From 7cdd3aef6eddfacbed044a7983791a3eb9261c6c Mon Sep 17 00:00:00 2001 From: Jin Huang Date: Thu, 23 Sep 2021 11:56:11 -0400 Subject: [PATCH 01/15] Fix ECCE Style --- common/ECCEStyle.C | 2300 +------------------------------------------- 1 file changed, 17 insertions(+), 2283 deletions(-) diff --git a/common/ECCEStyle.C b/common/ECCEStyle.C index a2d19816..b3aa712f 100644 --- a/common/ECCEStyle.C +++ b/common/ECCEStyle.C @@ -1,2288 +1,22 @@ +// +// @file ECCEStyle.h +// +// ECCE Style, based on a style file from ATLAS +// +// +// @author Peter Steinberg adapted from sPHENIX/ATLAS style +// +// Copyright (C) 2021 ECCE Collaboration +// +// Version 0.1 +#ifndef __ECCESTYLE_H +#define __ECCESTYLE_H +#include "TStyle.h" +void SetECCEStyle(); +TStyle* ECCEStyle(); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ecce-root-style/ECCEStyle.C at main · ecce-editorial/ecce-root-style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Skip to content - - - - - - - - - - -
- -
- - - - - - -
- - - -
- - - - - - - - - - -
-
-
- - - - - - - - - - -
- -
- -
-

- - - / - - ecce-root-style - - Public -

- - -
- -
    - -
  • - -
    - - - - - - - - Watch - - - - - -
    -
    -

    Notifications

    - -
    - -
    -
    - - - - - - - - -
    - - -
    -
    -
    - - -
    -
    - -
    - - - -
  • - -
  • -
    -
    - - -
    -
    - - -
    - -
  • - -
  • -
    -
    - - - Fork - - - -
    - -

    Fork ecce-root-style

    -
    - -
    - -
    -

    If this dialog fails to load, you can visit the fork page directly.

    -
    -
    - -
    -
    -
    - - -
  • -
- -
- -
-
- - - - -
- - - -
-
- - Open in github.dev - - - - - - - -
- - - - Permalink - - - -
- -
-
- - - main - - - - -
-
-
- Switch branches/tags - -
- - - -
- -
- -
- - -
- -
- - - - - - - - - - - - - - - - -
- - -
-
-
-
- -
- -
- - - - Go to file - - -
- - - - - - - - - -
-
-
- - - - -
- -
-
-
 
-
- -
-
 
- Cannot retrieve contributors at this time -
-
- - - - - - - - - - - - - -
- -
- - -
- - 117 lines (94 sloc) - - 3.37 KB -
- -
- - - -
- - - - - - - - - - - - - - - -
- -
-
- -
-
- -
- -
-
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// ECCE Style, based on a style file from BaBar, v0.1
//
-
#include <iostream>
-
#include "ECCEStyle.h"
-
#include "TROOT.h"
-
void SetECCEStyle ()
{
static TStyle* ecceStyle = 0;
std::cout << "ECCEStyle: Applying nominal settings." << std::endl ;
if ( ecceStyle==0 ) ecceStyle = ECCEStyle();
gROOT->SetStyle("ECCE");
gROOT->ForceStyle();
}
-
TStyle* ECCEStyle()
{
TStyle *ECCEStyle = new TStyle("ECCE","ECCE style");
-
// use plain black on white colors
Int_t icol=0; // WHITE
ECCEStyle->SetFrameBorderMode(icol);
ECCEStyle->SetFrameFillColor(icol);
ECCEStyle->SetCanvasBorderMode(icol);
ECCEStyle->SetCanvasColor(icol);
ECCEStyle->SetPadBorderMode(icol);
ECCEStyle->SetPadColor(icol);
ECCEStyle->SetStatColor(icol);
//ECCEStyle->SetFillColor(icol); // don't use: white fill color for *all* objects
-
// set the paper & margin sizes
ECCEStyle->SetPaperSize(20,26);
-
// set margin sizes
ECCEStyle->SetPadTopMargin(0.05);
ECCEStyle->SetPadRightMargin(0.05);
ECCEStyle->SetPadBottomMargin(0.16);
ECCEStyle->SetPadLeftMargin(0.16);
-
// set title offsets (for axis label)
ECCEStyle->SetTitleXOffset(1.4);
ECCEStyle->SetTitleYOffset(1.4);
-
// use large fonts
//Int_t font=72; // Helvetica italics
Int_t font=42; // Helvetica
Double_t tsize=0.05;
ECCEStyle->SetTextFont(font);
-
ECCEStyle->SetTextSize(tsize);
ECCEStyle->SetLabelFont(font,"x");
ECCEStyle->SetTitleFont(font,"x");
ECCEStyle->SetLabelFont(font,"y");
ECCEStyle->SetTitleFont(font,"y");
ECCEStyle->SetLabelFont(font,"z");
ECCEStyle->SetTitleFont(font,"z");
ECCEStyle->SetLabelSize(tsize,"x");
ECCEStyle->SetTitleSize(tsize,"x");
ECCEStyle->SetLabelSize(tsize,"y");
ECCEStyle->SetTitleSize(tsize,"y");
ECCEStyle->SetLabelSize(tsize,"z");
ECCEStyle->SetTitleSize(tsize,"z");
-
// use bold lines and markers
ECCEStyle->SetMarkerStyle(20);
ECCEStyle->SetMarkerSize(1.2);
ECCEStyle->SetHistLineWidth(2.);
ECCEStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
-
// get rid of X error bars
//ECCEStyle->SetErrorX(0.001);
// get rid of error bar caps
ECCEStyle->SetEndErrorSize(0.);
-
// do not display any of the standard histogram decorations
ECCEStyle->SetOptTitle(0);
//ECCEStyle->SetOptStat(1111);
ECCEStyle->SetOptStat(0);
//ECCEStyle->SetOptFit(1111);
ECCEStyle->SetOptFit(0);
-
// put tick marks on top and RHS of plots
ECCEStyle->SetPadTickX(1);
ECCEStyle->SetPadTickY(1);
-
// legend modificatin
ECCEStyle->SetLegendBorderSize(0);
ECCEStyle->SetLegendFillColor(0);
ECCEStyle->SetLegendFont(font);
-
-
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
std::cout << "ECCEStyle: ROOT6 mode" << std::endl;
ECCEStyle->SetLegendTextSize(tsize);
ECCEStyle->SetPalette(kBird);
#else
std::cout << "ECCEStyle: ROOT5 mode" << std::endl;
// color palette - manually define 'kBird' palette only available in ROOT 6
Int_t alpha = 0;
Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
#endif
-
ECCEStyle->SetNumberContours(80);
-
return ECCEStyle;
-
}
-
- - - -
- -
- - - - -
- - -
- - -
-
- - -
- - - -
-
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - +#endif // __ECCESTYLE_H From 212b27ff3ed0be738236f76873c3cdf79d8c1971 Mon Sep 17 00:00:00 2001 From: Jin Huang Date: Thu, 23 Sep 2021 11:56:29 -0400 Subject: [PATCH 02/15] Fix ECCE Style --- common/ECCEStyle.h | 2007 +++----------------------------------------- 1 file changed, 116 insertions(+), 1891 deletions(-) diff --git a/common/ECCEStyle.h b/common/ECCEStyle.h index 618d8f07..9784b68f 100644 --- a/common/ECCEStyle.h +++ b/common/ECCEStyle.h @@ -1,1891 +1,116 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ecce-root-style/ECCEStyle.h at main · ecce-editorial/ecce-root-style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- - - -
- - - - - - - - - - -
-
-
- - - - - - - - - - -
- -
- -
-

- - - / - - ecce-root-style - - Public -

- - -
- -
    - -
  • - -
    - - - - - - - - Watch - - - - - -
    -
    -

    Notifications

    - -
    - -
    -
    - - - - - - - - -
    - - -
    -
    -
    - - -
    -
    - -
    - - - -
  • - -
  • -
    -
    - - -
    -
    - - -
    - -
  • - -
  • -
    -
    - - - Fork - - - -
    - -

    Fork ecce-root-style

    -
    - -
    - -
    -

    If this dialog fails to load, you can visit the fork page directly.

    -
    -
    - -
    -
    -
    - - -
  • -
- -
- -
-
- - - - -
- - - -
-
- - Open in github.dev - - - - - - - -
- - - - Permalink - - - -
- -
-
- - - main - - - - -
-
-
- Switch branches/tags - -
- - - -
- -
- -
- - -
- -
- - - - - - - - - - - - - - - - -
- - -
-
-
-
- -
- -
- - - - Go to file - - -
- - - - - - - - - -
-
-
- - - - -
- -
-
-
 
-
- -
-
 
- Cannot retrieve contributors at this time -
-
- - - - - - - - - - - - - -
- -
- - -
- - 22 lines (17 sloc) - - 375 Bytes -
- -
- - - -
- - - - - - - - - - - - - - - -
- -
-
- -
-
- -
- -
-
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// @file ECCEStyle.h
//
// ECCE Style, based on a style file from ATLAS
//
//
// @author Peter Steinberg adapted from sPHENIX/ATLAS style
//
// Copyright (C) 2021 ECCE Collaboration
//
// Version 0.1
-
#ifndef __ECCESTYLE_H
#define __ECCESTYLE_H
-
#include "TStyle.h"
-
void SetECCEStyle();
-
TStyle* ECCEStyle();
-
#endif // __ECCESTYLE_H
- - - -
- -
- - - - -
- - -
- - -
-
- - -
- - - -
-
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - +// +// ECCE Style, based on a style file from BaBar, v0.1 +// + +#include + +#include "ECCEStyle.h" + +#include "TROOT.h" + +void SetECCEStyle () +{ + static TStyle* ecceStyle = 0; + std::cout << "ECCEStyle: Applying nominal settings." << std::endl ; + if ( ecceStyle==0 ) ecceStyle = ECCEStyle(); + gROOT->SetStyle("ECCE"); + gROOT->ForceStyle(); +} + +TStyle* ECCEStyle() +{ + TStyle *ECCEStyle = new TStyle("ECCE","ECCE style"); + + // use plain black on white colors + Int_t icol=0; // WHITE + ECCEStyle->SetFrameBorderMode(icol); + ECCEStyle->SetFrameFillColor(icol); + ECCEStyle->SetCanvasBorderMode(icol); + ECCEStyle->SetCanvasColor(icol); + ECCEStyle->SetPadBorderMode(icol); + ECCEStyle->SetPadColor(icol); + ECCEStyle->SetStatColor(icol); + //ECCEStyle->SetFillColor(icol); // don't use: white fill color for *all* objects + + // set the paper & margin sizes + ECCEStyle->SetPaperSize(20,26); + + // set margin sizes + ECCEStyle->SetPadTopMargin(0.05); + ECCEStyle->SetPadRightMargin(0.05); + ECCEStyle->SetPadBottomMargin(0.16); + ECCEStyle->SetPadLeftMargin(0.16); + + // set title offsets (for axis label) + ECCEStyle->SetTitleXOffset(1.4); + ECCEStyle->SetTitleYOffset(1.4); + + // use large fonts + //Int_t font=72; // Helvetica italics + Int_t font=42; // Helvetica + Double_t tsize=0.05; + ECCEStyle->SetTextFont(font); + + ECCEStyle->SetTextSize(tsize); + ECCEStyle->SetLabelFont(font,"x"); + ECCEStyle->SetTitleFont(font,"x"); + ECCEStyle->SetLabelFont(font,"y"); + ECCEStyle->SetTitleFont(font,"y"); + ECCEStyle->SetLabelFont(font,"z"); + ECCEStyle->SetTitleFont(font,"z"); + + ECCEStyle->SetLabelSize(tsize,"x"); + ECCEStyle->SetTitleSize(tsize,"x"); + ECCEStyle->SetLabelSize(tsize,"y"); + ECCEStyle->SetTitleSize(tsize,"y"); + ECCEStyle->SetLabelSize(tsize,"z"); + ECCEStyle->SetTitleSize(tsize,"z"); + + // use bold lines and markers + ECCEStyle->SetMarkerStyle(20); + ECCEStyle->SetMarkerSize(1.2); + ECCEStyle->SetHistLineWidth(2.); + ECCEStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes + + // get rid of X error bars + //ECCEStyle->SetErrorX(0.001); + // get rid of error bar caps + ECCEStyle->SetEndErrorSize(0.); + + // do not display any of the standard histogram decorations + ECCEStyle->SetOptTitle(0); + //ECCEStyle->SetOptStat(1111); + ECCEStyle->SetOptStat(0); + //ECCEStyle->SetOptFit(1111); + ECCEStyle->SetOptFit(0); + + // put tick marks on top and RHS of plots + ECCEStyle->SetPadTickX(1); + ECCEStyle->SetPadTickY(1); + + // legend modificatin + ECCEStyle->SetLegendBorderSize(0); + ECCEStyle->SetLegendFillColor(0); + ECCEStyle->SetLegendFont(font); + + +#if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0) + std::cout << "ECCEStyle: ROOT6 mode" << std::endl; + ECCEStyle->SetLegendTextSize(tsize); + ECCEStyle->SetPalette(kBird); +#else + std::cout << "ECCEStyle: ROOT5 mode" << std::endl; + // color palette - manually define 'kBird' palette only available in ROOT 6 + Int_t alpha = 0; + Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000}; + Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764}; + Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832}; + Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539}; + TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha); +#endif + + ECCEStyle->SetNumberContours(80); + + return ECCEStyle; + +} From 6b4716c3b5b54c863ed3f4c01041784043a7ee4a Mon Sep 17 00:00:00 2001 From: Jin Huang Date: Thu, 23 Sep 2021 12:17:21 -0400 Subject: [PATCH 03/15] Fix ECCE style - round 2 --- common/ECCEStyle.h | 124 ++++++--------------------------------------- 1 file changed, 15 insertions(+), 109 deletions(-) diff --git a/common/ECCEStyle.h b/common/ECCEStyle.h index 9784b68f..b3aa712f 100644 --- a/common/ECCEStyle.h +++ b/common/ECCEStyle.h @@ -1,116 +1,22 @@ // -// ECCE Style, based on a style file from BaBar, v0.1 +// @file ECCEStyle.h +// +// ECCE Style, based on a style file from ATLAS // +// +// @author Peter Steinberg adapted from sPHENIX/ATLAS style +// +// Copyright (C) 2021 ECCE Collaboration +// +// Version 0.1 -#include - -#include "ECCEStyle.h" - -#include "TROOT.h" - -void SetECCEStyle () -{ - static TStyle* ecceStyle = 0; - std::cout << "ECCEStyle: Applying nominal settings." << std::endl ; - if ( ecceStyle==0 ) ecceStyle = ECCEStyle(); - gROOT->SetStyle("ECCE"); - gROOT->ForceStyle(); -} - -TStyle* ECCEStyle() -{ - TStyle *ECCEStyle = new TStyle("ECCE","ECCE style"); - - // use plain black on white colors - Int_t icol=0; // WHITE - ECCEStyle->SetFrameBorderMode(icol); - ECCEStyle->SetFrameFillColor(icol); - ECCEStyle->SetCanvasBorderMode(icol); - ECCEStyle->SetCanvasColor(icol); - ECCEStyle->SetPadBorderMode(icol); - ECCEStyle->SetPadColor(icol); - ECCEStyle->SetStatColor(icol); - //ECCEStyle->SetFillColor(icol); // don't use: white fill color for *all* objects - - // set the paper & margin sizes - ECCEStyle->SetPaperSize(20,26); - - // set margin sizes - ECCEStyle->SetPadTopMargin(0.05); - ECCEStyle->SetPadRightMargin(0.05); - ECCEStyle->SetPadBottomMargin(0.16); - ECCEStyle->SetPadLeftMargin(0.16); - - // set title offsets (for axis label) - ECCEStyle->SetTitleXOffset(1.4); - ECCEStyle->SetTitleYOffset(1.4); - - // use large fonts - //Int_t font=72; // Helvetica italics - Int_t font=42; // Helvetica - Double_t tsize=0.05; - ECCEStyle->SetTextFont(font); - - ECCEStyle->SetTextSize(tsize); - ECCEStyle->SetLabelFont(font,"x"); - ECCEStyle->SetTitleFont(font,"x"); - ECCEStyle->SetLabelFont(font,"y"); - ECCEStyle->SetTitleFont(font,"y"); - ECCEStyle->SetLabelFont(font,"z"); - ECCEStyle->SetTitleFont(font,"z"); - - ECCEStyle->SetLabelSize(tsize,"x"); - ECCEStyle->SetTitleSize(tsize,"x"); - ECCEStyle->SetLabelSize(tsize,"y"); - ECCEStyle->SetTitleSize(tsize,"y"); - ECCEStyle->SetLabelSize(tsize,"z"); - ECCEStyle->SetTitleSize(tsize,"z"); - - // use bold lines and markers - ECCEStyle->SetMarkerStyle(20); - ECCEStyle->SetMarkerSize(1.2); - ECCEStyle->SetHistLineWidth(2.); - ECCEStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes - - // get rid of X error bars - //ECCEStyle->SetErrorX(0.001); - // get rid of error bar caps - ECCEStyle->SetEndErrorSize(0.); - - // do not display any of the standard histogram decorations - ECCEStyle->SetOptTitle(0); - //ECCEStyle->SetOptStat(1111); - ECCEStyle->SetOptStat(0); - //ECCEStyle->SetOptFit(1111); - ECCEStyle->SetOptFit(0); - - // put tick marks on top and RHS of plots - ECCEStyle->SetPadTickX(1); - ECCEStyle->SetPadTickY(1); - - // legend modificatin - ECCEStyle->SetLegendBorderSize(0); - ECCEStyle->SetLegendFillColor(0); - ECCEStyle->SetLegendFont(font); - +#ifndef __ECCESTYLE_H +#define __ECCESTYLE_H -#if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0) - std::cout << "ECCEStyle: ROOT6 mode" << std::endl; - ECCEStyle->SetLegendTextSize(tsize); - ECCEStyle->SetPalette(kBird); -#else - std::cout << "ECCEStyle: ROOT5 mode" << std::endl; - // color palette - manually define 'kBird' palette only available in ROOT 6 - Int_t alpha = 0; - Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000}; - Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764}; - Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832}; - Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539}; - TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha); -#endif +#include "TStyle.h" - ECCEStyle->SetNumberContours(80); +void SetECCEStyle(); - return ECCEStyle; +TStyle* ECCEStyle(); -} +#endif // __ECCESTYLE_H From f1a5afbbaf2551c22d27ec379a0d807d223e0b2b Mon Sep 17 00:00:00 2001 From: Jin Huang Date: Thu, 23 Sep 2021 12:17:40 -0400 Subject: [PATCH 04/15] Fix ECCE style - round 2 --- common/ECCEStyle.C | 124 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 109 insertions(+), 15 deletions(-) diff --git a/common/ECCEStyle.C b/common/ECCEStyle.C index b3aa712f..9784b68f 100644 --- a/common/ECCEStyle.C +++ b/common/ECCEStyle.C @@ -1,22 +1,116 @@ // -// @file ECCEStyle.h -// -// ECCE Style, based on a style file from ATLAS +// ECCE Style, based on a style file from BaBar, v0.1 // -// -// @author Peter Steinberg adapted from sPHENIX/ATLAS style -// -// Copyright (C) 2021 ECCE Collaboration -// -// Version 0.1 -#ifndef __ECCESTYLE_H -#define __ECCESTYLE_H +#include + +#include "ECCEStyle.h" + +#include "TROOT.h" + +void SetECCEStyle () +{ + static TStyle* ecceStyle = 0; + std::cout << "ECCEStyle: Applying nominal settings." << std::endl ; + if ( ecceStyle==0 ) ecceStyle = ECCEStyle(); + gROOT->SetStyle("ECCE"); + gROOT->ForceStyle(); +} + +TStyle* ECCEStyle() +{ + TStyle *ECCEStyle = new TStyle("ECCE","ECCE style"); + + // use plain black on white colors + Int_t icol=0; // WHITE + ECCEStyle->SetFrameBorderMode(icol); + ECCEStyle->SetFrameFillColor(icol); + ECCEStyle->SetCanvasBorderMode(icol); + ECCEStyle->SetCanvasColor(icol); + ECCEStyle->SetPadBorderMode(icol); + ECCEStyle->SetPadColor(icol); + ECCEStyle->SetStatColor(icol); + //ECCEStyle->SetFillColor(icol); // don't use: white fill color for *all* objects + + // set the paper & margin sizes + ECCEStyle->SetPaperSize(20,26); + + // set margin sizes + ECCEStyle->SetPadTopMargin(0.05); + ECCEStyle->SetPadRightMargin(0.05); + ECCEStyle->SetPadBottomMargin(0.16); + ECCEStyle->SetPadLeftMargin(0.16); + + // set title offsets (for axis label) + ECCEStyle->SetTitleXOffset(1.4); + ECCEStyle->SetTitleYOffset(1.4); + + // use large fonts + //Int_t font=72; // Helvetica italics + Int_t font=42; // Helvetica + Double_t tsize=0.05; + ECCEStyle->SetTextFont(font); + + ECCEStyle->SetTextSize(tsize); + ECCEStyle->SetLabelFont(font,"x"); + ECCEStyle->SetTitleFont(font,"x"); + ECCEStyle->SetLabelFont(font,"y"); + ECCEStyle->SetTitleFont(font,"y"); + ECCEStyle->SetLabelFont(font,"z"); + ECCEStyle->SetTitleFont(font,"z"); + + ECCEStyle->SetLabelSize(tsize,"x"); + ECCEStyle->SetTitleSize(tsize,"x"); + ECCEStyle->SetLabelSize(tsize,"y"); + ECCEStyle->SetTitleSize(tsize,"y"); + ECCEStyle->SetLabelSize(tsize,"z"); + ECCEStyle->SetTitleSize(tsize,"z"); + + // use bold lines and markers + ECCEStyle->SetMarkerStyle(20); + ECCEStyle->SetMarkerSize(1.2); + ECCEStyle->SetHistLineWidth(2.); + ECCEStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes + + // get rid of X error bars + //ECCEStyle->SetErrorX(0.001); + // get rid of error bar caps + ECCEStyle->SetEndErrorSize(0.); + + // do not display any of the standard histogram decorations + ECCEStyle->SetOptTitle(0); + //ECCEStyle->SetOptStat(1111); + ECCEStyle->SetOptStat(0); + //ECCEStyle->SetOptFit(1111); + ECCEStyle->SetOptFit(0); + + // put tick marks on top and RHS of plots + ECCEStyle->SetPadTickX(1); + ECCEStyle->SetPadTickY(1); + + // legend modificatin + ECCEStyle->SetLegendBorderSize(0); + ECCEStyle->SetLegendFillColor(0); + ECCEStyle->SetLegendFont(font); + -#include "TStyle.h" +#if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0) + std::cout << "ECCEStyle: ROOT6 mode" << std::endl; + ECCEStyle->SetLegendTextSize(tsize); + ECCEStyle->SetPalette(kBird); +#else + std::cout << "ECCEStyle: ROOT5 mode" << std::endl; + // color palette - manually define 'kBird' palette only available in ROOT 6 + Int_t alpha = 0; + Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000}; + Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764}; + Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832}; + Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539}; + TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha); +#endif -void SetECCEStyle(); + ECCEStyle->SetNumberContours(80); -TStyle* ECCEStyle(); + return ECCEStyle; -#endif // __ECCESTYLE_H +} From c900cf0f2b6cc0cda035cdc5cf9789d13067e8e9 Mon Sep 17 00:00:00 2001 From: billlee77 Date: Fri, 1 Oct 2021 12:35:58 -0400 Subject: [PATCH 05/15] Fixed the issue of gradient field not scaling issue (#72) * Flipped IP6 Far Forward detector stacks, include position, angle and field * flip crossing sign in HepMC event gen * flip crossing sign in beam chambers * before merging * Added the far backward region into Fun4all * Fixed a few issues suggested by Jin * Implemented the designed IP8 detector location * Extended the farbackward vaccum enclosure to include maximum path * fix overlap of world vol. * Updated IP6 detector location, and unflipped the x coord, angle, and field * Added the far forward evaluator * Adding FFR evaluator * void * Updated the IP8 configuration and main macro to include forward Eval * Fixed IP8 changes which were not merge into the master * Added the virtual detector in the farbackward region * Added the B0 detector models in the Fun4all There are three choices: 1. Real detector stack 2. Disk plane to help occupancy study 3. Hit planes replicating the real detector goemetry * Added the B0 detector * Fixed the issue for gradient field not scaling Co-authored-by: Jin Huang --- common/G4_hFarFwdBeamLine_EIC.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/G4_hFarFwdBeamLine_EIC.C b/common/G4_hFarFwdBeamLine_EIC.C index 6f228264..6d684dc6 100644 --- a/common/G4_hFarFwdBeamLine_EIC.C +++ b/common/G4_hFarFwdBeamLine_EIC.C @@ -234,7 +234,8 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) if( Enable::HFARFWD_ION_ENERGY != 275 ) { float scaleFactor = Enable::HFARFWD_ION_ENERGY / 275. ; dipole_field_x = dipole_field_x*scaleFactor; - } + fieldgradient = fieldgradient*scaleFactor; + } if (magnetlist.empty() || magnetlist.find(imagnet) != magnetlist.end()) { From 562f21633f9c35ca1805d59b89720f19d9563168 Mon Sep 17 00:00:00 2001 From: billlee77 Date: Thu, 7 Oct 2021 09:29:14 -0400 Subject: [PATCH 06/15] Setting forward and backward enclosure and magnets to active (#73) * Flipped IP6 Far Forward detector stacks, include position, angle and field * flip crossing sign in HepMC event gen * flip crossing sign in beam chambers * before merging * Added the far backward region into Fun4all * Fixed a few issues suggested by Jin * Implemented the designed IP8 detector location * Extended the farbackward vaccum enclosure to include maximum path * fix overlap of world vol. * Updated IP6 detector location, and unflipped the x coord, angle, and field * Added the far forward evaluator * Adding FFR evaluator * void * Updated the IP8 configuration and main macro to include forward Eval * Fixed IP8 changes which were not merge into the master * Added the virtual detector in the farbackward region * Added the B0 detector models in the Fun4all There are three choices: 1. Real detector stack 2. Disk plane to help occupancy study 3. Hit planes replicating the real detector goemetry * Added the B0 detector * Fixed the issue for gradient field not scaling * Setting Forward/backward enclosure and magnets to active * Fixed B0 Orientiion for IP6 and IP8; IP8 1st RP with 5cm radius hole Co-authored-by: Jin Huang --- common/G4_hFarBwdBeamLine_EIC.C | 1 + common/G4_hFarFwdBeamLine_EIC.C | 303 ++++++++++++++++++++++++++++---- 2 files changed, 268 insertions(+), 36 deletions(-) diff --git a/common/G4_hFarBwdBeamLine_EIC.C b/common/G4_hFarBwdBeamLine_EIC.C index 761bad31..6d9ab585 100644 --- a/common/G4_hFarBwdBeamLine_EIC.C +++ b/common/G4_hFarBwdBeamLine_EIC.C @@ -108,6 +108,7 @@ void hFarBwdDefineMagnets(PHG4Reco *g4Reco) hFarBwdBeamLine::hFarBwdBeamLineEnclosure->set_string_param("material", "G4_Galactic"); hFarBwdBeamLine::hFarBwdBeamLineEnclosure->set_color(.5, .5, .5, 0.2); hFarBwdBeamLine::hFarBwdBeamLineEnclosure->OverlapCheck(overlapCheck); + hFarBwdBeamLine::hFarBwdBeamLineEnclosure->SetActive(); if (verbosity) hFarBwdBeamLine::hFarBwdBeamLineEnclosure->Verbosity(verbosity); g4Reco->registerSubsystem(hFarBwdBeamLine::hFarBwdBeamLineEnclosure); diff --git a/common/G4_hFarFwdBeamLine_EIC.C b/common/G4_hFarFwdBeamLine_EIC.C index 6d684dc6..4bdd2353 100644 --- a/common/G4_hFarFwdBeamLine_EIC.C +++ b/common/G4_hFarFwdBeamLine_EIC.C @@ -114,6 +114,7 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) hFarFwdBeamLine::hFarFwdBeamLineEnclosure->set_string_param("material", "G4_Galactic"); hFarFwdBeamLine::hFarFwdBeamLineEnclosure->set_color(.5, .5, .5, 0.2); hFarFwdBeamLine::hFarFwdBeamLineEnclosure->OverlapCheck(overlapCheck); + hFarFwdBeamLine::hFarFwdBeamLineEnclosure->SetActive(); if (verbosity) hFarFwdBeamLine::hFarFwdBeamLineEnclosure->Verbosity(verbosity); g4Reco->registerSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); @@ -134,7 +135,7 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) } // make magnet active volume if you want to study the hits - bool magnet_active = false; + bool magnet_active = true; int absorberactive = 0; // if you insert numbers it only displays those magnets, do not comment out the set declaration @@ -235,7 +236,7 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) float scaleFactor = Enable::HFARFWD_ION_ENERGY / 275. ; dipole_field_x = dipole_field_x*scaleFactor; fieldgradient = fieldgradient*scaleFactor; - } + } if (magnetlist.empty() || magnetlist.find(imagnet) != magnetlist.end()) { @@ -255,6 +256,7 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) bl->set_double_param("inner_radius", inner_radius_zin); bl->set_double_param("outer_radius", outer_magnet_diameter / 2.); bl->SetActive(magnet_active); + bl->SetAbsorberActive(); bl->BlackHole(); bl->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); if (absorberactive) @@ -399,7 +401,7 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) // Choice 1 realistic detector const int b0DetNr = 4; - const double b0Mag_zCent = 590; + const double b0Mag_zCent = 640; const double b0Mag_zLen = 120; const double b0Cu_zLen = .2; //B0 dead material length const double b0Si_zLen = .1; //B0 Si length @@ -552,7 +554,7 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) /// Choice 3 Hit planes with real detector geometry const int b0DetNr = 4; - const double b0Mag_zCent = 590; + const double b0Mag_zCent = 640; const double b0Mag_zLen = 120; const double b0Cu_zLen = .2; //B0 dead material length const double b0Si_zLen = .1; //B0 Si length @@ -563,8 +565,9 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) const double b0_radius = 20.0; //outer radius of B0-detector const double spanning_angle = 240; //spanning angle Packman const double b0Ecal_z = 48; - double start_angle = spanning_angle - 360; //start angle Packman - +// double start_angle = spanning_angle - 360; //start angle Packman + double start_angle = spanning_angle - 180; //start angle Packman + for (int i = 0; i < b0DetNr; i++) { auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); @@ -681,16 +684,32 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) for (int i = 0; i < rpDetNr; i++) { - auto *detRP = new PHG4BlockSubsystem(Form("rpTruth_%d", i), i); - detRP->SuperDetector("rpTruth"); - detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); - detRP->set_double_param("place_y", 0); - detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); - detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); - detRP->set_double_param("size_x", 25); // Original design specification - detRP->set_double_param("size_y", 20); // Original design specification - detRP->set_double_param("size_z", 0.03); - detRP->set_string_param("material", "G4_Si"); + + // Circular disk design (16cm in) + auto *detRP = new PHG4CylinderSubsystem(Form("rpTruth_%d", i), i); + detRP->SuperDetector("rpTruth"); + detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_y", 0); + detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); + detRP->set_double_param("radius", 5); + detRP->set_double_param("thickness", 10); // 16 cm circulr to cover 25cm x20cm square (IR design) + detRP->set_double_param("length", 0.03); + detRP->set_string_param("material", "G4_Si"); + +// //------------------------------------ +// /// Square Design +// auto *detRP = new PHG4BlockSubsystem(Form("rpTruth_%d", i), i); +// detRP->SuperDetector("rpTruth"); +// detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); +// detRP->set_double_param("place_y", 0); +// detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); +// detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); +// detRP->set_double_param("size_x", 25); // Original design specification +// detRP->set_double_param("size_y", 20); // Original design specification +// detRP->set_double_param("size_z", 0.03); +// detRP->set_string_param("material", "G4_Si"); + detRP->OverlapCheck(overlapCheck); detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); detRP->SetActive(); @@ -731,26 +750,238 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) std::cout << "B0Magnet can be mother = " << hFarFwdBeamLine::B0Magnet->CanBeMotherSubsystem() << std::endl; } - const int b0DetNr = 4; - const double b0Mag_zCent = 610; - const double b0Mag_zLen = 120; - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("radius", 0); - detB0->set_double_param("thickness", 20); - detB0->set_double_param("length", 0.1); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("place_y", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - detB0->SetActive(true); - if (verbosity) - detB0->Verbosity(verbosity); - g4Reco->registerSubsystem(detB0); - } + //--------------------------------- + // B0 implementation + // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry + + if (Enable::B0_DISABLE_HITPLANE) { + + // Choice 1 realistic detector + + const int b0DetNr = 4; + +// const double b0Mag_zCent = 590; +// const double b0Mag_zLen = 120; + + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + + const double b0Cu_zLen = .2; //B0 dead material length + const double b0Si_zLen = .1; //B0 Si length + const double b0Ecal_zLen = 20.; //B0 Ecal length + const double pipe_hole = 5.0; //detector cut off for beam pipe + const double pipe_x = 3.4; //pipe hole position + const double d_radius = 7.0; //detector cut off Packman + const double b0_radius = 24.5; //outer radius of B0-detector + const double spanning_angle = 240; //spanning angle Packman + const double b0Ecal_z = 48; + double start_angle = spanning_angle - 360; //start angle Packman + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); + // detB0->set_int_param("ispipe", 0); //for future pipe implementation + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid",2*i); + detB0->set_double_param("startAngle",start_angle); + detB0->set_double_param("spanningAngle",spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); + + auto *detB0e = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i+1), 2*i+1); + detB0e->SuperDetector("b0Truth"); + // detB0e->set_int_param("ispipe", 0); //for future pipe implementation + detB0e->set_double_param("pipe_hole", pipe_hole); + detB0e->set_double_param("place_x", 0); + detB0e->set_double_param("place_y", 0); + detB0e->set_double_param("d_radius", d_radius); + detB0e->set_double_param("pipe_x", pipe_x); + detB0e->set_double_param("pipe_y", 0); + detB0e->set_double_param("pipe_z", 0); + detB0e->set_double_param("outer_radius", b0_radius); + detB0e->set_double_param("length", b0Cu_zLen); + detB0e->set_string_param("material", "G4_Cu"); + detB0e->set_double_param("detid",2*i+1); + detB0e->set_double_param("startAngle",start_angle); + detB0e->set_double_param("spanningAngle",spanning_angle); + detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) +(b0Cu_zLen+b0Si_zLen)/2) ); // relative to B0 magnet + detB0e->SetActive(true); + if (verbosity) + detB0e->Verbosity(verbosity); + detB0e->OverlapCheck(overlapCheck); + detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0e); + } + + auto *B0Ecal = new EICG4B0Subsystem("B0Ecal", 2*b0DetNr); + B0Ecal->SuperDetector("b0Truth"); + // B0Ecal->set_int_param("ispipe", 0); //for future pipe implementation + B0Ecal->set_double_param("pipe_hole", pipe_hole); + B0Ecal->set_double_param("place_x", 0); + B0Ecal->set_double_param("place_y", 0); + B0Ecal->set_double_param("place_z", b0Ecal_z); + B0Ecal->set_double_param("pipe_x", pipe_x); + B0Ecal->set_double_param("pipe_y", 0); + B0Ecal->set_double_param("pipe_z", 0); + B0Ecal->set_double_param("length", b0Ecal_zLen); + B0Ecal->set_double_param("outer_radius", b0_radius); + B0Ecal->set_double_param("d_radius", d_radius); + B0Ecal->set_string_param("material", "G4_PbWO4"); + B0Ecal->set_double_param("startAngle",start_angle); + B0Ecal->set_double_param("spanningAngle",spanning_angle); + B0Ecal->set_double_param("detid",2*b0DetNr); + B0Ecal->SetActive(true); + if (verbosity) + B0Ecal->Verbosity(verbosity); + B0Ecal->OverlapCheck(overlapCheck); + B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecal); + + auto *B0Ecale = new EICG4B0Subsystem("B0Ecale", 2*b0DetNr + 1); + B0Ecal->SuperDetector("b0Truth"); + // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation + B0Ecale->set_double_param("pipe_hole", pipe_hole); + B0Ecale->set_double_param("place_x", 0); + B0Ecale->set_double_param("place_y", 0); + B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen)/2); + B0Ecale->set_double_param("pipe_x", pipe_x); + B0Ecale->set_double_param("pipe_y", 0); + B0Ecale->set_double_param("pipe_z", 0); + B0Ecale->set_double_param("length", b0Cu_zLen); + B0Ecale->set_double_param("d_radius", d_radius); + B0Ecale->set_double_param("outer_radius", b0_radius); + B0Ecale->set_string_param("material", "G4_Cu"); + B0Ecale->set_double_param("startAngle",start_angle); + B0Ecale->set_double_param("spanningAngle",spanning_angle); + B0Ecale->set_double_param("detid",2*b0DetNr+1); + B0Ecale->SetActive(true); + if (verbosity) + B0Ecale->Verbosity(verbosity); + B0Ecale->OverlapCheck(overlapCheck); + B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecale); + + } else { + + if (Enable::B0_FULLHITPLANE) { + + // Choice 2 circular hit planes + + const int b0DetNr = 4; + + // Sep 09 2021 by Bill: + // B0 magnet center location in z: 610 + // B0 place location in z after 50cm shift: + // B0 layers has the same x coordinate: -14.57 + + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("radius", 0); + detB0->set_double_param("thickness", 20); + detB0->set_double_param("length", 0.1); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + + g4Reco->registerSubsystem(detB0); + + } + + } else { + + /// Fun4All default B0 planes + /// Choice 3 Hit planes with real detector geometry + + const int b0DetNr = 4; + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + const double b0Cu_zLen = .2; //B0 dead material length + const double b0Si_zLen = .1; //B0 Si length + const double b0Ecal_zLen = 20.; //B0 Ecal length + const double pipe_hole = 5.0; //detector cut off for beam pipe +// const double pipe_x = -3.4; //pipe hole position + const double pipe_x = 1.0; //pipe hole position + const double d_radius = 7.0; //detector cut off Packman + const double b0_radius = 24; //outer radius of B0-detector + const double spanning_angle = 240; //spanning angle Packman + const double b0Ecal_z = 48; + double start_angle = spanning_angle - 360; //start angle Packman + + for (int i = 0; i < b0DetNr; i++) { + + auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); + // detB0->set_int_param("ispipe", 0); //for future pipe implementation + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid",2*i); + detB0->set_double_param("startAngle",start_angle); + detB0->set_double_param("spanningAngle",spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); + } + + } + } + +// const int b0DetNr = 4; +// const double b0Mag_zCent = 610; +// const double b0Mag_zLen = 120; +// for (int i = 0; i < b0DetNr; i++) +// { +// auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); +// detB0->SuperDetector("b0Truth"); +// detB0->set_double_param("radius", 0); +// detB0->set_double_param("thickness", 20); +// detB0->set_double_param("length", 0.1); +// detB0->set_string_param("material", "G4_Si"); +// detB0->set_double_param("place_y", 0); +// detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); +// detB0->OverlapCheck(overlapCheck); +// detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); +// detB0->SetActive(true); +// if (verbosity) +// detB0->Verbosity(verbosity); +// g4Reco->registerSubsystem(detB0); +// } + } void hFarFwdDefineBeamPipe(PHG4Reco *g4Reco) From ac31a43bec59f50044e4bdbd947f6f75ae08457f Mon Sep 17 00:00:00 2001 From: cdean-github <59485912+cdean-github@users.noreply.github.com> Date: Thu, 7 Oct 2021 07:30:45 -0600 Subject: [PATCH 07/15] Updated Event Eval (#74) * Updated G4_EventEvaluator.C to work with new libraries * Updated G4_hFarFwd to point to new magnet file * Updated EventEval for new PR * FIxing overlaps * Reverting changes made by merge to production branch * Hash was changed to 'a', fixed * Added Tristan's clusteriser to macros * Missing / in setup * Pushed inner barrel tracker behind last vtx layer * Update G4_EventEvaluator.C * Update Fun4All_G4_EICDetector.C --- common/G4_EventEvaluator.C | 7 ++++--- detectors/EICDetector/Fun4All_G4_EICDetector.C | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/G4_EventEvaluator.C b/common/G4_EventEvaluator.C index 3209f030..43195eaa 100644 --- a/common/G4_EventEvaluator.C +++ b/common/G4_EventEvaluator.C @@ -11,6 +11,8 @@ namespace Enable { // use Enable::EVENT_EVAL = true; in your macro bool EVENT_EVAL = false; + bool EVENT_EVAL_DO_HEPMC = false; + bool EVENT_EVAL_DO_EVT_LVL = false; } // namespace Enable namespace EVENT_EVALUATOR @@ -49,9 +51,8 @@ void Event_Eval(const std::string &filename) if (Enable::BECAL) eval->set_do_BECAL(true); eval->set_do_MCPARTICLES(true); - eval->set_do_HEPMC(Input::PYTHIA6 or Input::PYTHIA8 or Input::SARTRE or Input::HEPMC - or Input::READEIC ); - eval->set_do_store_event_level_info( Input::PYTHIA6 or Input::PYTHIA8 or Input::READEIC ); + eval->set_do_HEPMC(Enable::EVENT_EVAL_DO_HEPMC); + eval->set_do_store_event_level_info(Enable::EVENT_EVAL_DO_EVT_LVL); se->registerSubsystem(eval); return; diff --git a/detectors/EICDetector/Fun4All_G4_EICDetector.C b/detectors/EICDetector/Fun4All_G4_EICDetector.C index 2a6063b3..0f35a088 100644 --- a/detectors/EICDetector/Fun4All_G4_EICDetector.C +++ b/detectors/EICDetector/Fun4All_G4_EICDetector.C @@ -403,6 +403,8 @@ int Fun4All_G4_EICDetector( Enable::EVENT_EVAL = true; // EVENT_EVALUATOR::Verbosity = 1; // EVENT_EVALUATOR::EnergyThreshold = 0.05; // GeV + Enable::EVENT_EVAL_DO_HEPMC = Input::PYTHIA6 or Input::PYTHIA8 or Input::SARTRE or Input::HEPMC or Input::READEIC; + Enable::EVENT_EVAL_DO_EVT_LVL = Input::PYTHIA6 or Input::PYTHIA8 or Input::READEIC; //Enable::USER = true; From c55655c4e8b966ad061c6c63acc327e6b9aaf217 Mon Sep 17 00:00:00 2001 From: billlee77 Date: Thu, 7 Oct 2021 17:26:46 -0400 Subject: [PATCH 08/15] Magnet set to active and B0 madifications (#75) * Flipped IP6 Far Forward detector stacks, include position, angle and field * flip crossing sign in HepMC event gen * flip crossing sign in beam chambers * before merging * Added the far backward region into Fun4all * Fixed a few issues suggested by Jin * Implemented the designed IP8 detector location * Extended the farbackward vaccum enclosure to include maximum path * fix overlap of world vol. * Updated IP6 detector location, and unflipped the x coord, angle, and field * Added the far forward evaluator * Adding FFR evaluator * void * Updated the IP8 configuration and main macro to include forward Eval * Fixed IP8 changes which were not merge into the master * Added the virtual detector in the farbackward region * Added the B0 detector models in the Fun4all There are three choices: 1. Real detector stack 2. Disk plane to help occupancy study 3. Hit planes replicating the real detector goemetry * Added the B0 detector * Fixed the issue for gradient field not scaling * Setting Forward/backward enclosure and magnets to active * Fixed B0 Orientiion for IP6 and IP8; IP8 1st RP with 5cm radius hole * Improved B0 geometry based on Sasha's suggestion * Reformatted G4_hFarFwdBeamLine_EIC.C style Co-authored-by: Jin Huang Co-authored-by: cdean-github Co-authored-by: cdean-github <59485912+cdean-github@users.noreply.github.com> --- common/G4_hFarFwdBeamLine_EIC.C | 990 ++++++++++++++++---------------- 1 file changed, 492 insertions(+), 498 deletions(-) diff --git a/common/G4_hFarFwdBeamLine_EIC.C b/common/G4_hFarFwdBeamLine_EIC.C index 4bdd2353..90795c1f 100644 --- a/common/G4_hFarFwdBeamLine_EIC.C +++ b/common/G4_hFarFwdBeamLine_EIC.C @@ -174,10 +174,10 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) } else { - //------------------------ - //Select only the magnet component in the far forward region - if (z < 0.0) - continue; + //------------------------ + //Select only the magnet component in the far forward region + if (z < 0.0) + continue; string magtype; if (inner_radius_zin != inner_radius_zout) @@ -230,12 +230,13 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) outer_magnet_diameter *= 100.; angle = (angle / TMath::Pi() * 180.) / 1000.; // given in mrad - //------------------------ - // Linearly scaling down the magnetic field for lower energy proton - if( Enable::HFARFWD_ION_ENERGY != 275 ) { - float scaleFactor = Enable::HFARFWD_ION_ENERGY / 275. ; - dipole_field_x = dipole_field_x*scaleFactor; - fieldgradient = fieldgradient*scaleFactor; + //------------------------ + // Linearly scaling down the magnetic field for lower energy proton + if (Enable::HFARFWD_ION_ENERGY != 275) + { + float scaleFactor = Enable::HFARFWD_ION_ENERGY / 275.; + dipole_field_x = dipole_field_x * scaleFactor; + fieldgradient = fieldgradient * scaleFactor; } if (magnetlist.empty() || magnetlist.find(imagnet) != magnetlist.end()) @@ -245,14 +246,14 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) bl->set_double_param("fieldgradient", MagFieldFlip(fieldgradient)); bl->set_string_param("magtype", magtype); bl->set_double_param("length", length); - bl->set_double_param("place_x", PosFlip(x));// relative position to mother vol. - bl->set_double_param("place_y", y);// relative position to mother vol. - bl->set_double_param("place_z", z - hFarFwdBeamLine::enclosure_center);// relative position to mother vol. - bl->set_double_param("field_global_position_x", PosFlip(x));// abs. position to world for field manager - bl->set_double_param("field_global_position_y", y);// abs. position to world for field manager - bl->set_double_param("field_global_position_z", z);// abs. position to world for field manager + bl->set_double_param("place_x", PosFlip(x)); // relative position to mother vol. + bl->set_double_param("place_y", y); // relative position to mother vol. + bl->set_double_param("place_z", z - hFarFwdBeamLine::enclosure_center); // relative position to mother vol. + bl->set_double_param("field_global_position_x", PosFlip(x)); // abs. position to world for field manager + bl->set_double_param("field_global_position_y", y); // abs. position to world for field manager + bl->set_double_param("field_global_position_z", z); // abs. position to world for field manager bl->set_double_param("rot_y", AngleFlip(angle)); - bl->set_double_param("field_global_rot_y", AngleFlip(angle));// abs. rotation to world for field manager + bl->set_double_param("field_global_rot_y", AngleFlip(angle)); // abs. rotation to world for field manager bl->set_double_param("inner_radius", inner_radius_zin); bl->set_double_param("outer_radius", outer_magnet_diameter / 2.); bl->SetActive(magnet_active); @@ -390,223 +391,217 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) if (verbosity) detRP->Verbosity(verbosity); g4Reco->registerSubsystem(detRP); } - - //--------------------------------- - // B0 implementation - // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry - - - if (Enable::B0_DISABLE_HITPLANE) { - - // Choice 1 realistic detector - - const int b0DetNr = 4; - const double b0Mag_zCent = 640; - const double b0Mag_zLen = 120; - const double b0Cu_zLen = .2; //B0 dead material length - const double b0Si_zLen = .1; //B0 Si length - const double b0Ecal_zLen = 20.; //B0 Ecal length - const double pipe_hole = 5.0; //detector cut off for beam pipe - const double pipe_x = -3.4; //pipe hole position - const double d_radius = 7.0; //detector cut off Packman - const double b0_radius = 20.0; //outer radius of B0-detector - const double spanning_angle = 240; //spanning angle Packman - const double b0Ecal_z = 48; - double start_angle = spanning_angle - 360; //start angle Packman - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("place_x", 0); - detB0->set_double_param("place_y", 0); + + //--------------------------------- + // B0 implementation + // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry + + if (Enable::B0_DISABLE_HITPLANE) + { + // Choice 1 realistic detector + + const int b0DetNr = 4; + const double b0Mag_zCent = 640; + const double b0Mag_zLen = 120; + const double b0Cu_zLen = .2; //B0 dead material length + const double b0Si_zLen = .1; //B0 Si length + const double b0Ecal_zLen = 20.; //B0 Ecal length + const double pipe_hole = 5.0; //detector cut off for beam pipe + const double pipe_x = -3.4; //pipe hole position + const double d_radius = 7.0; //detector cut off Packman + const double b0_radius = 20.0; //outer radius of B0-detector + const double spanning_angle = 240; //spanning angle Packman + const double b0Ecal_z = 48; + double start_angle = 60; //start angle Packman + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i), 2 * i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); // detB0->set_int_param("ispipe", 0); //for future pipe implementation - detB0->set_double_param("pipe_hole", pipe_hole); - detB0->set_double_param("outer_radius", b0_radius); - detB0->set_double_param("d_radius", d_radius); - detB0->set_double_param("length", b0Si_zLen); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("detid",2*i); - detB0->set_double_param("startAngle",start_angle); - detB0->set_double_param("spanningAngle",spanning_angle); - detB0->set_double_param("pipe_x", pipe_x); - detB0->set_double_param("pipe_y", 0); - detB0->set_double_param("pipe_z", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) - detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0); - - auto *detB0e = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i+1), 2*i+1); - detB0e->SuperDetector("b0Truth"); + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid", 2 * i); + detB0->set_double_param("startAngle", start_angle); + detB0->set_double_param("spanningAngle", spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); + + auto *detB0e = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i + 1), 2 * i + 1); + detB0e->SuperDetector("b0Truth"); // detB0e->set_int_param("ispipe", 0); //for future pipe implementation - detB0e->set_double_param("pipe_hole", pipe_hole); - detB0e->set_double_param("place_x", 0); - detB0e->set_double_param("place_y", 0); - detB0e->set_double_param("d_radius", d_radius); - detB0e->set_double_param("pipe_x", pipe_x); - detB0e->set_double_param("pipe_y", 0); - detB0e->set_double_param("pipe_z", 0); - detB0e->set_double_param("outer_radius", b0_radius); - detB0e->set_double_param("length", b0Cu_zLen); - detB0e->set_string_param("material", "G4_Cu"); - detB0e->set_double_param("detid",2*i+1); - detB0e->set_double_param("startAngle",start_angle); - detB0e->set_double_param("spanningAngle",spanning_angle); - detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) +(b0Cu_zLen+b0Si_zLen)/2) ); // relative to B0 magnet - detB0e->SetActive(true); - if (verbosity) - detB0e->Verbosity(verbosity); - detB0e->OverlapCheck(overlapCheck); - detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0e); - } - - auto *B0Ecal = new EICG4B0Subsystem("B0Ecal", 2*b0DetNr); - B0Ecal->SuperDetector("b0Truth"); - // B0Ecal->set_int_param("ispipe", 0); //for future pipe implementation - B0Ecal->set_double_param("pipe_hole", pipe_hole); - B0Ecal->set_double_param("place_x", 0); - B0Ecal->set_double_param("place_y", 0); - B0Ecal->set_double_param("place_z", b0Ecal_z); - B0Ecal->set_double_param("pipe_x", pipe_x); - B0Ecal->set_double_param("pipe_y", 0); - B0Ecal->set_double_param("pipe_z", 0); - B0Ecal->set_double_param("length", b0Ecal_zLen); - B0Ecal->set_double_param("outer_radius", b0_radius); - B0Ecal->set_double_param("d_radius", d_radius); - B0Ecal->set_string_param("material", "G4_PbWO4"); - B0Ecal->set_double_param("startAngle",start_angle); - B0Ecal->set_double_param("spanningAngle",spanning_angle); - B0Ecal->set_double_param("detid",2*b0DetNr); - B0Ecal->SetActive(true); - if (verbosity) - B0Ecal->Verbosity(verbosity); - B0Ecal->OverlapCheck(overlapCheck); - B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(B0Ecal); - - auto *B0Ecale = new EICG4B0Subsystem("B0Ecale", 2*b0DetNr + 1); - B0Ecal->SuperDetector("b0Truth"); - // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation - B0Ecale->set_double_param("pipe_hole", pipe_hole); - B0Ecale->set_double_param("place_x", 0); - B0Ecale->set_double_param("place_y", 0); - B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen)/2); - B0Ecale->set_double_param("pipe_x", pipe_x); - B0Ecale->set_double_param("pipe_y", 0); - B0Ecale->set_double_param("pipe_z", 0); - B0Ecale->set_double_param("length", b0Cu_zLen); - B0Ecale->set_double_param("d_radius", d_radius); - B0Ecale->set_double_param("outer_radius", b0_radius); - B0Ecale->set_string_param("material", "G4_Cu"); - B0Ecale->set_double_param("startAngle",start_angle); - B0Ecale->set_double_param("spanningAngle",spanning_angle); - B0Ecale->set_double_param("detid",2*b0DetNr+1); - B0Ecale->SetActive(true); - if (verbosity) - B0Ecale->Verbosity(verbosity); - B0Ecale->OverlapCheck(overlapCheck); - B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(B0Ecale); - - } else { - - if (Enable::B0_FULLHITPLANE) { - - // Choice 2 circular hit planes - - const int b0DetNr = 4; - - // Sep 09 2021 by Bill: - // B0 magnet center location in z: 640 - // B0 place location in z after 50cm shift: 592, 616, 640, 664 - // B0 layers has the same x coordinate: -14.57 - - const double b0Mag_zCent = 640; - const double b0Mag_zLen = 120; - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("radius", 0); - detB0->set_double_param("thickness", 20); - detB0->set_double_param("length", 0.1); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - - g4Reco->registerSubsystem(detB0); - - } - - } else { - - /// Fun4All default B0 planes - /// Choice 3 Hit planes with real detector geometry - - const int b0DetNr = 4; - const double b0Mag_zCent = 640; - const double b0Mag_zLen = 120; - const double b0Cu_zLen = .2; //B0 dead material length - const double b0Si_zLen = .1; //B0 Si length - const double b0Ecal_zLen = 20.; //B0 Ecal length - const double pipe_hole = 5.0; //detector cut off for beam pipe - const double pipe_x = -3.4; //pipe hole position - const double d_radius = 7.0; //detector cut off Packman - const double b0_radius = 20.0; //outer radius of B0-detector - const double spanning_angle = 240; //spanning angle Packman - const double b0Ecal_z = 48; -// double start_angle = spanning_angle - 360; //start angle Packman - double start_angle = spanning_angle - 180; //start angle Packman - - for (int i = 0; i < b0DetNr; i++) { - - auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("place_x", 0); - detB0->set_double_param("place_y", 0); - // detB0->set_int_param("ispipe", 0); //for future pipe implementation - detB0->set_double_param("pipe_hole", pipe_hole); - detB0->set_double_param("outer_radius", b0_radius); - detB0->set_double_param("d_radius", d_radius); - detB0->set_double_param("length", b0Si_zLen); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("detid",2*i); - detB0->set_double_param("startAngle",start_angle); - detB0->set_double_param("spanningAngle",spanning_angle); - detB0->set_double_param("pipe_x", pipe_x); - detB0->set_double_param("pipe_y", 0); - detB0->set_double_param("pipe_z", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) - detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0); - } - - } + detB0e->set_double_param("pipe_hole", pipe_hole); + detB0e->set_double_param("place_x", 0); + detB0e->set_double_param("place_y", 0); + detB0e->set_double_param("d_radius", d_radius); + detB0e->set_double_param("pipe_x", pipe_x); + detB0e->set_double_param("pipe_y", 0); + detB0e->set_double_param("pipe_z", 0); + detB0e->set_double_param("outer_radius", b0_radius); + detB0e->set_double_param("length", b0Cu_zLen); + detB0e->set_string_param("material", "G4_Cu"); + detB0e->set_double_param("detid", 2 * i + 1); + detB0e->set_double_param("startAngle", start_angle); + detB0e->set_double_param("spanningAngle", spanning_angle); + detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) + (b0Cu_zLen + b0Si_zLen) / 2)); // relative to B0 magnet + detB0e->SetActive(true); + if (verbosity) + detB0e->Verbosity(verbosity); + detB0e->OverlapCheck(overlapCheck); + detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0e); } + auto *B0Ecal = new EICG4B0Subsystem("B0Ecal", 2 * b0DetNr); + B0Ecal->SuperDetector("b0Truth"); + // B0Ecal->set_int_param("ispipe", 0); //for future pipe implementation + B0Ecal->set_double_param("pipe_hole", pipe_hole); + B0Ecal->set_double_param("place_x", 0); + B0Ecal->set_double_param("place_y", 0); + B0Ecal->set_double_param("place_z", b0Ecal_z); + B0Ecal->set_double_param("pipe_x", pipe_x); + B0Ecal->set_double_param("pipe_y", 0); + B0Ecal->set_double_param("pipe_z", 0); + B0Ecal->set_double_param("length", b0Ecal_zLen); + B0Ecal->set_double_param("outer_radius", b0_radius); + B0Ecal->set_double_param("d_radius", d_radius); + B0Ecal->set_string_param("material", "G4_PbWO4"); + B0Ecal->set_double_param("startAngle", start_angle); + B0Ecal->set_double_param("spanningAngle", spanning_angle); + B0Ecal->set_double_param("detid", 2 * b0DetNr); + B0Ecal->SetActive(true); + if (verbosity) + B0Ecal->Verbosity(verbosity); + B0Ecal->OverlapCheck(overlapCheck); + B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecal); + + auto *B0Ecale = new EICG4B0Subsystem("B0Ecale", 2 * b0DetNr + 1); + B0Ecal->SuperDetector("b0Truth"); + // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation + B0Ecale->set_double_param("pipe_hole", pipe_hole); + B0Ecale->set_double_param("place_x", 0); + B0Ecale->set_double_param("place_y", 0); + B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen) / 2); + B0Ecale->set_double_param("pipe_x", pipe_x); + B0Ecale->set_double_param("pipe_y", 0); + B0Ecale->set_double_param("pipe_z", 0); + B0Ecale->set_double_param("length", b0Cu_zLen); + B0Ecale->set_double_param("d_radius", d_radius); + B0Ecale->set_double_param("outer_radius", b0_radius); + B0Ecale->set_string_param("material", "G4_Cu"); + B0Ecale->set_double_param("startAngle", start_angle); + B0Ecale->set_double_param("spanningAngle", spanning_angle); + B0Ecale->set_double_param("detid", 2 * b0DetNr + 1); + B0Ecale->SetActive(true); + if (verbosity) + B0Ecale->Verbosity(verbosity); + B0Ecale->OverlapCheck(overlapCheck); + B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecale); + } + else + { + if (Enable::B0_FULLHITPLANE) + { + // Choice 2 circular hit planes + + const int b0DetNr = 4; + + // Sep 09 2021 by Bill: + // B0 magnet center location in z: 640 + // B0 place location in z after 50cm shift: 592, 616, 640, 664 + // B0 layers has the same x coordinate: -14.57 + + const double b0Mag_zCent = 640; + const double b0Mag_zLen = 120; + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("radius", 0); + detB0->set_double_param("thickness", 20); + detB0->set_double_param("length", 0.1); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + + g4Reco->registerSubsystem(detB0); + } + } + else + { + /// Fun4All default B0 planes + /// Choice 3 Hit planes with real detector geometry + + const int b0DetNr = 4; + const double b0Mag_zCent = 640; + const double b0Mag_zLen = 120; + const double b0Cu_zLen = .2; //B0 dead material length + const double b0Si_zLen = .1; //B0 Si length + const double b0Ecal_zLen = 20.; //B0 Ecal length + const double pipe_hole = 5.0; //detector cut off for beam pipe + const double pipe_x = -3.4; //pipe hole position + const double d_radius = 7.0; //detector cut off Packman + const double b0_radius = 20.0; //outer radius of B0-detector + const double spanning_angle = 240; //spanning angle Packman + const double b0Ecal_z = 48; + double start_angle = 60; //start angle Packman + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i), 2 * i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); + // detB0->set_int_param("ispipe", 0); //for future pipe implementation + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid", 2 * i); + detB0->set_double_param("startAngle", start_angle); + detB0->set_double_param("spanningAngle", spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); + } + } + } } void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) { - -//-------------------------------------------------------- -// The IP8 detector position is implemented by Wenliang Li (billlee@jlab.org) -// on July 07, 2021 -// Reference of this implementation: https://indico.bnl.gov/event/10974/contributions/51160/ + //-------------------------------------------------------- + // The IP8 detector position is implemented by Wenliang Li (billlee@jlab.org) + // on July 07, 2021 + // Reference of this implementation: https://indico.bnl.gov/event/10974/contributions/51160/ bool overlapCheck = Enable::OVERLAPCHECK || Enable::HFARFWD_OVERLAPCHECK; if (Enable::HFARFWD_VIRTUAL_DETECTORS_IP6 && Enable::HFARFWD_VIRTUAL_DETECTORS_IP8) @@ -663,7 +658,6 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) if (Enable::ZDC_DISABLE_BLACKHOLE) { - EICG4ZDCSubsystem *detZDC = new EICG4ZDCSubsystem("EICG4ZDC"); detZDC->SetActive(); detZDC->set_double_param("place_z", 3350. + detZDCsurrogate_size_z - hFarFwdBeamLine::enclosure_center); @@ -672,7 +666,6 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) detZDC->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); detZDC->OverlapCheck(overlapCheck); g4Reco->registerSubsystem(detZDC); - } //------------------ @@ -684,31 +677,30 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) for (int i = 0; i < rpDetNr; i++) { + // Circular disk design (16cm in) + auto *detRP = new PHG4CylinderSubsystem(Form("rpTruth_%d", i), i); + detRP->SuperDetector("rpTruth"); + detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_y", 0); + detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); + detRP->set_double_param("radius", 5); + detRP->set_double_param("thickness", 10); // 16 cm circulr to cover 25cm x20cm square (IR design) + detRP->set_double_param("length", 0.03); + detRP->set_string_param("material", "G4_Si"); - // Circular disk design (16cm in) - auto *detRP = new PHG4CylinderSubsystem(Form("rpTruth_%d", i), i); - detRP->SuperDetector("rpTruth"); - detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); - detRP->set_double_param("place_y", 0); - detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); - detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); - detRP->set_double_param("radius", 5); - detRP->set_double_param("thickness", 10); // 16 cm circulr to cover 25cm x20cm square (IR design) - detRP->set_double_param("length", 0.03); - detRP->set_string_param("material", "G4_Si"); - -// //------------------------------------ -// /// Square Design -// auto *detRP = new PHG4BlockSubsystem(Form("rpTruth_%d", i), i); -// detRP->SuperDetector("rpTruth"); -// detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); -// detRP->set_double_param("place_y", 0); -// detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); -// detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); -// detRP->set_double_param("size_x", 25); // Original design specification -// detRP->set_double_param("size_y", 20); // Original design specification -// detRP->set_double_param("size_z", 0.03); -// detRP->set_string_param("material", "G4_Si"); + // //------------------------------------ + // /// Square Design + // auto *detRP = new PHG4BlockSubsystem(Form("rpTruth_%d", i), i); + // detRP->SuperDetector("rpTruth"); + // detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + // detRP->set_double_param("place_y", 0); + // detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + // detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); + // detRP->set_double_param("size_x", 25); // Original design specification + // detRP->set_double_param("size_y", 20); // Original design specification + // detRP->set_double_param("size_z", 0.03); + // detRP->set_string_param("material", "G4_Si"); detRP->OverlapCheck(overlapCheck); detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); @@ -750,238 +742,230 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) std::cout << "B0Magnet can be mother = " << hFarFwdBeamLine::B0Magnet->CanBeMotherSubsystem() << std::endl; } - //--------------------------------- - // B0 implementation - // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry + //--------------------------------- + // B0 implementation + // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry - if (Enable::B0_DISABLE_HITPLANE) { + if (Enable::B0_DISABLE_HITPLANE) + { + // Choice 1 realistic detector + + const int b0DetNr = 4; + + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + const double b0Cu_zLen = .2; //B0 dead material length + const double b0Si_zLen = .1; //B0 Si length + const double b0Ecal_zLen = 20.; //B0 Ecal length + const double pipe_hole = 6.0; //detector cut off for beam pipe + const double pipe_x = 1.0; //pipe hole position + const double d_radius = 9.0; //detector cut off Packman + const double b0_radius = 24.5; //outer radius of B0-detector + const double spanning_angle = 240; //spanning angle Packman + const double b0Ecal_z = 48; + double start_angle = -120; //start angle Packman + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i), 2 * i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); + // detB0->set_int_param("ispipe", 0); //for future pipe implementation + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid", 2 * i); + detB0->set_double_param("startAngle", start_angle); + detB0->set_double_param("spanningAngle", spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); + + auto *detB0e = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i + 1), 2 * i + 1); + detB0e->SuperDetector("b0Truth"); + // detB0e->set_int_param("ispipe", 0); //for future pipe implementation + detB0e->set_double_param("pipe_hole", pipe_hole); + detB0e->set_double_param("place_x", 0); + detB0e->set_double_param("place_y", 0); + detB0e->set_double_param("d_radius", d_radius); + detB0e->set_double_param("pipe_x", pipe_x); + detB0e->set_double_param("pipe_y", 0); + detB0e->set_double_param("pipe_z", 0); + detB0e->set_double_param("outer_radius", b0_radius); + detB0e->set_double_param("length", b0Cu_zLen); + detB0e->set_string_param("material", "G4_Cu"); + detB0e->set_double_param("detid", 2 * i + 1); + detB0e->set_double_param("startAngle", start_angle); + detB0e->set_double_param("spanningAngle", spanning_angle); + detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) + (b0Cu_zLen + b0Si_zLen) / 2)); // relative to B0 magnet + detB0e->SetActive(true); + if (verbosity) + detB0e->Verbosity(verbosity); + detB0e->OverlapCheck(overlapCheck); + detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0e); + } - // Choice 1 realistic detector + auto *B0Ecal = new EICG4B0Subsystem("B0Ecal", 2 * b0DetNr); + B0Ecal->SuperDetector("b0Truth"); + // B0Ecal->set_int_param("ispipe", 0); //for future pipe implementation + B0Ecal->set_double_param("pipe_hole", pipe_hole); + B0Ecal->set_double_param("place_x", 0); + B0Ecal->set_double_param("place_y", 0); + B0Ecal->set_double_param("place_z", b0Ecal_z); + B0Ecal->set_double_param("pipe_x", pipe_x); + B0Ecal->set_double_param("pipe_y", 0); + B0Ecal->set_double_param("pipe_z", 0); + B0Ecal->set_double_param("length", b0Ecal_zLen); + B0Ecal->set_double_param("outer_radius", b0_radius); + B0Ecal->set_double_param("d_radius", d_radius); + B0Ecal->set_string_param("material", "G4_PbWO4"); + B0Ecal->set_double_param("startAngle", start_angle); + B0Ecal->set_double_param("spanningAngle", spanning_angle); + B0Ecal->set_double_param("detid", 2 * b0DetNr); + B0Ecal->SetActive(true); + if (verbosity) + B0Ecal->Verbosity(verbosity); + B0Ecal->OverlapCheck(overlapCheck); + B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecal); + + auto *B0Ecale = new EICG4B0Subsystem("B0Ecale", 2 * b0DetNr + 1); + B0Ecal->SuperDetector("b0Truth"); + // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation + B0Ecale->set_double_param("pipe_hole", pipe_hole); + B0Ecale->set_double_param("place_x", 0); + B0Ecale->set_double_param("place_y", 0); + B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen) / 2); + B0Ecale->set_double_param("pipe_x", pipe_x); + B0Ecale->set_double_param("pipe_y", 0); + B0Ecale->set_double_param("pipe_z", 0); + B0Ecale->set_double_param("length", b0Cu_zLen); + B0Ecale->set_double_param("d_radius", d_radius); + B0Ecale->set_double_param("outer_radius", b0_radius); + B0Ecale->set_string_param("material", "G4_Cu"); + B0Ecale->set_double_param("startAngle", start_angle); + B0Ecale->set_double_param("spanningAngle", spanning_angle); + B0Ecale->set_double_param("detid", 2 * b0DetNr + 1); + B0Ecale->SetActive(true); + if (verbosity) + B0Ecale->Verbosity(verbosity); + B0Ecale->OverlapCheck(overlapCheck); + B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecale); + } + else + { + if (Enable::B0_FULLHITPLANE) + { + // Choice 2 circular hit planes - const int b0DetNr = 4; + const int b0DetNr = 4; -// const double b0Mag_zCent = 590; -// const double b0Mag_zLen = 120; + // Sep 09 2021 by Bill: + // B0 magnet center location in z: 610 + // B0 place location in z after 50cm shift: + // B0 layers has the same x coordinate: -14.57 - const double b0Mag_zCent = 610; - const double b0Mag_zLen = 120; + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; - const double b0Cu_zLen = .2; //B0 dead material length - const double b0Si_zLen = .1; //B0 Si length - const double b0Ecal_zLen = 20.; //B0 Ecal length - const double pipe_hole = 5.0; //detector cut off for beam pipe - const double pipe_x = 3.4; //pipe hole position - const double d_radius = 7.0; //detector cut off Packman - const double b0_radius = 24.5; //outer radius of B0-detector - const double spanning_angle = 240; //spanning angle Packman - const double b0Ecal_z = 48; - double start_angle = spanning_angle - 360; //start angle Packman - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("place_x", 0); - detB0->set_double_param("place_y", 0); - // detB0->set_int_param("ispipe", 0); //for future pipe implementation - detB0->set_double_param("pipe_hole", pipe_hole); - detB0->set_double_param("outer_radius", b0_radius); - detB0->set_double_param("d_radius", d_radius); - detB0->set_double_param("length", b0Si_zLen); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("detid",2*i); - detB0->set_double_param("startAngle",start_angle); - detB0->set_double_param("spanningAngle",spanning_angle); - detB0->set_double_param("pipe_x", pipe_x); - detB0->set_double_param("pipe_y", 0); - detB0->set_double_param("pipe_z", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) - detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0); - - auto *detB0e = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i+1), 2*i+1); - detB0e->SuperDetector("b0Truth"); - // detB0e->set_int_param("ispipe", 0); //for future pipe implementation - detB0e->set_double_param("pipe_hole", pipe_hole); - detB0e->set_double_param("place_x", 0); - detB0e->set_double_param("place_y", 0); - detB0e->set_double_param("d_radius", d_radius); - detB0e->set_double_param("pipe_x", pipe_x); - detB0e->set_double_param("pipe_y", 0); - detB0e->set_double_param("pipe_z", 0); - detB0e->set_double_param("outer_radius", b0_radius); - detB0e->set_double_param("length", b0Cu_zLen); - detB0e->set_string_param("material", "G4_Cu"); - detB0e->set_double_param("detid",2*i+1); - detB0e->set_double_param("startAngle",start_angle); - detB0e->set_double_param("spanningAngle",spanning_angle); - detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) +(b0Cu_zLen+b0Si_zLen)/2) ); // relative to B0 magnet - detB0e->SetActive(true); - if (verbosity) - detB0e->Verbosity(verbosity); - detB0e->OverlapCheck(overlapCheck); - detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0e); - } - - auto *B0Ecal = new EICG4B0Subsystem("B0Ecal", 2*b0DetNr); - B0Ecal->SuperDetector("b0Truth"); - // B0Ecal->set_int_param("ispipe", 0); //for future pipe implementation - B0Ecal->set_double_param("pipe_hole", pipe_hole); - B0Ecal->set_double_param("place_x", 0); - B0Ecal->set_double_param("place_y", 0); - B0Ecal->set_double_param("place_z", b0Ecal_z); - B0Ecal->set_double_param("pipe_x", pipe_x); - B0Ecal->set_double_param("pipe_y", 0); - B0Ecal->set_double_param("pipe_z", 0); - B0Ecal->set_double_param("length", b0Ecal_zLen); - B0Ecal->set_double_param("outer_radius", b0_radius); - B0Ecal->set_double_param("d_radius", d_radius); - B0Ecal->set_string_param("material", "G4_PbWO4"); - B0Ecal->set_double_param("startAngle",start_angle); - B0Ecal->set_double_param("spanningAngle",spanning_angle); - B0Ecal->set_double_param("detid",2*b0DetNr); - B0Ecal->SetActive(true); - if (verbosity) - B0Ecal->Verbosity(verbosity); - B0Ecal->OverlapCheck(overlapCheck); - B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(B0Ecal); - - auto *B0Ecale = new EICG4B0Subsystem("B0Ecale", 2*b0DetNr + 1); - B0Ecal->SuperDetector("b0Truth"); - // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation - B0Ecale->set_double_param("pipe_hole", pipe_hole); - B0Ecale->set_double_param("place_x", 0); - B0Ecale->set_double_param("place_y", 0); - B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen)/2); - B0Ecale->set_double_param("pipe_x", pipe_x); - B0Ecale->set_double_param("pipe_y", 0); - B0Ecale->set_double_param("pipe_z", 0); - B0Ecale->set_double_param("length", b0Cu_zLen); - B0Ecale->set_double_param("d_radius", d_radius); - B0Ecale->set_double_param("outer_radius", b0_radius); - B0Ecale->set_string_param("material", "G4_Cu"); - B0Ecale->set_double_param("startAngle",start_angle); - B0Ecale->set_double_param("spanningAngle",spanning_angle); - B0Ecale->set_double_param("detid",2*b0DetNr+1); - B0Ecale->SetActive(true); + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("radius", 0); + detB0->set_double_param("thickness", 20); + detB0->set_double_param("length", 0.1); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + + g4Reco->registerSubsystem(detB0); + } + } + else + { + /// Fun4All default B0 planes + /// Choice 3 Hit planes with real detector geometry + + const int b0DetNr = 4; + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + const double b0Cu_zLen = .2; //B0 dead material length + const double b0Si_zLen = .1; //B0 Si length + const double b0Ecal_zLen = 20.; //B0 Ecal length + const double pipe_hole = 6.0; //detector cut off for beam pipe + const double pipe_x = 1.0; //pipe hole position + const double d_radius = 9.0; //detector cut off Packman + const double b0_radius = 24.5; //outer radius of B0-detector + const double spanning_angle = 240; //spanning angle Packman + const double b0Ecal_z = 48; + double start_angle = -120; //start angle Packman + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i), 2 * i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); + // detB0->set_int_param("ispipe", 0); //for future pipe implementation + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid", 2 * i); + detB0->set_double_param("startAngle", start_angle); + detB0->set_double_param("spanningAngle", spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); if (verbosity) - B0Ecale->Verbosity(verbosity); - B0Ecale->OverlapCheck(overlapCheck); - B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(B0Ecale); - - } else { - - if (Enable::B0_FULLHITPLANE) { - - // Choice 2 circular hit planes - - const int b0DetNr = 4; - - // Sep 09 2021 by Bill: - // B0 magnet center location in z: 610 - // B0 place location in z after 50cm shift: - // B0 layers has the same x coordinate: -14.57 - - const double b0Mag_zCent = 610; - const double b0Mag_zLen = 120; - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("radius", 0); - detB0->set_double_param("thickness", 20); - detB0->set_double_param("length", 0.1); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - - g4Reco->registerSubsystem(detB0); - - } - - } else { - - /// Fun4All default B0 planes - /// Choice 3 Hit planes with real detector geometry - - const int b0DetNr = 4; - const double b0Mag_zCent = 610; - const double b0Mag_zLen = 120; - const double b0Cu_zLen = .2; //B0 dead material length - const double b0Si_zLen = .1; //B0 Si length - const double b0Ecal_zLen = 20.; //B0 Ecal length - const double pipe_hole = 5.0; //detector cut off for beam pipe -// const double pipe_x = -3.4; //pipe hole position - const double pipe_x = 1.0; //pipe hole position - const double d_radius = 7.0; //detector cut off Packman - const double b0_radius = 24; //outer radius of B0-detector - const double spanning_angle = 240; //spanning angle Packman - const double b0Ecal_z = 48; - double start_angle = spanning_angle - 360; //start angle Packman - - for (int i = 0; i < b0DetNr; i++) { - - auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("place_x", 0); - detB0->set_double_param("place_y", 0); - // detB0->set_int_param("ispipe", 0); //for future pipe implementation - detB0->set_double_param("pipe_hole", pipe_hole); - detB0->set_double_param("outer_radius", b0_radius); - detB0->set_double_param("d_radius", d_radius); - detB0->set_double_param("length", b0Si_zLen); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("detid",2*i); - detB0->set_double_param("startAngle",start_angle); - detB0->set_double_param("spanningAngle",spanning_angle); - detB0->set_double_param("pipe_x", pipe_x); - detB0->set_double_param("pipe_y", 0); - detB0->set_double_param("pipe_z", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) - detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0); - } - - } + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); + } } + } -// const int b0DetNr = 4; -// const double b0Mag_zCent = 610; -// const double b0Mag_zLen = 120; -// for (int i = 0; i < b0DetNr; i++) -// { -// auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); -// detB0->SuperDetector("b0Truth"); -// detB0->set_double_param("radius", 0); -// detB0->set_double_param("thickness", 20); -// detB0->set_double_param("length", 0.1); -// detB0->set_string_param("material", "G4_Si"); -// detB0->set_double_param("place_y", 0); -// detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); -// detB0->OverlapCheck(overlapCheck); -// detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); -// detB0->SetActive(true); -// if (verbosity) -// detB0->Verbosity(verbosity); -// g4Reco->registerSubsystem(detB0); -// } - + // const int b0DetNr = 4; + // const double b0Mag_zCent = 610; + // const double b0Mag_zLen = 120; + // for (int i = 0; i < b0DetNr; i++) + // { + // auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); + // detB0->SuperDetector("b0Truth"); + // detB0->set_double_param("radius", 0); + // detB0->set_double_param("thickness", 20); + // detB0->set_double_param("length", 0.1); + // detB0->set_string_param("material", "G4_Si"); + // detB0->set_double_param("place_y", 0); + // detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); + // detB0->OverlapCheck(overlapCheck); + // detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + // detB0->SetActive(true); + // if (verbosity) + // detB0->Verbosity(verbosity); + // g4Reco->registerSubsystem(detB0); + // } } void hFarFwdDefineBeamPipe(PHG4Reco *g4Reco) @@ -1091,42 +1075,54 @@ void hFarFwdDefineBeamPipe(PHG4Reco *g4Reco) } } -float PosFlip(float pos) { - if(Enable::HFARFWD_MAGNETS_IP6) { - return pos; - } else { - return pos; +float PosFlip(float pos) +{ + if (Enable::HFARFWD_MAGNETS_IP6) + { + return pos; + } + else + { + return pos; } } -float AngleFlip(float angle){ - if(Enable::HFARFWD_MAGNETS_IP6) { - return angle; - } else { - return angle; +float AngleFlip(float angle) +{ + if (Enable::HFARFWD_MAGNETS_IP6) + { + return angle; + } + else + { + return angle; } } -float MagFieldFlip(float Bfield){ - if(Enable::HFARFWD_MAGNETS_IP6) { - return Bfield; - } else { - return Bfield; +float MagFieldFlip(float Bfield) +{ + if (Enable::HFARFWD_MAGNETS_IP6) + { + return Bfield; + } + else + { + return Bfield; } } - //------------------------------------------ void FFR_Eval(const std::string &outputfile) { - string ip_str; - - if(Enable::IP6) { + if (Enable::IP6) + { ip_str = "IP6"; - } else { + } + else + { ip_str = "IP8"; } @@ -1142,6 +1138,4 @@ void FFR_Eval(const std::string &outputfile) return; } - - -#endif +#endif \ No newline at end of file From 3d72f648128d6d509285f1d8cbd0cc3333d82570 Mon Sep 17 00:00:00 2001 From: Jin Huang Date: Fri, 8 Oct 2021 09:32:48 -0400 Subject: [PATCH 09/15] + link to https://ecce-eic.github.io/ --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ff47361b..f3a60faa 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ This is the standard macros respository for [ECCE](https://www.ecce-eic.org/). Following is the 10-min tutorial on using the default macros. [![Build Status](https://web.sdcc.bnl.gov/jenkins-sphenix/buildStatus/icon?job=sPHENIX/sPHENIX_CoreSoftware_MasterBranch)](https://web.sdcc.bnl.gov/jenkins-sphenix/job/sPHENIX/job/sPHENIX_CoreSoftware_MasterBranch/) +[![Tutorials](https://img.shields.io/badge/Tutorials-Doc-green.svg)](https://ecce-eic.github.io/) [![Doxygen](https://img.shields.io/badge/code%20reference-Doxygen-green.svg)](https://ecce-eic.github.io/doxygen/) [![Singularity](https://img.shields.io/badge/container-Singularity%20via%20CVMFS-green.svg)](https://github.com/ECCE-EIC/Singularity) From dcfd9b737978eb1b0d674973bf904a6b315f5d86 Mon Sep 17 00:00:00 2001 From: cdean-github <59485912+cdean-github@users.noreply.github.com> Date: Sun, 7 Nov 2021 13:42:27 -0500 Subject: [PATCH 10/15] October 2021 concept (#87) * TRD related macros (#42) * Macros for TRD * Macros for TRD * updating my forked rep * G4_TRD.C macro update , G4_BMMGT.C for barrel MMG added * G4_TRD.C for TRD and G4_BMMGT.C for barrel MMG tracker * Patches to G4_TRD and G4_BMMG * Updates to main macro * Barrel MMG macro and HCap TRD macro * Removed verbosity hard codes and moved TRD back 20cm due to overlap in support structure Co-authored-by: cdean-github * mRPC Barrel ToF (#76) * Macros for TRD * Macros for TRD * updating my forked rep * G4_TRD.C macro update , G4_BMMGT.C for barrel MMG added * G4_TRD.C for TRD and G4_BMMGT.C for barrel MMG tracker * Patches to G4_TRD and G4_BMMG * Updates to main macro * Adding Barrel mRPC ToF * Delete MMG and TRD macros * modified Fun4All and G4SetUp macros * modified Fun4All and G4SetUp macros to remove TRD and BMMG * Ran overlap checks Co-authored-by: cdean-github Co-authored-by: cdean-github <59485912+cdean-github@users.noreply.github.com> * End cap mRPC ToF (#78) * Macros for TRD * Macros for TRD * updating my forked rep * G4_TRD.C macro update , G4_BMMGT.C for barrel MMG added * G4_TRD.C for TRD and G4_BMMGT.C for barrel MMG tracker * Patches to G4_TRD and G4_BMMG * Updates to main macro * Adding Barrel mRPC ToF * Delete MMG and TRD macros * modified Fun4All and G4SetUp macros * modified Fun4All and G4SetUp macros to remove TRD and BMMG * Ran overlap checks * Adding end cap mRPC ToF macros * Ran integration checks Co-authored-by: cdean-github Co-authored-by: cdean-github <59485912+cdean-github@users.noreply.github.com> * Updated barrel layout * necessary changes for correct hit association and TTL geometry setup (#79) * Adding Roman Pots into the main macros (#77) * Flipped IP6 Far Forward detector stacks, include position, angle and field * flip crossing sign in HepMC event gen * flip crossing sign in beam chambers * before merging * Added the far backward region into Fun4all * Fixed a few issues suggested by Jin * Implemented the designed IP8 detector location * Extended the farbackward vaccum enclosure to include maximum path * fix overlap of world vol. * Updated IP6 detector location, and unflipped the x coord, angle, and field * Added the far forward evaluator * Adding FFR evaluator * void * Updated the IP8 configuration and main macro to include forward Eval * Fixed IP8 changes which were not merge into the master * Added the virtual detector in the farbackward region * Added the B0 detector models in the Fun4all There are three choices: 1. Real detector stack 2. Disk plane to help occupancy study 3. Hit planes replicating the real detector goemetry * Added the B0 detector * Fixed the issue for gradient field not scaling * Setting Forward/backward enclosure and magnets to active * Fixed B0 Orientiion for IP6 and IP8; IP8 1st RP with 5cm radius hole * Improved B0 geometry based on Sasha's suggestion * Reformatted G4_hFarFwdBeamLine_EIC.C style * Adding the RP implementation to the macro for IP6 and IP8 * merge * Corrected RP2nd option Co-authored-by: Jin Huang Co-authored-by: cdean-github Co-authored-by: cdean-github <59485912+cdean-github@users.noreply.github.com> * October 2021 concept (#81) * disabling non-default detectors * adding conf. check * disabling BTOF * disable overlap check * breakout RWELL into individual layers * turn off jet eval * Small changes to Oct layout * update DIRC * update BECAL * update BECAL * Added inner detector updates * Fixed some smaller issues * Separate hit nodes in SVTX and BARR as in #79 Co-authored-by: cdean-github * Updated FGEM and tracking support (#82) * Updated G4_EventEvaluator.C to work with new libraries * Updated G4_hFarFwd to point to new magnet file * Updated EventEval for new PR * FIxing overlaps * Reverting changes made by merge to production branch * Hash was changed to 'a', fixed * Added Tristan's clusteriser to macros * Missing / in setup * Pushed inner barrel tracker behind last vtx layer * Updated FGEM and tracking support for move * TTL change and tracking/eval update (#83) * Updated G4_EventEvaluator.C to work with new libraries * Updated G4_hFarFwd to point to new magnet file * Updated EventEval for new PR * FIxing overlaps * Reverting changes made by merge to production branch * Hash was changed to 'a', fixed * Added Tristan's clusteriser to macros * Missing / in setup * Pushed inner barrel tracker behind last vtx layer * Updated FGEM and tracking support for move * Patched TTL and updated tracking/EvtEval * Tracking group re-assignment for October 2021 concept (#84) * Following Nov-5 tracking meeting, update to muRwell performance of 55um resolution 2D readout * reassign mRwell to tracking groups in the new layout * reassign TTL to tracking groups in the new layout * reassign FGEM to tracking groups in the new layout * recover default parameters * fix TTL projection * fix GEM projection * impliment tracking group silicon design (#85) * Changed to option 1a (#86) * Updated G4_EventEvaluator.C to work with new libraries * Updated G4_hFarFwd to point to new magnet file * Updated EventEval for new PR * FIxing overlaps * Reverting changes made by merge to production branch * Hash was changed to 'a', fixed * Added Tristan's clusteriser to macros * Missing / in setup * Pushed inner barrel tracker behind last vtx layer * Updated FGEM and tracking support for move * Patched TTL and updated tracking/EvtEval * Changed inner system to option 1a * recover inner HCal radius * Suggestion from James Fast on L3 radius * Final changes for campaign 3 Co-authored-by: Jin Huang Co-authored-by: sourav-tarafdar Co-authored-by: nschmidtALICE Co-authored-by: billlee77 Co-authored-by: Jin Huang Co-authored-by: Jin Huang --- common/G4_BECAL.C | 8 +- common/G4_BMMG.C | 125 ++++ common/G4_BToF.C | 567 ++++++++++++++++++ common/G4_Barrel_EIC.C | 55 +- common/G4_DIRC.C | 21 +- common/G4_EToF.C | 130 ++++ common/G4_EventEvaluator.C | 5 +- common/G4_FST_EIC.C | 73 ++- common/G4_GEM_EIC.C | 29 +- common/G4_HToF.C | 128 ++++ common/G4_HcalIn_ref.C | 2 +- common/G4_TRD.C | 100 +++ common/G4_TTL_EIC.C | 98 ++- common/G4_TrackingSupport.C | 244 +++++--- common/G4_hFarFwdBeamLine_EIC.C | 507 +++++++++++++--- common/G4_mRwell_EIC.C | 152 +++-- .../EICDetector/Fun4All_G4_EICDetector.C | 32 +- detectors/EICDetector/G4Setup_EICDetector.C | 47 ++ 18 files changed, 1998 insertions(+), 325 deletions(-) create mode 100644 common/G4_BMMG.C create mode 100644 common/G4_BToF.C create mode 100644 common/G4_EToF.C create mode 100644 common/G4_HToF.C create mode 100644 common/G4_TRD.C diff --git a/common/G4_BECAL.C b/common/G4_BECAL.C index cc169f8c..e7427246 100644 --- a/common/G4_BECAL.C +++ b/common/G4_BECAL.C @@ -48,7 +48,7 @@ namespace G4BECAL double minz = -453; double maxz = 371; double topradius = 138; - double radius = 85; + double radius = 80; // this is default set to -1.5set_string_param("mapping_file", mapping_becal.str()); diff --git a/common/G4_BMMG.C b/common/G4_BMMG.C new file mode 100644 index 00000000..a3756e13 --- /dev/null +++ b/common/G4_BMMG.C @@ -0,0 +1,125 @@ +#ifndef MACRO_G4BMMG_C +#define MACRO_G4BMMG_C + +#include + +#include +#include +#include +#include +#include + +R__LOAD_LIBRARY(libg4barrelmmg.so) +R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libg4testbench.so) +R__LOAD_LIBRARY(libg4detectors.so) + +namespace Enable +{ + bool BMMG = false; + bool use_2Dreadout = true; + bool BMMG_OVERLAPCHECK = true; + int BMMG_VERBOSITY = 0; +} // namespace Enable + +namespace BMMG +{ + const int n_layer = 3; + + const double rad[BMMG::n_layer] = {45., 47.4, 67.4}; // approximate radial location + const double len[BMMG::n_layer] = {140, 150, 280.0}; +} // namespace BMMG + +void BMMGInit(int verbosity = 1) +{ + BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, BMMG::rad[BMMG::n_layer - 1] / 10. + 0.7); + BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, BMMG::len[BMMG::n_layer - 1] / 2.0 + 1.0); + BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -BMMG::len[BMMG::n_layer - 1] / 2.0 - 10.); +} + +void BMMGSetup(PHG4Reco* g4Reco) +{ + int verbosity = std::max(Enable::VERBOSITY, Enable::BMMG_VERBOSITY); + Fun4AllServer* se = Fun4AllServer::instance(); + se->Verbosity(verbosity); + + bool OverlapCheck = Enable::OVERLAPCHECK || Enable::BMMG_OVERLAPCHECK; + + gSystem->Load("libfun4all"); + gSystem->Load("libg4detectors.so"); + gSystem->Load("libg4testbench.so"); + gSystem->Load("libg4trackfastsim.so"); + + PHG4CylinderStripSubsystem* barrel_mmg; + double gap_betweenCZ = 1.5; + double Gap_betweenlayer = 1.5; + double thickness = 0.36499; + int nCZlayer = 2; + if (Enable::use_2Dreadout) + { + gap_betweenCZ = 0; + nCZlayer = 1; + } + + const double prapidity = 1; + + for (int ilayer = 0; ilayer < BMMG::n_layer; ilayer++) + { + barrel_mmg = new PHG4CylinderStripSubsystem(Form("BMT_%d", ilayer), ilayer); + barrel_mmg->set_double_param("radius", BMMG::rad[ilayer]); + barrel_mmg->set_string_param("gas", "myMMGas"); + //barrel_mmg->set_double_param("steplimits", 300e-4); + barrel_mmg->set_double_param("phi0", 15 * ilayer); + barrel_mmg->set_double_param("gap", gap_betweenCZ); + barrel_mmg->SetActive(); + barrel_mmg->SuperDetector("BMT"); + barrel_mmg->set_int_param("lengthviarapidity", 0); + barrel_mmg->set_double_param("gas1thickness", 0.15); + barrel_mmg->set_double_param("length", BMMG::len[ilayer]); + barrel_mmg->set_double_param("deadzone", 0.2); + barrel_mmg->set_int_param("nhit", 1); + barrel_mmg->OverlapCheck(true); + barrel_mmg->set_int_param("use_2Dreadout", Enable::use_2Dreadout); + g4Reco->registerSubsystem(barrel_mmg); + } // ilayer loop + + if (TRACKING::FastKalmanFilter) + { + if (Enable::use_2Dreadout) + { + TRACKING::FastKalmanFilter->add_phg4hits( + "G4HIT_BMT", // const std::string& phg4hitsNames, + PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype, + 2.5 / 2 / sqrt(12), //1./sqrt(12), // radial-resolution , only used for Vertical Plane Detector Type + 75e-4, //150e-4, // azimuthal-resolution [cm] + 75e-4, //150e-4, // z-resolution [cm] + 1, // efficiency, + 0); // noise hits + } + else + { + TRACKING::FastKalmanFilter->add_phg4hits( + "G4HIT_CZBMT", // const std::string& phg4hitsNames, + PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype, + 2.5 / 2 / sqrt(12), //1/sqrt(12), // radial-resolution [cm], only used for Vertical Plane Detector Type + 75e-4, //150e-4, // azimuthal-resolution [cm] + 75e-4, //150e-4, // z-resolution [cm] + 1, // efficiency, + 0); // noise hits + } + } + + return; +} + +void BMMGT_Reco() +{ + gSystem->Load("libfun4all.so"); + gSystem->Load("libg4detectors.so"); + + int verbosity = std::max(Enable::VERBOSITY, Enable::BMMG_VERBOSITY); + Fun4AllServer* se = Fun4AllServer::instance(); + + return; +} +#endif diff --git a/common/G4_BToF.C b/common/G4_BToF.C new file mode 100644 index 00000000..6988780b --- /dev/null +++ b/common/G4_BToF.C @@ -0,0 +1,567 @@ +#ifndef MACRO_G4BToF_C +#define MACRO_G4BToF_C + +#include + +#include +#include +#include +#include +#include + +R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libg4testbench.so) +R__LOAD_LIBRARY(libg4detectors.so) + +namespace Enable +{ + bool BTOF = false; + bool BTOF_OVERLAPCHECK = false; + int BTOF_VERBOSITY = 0; +} // namespace Enable + +namespace BTOF +{ + const int gas_lyr = 6; // 1/2 of the total number of layers + const int mrpc_inn_lyr = 5; // 1/2 of the total number of layers + const double rad = 76.5; // cm + const double zpos = -60.0; // cm + const double length = 400.; //cm + int subsysID = 0; +} // namespace BTOF + +void BToFInit() +{ + BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 85.); + BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, BTOF::length / 2.0 + 10.0); + BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -BTOF::length / 2.0 - 10.0); +} + +double Build_G4_BTof(PHG4Reco* g4Reco, + double tof_rad = 82.0, + double zpos = -60.0, + double tof_length = 400.0) +{ + int verbosity = std::max(Enable::VERBOSITY, Enable::BTOF_VERBOSITY); + bool OverlapCheck = Enable::OVERLAPCHECK || Enable::BTOF_OVERLAPCHECK; + + gSystem->Load("libfun4all"); + gSystem->Load("libg4detectors.so"); + gSystem->Load("libg4trackfastsim.so"); + + double rsum = 0.0; + + //mRPC TOF parameters + double gas_gap = 0.0220; // 220 microns , 12 gas gaps + double mrpc_in_thick = 0.04; // 400 microns, 10 think glass + double mrpc_out_thick = 0.07; // 700 microns, 4 thick glass + double pcb_thickness = 0.06; // 600 microns, 3 PCBs + double cu_thickness = 0.003; // 30 microns, layer over pcb, (1 each on outer pcb and 2 on central pcb = 4) + double carbon_thickness = 0.01; // 100 microns , 2 layers + double mylar_thickness = 0.04; // 400 microns, 4 layers + double honeycomb_thickness = 0.75; // 7.5 mm, 2 honeycomb + + //------------------------------- + // mRPC material needs to change to plate glass (rad length 10.69 cm). + //Currently implemented G4_Si has rad length of 9.37 cm. + //Changing material to plate glass will increase radiation length by 10% w.r.t. to 1.X0(~10%) + // and the new radiation length will be 1.1X0 (~ 11%).Assuming G4_Si for mRPC is reasonable for the time being + //----------------------------------- + + PHG4CylinderSubsystem* tof_cyl; + + //Honeycomb + tof_cyl = new PHG4CylinderSubsystem("ToF_honeycomb_bottom", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", tof_rad); + tof_cyl->set_string_param("material", "NOMEX"); + tof_cyl->set_double_param("thickness", honeycomb_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(tof_cyl); + ++BTOF::subsysID; + if (verbosity > 1) cout << " bottom HC :" << tof_rad << endl; + + //PCB + rsum = tof_rad + honeycomb_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_pcb_bottom", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "FR4"); + tof_cyl->set_double_param("thickness", pcb_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(tof_cyl); + ++BTOF::subsysID; + if (verbosity > 1) cout << " bototm PCB " << rsum << endl; + + //PCB Cu + rsum += pcb_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_bottompcb_cu", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_Cu"); + tof_cyl->set_double_param("thickness", cu_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); // Length restricted to active area + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(tof_cyl); + ++BTOF::subsysID; + if (verbosity > 1) cout << " PCB Cu :" << rsum << endl; + + //Mylar + rsum += cu_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_mylar_bottom", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_MYLAR"); + tof_cyl->set_double_param("thickness", mylar_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(tof_cyl); + ++BTOF::subsysID; + if (verbosity > 1) cout << " Mylar : " << rsum << endl; + + //Carbon layer + rsum += mylar_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_Carbon_bottom", BTOF::subsysID); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_C"); + tof_cyl->set_double_param("thickness", carbon_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(tof_cyl); + ++BTOF::subsysID; + if (verbosity > 1) cout << " Carbon :" << rsum << endl; + + //Outside Glass layer + rsum += carbon_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_glass_bottom", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_Si"); + tof_cyl->set_double_param("thickness", mrpc_out_thick); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + + if (verbosity > 1) cout << " Glass outside :" << rsum << endl; + + //Active gas gap abd mRPC inner glass layers + double rsum_gasin_begin = rsum + mrpc_out_thick; + double rsum_innglass_begin = rsum_gasin_begin + gas_gap; + double rsum_gasin; + double rsum_innglass; + for (int layer = 0; layer < BTOF::gas_lyr; layer++) + { + rsum_gasin = rsum_gasin_begin + layer * gas_gap + layer * mrpc_in_thick; + tof_cyl = new PHG4CylinderSubsystem(Form("ToF_gas_%d", layer), BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum_gasin); + tof_cyl->set_string_param("material", "G4_Ar"); + tof_cyl->set_double_param("thickness", gas_gap); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(1); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " gas inner" << layer << " : " << rsum_gasin << endl; + + if (layer < BTOF::mrpc_inn_lyr) + { + rsum_innglass = rsum_gasin_begin + layer * mrpc_in_thick + (layer + 1) * gas_gap; + tof_cyl = new PHG4CylinderSubsystem(Form("ToF_inner_glass_%d", layer), BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum_innglass); + tof_cyl->set_string_param("material", "G4_Si"); + tof_cyl->set_double_param("thickness", mrpc_in_thick); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " inner mrpc" << layer << " : " << rsum_innglass << endl; + } + } + rsum = rsum_gasin; + + //Middle thick Glass layer + rsum += gas_gap; + tof_cyl = new PHG4CylinderSubsystem("ToF_glass_bot_mid", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_Si"); + tof_cyl->set_double_param("thickness", mrpc_out_thick); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " mid bottom glass :" << rsum << endl; + + //Middle Carbon layer + rsum += mrpc_out_thick; + tof_cyl = new PHG4CylinderSubsystem("ToF_Carbon_bot_mid", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_C"); + tof_cyl->set_double_param("thickness", carbon_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " mid bottom Carbon :" << rsum << endl; + + //Middle mylar layer + + rsum += carbon_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_mylar_bot_mid", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_MYLAR"); + tof_cyl->set_double_param("thickness", mylar_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " Mid bottom Mylar : " << rsum << endl; + + //Middle PCB bottom Cu + rsum += mylar_thickness /*cu_thickness*/; + tof_cyl = new PHG4CylinderSubsystem("ToF_midpcb_cub", BTOF::subsysID); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_Cu"); + tof_cyl->set_double_param("thickness", cu_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); // Length restricted to active area + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " mid PCB bottom cu :" << rsum << endl; + + //Mid PCB + rsum += cu_thickness /*pcb_thickness*/; + tof_cyl = new PHG4CylinderSubsystem("ToF_pcb_mid", BTOF::subsysID); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "FR4"); + tof_cyl->set_double_param("thickness", pcb_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " mid PCB " << rsum << endl; + + //Middle PCB top Cu + rsum += pcb_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_midpcb_tcu", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_Cu"); + tof_cyl->set_double_param("thickness", cu_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); // Length restricted to active area + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " mid PCB top cu :" << rsum << endl; + + //Middle top mylar layer + + rsum += cu_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_mylar_topmid", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_MYLAR"); + tof_cyl->set_double_param("thickness", mylar_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " Mid top Mylar : " << rsum << endl; + + //Middle top carbon layer + rsum += mylar_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_Carbon_top_mid", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_C"); + tof_cyl->set_double_param("thickness", carbon_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " mid top Carbon :" << rsum << endl; + + //Middle top thick glass + rsum += carbon_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_glass_top_mid", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_Si"); + tof_cyl->set_double_param("thickness", mrpc_out_thick); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " mid top glass :" << rsum << endl; + + //Upper half gas gaps and mRPCs + //Active gas gap abd mRPC inner glass layers + double rsum_gasin_begin_uphalf = (rsum + mrpc_out_thick); + double rsum_innglass_begin_uphalf = (rsum_gasin_begin_uphalf + gas_gap); + double rsum_gasin_uphalf; + double rsum_innglass_uphalf; + for (int layer = 0; layer < BTOF::gas_lyr; layer++) + { + rsum_gasin_uphalf = rsum_gasin_begin_uphalf + layer * gas_gap + layer * mrpc_in_thick; + tof_cyl = new PHG4CylinderSubsystem(Form("ToF_gas_%d", layer + 6), BTOF::subsysID); //stupid way to implement indexing of active gas layer for the upper half of ToF + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum_gasin_uphalf); + tof_cyl->set_string_param("material", "G4_Ar"); + tof_cyl->set_double_param("thickness", gas_gap); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(1); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " gas inner" << layer << " : " << rsum_gasin_uphalf << endl; + + if (layer < BTOF::mrpc_inn_lyr) + { + rsum_innglass_uphalf = rsum_gasin_begin_uphalf + layer * mrpc_in_thick + (layer + 1) * gas_gap; + tof_cyl = new PHG4CylinderSubsystem(Form("ToF_inner_up_half_glass_%d", layer), BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum_innglass_uphalf); + tof_cyl->set_string_param("material", "G4_Si"); + tof_cyl->set_double_param("thickness", mrpc_in_thick); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " inner mrpc" << layer << " : " << rsum_innglass_uphalf << endl; + } + } + rsum = rsum_gasin_uphalf; + + //top outer glass + rsum += gas_gap; + tof_cyl = new PHG4CylinderSubsystem("ToF_glass_top", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_Si"); + tof_cyl->set_double_param("thickness", mrpc_out_thick); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " top glass :" << rsum << endl; + + // Carbon layer + rsum += mrpc_out_thick; + tof_cyl = new PHG4CylinderSubsystem("ToF_Carbon_top", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_C"); + tof_cyl->set_double_param("thickness", carbon_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " Carbon :" << rsum << endl; + + //Mylar + rsum += carbon_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_mylar_top", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_MYLAR"); + tof_cyl->set_double_param("thickness", mylar_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << "Mylar :" << rsum << endl; + + //PCB Cu + rsum += mylar_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_toppcb_cu", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "G4_Cu"); + tof_cyl->set_double_param("thickness", cu_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); // Length restricted to active area + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " PCB cu :" << rsum << endl; + + //Top PCB + rsum += cu_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_pcb_top", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", rsum); + tof_cyl->set_string_param("material", "FR4"); + tof_cyl->set_double_param("thickness", pcb_thickness); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " top PCB " << rsum << endl; + + //Honeycomb + rsum += pcb_thickness; + tof_cyl = new PHG4CylinderSubsystem("ToF_honeycomb_top", BTOF::subsysID); + tof_cyl->Verbosity(verbosity); + tof_cyl->set_double_param("radius", tof_rad); + tof_cyl->set_string_param("material", "NOMEX"); + tof_cyl->set_double_param("thickness", honeycomb_thickness); + tof_cyl->SetActive(0); + tof_cyl->set_int_param("lengthviarapidity", 0); + tof_cyl->set_double_param("place_z", zpos); + tof_cyl->set_double_param("length", tof_length); + tof_cyl->SuperDetector("bTOF"); + tof_cyl->SetActive(0); + tof_cyl->OverlapCheck(OverlapCheck); + ++BTOF::subsysID; + g4Reco->registerSubsystem(tof_cyl); + if (verbosity > 1) cout << " Top honeycomb :" << rsum << endl; + + if (verbosity > 1) cout << " tof thickness :" << tof_rad << endl; + return tof_rad; +} + +double BToFSetup(PHG4Reco* g4Reco) +{ + double radius = 0; + + radius = Build_G4_BTof(g4Reco, + BTOF::rad, + BTOF::zpos, + BTOF::length); + + for (int igap = 0; igap < BTOF::gas_lyr + 6; igap++) + { + //Uncomment below if one wants tracking evaluation + /* + if (TRACKING::FastKalmanFilter) + TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + string(Form("ToF_gas_%d", igap)), // const std::string& phg4hitsNames, + PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype, + 1, //1. / sqrt(12.), // const float radres, + 5.0e-1,//55e-4, // const float phires, + 5.0e-1,//55e-4, // const float lonres, + 1, // const float eff, + 0); // const float noise + + */ + + //Reference plane projection at initial R of ToF + TRACKING::FastKalmanFilter->add_cylinder_state(string("G4HIT_") + string(Form("ACTIVEGAS_BTOF_%d", igap)), 82.0); + TRACKING::ProjectionNames.insert(string("G4HIT_") + string(Form("ACTIVEGAS_BTOF_%d", igap))); + } + return radius; // cm +} + +void BToF_Reco(int verbosity = 0) +{ + //--------------- + // Load libraries + //--------------- + gSystem->Load("libfun4all.so"); + gSystem->Load("libg4detectors.so"); + + //--------------- + // Fun4All server + //--------------- + + Fun4AllServer* se = Fun4AllServer::instance(); + + return; +} + +#endif diff --git a/common/G4_Barrel_EIC.C b/common/G4_Barrel_EIC.C index cb9132ea..888c43a5 100644 --- a/common/G4_Barrel_EIC.C +++ b/common/G4_Barrel_EIC.C @@ -16,20 +16,21 @@ using namespace std; namespace Enable { bool BARREL = false; + bool BARREL_OVERLAPCHECK = false; } // namespace Enable //-----------------------------------------------------------------------------------// void BarrelInit() { } -void BarrelFastKalmanFilterConfig(PHG4TrackFastSim * kalman_filter) +void BarrelFastKalmanFilterConfigSVTX(PHG4TrackFastSim * kalman_filter, int ilay, double radius, bool addproj) { // import Kalman filter config (lines 226 to 246 here: https://github.com/eic/g4lblvtx/blob/master/macros/auxiliary_studies/simplified_geometry/Fun4All_G4_simplified_v2.C): // add Vertexing Layers kalman_filter->add_phg4hits( - "G4HIT_SVTX", // const std::string& phg4hitsNames, + Form("G4HIT_SVTX_%d",ilay), // const std::string& phg4hitsNames, PHG4TrackFastSim::Cylinder, 999., // radial-resolution [cm] 10. / 10000. / sqrt(12.), // azimuthal-resolution [cm] @@ -37,10 +38,15 @@ void BarrelFastKalmanFilterConfig(PHG4TrackFastSim * kalman_filter) 1, // efficiency, 0 // noise hits ); + kalman_filter->add_cylinder_state(Form("SVTX_%d",ilay), radius); + if(addproj)TRACKING::ProjectionNames.insert(Form("SVTX_%d",ilay)); +} +void BarrelFastKalmanFilterConfigBARR(PHG4TrackFastSim * kalman_filter, int ilay, double radius, bool addproj) +{ // add Barrel Layers kalman_filter->add_phg4hits( - "G4HIT_BARR", // const std::string& phg4hitsNames, + Form("G4HIT_BARR_%d",ilay), // const std::string& phg4hitsNames, PHG4TrackFastSim::Cylinder, 999., // radial-resolution [cm] 10. / 10000. / sqrt(12.), // azimuthal-resolution [cm] @@ -48,6 +54,8 @@ void BarrelFastKalmanFilterConfig(PHG4TrackFastSim * kalman_filter) 1, // efficiency, 0 // noise hits ); + kalman_filter->add_cylinder_state(Form("BARR_%d",ilay), radius); + if(addproj)TRACKING::ProjectionNames.insert(Form("BARR_%d",ilay)); } @@ -55,12 +63,13 @@ void BarrelFastKalmanFilterConfig(PHG4TrackFastSim * kalman_filter) //-----------------------------------------------------------------------------------// void Barrel(PHG4Reco *g4Reco, int det_ver = 3) { + bool OverlapCheck = Enable::OVERLAPCHECK || Enable::BARREL_OVERLAPCHECK; // import Geometry (lines 111 to 148 in https://github.com/eic/g4lblvtx/blob/master/macros/auxiliary_studies/simplified_geometry/Fun4All_G4_simplified_v2.C): PHG4CylinderSubsystem *cyl(nullptr); //--------------------------- // Vertexing - double si_vtx_r_pos[] = {3.30, 5.70, 8.10}; + double si_vtx_r_pos[] = {3.3, 5.7, 8.5}; const int nVtxLayers = sizeof(si_vtx_r_pos) / sizeof(*si_vtx_r_pos); for (int ilayer = 0; ilayer < nVtxLayers; ilayer++) { @@ -68,35 +77,47 @@ void Barrel(PHG4Reco *g4Reco, int det_ver = 3) cyl->set_string_param("material", "G4_Si"); cyl->set_double_param("radius", si_vtx_r_pos[ilayer]); cyl->set_double_param("thickness", 0.05 / 100. * 9.37); - cyl->set_double_param("place_z", 0); - cyl->set_double_param("length", 30.); + cyl->set_double_param("place_z", 0.); + cyl->set_double_param("length", 27); cyl->SetActive(); - cyl->SuperDetector("SVTX"); +// cyl->SuperDetector("SVTX"); breakout SVTX into individual layers + cyl->OverlapCheck(OverlapCheck); g4Reco->registerSubsystem(cyl); + + BarrelFastKalmanFilterConfigSVTX(TRACKING::FastKalmanFilter, ilayer, si_vtx_r_pos[ilayer],true); + BarrelFastKalmanFilterConfigSVTX(TRACKING::FastKalmanFilterInnerTrack, ilayer, si_vtx_r_pos[ilayer],false); + BarrelFastKalmanFilterConfigSVTX(TRACKING::FastKalmanFilterSiliconTrack, ilayer, si_vtx_r_pos[ilayer],false); } //--------------------------- // Barrel - double si_r_pos[] = {21., 22.68}; + + double z_e_length[] = {-27, -27.}; + double z_h_length[] = {27., 27.}; + double si_r_pos[] = {21, 22.68}; // Modified on 29th Oct to account for new struture design const int nTrckLayers = sizeof(si_r_pos) / sizeof(*si_r_pos); - double si_z_length[] = {60., 60.}; + for (int ilayer = 0; ilayer < nTrckLayers; ilayer++) { + //cout << "Radius " << ilayer + 1 << ": " << si_r_pos[ilayer] << "cms \t e-length : " << z_e_length[ilayer] << "cms \t h-length : " << z_h_length[ilayer] << "cms"<< endl; + //cout << "eslope : " << e_slope1 << " \n hslope : " << h_slope1 << " \n zleft : " << z_e_length[ilayer] << "\n zright : " << z_h_length[ilayer] << " \n radius : " << si_r_pos[ilayer] << endl ; cyl = new PHG4CylinderSubsystem("BARR", ilayer); cyl->set_string_param("material", "G4_Si"); cyl->set_double_param("radius", si_r_pos[ilayer]); cyl->set_double_param("thickness", 0.05 / 100. * 9.37); - cyl->set_double_param("place_z", 0); - cyl->set_double_param("length", si_z_length[ilayer]); + cyl->set_double_param("place_z", (z_h_length[ilayer] + z_e_length[ilayer])/2); + cyl->set_double_param("length", (z_h_length[ilayer] - z_e_length[ilayer])); cyl->SetActive(); - cyl->SuperDetector("BARR"); + cyl->OverlapCheck(OverlapCheck); +// cyl->SuperDetector("BARR"); breakout BARR into individual layers g4Reco->registerSubsystem(cyl); - } - - BarrelFastKalmanFilterConfig(TRACKING::FastKalmanFilter); - BarrelFastKalmanFilterConfig(TRACKING::FastKalmanFilterInnerTrack); + BarrelFastKalmanFilterConfigBARR(TRACKING::FastKalmanFilter, ilayer, si_r_pos[ilayer],true); + BarrelFastKalmanFilterConfigBARR(TRACKING::FastKalmanFilterInnerTrack, ilayer, si_r_pos[ilayer],false); + BarrelFastKalmanFilterConfigBARR(TRACKING::FastKalmanFilterSiliconTrack, ilayer, si_r_pos[ilayer],false); + } - BarrelFastKalmanFilterConfig(TRACKING::FastKalmanFilterSiliconTrack); + return si_r_pos[1]; } #endif + diff --git a/common/G4_DIRC.C b/common/G4_DIRC.C index cca50238..f8e57303 100644 --- a/common/G4_DIRC.C +++ b/common/G4_DIRC.C @@ -44,28 +44,27 @@ void DIRCSetup(PHG4Reco* g4Reco) bool OverlapCheck = Enable::OVERLAPCHECK || Enable::DIRC_OVERLAPCHECK; int verbosity = std::max(Enable::VERBOSITY, Enable::DIRC_VERBOSITY); + // Per request from DIRC group on Oct-18 + // Import DIRC geometry from https://github.com/niwgit/fun4all_eicmacros/blob/6b1fa3b/common/G4_DIRC_new.C#L47 G4EicDircSubsystem *dircSubsys = new G4EicDircSubsystem("hpDIRC"); dircSubsys->SuperDetector("hpDIRC"); - dircSubsys->set_double_param("rMin", 74.1 * Enable::DIRC_SCALE); - dircSubsys->set_double_param("rMin_inner", 60.0 * Enable::DIRC_SCALE); - dircSubsys->set_double_param("length", (287 + 168) * Enable::DIRC_SCALE); - dircSubsys->set_double_param("NBars", 11); - dircSubsys->set_double_param("Radius", 75.0 * Enable::DIRC_SCALE); - dircSubsys->set_double_param("Prizm_width", 38.65 * Enable::DIRC_SCALE); + dircSubsys->set_double_param("NBars", 10); + dircSubsys->set_double_param("Radius", 72.96 * Enable::DIRC_SCALE); + dircSubsys->set_double_param("Prizm_width", 35.135 * Enable::DIRC_SCALE); dircSubsys->set_double_param("Prizm_length", 30.0 * Enable::DIRC_SCALE); - dircSubsys->set_double_param("Prizm_height_at_lens", 5 * Enable::DIRC_SCALE); // override internal default - dircSubsys->set_double_param("Bar_thickness", 1.7 * Enable::DIRC_SCALE); + dircSubsys->set_double_param("Prizm_height_at_lens", 5.0 * Enable::DIRC_SCALE); + dircSubsys->set_double_param("Bar_thickness", 1.725 * Enable::DIRC_SCALE); dircSubsys->set_double_param("Bar_width", 3.5 * Enable::DIRC_SCALE); dircSubsys->set_double_param("BarL_length", 122.5 * Enable::DIRC_SCALE); dircSubsys->set_double_param("BarS_length", 56.0 * Enable::DIRC_SCALE); dircSubsys->set_double_param("Mirror_height", 2.0 * Enable::DIRC_SCALE); - dircSubsys->set_double_param("z_shift", -45 * Enable::DIRC_SCALE); + dircSubsys->set_double_param("z_shift", -43.75 * Enable::DIRC_SCALE); dircSubsys->set_int_param("Geom_type", 0); // 0-whole DIRC, 1-one bar box dircSubsys->set_int_param("Lens_id", 3); // 3- 3-layer spherical lens dircSubsys->set_int_param("MCP_rows", 6); dircSubsys->set_int_param("MCP_columns", 4); - dircSubsys->set_int_param("NBoxes",12); - dircSubsys->set_int_param("Bar_pieces", 4); + dircSubsys->set_int_param("NBoxes", 12); // number of bar boxes + dircSubsys->set_int_param("Bar_pieces", 4); // pieces glued in one bar if (Enable::DIRC_DISABLE_PHOTON_SIMULATION) dircSubsys->set_int_param("disable_photon_sim", 1); diff --git a/common/G4_EToF.C b/common/G4_EToF.C new file mode 100644 index 00000000..bd3f4f1f --- /dev/null +++ b/common/G4_EToF.C @@ -0,0 +1,130 @@ +#ifndef MACRO_G4EToF_C +#define MACRO_G4EToF_C + +#include + +#include +#include + +#include +#include + +R__LOAD_LIBRARY(libg4etof.so) +//R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libg4detectors.so) + +namespace Enable +{ + bool ETOF = false; + bool ETOF_GAS = false; + bool ETOF_OVERLAPCHECK = false; + int ETOF_VERBOSITY = 0; +} // namespace Enable + +namespace ETOF +{ + int f_gas_lyr = 6.; // total number of layers + int f_mrpc_lyr = 7.; //total number of layers + int b_gas_lyr = 6.; // total number of layers + int b_mrpc_lyr = 7.; //total number of layers + int pcb_lyr = 3.; + int mylar_lyr = 4.; + int cu_lyr = 4.; + int carbon_lyr = 4.; + int honeycomb_lyr = 2.; + double z_start = -165.; // cm , from left side of -ve Z axis moving towards origin + double R_in = 6.5; // cm + double R_out = 68.; //cm + double gas_gap = 0.0220; // 220 microns + double mrpc_thick = 0.04; // 400 microns + double pcb_thick = 0.06; // 600 microns + double cu_thick = 0.003; // 30 microns, layer over pcb, (1 each on outer pcb and 2 on central pcb = 4) + double carbon_thick = 0.01; // 100 microns , 2 layers + double mylar_thick = 0.04; // 400 microns, 4 layers + double honeycomb_thick = 0.75; // 7.5 mm, 2 honeycomb + + double tof_width = (f_gas_lyr + b_gas_lyr) * gas_gap + (f_mrpc_lyr + b_mrpc_lyr) * mrpc_thick + carbon_lyr * carbon_thick + pcb_lyr * pcb_thick + cu_lyr * cu_thick + mylar_lyr * mylar_thick + honeycomb_lyr * honeycomb_thick; + + double z_end = (z_start + tof_width); + +} // namespace ETOF + +void ETOFInit() +{ + BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, ETOF::R_out); + BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, ETOF::z_end - 5); + BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, ETOF::z_start + 5); +} + +void ETOFSetup(PHG4Reco* g4Reco) +{ + bool GasActive = Enable::ABSORBER || Enable::ETOF_GAS; + bool OverlapCheck = Enable::OVERLAPCHECK || Enable::ETOF_OVERLAPCHECK; + int verbosity = std::max(Enable::VERBOSITY, Enable::ETOF_VERBOSITY); + + Fun4AllServer* se = Fun4AllServer::instance(); + se->Verbosity(verbosity); + + PHG4ECAPToFSubsystem* eTOF = new PHG4ECAPToFSubsystem("eTOF", 1); + eTOF->Verbosity(verbosity); + + eTOF->set_int_param("n_fgas_layer", ETOF::f_gas_lyr); + eTOF->set_int_param("n_bgas_layer", ETOF::b_gas_lyr); + eTOF->set_double_param("gas_gap", ETOF::gas_gap); + eTOF->set_double_param("glass_thick", ETOF::mrpc_thick); + eTOF->set_double_param("Carbon_thick", ETOF::carbon_thick); + eTOF->set_double_param("pcb_thick", ETOF::pcb_thick); + eTOF->set_double_param("cu_thick", ETOF::cu_thick); + eTOF->set_double_param("honeycomb_thick", ETOF::honeycomb_thick); + eTOF->set_double_param("mylar_thick", ETOF::mylar_thick); + eTOF->set_double_param("Rin", ETOF::R_in); + eTOF->set_double_param("Rout", ETOF::R_out); + eTOF->set_double_param("z_begin", ETOF::z_start); + eTOF->set_int_param("use_g4steps", 1); + eTOF->SetActive(1); + eTOF->SuperDetector("ETOF"); + if (GasActive) + { + eTOF->SetAbsorberActive(1); + } + eTOF->OverlapCheck(OverlapCheck); + + g4Reco->registerSubsystem(eTOF); + + //trd_hcap->OverlapCheck(1); + + if (verbosity > 1) cout << " ETOF gas layer :" << ETOF::f_gas_lyr << endl; + + if (TRACKING::FastKalmanFilter) + { + /* + TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + string(Form("ACTIVEGAS_ETOF")), // const std::string& phg4hitsNames, + PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + 1, //1. / sqrt(12.), // const float radres, + 5.0e-1,//55e-4, // const float phires, + 5.0e-1,//55e-4, // const float lonres, + 1, // const float eff, + 0); // const float noise + + */ + + //Reference plane projection at initial R of ToF + TRACKING::FastKalmanFilter->add_zplane_state(string("G4HIT_") + string(Form("ACTIVEGAS_ETOF")), ETOF::z_start); + TRACKING::ProjectionNames.insert(string("G4HIT_") + string(Form("ACTIVEGAS_ETOF"))); + } + return; +} + +void ETOF_Reco() +{ + gSystem->Load("libfun4all.so"); + gSystem->Load("libg4detectors.so"); + + int verbosity = std::max(Enable::VERBOSITY, Enable::ETOF_VERBOSITY); + Fun4AllServer* se = Fun4AllServer::instance(); + //se->Verbosity(INT_MAX-10); + + return; +} + +#endif diff --git a/common/G4_EventEvaluator.C b/common/G4_EventEvaluator.C index 43195eaa..267bc123 100644 --- a/common/G4_EventEvaluator.C +++ b/common/G4_EventEvaluator.C @@ -32,7 +32,7 @@ void Event_Eval(const std::string &filename) if (Enable::TRACKING) { eval->set_do_TRACKS(true); - //eval->set_do_HITS(true); + eval->set_do_HITS(true); eval->set_do_PROJECTIONS(true); if (G4TRACKING::DISPLACED_VERTEX) eval->set_do_VERTEX(true); @@ -40,7 +40,7 @@ void Event_Eval(const std::string &filename) eval->set_do_PID_LogLikelihood(true); } if (Enable::CEMC_CLUSTER) eval->set_do_CEMC(true); - if (Enable::EEMC_CLUSTER) eval->set_do_EEMC(true); + if (Enable::EEMC_CLUSTER || Enable::EEMCH_CLUSTER) eval->set_do_EEMC(true); if (Enable::FEMC_CLUSTER) eval->set_do_FEMC(true); if (Enable::HCALIN_CLUSTER) eval->set_do_HCALIN(true); if (Enable::HCALOUT_CLUSTER) eval->set_do_HCALOUT(true); @@ -49,6 +49,7 @@ void Event_Eval(const std::string &filename) if (Enable::DRCALO_CLUSTER) eval->set_do_DRCALO(true); if (Enable::LFHCAL_CLUSTER) eval->set_do_LFHCAL(true); if (Enable::BECAL) eval->set_do_BECAL(true); + if (Enable::EHCAL) eval->set_do_EHCAL(true); eval->set_do_MCPARTICLES(true); eval->set_do_HEPMC(Enable::EVENT_EVAL_DO_HEPMC); diff --git a/common/G4_FST_EIC.C b/common/G4_FST_EIC.C index e065194e..5471823d 100644 --- a/common/G4_FST_EIC.C +++ b/common/G4_FST_EIC.C @@ -52,24 +52,66 @@ void FST_Init() } } //-----------------------------------------------------------------------------------// -void FSTSetup(PHG4Reco *g4Reco, const double min_eta = 1.245) + +/* + +The idea is to calculate all the rmax rmin based on z and theta1 and theta2 in a python script (obj_fun.py) +Once calculated just pass the disk dimensions into this script + +*/ + +void FSTSetup(PHG4Reco *g4Reco) { const double cm = PHG4Sector::Sector_Geometry::Unit_cm(); const double mm = .1 * cm; const double um = 1e-3 * mm; + //const double max_radius = 50.; - //Design from Xuan Li @LANL - make_LANL_FST_station("FST_0", g4Reco, 35, 4, 22, 35 * um, 10e-4); //cm - make_LANL_FST_station("FST_1", g4Reco, 57.5, 4.5, 42, 35 * um, 10e-4); - make_LANL_FST_station("FST_2", g4Reco, 80, 6, 43.5, 35 * um, 10e-4); - make_LANL_FST_station("FST_3", g4Reco, 115, 9.3, 46.8, 35 * um, 10e-4); - make_LANL_FST_station("FST_4", g4Reco, 125, 9.6, 47.1, 35 * um, 10e-4); - //mirror for e-going FST, after update with new e-spectrometer - make_LANL_FST_station("EFST_0", g4Reco, -35, 4, 22, 35 * um, 10e-4); //cm - make_LANL_FST_station("EFST_1", g4Reco, -57.5, 4.5, 42, 35 * um, 10e-4); - make_LANL_FST_station("EFST_2", g4Reco, -80, 6, 43.5, 35 * um, 10e-4); - make_LANL_FST_station("EFST_3", g4Reco, -107.1, 9.3, 46.8, 35 * um, 10e-4); + +// const double bkwd_z[] = {33.2, 58.29, 80.05, 107.4}; +// double bkwd_rmin[] = {3.3, 3.3, 5.25, 6.4}; +// double bkwd_rmax[] = {15.3, 27.3, 35.25, 48.4}; + const double bkwd_z[] = {25, 52, 79, 106}; + double bkwd_rmin[] = {3.5, 3.5, 4.5, 5.5}; + double bkwd_rmax[] = {18.5, 36.5, 40.5, 41.5}; + const int n_bkwd_disk = sizeof(bkwd_z) / sizeof(*bkwd_z); + for (unsigned int i = 0; i < n_bkwd_disk; i++) + { +/* + // Below was made to auto calculate the min and max Radius + if(bkwd_z[i] < uRwell1_e_length) bkwd_rmax[i] = std::min(max_radius, e_slope1*bkwd_z[i] + e_intercept1) - 0.5; + else if (bkwd_z[i] >= uRwell1_e_length && bkwd_z[i] <= (uRwell1_e_length + uRwell_plateau_length)){bkwd_rmax[i] = uRwell1_radius - 1.5;} + else if(bkwd_z[i] > (uRwell1_e_length + uRwell_plateau_length)){bkwd_rmax[i] = std::min(max_radius, e_slope2*bkwd_z[i] + e_intercept2) - 0.5;} + else {cout << "Cannot calculate the RMax exiting" << endl; gSystem->Exit(0); } + + if(bkwd_z[i]>79.8 && bkwd_z[i]>0) bkwd_rmin[i] = (0.0521*bkwd_z[i] + 1.0); + else bkwd_rmin[i] = 3.3; +*/ + make_LANL_FST_station(Form("EST_%i", i), g4Reco, -1*bkwd_z[i], bkwd_rmin[i], bkwd_rmax[i], 35 * um, 10e-4); //cm + } + + + const double fwd_z[] = {25, 52, 73, 106, 125}; + double fwd_rmin[] = {3.5, 3.5, 4.5, 5.5, 7.5}; + double fwd_rmax[] = {18.5, 36.5, 40.5, 41.5, 43.4}; + const int n_fwd_disk = sizeof(fwd_z) / sizeof(*fwd_z); + for (unsigned int i = 0; i < n_fwd_disk; i++) + { + +/* + if(fwd_z[i] < uRwell1_h_length) fwd_rmax[i] = std::min(max_radius, h_slope1*fwd_z[i] + h_intercept1) - 0.5; + else if (fwd_z[i] >= uRwell1_h_length && fwd_z[i] <= (uRwell1_h_length + uRwell_plateau_length)){fwd_rmax[i] = uRwell1_radius - 1.5;} + //else if(fwd_z[i] > (uRwell1_h_length + uRwell_plateau_length)){fwd_rmax[i] = std::min(max_radius, h_slope2*fwd_z[i] + h_intercept2) - 0.5;} + else if(fwd_z[i] > (uRwell1_h_length + uRwell_plateau_length) && fwd_z[i] <= 130.){ fwd_rmax[i] = std::min(max_radius, h_slope2*fwd_z[i] + h_intercept2) - 0.5;} + //else if(fwd_z[i] > 113.){fwd_rmax[i] = h_slope2*(fwd_z[i] + 5.) + h_intercept2 - 0.25;} + else {cout << "Cannot calculate the RMax exiting" << endl; gSystem->Exit(0); } + + if(fwd_z[i]>66.8 && fwd_z[i]>0) fwd_rmin[i] = (0.0521*fwd_z[i] + 1.0); + else fwd_rmin[i] = 3.3; +*/ + make_LANL_FST_station(Form("FST_%i", i), g4Reco, fwd_z[i], fwd_rmin[i], fwd_rmax[i], 35 * um, 10e-4); //cm + } if (G4FST::SETTING::SUPPORTCYL) { @@ -137,21 +179,21 @@ int make_LANL_FST_station(string name, PHG4Reco *g4Reco, pitch / sqrt(12.), // const float radres, pitch / sqrt(12.), // const float phires, 50e-4 / sqrt(12.), // const float lonres, *ignored in plane detector* - 1, // const float eff, + 0.9, // const float eff, 0); // const float noise TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, pitch / sqrt(12.), // const float radres, pitch / sqrt(12.), // const float phires, 50e-4 / sqrt(12.), // const float lonres, *ignored in plane detector* - 1, // const float eff, + 0.9, // const float eff, 0); // const float noise TRACKING::FastKalmanFilterSiliconTrack->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, pitch / sqrt(12.), // const float radres, pitch / sqrt(12.), // const float phires, 50e-4 / sqrt(12.), // const float lonres, *ignored in plane detector* - 1, // const float eff, + 0.9, // const float eff, 0); // const float noise } return 0; @@ -178,3 +220,4 @@ int make_supportCyl(string name, PHG4Reco *g4Reco, double r, double t, double le return 0; } #endif + diff --git a/common/G4_GEM_EIC.C b/common/G4_GEM_EIC.C index dbc0303a..015afddb 100644 --- a/common/G4_GEM_EIC.C +++ b/common/G4_GEM_EIC.C @@ -13,7 +13,7 @@ R__LOAD_LIBRARY(libg4detectors.so) -int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin, double etamax, const int N_Sector = 8, double tilt = 0, bool doTilt = false); +int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin, double etamax, const int N_Sector = 16, double tilt = 0, bool doTilt = false); void AddLayers_MiniTPCDrift(PHG4SectorSubsystem *gem); void AddLayers_GEMDrift(PHG4SectorSubsystem *gem); @@ -48,13 +48,14 @@ void BGEM_Init() void EGEMSetup(PHG4Reco *g4Reco) { - make_GEM_station("EGEM_0", g4Reco, -120.0, -1.68, -3.5); + make_GEM_station("EGEM_0", g4Reco, -121.0, -1.668, -3.7); + //make_GEM_station("EGEM_0", g4Reco, -121.0, -1.68, -3.7); // make_GEM_station("EGEM_1", g4Reco, -190.0, -1.85, -3.6); // replaced by LGAD-TTL } -void FGEMSetup(PHG4Reco *g4Reco, const int N_Sector = 8) +void FGEMSetup(PHG4Reco *g4Reco, const int N_Sector = 16) { - make_GEM_station("FGEM_0", g4Reco, 160.0, 1.65, 3.5, N_Sector); + make_GEM_station("FGEM_0", g4Reco, 287.0, 1.3, 3.6, N_Sector); // make_GEM_station("FGEM_1", g4Reco, 285.0, 1.2, 3.5, N_Sector);// replaced by LGAD-TTL } @@ -110,12 +111,13 @@ void AddLayers_GEMDrift(PHG4SectorSubsystem *gem) } int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin, - double etamax, const int N_Sector = 8, double tilt = 0, bool doTilt = false) + double etamax, const int N_Sector = 16, double tilt = 0, bool doTilt = false) { // cout // << "make_GEM_station - GEM construction with PHG4SectorSubsystem - make_GEM_station_EdgeReadout of " // << name << endl; + double zpos_lab(zpos); double polar_angle = 0; if (doTilt) @@ -165,20 +167,26 @@ int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin, gem->OverlapCheck(Enable::OVERLAPCHECK); g4Reco->registerSubsystem(gem); + // Following Nov-5 tracking meeting, update to muRwell performance of 55um resolution 2D readout if (TRACKING::FastKalmanFilter) + { TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, - 1. / sqrt(12.), // const float radres, - 50e-4, // const float phires, + 55e-4, // const float radres, + 55e-4, // const float phires, 100e-4, // const float lonres, 1, // const float eff, 0); // const float noise - if (TRACKING::FastKalmanFilterInnerTrack) + TRACKING::FastKalmanFilter->add_zplane_state(name, zpos_lab); + TRACKING::ProjectionNames.insert(name); + } + + if (TRACKING::FastKalmanFilterInnerTrack and zpos_lab<0) TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, - 1. / sqrt(12.), // const float radres, - 50e-4, // const float phires, + 55e-4, // const float radres, + 55e-4, // const float phires, 100e-4, // const float lonres, 1, // const float eff, 0); // const float noise @@ -186,3 +194,4 @@ int make_GEM_station(string name, PHG4Reco *g4Reco, double zpos, double etamin, return 0; } #endif + diff --git a/common/G4_HToF.C b/common/G4_HToF.C new file mode 100644 index 00000000..26fa308a --- /dev/null +++ b/common/G4_HToF.C @@ -0,0 +1,128 @@ +#ifndef MACRO_G4HToF_C +#define MACRO_G4HToF_C + +#include + +#include +#include + +#include +#include + +R__LOAD_LIBRARY(libg4etof.so) +//R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libg4detectors.so) + +namespace Enable +{ + bool HTOF = false; + bool HTOF_GAS = false; + bool HTOF_OVERLAPCHECK = true; + int HTOF_VERBOSITY = 0; +} // namespace Enable + +namespace HTOF +{ + int f_gas_lyr = 6.; // total number of layers + int f_mrpc_lyr = 7.; //total number of layers + int b_gas_lyr = 6.; // total number of layers + int b_mrpc_lyr = 7.; //total number of layers + int pcb_lyr = 3.; + int mylar_lyr = 4.; + int cu_lyr = 4.; + int carbon_lyr = 4.; + int honeycomb_lyr = 2.; + double z_start = 287.; //cm, starting point from left on +ve Z axis moving away from origin + double R_in = 15.0; // cm + double R_out = 170.; //cm + double gas_gap = 0.0220; // 220 microns + double mrpc_thick = 0.04; // 400 microns + double pcb_thick = 0.06; // 600 microns + double cu_thick = 0.003; // 30 microns, layer over pcb, (1 each on outer pcb and 2 on central pcb = 4) + double carbon_thick = 0.01; // 100 microns , 2 layers + double mylar_thick = 0.04; // 400 microns, 4 layers + double honeycomb_thick = 0.75; // 7.5 mm, 2 honeycomb + + double tof_width = (f_gas_lyr + b_gas_lyr) * gas_gap + (f_mrpc_lyr + b_mrpc_lyr) * mrpc_thick + carbon_lyr * carbon_thick + pcb_lyr * pcb_thick + cu_lyr * cu_thick + mylar_lyr * mylar_thick + honeycomb_lyr * honeycomb_thick; + + double z_end = (z_start + tof_width); + +} // namespace HTOF + +void HTOFInit() +{ + BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, HTOF::R_out); + BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, HTOF::z_end + 5); + BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, HTOF::z_start - 5); +} + +void HTOFSetup(PHG4Reco* g4Reco) +{ + int verbosity = std::max(Enable::VERBOSITY, Enable::HTOF_VERBOSITY); + bool GasActive = Enable::ABSORBER || Enable::HTOF_GAS; + bool OverlapCheck = Enable::OVERLAPCHECK || Enable::HTOF_OVERLAPCHECK; + + Fun4AllServer* se = Fun4AllServer::instance(); + se->Verbosity(verbosity); + + PHG4ECAPToFSubsystem* hTOF = new PHG4ECAPToFSubsystem("hTOF", 1); + hTOF->Verbosity(verbosity); + hTOF->set_int_param("n_fgas_layer", HTOF::f_gas_lyr); + hTOF->set_int_param("n_bgas_layer", HTOF::b_gas_lyr); + hTOF->set_double_param("gas_gap", HTOF::gas_gap); + hTOF->set_double_param("glass_thick", HTOF::mrpc_thick); + hTOF->set_double_param("Carbon_thick", HTOF::carbon_thick); + hTOF->set_double_param("pcb_thick", HTOF::pcb_thick); + hTOF->set_double_param("cu_thick", HTOF::cu_thick); + hTOF->set_double_param("honeycomb_thick", HTOF::honeycomb_thick); + hTOF->set_double_param("mylar_thick", HTOF::mylar_thick); + hTOF->set_double_param("Rin", HTOF::R_in); + hTOF->set_double_param("Rout", HTOF::R_out); + hTOF->set_double_param("z_begin", HTOF::z_start); + hTOF->set_int_param("use_g4steps", 1); + hTOF->SetActive(1); + hTOF->SuperDetector("HTOF"); + if (GasActive) + { + hTOF->SetAbsorberActive(1); + } + hTOF->OverlapCheck(OverlapCheck); + + g4Reco->registerSubsystem(hTOF); + + //trd_hcap->OverlapCheck(1); + + if (verbosity > 1) cout << " HTOF gas layer :" << HTOF::f_gas_lyr << endl; + + if (TRACKING::FastKalmanFilter) + { + /* + TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + string(Form("ACTIVEGAS_HTOF")), // const std::string& phg4hitsNames, + PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + 1, //1. / sqrt(12.), // const float radres, + 5.0e-1,//55e-4, // const float phires, + 5.0e-1,//55e-4, // const float lonres, + 1, // const float eff, + 0); // const float noise + + */ + //Reference plane projection at initial R of ToF + TRACKING::FastKalmanFilter->add_zplane_state(string("G4HIT_") + string(Form("ACTIVEGAS_HTOF")), HTOF::z_end); + TRACKING::ProjectionNames.insert(string("G4HIT_") + string(Form("ACTIVEGAS_HTOF"))); + } + return; +} + +void HTOF_Reco() +{ + gSystem->Load("libfun4all.so"); + gSystem->Load("libg4detectors.so"); + + int verbosity = std::max(Enable::VERBOSITY, Enable::HTOF_VERBOSITY); + Fun4AllServer* se = Fun4AllServer::instance(); + //se->Verbosity(INT_MAX-10); + + return; +} + +#endif diff --git a/common/G4_HcalIn_ref.C b/common/G4_HcalIn_ref.C index f45f2019..c9a74c30 100644 --- a/common/G4_HcalIn_ref.C +++ b/common/G4_HcalIn_ref.C @@ -134,7 +134,7 @@ double HCalInner(PHG4Reco *g4Reco, hcal->set_double_param("outer_radius", 138.5); hcal->set_double_param("scinti_outer_radius", 138.0); - hcal->set_double_param("inner_radius", 135.0); + hcal->set_double_param("inner_radius", 134.0); hcal->set_double_param("tilt_angle", 36.15); hcal->set_double_param("size_z", length); hcal->set_int_param("n_scinti_tiles", 0); diff --git a/common/G4_TRD.C b/common/G4_TRD.C new file mode 100644 index 00000000..8ad5c537 --- /dev/null +++ b/common/G4_TRD.C @@ -0,0 +1,100 @@ +#ifndef MACRO_G4TRD_C +#define MACRO_G4TRD_C + +#include + +#include +#include +#include +#include + +R__LOAD_LIBRARY(libg4trd.so) +R__LOAD_LIBRARY(libg4detectors.so) + +namespace Enable +{ + bool TRD = false; + //bool TRD_ABSORBER = false; + bool TRD_GAS = false; + bool TRD_OVERLAPCHECK = true; + int TRD_VERBOSITY = 0; +} // namespace Enable + +namespace TRD +{ + double R_max = 180.; + double R_min = 15.; + double z_mid = 200. + 20; + double half_length = 6.5; // Mother volume, radiator = 10 cm + double z_min = z_mid - half_length; + double z_max = z_mid + half_length + 10.; +} // namespace TRD +void TRDInit() +{ + BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, TRD::R_max); + BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, TRD::z_max); + BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, TRD::z_min); +} + +void TRDSetup(PHG4Reco* g4Reco) +{ + int verbosity = std::max(Enable::VERBOSITY, Enable::TRD_VERBOSITY); + Fun4AllServer* se = Fun4AllServer::instance(); + se->Verbosity(verbosity); + + //bool AbsorberActive = Enable::ABSORBER || Enable::TRD_ABSORBER; + bool GasActive = Enable::ABSORBER || Enable::TRD_GAS; + bool OverlapCheck = Enable::OVERLAPCHECK || Enable::TRD_OVERLAPCHECK; + PHG4TRDSubsystem* trd_hcap = new PHG4TRDSubsystem("TRD_hcap", 1); + + trd_hcap->set_double_param("ThicknessZ", 2. * TRD::half_length); + trd_hcap->set_double_param("RIn", TRD::R_min); + trd_hcap->set_double_param("ROut", TRD::R_max); + trd_hcap->set_double_param("PosZ", TRD::z_mid); + trd_hcap->set_double_param("det_RIn", TRD::R_min); + trd_hcap->set_double_param("det_ROut", TRD::R_max); + trd_hcap->SetActive(1); + trd_hcap->SuperDetector("TRD"); + //if(AbsorberActive) + if (GasActive) + { + trd_hcap->SetAbsorberActive(1); + } + trd_hcap->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(trd_hcap); + + if (verbosity > 0) + { + cout << " Min Z :" + << " " << TRD::z_min << " Max Z :" << TRD::z_max << endl; + cout << "=======End setting parameters to geometry : ============" << endl; + } + if (TRACKING::FastKalmanFilter) + { + TRACKING::FastKalmanFilter->add_zplane_state("TRD", 284.); + TRACKING::ProjectionNames.insert("TRD"); + + //Use hits from absorber (Active Gas volume) + TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + string(Form("ACTIVEGAS_TRD")), // const std::string& phg4hitsNames, + PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + 1. / sqrt(12.), // const float radres, + 70e-4, // const float phires, + 100e-4, // const float lonres, + 1, // const float eff, + 0); + } + + return; +} + +void TRD_Reco() +{ + gSystem->Load("libfun4all.so"); + gSystem->Load("libg4detectors.so"); + + int verbosity = std::max(Enable::VERBOSITY, Enable::TRD_VERBOSITY); + Fun4AllServer* se = Fun4AllServer::instance(); + + return; +} +#endif diff --git a/common/G4_TTL_EIC.C b/common/G4_TTL_EIC.C index 9d9f9d60..da907a7f 100644 --- a/common/G4_TTL_EIC.C +++ b/common/G4_TTL_EIC.C @@ -35,6 +35,8 @@ namespace G4TTL double positionToVtx[3][3] = { {-169., -172., -309.5}, {80., 114.7, 0. }, { 287., 289., 340.} }; double minExtension[3][3] = { {8, 8, 15.3}, {218, 180, 0 }, {11.62, 11.7, 13.8 } }; double maxExtension[3][3] = { {61., 61. , 200}, {-40, 0, 0 }, {170., 170., 250 } }; + double xoffsetFTTLIP6[3] = { -6., -6., -6.}; + double xoffsetFTTLIP8[3] = { 8.4, 8.4, 8.4}; namespace SETTING { bool optionCEMC = true; @@ -84,13 +86,15 @@ void TTL_Init() if (G4TTL::SETTING::optionGeo == 1){ cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel" << endl; - } if (G4TTL::SETTING::optionGeo == 2){ + } + if (G4TTL::SETTING::optionGeo == 2){ cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel, lower barrel layer" << endl; G4TTL::positionToVtx[1][0] = 50.; if(!G4TTL::SETTING::optionBasicGeo) G4TTL::positionToVtx[1][0] = 65.; G4TTL::minExtension[1][0] = 100.; G4TTL::maxExtension[1][0] = 0.; - } if (G4TTL::SETTING::optionGeo == 3){ + } + if (G4TTL::SETTING::optionGeo == 3 || G4TTL::SETTING::optionGeo == 5 || G4TTL::SETTING::optionGeo == 6){ cout << "TTL setup infront of ECals with 1 layers fwd/bwd & 1 layer barrel, lower barrel layer" << endl; G4TTL::positionToVtx[1][0] = 50.; if(!G4TTL::SETTING::optionBasicGeo) G4TTL::positionToVtx[1][0] = 65.; @@ -104,13 +108,41 @@ void TTL_Init() G4TTL::minExtension[2][0] = G4TTL::minExtension[2][1]; G4TTL::maxExtension[0][0] = G4TTL::maxExtension[0][1]; G4TTL::maxExtension[2][0] = G4TTL::maxExtension[2][1]; - } if (G4TTL::SETTING::optionGeo == 4){ + } + if (G4TTL::SETTING::optionGeo == 4){ cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel, 1 layer before HCals everywhere" << endl; G4TTL::layer[0] = 3; G4TTL::layer[1] = 2; if(!G4TTL::SETTING::optionBasicGeo) G4TTL::layer[1] = 1; G4TTL::layer[2] = 3; } + if(G4TTL::SETTING::optionGeo == 7){ + cout << "TTL one forward disk in front of dRICH and one backward disk in front of EEMC, barrel CTTL center at radius 64cm" << endl; + // single disk in front of dRICH (full eta) + G4TTL::layer[2] = 1; + G4TTL::minExtension[2][0] = 7.0; + G4TTL::maxExtension[2][0] = 87; + G4TTL::positionToVtx[2][0] = 182.; + G4TTL::xoffsetFTTLIP6[0] = -2.7; + G4TTL::xoffsetFTTLIP8[0] = 3.0; + + // single disk in front of EEMC + G4TTL::layer[0] = 1; + // G4TTL::minExtension[0][0] = 7.0; + // G4TTL::maxExtension[0][0] = 87; + // G4TTL::positionToVtx[0][0] = 182.; + // G4TTL::xoffsetFTTLIP6[0] = -2.7; + // G4TTL::xoffsetFTTLIP8[0] = 3.0; + + // barrel layer at 64cm + G4TTL::positionToVtx[1][0] = 64.; + G4TTL::minExtension[1][0] = 140; + G4TTL::maxExtension[1][0] = 0; + } + if(G4TTL::SETTING::optionGeo == 8){ + cout << "TTL forward disk 1 reduced in radius to 60cm" << endl; + G4TTL::maxExtension[2][0] = 60.; + } if (G4TTL::SETTING::optionDR == 2 && G4TTL::SETTING::optionGeo == 4 ){ cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel, 1 layer before HCals everywhere choosen!" << endl; @@ -130,14 +162,10 @@ void FTTLSetup(PHG4Reco *g4Reco, TString fttloption = "") const double mm = .1 * cm; const double um = 1e-3 * mm; - double xoffset = 0; - if (Enable::IP6) xoffset = -6.0; - if (Enable::IP8) xoffset = 8.4; - for (Int_t i = 0; i < G4TTL::layer[2]; i++){ cout << G4TTL::positionToVtx[2][i] << "\t" << G4TTL::minExtension[2][i] << "\t" << G4TTL::maxExtension[2][i] << endl; if(!G4TTL::SETTING::optionBasicGeo){ - make_forward_station(Form("FTTL_%d", i), g4Reco, G4TTL::positionToVtx[2][i], G4TTL::minExtension[2][i], G4TTL::maxExtension[2][i], 85*um, xoffset); + make_forward_station(Form("FTTL_%d", i), g4Reco, G4TTL::positionToVtx[2][i], G4TTL::minExtension[2][i], G4TTL::maxExtension[2][i], 85*um, Enable::IP8 ? G4TTL::xoffsetFTTLIP8[i] : G4TTL::xoffsetFTTLIP6[i]); } else { make_forward_station_basic(Form("FTTL_%d", i), g4Reco, G4TTL::positionToVtx[2][i], G4TTL::minExtension[2][i], G4TTL::maxExtension[2][i], 85*um); } @@ -189,8 +217,9 @@ int make_forward_station(string name, PHG4Reco *g4Reco, // always facing the interaction point double polar_angle = 0; - if (zpos < 0){ - zpos = -zpos; + double place_z(zpos); + if (place_z < 0){ + place_z = -place_z; polar_angle = M_PI; } PHG4TTLSubsystem *ttl; @@ -199,12 +228,12 @@ int make_forward_station(string name, PHG4Reco *g4Reco, ttl->SuperDetector(name); ttl->set_double_param("polar_angle", polar_angle); // ttl->set_int_param("isForward", 1); // - ttl->set_double_param("place_z", zpos * cm); // + ttl->set_double_param("place_z", place_z * cm); // ttl->set_double_param("rMin", rMin * cm); // ttl->set_double_param("rMax", rMax * cm); // ttl->set_double_param("offset_x", xoffset * cm); // ttl->set_double_param("tSilicon", tSilicon); // -// ttl->OverlapCheck(true); + // ttl->OverlapCheck(true); ttl->OverlapCheck(Enable::OVERLAPCHECK); g4Reco->registerSubsystem(ttl); @@ -222,6 +251,16 @@ int make_forward_station(string name, PHG4Reco *g4Reco, TRACKING::FastKalmanFilter->add_zplane_state(name, zpos); TRACKING::ProjectionNames.insert(name); } + if (TRACKING::FastKalmanFilterInnerTrack and zpos>0) + { + TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, + PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + G4TTL::PositionResolution, // const float radres, + G4TTL::PositionResolution, // const float phires, + tSilicon / sqrt(12.), // const float lonres, *ignored in plane detector* + 1, // const float eff, + 0); // const float noise + } return 0; } @@ -266,7 +305,7 @@ int make_forward_station_basic(string name, PHG4Reco *g4Reco, ttl->get_geometry().set_min_polar_edge(PHG4Sector::Sector_Geometry::ConeEdge()); ttl->get_geometry().set_N_Sector(1); ttl->get_geometry().set_material("G4_AIR"); - ttl->OverlapCheck(true); + ttl->OverlapCheck(Enable::OVERLAPCHECK); const double cm = PHG4Sector::Sector_Geometry::Unit_cm(); const double mm = .1 * cm; @@ -296,6 +335,17 @@ int make_forward_station_basic(string name, PHG4Reco *g4Reco, TRACKING::FastKalmanFilter->add_zplane_state(name, zpos); TRACKING::ProjectionNames.insert(name); } + if (TRACKING::FastKalmanFilterInnerTrack and zpos>0) + { + TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, + PHG4TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + G4TTL::PositionResolution, // const float radres, + G4TTL::PositionResolution, // const float phires, + tSilicon / sqrt(12.), // const float lonres, *ignored in plane detector* + 1, // const float eff, + 0); // const float noise + } + return 0; } @@ -334,6 +384,17 @@ int make_barrel_layer(string name, PHG4Reco *g4Reco, TRACKING::ProjectionNames.insert(name); } + if (TRACKING::FastKalmanFilterInnerTrack) + { + TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, + PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype, + tSilicon / sqrt(12.), // const float radres, + G4TTL::PositionResolution, // const float phires, + G4TTL::PositionResolution, // const float lonres, + 1, // const float eff, + 0); // const float noise + + } return 0; } @@ -396,6 +457,17 @@ int make_barrel_layer_basic(string name, PHG4Reco *g4Reco, TRACKING::ProjectionNames.insert(name); } + if (TRACKING::FastKalmanFilterInnerTrack) + { + TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, + PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype, + tSilicon / sqrt(12.), // const float radres, + G4TTL::PositionResolution, // const float phires, + G4TTL::PositionResolution, // const float lonres, + 1, // const float eff, + 0); // const float noise + + } return 0; } diff --git a/common/G4_TrackingSupport.C b/common/G4_TrackingSupport.C index e0ab4577..f666dfc9 100644 --- a/common/G4_TrackingSupport.C +++ b/common/G4_TrackingSupport.C @@ -22,49 +22,49 @@ using namespace std; class ServiceProperties { - public: - ServiceProperties(); - - explicit ServiceProperties(const string &name, - const double &rad_len_copper, - const double &rad_len_aluminum, - const double &rad_len_water, - const double &rad_len_plastic, - const double &rad_len_carbon, - const double &rad_len_iron, - const double &z_south, - const double &z_north, - const double &r_south, - const double &r_north); - - virtual ~ServiceProperties(){}; - - const string get_name(); - const double get_rad_len_copper(); - const double get_rad_len_aluminum(); - const double get_rad_len_water(); - const double get_rad_len_plastic(); - const double get_rad_len_carbon(); - const double get_rad_len_iron(); - const double get_z_south(); - const double get_z_north(); - const double get_r_south(); - const double get_r_north(); - - private: - const string m_name = "service"; - const double m_rad_len_copper = 0.0; - const double m_rad_len_aluminum = 0.0; - const double m_rad_len_water = 0.0; - const double m_rad_len_plastic = 0.0; - const double m_rad_len_carbon = 0.0; - const double m_rad_len_iron = 0.0; - const double m_z_south = 0.0; - const double m_z_north = 0.0; - const double m_r_south = 0.0; - const double m_r_north = 0.0; + public: + ServiceProperties(); + + explicit ServiceProperties(const string &name, + const double &rad_len_copper, + const double &rad_len_aluminum, + const double &rad_len_water, + const double &rad_len_plastic, + const double &rad_len_carbon, + const double &rad_len_iron, + const double &z_south, + const double &z_north, + const double &r_south, + const double &r_north); + + virtual ~ServiceProperties(){}; + + const string get_name(); + const double get_rad_len_copper(); + const double get_rad_len_aluminum(); + const double get_rad_len_water(); + const double get_rad_len_plastic(); + const double get_rad_len_carbon(); + const double get_rad_len_iron(); + const double get_z_south(); + const double get_z_north(); + const double get_r_south(); + const double get_r_north(); + + private: + const string m_name = "service"; + const double m_rad_len_copper = 0.0; + const double m_rad_len_aluminum = 0.0; + const double m_rad_len_water = 0.0; + const double m_rad_len_plastic = 0.0; + const double m_rad_len_carbon = 0.0; + const double m_rad_len_iron = 0.0; + const double m_z_south = 0.0; + const double m_z_north = 0.0; + const double m_r_south = 0.0; + const double m_r_north = 0.0; }; - +//8, 0, 0.42, 0.27, shellX0, 0 ServiceProperties::ServiceProperties(const string &name, const double &rad_len_copper, const double &rad_len_aluminum, @@ -87,7 +87,8 @@ ServiceProperties::ServiceProperties(const string &name, , m_z_north(z_north) , m_r_south(r_south) , m_r_north(r_north) -{} +{ +} const string ServiceProperties::get_name() { return m_name; } const double ServiceProperties::get_rad_len_copper() { return m_rad_len_copper; } @@ -111,42 +112,45 @@ namespace Enable } // namespace Enable namespace G4TrackingService -{ //List materials and radiation length in cm +{ //List materials and radiation length in cm const int nMaterials = 6; - pair materials[nMaterials] = { make_pair("G4_Cu", 1.436) - , make_pair("G4_Al", 8.897) - , make_pair("G4_WATER", 36.08) - , make_pair("G4_POLYETHYLENE", 50.31) - , make_pair("PEEK", 30.00) - , make_pair("G4_Fe", 1.757) }; - + pair materials[nMaterials] = {make_pair("G4_Cu", 1.436) + ,make_pair("G4_Al", 8.897) + ,make_pair("G4_WATER", 36.08) + ,make_pair("G4_POLYETHYLENE", 50.31) + ,make_pair("PEEK", 30.00) + ,make_pair("G4_Fe", 1.757)}; + double GlobalOffset = 0.0; - double ShellThickness = 0.3; //Thickness in cm + double ShellThickness = 0.3; //Thickness in cm int subsysID = 0; } // namespace G4TrackingService vector get_thickness(ServiceProperties *object) { - vector thickness = {(object->get_rad_len_copper()/100)*G4TrackingService::materials[0].second - ,(object->get_rad_len_aluminum()/100)*G4TrackingService::materials[1].second - ,(object->get_rad_len_water()/100)*G4TrackingService::materials[2].second - ,(object->get_rad_len_plastic()/100)*G4TrackingService::materials[3].second - ,(object->get_rad_len_carbon()/100)*G4TrackingService::materials[4].second - ,(object->get_rad_len_iron()/100)*G4TrackingService::materials[5].second}; + vector thickness = {(object->get_rad_len_copper() / 100) * G4TrackingService::materials[0].second + ,(object->get_rad_len_aluminum() / 100) * G4TrackingService::materials[1].second + ,(object->get_rad_len_water() / 100) * G4TrackingService::materials[2].second + ,(object->get_rad_len_plastic() / 100) * G4TrackingService::materials[3].second + ,(object->get_rad_len_carbon() / 100) * G4TrackingService::materials[4].second + ,(object->get_rad_len_iron() / 100) * G4TrackingService::materials[5].second}; return thickness; } void TrackingServiceInit() { + BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 280.); + // extends only to -z + BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -450.); } -double TrackingServiceCone(ServiceProperties *object, PHG4Reco* g4Reco, double radius) +double TrackingServiceCone(ServiceProperties *object, PHG4Reco *g4Reco, double radius) { bool AbsorberActive = Enable::ABSORBER || Enable::TrackingService_ABSORBER; bool OverlapCheck = Enable::OVERLAPCHECK || Enable::TrackingService_OVERLAPCHECK; int verbosity = max(Enable::VERBOSITY, Enable::TrackingService_VERBOSITY); - PHG4ConeSubsystem* cone; + PHG4ConeSubsystem *cone; double innerRadiusSouth = object->get_r_south(); double innerRadiusNorth = object->get_r_north(); @@ -160,8 +164,8 @@ double TrackingServiceCone(ServiceProperties *object, PHG4Reco* g4Reco, double r cone->Verbosity(verbosity); cone->SetR1(innerRadiusSouth, innerRadiusSouth + thickness[i]); cone->SetR2(innerRadiusNorth, innerRadiusNorth + thickness[i]); - cone->SetPlaceZ(object->get_z_south() + length/2 + G4TrackingService::GlobalOffset); - cone->SetZlength(length/2); + cone->SetPlaceZ(object->get_z_south() + length / 2 + G4TrackingService::GlobalOffset); + cone->SetZlength(length / 2); cone->SetMaterial(G4TrackingService::materials[i].first); cone->SuperDetector("TrackingService"); if (AbsorberActive) cone->SetActive(); @@ -176,13 +180,13 @@ double TrackingServiceCone(ServiceProperties *object, PHG4Reco* g4Reco, double r return radius; } -double TrackingServiceCylinder(ServiceProperties *object, PHG4Reco* g4Reco, double radius) +double TrackingServiceCylinder(ServiceProperties *object, PHG4Reco *g4Reco, double radius) { bool AbsorberActive = Enable::ABSORBER || Enable::TrackingService_ABSORBER; bool OverlapCheck = Enable::OVERLAPCHECK || Enable::TrackingService_OVERLAPCHECK; int verbosity = max(Enable::VERBOSITY, Enable::TrackingService_VERBOSITY); - PHG4CylinderSubsystem* cyl; + PHG4CylinderSubsystem *cyl; double innerRadius = object->get_r_south(); double length = abs(object->get_z_north() - object->get_z_south()); @@ -193,7 +197,7 @@ double TrackingServiceCylinder(ServiceProperties *object, PHG4Reco* g4Reco, doub if (thickness[i] == 0) continue; cyl = new PHG4CylinderSubsystem(object->get_name(), G4TrackingService::subsysID); cyl->Verbosity(verbosity); - cyl->set_double_param("place_z", object->get_z_south() + length/2 + G4TrackingService::GlobalOffset); + cyl->set_double_param("place_z", object->get_z_south() + length / 2 + G4TrackingService::GlobalOffset); cyl->set_double_param("radius", innerRadius); cyl->set_double_param("length", length); cyl->set_string_param("material", G4TrackingService::materials[i].first); @@ -210,41 +214,93 @@ double TrackingServiceCylinder(ServiceProperties *object, PHG4Reco* g4Reco, doub return radius; } -double TrackingService(PHG4Reco* g4Reco, double radius) +double TrackingService(PHG4Reco *g4Reco, double radius) { - vector cylinders, cones; - - double shellX0 = 100*G4TrackingService::ShellThickness/G4TrackingService::materials[4].second; - + vector cylinders, cones; + + double shellX0 = 100 * G4TrackingService::ShellThickness / G4TrackingService::materials[4].second; + double disk_cone_radii = 50.; // max radius for the inner tracker Thickness incorporated in here + double avg_thickness_inner = 1.0; // for 13, 0, 0.56, 0.48, shellX0 + double vtx_support_radius = 9.0; + double vtx_e_length = 19.44; + double vtx_h_length = 19.44; + double sagitta_support_radius = 17.0 + 1.5; // 17.0 cms is the radiius of the second sagitta layer. 1.5cms is the gap given for support structure + double sagitta_support_e_length = 37.7861; // +1.5 is the gap given for the support structure + double sagitta_support_h_length = 37.7861; + double plateau_length = 5.1; + + /* Inclination 2 for e-going and h-going directions*/ + + double inner_uRwell_radius = 33.12; // Radius of the inner uRwell + double gap = 1. * avg_thickness_inner; + inner_uRwell_radius -= gap; // subtract the thickness + double inner_uRwell_e_length = 67.54; + double inner_uRwell_h_length = 67.54; + double inner_uRwell_length = inner_uRwell_e_length + inner_uRwell_h_length; + + double e_cone_ends = 110.; + double h_cone_ends = 110.; + + /* Below are the support structures beyond EGEM*/ cylinders.push_back(new ServiceProperties("ETrackingCylinderService_1", 9, 0, 0.42, 0.32, shellX0, 0, -400, -310, 270, 0)); cones.push_back(new ServiceProperties("ETrackingConeService_1", 9, 0, 0.42, 0.32, shellX0, 0, -310, -300, 270, 68)); cylinders.push_back(new ServiceProperties("ETrackingCylinderService_2", 17, 0, 0.56, 0.64, shellX0, 0, -300, -200, 68, 0)); - cylinders.push_back(new ServiceProperties("ETrackingCylinderService_3", 15, 0, 0.56, 0.56, shellX0, 0, -200, -152, 68, 0)); - cones.push_back(new ServiceProperties("ETrackingConeService_2", 13, 0, 0.56, 0.48, shellX0, 0, -152, -132.1, 68, 63.2)); - cones.push_back(new ServiceProperties("ETrackingConeService_3", 13, 0, 0.56, 0.48, shellX0, 0, -132.1, -119.9, 63.2, 50.2)); - cones.push_back(new ServiceProperties("ETrackingConeService_4", 11, 0, 0.56, 0.40, shellX0, 0, -119.9, -107, 50.2, 47.1)); - cones.push_back(new ServiceProperties("ETrackingConeService_5", 9, 0, 0.56, 0.32, shellX0, 0, -107, -80, 47.1, 44)); - cones.push_back(new ServiceProperties("ETrackingConeService_6", 7.5, 0, 0.42, 0.24, shellX0, 0, -80, -56.9, 44, 42.7)); - cones.push_back(new ServiceProperties("ETrackingConeService_7", 6, 0, 0.14, 0.159, shellX0, 0, -56.9, -34, 42.7, 24)); - cones.push_back(new ServiceProperties("ETrackingConeService_8", 3, 0, 0, 0.079, shellX0, 0, -34, -18, 24, 8.2)); - - cylinders.push_back(new ServiceProperties("BTrackingCylinderService_1", 0, 0, 0, 0, 0.1, 0, -56.8, 56.8, 48, 0)); - cylinders.push_back(new ServiceProperties("BTrackingCylinderService_2", 0, 0, 0, 0, 0.1, 0, -33.6, 33.6, 24, 0)); - cylinders.push_back(new ServiceProperties("BTrackingCylinderService_3", 0, 0, 0, 0, shellX0, 0, -17.8, 17.8, 8.2, 0)); - - cones.push_back(new ServiceProperties("HTrackingConeService_1", 3, 0, 0, 0.079, shellX0, 0, 18, 34, 8.2, 24)); - cones.push_back(new ServiceProperties("HTrackingConeService_2", 6, 0, 0.14, 0.159, shellX0, 0, 34, 56.9, 24, 42.7)); - cones.push_back(new ServiceProperties("HTrackingConeService_3", 7.5, 0, 0.28, 0.24, shellX0, 0, 56.9, 79.9, 42.7, 44.1)); - cones.push_back(new ServiceProperties("HTrackingConeService_4", 9, 0, 0.42, 0.32, shellX0, 0, 79.9, 114.9, 44.1, 47.2)); - cones.push_back(new ServiceProperties("HTrackingConeService_5", 11, 0, 0.56, 0.40, shellX0, 0, 114.9, 124.9, 47.2, 47.5)); - cones.push_back(new ServiceProperties("HTrackingConeService_6", 13, 0, 0.70, 0.48, shellX0, 0, 124.9, 157.9, 47.5, 69.2)); - cylinders.push_back(new ServiceProperties("HTrackingCylinderService_1", 15, 0, 0.84, 0.56, shellX0, 0, 157.9, 173, 69.2, 0)); - cones.push_back(new ServiceProperties("HTrackingConeService_7", 13, 0, 0.70, 0.48, shellX0, 0, 173, 180, 69.2, 85)); - cones.push_back(new ServiceProperties("HTrackingConeService_8", 13, 0, 0.70, 0.48, shellX0, 0, 180, 195, 85, 100)); - + cylinders.push_back(new ServiceProperties("ETrackingCylinderService_3", 15, 0, 0.56, 0.56, shellX0, 0, -200, -147.47, 68, 0)); + + //cones.push_back(new ServiceProperties("ETrackingConeService_2", 13, 0, 0.56, 0.48, shellX0, 0, -152, -132.1, 68, 63.2)); + //cones.push_back(new ServiceProperties("ETrackingConeService_3", 13, 0, 0.56, 0.48, shellX0, 0, -132.1, -120., 63.2, disk_cone_radii)); + + /* Support structure thickness*/ + + double CuThickness = 13.; // 0.18668 cms + double AlThickness = 0.; // 0. cms + double WaterThickness = 0.70; // 0.25256 cms + double PlasticThickness = 0.48; // 0.241488 cms + double CarbonThickness = shellX0; // 0.3 cms + + // Cylinder from end Disk to EGEM + //cylinders.push_back(new ServiceProperties("ETrackingCyl_EGEMToDisk4", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -120.0, -1 * e_cone_ends, disk_cone_radii, 0)); + + // Cone service from the end Disk to the uRwell1 radius + cones.push_back(new ServiceProperties("ETrackingCone_Disk4TouRwell", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -147.47, -90, 68, 41.5)); + //cones.push_back(new ServiceProperties("ETrackingCone_Disk4TouRwell", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -1 * e_cone_ends, -1 * inner_uRwell_e_length - plateau_length, disk_cone_radii, inner_uRwell_radius)); + + // The cylindrical plateau structure for Electron uRwell side. + cylinders.push_back(new ServiceProperties("ETrackingCyl_uRWellPlateau", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -90, -56.08, 41.5, 0)); + + // Cone service from electron side uRwell1 to vertex support. + cones.push_back(new ServiceProperties("ETrackingCone_uRwellToVertex", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -56.08, -12.16, 41.5, 9.0)); + + // Sagitta Cylindrical Support Structure + cylinders.push_back(new ServiceProperties("BTrackingCyl_Sagitta", 0, 0, 0, 0, 0.1, 0, -30.3, 30.3, 23.50, 0)); + + // Vertex Cylindrical Support Structure + cylinders.push_back(new ServiceProperties("BTrackingCyl_Vertex", 0, 0, 0, 0, shellX0, 0, -12.16, 12.16, 9.0, 0)); + + // Cone service in H-region from vertex to inner uRwell + cones.push_back(new ServiceProperties("HTrackingCone_VertexTouRwell", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 12.16, 56.08, 9.0, 41.5)); + + // Cylinder service to rest the uRwell in H region Plateau + cylinders.push_back(new ServiceProperties("HTrackingRWellPlateau", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 56.08, 103.75, 41.5, 0)); + + // Cone service from uRwell to Disk 5 in h-region + cones.push_back(new ServiceProperties("HTrackingCone_uRwellToDisk5", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 103.75, 173, 41.5, 69.2)); + + // Cylinder service from Disk 5 to 137 in h direction. This 137 cms is from 2nd campaign and keeping the outer tracker intact. + //cylinders.push_back(new ServiceProperties("HSidemRWellSupportCyl", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, h_cone_ends, 124., disk_cone_radii, 0)); + + // Cone service from 137. to FGEM + //cones.push_back(new ServiceProperties("HTrackingConeForFGEM", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 137., 157.9, disk_cone_radii, 69.2)); + //cones.push_back(new ServiceProperties("HTrackingConeForFGEM", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 124., 173, disk_cone_radii, 69.2)); + + // Supports beyond FGEM + //cylinders.push_back(new ServiceProperties("HTrackingCylinderService_1", 15, 0, 0.84, 0.56, shellX0, 0, 157.9, 173, 69.2, 0)); + cones.push_back(new ServiceProperties("HTrackingConeService_7", 13, 0, 0.70, 0.48, shellX0, 0, 173, 173.1, 69.2, 85)); + cones.push_back(new ServiceProperties("HTrackingConeService_8", 13, 0, 0.70, 0.48, shellX0, 0, 173.1, 195, 85, 100)); + cylinders.push_back(new ServiceProperties("EEMCalSupport", 0, 0, 0, 0, 0, 171, -200, -197, 62, 0)); - for (ServiceProperties *cylinder : cylinders) radius += TrackingServiceCylinder(cylinder, g4Reco, radius); + for (ServiceProperties *cylinder : cylinders) radius += TrackingServiceCylinder(cylinder, g4Reco, radius); for (ServiceProperties *cone : cones) radius += TrackingServiceCone(cone, g4Reco, radius); return radius; diff --git a/common/G4_hFarFwdBeamLine_EIC.C b/common/G4_hFarFwdBeamLine_EIC.C index 90795c1f..376139b2 100644 --- a/common/G4_hFarFwdBeamLine_EIC.C +++ b/common/G4_hFarFwdBeamLine_EIC.C @@ -13,6 +13,7 @@ #include #include +#include #include @@ -37,9 +38,15 @@ namespace Enable bool HFARFWD_PIPE = false; bool HFARFWD_OVERLAPCHECK = false; int HFARFWD_VERBOSITY = 0; + + // Detector configuration options bool ZDC_DISABLE_BLACKHOLE = false; bool B0_DISABLE_HITPLANE = false; bool B0_FULLHITPLANE = false; + bool RP_DISABLE_HITPLANE = false; + bool RP_FULLHITPLANE = false; + bool RP2nd_DISABLE_HITPLANE = false; + bool RP2nd_FULLHITPLANE = false; //enabled automatically in hFarFwdBeamLineInit(), unless overridden by user bool HFARFWD_MAGNETS_IP6 = false; @@ -349,47 +356,150 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) g4Reco->registerSubsystem(detOM); } + ////********************* + // RP + // Three choices: 1. Realistic detector; 2. Circulat or square plane; 3. hit plane with realistic detector goemetry + const int rpDetNr = 2; const double rp_zCent[rpDetNr] = {2600, 2800}; const double rp_xCent[rpDetNr] = {-83.22, -92.20}; - for (int i = 0; i < rpDetNr; i++) - { - ////********************* - //// Square design - //// 25 cm in x - // - // auto *detRP = new PHG4BlockSubsystem(Form("rpTruth_%d",i)); - //// detRP->SuperDetector("RomanPots"); - // detRP->SuperDetector(Form("RomanPots_%d",i)); - // detRP->set_double_param("place_x",rp_xCent[i]); - // detRP->set_double_param("place_y",0); - // detRP->set_double_param("place_z",rp_zCent[i]); - // detRP->set_double_param("rot_y",-0.025*TMath::RadToDeg()); - // detRP->set_double_param("size_x",25); - // detRP->set_double_param("size_y",10); - // detRP->set_double_param("size_z",0.03); - // detRP->set_string_param("material","G4_Si"); - - ////********************* - //// Disk design - //// 50 cm in x - - auto *detRP = new PHG4CylinderSubsystem(Form("rpTruth_%d", i), i); - detRP->SuperDetector("rpTruth"); - detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); - detRP->set_double_param("place_y", 0); - detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); - detRP->set_double_param("rot_y", AngleFlip(0.047 * TMath::RadToDeg())); - detRP->set_double_param("radius", 0); - detRP->set_double_param("thickness", 25); // This is intentionally made large 25cm radius - detRP->set_double_param("length", 0.03); - detRP->set_string_param("material", "G4_Si"); - detRP->OverlapCheck(overlapCheck); - detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); - detRP->SetActive(); - if (verbosity) detRP->Verbosity(verbosity); - g4Reco->registerSubsystem(detRP); + if (Enable::RP_DISABLE_HITPLANE) + { + const double rpCu_zLen = .2; //B0 dead material length + const double rpSi_zLen = .03; //B0 Si length + const double hole_x = 10.0; //detector cut off for beam pipe + const double rppipe_x = 0.0; //detector cut off for beam pipe position + const double hole_y = 3.0; //detector cut off for beam pipe + const double rp_x = 30.0; //detector width + const double rp_y = 10.0; //detector height + const double rot_y = 0.047; //rotation angle + for (int i = 0; i < rpDetNr; i++) + { + auto *detRP = new EICG4RPSubsystem(Form("rpTruth_%d", 2 * i), 2 * i); + detRP->SuperDetector("rpTruth"); + detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_y", 0); + detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRP->set_double_param("rp_x", rp_x); + detRP->set_double_param("rp_y", rp_y); + detRP->set_double_param("hole_x", hole_x); + detRP->set_double_param("hole_y", hole_y); + detRP->set_double_param("length", rpSi_zLen); + detRP->set_string_param("material", "G4_Si"); + detRP->set_double_param("detid", 2 * i); + detRP->set_double_param("pipe_x", rppipe_x); + detRP->set_double_param("pipe_y", 0); + detRP->set_double_param("pipe_z", 0); + detRP->OverlapCheck(overlapCheck); + detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRP->SetActive(true); + if (verbosity) detRP->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP); + + auto *detRPe = new EICG4RPSubsystem(Form("rpTruth_%d", 2 * i + 1), 2 * i + 1); + detRPe->SuperDetector("rpTruth"); + detRPe->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRPe->set_double_param("place_y", 0); + detRPe->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center + (rpSi_zLen + rpCu_zLen) / 2); + detRPe->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRPe->set_double_param("rp_x", rp_x); + detRPe->set_double_param("rp_y", rp_y); + detRPe->set_double_param("hole_x", hole_x); + detRPe->set_double_param("hole_y", hole_y); + detRPe->set_double_param("length", rpCu_zLen); + detRPe->set_string_param("material", "G4_Cu"); + detRPe->set_double_param("detid", 2 * i + 1); + detRPe->set_double_param("pipe_x", rppipe_x); + detRPe->set_double_param("pipe_y", 0); + detRPe->set_double_param("pipe_z", 0); + detRPe->OverlapCheck(overlapCheck); + detRPe->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRPe->SetActive(true); + if (verbosity) detRPe->Verbosity(verbosity); + g4Reco->registerSubsystem(detRPe); + } + } + else + { + if (Enable::B0_FULLHITPLANE) + { + for (int i = 0; i < rpDetNr; i++) + { + ////********************* + //// Square design + //// 25 cm in x + // + // auto *detRP = new PHG4BlockSubsystem(Form("rpTruth_%d",i)); + //// detRP->SuperDetector("RomanPots"); + // detRP->SuperDetector(Form("RomanPots_%d",i)); + // detRP->set_double_param("place_x",rp_xCent[i]); + // detRP->set_double_param("place_y",0); + // detRP->set_double_param("place_z",rp_zCent[i]); + // detRP->set_double_param("rot_y",-0.025*TMath::RadToDeg()); + // detRP->set_double_param("size_x",25); + // detRP->set_double_param("size_y",10); + // detRP->set_double_param("size_z",0.03); + // detRP->set_string_param("material","G4_Si"); + + ////********************* + //// Disk design + //// 50 cm in x + + auto *detRP = new PHG4CylinderSubsystem(Form("rpTruth_%d", i), i); + detRP->SuperDetector("rpTruth"); + detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_y", 0); + detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("rot_y", AngleFlip(0.047 * TMath::RadToDeg())); + detRP->set_double_param("radius", 0); + detRP->set_double_param("thickness", 25); // This is intentionally made large 25cm radius + detRP->set_double_param("length", 0.03); + detRP->set_string_param("material", "G4_Si"); + detRP->OverlapCheck(overlapCheck); + detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + + detRP->SetActive(); + if (verbosity) detRP->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP); + } + } + else + { + const double rpCu_zLen = .2; //B0 dead material length + const double rpSi_zLen = .03; //B0 Si length + const double hole_x = 10.0; //detector cut off for beam pipe + const double rppipe_x = 0.0; //detector cut off for beam pipe position + const double hole_y = 3.0; //detector cut off for beam pipe + const double rp_x = 30.0; //detector width + const double rp_y = 10.0; //detector height + const double rot_y = 0.047; //rotation angle + for (int i = 0; i < rpDetNr; i++) + { + auto *detRP = new EICG4RPSubsystem(Form("rpTruth_%d", 2 * i), 2 * i); + detRP->SuperDetector("rpTruth"); + detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_y", 0); + detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRP->set_double_param("rp_x", rp_x); + detRP->set_double_param("rp_y", rp_y); + detRP->set_double_param("hole_x", hole_x); + detRP->set_double_param("hole_y", hole_y); + detRP->set_double_param("length", rpSi_zLen); + detRP->set_string_param("material", "G4_Si"); + detRP->set_double_param("detid", 2 * i); + detRP->set_double_param("pipe_x", rppipe_x); + detRP->set_double_param("pipe_y", 0); + detRP->set_double_param("pipe_z", 0); + detRP->OverlapCheck(overlapCheck); + detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRP->SetActive(true); + if (verbosity) detRP->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP); + } + } } //--------------------------------- @@ -434,8 +544,7 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) detB0->set_double_param("pipe_z", 0); detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet detB0->SetActive(true); - if (verbosity) - detB0->Verbosity(verbosity); + if (verbosity) detB0->Verbosity(verbosity); detB0->OverlapCheck(overlapCheck); detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); g4Reco->registerSubsystem(detB0); @@ -458,8 +567,7 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) detB0e->set_double_param("spanningAngle", spanning_angle); detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) + (b0Cu_zLen + b0Si_zLen) / 2)); // relative to B0 magnet detB0e->SetActive(true); - if (verbosity) - detB0e->Verbosity(verbosity); + if (verbosity) detB0e->Verbosity(verbosity); detB0e->OverlapCheck(overlapCheck); detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); g4Reco->registerSubsystem(detB0e); @@ -483,8 +591,7 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) B0Ecal->set_double_param("spanningAngle", spanning_angle); B0Ecal->set_double_param("detid", 2 * b0DetNr); B0Ecal->SetActive(true); - if (verbosity) - B0Ecal->Verbosity(verbosity); + if (verbosity) B0Ecal->Verbosity(verbosity); B0Ecal->OverlapCheck(overlapCheck); B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); g4Reco->registerSubsystem(B0Ecal); @@ -507,8 +614,7 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) B0Ecale->set_double_param("spanningAngle", spanning_angle); B0Ecale->set_double_param("detid", 2 * b0DetNr + 1); B0Ecale->SetActive(true); - if (verbosity) - B0Ecale->Verbosity(verbosity); + if (verbosity) B0Ecale->Verbosity(verbosity); B0Ecale->OverlapCheck(overlapCheck); B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); g4Reco->registerSubsystem(B0Ecale); @@ -586,8 +692,7 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) detB0->set_double_param("pipe_z", 0); detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet detB0->SetActive(true); - if (verbosity) - detB0->Verbosity(verbosity); + if (verbosity) detB0->Verbosity(verbosity); detB0->OverlapCheck(overlapCheck); detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); g4Reco->registerSubsystem(detB0); @@ -651,8 +756,7 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) detZDCsurrogate->OverlapCheck(overlapCheck); detZDCsurrogate->set_color(1, 0, 0, 0.5); if (!Enable::ZDC_DISABLE_BLACKHOLE) detZDCsurrogate->BlackHole(); - if (verbosity) - detZDCsurrogate->Verbosity(verbosity); + if (verbosity) detZDCsurrogate->Verbosity(verbosity); detZDCsurrogate->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); g4Reco->registerSubsystem(detZDCsurrogate); @@ -670,72 +774,289 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) //------------------ // Roman pot set #1 - const int rpDetNr = 2; - const double rp_xCent[rpDetNr] = {75.6, 78.15}; + ////********************* + // RP + // Three choices: 1. Realistic detector; 2. Circulat or square plane; 3. hit plane with realistic detector goemetry + + const int rpDetNr = 2; const double rp_zCent[rpDetNr] = {2600, 2800}; + const double rp_xCent[rpDetNr] = {75.6, 78.15}; - for (int i = 0; i < rpDetNr; i++) + if (Enable::RP_DISABLE_HITPLANE) { // Circular disk design (16cm in) - auto *detRP = new PHG4CylinderSubsystem(Form("rpTruth_%d", i), i); + auto *detRP = new PHG4CylinderSubsystem(Form("rpTruth_%d", 0), 0); detRP->SuperDetector("rpTruth"); - detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_x", PosFlip(rp_xCent[0])); detRP->set_double_param("place_y", 0); - detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("place_z", rp_zCent[0] - hFarFwdBeamLine::enclosure_center); detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); detRP->set_double_param("radius", 5); detRP->set_double_param("thickness", 10); // 16 cm circulr to cover 25cm x20cm square (IR design) detRP->set_double_param("length", 0.03); detRP->set_string_param("material", "G4_Si"); - // //------------------------------------ - // /// Square Design - // auto *detRP = new PHG4BlockSubsystem(Form("rpTruth_%d", i), i); - // detRP->SuperDetector("rpTruth"); - // detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); - // detRP->set_double_param("place_y", 0); - // detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); - // detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); - // detRP->set_double_param("size_x", 25); // Original design specification - // detRP->set_double_param("size_y", 20); // Original design specification - // detRP->set_double_param("size_z", 0.03); - // detRP->set_string_param("material", "G4_Si"); - - detRP->OverlapCheck(overlapCheck); - detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); - detRP->SetActive(); - if (verbosity) - detRP->Verbosity(verbosity); - g4Reco->registerSubsystem(detRP); + const double rpCu_zLen = .2; //B0 dead material length + const double rpSi_zLen = .03; //B0 Si length + const double hole_x = 10.0; //detector cut off for beam pipe + const double rppipe_x = 0.0; //detector cut off for beam pipe position + const double hole_y = 3.0; //detector cut off for beam pipe + const double rp_x = 25.0; //detector width + const double rp_y = 20.0; //detector height + const double rot_y = -0.035; //rotation angle + for (int i = 0; i < rpDetNr; i++) + { + auto *detRP = new EICG4RPSubsystem(Form("rpTruth_%d", 2 * i + 1), 2 * i + 1); + detRP->SuperDetector("rpTruth"); + detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_y", 0); + detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRP->set_double_param("rp_x", rp_x); + detRP->set_double_param("rp_y", rp_y); + detRP->set_double_param("hole_x", hole_x); + detRP->set_double_param("hole_y", hole_y); + detRP->set_double_param("length", rpSi_zLen); + detRP->set_string_param("material", "G4_Si"); + detRP->set_double_param("detid", 2 * i); + detRP->set_double_param("pipe_x", rppipe_x); + detRP->set_double_param("pipe_y", 0); + detRP->set_double_param("pipe_z", 0); + detRP->OverlapCheck(overlapCheck); + detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRP->SetActive(true); + if (verbosity) detRP->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP); + + auto *detRPe = new EICG4RPSubsystem(Form("rpTruth_%d", 2 * i + 2), 2 * i + 2); + detRPe->SuperDetector("rpTruth"); + detRPe->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRPe->set_double_param("place_y", 0); + detRPe->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center + (rpSi_zLen + rpCu_zLen) / 2); + detRPe->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRPe->set_double_param("rp_x", rp_x); + detRPe->set_double_param("rp_y", rp_y); + detRPe->set_double_param("hole_x", hole_x); + detRPe->set_double_param("hole_y", hole_y); + detRPe->set_double_param("length", rpCu_zLen); + detRPe->set_string_param("material", "G4_Cu"); + detRPe->set_double_param("detid", 2 * i + 1); + detRPe->set_double_param("pipe_x", rppipe_x); + detRPe->set_double_param("pipe_y", 0); + detRPe->set_double_param("pipe_z", 0); + detRPe->OverlapCheck(overlapCheck); + detRPe->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRPe->SetActive(true); + if (verbosity) detRPe->Verbosity(verbosity); + g4Reco->registerSubsystem(detRPe); + } + } + else + { + if (Enable::B0_FULLHITPLANE) + { + for (int i = 0; i < rpDetNr; i++) + { + // Circular disk design (16cm in) + auto *detRP = new PHG4CylinderSubsystem(Form("rpTruth_%d", i), i); + detRP->SuperDetector("rpTruth"); + detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_y", 0); + detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); + detRP->set_double_param("radius", 5); + detRP->set_double_param("thickness", 10); // 16 cm circulr to cover 25cm x20cm square (IR design) + detRP->set_double_param("length", 0.03); + detRP->set_string_param("material", "G4_Si"); + + // //------------------------------------ + // /// Square Design + // auto *detRP = new PHG4BlockSubsystem(Form("rpTruth_%d", i), i); + // detRP->SuperDetector("rpTruth"); + // detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + // detRP->set_double_param("place_y", 0); + // detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + // detRP->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg())); + // detRP->set_double_param("size_x", 25); // Original design specification + // detRP->set_double_param("size_y", 20); // Original design specification + // detRP->set_double_param("size_z", 0.03); + // detRP->set_string_param("material", "G4_Si"); + + detRP->OverlapCheck(overlapCheck); + detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRP->SetActive(); + if (verbosity) + detRP->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP); + } + } + else + { + const double rpCu_zLen = .2; //B0 dead material length + const double rpSi_zLen = .03; //B0 Si length + const double hole_x = 10.0; //detector cut off for beam pipe + const double rppipe_x = 0.0; //detector cut off for beam pipe position + const double hole_y = 3.0; //detector cut off for beam pipe + const double rp_x = 25.0; //detector width + const double rp_y = 20.0; //detector height + const double rot_y = -0.029; //rotation angle + for (int i = 0; i < rpDetNr; i++) + { + auto *detRP = new EICG4RPSubsystem(Form("rpTruth_%d", 2 * i), 2 * i); + detRP->SuperDetector("rpTruth"); + detRP->set_double_param("place_x", PosFlip(rp_xCent[i])); + detRP->set_double_param("place_y", 0); + detRP->set_double_param("place_z", rp_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRP->set_double_param("rp_x", rp_x); + detRP->set_double_param("rp_y", rp_y); + detRP->set_double_param("hole_x", hole_x); + detRP->set_double_param("hole_y", hole_y); + detRP->set_double_param("length", rpSi_zLen); + detRP->set_string_param("material", "G4_Si"); + detRP->set_double_param("detid", 2 * i); + detRP->set_double_param("pipe_x", rppipe_x); + detRP->set_double_param("pipe_y", 0); + detRP->set_double_param("pipe_z", 0); + detRP->OverlapCheck(overlapCheck); + detRP->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRP->SetActive(true); + if (verbosity) detRP->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP); + } + } } - //------------------ + ////********************* // Roman pot set #2 before and after the secondary focus + // Three choices: 1. Realistic detector; 2. Circulat or square plane; 3. hit plane with realistic detector goemetry const int rp2ndDetNr = 2; const double rp_2nd_xCent[rp2ndDetNr] = {101.94, 106.94}; const double rp_2nd_zCent[rp2ndDetNr] = {4300, 4450}; - for (int i = 0; i < rp2ndDetNr; i++) + if (Enable::RP_DISABLE_HITPLANE) { - auto *detRP_2nd = new PHG4BlockSubsystem(Form("rpTruth2_%d", i), i); - detRP_2nd->SuperDetector("rpTruth2"); - detRP_2nd->set_double_param("place_x", PosFlip(rp_2nd_xCent[i])); - detRP_2nd->set_double_param("place_y", 0); - detRP_2nd->set_double_param("place_z", rp_2nd_zCent[i] - hFarFwdBeamLine::enclosure_center); - detRP_2nd->set_double_param("rot_y", AngleFlip(-0.029 * TMath::RadToDeg())); - detRP_2nd->set_double_param("size_x", 25); - detRP_2nd->set_double_param("size_y", 20); - detRP_2nd->set_double_param("size_z", 0.03); - detRP_2nd->set_string_param("material", "G4_Si"); - detRP_2nd->OverlapCheck(overlapCheck); - detRP_2nd->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); - detRP_2nd->SetActive(); - if (verbosity) - detRP_2nd->Verbosity(verbosity); - g4Reco->registerSubsystem(detRP_2nd); + const double rpCu_zLen = .2; //B0 dead material length + const double rpSi_zLen = .03; //B0 Si length + const double hole_x = 10.0; //detector cut off for beam pipe + const double rppipe_x = 0.0; //detector cut off for beam pipe position + const double hole_y = 3.0; //detector cut off for beam pipe + const double rp_x = 25.0; //detector width + const double rp_y = 20.0; //detector height + const double rot_y = -0.029; //rotation angle + for (int i = 0; i < rp2ndDetNr; i++) + { + auto *detRP_2nd = new EICG4RPSubsystem(Form("rpTruth2_%d", 2 * i), 2 * i); + detRP_2nd->SuperDetector("rpTruth2"); + detRP_2nd->set_double_param("place_x", PosFlip(rp_2nd_xCent[i])); + detRP_2nd->set_double_param("place_y", 0); + detRP_2nd->set_double_param("place_z", rp_2nd_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP_2nd->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRP_2nd->set_double_param("rp_x", rp_x); + detRP_2nd->set_double_param("rp_y", rp_y); + detRP_2nd->set_double_param("hole_x", hole_x); + detRP_2nd->set_double_param("hole_y", hole_y); + detRP_2nd->set_double_param("length", rpSi_zLen); + detRP_2nd->set_string_param("material", "G4_Si"); + detRP_2nd->set_double_param("detid", 2 * i); + detRP_2nd->set_double_param("pipe_x", rppipe_x); + detRP_2nd->set_double_param("pipe_y", 0); + detRP_2nd->set_double_param("pipe_z", 0); + detRP_2nd->OverlapCheck(overlapCheck); + detRP_2nd->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRP_2nd->SetActive(true); + if (verbosity) detRP_2nd->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP_2nd); + + auto *detRPe_2nd = new EICG4RPSubsystem(Form("rpTruth2_%d", 2 * i + 1), 2 * i + 1); + detRPe_2nd->SuperDetector("rpTruth2"); + detRPe_2nd->set_double_param("place_x", PosFlip(rp_2nd_xCent[i])); + detRPe_2nd->set_double_param("place_y", 0); + detRPe_2nd->set_double_param("place_z", rp_2nd_zCent[i] - hFarFwdBeamLine::enclosure_center + (rpSi_zLen + rpCu_zLen) / 2); + detRPe_2nd->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRPe_2nd->set_double_param("rp_x", rp_x); + detRPe_2nd->set_double_param("rp_y", rp_y); + detRPe_2nd->set_double_param("hole_x", hole_x); + detRPe_2nd->set_double_param("hole_y", hole_y); + detRPe_2nd->set_double_param("length", rpCu_zLen); + detRPe_2nd->set_string_param("material", "G4_Cu"); + detRPe_2nd->set_double_param("detid", 2 * i + 1); + detRPe_2nd->set_double_param("pipe_x", rppipe_x); + detRPe_2nd->set_double_param("pipe_y", 0); + detRPe_2nd->set_double_param("pipe_z", 0); + detRPe_2nd->OverlapCheck(overlapCheck); + detRPe_2nd->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRPe_2nd->SetActive(true); + if (verbosity) detRPe_2nd->Verbosity(verbosity); + g4Reco->registerSubsystem(detRPe_2nd); + } } + else + { + if (Enable::B0_FULLHITPLANE) + { + for (int i = 0; i < rp2ndDetNr; i++) + { + auto *detRP_2nd = new PHG4BlockSubsystem(Form("rpTruth2_%d", i), i); + detRP_2nd->SuperDetector("rpTruth2"); + detRP_2nd->set_double_param("place_x", PosFlip(rp_2nd_xCent[i])); + detRP_2nd->set_double_param("place_y", 0); + detRP_2nd->set_double_param("place_z", rp_2nd_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP_2nd->set_double_param("rot_y", AngleFlip(-0.029 * TMath::RadToDeg())); + detRP_2nd->set_double_param("size_x", 25); + detRP_2nd->set_double_param("size_y", 20); + detRP_2nd->set_double_param("size_z", 0.03); + detRP_2nd->set_string_param("material", "G4_Si"); + detRP_2nd->OverlapCheck(overlapCheck); + detRP_2nd->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRP_2nd->SetActive(); + if (verbosity) + detRP_2nd->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP_2nd); + } + } + else + { + const double rpCu_zLen = .2; //B0 dead material length + const double rpSi_zLen = .03; //B0 Si length + const double hole_x = 10.0; //detector cut off for beam pipe + const double rppipe_x = 0.0; //detector cut off for beam pipe position + const double hole_y = 3.0; //detector cut off for beam pipe + const double rp_x = 25.0; //detector width + const double rp_y = 20.0; //detector height + const double rot_y = -0.029; //rotation angle + for (int i = 0; i < rp2ndDetNr; i++) + { + auto *detRP_2nd = new EICG4RPSubsystem(Form("rpTruth2_%d", 2 * i), 2 * i); + detRP_2nd->SuperDetector("rpTruth2"); + detRP_2nd->set_double_param("place_x", PosFlip(rp_2nd_xCent[i])); + detRP_2nd->set_double_param("place_y", 0); + detRP_2nd->set_double_param("place_z", rp_2nd_zCent[i] - hFarFwdBeamLine::enclosure_center); + detRP_2nd->set_double_param("rot_y", AngleFlip(rot_y * TMath::RadToDeg())); + detRP_2nd->set_double_param("rp_x", rp_x); + detRP_2nd->set_double_param("rp_y", rp_y); + detRP_2nd->set_double_param("hole_x", hole_x); + detRP_2nd->set_double_param("hole_y", hole_y); + detRP_2nd->set_double_param("length", rpSi_zLen); + detRP_2nd->set_string_param("material", "G4_Si"); + detRP_2nd->set_double_param("detid", 2 * i); + detRP_2nd->set_double_param("pipe_x", rppipe_x); + detRP_2nd->set_double_param("pipe_y", 0); + detRP_2nd->set_double_param("pipe_z", 0); + detRP_2nd->OverlapCheck(overlapCheck); + detRP_2nd->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); + detRP_2nd->SetActive(true); + if (verbosity) detRP_2nd->Verbosity(verbosity); + g4Reco->registerSubsystem(detRP_2nd); + } + } + } + + //--------------------------------- + // B0 implementation + // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry if (verbosity > 0) { @@ -1138,4 +1459,4 @@ void FFR_Eval(const std::string &outputfile) return; } -#endif \ No newline at end of file +#endif diff --git a/common/G4_mRwell_EIC.C b/common/G4_mRwell_EIC.C index c0502e3a..74e3496c 100644 --- a/common/G4_mRwell_EIC.C +++ b/common/G4_mRwell_EIC.C @@ -30,9 +30,14 @@ namespace RWELL // const double nom_length[RWELL::n_layer] = {300.0, 300.0}; const int n_layer = 3; //tracker layers - const double nom_radius[RWELL::n_layer] = {44.2, 47.4, 67.4}; + //const double nom_radius[RWELL::n_layer] = {44.2, 47.4, 77.0175}; + const double nom_radius[RWELL::n_layer] = {33.14, 51., 77.0175}; + double e_length_uRwell[RWELL::n_layer] = {40.08, 106., 197}; + double h_length_uRwell[RWELL::n_layer] = {e_length_uRwell[0], e_length_uRwell[1], 145}; const double nom_driftgap[RWELL::n_layer] = {0.4, 0.4, 0.4}; - const double nom_length[RWELL::n_layer] = {140, 150, 280.0}; + //const double nom_length[RWELL::n_layer] = {140, 150, 280.0}; + const double nom_length[RWELL::n_layer] = {2*e_length_uRwell[0], 2*e_length_uRwell[1], 342.0}; + int subsysID = 0; } //namespace RWELL void RWellInit(int verbosity = 0) @@ -44,7 +49,7 @@ void RWellInit(int verbosity = 0) double Build_G4_RWell_Bare(PHG4Reco* g4Reco, double rwellrad = 80.0, - double driftgap = 1.5, + double driftgap = 1.83, double length = 200.0, int index = 0) { @@ -82,71 +87,76 @@ double Build_G4_RWell_Bare(PHG4Reco* g4Reco, double support_03_thickness = 0.50; double support_03_length = 1.2; - PHG4CylinderSubsystem* rwell_cyl(nullptr); + PHG4CylinderSubsystem* rwell_cyl; + double Shift = (RWELL::h_length_uRwell[index] - RWELL::e_length_uRwell[index])/2.0; // here is our uRwell: //Gass layer - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rwellrad); rwell_cyl->set_string_param("material", "G4_Ar"); rwell_cyl->set_double_param("thickness", driftgap); - rwell_cyl->SetActive(1); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(1); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); //Kapton - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Kapton_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Kapton_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rwellrad - kapton_thickness); rwell_cyl->set_string_param("material", "G4_KAPTON"); rwell_cyl->set_double_param("thickness", kapton_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_Kapton_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); //Cu rsum = rwellrad + driftgap; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Cu_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Cu_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", "G4_Cu"); rwell_cyl->set_double_param("thickness", cu_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_Cu_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); //Prepreg rsum += cu_thickness; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PrePreg_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PrePreg_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", "NOMEX"); rwell_cyl->set_double_param("thickness", prepreg_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_PrePreg_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); //PCB rsum += prepreg_thickness; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PCB_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PCB_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", "FR4"); rwell_cyl->set_double_param("thickness", pcb_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_PCB_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); return rwellrad; } @@ -159,7 +169,6 @@ double Build_G4_RWell_Sup01(PHG4Reco* g4Reco, { gSystem->Load("libfun4all"); gSystem->Load("libg4detectors.so"); - gSystem->Load("libg4testbench.so"); bool OverlapCheck = Enable::OVERLAPCHECK || Enable::RWELL_OVERLAPCHECK; @@ -190,76 +199,85 @@ double Build_G4_RWell_Sup01(PHG4Reco* g4Reco, double support_03_thickness = 0.50; double support_03_length = 1.2; - PHG4CylinderSubsystem* rwell_cyl(nullptr); + PHG4CylinderSubsystem* rwell_cyl; + double Shift = (RWELL::h_length_uRwell[index] - RWELL::e_length_uRwell[index])/2.0; // here is our uRwell: //Gass layer - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem("RWELL", index); rwell_cyl->set_double_param("radius", rwellrad); rwell_cyl->set_string_param("material", "G4_METHANE"); rwell_cyl->set_double_param("thickness", driftgap); - rwell_cyl->SetActive(1); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_%d", index)); + // rwell_cyl->SuperDetector("RWELL"); // breakout RWELL into individual layers rwell_cyl->SetActive(1); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //Kapton - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Kapton_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Kapton_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rwellrad - kapton_thickness); rwell_cyl->set_string_param("material", "G4_KAPTON"); rwell_cyl->set_double_param("thickness", kapton_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_Kapton_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //Cu rsum = rwellrad + driftgap; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Cu_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Cu_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", "G4_Cu"); rwell_cyl->set_double_param("thickness", cu_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_Cu_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + ++RWELL::subsysID; //Prepreg rsum += cu_thickness; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PrePreg_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PrePreg_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", "NOMEX"); rwell_cyl->set_double_param("thickness", prepreg_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_PrePreg_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //PCB rsum += prepreg_thickness; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PCB_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PCB_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", "FR4"); rwell_cyl->set_double_param("thickness", pcb_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); + rwell_cyl->set_double_param("place_z", Shift); rwell_cyl->set_double_param("length", length); - rwell_cyl->SuperDetector(Form("RWELL_PCB_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //---Support structure-- //tube rsum += pcb_thickness; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support01_0_%d", index), 0); //RWELL___ + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support01_0_%d", index), RWELL::subsysID); //RWELL___ //Support 01 = tube //Support 02 = inner ring //Support 03 = outer ring @@ -269,74 +287,80 @@ double Build_G4_RWell_Sup01(PHG4Reco* g4Reco, rwell_cyl->set_string_param("material", supMat); rwell_cyl->set_double_param("thickness", support_01_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); - rwell_cyl->set_double_param("place_z", -length / 2); + rwell_cyl->set_double_param("place_z", -length / 2 + Shift + 0.5); rwell_cyl->set_double_param("length", support_01_length); - rwell_cyl->SuperDetector(Form("RWELL_Support01_0_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //tube 2 - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support01_1_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support01_1_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", supMat); rwell_cyl->set_double_param("thickness", support_01_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); - rwell_cyl->set_double_param("place_z", length / 2); + rwell_cyl->set_double_param("place_z", length / 2 + Shift); rwell_cyl->set_double_param("length", support_01_length); - rwell_cyl->SuperDetector(Form("RWELL_Support01_1_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //inner ring rsum += support_01_thickness; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support02_0_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support02_0_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", supMat); rwell_cyl->set_double_param("thickness", support_02_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); - rwell_cyl->set_double_param("place_z", -length / 2 + support_01_length / 2); + rwell_cyl->set_double_param("place_z", -length / 2 + support_01_length / 2 + Shift); rwell_cyl->set_double_param("length", support_02_length); - rwell_cyl->SuperDetector(Form("RWELL_Support02_0_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //inner ring 2 - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support02_1_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support02_1_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", supMat); rwell_cyl->set_double_param("thickness", support_02_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); - rwell_cyl->set_double_param("place_z", length / 2 - support_01_length / 2); + rwell_cyl->set_double_param("place_z", length / 2 + Shift - support_01_length / 2); rwell_cyl->set_double_param("length", support_02_length); - rwell_cyl->SuperDetector(Form("RWELL_Support02_1_%d", index)); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //outer ring rsum += support_02_thickness; - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support03_0_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support03_0_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", supMat); rwell_cyl->set_double_param("thickness", support_03_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); rwell_cyl->set_double_param("length", support_03_length); - rwell_cyl->SuperDetector(Form("RWELL_Support03_0_%d", index)); - rwell_cyl->set_double_param("place_z", -length / 2 + support_01_length / 2); + rwell_cyl->set_double_param("place_z", -length / 2 + Shift + support_01_length / 2); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; //outer ring 2 - rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support03_1_%d", index), 0); + rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support03_1_%d", index), RWELL::subsysID); rwell_cyl->set_double_param("radius", rsum); rwell_cyl->set_string_param("material", supMat); rwell_cyl->set_double_param("thickness", support_03_thickness); rwell_cyl->set_int_param("lengthviarapidity", 0); rwell_cyl->set_double_param("length", support_03_length); - rwell_cyl->SuperDetector(Form("RWELL_Support03_1_%d", index)); - rwell_cyl->set_double_param("place_z", length / 2 - support_01_length / 2); + rwell_cyl->set_double_param("place_z", length / 2 + Shift - support_01_length / 2); + rwell_cyl->SuperDetector("RWELL"); rwell_cyl->SetActive(0); - g4Reco->registerSubsystem(rwell_cyl); rwell_cyl->OverlapCheck(OverlapCheck); + g4Reco->registerSubsystem(rwell_cyl); + ++RWELL::subsysID; return rwellrad; } @@ -372,6 +396,7 @@ double RWellSetup(PHG4Reco* g4Reco, // (usually it is in between 40-60 microns depending on the angle of incidence of // primary tracks when mRwell are used in microTPC mode i.e drift gap of 3-4 mm) . if (TRACKING::FastKalmanFilter) + { TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + string(Form("RWELL_%d", ilyr)), // const std::string& phg4hitsNames, PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype, 1. / sqrt(12.), // const float radres, @@ -379,7 +404,12 @@ double RWellSetup(PHG4Reco* g4Reco, 55e-4, // const float lonres, 1, // const float eff, 0); // const float noise - if (TRACKING::FastKalmanFilterInnerTrack) + TRACKING::FastKalmanFilter->add_cylinder_state(Form("RWELL_%d", ilyr), RWELL::nom_radius[ilyr]); + TRACKING::ProjectionNames.insert(Form("RWELL_%d", ilyr)); + } + + // FastKalmanFilterInnerTrack has everything within DIRC + if (TRACKING::FastKalmanFilterInnerTrack and RWELL::nom_radius[ilyr] < 70) TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + string(Form("RWELL_%d", ilyr)), // const std::string& phg4hitsNames, PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype, 1. / sqrt(12.), // const float radres, diff --git a/detectors/EICDetector/Fun4All_G4_EICDetector.C b/detectors/EICDetector/Fun4All_G4_EICDetector.C index 0f35a088..f9adbe19 100644 --- a/detectors/EICDetector/Fun4All_G4_EICDetector.C +++ b/detectors/EICDetector/Fun4All_G4_EICDetector.C @@ -274,7 +274,7 @@ int Fun4All_G4_EICDetector( // gems Enable::EGEM = true; - Enable::FGEM = true; + Enable::FGEM = true; // deactivated as it's replaced by a FTTL layer // Enable::BGEM = true; // not yet defined in this model Enable::RWELL = true; // barrel tracker @@ -284,12 +284,19 @@ int Fun4All_G4_EICDetector( // fst Enable::FST = true; - // TOFs + //AC-LGAD TOFs Enable::FTTL = true; Enable::ETTL = true; Enable::CTTL = true; G4TTL::SETTING::optionCEMC = false; - G4TTL::SETTING::optionGeo = 1; + G4TTL::SETTING::optionGeo = 7; + + //mRPC TOFs + Enable::BTOF = false; + Enable::ETOF = false; + Enable::HTOF = false; + Enable::ETOF_GAS = Enable::ETOF && true; + Enable::HTOF_GAS = Enable::HTOF && true; Enable::TRACKING = true; Enable::TRACKING_EVAL = Enable::TRACKING && true; @@ -329,16 +336,21 @@ int Fun4All_G4_EICDetector( // EICDetector geometry - barrel Enable::DIRC = true; Enable::DIRC_RECO = Enable::DIRC && true; + + Enable::BMMG = false; // Enable::DIRC_VERBOSITY = 2; // EICDetector geometry - 'hadron' direction Enable::RICH = true; - Enable::RICH_RECO = Enable::DIRC && true; + Enable::RICH_RECO = Enable::RICH && true; + + Enable::TRD = false; + Enable::TRD_GAS = false; // Enable::RICH_VERBOSITY = 2; // EICDetector geometry - 'electron' direction Enable::mRICH = true; - Enable::mRICH_RECO = Enable::DIRC && true; + Enable::mRICH_RECO = Enable::mRICH && true; // Enable::mRICH_VERBOSITY = 2; Enable::FEMC = true; @@ -384,7 +396,7 @@ int Fun4All_G4_EICDetector( // jet reconstruction Enable::FWDJETS = true; - Enable::FWDJETS_EVAL = Enable::FWDJETS && true; + Enable::FWDJETS_EVAL = Enable::FWDJETS && false; // new settings using Enable namespace in GlobalVariables.C Enable::BLACKHOLE = true; @@ -399,6 +411,14 @@ int Fun4All_G4_EICDetector( // Enable::B0_DISABLE_HITPLANE = true; // Enable::B0_FULLHITPLANE = true; + // RP + // Enable::RP_DISABLE_HITPLANE = true; + // Enable::RP_FULLHITPLANE = true; + + // RP after 2nd focus for IP8 only + // Enable::RP2nd_DISABLE_HITPLANE = true; + // Enable::RP2nd_FULLHITPLANE = true; + // Enabling the event evaluator? Enable::EVENT_EVAL = true; // EVENT_EVALUATOR::Verbosity = 1; diff --git a/detectors/EICDetector/G4Setup_EICDetector.C b/detectors/EICDetector/G4Setup_EICDetector.C index c07ad915..f0efab05 100644 --- a/detectors/EICDetector/G4Setup_EICDetector.C +++ b/detectors/EICDetector/G4Setup_EICDetector.C @@ -1,6 +1,9 @@ #ifndef MACRO_G4SETUPEICDETECTOR_C #define MACRO_G4SETUPEICDETECTOR_C +#include +#include + #include #include @@ -32,6 +35,9 @@ #include #include #include +#include +#include +#include // these two has to be ordered this way for now. #include @@ -83,6 +89,36 @@ void G4Init() cout << "Can not enable CEMC and BECAL at the same time!" << endl; gSystem->Exit(1); } + if (Enable::BTOF and Enable::CTTL) + { + cout << "Can not enable BTOF and CTTL at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::ETOF and Enable::ETTL) + { + cout << "Can not enable ETOF and ETTL at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::HTOF and Enable::FTTL) + { + cout << "Can not enable HTOF and FTTL at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::BMMG and Enable::DIRC) + { + cout << "Can not enable BMMG and DIRC at the same time!" << endl; + gSystem->Exit(1); + } + if ((Enable::TRD||Enable::TRD_GAS) and Enable::RICH) + { + cout << "Can not enable TRD* and RICH at the same time!" << endl; + gSystem->Exit(1); + } + if ((Enable::LFHCAL||Enable::EHCAL) and Enable::PLUGDOOR) + { + cout << "Can not enable *HCal and PLUGDOOR at the same time!" << endl; + gSystem->Exit(1); + } // load detector/material macros and execute Init() function if (Enable::PIPE) PipeInit(); @@ -104,6 +140,8 @@ void G4Init() MagnetFieldInit(); // We want the field - even if the magnet volume is disabled if (Enable::HCALOUT) HCalOuterInit(); if (Enable::DIRC) DIRCInit(); + if (Enable::BTOF) BToFInit(); + if (Enable::BMMG) BMMGInit(); //Forward if (Enable::FGEM) FGEM_Init(); @@ -112,6 +150,8 @@ void G4Init() if (Enable::FHCAL) FHCALInit(); if (Enable::LFHCAL) LFHCALInit(); if (Enable::RICH) RICHInit(); + if (Enable::TRD) TRDInit(); + if(Enable::HTOF) HTOFInit(); //Backward if (Enable::EGEM) EGEM_Init(); @@ -119,6 +159,8 @@ void G4Init() if (Enable::EEMCH) EEMCHInit(); if (Enable::EHCAL) EHCALInit(); if (Enable::mRICH) mRICHInit(); + if(Enable::ETOF) ETOFInit(); + //Combined if (Enable::FST) FST_Init(); @@ -200,6 +242,8 @@ int G4Setup() if (Enable::MAGNET) radius = Magnet(g4Reco, radius); if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4); if (Enable::DIRC) DIRCSetup(g4Reco); + if (Enable::BTOF) BToFSetup(g4Reco); + if (Enable::BMMG) BMMGSetup(g4Reco); //Forward if (Enable::FGEM) FGEMSetup(g4Reco); @@ -209,6 +253,8 @@ int G4Setup() if (Enable::FHCAL) FHCALSetup(g4Reco); if (Enable::LFHCAL) LFHCALSetup(g4Reco); if (Enable::RICH) RICHSetup(g4Reco); + if (Enable::TRD) TRDSetup(g4Reco); + if (Enable::HTOF) HTOFSetup(g4Reco); //Backward if (Enable::ETTL) ETTLSetup(g4Reco); @@ -217,6 +263,7 @@ int G4Setup() if (Enable::EEMCH) EEMCHSetup(g4Reco); if (Enable::EHCAL) EHCALSetup(g4Reco); if (Enable::mRICH) mRICHSetup(g4Reco); + if (Enable::ETOF) ETOFSetup(g4Reco); //---------------------------------------- // sPHENIX forward flux return door From deaf6e1ebc52448d3aa642ec397d2b575c0b73d0 Mon Sep 17 00:00:00 2001 From: Jin Huang Date: Mon, 8 Nov 2021 09:56:17 -0500 Subject: [PATCH 11/15] install default option for TTL to TTL macro (#88) --- common/G4_TTL_EIC.C | 4 ++-- detectors/EICDetector/Fun4All_G4_EICDetector.C | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/common/G4_TTL_EIC.C b/common/G4_TTL_EIC.C index da907a7f..cad08843 100644 --- a/common/G4_TTL_EIC.C +++ b/common/G4_TTL_EIC.C @@ -39,11 +39,11 @@ namespace G4TTL double xoffsetFTTLIP8[3] = { 8.4, 8.4, 8.4}; namespace SETTING { - bool optionCEMC = true; + bool optionCEMC = false; bool optionEEMCH = true; bool optionBasicGeo = false; int optionDR = 0; - int optionGeo = 1; + int optionGeo = 7; int optionGran = 1; } // namespace SETTING diff --git a/detectors/EICDetector/Fun4All_G4_EICDetector.C b/detectors/EICDetector/Fun4All_G4_EICDetector.C index f9adbe19..8bc46a91 100644 --- a/detectors/EICDetector/Fun4All_G4_EICDetector.C +++ b/detectors/EICDetector/Fun4All_G4_EICDetector.C @@ -288,8 +288,6 @@ int Fun4All_G4_EICDetector( Enable::FTTL = true; Enable::ETTL = true; Enable::CTTL = true; - G4TTL::SETTING::optionCEMC = false; - G4TTL::SETTING::optionGeo = 7; //mRPC TOFs Enable::BTOF = false; @@ -364,7 +362,6 @@ int Fun4All_G4_EICDetector( Enable::DRCALO_TOWER = Enable::DRCALO_CELL && true; Enable::DRCALO_CLUSTER = Enable::DRCALO_TOWER && true; Enable::DRCALO_EVAL = Enable::DRCALO_CLUSTER && false; - G4TTL::SETTING::optionDR = 1; Enable::LFHCAL = true; Enable::LFHCAL_ABSORBER = false; @@ -378,7 +375,6 @@ int Fun4All_G4_EICDetector( Enable::EEMCH_TOWER = Enable::EEMCH && true; Enable::EEMCH_CLUSTER = Enable::EEMCH_TOWER && true; Enable::EEMCH_EVAL = Enable::EEMCH_CLUSTER && true; - G4TTL::SETTING::optionEEMCH = Enable::EEMCH && true; Enable::EHCAL = true; Enable::EHCAL_CELL = Enable::EHCAL && true; From 484f4b1e738bcdf7e6998cacc7b299dff48a1915 Mon Sep 17 00:00:00 2001 From: Sasha Bylinkin <37345380+abylinkin@users.noreply.github.com> Date: Tue, 9 Nov 2021 17:51:15 -0500 Subject: [PATCH 12/15] B0 Ecal implementation (#89) * Update Fun4All_G4_EICDetector.C Fun4All macro updated with B0 EM Calorimeter implementation * Add files via upload G4Setup for B0 ECal * Add files via upload Setup for B0 Ecal implementation * Add files via upload Setup for B0 Ecal implementation * Delete G4_B0ECAL.C * Delete G4_hFarFwdBeamLine_EIC.C * Add files via upload B0 Ecal implementation * Update G4_hFarFwdBeamLine_EIC.C * Update G4Setup_EICDetector.C * Update G4_hFarFwdBeamLine_EIC.C --- common/G4_B0ECAL.C | 142 +++ common/G4_hFarFwdBeamLine_EIC.C | 1116 ++++++++++------- .../EICDetector/Fun4All_G4_EICDetector.C | 12 + detectors/EICDetector/G4Setup_EICDetector.C | 31 +- 4 files changed, 811 insertions(+), 490 deletions(-) create mode 100644 common/G4_B0ECAL.C diff --git a/common/G4_B0ECAL.C b/common/G4_B0ECAL.C new file mode 100644 index 00000000..9ff9d3b4 --- /dev/null +++ b/common/G4_B0ECAL.C @@ -0,0 +1,142 @@ +#ifndef MACRO_G4B0ECAL_C +#define MACRO_G4B0ECAL_C + +#include + +//include our own B0 Raw Tower Builder +#include + +#include + +#include +// Use Forward Cal Cell Reco . + +#include +// Include our Subsystem + +//Standard RawTowerDefs.h is modified + +#include + +#include + +#include +#include + +#include +#include +#include + +#include + +R__LOAD_LIBRARY(libcalo_reco.so) +R__LOAD_LIBRARY(libg4calo.so) +R__LOAD_LIBRARY(libg4eiccalos.so) +R__LOAD_LIBRARY(libg4eval.so) + +namespace Enable +{ + bool B0ECAL = false; + bool B0ECAL_ABSORBER = false; + bool B0ECAL_CELL = false; + bool B0ECAL_TOWER = false; + bool B0ECAL_CLUSTER = false; + bool B0ECAL_EVAL = false; + bool B0ECAL_OVERLAPCHECK = false; + int B0ECAL_VERBOSITY = 0; +} // namespace Enable + + +namespace G4B0ECAL +{ + + double minz = 678; + double maxz = 698; + double radius = 20; + + // Default set to B0 Ecal position at IP6 + + // Digitization (default photon digi): + RawTowerDigitizer::enu_digi_algorithm TowerDigi = RawTowerDigitizer::kNo_digitization; + // directly pass the energy of sim tower to digitized tower + // kNo_digitization + // simple digitization with photon statistics, single amplitude ADC conversion and pedestal + // kSimple_photon_digitization + // digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal + // kSiPM_photon_digitization + +} // namespace G4B0ECAL + +void B0ECALInit() +{ +} + +void B0ECALSetup(PHG4Reco *g4Reco) +{ +//Done in G4_hFarFwdBeamLine.C +} + +void B0ECAL_Cells(int verbosity = 0) +{ + return; +} + +void B0ECAL_Towers() +{ + int verbosity = std::max(Enable::VERBOSITY, Enable::B0ECAL_VERBOSITY); + + Fun4AllServer *se = Fun4AllServer::instance(); + + ostringstream mapping_b0ecal; + mapping_b0ecal << getenv("CALIBRATIONROOT") << "/B0Ecal/mapping/B0ECAL_mapping_v1.txt"; + //mapping_b0ecal << "B0ECAL_mapping_v1.txt"; + + B0RawTowerBuilderByHitIndex *tower_B0ECAL = new B0RawTowerBuilderByHitIndex("TowerBuilder_B0ECAL"); + tower_B0ECAL->Detector("B0ECAL"); + tower_B0ECAL->set_sim_tower_node_prefix("SIM"); + tower_B0ECAL->GeometryTableFile(mapping_b0ecal.str()); + + se->registerSubsystem(tower_B0ECAL); + + + RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("B0ECALRawTowerDigitizer"); + TowerDigitizer->Detector("B0ECAL"); + TowerDigitizer->Verbosity(verbosity); + TowerDigitizer->set_digi_algorithm(RawTowerDigitizer::kNo_digitization); + se->registerSubsystem(TowerDigitizer); + + RawTowerCalibration *TowerCalibration = new RawTowerCalibration("B0ECALRawTowerCalibration"); + TowerCalibration->Detector("B0ECAL"); + TowerCalibration->Verbosity(verbosity); + TowerCalibration->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration); + TowerCalibration->set_calib_const_GeV_ADC(1. ); + TowerCalibration->set_pedstal_ADC(0); + se->registerSubsystem(TowerCalibration); +} + +void B0ECAL_Clusters() +{ + int verbosity = std::max(Enable::VERBOSITY, Enable::B0ECAL_VERBOSITY); + Fun4AllServer *se = Fun4AllServer::instance(); + + RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("B0ECALRawClusterBuilderFwd"); + ClusterBuilder->Detector("B0ECAL"); + ClusterBuilder->Verbosity(verbosity); + ClusterBuilder->set_threshold_energy(0.100); + se->registerSubsystem(ClusterBuilder); + + return; +} + +void B0ECAL_Eval(const std::string &outputfile) +{ + int verbosity = std::max(Enable::VERBOSITY, Enable::B0ECAL_VERBOSITY); + Fun4AllServer *se = Fun4AllServer::instance(); + + CaloEvaluator *eval = new CaloEvaluator("B0ECALEVALUATOR", "B0ECAL", outputfile.c_str()); + eval->Verbosity(verbosity); + se->registerSubsystem(eval); + + return; +} +#endif diff --git a/common/G4_hFarFwdBeamLine_EIC.C b/common/G4_hFarFwdBeamLine_EIC.C index 376139b2..46e3e384 100644 --- a/common/G4_hFarFwdBeamLine_EIC.C +++ b/common/G4_hFarFwdBeamLine_EIC.C @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -38,8 +39,8 @@ namespace Enable bool HFARFWD_PIPE = false; bool HFARFWD_OVERLAPCHECK = false; int HFARFWD_VERBOSITY = 0; - - // Detector configuration options + +// Detector configuration options bool ZDC_DISABLE_BLACKHOLE = false; bool B0_DISABLE_HITPLANE = false; bool B0_FULLHITPLANE = false; @@ -47,6 +48,7 @@ namespace Enable bool RP_FULLHITPLANE = false; bool RP2nd_DISABLE_HITPLANE = false; bool RP2nd_FULLHITPLANE = false; + bool B0ECALTOWERS = true; //Set to 'false' for nice PackMan views. Set 'true' for physics studies. //enabled automatically in hFarFwdBeamLineInit(), unless overridden by user bool HFARFWD_MAGNETS_IP6 = false; @@ -72,6 +74,9 @@ namespace hFarFwdBeamLine PHG4CylinderSubsystem *hFarFwdBeamLineEnclosure(nullptr); BeamLineMagnetSubsystem *B0Magnet = (nullptr); + double B0Magnet_x = NAN; + double B0Magnet_y = NAN; + double B0Magnet_z = NAN; } // namespace hFarFwdBeamLine void hFarFwdBeamLineInit() @@ -181,10 +186,10 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) } else { - //------------------------ - //Select only the magnet component in the far forward region - if (z < 0.0) - continue; + //------------------------ + //Select only the magnet component in the far forward region + if (z < 0.0) + continue; string magtype; if (inner_radius_zin != inner_radius_zout) @@ -237,14 +242,13 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) outer_magnet_diameter *= 100.; angle = (angle / TMath::Pi() * 180.) / 1000.; // given in mrad - //------------------------ - // Linearly scaling down the magnetic field for lower energy proton - if (Enable::HFARFWD_ION_ENERGY != 275) - { - float scaleFactor = Enable::HFARFWD_ION_ENERGY / 275.; - dipole_field_x = dipole_field_x * scaleFactor; - fieldgradient = fieldgradient * scaleFactor; - } + //------------------------ + // Linearly scaling down the magnetic field for lower energy proton + if( Enable::HFARFWD_ION_ENERGY != 275 ) { + float scaleFactor = Enable::HFARFWD_ION_ENERGY / 275. ; + dipole_field_x = dipole_field_x*scaleFactor; + fieldgradient = fieldgradient * scaleFactor; + } if (magnetlist.empty() || magnetlist.find(imagnet) != magnetlist.end()) { @@ -253,14 +257,14 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) bl->set_double_param("fieldgradient", MagFieldFlip(fieldgradient)); bl->set_string_param("magtype", magtype); bl->set_double_param("length", length); - bl->set_double_param("place_x", PosFlip(x)); // relative position to mother vol. - bl->set_double_param("place_y", y); // relative position to mother vol. - bl->set_double_param("place_z", z - hFarFwdBeamLine::enclosure_center); // relative position to mother vol. - bl->set_double_param("field_global_position_x", PosFlip(x)); // abs. position to world for field manager - bl->set_double_param("field_global_position_y", y); // abs. position to world for field manager - bl->set_double_param("field_global_position_z", z); // abs. position to world for field manager + bl->set_double_param("place_x", PosFlip(x)); // relative position to mother vol. + bl->set_double_param("place_y", y); // relative position to mother vol. + bl->set_double_param("place_z", z - hFarFwdBeamLine::enclosure_center); // relative position to mother vol. + bl->set_double_param("field_global_position_x", PosFlip(x)); // abs. position to world for field manager + bl->set_double_param("field_global_position_y", y); // abs. position to world for field manager + bl->set_double_param("field_global_position_z", z); // abs. position to world for field manager bl->set_double_param("rot_y", AngleFlip(angle)); - bl->set_double_param("field_global_rot_y", AngleFlip(angle)); // abs. rotation to world for field manager + bl->set_double_param("field_global_rot_y", AngleFlip(angle)); // abs. rotation to world for field manager bl->set_double_param("inner_radius", inner_radius_zin); bl->set_double_param("outer_radius", outer_magnet_diameter / 2.); bl->SetActive(magnet_active); @@ -278,7 +282,12 @@ void hFarFwdDefineMagnets(PHG4Reco *g4Reco) // rag the B0 magnet if (imagnet == 0) - hFarFwdBeamLine::B0Magnet = bl; + { //To tell the B0 Calorimeter the global coordinates of the B0 Magnet + hFarFwdBeamLine::B0Magnet = bl; + hFarFwdBeamLine::B0Magnet_x = PosFlip(x); + hFarFwdBeamLine::B0Magnet_y = y; + hFarFwdBeamLine::B0Magnet_z = z; + } } imagnet++; if (fabs(z) + length > biggest_z) @@ -355,11 +364,11 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) detOM->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); g4Reco->registerSubsystem(detOM); } - ////********************* // RP // Three choices: 1. Realistic detector; 2. Circulat or square plane; 3. hit plane with realistic detector goemetry + const int rpDetNr = 2; const double rp_zCent[rpDetNr] = {2600, 2800}; const double rp_xCent[rpDetNr] = {-83.22, -92.20}; @@ -423,7 +432,7 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) } else { - if (Enable::B0_FULLHITPLANE) + if (Enable::RP_FULLHITPLANE) { for (int i = 0; i < rpDetNr; i++) { @@ -501,212 +510,331 @@ void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco) } } } - - //--------------------------------- - // B0 implementation - // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry - - if (Enable::B0_DISABLE_HITPLANE) - { - // Choice 1 realistic detector - - const int b0DetNr = 4; - const double b0Mag_zCent = 640; - const double b0Mag_zLen = 120; - const double b0Cu_zLen = .2; //B0 dead material length - const double b0Si_zLen = .1; //B0 Si length - const double b0Ecal_zLen = 20.; //B0 Ecal length - const double pipe_hole = 5.0; //detector cut off for beam pipe - const double pipe_x = -3.4; //pipe hole position - const double d_radius = 7.0; //detector cut off Packman - const double b0_radius = 20.0; //outer radius of B0-detector - const double spanning_angle = 240; //spanning angle Packman - const double b0Ecal_z = 48; - double start_angle = 60; //start angle Packman - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i), 2 * i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("place_x", 0); - detB0->set_double_param("place_y", 0); + + //--------------------------------- + // B0 implementation + // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry + + double b0tr_z = 0; //Subsystem position relative to B0 magnet (for iterator) + + if (Enable::B0_DISABLE_HITPLANE) { + + // Choice 1 realistic detector + cout << "Realistic B0"<SuperDetector(Form("b0Truth_%d", i)); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); // detB0->set_int_param("ispipe", 0); //for future pipe implementation - detB0->set_double_param("pipe_hole", pipe_hole); - detB0->set_double_param("outer_radius", b0_radius); - detB0->set_double_param("d_radius", d_radius); - detB0->set_double_param("length", b0Si_zLen); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("detid", 2 * i); - detB0->set_double_param("startAngle", start_angle); - detB0->set_double_param("spanningAngle", spanning_angle); - detB0->set_double_param("pipe_x", pipe_x); - detB0->set_double_param("pipe_y", 0); - detB0->set_double_param("pipe_z", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0); - - auto *detB0e = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i + 1), 2 * i + 1); - detB0e->SuperDetector("b0Truth"); + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("startAngle",start_angle); + detB0->set_double_param("spanningAngle",spanning_angle); + detB0->set_double_param("detid",i); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0tr_z); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); +// For B0 Tracking Implementation +/* if (Enable::B0TRACKING){ + if (B0TRACKING::FastKalmanFilter) + { + B0TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames, + B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + G4B0TRACKING::PositionResolution, // const float radres, + G4B0TRACKING::PositionResolution, // const float phires, + 0, // const float lonres, *ignored in plane detector* + 1, // const float eff, + 0); // const float noise + B0TRACKING::FastKalmanFilter->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z); + B0TRACKING::FastKalmanFilterB0Track->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames, + B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + G4B0TRACKING::PositionResolution, // const float radres, + G4B0TRACKING::PositionResolution, // const float phires, + 0, // const float lonres, *ignored in plane detector* + 1, // const float eff, + 0); // const float noise + B0TRACKING::FastKalmanFilterB0Track->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z); + B0TRACKING::B0ProjectionNames.insert(Form("b0Truth_%d", i)); + } + } +*/ + auto *detB0e = new EICG4B0Subsystem(Form("b0Dead_%d", i), i); + detB0e->SuperDetector("b0Dead"); // detB0e->set_int_param("ispipe", 0); //for future pipe implementation - detB0e->set_double_param("pipe_hole", pipe_hole); - detB0e->set_double_param("place_x", 0); - detB0e->set_double_param("place_y", 0); - detB0e->set_double_param("d_radius", d_radius); - detB0e->set_double_param("pipe_x", pipe_x); - detB0e->set_double_param("pipe_y", 0); - detB0e->set_double_param("pipe_z", 0); - detB0e->set_double_param("outer_radius", b0_radius); - detB0e->set_double_param("length", b0Cu_zLen); - detB0e->set_string_param("material", "G4_Cu"); - detB0e->set_double_param("detid", 2 * i + 1); - detB0e->set_double_param("startAngle", start_angle); - detB0e->set_double_param("spanningAngle", spanning_angle); - detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) + (b0Cu_zLen + b0Si_zLen) / 2)); // relative to B0 magnet - detB0e->SetActive(true); - if (verbosity) detB0e->Verbosity(verbosity); - detB0e->OverlapCheck(overlapCheck); - detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0e); + detB0e->set_double_param("pipe_hole", pipe_hole); + detB0e->set_double_param("place_x", 0); + detB0e->set_double_param("place_y", 0); + detB0e->set_double_param("d_radius", d_radius); + detB0e->set_double_param("pipe_x", pipe_x); + detB0e->set_double_param("pipe_y", 0); + detB0e->set_double_param("pipe_z", 0); + detB0e->set_double_param("outer_radius", b0_radius); + detB0e->set_double_param("length", b0Cu_zLen); + detB0e->set_string_param("material", "G4_Cu"); + detB0e->set_double_param("detid",i); + detB0e->set_double_param("startAngle",start_angle); + detB0e->set_double_param("spanningAngle",spanning_angle); + detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) +(b0Cu_zLen+b0Si_zLen)/2) ); // relative to B0 magnet + detB0e->SetActive(false); + if (verbosity) + detB0e->Verbosity(verbosity); + detB0e->OverlapCheck(overlapCheck); + detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0e); + } + + if (Enable::B0ECAL) { + if (Enable::B0ECALTOWERS){ //Use this option to do physics studies + cout << hFarFwdBeamLine::B0Magnet_x<SetTowerMappingFile(mapping_b0ecal.str()); + B0Ecal->SuperDetector("B0ECAL"); + B0Ecal->set_double_param("pipe_hole", pipe_hole); + B0Ecal->set_double_param("place_x", 0); + B0Ecal->set_double_param("place_y", 0); + B0Ecal->set_double_param("place_z", b0Ecal_z); + B0Ecal->set_double_param("pipe_x", pipe_x); + B0Ecal->set_double_param("pipe_y", 0); + B0Ecal->set_double_param("pipe_z", 0); + B0Ecal->set_double_param("length", b0Ecal_zLen); + B0Ecal->set_double_param("outer_radius", b0_radius); + B0Ecal->set_double_param("d_radius", d_radius); + B0Ecal->set_string_param("material", "G4_PbWO4"); + B0Ecal->set_double_param("startAngle",start_angle); + B0Ecal->set_double_param("spanningAngle",spanning_angle); + B0Ecal->set_double_param("detid",0); + B0Ecal->set_double_param("global_x",hFarFwdBeamLine::B0Magnet_x); + B0Ecal->set_double_param("global_y",hFarFwdBeamLine::B0Magnet_y); + B0Ecal->set_double_param("global_z",hFarFwdBeamLine::B0Magnet_z); + B0Ecal->set_int_param("lightyield",1); //Note additional parameter for storing Light Yield in B0 Ecal + B0Ecal->SetActive(true); + if (verbosity) + B0Ecal->Verbosity(verbosity); + B0Ecal->OverlapCheck(overlapCheck); + B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecal); + } + else { //Use this option to have a circular packman-shape of the B0 ECal for plots. + auto *B0Ecal = new EICG4B0Subsystem(Form("b0Truth_%d", 2*b0DetNr), 2*b0DetNr); + B0Ecal->SuperDetector("b0Truth"); + B0Ecal->set_double_param("pipe_hole", pipe_hole); + B0Ecal->set_double_param("place_x", 0); + B0Ecal->set_double_param("place_y", 0); + B0Ecal->set_double_param("place_z", b0Ecal_z); + B0Ecal->set_double_param("pipe_x", pipe_x); + B0Ecal->set_double_param("pipe_y", 0); + B0Ecal->set_double_param("pipe_z", 0); + B0Ecal->set_double_param("length", b0Ecal_zLen); + B0Ecal->set_double_param("outer_radius", b0_radius); + B0Ecal->set_double_param("d_radius", d_radius); + B0Ecal->set_string_param("material", "G4_PbWO4"); + B0Ecal->set_double_param("startAngle",start_angle); + B0Ecal->set_double_param("spanningAngle",spanning_angle); + B0Ecal->set_double_param("detid",2*b0DetNr); + B0Ecal->SetActive(true); + if (verbosity) + B0Ecal->Verbosity(verbosity); + B0Ecal->OverlapCheck(overlapCheck); + B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecal); + } + + auto *B0Ecale = new EICG4B0Subsystem(Form("b0Dead_%d", b0DetNr), b0DetNr); //B0 ECal dead layer is the same subsystem as other four dead layers + B0Ecale->SuperDetector("b0Dead"); + // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation + B0Ecale->set_double_param("pipe_hole", pipe_hole); + B0Ecale->set_double_param("place_x", 0); + B0Ecale->set_double_param("place_y", 0); + B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen)/2); + B0Ecale->set_double_param("pipe_x", pipe_x); + B0Ecale->set_double_param("pipe_y", 0); + B0Ecale->set_double_param("pipe_z", 0); + B0Ecale->set_double_param("length", b0Cu_zLen); + B0Ecale->set_double_param("d_radius", d_radius); + B0Ecale->set_double_param("outer_radius", b0_radius); + B0Ecale->set_string_param("material", "G4_Cu"); + B0Ecale->set_double_param("startAngle",start_angle); + B0Ecale->set_double_param("spanningAngle",spanning_angle); + B0Ecale->set_double_param("detid",b0DetNr+1); + //B0Ecale->SetActive(true); + B0Ecale->SetActive(false); + if (verbosity) + B0Ecale->Verbosity(verbosity); + B0Ecale->OverlapCheck(overlapCheck); + B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecale); + } + } else { + + if (Enable::B0_FULLHITPLANE) { + + // Choice 2 circular hit planes + cout << "Circular hit planes"<SuperDetector(Form("b0Truth_%d", i)); + detB0->set_double_param("radius", 0); + detB0->set_double_param("thickness", 20); + detB0->set_double_param("length", 0.1); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("place_z", b0tr_z); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + + g4Reco->registerSubsystem(detB0); +/* if (Enable::B0TRACKING){ + if (B0TRACKING::FastKalmanFilter) + { + B0TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames, + B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + G4B0TRACKING::PositionResolution, // const float radres, + G4B0TRACKING::PositionResolution, // const float phires, + 0, // const float lonres, *ignored in plane detector* + 1, // const float eff, + 0); // const float noise + B0TRACKING::FastKalmanFilter->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z); + B0TRACKING::FastKalmanFilterB0Track->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames, + B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + G4B0TRACKING::PositionResolution, // const float radres, + G4B0TRACKING::PositionResolution, // const float phires, + 0, // const float lonres, *ignored in plane detector* + 1, // const float eff, + 0); // const float noise + B0TRACKING::FastKalmanFilterB0Track->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z); + B0TRACKING::B0ProjectionNames.insert(Form("b0Truth_%d", i)); + } + } +*/ + } + + } else { + + /// Fun4All default B0 planes + /// Choice 3 Hit planes with real detector geometry + cout << "Realistic hit planes"<SuperDetector(Form("b0Truth_%d", i)); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); + // detB0->set_int_param("ispipe", 0); //for future pipe implementation + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid",i); + detB0->set_double_param("startAngle",start_angle); + detB0->set_double_param("spanningAngle",spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0tr_z); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); +/* if (Enable::B0TRACKING){ + if (B0TRACKING::FastKalmanFilter) + { + B0TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames, + B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + G4B0TRACKING::PositionResolution, // const float radres, + G4B0TRACKING::PositionResolution, // const float phires, + 0, // const float lonres, *ignored in plane detector* + 1, // const float eff, + 0); // const float noise + B0TRACKING::FastKalmanFilter->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z); + B0TRACKING::FastKalmanFilterB0Track->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames, + B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype, + G4B0TRACKING::PositionResolution, // const float radres, + G4B0TRACKING::PositionResolution, // const float phires, + 0, // const float lonres, *ignored in plane detector* + 1, // const float eff, + 0); // const float noise + B0TRACKING::FastKalmanFilterB0Track->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z); + B0TRACKING::B0ProjectionNames.insert(Form("b0Truth_%d", i)); + } + } +*/ } + + } } - auto *B0Ecal = new EICG4B0Subsystem("B0Ecal", 2 * b0DetNr); - B0Ecal->SuperDetector("b0Truth"); - // B0Ecal->set_int_param("ispipe", 0); //for future pipe implementation - B0Ecal->set_double_param("pipe_hole", pipe_hole); - B0Ecal->set_double_param("place_x", 0); - B0Ecal->set_double_param("place_y", 0); - B0Ecal->set_double_param("place_z", b0Ecal_z); - B0Ecal->set_double_param("pipe_x", pipe_x); - B0Ecal->set_double_param("pipe_y", 0); - B0Ecal->set_double_param("pipe_z", 0); - B0Ecal->set_double_param("length", b0Ecal_zLen); - B0Ecal->set_double_param("outer_radius", b0_radius); - B0Ecal->set_double_param("d_radius", d_radius); - B0Ecal->set_string_param("material", "G4_PbWO4"); - B0Ecal->set_double_param("startAngle", start_angle); - B0Ecal->set_double_param("spanningAngle", spanning_angle); - B0Ecal->set_double_param("detid", 2 * b0DetNr); - B0Ecal->SetActive(true); - if (verbosity) B0Ecal->Verbosity(verbosity); - B0Ecal->OverlapCheck(overlapCheck); - B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(B0Ecal); - - auto *B0Ecale = new EICG4B0Subsystem("B0Ecale", 2 * b0DetNr + 1); - B0Ecal->SuperDetector("b0Truth"); - // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation - B0Ecale->set_double_param("pipe_hole", pipe_hole); - B0Ecale->set_double_param("place_x", 0); - B0Ecale->set_double_param("place_y", 0); - B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen) / 2); - B0Ecale->set_double_param("pipe_x", pipe_x); - B0Ecale->set_double_param("pipe_y", 0); - B0Ecale->set_double_param("pipe_z", 0); - B0Ecale->set_double_param("length", b0Cu_zLen); - B0Ecale->set_double_param("d_radius", d_radius); - B0Ecale->set_double_param("outer_radius", b0_radius); - B0Ecale->set_string_param("material", "G4_Cu"); - B0Ecale->set_double_param("startAngle", start_angle); - B0Ecale->set_double_param("spanningAngle", spanning_angle); - B0Ecale->set_double_param("detid", 2 * b0DetNr + 1); - B0Ecale->SetActive(true); - if (verbosity) B0Ecale->Verbosity(verbosity); - B0Ecale->OverlapCheck(overlapCheck); - B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(B0Ecale); - } - else - { - if (Enable::B0_FULLHITPLANE) - { - // Choice 2 circular hit planes - - const int b0DetNr = 4; - - // Sep 09 2021 by Bill: - // B0 magnet center location in z: 640 - // B0 place location in z after 50cm shift: 592, 616, 640, 664 - // B0 layers has the same x coordinate: -14.57 - - const double b0Mag_zCent = 640; - const double b0Mag_zLen = 120; - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("radius", 0); - detB0->set_double_param("thickness", 20); - detB0->set_double_param("length", 0.1); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - - g4Reco->registerSubsystem(detB0); - } - } - else - { - /// Fun4All default B0 planes - /// Choice 3 Hit planes with real detector geometry - - const int b0DetNr = 4; - const double b0Mag_zCent = 640; - const double b0Mag_zLen = 120; - const double b0Cu_zLen = .2; //B0 dead material length - const double b0Si_zLen = .1; //B0 Si length - const double b0Ecal_zLen = 20.; //B0 Ecal length - const double pipe_hole = 5.0; //detector cut off for beam pipe - const double pipe_x = -3.4; //pipe hole position - const double d_radius = 7.0; //detector cut off Packman - const double b0_radius = 20.0; //outer radius of B0-detector - const double spanning_angle = 240; //spanning angle Packman - const double b0Ecal_z = 48; - double start_angle = 60; //start angle Packman - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i), 2 * i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("place_x", 0); - detB0->set_double_param("place_y", 0); - // detB0->set_int_param("ispipe", 0); //for future pipe implementation - detB0->set_double_param("pipe_hole", pipe_hole); - detB0->set_double_param("outer_radius", b0_radius); - detB0->set_double_param("d_radius", d_radius); - detB0->set_double_param("length", b0Si_zLen); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("detid", 2 * i); - detB0->set_double_param("startAngle", start_angle); - detB0->set_double_param("spanningAngle", spanning_angle); - detB0->set_double_param("pipe_x", pipe_x); - detB0->set_double_param("pipe_y", 0); - detB0->set_double_param("pipe_z", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0); - } - } - } } void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) { - //-------------------------------------------------------- - // The IP8 detector position is implemented by Wenliang Li (billlee@jlab.org) - // on July 07, 2021 - // Reference of this implementation: https://indico.bnl.gov/event/10974/contributions/51160/ +//-------------------------------------------------------- +// The IP8 detector position is implemented by Wenliang Li (billlee@jlab.org) +// on July 07, 2021 +// Reference of this implementation: https://indico.bnl.gov/event/10974/contributions/51160/ bool overlapCheck = Enable::OVERLAPCHECK || Enable::HFARFWD_OVERLAPCHECK; if (Enable::HFARFWD_VIRTUAL_DETECTORS_IP6 && Enable::HFARFWD_VIRTUAL_DETECTORS_IP8) @@ -762,6 +890,7 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) if (Enable::ZDC_DISABLE_BLACKHOLE) { + EICG4ZDCSubsystem *detZDC = new EICG4ZDCSubsystem("EICG4ZDC"); detZDC->SetActive(); detZDC->set_double_param("place_z", 3350. + detZDCsurrogate_size_z - hFarFwdBeamLine::enclosure_center); @@ -770,6 +899,7 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) detZDC->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure); detZDC->OverlapCheck(overlapCheck); g4Reco->registerSubsystem(detZDC); + } //------------------ @@ -782,7 +912,7 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) const int rpDetNr = 2; const double rp_zCent[rpDetNr] = {2600, 2800}; const double rp_xCent[rpDetNr] = {75.6, 78.15}; - + if (Enable::RP_DISABLE_HITPLANE) { // Circular disk design (16cm in) @@ -854,7 +984,7 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) } else { - if (Enable::B0_FULLHITPLANE) + if (Enable::RP_FULLHITPLANE) { for (int i = 0; i < rpDetNr; i++) { @@ -928,10 +1058,9 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) } } - ////********************* + //------------------ // Roman pot set #2 before and after the secondary focus // Three choices: 1. Realistic detector; 2. Circulat or square plane; 3. hit plane with realistic detector goemetry - const int rp2ndDetNr = 2; const double rp_2nd_xCent[rp2ndDetNr] = {101.94, 106.94}; const double rp_2nd_zCent[rp2ndDetNr] = {4300, 4450}; @@ -995,7 +1124,7 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) } else { - if (Enable::B0_FULLHITPLANE) + if (Enable::RP_FULLHITPLANE) { for (int i = 0; i < rp2ndDetNr; i++) { @@ -1054,239 +1183,272 @@ void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco) } } - //--------------------------------- - // B0 implementation - // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry - if (verbosity > 0) { std::cout << "B0Magnet can be mother = " << hFarFwdBeamLine::B0Magnet->CanBeMotherSubsystem() << std::endl; } - //--------------------------------- - // B0 implementation - // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry - - if (Enable::B0_DISABLE_HITPLANE) +/* const int b0DetNr = 4; + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + for (int i = 0; i < b0DetNr; i++) { - // Choice 1 realistic detector - - const int b0DetNr = 4; - - const double b0Mag_zCent = 610; - const double b0Mag_zLen = 120; - const double b0Cu_zLen = .2; //B0 dead material length - const double b0Si_zLen = .1; //B0 Si length - const double b0Ecal_zLen = 20.; //B0 Ecal length - const double pipe_hole = 6.0; //detector cut off for beam pipe - const double pipe_x = 1.0; //pipe hole position - const double d_radius = 9.0; //detector cut off Packman - const double b0_radius = 24.5; //outer radius of B0-detector - const double spanning_angle = 240; //spanning angle Packman - const double b0Ecal_z = 48; - double start_angle = -120; //start angle Packman - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i), 2 * i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("place_x", 0); - detB0->set_double_param("place_y", 0); + auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("radius", 0); + detB0->set_double_param("thickness", 20); + detB0->set_double_param("length", 0.1); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("place_y", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + g4Reco->registerSubsystem(detB0); + }*/ + //--------------------------------- + // B0 implementation + // Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry + + + if (Enable::B0_DISABLE_HITPLANE) { + + // Choice 1 realistic detector + + const int b0DetNr = 4; + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + const double b0Cu_zLen = .2; //B0 dead material length + const double b0Si_zLen = .1; //B0 Si length + const double b0Ecal_zLen = 20.; //B0 Ecal length + const double pipe_hole = 6.0; //detector cut off for beam pipe //- different from IP6 to account for the 35mrad angle + const double pipe_x = -1; //pipe hole position //- different from IP6 to account for the 35mrad angle + const double d_radius = 9.0; //detector cut off Packman //- different from IP6 to account for the 35mrad angle + const double b0_radius = 24.5; //outer radius of B0-detector //- different from IP6 + const double spanning_angle = 240; //spanning angle Packman + const double b0Ecal_z = 48; + const double tower_size = 2; //Tower size for B0 ECal in cm + double start_angle = -120; //start angle Packman //- mirrored wrt to IP6 + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); // detB0->set_int_param("ispipe", 0); //for future pipe implementation - detB0->set_double_param("pipe_hole", pipe_hole); - detB0->set_double_param("outer_radius", b0_radius); - detB0->set_double_param("d_radius", d_radius); - detB0->set_double_param("length", b0Si_zLen); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("detid", 2 * i); - detB0->set_double_param("startAngle", start_angle); - detB0->set_double_param("spanningAngle", spanning_angle); - detB0->set_double_param("pipe_x", pipe_x); - detB0->set_double_param("pipe_y", 0); - detB0->set_double_param("pipe_z", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) - detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0); - - auto *detB0e = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i + 1), 2 * i + 1); - detB0e->SuperDetector("b0Truth"); + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid",2*i); + detB0->set_double_param("startAngle",start_angle); + detB0->set_double_param("spanningAngle",spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); + + auto *detB0e = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i+1), 2*i+1); + detB0e->SuperDetector("b0Truth"); // detB0e->set_int_param("ispipe", 0); //for future pipe implementation - detB0e->set_double_param("pipe_hole", pipe_hole); - detB0e->set_double_param("place_x", 0); - detB0e->set_double_param("place_y", 0); - detB0e->set_double_param("d_radius", d_radius); - detB0e->set_double_param("pipe_x", pipe_x); - detB0e->set_double_param("pipe_y", 0); - detB0e->set_double_param("pipe_z", 0); - detB0e->set_double_param("outer_radius", b0_radius); - detB0e->set_double_param("length", b0Cu_zLen); - detB0e->set_string_param("material", "G4_Cu"); - detB0e->set_double_param("detid", 2 * i + 1); - detB0e->set_double_param("startAngle", start_angle); - detB0e->set_double_param("spanningAngle", spanning_angle); - detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) + (b0Cu_zLen + b0Si_zLen) / 2)); // relative to B0 magnet - detB0e->SetActive(true); - if (verbosity) - detB0e->Verbosity(verbosity); - detB0e->OverlapCheck(overlapCheck); - detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0e); - } - - auto *B0Ecal = new EICG4B0Subsystem("B0Ecal", 2 * b0DetNr); - B0Ecal->SuperDetector("b0Truth"); - // B0Ecal->set_int_param("ispipe", 0); //for future pipe implementation - B0Ecal->set_double_param("pipe_hole", pipe_hole); - B0Ecal->set_double_param("place_x", 0); - B0Ecal->set_double_param("place_y", 0); - B0Ecal->set_double_param("place_z", b0Ecal_z); - B0Ecal->set_double_param("pipe_x", pipe_x); - B0Ecal->set_double_param("pipe_y", 0); - B0Ecal->set_double_param("pipe_z", 0); - B0Ecal->set_double_param("length", b0Ecal_zLen); - B0Ecal->set_double_param("outer_radius", b0_radius); - B0Ecal->set_double_param("d_radius", d_radius); - B0Ecal->set_string_param("material", "G4_PbWO4"); - B0Ecal->set_double_param("startAngle", start_angle); - B0Ecal->set_double_param("spanningAngle", spanning_angle); - B0Ecal->set_double_param("detid", 2 * b0DetNr); - B0Ecal->SetActive(true); - if (verbosity) - B0Ecal->Verbosity(verbosity); - B0Ecal->OverlapCheck(overlapCheck); - B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(B0Ecal); - - auto *B0Ecale = new EICG4B0Subsystem("B0Ecale", 2 * b0DetNr + 1); - B0Ecal->SuperDetector("b0Truth"); - // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation - B0Ecale->set_double_param("pipe_hole", pipe_hole); - B0Ecale->set_double_param("place_x", 0); - B0Ecale->set_double_param("place_y", 0); - B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen) / 2); - B0Ecale->set_double_param("pipe_x", pipe_x); - B0Ecale->set_double_param("pipe_y", 0); - B0Ecale->set_double_param("pipe_z", 0); - B0Ecale->set_double_param("length", b0Cu_zLen); - B0Ecale->set_double_param("d_radius", d_radius); - B0Ecale->set_double_param("outer_radius", b0_radius); - B0Ecale->set_string_param("material", "G4_Cu"); - B0Ecale->set_double_param("startAngle", start_angle); - B0Ecale->set_double_param("spanningAngle", spanning_angle); - B0Ecale->set_double_param("detid", 2 * b0DetNr + 1); - B0Ecale->SetActive(true); - if (verbosity) - B0Ecale->Verbosity(verbosity); - B0Ecale->OverlapCheck(overlapCheck); - B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(B0Ecale); - } - else - { - if (Enable::B0_FULLHITPLANE) - { - // Choice 2 circular hit planes - - const int b0DetNr = 4; - - // Sep 09 2021 by Bill: - // B0 magnet center location in z: 610 - // B0 place location in z after 50cm shift: - // B0 layers has the same x coordinate: -14.57 - - const double b0Mag_zCent = 610; - const double b0Mag_zLen = 120; - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("radius", 0); - detB0->set_double_param("thickness", 20); - detB0->set_double_param("length", 0.1); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); - if (verbosity) detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - - g4Reco->registerSubsystem(detB0); - } - } - else - { - /// Fun4All default B0 planes - /// Choice 3 Hit planes with real detector geometry - - const int b0DetNr = 4; - const double b0Mag_zCent = 610; - const double b0Mag_zLen = 120; - const double b0Cu_zLen = .2; //B0 dead material length - const double b0Si_zLen = .1; //B0 Si length - const double b0Ecal_zLen = 20.; //B0 Ecal length - const double pipe_hole = 6.0; //detector cut off for beam pipe - const double pipe_x = 1.0; //pipe hole position - const double d_radius = 9.0; //detector cut off Packman - const double b0_radius = 24.5; //outer radius of B0-detector - const double spanning_angle = 240; //spanning angle Packman - const double b0Ecal_z = 48; - double start_angle = -120; //start angle Packman - - for (int i = 0; i < b0DetNr; i++) - { - auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2 * i), 2 * i); - detB0->SuperDetector("b0Truth"); - detB0->set_double_param("place_x", 0); - detB0->set_double_param("place_y", 0); - // detB0->set_int_param("ispipe", 0); //for future pipe implementation - detB0->set_double_param("pipe_hole", pipe_hole); - detB0->set_double_param("outer_radius", b0_radius); - detB0->set_double_param("d_radius", d_radius); - detB0->set_double_param("length", b0Si_zLen); - detB0->set_string_param("material", "G4_Si"); - detB0->set_double_param("detid", 2 * i); - detB0->set_double_param("startAngle", start_angle); - detB0->set_double_param("spanningAngle", spanning_angle); - detB0->set_double_param("pipe_x", pipe_x); - detB0->set_double_param("pipe_y", 0); - detB0->set_double_param("pipe_z", 0); - detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet - detB0->SetActive(true); + detB0e->set_double_param("pipe_hole", pipe_hole); + detB0e->set_double_param("place_x", 0); + detB0e->set_double_param("place_y", 0); + detB0e->set_double_param("d_radius", d_radius); + detB0e->set_double_param("pipe_x", pipe_x); + detB0e->set_double_param("pipe_y", 0); + detB0e->set_double_param("pipe_z", 0); + detB0e->set_double_param("outer_radius", b0_radius); + detB0e->set_double_param("length", b0Cu_zLen); + detB0e->set_string_param("material", "G4_Cu"); + detB0e->set_double_param("detid",2*i+1); + detB0e->set_double_param("startAngle",start_angle); + detB0e->set_double_param("spanningAngle",spanning_angle); + detB0e->set_double_param("place_z", (b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2) +(b0Cu_zLen+b0Si_zLen)/2) ); // relative to B0 magnet + detB0e->SetActive(true); + if (verbosity) + detB0e->Verbosity(verbosity); + detB0e->OverlapCheck(overlapCheck); + detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0e); + + + if (Enable::B0ECAL) { + if (Enable::B0ECALTOWERS){ //Use this option to do physics studies + ostringstream mapping_b0ecal; + //mapping_b0ecal << "B0ECAL_mapping_v1.txt"; // Specify the mapping file for B0 ECal Towers here + mapping_b0ecal << getenv("CALIBRATIONROOT") << "/B0Ecal/mapping/B0ECAL_mapping_ip8_v1.txt"; // Specify the mapping file for B0 ECal Towers here + //cout <<"Will use B0 mapping file "<< mapping_b0ecal.str()<SetTowerMappingFile(mapping_b0ecal.str()); + B0Ecal->SuperDetector("B0ECAL"); + B0Ecal->set_double_param("pipe_hole", pipe_hole); + B0Ecal->set_double_param("place_x", 0); + B0Ecal->set_double_param("place_y", 0); + B0Ecal->set_double_param("place_z", b0Ecal_z); + B0Ecal->set_double_param("pipe_x", pipe_x); + B0Ecal->set_double_param("pipe_y", 0); + B0Ecal->set_double_param("pipe_z", 0); + B0Ecal->set_double_param("length", b0Ecal_zLen); + B0Ecal->set_double_param("outer_radius", b0_radius); + B0Ecal->set_double_param("d_radius", d_radius); + B0Ecal->set_string_param("material", "G4_PbWO4"); + B0Ecal->set_double_param("startAngle",start_angle); + B0Ecal->set_double_param("spanningAngle",spanning_angle); + B0Ecal->set_double_param("tower_size",tower_size); + B0Ecal->set_double_param("detid",0); + B0Ecal->set_int_param("lightyield",1); //Note additional parameter for storing Light Yield in B0 Ecal + B0Ecal->SetActive(true); + if (verbosity) + B0Ecal->Verbosity(verbosity); + B0Ecal->OverlapCheck(overlapCheck); + B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecal); + } + else { //Use this option to have a circular packman-shape of the B0 ECal for plots. + auto *B0Ecal = new EICG4B0Subsystem(Form("b0Truth_%d", 2*b0DetNr), 2*b0DetNr); + B0Ecal->SuperDetector("b0Truth"); + B0Ecal->set_double_param("pipe_hole", pipe_hole); + B0Ecal->set_double_param("place_x", 0); + B0Ecal->set_double_param("place_y", 0); + B0Ecal->set_double_param("place_z", b0Ecal_z); + B0Ecal->set_double_param("pipe_x", pipe_x); + B0Ecal->set_double_param("pipe_y", 0); + B0Ecal->set_double_param("pipe_z", 0); + B0Ecal->set_double_param("length", b0Ecal_zLen); + B0Ecal->set_double_param("outer_radius", b0_radius); + B0Ecal->set_double_param("d_radius", d_radius); + B0Ecal->set_string_param("material", "G4_PbWO4"); + B0Ecal->set_double_param("startAngle",start_angle); + B0Ecal->set_double_param("spanningAngle",spanning_angle); + B0Ecal->set_double_param("detid",2*b0DetNr); + B0Ecal->SetActive(true); + if (verbosity) + B0Ecal->Verbosity(verbosity); + B0Ecal->OverlapCheck(overlapCheck); + B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecal); + } + + auto *B0Ecale = new EICG4B0Subsystem(Form("b0Truth_%d", 2*b0DetNr+1), 2*b0DetNr+1); //B0 ECal dead layer is the same subsystem as other four dead layers + B0Ecale->SuperDetector("b0Truth"); + // B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation + B0Ecale->set_double_param("pipe_hole", pipe_hole); + B0Ecale->set_double_param("place_x", 0); + B0Ecale->set_double_param("place_y", 0); + B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen)/2); + B0Ecale->set_double_param("pipe_x", pipe_x); + B0Ecale->set_double_param("pipe_y", 0); + B0Ecale->set_double_param("pipe_z", 0); + B0Ecale->set_double_param("length", b0Cu_zLen); + B0Ecale->set_double_param("d_radius", d_radius); + B0Ecale->set_double_param("outer_radius", b0_radius); + B0Ecale->set_string_param("material", "G4_Cu"); + B0Ecale->set_double_param("startAngle",start_angle); + B0Ecale->set_double_param("spanningAngle",spanning_angle); + B0Ecale->set_double_param("detid",2*b0DetNr+1); + B0Ecale->SetActive(true); if (verbosity) - detB0->Verbosity(verbosity); - detB0->OverlapCheck(overlapCheck); - detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - g4Reco->registerSubsystem(detB0); - } + B0Ecale->Verbosity(verbosity); + B0Ecale->OverlapCheck(overlapCheck); + B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(B0Ecale); + } + } + + } else { + + if (Enable::B0_FULLHITPLANE) { + + // Choice 2 circular hit planes + + const int b0DetNr = 4; + + // Sep 09 2021 by Bill: + // B0 magnet center location in z: 640 + // B0 place location in z after 50cm shift: 592, 616, 640, 664 + // B0 layers has the same x coordinate: -14.57 + + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + + for (int i = 0; i < b0DetNr; i++) + { + auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("radius", 0); + detB0->set_double_param("thickness", 20); + detB0->set_double_param("length", 0.1); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + + g4Reco->registerSubsystem(detB0); + + } + + } else { + + /// Fun4All default B0 planes + /// Choice 3 Hit planes with real detector geometry + + const int b0DetNr = 4; + const double b0Mag_zCent = 610; + const double b0Mag_zLen = 120; + const double b0Cu_zLen = .2; //B0 dead material length + const double b0Si_zLen = .1; //B0 Si length + const double b0Ecal_zLen = 20.; //B0 Ecal length + const double pipe_hole = 6.0; //detector cut off for beam pipe + const double pipe_x = -5.1; //pipe hole position + const double d_radius = 9.0; //detector cut off Packman + const double b0_radius = 24.5; //outer radius of B0-detector + const double spanning_angle = 240; //spanning angle Packman + const double b0Ecal_z = 48; + double start_angle = -120; //start angle Packman + + for (int i = 0; i < b0DetNr; i++) { + + auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", 2*i), 2*i); + detB0->SuperDetector("b0Truth"); + detB0->set_double_param("place_x", 0); + detB0->set_double_param("place_y", 0); + // detB0->set_int_param("ispipe", 0); //for future pipe implementation + detB0->set_double_param("pipe_hole", pipe_hole); + detB0->set_double_param("outer_radius", b0_radius); + detB0->set_double_param("d_radius", d_radius); + detB0->set_double_param("length", b0Si_zLen); + detB0->set_string_param("material", "G4_Si"); + detB0->set_double_param("detid",2*i); + detB0->set_double_param("startAngle",start_angle); + detB0->set_double_param("spanningAngle",spanning_angle); + detB0->set_double_param("pipe_x", pipe_x); + detB0->set_double_param("pipe_y", 0); + detB0->set_double_param("pipe_z", 0); + detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); // relative to B0 magnet + detB0->SetActive(true); + if (verbosity) + detB0->Verbosity(verbosity); + detB0->OverlapCheck(overlapCheck); + detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); + g4Reco->registerSubsystem(detB0); + } + + } } - } - - // const int b0DetNr = 4; - // const double b0Mag_zCent = 610; - // const double b0Mag_zLen = 120; - // for (int i = 0; i < b0DetNr; i++) - // { - // auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i); - // detB0->SuperDetector("b0Truth"); - // detB0->set_double_param("radius", 0); - // detB0->set_double_param("thickness", 20); - // detB0->set_double_param("length", 0.1); - // detB0->set_string_param("material", "G4_Si"); - // detB0->set_double_param("place_y", 0); - // detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2)); - // detB0->OverlapCheck(overlapCheck); - // detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet); - // detB0->SetActive(true); - // if (verbosity) - // detB0->Verbosity(verbosity); - // g4Reco->registerSubsystem(detB0); - // } } void hFarFwdDefineBeamPipe(PHG4Reco *g4Reco) @@ -1396,54 +1558,42 @@ void hFarFwdDefineBeamPipe(PHG4Reco *g4Reco) } } -float PosFlip(float pos) -{ - if (Enable::HFARFWD_MAGNETS_IP6) - { - return pos; - } - else - { - return pos; +float PosFlip(float pos) { + if(Enable::HFARFWD_MAGNETS_IP6) { + return pos; + } else { + return pos; } } -float AngleFlip(float angle) -{ - if (Enable::HFARFWD_MAGNETS_IP6) - { - return angle; - } - else - { - return angle; +float AngleFlip(float angle){ + if(Enable::HFARFWD_MAGNETS_IP6) { + return angle; + } else { + return angle; } } -float MagFieldFlip(float Bfield) -{ - if (Enable::HFARFWD_MAGNETS_IP6) - { - return Bfield; - } - else - { - return Bfield; +float MagFieldFlip(float Bfield){ + if(Enable::HFARFWD_MAGNETS_IP6) { + return Bfield; + } else { + return Bfield; } } + //------------------------------------------ void FFR_Eval(const std::string &outputfile) { + string ip_str; - if (Enable::IP6) - { + + if(Enable::IP6) { ip_str = "IP6"; - } - else - { + } else { ip_str = "IP8"; } @@ -1459,4 +1609,6 @@ void FFR_Eval(const std::string &outputfile) return; } + + #endif diff --git a/detectors/EICDetector/Fun4All_G4_EICDetector.C b/detectors/EICDetector/Fun4All_G4_EICDetector.C index 8bc46a91..fbf968d2 100644 --- a/detectors/EICDetector/Fun4All_G4_EICDetector.C +++ b/detectors/EICDetector/Fun4All_G4_EICDetector.C @@ -407,6 +407,13 @@ int Fun4All_G4_EICDetector( // Enable::B0_DISABLE_HITPLANE = true; // Enable::B0_FULLHITPLANE = true; + // Enable::B0ECALTOWERS = true; //To Construct Towers of B0ECal instead of one single volume + // Enable::B0ECAL = Enable::B0_DISABLE_HITPLANE && true; + // Enable::B0ECAL_CELL = Enable::B0ECAL && true; + // Enable::B0ECAL_TOWER = Enable::B0ECAL_CELL && true; + // Enable::B0ECAL_CLUSTER = Enable::B0ECAL_TOWER && true; + // Enable::B0ECAL_EVAL = Enable::B0ECAL_CLUSTER && true; + // RP // Enable::RP_DISABLE_HITPLANE = true; // Enable::RP_FULLHITPLANE = true; @@ -512,6 +519,9 @@ int Fun4All_G4_EICDetector( if (Enable::BECAL_TOWER) BECAL_Towers(); if (Enable::BECAL_CLUSTER) BECAL_Clusters(); + + if (Enable::B0ECAL_TOWER) B0ECAL_Towers(); // For B0Ecal + if (Enable::B0ECAL_CLUSTER) B0ECAL_Clusters(); //For B0Ecal if (Enable::DSTOUT_COMPRESS) ShowerCompress(); @@ -578,6 +588,8 @@ int Fun4All_G4_EICDetector( if (Enable::FFR_EVAL) FFR_Eval(outputroot + "_g4ffr_eval.root"); + if (Enable::B0ECAL_EVAL) B0ECAL_Eval(outputroot + "_g4b0ecal_eval_test.root"); // For B0Ecal + if (Enable::FWDJETS_EVAL) Jet_FwdEval(); if (Enable::USER) UserAnalysisInit(); diff --git a/detectors/EICDetector/G4Setup_EICDetector.C b/detectors/EICDetector/G4Setup_EICDetector.C index f0efab05..5bc89ba8 100644 --- a/detectors/EICDetector/G4Setup_EICDetector.C +++ b/detectors/EICDetector/G4Setup_EICDetector.C @@ -20,6 +20,7 @@ #include #include #include +#include //for B0 ECAL #include #include #include @@ -32,6 +33,7 @@ #include #include #include +//#include for B0 Tracking #include #include #include @@ -48,6 +50,8 @@ #include #include +#include +#include #include @@ -89,7 +93,7 @@ void G4Init() cout << "Can not enable CEMC and BECAL at the same time!" << endl; gSystem->Exit(1); } - if (Enable::BTOF and Enable::CTTL) + if (Enable::BTOF and Enable::CTTL) { cout << "Can not enable BTOF and CTTL at the same time!" << endl; gSystem->Exit(1); @@ -119,11 +123,11 @@ void G4Init() cout << "Can not enable *HCal and PLUGDOOR at the same time!" << endl; gSystem->Exit(1); } - // load detector/material macros and execute Init() function if (Enable::PIPE) PipeInit(); if (Enable::PLUGDOOR) PlugDoorInit(); if (Enable::TRACKING) TrackingInit(); +// if (Enable::B0TRACKING) B0TrackingInit(); //Farforward/backward if (Enable::HFARFWD_MAGNETS) hFarBwdBeamLineInit(); //Shouldnt this be far backward enables @@ -142,7 +146,7 @@ void G4Init() if (Enable::DIRC) DIRCInit(); if (Enable::BTOF) BToFInit(); if (Enable::BMMG) BMMGInit(); - + //Forward if (Enable::FGEM) FGEM_Init(); if (Enable::FEMC) FEMCInit(); @@ -151,7 +155,8 @@ void G4Init() if (Enable::LFHCAL) LFHCALInit(); if (Enable::RICH) RICHInit(); if (Enable::TRD) TRDInit(); - if(Enable::HTOF) HTOFInit(); + if (Enable::HTOF) HTOFInit(); + if (Enable::B0ECAL) B0ECALInit(); //Backward if (Enable::EGEM) EGEM_Init(); @@ -160,7 +165,6 @@ void G4Init() if (Enable::EHCAL) EHCALInit(); if (Enable::mRICH) mRICHInit(); if(Enable::ETOF) ETOFInit(); - //Combined if (Enable::FST) FST_Init(); @@ -199,7 +203,10 @@ int G4Setup() { // conversion to double fails -> we have a string if (G4MAGNET::magfield.find("sPHENIX.root") != string::npos) +// if (G4MAGNET::magfield.find("B0MagField_all_v2.root") != string::npos) // for B0 Tracking +// if (G4MAGNET::magfield.find("/cvmfs/eic.opensciencegrid.org/ecce/gcc-8.3/opt/fun4all/core/calibrations/Field/Map/sphenix3dbigmapxyz.root") != string::npos) { +// std::cout <<"G4 Setup: Using B0MagField_all_v1.root as 3D fieldMap"<set_field_map(G4MAGNET::magfield, PHFieldConfig::Field3DCartesian); } else @@ -255,7 +262,7 @@ int G4Setup() if (Enable::RICH) RICHSetup(g4Reco); if (Enable::TRD) TRDSetup(g4Reco); if (Enable::HTOF) HTOFSetup(g4Reco); - + //Backward if (Enable::ETTL) ETTLSetup(g4Reco); if (Enable::EGEM) EGEMSetup(g4Reco); @@ -297,7 +304,7 @@ void ShowerCompress() // // compress->AddHitContainer("G4HIT_ZDC"); // compress->AddHitContainer("G4HIT_RomanPots"); - // compress->AddHitContainer("G4HIT_B0detector"); + compress->AddHitContainer("G4HIT_b0Truth"); compress->AddHitContainer("G4HIT_FIELDCAGE"); compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS"); @@ -379,6 +386,13 @@ void ShowerCompress() compress->AddTowerContainer("TOWER_RAW_EHCAL"); compress->AddTowerContainer("TOWER_CALIB_EHCAL"); + compress->AddHitContainer("G4HIT_B0ECAL"); + compress->AddHitContainer("G4HIT_ABSORBER_B0ECAL"); + compress->AddCellContainer("G4CELL_B0ECAL"); + compress->AddTowerContainer("TOWER_SIM_B0ECAL"); + compress->AddTowerContainer("TOWER_RAW_B0ECAL"); + compress->AddTowerContainer("TOWER_CALIB_B0ECAL"); + se->registerSubsystem(compress); return; @@ -396,7 +410,7 @@ void DstCompress(Fun4AllDstOutputManager *out) // // out->StripNode("G4HIT_ZDC"); // out->StripNode("G4HIT_RomanPots"); - // out->StripNode("G4HIT_B0detectors"); + out->StripNode("G4HIT_b0Truth"); out->StripNode("G4HIT_SVTXSUPPORT"); out->StripNode("G4HIT_CEMC_ELECTRONICS"); out->StripNode("G4HIT_CEMC"); @@ -437,6 +451,7 @@ void DstCompress(Fun4AllDstOutputManager *out) out->StripNode("G4HIT_EHCAL"); out->StripNode("G4HIT_ABSORBER_EHCAL"); out->StripNode("G4CELL_EHCAL"); + out->StripNode("G4CELL_B0ECAL"); } } #endif From b7da87b60478afff964573a491188fba440f59f0 Mon Sep 17 00:00:00 2001 From: cdean-github <59485912+cdean-github@users.noreply.github.com> Date: Tue, 9 Nov 2021 20:34:05 -0500 Subject: [PATCH 13/15] Changed vertex and sagitta (#90) * Updated G4_EventEvaluator.C to work with new libraries * Updated G4_hFarFwd to point to new magnet file * Updated EventEval for new PR * FIxing overlaps * Reverting changes made by merge to production branch * Hash was changed to 'a', fixed * Added Tristan's clusteriser to macros * Missing / in setup * Pushed inner barrel tracker behind last vtx layer * Update G4_EventEvaluator.C * Update Fun4All_G4_EICDetector.C * TRD related macros (#42) * Macros for TRD * Macros for TRD * updating my forked rep * G4_TRD.C macro update , G4_BMMGT.C for barrel MMG added * G4_TRD.C for TRD and G4_BMMGT.C for barrel MMG tracker * Patches to G4_TRD and G4_BMMG * Updates to main macro * Barrel MMG macro and HCap TRD macro * Removed verbosity hard codes and moved TRD back 20cm due to overlap in support structure Co-authored-by: cdean-github * mRPC Barrel ToF (#76) * Macros for TRD * Macros for TRD * updating my forked rep * G4_TRD.C macro update , G4_BMMGT.C for barrel MMG added * G4_TRD.C for TRD and G4_BMMGT.C for barrel MMG tracker * Patches to G4_TRD and G4_BMMG * Updates to main macro * Adding Barrel mRPC ToF * Delete MMG and TRD macros * modified Fun4All and G4SetUp macros * modified Fun4All and G4SetUp macros to remove TRD and BMMG * Ran overlap checks Co-authored-by: cdean-github Co-authored-by: cdean-github <59485912+cdean-github@users.noreply.github.com> * End cap mRPC ToF (#78) * Macros for TRD * Macros for TRD * updating my forked rep * G4_TRD.C macro update , G4_BMMGT.C for barrel MMG added * G4_TRD.C for TRD and G4_BMMGT.C for barrel MMG tracker * Patches to G4_TRD and G4_BMMG * Updates to main macro * Adding Barrel mRPC ToF * Delete MMG and TRD macros * modified Fun4All and G4SetUp macros * modified Fun4All and G4SetUp macros to remove TRD and BMMG * Ran overlap checks * Adding end cap mRPC ToF macros * Ran integration checks Co-authored-by: cdean-github Co-authored-by: cdean-github <59485912+cdean-github@users.noreply.github.com> * Updated barrel layout * necessary changes for correct hit association and TTL geometry setup (#79) * Adding Roman Pots into the main macros (#77) * Flipped IP6 Far Forward detector stacks, include position, angle and field * flip crossing sign in HepMC event gen * flip crossing sign in beam chambers * before merging * Added the far backward region into Fun4all * Fixed a few issues suggested by Jin * Implemented the designed IP8 detector location * Extended the farbackward vaccum enclosure to include maximum path * fix overlap of world vol. * Updated IP6 detector location, and unflipped the x coord, angle, and field * Added the far forward evaluator * Adding FFR evaluator * void * Updated the IP8 configuration and main macro to include forward Eval * Fixed IP8 changes which were not merge into the master * Added the virtual detector in the farbackward region * Added the B0 detector models in the Fun4all There are three choices: 1. Real detector stack 2. Disk plane to help occupancy study 3. Hit planes replicating the real detector goemetry * Added the B0 detector * Fixed the issue for gradient field not scaling * Setting Forward/backward enclosure and magnets to active * Fixed B0 Orientiion for IP6 and IP8; IP8 1st RP with 5cm radius hole * Improved B0 geometry based on Sasha's suggestion * Reformatted G4_hFarFwdBeamLine_EIC.C style * Adding the RP implementation to the macro for IP6 and IP8 * merge * Corrected RP2nd option Co-authored-by: Jin Huang Co-authored-by: cdean-github Co-authored-by: cdean-github <59485912+cdean-github@users.noreply.github.com> * October 2021 concept (#81) * disabling non-default detectors * adding conf. check * disabling BTOF * disable overlap check * breakout RWELL into individual layers * turn off jet eval * Small changes to Oct layout * update DIRC * update BECAL * update BECAL * Added inner detector updates * Fixed some smaller issues * Separate hit nodes in SVTX and BARR as in #79 Co-authored-by: cdean-github * Updated FGEM and tracking support for move * Changed vertex and sagitta Co-authored-by: sourav-tarafdar Co-authored-by: nschmidtALICE Co-authored-by: billlee77 Co-authored-by: Jin Huang Co-authored-by: Jin Huang --- common/G4_Barrel_EIC.C | 6 +++--- common/G4_FST_EIC.C | 3 --- common/G4_GEM_EIC.C | 3 --- common/G4_TrackingSupport.C | 22 +++------------------- common/G4_mRwell_EIC.C | 6 +++--- 5 files changed, 9 insertions(+), 31 deletions(-) diff --git a/common/G4_Barrel_EIC.C b/common/G4_Barrel_EIC.C index 888c43a5..b7903143 100644 --- a/common/G4_Barrel_EIC.C +++ b/common/G4_Barrel_EIC.C @@ -69,7 +69,7 @@ void Barrel(PHG4Reco *g4Reco, int det_ver = 3) //--------------------------- // Vertexing - double si_vtx_r_pos[] = {3.3, 5.7, 8.5}; + double si_vtx_r_pos[] = {3.3, 4.35, 5.4}; const int nVtxLayers = sizeof(si_vtx_r_pos) / sizeof(*si_vtx_r_pos); for (int ilayer = 0; ilayer < nVtxLayers; ilayer++) { @@ -91,8 +91,8 @@ void Barrel(PHG4Reco *g4Reco, int det_ver = 3) //--------------------------- // Barrel - double z_e_length[] = {-27, -27.}; - double z_h_length[] = {27., 27.}; + double z_e_length[] = {-27, -29.0}; + double z_h_length[] = {27., 29.0}; double si_r_pos[] = {21, 22.68}; // Modified on 29th Oct to account for new struture design const int nTrckLayers = sizeof(si_r_pos) / sizeof(*si_r_pos); diff --git a/common/G4_FST_EIC.C b/common/G4_FST_EIC.C index 5471823d..079e1b53 100644 --- a/common/G4_FST_EIC.C +++ b/common/G4_FST_EIC.C @@ -69,9 +69,6 @@ void FSTSetup(PHG4Reco *g4Reco) -// const double bkwd_z[] = {33.2, 58.29, 80.05, 107.4}; -// double bkwd_rmin[] = {3.3, 3.3, 5.25, 6.4}; -// double bkwd_rmax[] = {15.3, 27.3, 35.25, 48.4}; const double bkwd_z[] = {25, 52, 79, 106}; double bkwd_rmin[] = {3.5, 3.5, 4.5, 5.5}; double bkwd_rmax[] = {18.5, 36.5, 40.5, 41.5}; diff --git a/common/G4_GEM_EIC.C b/common/G4_GEM_EIC.C index 015afddb..d1869113 100644 --- a/common/G4_GEM_EIC.C +++ b/common/G4_GEM_EIC.C @@ -49,14 +49,11 @@ void BGEM_Init() void EGEMSetup(PHG4Reco *g4Reco) { make_GEM_station("EGEM_0", g4Reco, -121.0, -1.668, -3.7); - //make_GEM_station("EGEM_0", g4Reco, -121.0, -1.68, -3.7); - // make_GEM_station("EGEM_1", g4Reco, -190.0, -1.85, -3.6); // replaced by LGAD-TTL } void FGEMSetup(PHG4Reco *g4Reco, const int N_Sector = 16) { make_GEM_station("FGEM_0", g4Reco, 287.0, 1.3, 3.6, N_Sector); - // make_GEM_station("FGEM_1", g4Reco, 285.0, 1.2, 3.5, N_Sector);// replaced by LGAD-TTL } //! Add drift layers to mini TPC diff --git a/common/G4_TrackingSupport.C b/common/G4_TrackingSupport.C index f666dfc9..95148afe 100644 --- a/common/G4_TrackingSupport.C +++ b/common/G4_TrackingSupport.C @@ -64,7 +64,6 @@ class ServiceProperties const double m_r_south = 0.0; const double m_r_north = 0.0; }; -//8, 0, 0.42, 0.27, shellX0, 0 ServiceProperties::ServiceProperties(const string &name, const double &rad_len_copper, const double &rad_len_aluminum, @@ -247,9 +246,6 @@ double TrackingService(PHG4Reco *g4Reco, double radius) cylinders.push_back(new ServiceProperties("ETrackingCylinderService_2", 17, 0, 0.56, 0.64, shellX0, 0, -300, -200, 68, 0)); cylinders.push_back(new ServiceProperties("ETrackingCylinderService_3", 15, 0, 0.56, 0.56, shellX0, 0, -200, -147.47, 68, 0)); - //cones.push_back(new ServiceProperties("ETrackingConeService_2", 13, 0, 0.56, 0.48, shellX0, 0, -152, -132.1, 68, 63.2)); - //cones.push_back(new ServiceProperties("ETrackingConeService_3", 13, 0, 0.56, 0.48, shellX0, 0, -132.1, -120., 63.2, disk_cone_radii)); - /* Support structure thickness*/ double CuThickness = 13.; // 0.18668 cms @@ -258,27 +254,23 @@ double TrackingService(PHG4Reco *g4Reco, double radius) double PlasticThickness = 0.48; // 0.241488 cms double CarbonThickness = shellX0; // 0.3 cms - // Cylinder from end Disk to EGEM - //cylinders.push_back(new ServiceProperties("ETrackingCyl_EGEMToDisk4", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -120.0, -1 * e_cone_ends, disk_cone_radii, 0)); - // Cone service from the end Disk to the uRwell1 radius cones.push_back(new ServiceProperties("ETrackingCone_Disk4TouRwell", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -147.47, -90, 68, 41.5)); - //cones.push_back(new ServiceProperties("ETrackingCone_Disk4TouRwell", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -1 * e_cone_ends, -1 * inner_uRwell_e_length - plateau_length, disk_cone_radii, inner_uRwell_radius)); // The cylindrical plateau structure for Electron uRwell side. cylinders.push_back(new ServiceProperties("ETrackingCyl_uRWellPlateau", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -90, -56.08, 41.5, 0)); // Cone service from electron side uRwell1 to vertex support. - cones.push_back(new ServiceProperties("ETrackingCone_uRwellToVertex", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -56.08, -12.16, 41.5, 9.0)); + cones.push_back(new ServiceProperties("ETrackingCone_uRwellToVertex", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, -56.08, -8.51, 41.5, 6.3)); // Sagitta Cylindrical Support Structure cylinders.push_back(new ServiceProperties("BTrackingCyl_Sagitta", 0, 0, 0, 0, 0.1, 0, -30.3, 30.3, 23.50, 0)); // Vertex Cylindrical Support Structure - cylinders.push_back(new ServiceProperties("BTrackingCyl_Vertex", 0, 0, 0, 0, shellX0, 0, -12.16, 12.16, 9.0, 0)); + cylinders.push_back(new ServiceProperties("BTrackingCyl_Vertex", 0, 0, 0, 0, shellX0, 0, -8.51, 8.51, 6.3, 0)); // Cone service in H-region from vertex to inner uRwell - cones.push_back(new ServiceProperties("HTrackingCone_VertexTouRwell", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 12.16, 56.08, 9.0, 41.5)); + cones.push_back(new ServiceProperties("HTrackingCone_VertexTouRwell", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 8.51, 56.08, 6.3, 41.5)); // Cylinder service to rest the uRwell in H region Plateau cylinders.push_back(new ServiceProperties("HTrackingRWellPlateau", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 56.08, 103.75, 41.5, 0)); @@ -286,15 +278,7 @@ double TrackingService(PHG4Reco *g4Reco, double radius) // Cone service from uRwell to Disk 5 in h-region cones.push_back(new ServiceProperties("HTrackingCone_uRwellToDisk5", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 103.75, 173, 41.5, 69.2)); - // Cylinder service from Disk 5 to 137 in h direction. This 137 cms is from 2nd campaign and keeping the outer tracker intact. - //cylinders.push_back(new ServiceProperties("HSidemRWellSupportCyl", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, h_cone_ends, 124., disk_cone_radii, 0)); - - // Cone service from 137. to FGEM - //cones.push_back(new ServiceProperties("HTrackingConeForFGEM", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 137., 157.9, disk_cone_radii, 69.2)); - //cones.push_back(new ServiceProperties("HTrackingConeForFGEM", CuThickness, AlThickness, WaterThickness, PlasticThickness, CarbonThickness, 0, 124., 173, disk_cone_radii, 69.2)); - // Supports beyond FGEM - //cylinders.push_back(new ServiceProperties("HTrackingCylinderService_1", 15, 0, 0.84, 0.56, shellX0, 0, 157.9, 173, 69.2, 0)); cones.push_back(new ServiceProperties("HTrackingConeService_7", 13, 0, 0.70, 0.48, shellX0, 0, 173, 173.1, 69.2, 85)); cones.push_back(new ServiceProperties("HTrackingConeService_8", 13, 0, 0.70, 0.48, shellX0, 0, 173.1, 195, 85, 100)); diff --git a/common/G4_mRwell_EIC.C b/common/G4_mRwell_EIC.C index 74e3496c..1ee08925 100644 --- a/common/G4_mRwell_EIC.C +++ b/common/G4_mRwell_EIC.C @@ -392,9 +392,9 @@ double RWellSetup(PHG4Reco* g4Reco, ilyr); //index } - // sourav: For spatial resolution the mRwell I will use about 55 microns - // (usually it is in between 40-60 microns depending on the angle of incidence of - // primary tracks when mRwell are used in microTPC mode i.e drift gap of 3-4 mm) . +// // sourav: For spatial resolution the mRwell I will use about 55 microns +// // (usually it is in between 40-60 microns depending on the angle of incidence of +// // primary tracks when mRwell are used in microTPC mode i.e drift gap of 3-4 mm) . if (TRACKING::FastKalmanFilter) { TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + string(Form("RWELL_%d", ilyr)), // const std::string& phg4hitsNames, From 6bb004232aff75c8bf9bd87f820272f8c7cc469e Mon Sep 17 00:00:00 2001 From: Jin Huang Date: Thu, 11 Nov 2021 10:13:34 -0500 Subject: [PATCH 14/15] Adding HCalIN projection (#92) * add HCalIN projection * HCALOUT -> HCALIN * HCALOUT -> HCALIN Co-authored-by: cdean-github --- common/G4_Tracking_EIC.C | 9 +++++++++ detectors/EICDetector/Fun4All_G4_EICDetector.C | 1 + 2 files changed, 10 insertions(+) diff --git a/common/G4_Tracking_EIC.C b/common/G4_Tracking_EIC.C index 2ffea433..5d8c7c07 100644 --- a/common/G4_Tracking_EIC.C +++ b/common/G4_Tracking_EIC.C @@ -30,6 +30,7 @@ namespace G4TRACKING bool PROJECTION_EHCAL = false; bool PROJECTION_CEMC = false; bool PROJECTION_BECAL = false; + bool PROJECTION_HCALIN = false; bool PROJECTION_HCALOUT = false; bool PROJECTION_FEMC = false; bool PROJECTION_FHCAL = false; @@ -131,6 +132,14 @@ void Tracking_Reco() TRACKING::ProjectionNames.insert("BECAL"); } //------------------------- + // HCALIN + //------------------------- + if (Enable::HCALIN && G4TRACKING::PROJECTION_HCALIN) + { + TRACKING::FastKalmanFilter->add_state_name("HCALIN"); + TRACKING::ProjectionNames.insert("HCALIN"); + } + //------------------------- // HCALOUT //------------------------- if (Enable::HCALOUT && G4TRACKING::PROJECTION_HCALOUT) diff --git a/detectors/EICDetector/Fun4All_G4_EICDetector.C b/detectors/EICDetector/Fun4All_G4_EICDetector.C index fbf968d2..e0ff30f5 100644 --- a/detectors/EICDetector/Fun4All_G4_EICDetector.C +++ b/detectors/EICDetector/Fun4All_G4_EICDetector.C @@ -304,6 +304,7 @@ int Fun4All_G4_EICDetector( G4TRACKING::PROJECTION_BECAL = true; G4TRACKING::PROJECTION_EHCAL = true; G4TRACKING::PROJECTION_CEMC = true; + G4TRACKING::PROJECTION_HCALIN = true; G4TRACKING::PROJECTION_HCALOUT = true; G4TRACKING::PROJECTION_FEMC = true; G4TRACKING::PROJECTION_FHCAL = true; From aa2d745ddf7b282c1f4ddb420c75d05ee9293aa4 Mon Sep 17 00:00:00 2001 From: Friederike Bock Date: Sun, 5 Dec 2021 20:35:22 -0500 Subject: [PATCH 15/15] updated settings of TTL, EEMC, LFHCAL to improve performance (#93) * updated settings of TTL, EEMC, LFHCAL to improve performance --- common/G4_EEMC_hybrid.C | 49 +- common/G4_EventEvaluator.C | 50 +- common/G4_LFHCAL.C | 28 +- common/G4_TTL_EIC.C | 135 ++- .../EICDetector/Fun4All_G4_EICDetector.C | 121 +-- detectors/EICDetector/G4Setup_EICDetector.C | 3 +- detectors/Modular/DisplayOn.C | 64 ++ detectors/Modular/Fun4All_G4_ECCEModular.C | 910 ++++++++++++++++++ detectors/Modular/Fun4All_runEvaluators.C | 214 ++++ detectors/Modular/G4Setup_ECCEModular.C | 448 +++++++++ detectors/Modular/init_gui_vis.mac | 20 + detectors/Modular/vis.mac | 85 ++ 12 files changed, 2004 insertions(+), 123 deletions(-) create mode 100644 detectors/Modular/DisplayOn.C create mode 100644 detectors/Modular/Fun4All_G4_ECCEModular.C create mode 100644 detectors/Modular/Fun4All_runEvaluators.C create mode 100644 detectors/Modular/G4Setup_ECCEModular.C create mode 100644 detectors/Modular/init_gui_vis.mac create mode 100644 detectors/Modular/vis.mac diff --git a/common/G4_EEMC_hybrid.C b/common/G4_EEMC_hybrid.C index ac41a057..f953ec1a 100644 --- a/common/G4_EEMC_hybrid.C +++ b/common/G4_EEMC_hybrid.C @@ -28,14 +28,14 @@ R__LOAD_LIBRARY(libg4eval.so) namespace Enable { - bool EEMCH = false; - bool EEMCH_ABSORBER = false; - bool EEMCH_CELL = false; - bool EEMCH_TOWER = false; - bool EEMCH_CLUSTER = false; - bool EEMCH_EVAL = false; + bool EEMCH = false; + bool EEMCH_ABSORBER = false; + bool EEMCH_CELL = false; + bool EEMCH_TOWER = false; + bool EEMCH_CLUSTER = false; + bool EEMCH_EVAL = false; bool EEMCH_OVERLAPCHECK = false; - int EEMCH_VERBOSITY = 0; + int EEMCH_VERBOSITY = 0; } // namespace Enable @@ -50,8 +50,12 @@ namespace G4EEMCH namespace SETTING { - bool USEHYBRID = false; - bool USECEMCGeo = false; + bool USEHYBRID = false; + bool USECEMCGeo = false; + bool USECUSTOMMAPNOCARBON = false; + bool USECUSTOMMAP30CM = false; + bool USECUSTOMMAPCARBON = false; + bool USECUSTOMMAPUPDATED = false; } // namespace SETTING // Digitization (default photon digi): @@ -78,9 +82,11 @@ namespace G4EEMCH void EEMCHInit() { - BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 77.); + BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 90.); // from towerMap_EEMC_v006.txt BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, G4EEMCH::Gz0 - G4EEMCH::Gdz / 2.); + BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, 30.); + } @@ -101,7 +107,15 @@ void EEMCHSetup(PHG4Reco *g4Reco) if (AbsorberActive) eemc_crystal->SetAbsorberActive(); - if (G4EEMCH::SETTING::USEHYBRID && !G4EEMCH::SETTING::USECEMCGeo) + if(G4EEMCH::SETTING::USECUSTOMMAPNOCARBON){ + mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185_noCarbon.txt"; + } else if (G4EEMCH::SETTING::USECUSTOMMAP30CM){ + mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185_30cm.txt"; + } else if (G4EEMCH::SETTING::USECUSTOMMAPCARBON){ + mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185cm_EEEMCcarbon.txt"; + } else if (G4EEMCH::SETTING::USECUSTOMMAPUPDATED){ + mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185cm_updatedGeo.txt"; + } else if (G4EEMCH::SETTING::USEHYBRID && !G4EEMCH::SETTING::USECEMCGeo) mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_crystal_200cm_SciGlassBarrel.txt"; else if (G4EEMCH::SETTING::USEHYBRID && G4EEMCH::SETTING::USECEMCGeo) mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_crystal_200cm_CEMCBarrel.txt"; @@ -119,7 +133,6 @@ void EEMCHSetup(PHG4Reco *g4Reco) cout << "setting EEMC crystal mapping: " << mapping_eemc_1.str() << endl; eemc_crystal->set_string_param("mappingtower", mapping_eemc_1.str()); eemc_crystal->OverlapCheck(OverlapCheck); -// eemc_crystal->OverlapCheck(true); g4Reco->registerSubsystem(eemc_crystal); @@ -143,7 +156,6 @@ void EEMCHSetup(PHG4Reco *g4Reco) eemc_glass->SetAbsorberActive(); eemc_glass->set_string_param("mappingtower", mapping_eemc_2.str()); - eemc_glass->OverlapCheck(OverlapCheck); g4Reco->registerSubsystem(eemc_glass); @@ -161,7 +173,16 @@ void EEMCH_Towers() Fun4AllServer *se = Fun4AllServer::instance(); ostringstream mapping_eemc_1, mapping_eemc_2; - if (G4EEMCH::SETTING::USEHYBRID && !G4EEMCH::SETTING::USECEMCGeo) + + if(G4EEMCH::SETTING::USECUSTOMMAPNOCARBON){ + mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185_noCarbon.txt"; + } else if (G4EEMCH::SETTING::USECUSTOMMAP30CM){ + mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185_30cm.txt"; + } else if (G4EEMCH::SETTING::USECUSTOMMAPCARBON){ + mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185cm_EEEMCcarbon.txt"; + } else if (G4EEMCH::SETTING::USECUSTOMMAPUPDATED){ + mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185cm_updatedGeo.txt"; + } else if (G4EEMCH::SETTING::USEHYBRID && !G4EEMCH::SETTING::USECEMCGeo) mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_crystal_200cm_SciGlassBarrel.txt"; else if (G4EEMCH::SETTING::USEHYBRID && G4EEMCH::SETTING::USECEMCGeo) mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_crystal_200cm_CEMCBarrel.txt"; diff --git a/common/G4_EventEvaluator.C b/common/G4_EventEvaluator.C index 267bc123..33b16774 100644 --- a/common/G4_EventEvaluator.C +++ b/common/G4_EventEvaluator.C @@ -10,9 +10,13 @@ R__LOAD_LIBRARY(libeiceval.so) namespace Enable { // use Enable::EVENT_EVAL = true; in your macro - bool EVENT_EVAL = false; - bool EVENT_EVAL_DO_HEPMC = false; - bool EVENT_EVAL_DO_EVT_LVL = false; + bool EVENT_EVAL = false; + bool EVENT_EVAL_DO_HEPMC = false; + bool EVENT_EVAL_DO_EVT_LVL = false; + bool EVENT_EVAL_DO_HITS = false; + bool EVENT_EVAL_DO_HITS_ABSORBER = false; + bool EVENT_EVAL_DO_HITS_CALO = false; + bool EVENT_EVAL_DO_HITS_BLACKHOLE = false; } // namespace Enable namespace EVENT_EVALUATOR @@ -32,28 +36,48 @@ void Event_Eval(const std::string &filename) if (Enable::TRACKING) { eval->set_do_TRACKS(true); - eval->set_do_HITS(true); + if (Enable::EVENT_EVAL_DO_HITS) { + std::cout << "Enabled hits in event eval.\n"; + eval->set_do_HITS(true); + if (Enable::EVENT_EVAL_DO_HITS_ABSORBER) { + std::cout << "Enabled absorber hits in event eval.\n"; + eval->set_do_HITS_ABSORBER(true); + } + if (Enable::EVENT_EVAL_DO_HITS_CALO) { + std::cout << "Enabled calorimeter hits in event eval.\n"; + eval->set_do_HITS_CALO(true); + } + if (Enable::BLACKHOLE_SAVEHITS && Enable::EVENT_EVAL_DO_HITS_BLACKHOLE) eval->set_do_BLACKHOLE(true); + } + eval->set_do_PROJECTIONS(true); if (G4TRACKING::DISPLACED_VERTEX) eval->set_do_VERTEX(true); if (Enable::DIRC_RECO or Enable::mRICH_RECO or Enable::RICH_RECO) eval->set_do_PID_LogLikelihood(true); } - if (Enable::CEMC_CLUSTER) eval->set_do_CEMC(true); - if (Enable::EEMC_CLUSTER || Enable::EEMCH_CLUSTER) eval->set_do_EEMC(true); - if (Enable::FEMC_CLUSTER) eval->set_do_FEMC(true); - if (Enable::HCALIN_CLUSTER) eval->set_do_HCALIN(true); - if (Enable::HCALOUT_CLUSTER) eval->set_do_HCALOUT(true); - if (Enable::FHCAL_CLUSTER) eval->set_do_FHCAL(true); + // set calorimeter Infos + if (Enable::CEMC) eval->set_do_CEMC(true); + if (Enable::EEMC || Enable::EEMCH) eval->set_do_EEMC(true); + if (Enable::EEMCH && G4EEMCH::SETTING::USEHYBRID) eval->set_do_EEMCG(true); + if (Enable::FEMC) eval->set_do_FEMC(true); + if (Enable::EHCAL) eval->set_do_EHCAL(true); + if (Enable::HCALIN) eval->set_do_HCALIN(true); + if (Enable::HCALOUT) eval->set_do_HCALOUT(true); + if (Enable::FHCAL) eval->set_do_FHCAL(true); if (Enable::FHCAL_CLUSTER || Enable::FEMC_CLUSTER || Enable::EEMC_CLUSTER) eval->set_do_CLUSTERS(true); - if (Enable::DRCALO_CLUSTER) eval->set_do_DRCALO(true); - if (Enable::LFHCAL_CLUSTER) eval->set_do_LFHCAL(true); + if (Enable::DRCALO) eval->set_do_DRCALO(true); + if (Enable::LFHCAL) eval->set_do_LFHCAL(true); if (Enable::BECAL) eval->set_do_BECAL(true); - if (Enable::EHCAL) eval->set_do_EHCAL(true); + // storing MC event info eval->set_do_MCPARTICLES(true); eval->set_do_HEPMC(Enable::EVENT_EVAL_DO_HEPMC); eval->set_do_store_event_level_info(Enable::EVENT_EVAL_DO_EVT_LVL); + + // storing geometry + eval->set_do_GEOMETRY(true); + se->registerSubsystem(eval); return; diff --git a/common/G4_LFHCAL.C b/common/G4_LFHCAL.C index cb2543b6..6daba460 100644 --- a/common/G4_LFHCAL.C +++ b/common/G4_LFHCAL.C @@ -43,7 +43,7 @@ namespace G4LFHCAL // from LFHcal/mapping/towerMap_LFHCAL_v005.txt double Gz0 = 400.; double Gdz = 100.; - double outer_radius = 262.; + double outer_radius = 265.; enum enu_FHcal_clusterizer { kFHcalGraphClusterizer, @@ -55,13 +55,14 @@ namespace G4LFHCAL //enu_FHcal_clusterizer FHcal_clusterizer = kFHcalGraphClusterizer; namespace SETTING { - bool FullEtaAcc = false; - bool HC2x = false; - bool asymmetric = true; - bool wDR = false; - bool FwdSquare = false; - bool FwdConfig = false; - bool longer = true; + bool FullEtaAcc = false; + bool HC2x = false; + bool asymmetric = true; + bool wDR = false; + bool FwdSquare = false; + bool FwdConfig = false; + bool longer = true; + bool tailcatcher = true; } // namespace SETTING } // namespace G4LFHCAL @@ -102,9 +103,12 @@ TString GetMappingFile(){ else if (G4LFHCAL::SETTING::asymmetric) { if (Enable::IP6){ - if (G4LFHCAL::SETTING::longer) - mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric-long.txt"; - else + if (G4LFHCAL::SETTING::longer){ + if (G4LFHCAL::SETTING::tailcatcher) + mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric-long-tailcatcher.txt"; + else + mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric-long.txt"; + } else mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric.txt"; } else { if (G4LFHCAL::SETTING::longer) @@ -162,7 +166,7 @@ void LFHCALSetup(PHG4Reco *g4Reco) fhcal->SetTowerMappingFile(mapping_fhcal_s.str()); fhcal->OverlapCheck(OverlapCheck); fhcal->SetActive(); - fhcal->SetDetailed(true); + //fhcal->SetDetailed(true); fhcal->SuperDetector("LFHCAL"); if (AbsorberActive) fhcal->SetAbsorberActive(); diff --git a/common/G4_TTL_EIC.C b/common/G4_TTL_EIC.C index cad08843..7891788c 100644 --- a/common/G4_TTL_EIC.C +++ b/common/G4_TTL_EIC.C @@ -16,7 +16,9 @@ int make_forward_station(string name, PHG4Reco *g4Reco, double zpos, double Rmin double Rmax,double tSilicon, double xoffset=0); int make_forward_station_basic(string name, PHG4Reco *g4Reco, double zpos, double Rmin, double Rmax,double tSilicon); -int make_barrel_layer_basic(string name, PHG4Reco *g4Reco, +int make_barrel_layer_basic(string name, PHG4Reco *g4Reco, + double radius, double halflength, double tSilicon, double zOffset); +int make_barrel_layer_LYSO_basic(string name, PHG4Reco *g4Reco, double radius, double halflength, double tSilicon, double zOffset); int make_barrel_layer(string name, PHG4Reco *g4Reco, double radius, double halflength, double tSilicon, double zOffset); @@ -35,16 +37,17 @@ namespace G4TTL double positionToVtx[3][3] = { {-169., -172., -309.5}, {80., 114.7, 0. }, { 287., 289., 340.} }; double minExtension[3][3] = { {8, 8, 15.3}, {218, 180, 0 }, {11.62, 11.7, 13.8 } }; double maxExtension[3][3] = { {61., 61. , 200}, {-40, 0, 0 }, {170., 170., 250 } }; - double xoffsetFTTLIP6[3] = { -6., -6., -6.}; + double xoffsetFTTLIP6[3] = { -6., -6., -6.}; double xoffsetFTTLIP8[3] = { 8.4, 8.4, 8.4}; namespace SETTING { - bool optionCEMC = false; - bool optionEEMCH = true; - bool optionBasicGeo = false; - int optionDR = 0; - int optionGeo = 7; - int optionGran = 1; + bool optionCEMC = false; + bool optionEEMCH = true; + bool optionBasicGeo = false; + bool optionLYSO = false; + int optionDR = 0; + int optionGeo = 7; + int optionGran = 1; } // namespace SETTING @@ -116,32 +119,51 @@ void TTL_Init() if(!G4TTL::SETTING::optionBasicGeo) G4TTL::layer[1] = 1; G4TTL::layer[2] = 3; } + if (G4TTL::SETTING::optionGeo == 5){ + // Option 5 is 1 layer fwd/bwd, with LYSO in the central barrel. We use the geometry for option 3 since it's the same. + // However, we create a separate option to simplify setting up the configuration. + cout << "TTL setup using LYSO in central barrel" << endl; + G4TTL::SETTING::optionLYSO = true; + } if(G4TTL::SETTING::optionGeo == 7){ cout << "TTL one forward disk in front of dRICH and one backward disk in front of EEMC, barrel CTTL center at radius 64cm" << endl; // single disk in front of dRICH (full eta) - G4TTL::layer[2] = 1; - G4TTL::minExtension[2][0] = 7.0; - G4TTL::maxExtension[2][0] = 87; - G4TTL::positionToVtx[2][0] = 182.; - G4TTL::xoffsetFTTLIP6[0] = -2.7; - G4TTL::xoffsetFTTLIP8[0] = 3.0; + G4TTL::layer[2] = 1; + G4TTL::minExtension[2][0] = 7.0; + G4TTL::maxExtension[2][0] = 87; + G4TTL::positionToVtx[2][0] = 182.; + G4TTL::xoffsetFTTLIP6[0] = -2.7; + G4TTL::xoffsetFTTLIP8[0] = 3.0; // single disk in front of EEMC - G4TTL::layer[0] = 1; - // G4TTL::minExtension[0][0] = 7.0; - // G4TTL::maxExtension[0][0] = 87; - // G4TTL::positionToVtx[0][0] = 182.; - // G4TTL::xoffsetFTTLIP6[0] = -2.7; - // G4TTL::xoffsetFTTLIP8[0] = 3.0; + G4TTL::layer[0] = 1; + G4TTL::maxExtension[0][0] = 64; // barrel layer at 64cm - G4TTL::positionToVtx[1][0] = 64.; - G4TTL::minExtension[1][0] = 140; - G4TTL::maxExtension[1][0] = 0; + G4TTL::positionToVtx[1][0] = 64.; + G4TTL::minExtension[1][0] = 140; + G4TTL::maxExtension[1][0] = 0; } if(G4TTL::SETTING::optionGeo == 8){ - cout << "TTL forward disk 1 reduced in radius to 60cm" << endl; - G4TTL::maxExtension[2][0] = 60.; + G4TTL::layer[2] = 3; + cout << "TTL forward disk 1 in front of dRICH" << endl; + G4TTL::minExtension[2][0] = 7.0; + G4TTL::maxExtension[2][0] = 87; + G4TTL::positionToVtx[2][0] = 182.; + cout << "additional two small TTL disks in front of FEMC" << endl; + G4TTL::minExtension[2][1] = 11.62; + G4TTL::minExtension[2][2] = 11.7; + G4TTL::maxExtension[2][1] = 60.; + G4TTL::maxExtension[2][2] = 60.; + G4TTL::positionToVtx[2][1] = 287.; + G4TTL::positionToVtx[2][2] = 289.; + + G4TTL::layer[0] = 1; + G4TTL::maxExtension[0][0] = 64; + + G4TTL::positionToVtx[1][0] = 64.; + G4TTL::minExtension[1][0] = 140; + G4TTL::maxExtension[1][0] = 0; } if (G4TTL::SETTING::optionDR == 2 && G4TTL::SETTING::optionGeo == 4 ){ @@ -198,7 +220,9 @@ void CTTLSetup(PHG4Reco *g4Reco, TString cttloption = "") for (Int_t i = 0; i < G4TTL::layer[1]; i++){ cout << "Radius: " << G4TTL::positionToVtx[1][i] << "\tLength: " << G4TTL::minExtension[1][i] << "\tz-Offset: " << G4TTL::maxExtension[1][i] << endl; - if(G4TTL::SETTING::optionBasicGeo){ + if(G4TTL::SETTING::optionBasicGeo && G4TTL::SETTING::optionLYSO){ + make_barrel_layer_LYSO_basic(Form("CTTL_%d",i), g4Reco, G4TTL::positionToVtx[1][i], G4TTL::minExtension[1][i], 85*um, G4TTL::maxExtension[1][i]); + } else if(G4TTL::SETTING::optionBasicGeo){ make_barrel_layer_basic(Form("CTTL_%d",i), g4Reco, G4TTL::positionToVtx[1][i], G4TTL::minExtension[1][i], 85*um, G4TTL::maxExtension[1][i]); } else { make_barrel_layer(Form("CTTL_%d",i), g4Reco, G4TTL::positionToVtx[1][i], G4TTL::minExtension[1][i], 85*um, G4TTL::maxExtension[1][i]); @@ -472,6 +496,65 @@ int make_barrel_layer_basic(string name, PHG4Reco *g4Reco, return 0; } +//-----------------------------------------------------------------------------------// +int make_barrel_layer_LYSO_basic(string name, PHG4Reco *g4Reco, + double radius, double halflength, double tSilicon, double zOffset){ + + //--------------------------------- + //build barrel layer + //--------------------------------- + const int nSubLayer = 4; + + string layerName[nSubLayer] = {"Cooling", "Crystal","SiliconSensor", "Motherboard"}; + string material[nSubLayer] = {"G4_Al", "LSO", "G4_Si", "FR4"}; + double thickness[nSubLayer] = {0.031 * cm, 0.029 * cm, tSilicon, 0.033 * cm}; + + double max_bh_radius = 0.; + PHG4CylinderSubsystem* cyl; +// cout << "started to create cylinder layer: " << name << endl; + + double currRadius = radius; +// cout << currRadius << endl; + for (int l = 0; l < nSubLayer; l++) { +// cout << name <<"_"<< layerName[l] << endl; + cyl = new PHG4CylinderSubsystem(name + "_" + layerName[l],l); + cyl->SuperDetector(name); + cyl->set_double_param("radius", currRadius); + cyl->set_double_param("length", 2.0 * halflength); + cyl->set_string_param("material", material[l]); + cyl->set_double_param("thickness", thickness[l]); + cyl->set_double_param("place_x", 0.); + cyl->set_double_param("place_y", 0.); + cyl->set_double_param("place_z", zOffset); + + if (l == 2) cyl->SetActive(); //only the Silicon Sensor is active + cyl->OverlapCheck(Enable::OVERLAPCHECK); + g4Reco->registerSubsystem(cyl); + currRadius = currRadius+thickness[l]; +// cout << currRadius << endl; + } + + if (TRACKING::FastKalmanFilter) + { + float resLGAD_barrel = G4TTL::PositionResolution; + if(G4TTL::SETTING::optionLYSO){ + resLGAD_barrel = 35e-1; // https://cds.cern.ch/record/2667167/files/CMS-TDR-020.pdf page 33 bottom + } + TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + name, // const std::string& phg4hitsNames, + PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype, + 999, // const float radres, + resLGAD_barrel, // const float phires, + resLGAD_barrel, // const float lonres, + 1, // const float eff, NOTE: Different from 0.95 in Modular + 0); // const float noise + TRACKING::FastKalmanFilter->add_cylinder_state(name, radius); + + TRACKING::ProjectionNames.insert(name); + } + + return 0; +} + #endif //-----------------------------------------------------------------------------------// diff --git a/detectors/EICDetector/Fun4All_G4_EICDetector.C b/detectors/EICDetector/Fun4All_G4_EICDetector.C index e0ff30f5..49eb3b1c 100644 --- a/detectors/EICDetector/Fun4All_G4_EICDetector.C +++ b/detectors/EICDetector/Fun4All_G4_EICDetector.C @@ -273,8 +273,8 @@ int Fun4All_G4_EICDetector( Enable::HFARBWD_VIRTUAL_DETECTORS = true; // gems - Enable::EGEM = true; - Enable::FGEM = true; // deactivated as it's replaced by a FTTL layer + Enable::EGEM = false; + Enable::FGEM = false; // deactivated as it's replaced by a FTTL layer // Enable::BGEM = true; // not yet defined in this model Enable::RWELL = true; // barrel tracker @@ -310,27 +310,11 @@ int Fun4All_G4_EICDetector( G4TRACKING::PROJECTION_FHCAL = true; G4TRACKING::PROJECTION_LFHCAL = true; - Enable::BECAL = true; - Enable::BECAL_CELL = Enable::BECAL && true; - Enable::BECAL_TOWER = Enable::BECAL_CELL && true; - Enable::BECAL_CLUSTER = Enable::BECAL_TOWER && true; - Enable::BECAL_EVAL = Enable::BECAL_CLUSTER && true; - - Enable::HCALIN = true; - // Enable::HCALIN_ABSORBER = true; - Enable::HCALIN_CELL = Enable::HCALIN && true; - Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true; - Enable::HCALIN_CLUSTER = Enable::HCALIN_TOWER && true; - Enable::HCALIN_EVAL = Enable::HCALIN_CLUSTER && true; - - Enable::MAGNET = true; - + // enable barrel calos & magnet + Enable::BECAL = true; + Enable::HCALIN = true; + Enable::MAGNET = true; Enable::HCALOUT = true; - // Enable::HCALOUT_ABSORBER = true; - Enable::HCALOUT_CELL = Enable::HCALOUT && true; - Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true; - Enable::HCALOUT_CLUSTER = Enable::HCALOUT_TOWER && true; - Enable::HCALOUT_EVAL = Enable::HCALOUT_CLUSTER && true; // EICDetector geometry - barrel Enable::DIRC = true; @@ -347,41 +331,22 @@ int Fun4All_G4_EICDetector( Enable::TRD_GAS = false; // Enable::RICH_VERBOSITY = 2; + + // enable forward calos + Enable::FEMC = true; + Enable::DRCALO = false; + Enable::LFHCAL = true; + // EICDetector geometry - 'electron' direction Enable::mRICH = true; Enable::mRICH_RECO = Enable::mRICH && true; // Enable::mRICH_VERBOSITY = 2; - - Enable::FEMC = true; - // Enable::FEMC_ABSORBER = true; - Enable::FEMC_TOWER = Enable::FEMC && true; - Enable::FEMC_CLUSTER = Enable::FEMC_TOWER && true; - Enable::FEMC_EVAL = Enable::FEMC_CLUSTER && true; - - //Enable::DRCALO = false; - Enable::DRCALO_CELL = Enable::DRCALO && true; - Enable::DRCALO_TOWER = Enable::DRCALO_CELL && true; - Enable::DRCALO_CLUSTER = Enable::DRCALO_TOWER && true; - Enable::DRCALO_EVAL = Enable::DRCALO_CLUSTER && false; - - Enable::LFHCAL = true; - Enable::LFHCAL_ABSORBER = false; - Enable::LFHCAL_CELL = Enable::LFHCAL && true; - Enable::LFHCAL_TOWER = Enable::LFHCAL_CELL && true; - Enable::LFHCAL_CLUSTER = Enable::LFHCAL_TOWER && true; - Enable::LFHCAL_EVAL = Enable::LFHCAL_CLUSTER && true; - + // EICDetector geometry - 'electron' direction - Enable::EEMCH = true; - Enable::EEMCH_TOWER = Enable::EEMCH && true; - Enable::EEMCH_CLUSTER = Enable::EEMCH_TOWER && true; - Enable::EEMCH_EVAL = Enable::EEMCH_CLUSTER && true; - - Enable::EHCAL = true; - Enable::EHCAL_CELL = Enable::EHCAL && true; - Enable::EHCAL_TOWER = Enable::EHCAL_CELL && true; - Enable::EHCAL_CLUSTER = Enable::EHCAL_TOWER && true; - Enable::EHCAL_EVAL = Enable::EHCAL_CLUSTER && true; + Enable::EEMCH = true; + G4EEMCH::SETTING::USECUSTOMMAPUPDATED = true; // enable proper carbon structure + G4TTL::SETTING::optionEEMCH = Enable::EEMCH && true; + Enable::EHCAL = false; Enable::FFR_EVAL = Enable::HFARFWD_MAGNETS && Enable::HFARFWD_VIRTUAL_DETECTORS && true; @@ -422,12 +387,56 @@ int Fun4All_G4_EICDetector( // RP after 2nd focus for IP8 only // Enable::RP2nd_DISABLE_HITPLANE = true; // Enable::RP2nd_FULLHITPLANE = true; + + //************************************************************ + // details for calos: cells, towers, clusters + //************************************************************ + Enable::BECAL_CELL = Enable::BECAL && true; + Enable::BECAL_TOWER = Enable::BECAL_CELL && true; + Enable::BECAL_CLUSTER = Enable::BECAL_TOWER && true; + Enable::BECAL_EVAL = Enable::BECAL_CLUSTER && true; + + // Enable::HCALIN_ABSORBER = true; + Enable::HCALIN_CELL = Enable::HCALIN && true; + Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true; + Enable::HCALIN_CLUSTER = Enable::HCALIN_TOWER && true; + Enable::HCALIN_EVAL = Enable::HCALIN_CLUSTER && true; + + // Enable::HCALOUT_ABSORBER = true; + Enable::HCALOUT_CELL = Enable::HCALOUT && true; + Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true; + Enable::HCALOUT_CLUSTER = Enable::HCALOUT_TOWER && true; + Enable::HCALOUT_EVAL = Enable::HCALOUT_CLUSTER && true; + + // Enable::FEMC_ABSORBER = true; + Enable::FEMC_TOWER = Enable::FEMC && true; + Enable::FEMC_CLUSTER = Enable::FEMC_TOWER && true; + Enable::FEMC_EVAL = Enable::FEMC_CLUSTER && true; + + Enable::DRCALO_CELL = Enable::DRCALO && true; + Enable::DRCALO_TOWER = Enable::DRCALO_CELL && true; + Enable::DRCALO_CLUSTER = Enable::DRCALO_TOWER && true; + Enable::DRCALO_EVAL = Enable::DRCALO_CLUSTER && false; + Enable::LFHCAL_ABSORBER = false; + Enable::LFHCAL_CELL = Enable::LFHCAL && true; + Enable::LFHCAL_TOWER = Enable::LFHCAL_CELL && true; + Enable::LFHCAL_CLUSTER = Enable::LFHCAL_TOWER && true; + Enable::LFHCAL_EVAL = Enable::LFHCAL_CLUSTER && true; + + Enable::EEMCH_TOWER = Enable::EEMCH && true; + Enable::EEMCH_CLUSTER = Enable::EEMCH_TOWER && true; + Enable::EEMCH_EVAL = Enable::EEMCH_CLUSTER && true; + + Enable::EHCAL_CELL = Enable::EHCAL && true; + Enable::EHCAL_TOWER = Enable::EHCAL_CELL && true; + Enable::EHCAL_CLUSTER = Enable::EHCAL_TOWER && true; + Enable::EHCAL_EVAL = Enable::EHCAL_CLUSTER && true; + // Enabling the event evaluator? - Enable::EVENT_EVAL = true; - // EVENT_EVALUATOR::Verbosity = 1; - // EVENT_EVALUATOR::EnergyThreshold = 0.05; // GeV - Enable::EVENT_EVAL_DO_HEPMC = Input::PYTHIA6 or Input::PYTHIA8 or Input::SARTRE or Input::HEPMC or Input::READEIC; + Enable::EVENT_EVAL = true; + Enable::EVENT_EVAL_DO_HITS = true; + Enable::EVENT_EVAL_DO_HEPMC = Input::PYTHIA6 or Input::PYTHIA8 or Input::SARTRE or Input::HEPMC or Input::READEIC; Enable::EVENT_EVAL_DO_EVT_LVL = Input::PYTHIA6 or Input::PYTHIA8 or Input::READEIC; //Enable::USER = true; diff --git a/detectors/EICDetector/G4Setup_EICDetector.C b/detectors/EICDetector/G4Setup_EICDetector.C index 5bc89ba8..920a9271 100644 --- a/detectors/EICDetector/G4Setup_EICDetector.C +++ b/detectors/EICDetector/G4Setup_EICDetector.C @@ -43,7 +43,6 @@ // these two has to be ordered this way for now. #include - #include #include @@ -164,7 +163,7 @@ void G4Init() if (Enable::EEMCH) EEMCHInit(); if (Enable::EHCAL) EHCALInit(); if (Enable::mRICH) mRICHInit(); - if(Enable::ETOF) ETOFInit(); + if (Enable::ETOF) ETOFInit(); //Combined if (Enable::FST) FST_Init(); diff --git a/detectors/Modular/DisplayOn.C b/detectors/Modular/DisplayOn.C new file mode 100644 index 00000000..02862080 --- /dev/null +++ b/detectors/Modular/DisplayOn.C @@ -0,0 +1,64 @@ +#ifndef MACRO_DISPLAYON_C +#define MACRO_DISPLAYON_C + +#include + +#include + +R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libg4testbench.so) + +namespace Enable +{ + bool DISPLAY = false; +} + +// This starts the QT based G4 gui which takes control +// when x'ed out it will return a pointer to PHG4Reco so +// the gui can be startrd again +PHG4Reco *QTGui() +{ + Fun4AllServer *se = Fun4AllServer::instance(); + PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO"); + g4->InitRun(se->topNode()); + g4->ApplyDisplayAction(); + g4->StartGui(); + return g4; +} + +// stupid macro to turn on the geant4 display +// we ask Fun4All for a pointer to PHG4Reco +// using the ApplyCommand will start up the +// G4 cmd interpreter and graphics system +// the vis.mac contains the necessary commands to +// start up the visualization, the next event will +// be displayed. Do not execute this macro +// before PHG4Reco was registered with Fun4All +PHG4Reco * DisplayOn(const char *mac = "vis.mac") +{ + char cmd[100]; + Fun4AllServer *se = Fun4AllServer::instance(); + PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO"); + g4->InitRun(se->topNode()); + g4->ApplyDisplayAction(); + sprintf(cmd, "/control/execute %s", mac); + g4->ApplyCommand(cmd); + return g4; +} +// print out the commands I always forget +void displaycmd() +{ + cout << "draw axis: " << endl; + cout << " g4->ApplyCommand(\"/vis/scene/add/axes 0 0 0 50 cm\")" << endl; + cout << "zoom" << endl; + cout << " g4->ApplyCommand(\"/vis/viewer/zoom 1\")" << endl; + cout << "viewpoint:" << endl; + cout << " g4->ApplyCommand(\"/vis/viewer/set/viewpointThetaPhi 0 0\")" << endl; + cout << "panTo:" << endl; + cout << " g4->ApplyCommand(\"/vis/viewer/panTo 0 0 cm\")" << endl; + cout << "print to eps:" << endl; + cout << " g4->ApplyCommand(\"/vis/ogl/printEPS\")" << endl; + cout << "set background color:" << endl; + cout << " g4->ApplyCommand(\"/vis/viewer/set/background white\")" << endl; +} +#endif diff --git a/detectors/Modular/Fun4All_G4_ECCEModular.C b/detectors/Modular/Fun4All_G4_ECCEModular.C new file mode 100644 index 00000000..9b3e96e7 --- /dev/null +++ b/detectors/Modular/Fun4All_G4_ECCEModular.C @@ -0,0 +1,910 @@ +#ifndef MACRO_FUN4ALLG4EICDETECTOR_C +#define MACRO_FUN4ALLG4EICDETECTOR_C + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +R__LOAD_LIBRARY(libfun4all.so) + +int Fun4All_G4_ECCEModular( + const int nEvents = 1, + const double particlemomMin = -1, + const double particlemomMax = -1, + const string detectorSettings = "TTLGEO_5", + const TString generatorSettings = "PYTHIA8", + const string &inputFile = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root", + const string &outputFile = "G4EICDetector.root", + const string &embed_input_file = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root", + const int skip = 0, + const string &outdir = ".") +{ + //--------------- + // Fun4All server + //--------------- + Fun4AllServer *se = Fun4AllServer::instance(); + se->Verbosity(0); + //Opt to print all random seed used for debugging reproducibility. Comment out to reduce stdout prints. + //PHRandomSeed::Verbosity(1); + + // just if we set some flags somewhere in this macro + recoConsts *rc = recoConsts::instance(); + // By default every random number generator uses + // PHRandomSeed() which reads /dev/urandom to get its seed + // if the RANDOMSEED flag is set its value is taken as initial seed + // which will produce identical results so you can debug your code + // rc->set_IntFlag("RANDOMSEED", 12345); + + bool generate_seed = false; + + if (generate_seed) + { + size_t findSlash = inputFile.find_last_of("/"); + string inputFileName = inputFile.substr(findSlash + 1, inputFile.size()); + + RooRealVar dummyVal("dummy", "", 0); + RooUnblindPrecision blindVal("blindVal", "blindVal", inputFileName.c_str(), nEvents, skip + 1, dummyVal, kFALSE); + rc->set_IntFlag("RANDOMSEED", abs(ceil(blindVal.getVal() * 1e2))); + } + + //=============== + // Input options + //=============== + + // switching IPs by comment/uncommenting the following lines + // used for both beamline setting and for the event generator crossing boost + Enable::IP6 = true; + // Enable::IP8 = true; + + // Setting proton beam pipe energy. If you don't know what to set here, leave it at 275 + Enable::HFARFWD_ION_ENERGY = 275; + + // Either: + // read previously generated g4-hits files, in this case it opens a DST and skips + // the simulations step completely. The G4Setup macro is only loaded to get information + // about the number of layers used for the cell reco code + // + //Input::READHITS = true; + INPUTREADHITS::filename[0] = inputFile; + // if you use a filelist + // INPUTREADHITS::listfile[0] = inputFile; + + // Or: + // Use one or more particle generators + // It is run if Input:: is set to true + // all other options only play a role if it is active + // In case embedding into a production output, please double check your G4Setup_EICDetector.C and G4_*.C consistent with those in the production macro folder + // Input::EMBED = true; + INPUTEMBED::filename[0] = embed_input_file; + // if you use a filelist + //INPUTEMBED::listfile[0] = embed_input_file; + + if(particlemomMin==-1 && particlemomMax==-1){ + if (generatorSettings.Contains("PYTHIA6")) { + Input::PYTHIA6 = true; + } else if (generatorSettings.Contains("PYTHIA8")) { + Input::PYTHIA8 = true; + } else if (generatorSettings.Contains("SATRE")) { + Input::SARTRE = true; + } else if (generatorSettings.Contains("READEIC")) { + Input::READEIC = true; + } else if (generatorSettings.Contains("HEPMCINPUT")) { + Input::HEPMC = true; + INPUTHEPMC::filename = inputFile; + } + } + // Simple multi particle generator in eta/phi/pt ranges + Input::SIMPLE = false; + if (particlemomMin>-1 && particlemomMax>-1){ + Input::SIMPLE = true; + Input::SIMPLE_VERBOSITY = 0; + if (generatorSettings.Contains("Multi")) + Input::SIMPLE_NUMBER = 3; // if you need 2 of them + } + + Input::VERBOSITY = 0; + + //----------------- + // Initialize the selected Input/Event generation + //----------------- + InputInit(); + //-------------- + // Set generator specific options + //-------------- + // can only be set after InputInit() is called + + // Simple Input generator: + // if you run more than one of these Input::SIMPLE_NUMBER > 1 + // add the settings for other with [1], next with [2]... + if (Input::SIMPLE){ + if (generatorSettings.Contains("Multi")){ + for(int igen=0;igenadd_particles("pi-", 1); + else if(igen==1)INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("e-", 1); + else if(igen==2)INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("proton", 1); + }else if (generatorSettings.Contains("Pion")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("pi-", 1); + else if (generatorSettings.Contains("Kaon")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("kaon-", 1); + else if (generatorSettings.Contains("Proton")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("proton", 1); + else if (generatorSettings.Contains("Muon")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("mu-", 1); + else if (generatorSettings.Contains("Photon")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("gamma", 1); + else if (generatorSettings.Contains("Neutron")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("neutron", 1); + else if (generatorSettings.Contains("Lambda")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("lambda", 1); + else if (generatorSettings.Contains("K0S")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("kaon0S", 1); + else if (generatorSettings.Contains("Electron")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("e-", 1); + else if (generatorSettings.Contains("PiZero")) + INPUTGENERATOR::SimpleEventGenerator[igen]->add_particles("pi0", 1); + else { + std::cout << "You didn't specify which particle you wanted to generate, exiting" << std::endl; + return 0; + } + INPUTGENERATOR::SimpleEventGenerator[igen]->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform, + PHG4SimpleEventGenerator::Uniform, + PHG4SimpleEventGenerator::Uniform); + INPUTGENERATOR::SimpleEventGenerator[igen]->set_vertex_distribution_mean(0., 0., 0.); + INPUTGENERATOR::SimpleEventGenerator[igen]->set_vertex_distribution_width(0., 0., 0.); + + bool strictrange = false; + if(generatorSettings.Contains("strict")) strictrange = true; + if (igen==0){ + if(strictrange) + INPUTGENERATOR::SimpleEventGenerator[igen]->set_eta_range(-0.7, 0.7); + else + INPUTGENERATOR::SimpleEventGenerator[igen]->set_eta_range(-1.7, 1.2); + } else if (igen==1) { + if(strictrange) + INPUTGENERATOR::SimpleEventGenerator[igen]->set_eta_range(-3.0, -2.5); + else + INPUTGENERATOR::SimpleEventGenerator[igen]->set_eta_range(-4, -1.7); + } else if (igen==2) { + if(strictrange) + INPUTGENERATOR::SimpleEventGenerator[igen]->set_eta_range(2.5, 3.0); + else + INPUTGENERATOR::SimpleEventGenerator[igen]->set_eta_range(1.2, 4.0); + } else { + INPUTGENERATOR::SimpleEventGenerator[igen]->set_eta_range(-4.0, 4.0); + } + INPUTGENERATOR::SimpleEventGenerator[igen]->set_phi_range(-M_PI, M_PI); + INPUTGENERATOR::SimpleEventGenerator[igen]->set_p_range(particlemomMin, particlemomMax); + } + } else { + if (generatorSettings.Contains("SimplePion")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("pi-", 1); + else if (generatorSettings.Contains("SimpleKaon")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("kaon-", 1); + else if (generatorSettings.Contains("SimpleProton")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("proton", 1); + else if (generatorSettings.Contains("SimplePhoton")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("gamma", 1); + else if (generatorSettings.Contains("SimpleNeutron")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("neutron", 1); + else if (generatorSettings.Contains("SimpleMuon")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("mu-", 1); + else if (generatorSettings.Contains("SimpleLambda")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("lambda", 1); + else if (generatorSettings.Contains("SimpleK0S")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("kaon0S", 1); + else if (generatorSettings.Contains("SimpleElectron")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("e-", 1); + else if (generatorSettings.Contains("SimplePiZero")) + INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("pi0", 1); + else { + std::cout << "You didn't specify which particle you wanted to generate, exiting" << std::endl; + return 0; + } + INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform, + PHG4SimpleEventGenerator::Uniform, + PHG4SimpleEventGenerator::Uniform); + INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_mean(0., 0., 0.); + INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_width(0., 0., 0.); + if (generatorSettings.Contains("central")) + INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-1.8, 1.2); + else if (generatorSettings.Contains("bck")) + INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-4, -1.7); + else if (generatorSettings.Contains("fwd")) + INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(1.2, 4.0); + else + INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-4.0, 4.0); + INPUTGENERATOR::SimpleEventGenerator[0]->set_phi_range(-M_PI, M_PI); + INPUTGENERATOR::SimpleEventGenerator[0]->set_p_range(particlemomMin, particlemomMax); + } + } + if(particlemomMin>-1 && particlemomMax == -1){ + PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR"); + gen->set_name("pi-"); + // gen->set_name("pi0"); + gen->set_vtx(0, 0, 0); + gen->set_eta_range(-4.0, 4.0); // around midrapidity + if(particlemomMin > -1) { + gen->set_mom_range(particlemomMin, particlemomMin); // fixed 4 GeV/c + } + else { + gen->set_mom_range(1, 60); // fixed 4 GeV/c + } + gen->set_phi_range(0., 2* M_PI); // 0-90 deg + // gen->Verbosity(1); // 0-90 deg + se->registerSubsystem(gen); + } + // pythia6 + if (Input::PYTHIA6) + { + //INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_ep.cfg"); + INPUTGENERATOR::Pythia6->set_config_file(inputFile); + //! apply EIC beam parameter following EIC CDR + Input::ApplyEICBeamParameter(INPUTGENERATOR::Pythia6); + } + // pythia8 + if (Input::PYTHIA8) + { + // Configuration file + PYTHIA8::config_file = inputFile; + //! apply EIC beam parameter following EIC CDR + Input::ApplyEICBeamParameter(INPUTGENERATOR::Pythia8); + } + // Sartre + if (Input::SARTRE) + { + //! apply EIC beam parameter following EIC CDR + Input::ApplyEICBeamParameter(INPUTGENERATOR::Sartre); + } + + //-------------- + // Set Input Manager specific options + //-------------- + // can only be set after InputInit() is called + + if (Input::HEPMC) + { + //! apply EIC beam parameter following EIC CDR + Input::ApplyEICBeamParameter(INPUTMANAGER::HepMCInputManager); + // optional overriding beam parameters + //INPUTMANAGER::HepMCInputManager->set_vertex_distribution_width(100e-4, 100e-4, 30, 0); //optional collision smear in space, time + // INPUTMANAGER::HepMCInputManager->set_vertex_distribution_mean(0,0,0,0);//optional collision central position shift in space, time + // //optional choice of vertex distribution function in space, time + // INPUTMANAGER::HepMCInputManager->set_vertex_distribution_function(PHHepMCGenHelper::Gaus, PHHepMCGenHelper::Gaus, PHHepMCGenHelper::Gaus, PHHepMCGenHelper::Gaus); + //! embedding ID for the event + //! positive ID is the embedded event of interest, e.g. jetty event from pythia + //! negative IDs are backgrounds, .e.g out of time pile up collisions + //! Usually, ID = 0 means the primary Au+Au collision background + //INPUTMANAGER::HepMCInputManager->set_embedding_id(2); + } + + // register all input generators with Fun4All + InputRegister(); + + // Reads event generators in EIC smear files, which is registered in InputRegister + if (Input::READEIC) + { + INPUTREADEIC::filename = inputFile; + //! apply EIC beam parameter following EIC CDR + INPUTGENERATOR::EICFileReader->SetFirstEntry(skip); + Input::ApplyEICBeamParameter(INPUTGENERATOR::EICFileReader); + } + + // set up production relatedstuff + // Enable::PRODUCTION = true; + + //====================== + // Write the DST + //====================== + + Enable::DSTOUT = false; + DstOut::OutputDir = outdir; + DstOut::OutputFile = outputFile; + Enable::DSTOUT_COMPRESS = false; // Compress DST files + + //Option to convert DST to human command readable TTree for quick poke around the outputs + // Enable::DSTREADER = true; + + // turn the display on (default off) + if (detectorSettings.find("display") != std::string::npos) { + Enable::DISPLAY = true; + } + //====================== + // What to run + //====================== + // Global options (enabled for all subsystems - if implemented) + // Enable::ABSORBER = true; + // Enable::OVERLAPCHECK = true; + // Enable::VERBOSITY = 1; + + // whether to simulate the Be section of the beam pipe + Enable::PIPE = true; + // If need to disable EIC beam pipe extension beyond the Be-section: + G4PIPE::use_forward_pipes = true; + //EIC hadron far forward magnets and detectors. IP6 and IP8 are incompatible (pick either or); + // Enable::HFARFWD_MAGNETS = true; + // Enable::HFARFWD_VIRTUAL_DETECTORS = true; + + // Enable::HFARBWD_MAGNETS = true; + // Enable::HFARBWD_VIRTUAL_DETECTORS = true; + + //*********************************************** + // barrel trackers + //*********************************************** + Enable::RWELL = true; + // barrel tracker + Enable::TrackingService = true; + // Enable::TrackingService_VERBOSITY = INT_MAX - 10; + Enable::BARREL = true; + // fst + Enable::FST = true; + + //*********************************************** + // TOFs + //*********************************************** + Enable::FTTL = true; + Enable::ETTL = true; + Enable::CTTL = true; + G4TTL::SETTING::optionCEMC = false; + std::string ttlSettingToFind = "TTLGEO_"; + if (detectorSettings.find(ttlSettingToFind) != std::string::npos) { + auto pos = detectorSettings.find(ttlSettingToFind); + G4TTL::SETTING::optionGeo = std::stoi(detectorSettings.substr(pos + ttlSettingToFind.size(), pos + ttlSettingToFind.size() + 1)); + } else { + G4TTL::SETTING::optionGeo = 1; + } + + //*********************************************** + // gems fwd & bwd + //*********************************************** + Enable::EGEM = false; + Enable::FGEM = false; + + //*********************************************** + // tracking macro settings + //*********************************************** + Enable::TRACKING = true; + Enable::TRACKING_EVAL = Enable::TRACKING && false; + G4TRACKING::DISPLACED_VERTEX = true; // this option exclude vertex in the track fitting and use RAVE to reconstruct primary and 2ndary vertexes + // projections to calorimeters + G4TRACKING::PROJECTION_EEMC = true; + G4TRACKING::PROJECTION_BECAL = true; + G4TRACKING::PROJECTION_EHCAL = true; + G4TRACKING::PROJECTION_CEMC = true; + G4TRACKING::PROJECTION_HCALIN = true; + G4TRACKING::PROJECTION_HCALOUT = true; + G4TRACKING::PROJECTION_FEMC = true; + G4TRACKING::PROJECTION_FHCAL = true; + G4TRACKING::PROJECTION_LFHCAL = true; + + //*********************************************** + // barrel calos & magnet + //*********************************************** + Enable::BECAL = true; + Enable::HCALIN = true; + Enable::MAGNET = true; + Enable::HCALOUT = true; + + //*********************************************** + // cherenkov's + //*********************************************** + Enable::DIRC = true; + Enable::RICH = true; + Enable::mRICH = true; + + //*********************************************** + // fwd calos + //*********************************************** + Enable::FEMC = true; + Enable::DRCALO = false; + G4TTL::SETTING::optionDR = 1; + Enable::LFHCAL = true; + + //*********************************************** + // bwd calos + //*********************************************** + Enable::EEMCH = true; + if (detectorSettings.find("EEMAPNC") != std::string::npos) { + G4EEMCH::SETTING::USECUSTOMMAPNOCARBON = true; + } + if (detectorSettings.find("EEMAP30CM") != std::string::npos) { + G4EEMCH::SETTING::USECUSTOMMAP30CM = true; + } + if (detectorSettings.find("EEMAPCARBON") != std::string::npos) { + G4EEMCH::SETTING::USECUSTOMMAPCARBON = true; + } + if (detectorSettings.find("EEMAPUPDATE") != std::string::npos) { + G4EEMCH::SETTING::USECUSTOMMAPUPDATED = true; + } + Enable::EHCAL = false; + Enable::PLUGDOOR = true; + + // Other options + Enable::GLOBAL_RECO = G4TRACKING::DISPLACED_VERTEX; // use reco vertex for global event vertex + Enable::GLOBAL_FASTSIM = true; + + // jet reconstruction + Enable::FWDJETS = false; + Enable::FWDJETS_EVAL = Enable::FWDJETS && false; + + // new settings using Enable namespace in GlobalVariables.C + Enable::BLACKHOLE = true; + bool BLACKHOLE_SAVEHITS = false; + if(detectorSettings.find("BHH")!= std::string::npos ){ + Enable::BLACKHOLE_SAVEHITS = true; // turn off saving of bh hits + Enable::EVENT_EVAL_DO_HITS_BLACKHOLE = true; // turn off saving of bh hits + } + // BlackHoleGeometry::visible = true; + + // ZDC + // Enable::ZDC = true; + // Enable::ZDC_DISABLE_BLACKHOLE = true; + + // B0 + // Enable::B0_DISABLE_HITPLANE = true; + // Enable::B0_FULLHITPLANE = true; + + // Enable::B0ECALTOWERS = true; //To Construct Towers of B0ECal instead of one single volume + // Enable::B0ECAL = Enable::B0_DISABLE_HITPLANE && true; + // Enable::B0ECAL_CELL = Enable::B0ECAL && true; + // Enable::B0ECAL_TOWER = Enable::B0ECAL_CELL && true; + // Enable::B0ECAL_CLUSTER = Enable::B0ECAL_TOWER && true; + // Enable::B0ECAL_EVAL = Enable::B0ECAL_CLUSTER && true; + + // RP + // Enable::RP_DISABLE_HITPLANE = true; + // Enable::RP_FULLHITPLANE = true; + + // RP after 2nd focus for IP8 only + // Enable::RP2nd_DISABLE_HITPLANE = true; + // Enable::RP2nd_FULLHITPLANE = true; + + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // special settings for Calo standalone studies + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // deactivate all respective detector systems for standalone studies + if(detectorSettings.find("STANDALONE")!= std::string::npos){ + Enable::PIPE = false; + G4PIPE::use_forward_pipes = false; + Enable::HFARFWD_MAGNETS = false; + Enable::HFARFWD_VIRTUAL_DETECTORS = false; + // Enable::TPC_ENDCAP = false; + // G4TRACKING::PROJECTION_CEMC = false; + // G4TRACKING::PROJECTION_FEMC = false; + // G4TRACKING::PROJECTION_FHCAL = false; + // G4TRACKING::PROJECTION_EHCAL = false; + // G4TRACKING::PROJECTION_DRCALO = false; + // G4TRACKING::PROJECTION_EEMC = false; + Enable::MAGNET = false; + Enable::DIRC = false; + Enable::RICH = false; + Enable::mRICH = false; + // Enable::AEROGEL = false; + Enable::CEMC = false; + Enable::HCALOUT = false; + Enable::HCALIN = false; + Enable::EHCAL = false; + Enable::EEMC = false; + Enable::EEMCH = false; + Enable::FEMC = false; + Enable::FHCAL = false; + Enable::LFHCAL = false; + Enable::BECAL = false; + Enable::FTTL = false; + Enable::CTTL = false; + Enable::ETTL = false; + Enable::EEMCH = false; + Enable::RWELL = false; + Enable::TrackingService = false; + Enable::BARREL = false; + Enable::FST = false; + Enable::EGEM = false; + Enable::FGEM = false; + if(detectorSettings.find("PIPE")!= std::string::npos ){ + Enable::PIPE = true; + G4PIPE::use_forward_pipes = true; + } + if(detectorSettings.find("Magnet")!= std::string::npos ) + Enable::MAGNET = true; + if(detectorSettings.find("dRICH")!= std::string::npos ) + Enable::RICH = true; + // if(detectorSettings.find("ALLSILICON")!= std::string::npos ) + // Enable::ALLSILICON = true; + if(detectorSettings.find("CEMC")!= std::string::npos ) + Enable::CEMC = true; + if(detectorSettings.find("HCALOUT")!= std::string::npos ){ + Enable::HCALOUT = true; + } + if(detectorSettings.find("HCALIN")!= std::string::npos ){ + Enable::HCALIN = true; + } + if(detectorSettings.find("HCALINOUT")!= std::string::npos ){ + Enable::HCALOUT = true; + Enable::HCALIN = true; + } + if(detectorSettings.find("DR")!= std::string::npos ) + Enable::DRCALO = true; + if(detectorSettings.find("FEMC")!= std::string::npos ) + Enable::FEMC = true; + if(detectorSettings.find("FGEM")!= std::string::npos ) + Enable::FGEM = true; + if((detectorSettings.find("FHCAL")!= std::string::npos) && !(detectorSettings.find("LFHCAL")!= std::string::npos) ) + Enable::FHCAL = true; + if(detectorSettings.find("LFHCAL")!= std::string::npos ) + Enable::LFHCAL = true; + if(detectorSettings.find("BECAL")!= std::string::npos ) + Enable::BECAL = true; + if(detectorSettings.find("EHCAL")!= std::string::npos ) + Enable::EHCAL = true; + if(detectorSettings.find("EEMCH")!= std::string::npos ) + Enable::EEMCH = true; + if(detectorSettings.find("RWELL")!= std::string::npos ) + Enable::RWELL = true; + if(detectorSettings.find("CHCAL")!= std::string::npos ){ + Enable::HCALIN = true; + Enable::HCALOUT = true; + } + if(detectorSettings.find("DIRC")!= std::string::npos ) + Enable::DIRC = true; + if(detectorSettings.find("SUPPORT")!= std::string::npos ){ + Enable::TrackingService = true; + Enable::TrackingService_OVERLAPCHECK = true; + } + if(detectorSettings.find("FWDCALO")!= std::string::npos ){ + Enable::FEMC = true; + Enable::FHCAL = true; + } + if(detectorSettings.find("FWDLCALO")!= std::string::npos ){ + Enable::FEMC = true; + Enable::LFHCAL = true; + } + if(detectorSettings.find("BARCALO")!= std::string::npos ){ + Enable::BECAL = true; + Enable::HCALIN = true; + Enable::HCALOUT = true; + Enable::MAGNET = true; + } + if(detectorSettings.find("BCKCALO")!= std::string::npos ){ + Enable::EHCAL = true; + Enable::EEMCH = true; + } + if(detectorSettings.find("TTL")!= std::string::npos ){ + // Enable::PIPE = true; + // G4PIPE::use_forward_pipes = true; + // LGAD layers + if(detectorSettings.find("FTTL")!= std::string::npos ) + Enable::FTTL = true; + if(detectorSettings.find("ETTL")!= std::string::npos ){ + Enable::ETTL = true; + // G4DIRC::SETTING::USECEMCGeo = false; + G4TTL::SETTING::optionCEMC = false; + } + if(detectorSettings.find("CTTL")!= std::string::npos ){ + Enable::CTTL = true; + // Enable::DIRC = true; + // Enable::CEMC = true; + // Enable::BECAL = true; + // Enable::ALLSILICON = true; + // G4DIRC::SETTING::USECEMCGeo = false; + G4TTL::SETTING::optionCEMC = false; + } + } + } + + //************************************************************ + // details for calos: cells, towers, clusters + //************************************************************ + Enable::BECAL_CELL = Enable::BECAL && true; + Enable::BECAL_TOWER = Enable::BECAL_CELL && true; + Enable::BECAL_CLUSTER = Enable::BECAL_TOWER && true; + Enable::BECAL_EVAL = Enable::BECAL_CLUSTER && false; + + Enable::HCALIN_CELL = Enable::HCALIN && true; + Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true; + Enable::HCALIN_CLUSTER = Enable::HCALIN_TOWER && true; + Enable::HCALIN_EVAL = Enable::HCALIN_CLUSTER && false; + + Enable::HCALOUT_CELL = Enable::HCALOUT && true; + Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true; + Enable::HCALOUT_CLUSTER = Enable::HCALOUT_TOWER && true; + Enable::HCALOUT_EVAL = Enable::HCALOUT_CLUSTER && false; + + Enable::DIRC_RECO = Enable::DIRC && true; + Enable::RICH_RECO = Enable::DIRC && true; + Enable::mRICH_RECO = Enable::DIRC && true; + + Enable::FEMC_TOWER = Enable::FEMC && true; + Enable::FEMC_CLUSTER = Enable::FEMC_TOWER && true; + Enable::FEMC_EVAL = Enable::FEMC_CLUSTER && false; + + Enable::DRCALO_CELL = Enable::DRCALO && true; + Enable::DRCALO_TOWER = Enable::DRCALO_CELL && true; + Enable::DRCALO_CLUSTER = Enable::DRCALO_TOWER && true; + Enable::DRCALO_EVAL = Enable::DRCALO_CLUSTER && false; + + Enable::LFHCAL_ABSORBER = false; + Enable::LFHCAL_CELL = Enable::LFHCAL && true; + Enable::LFHCAL_TOWER = Enable::LFHCAL_CELL && true; + Enable::LFHCAL_CLUSTER = Enable::LFHCAL_TOWER && true; + Enable::LFHCAL_EVAL = Enable::LFHCAL_CLUSTER && false; + + Enable::EEMCH_TOWER = Enable::EEMCH && true; + Enable::EEMCH_CLUSTER = Enable::EEMCH_TOWER && true; + Enable::EEMCH_EVAL = Enable::EEMCH_CLUSTER && false; + G4TTL::SETTING::optionEEMCH = Enable::EEMCH && true; + + Enable::EHCAL_CELL = Enable::EHCAL && true; + Enable::EHCAL_TOWER = Enable::EHCAL_CELL && true; + Enable::EHCAL_CLUSTER = Enable::EHCAL_TOWER && true; + Enable::EHCAL_EVAL = Enable::EHCAL_CLUSTER && false; + + Enable::FFR_EVAL = Enable::HFARFWD_MAGNETS && Enable::HFARFWD_VIRTUAL_DETECTORS && false; + + // Enabling the event evaluator? + Enable::EVENT_EVAL = true; + if (detectorSettings.find("HITS") != std::string::npos) { + Enable::EVENT_EVAL_DO_HITS = true; + if (detectorSettings.find("HITSABS") != std::string::npos) { + Enable::EVENT_EVAL_DO_HITS_ABSORBER = true; + } + if (detectorSettings.find("HITSC") != std::string::npos) { + Enable::EVENT_EVAL_DO_HITS_CALO = true; + } + } + Enable::EVENT_EVAL_DO_HEPMC = Input::PYTHIA6 or Input::PYTHIA8 or Input::SARTRE or Input::HEPMC or Input::READEIC; + Enable::EVENT_EVAL_DO_EVT_LVL = Input::PYTHIA6 or Input::PYTHIA8 or Input::READEIC; + // EVENT_EVALUATOR::Verbosity = 1; + + //Enable::USER = true; + + //--------------- + // World Settings + //--------------- + // G4WORLD::PhysicsList = "FTFP_BERT"; //FTFP_BERT_HP best for calo + // G4WORLD::WorldMaterial = "G4_AIR"; // set to G4_GALACTIC for material scans + // G4WORLD::WorldMaterial = "G4_Galactic"; // set to G4_GALACTIC for material scans + // --------------- + // Magnet Settings + //--------------- + if (detectorSettings.find("NOFIELD") != std::string::npos) { + const string magfield = "0.0"; // alternatively to specify a constant magnetic field, give a float number, which will be translated to solenoidal field in T, if string use as fieldmap name (including path) + G4MAGNET::magfield = magfield; + G4WORLD::WorldMaterial = "G4_Galactic"; // set to G4_GALACTIC for material scans + } else { + // const string magfield = "1.5"; // alternatively to specify a constant magnetic field, give a float number, which will be translated to solenoidal field in T, if string use as fieldmap name (including path) + // G4MAGNET::magfield = string(getenv("CALIBRATIONROOT")) + string("/Field/Map/sPHENIX.2d.root"); // default map from the calibration database + G4MAGNET::magfield_rescale = -1.4 / 1.5; // make consistent with expected Babar field strength of 1.4T + } + //--------------- + // Pythia Decayer + //--------------- + // list of decay types in + // $OFFLINE_MAIN/include/g4decayer/EDecayType.hh + // default is All: + // G4P6DECAYER::decayType = EDecayType::kAll; + + // Initialize the selected subsystems + G4Init(); + + //--------------------- + // GEANT4 Detector description + //--------------------- + + // If "readhepMC" is also set, the Upsilons will be embedded in Hijing events, if 'particles" is set, the Upsilons will be embedded in whatever particles are thrown + if (!Input::READHITS) + { + G4Setup(); + } + + //------------------ + // Detector Division + //------------------ + if (Enable::CEMC_CELL) CEMC_Cells(); + if (Enable::HCALIN_CELL) HCALInner_Cells(); + if (Enable::HCALOUT_CELL) HCALOuter_Cells(); + + //----------------------------- + // CEMC towering and clustering + //----------------------------- + + if (Enable::CEMC_TOWER) CEMC_Towers(); + if (Enable::CEMC_CLUSTER) CEMC_Clusters(); + + //----------------------------- + // HCAL towering and clustering + //----------------------------- + + if (Enable::HCALIN_TOWER) HCALInner_Towers(); + if (Enable::HCALIN_CLUSTER) HCALInner_Clusters(); + + if (Enable::HCALOUT_TOWER) HCALOuter_Towers(); + if (Enable::HCALOUT_CLUSTER) HCALOuter_Clusters(); + + //----------------------------- + // e, h direction Calorimeter towering and clustering + //----------------------------- + + if (Enable::FEMC_TOWER) FEMC_Towers(); + if (Enable::FEMC_CLUSTER) FEMC_Clusters(); + + if (Enable::FHCAL_TOWER) FHCAL_Towers(); + if (Enable::FHCAL_CLUSTER) FHCAL_Clusters(); + + if (Enable::DRCALO_TOWER) DRCALO_Towers(); + if (Enable::DRCALO_CLUSTER) DRCALO_Clusters(); + + if (Enable::LFHCAL_TOWER) LFHCAL_Towers(); + if (Enable::LFHCAL_CLUSTER) LFHCAL_Clusters(); + + if (Enable::EEMC_TOWER) EEMC_Towers(); + if (Enable::EEMC_CLUSTER) EEMC_Clusters(); + + if (Enable::EEMCH_TOWER) EEMCH_Towers(); + if (Enable::EEMCH_CLUSTER) EEMCH_Clusters(); + + if (Enable::EHCAL_TOWER) EHCAL_Towers(); + if (Enable::EHCAL_CLUSTER) EHCAL_Clusters(); + + if (Enable::BECAL_TOWER) BECAL_Towers(); + if (Enable::BECAL_CLUSTER) BECAL_Clusters(); + + if (Enable::DSTOUT_COMPRESS) ShowerCompress(); + + //-------------- + // Tracking and PID + //-------------- + + if (Enable::TRACKING) Tracking_Reco(); + + if (Enable::DIRC_RECO) DIRCReco(); + + if (Enable::mRICH_RECO ) mRICHReco(); + + if (Enable::RICH_RECO) RICHReco(); + + //----------------- + // Global Vertexing + //----------------- + + if (Enable::GLOBAL_RECO) + { + Global_Reco(); + } + else if (Enable::GLOBAL_FASTSIM) + { + Global_FastSim(); + } + + //--------- + // Jet reco + //--------- + + if (Enable::FWDJETS) Jet_FwdReco(); + + string outputroot = outdir + "/" + outputFile; + string remove_this = ".root"; + size_t pos = outputroot.find(remove_this); + if (pos != string::npos) + { + outputroot.erase(pos, remove_this.length()); + } + + if (Enable::DSTREADER) G4DSTreader_EICDetector(outputroot + "_DSTReader.root"); + + //---------------------- + // Simulation evaluation + //---------------------- + + if (Enable::EVENT_EVAL) Event_Eval(outputroot + "_eventtree.root"); + + if (Enable::TRACKING_EVAL) Tracking_Eval(outputroot + "_g4tracking_eval.root"); + + if (Enable::CEMC_EVAL) CEMC_Eval(outputroot + "_g4cemc_eval.root"); + + if (Enable::HCALIN_EVAL) HCALInner_Eval(outputroot + "_g4hcalin_eval.root"); + + if (Enable::HCALOUT_EVAL) HCALOuter_Eval(outputroot + "_g4hcalout_eval.root"); + + if (Enable::FEMC_EVAL) FEMC_Eval(outputroot + "_g4femc_eval.root"); + + if (Enable::FHCAL_EVAL) FHCAL_Eval(outputroot + "_g4fhcal_eval.root"); + + if (Enable::EEMC_EVAL) EEMC_Eval(outputroot + "_g4eemc_eval.root"); + + if (Enable::FFR_EVAL) FFR_Eval(outputroot + "_g4ffr_eval.root"); + + if (Enable::FWDJETS_EVAL) Jet_FwdEval(outputroot); + + if (Enable::USER) UserAnalysisInit(); + + + //-------------- + // Set up Input Managers + //-------------- + + InputManagers(); + + //-------------- + // Set up Output Manager + //-------------- + if (Enable::PRODUCTION) + { + Production_CreateOutputDir(); + } + + if (Enable::DSTOUT) + { + string FullOutFile = DstOut::OutputDir + "/" + DstOut::OutputFile; + Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", FullOutFile); + if (Enable::DSTOUT_COMPRESS) DstCompress(out); + se->registerOutputManager(out); + } + + //----------------- + // Event processing + //----------------- + if (Enable::DISPLAY) + { + if (detectorSettings.find("viewer") != std::string::npos){ + gROOT->ProcessLine("PHG4Reco *g4 = QTGui();"); // alternative to DisplayOn + } else { + DisplayOn(); + gROOT->ProcessLine("Fun4AllServer *se = Fun4AllServer::instance();"); + gROOT->ProcessLine("PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");"); + } + cout << "-------------------------------------------------" << endl; + cout << "You are in event display mode. Run one event with" << endl; + cout << "se->run(1)" << endl; + cout << "Run Geant4 command with following examples" << endl; + gROOT->ProcessLine("displaycmd()"); + + return 0; + } + // if we use a negative number of events we go back to the command line here + if (nEvents < 0) + { + return 0; + } + // if we run any of the particle generators and use 0 it'll run forever + if (nEvents == 0 && !Input::READHITS && !Input::HEPMC && !Input::READEIC) + { + cout << "using 0 for number of events is a bad idea when using particle generators" << endl; + cout << "it will run forever, so I just return without running anything" << endl; + return 0; + } + + se->skip(skip); + se->run(nEvents); + + //----- + // Exit + //----- + + se->End(); + std::cout << "All done" << std::endl; + delete se; + if (Enable::PRODUCTION) + { + Production_MoveOutput(); + } + gSystem->Exit(0); + return 0; +} +#endif diff --git a/detectors/Modular/Fun4All_runEvaluators.C b/detectors/Modular/Fun4All_runEvaluators.C new file mode 100644 index 00000000..ce86727e --- /dev/null +++ b/detectors/Modular/Fun4All_runEvaluators.C @@ -0,0 +1,214 @@ +#ifndef MACRO_FUN4ALLG4RUNEVALUATORS_C +#define MACRO_FUN4ALLG4RUNEVALUATORS_C + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; + +R__LOAD_LIBRARY(libfun4all.so) + +bool checkForDir(string name) +{ + DIR* dir = opendir(name.c_str()); + + return dir == NULL ? 0 : 1; +} + +bool checkForFile(string dir, string base, map extension) +{ + bool fileExists = false; + string fileName; + for (auto const& key : extension) + { + fileName = dir + "/" + base + key.second; + ifstream file(fileName.c_str()); + if (file.good()) fileExists = true; + } + + return fileExists; +} + +int Fun4All_runEvaluators( + const int nEvents = 1, + const string &inputFile = "myInputFile.root", + const string &inputDir = ".", + const int skip = 0, + const string &outdir = ".") +{ + Fun4AllServer *se = Fun4AllServer::instance(); + se->Verbosity(0); + + Input::READHITS = true; + INPUTREADHITS::filename[0] = inputDir + "/" + inputFile; + + InputInit(); + + //----- + // What to run + //----- + + Enable::DSTREADER = false; + Enable::USER = false; // Enable this to run custom code from G4_User.C + + Enable::EVENT_EVAL = true; + Enable::TRACKING_EVAL = true; + Enable::BECAL_EVAL = true; + Enable::HCALIN_EVAL = true; + Enable::HCALOUT_EVAL = true; + Enable::FEMC_EVAL = true; + Enable::LFHCAL_EVAL = true; + Enable::EEMCH_EVAL = true; + Enable::EHCAL_EVAL = true; + Enable::FWDJETS_EVAL = false; + Enable::FFR_EVAL = true; + + map evaluatorNames; + evaluatorNames["event"] = "_g4event_eval.root"; + evaluatorNames["tracking"] = "_g4tracking_eval.root"; + evaluatorNames["becal"] = "_g4becal_eval.root"; + evaluatorNames["hcalin"] = "_g4hcalin_eval.root"; + evaluatorNames["hcalout"] = "_g4hcalout_eval.root"; + evaluatorNames["femc"] = "_g4femc_eval.root"; + evaluatorNames["fhcal"] = "_g4fhcal_eval.root"; + evaluatorNames["eemch"] = "_g4eemch_eval.root"; + evaluatorNames["ehcal"] = "_g4ehcal_eval.root"; + evaluatorNames["farfwd"] = "_g4farfwd_eval.root"; + + /* + * Enable extra features in the evaluators + * WARNING!!! Ensure your DST has the right nodes + */ + Enable::TRACKING = true; + Enable::BECAL = true; + Enable::HCALIN = true; + Enable::HCALOUT = true; + Enable::FEMC = true; + Enable::LFHCAL = true; + Enable::EEMCH = true; + Enable::EHCAL = true; + + TRACKING::ProjectionNames = {"BECAL" + ,"CTTL_0" + ,"EEMC" + ,"EHCAL" + ,"ETTL_0" + ,"ETTL_1" + ,"FEMC" + ,"FTTL_0" + ,"FTTL_1" + ,"HCALOUT" + ,"LFHCAL" + ,"RICH" + ,"hpDIRC" + ,"mRICH" + }; + + Enable::DIRC_RECO = true; + Enable::mRICH_RECO = true; + Enable::RICH_RECO = true; + + //----- + // Output file headers and path + //----- + + //Get base file name + string baseFile = inputFile; + string remove_this = ".root"; + size_t pos = baseFile.find(remove_this); + if (pos != string::npos) + { + baseFile.erase(pos, remove_this.length()); + } + + string evalDir = outdir; + string outdirLastChar = outdir.substr(outdir.size() - 1, 1); + if (outdirLastChar != "/") evalDir += "/"; + + unsigned int revisionWidth = 5; + unsigned int revisionNumber = 0; + ostringstream evalRevision; + evalRevision << setfill('0') << setw(revisionWidth) << to_string(revisionNumber); + evalDir += "eval_" + evalRevision.str(); + + while (checkForDir(evalDir)) + { + bool evalFileStatus = checkForFile(evalDir, baseFile, evaluatorNames); + if (!evalFileStatus) break; + evalDir = evalDir.substr(0, evalDir.size() - revisionWidth); + revisionNumber++; + evalRevision.str(""); + evalRevision.clear(); + evalRevision << setfill('0') << setw(revisionWidth) << to_string(revisionNumber); + evalDir += evalRevision.str(); + } + + string makeDirectory = "mkdir -p " + evalDir; + system(makeDirectory.c_str()); + + string outputroot = evalDir + "/" + baseFile; + + //----- + // Reader and User analysis + //----- + + if (Enable::DSTREADER) G4DSTreader_EICDetector(outputroot + "_DSTReader.root"); + if (Enable::USER) UserAnalysisInit(); + + //----- + // Evaluators + //----- + + if (Enable::EVENT_EVAL) Event_Eval(outputroot + evaluatorNames.find("event")->second); + if (Enable::TRACKING_EVAL) Tracking_Eval(outputroot + evaluatorNames.find("tracking")->second); + if (Enable::BECAL_EVAL) BECAL_Eval(outputroot + evaluatorNames.find("becal")->second); + if (Enable::HCALIN_EVAL) HCALInner_Eval(outputroot + evaluatorNames.find("hcalin")->second); + if (Enable::HCALOUT_EVAL) HCALOuter_Eval(outputroot + evaluatorNames.find("hcalout")->second); + if (Enable::FEMC_EVAL) FEMC_Eval(outputroot + evaluatorNames.find("femc")->second); + if (Enable::FHCAL_EVAL) FHCAL_Eval(outputroot + evaluatorNames.find("fhcal")->second); + if (Enable::EEMCH_EVAL) EEMCH_Eval(outputroot + evaluatorNames.find("eemch")->second); + if (Enable::EHCAL_EVAL) EHCAL_Eval(outputroot + evaluatorNames.find("ehcal")->second); + if (Enable::FWDJETS_EVAL) Jet_FwdEval(outputroot); + if (Enable::FFR_EVAL) FFR_Eval(outputroot + evaluatorNames.find("farfwd")->second); + + //-------------- + // Set up Input Managers + //-------------- + + InputManagers(); + + //----- + // Run + //----- + + se->skip(skip); + se->run(nEvents); + + //----- + // Exit + //----- + + se->End(); + cout << "All done" << endl; + delete se; + + gSystem->Exit(0); + return 0; +} + +#endif diff --git a/detectors/Modular/G4Setup_ECCEModular.C b/detectors/Modular/G4Setup_ECCEModular.C new file mode 100644 index 00000000..3c9b7128 --- /dev/null +++ b/detectors/Modular/G4Setup_ECCEModular.C @@ -0,0 +1,448 @@ +#ifndef MACRO_G4SETUPECCEMODULAR_C +#define MACRO_G4SETUPECCEMODULAR_C + +#include + +#include + +//#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include //for B0 ECAL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include for B0 Tracking +#include +#include +#include +#include +#include +#include + +// these two has to be ordered this way for now. +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +#include +#include + +R__LOAD_LIBRARY(libg4decayer.so) +R__LOAD_LIBRARY(libg4detectors.so) + +void G4Init() +{ + // First some check for subsystems which do not go together + + if (Enable::IP6 and Enable::IP8) + { + cout << "Can not enable Enable::IP6 and Enable::IP8 at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::IP6 == false and Enable::IP8 == false) + { + cout << "None of the possible EIC IPs were selected: Enable::IP6 and Enable::IP8 !" << endl; + gSystem->Exit(1); + } + + if (Enable::EEMC and Enable::EEMCH) + { + cout << "Can not enable EEMC and EEMCH at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::CEMC and Enable::BECAL) + { + cout << "Can not enable CEMC and BECAL at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::BTOF and Enable::CTTL) + { + cout << "Can not enable BTOF and CTTL at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::ETOF and Enable::ETTL) + { + cout << "Can not enable ETOF and ETTL at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::HTOF and Enable::FTTL) + { + cout << "Can not enable HTOF and FTTL at the same time!" << endl; + gSystem->Exit(1); + } + if (Enable::BMMG and Enable::DIRC) + { + cout << "Can not enable BMMG and DIRC at the same time!" << endl; + gSystem->Exit(1); + } + if ((Enable::TRD||Enable::TRD_GAS) and Enable::RICH) + { + cout << "Can not enable TRD* and RICH at the same time!" << endl; + gSystem->Exit(1); + } + + // load detector/material macros and execute Init() function + if (Enable::PIPE) PipeInit(); + if (Enable::PLUGDOOR) PlugDoorInit(); + if (Enable::TRACKING) TrackingInit(); +// if (Enable::B0TRACKING) B0TrackingInit(); + + //Farforward/backward + if (Enable::HFARFWD_MAGNETS) hFarBwdBeamLineInit(); //Shouldnt this be far backward enables + if (Enable::HFARFWD_MAGNETS) hFarFwdBeamLineInit(); + + //Barrel + if (Enable::TrackingService) TrackingServiceInit(); + if (Enable::BARREL) BarrelInit(); + if (Enable::RWELL) RWellInit(); + if (Enable::CEMC) CEmcInit(72); // make it 2*2*2*3*3 so we can try other combinations + if (Enable::BECAL) BECALInit(); + if (Enable::HCALIN) HCalInnerInit(1); + if (Enable::MAGNET) MagnetInit(); + MagnetFieldInit(); // We want the field - even if the magnet volume is disabled + if (Enable::HCALOUT) HCalOuterInit(); + if (Enable::DIRC) DIRCInit(); + if (Enable::BTOF) BToFInit(); + if (Enable::BMMG) BMMGInit(); + + //Forward + if (Enable::FGEM) FGEM_Init(); + if (Enable::FEMC) FEMCInit(); + if (Enable::DRCALO) DRCALOInit(); + if (Enable::FHCAL) FHCALInit(); + if (Enable::LFHCAL) LFHCALInit(); + if (Enable::RICH) RICHInit(); + if (Enable::TRD) TRDInit(); + if (Enable::HTOF) HTOFInit(); + if (Enable::B0ECAL) B0ECALInit(); + + //Backward + if (Enable::EGEM) EGEM_Init(); + if (Enable::EEMC) EEMCInit(); + if (Enable::EEMCH) EEMCHInit(); + if (Enable::EHCAL) EHCALInit(); + if (Enable::mRICH) mRICHInit(); + if (Enable::ETOF) ETOFInit(); + + //Combined + if (Enable::FST) FST_Init(); + if (Enable::FTTL || Enable::ETTL || Enable::CTTL) TTL_Init(); + + if (Enable::USER) UserInit(); + if (Enable::BLACKHOLE) BlackHoleInit(); +} + +int G4Setup() +{ + //--------------- + // Fun4All server + //--------------- + + Fun4AllServer *se = Fun4AllServer::instance(); + + PHG4Reco *g4Reco = new PHG4Reco(); + + WorldInit(g4Reco); + + g4Reco->set_rapidity_coverage(1.1); // according to drawings + // uncomment to set QGSP_BERT_HP physics list for productions + // (default is QGSP_BERT for speed) + // g4Reco->SetPhysicsList("QGSP_BERT_HP"); + + if (G4P6DECAYER::decayType != EDecayType::kAll) + { + g4Reco->set_force_decay(G4P6DECAYER::decayType); + } + + double fieldstrength; + istringstream stringline(G4MAGNET::magfield); + stringline >> fieldstrength; + if (stringline.fail()) + { // conversion to double fails -> we have a string + + if (G4MAGNET::magfield.find("sPHENIX.root") != string::npos) + { + g4Reco->set_field_map(G4MAGNET::magfield, PHFieldConfig::Field3DCartesian); + } + else + { + g4Reco->set_field_map(G4MAGNET::magfield, PHFieldConfig::kField2D); + } + } + else + { + g4Reco->set_field(fieldstrength); // use const soleniodal field + } + g4Reco->set_field_rescale(G4MAGNET::magfield_rescale); + + // the radius is an older protection against overlaps, it is not + // clear how well this works nowadays but it doesn't hurt either + double radius = 0.; + + if (Enable::PIPE) radius = Pipe(g4Reco, radius); + + // Far Forward Region + if (Enable::HFARFWD_MAGNETS_IP6 || Enable::HFARFWD_MAGNETS_IP8) hFarFwdDefineMagnets(g4Reco); + if (Enable::HFARFWD_VIRTUAL_DETECTORS_IP6) hFarFwdDefineDetectorsIP6(g4Reco); + if (Enable::HFARFWD_VIRTUAL_DETECTORS_IP8) hFarFwdDefineDetectorsIP8(g4Reco); + + // Far Backward Region + if (Enable::HFARBWD_MAGNETS_IP6 || Enable::HFARBWD_MAGNETS_IP8) hFarBwdDefineMagnets(g4Reco); + if (Enable::HFARBWD_VIRTUAL_DETECTORS_IP6) hFarBwdDefineDetectorsIP6(g4Reco); + if (Enable::HFARBWD_VIRTUAL_DETECTORS_IP8) hFarBwdDefineDetectorsIP8(g4Reco); + + //Barrel + if (Enable::TrackingService) TrackingService(g4Reco, radius); + + if (Enable::RWELL) RWellSetup(g4Reco); + if (Enable::FST) FSTSetup(g4Reco); + if (Enable::CTTL) CTTLSetup(g4Reco); + if (Enable::BARREL) Barrel(g4Reco); + if (Enable::CEMC) radius = CEmc(g4Reco, radius); + if (Enable::BECAL) BECALSetup(g4Reco); + if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4); + if (Enable::MAGNET) radius = Magnet(g4Reco, radius); + if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4); + if (Enable::DIRC) DIRCSetup(g4Reco); + if (Enable::BTOF) BToFSetup(g4Reco); + if (Enable::BMMG) BMMGSetup(g4Reco); + + //Forward + if (Enable::FGEM) FGEMSetup(g4Reco); + if (Enable::FTTL) FTTLSetup(g4Reco); + if (Enable::FEMC) FEMCSetup(g4Reco); + if (Enable::DRCALO) DRCALOSetup(g4Reco); + if (Enable::FHCAL) FHCALSetup(g4Reco); + if (Enable::LFHCAL) LFHCALSetup(g4Reco); + if (Enable::RICH) RICHSetup(g4Reco); + if (Enable::TRD) TRDSetup(g4Reco); + if (Enable::HTOF) HTOFSetup(g4Reco); + + //Backward + if (Enable::ETTL) ETTLSetup(g4Reco); + if (Enable::EGEM) EGEMSetup(g4Reco); + if (Enable::EEMC) EEMCSetup(g4Reco); + if (Enable::EEMCH) EEMCHSetup(g4Reco); + if (Enable::EHCAL) EHCALSetup(g4Reco); + if (Enable::mRICH) mRICHSetup(g4Reco); + if (Enable::ETOF) ETOFSetup(g4Reco); + + //---------------------------------------- + // sPHENIX forward flux return door + if (Enable::PLUGDOOR) PlugDoor(g4Reco); + + if (Enable::USER) UserDetector(g4Reco); + + //---------------------------------------- + // BLACKHOLE if enabled, needs info from all previous sub detectors for dimensions + if (Enable::BLACKHOLE) BlackHole(g4Reco, radius); + + PHG4TruthSubsystem *truth = new PHG4TruthSubsystem(); + g4Reco->registerSubsystem(truth); + // finally adjust the world size in case the default is too small + WorldSize(g4Reco, radius); + + se->registerSubsystem(g4Reco); + return 0; +} + +void ShowerCompress() +{ + Fun4AllServer *se = Fun4AllServer::instance(); + + PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco"); + compress->AddHitContainer("G4HIT_PIPE"); + + ////------------------ + //// Disabling these option during the compression, + //// until ZDC, Romanpots, and B0 have real design. + // + // compress->AddHitContainer("G4HIT_ZDC"); + // compress->AddHitContainer("G4HIT_RomanPots"); + // compress->AddHitContainer("G4HIT_B0detector"); + compress->AddHitContainer("G4HIT_b0Truth"); + compress->AddHitContainer("G4HIT_FIELDCAGE"); + + compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS"); + compress->AddHitContainer("G4HIT_CEMC"); + compress->AddHitContainer("G4HIT_ABSORBER_CEMC"); + compress->AddHitContainer("G4HIT_CEMC_SPT"); + compress->AddCellContainer("G4CELL_CEMC"); + compress->AddTowerContainer("TOWER_SIM_CEMC"); + compress->AddTowerContainer("TOWER_RAW_CEMC"); + compress->AddTowerContainer("TOWER_CALIB_CEMC"); + + compress->AddHitContainer("G4HIT_BECAL"); + compress->AddHitContainer("G4HIT_ABSORBER_BECAL"); + compress->AddCellContainer("G4CELL_BECAL"); + compress->AddTowerContainer("TOWER_SIM_BECAL"); + compress->AddTowerContainer("TOWER_RAW_BECAL"); + compress->AddTowerContainer("TOWER_CALIB_BECAL"); + + compress->AddHitContainer("G4HIT_HCALIN"); + compress->AddHitContainer("G4HIT_ABSORBER_HCALIN"); + compress->AddHitContainer("G4HIT_HCALIN_SPT"); + compress->AddCellContainer("G4CELL_HCALIN"); + compress->AddTowerContainer("TOWER_SIM_HCALIN"); + compress->AddTowerContainer("TOWER_RAW_HCALIN"); + compress->AddTowerContainer("TOWER_CALIB_HCALIN"); + + compress->AddHitContainer("G4HIT_MAGNET"); + + compress->AddHitContainer("G4HIT_HCALOUT"); + compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT"); + compress->AddCellContainer("G4CELL_HCALOUT"); + compress->AddTowerContainer("TOWER_SIM_HCALOUT"); + compress->AddTowerContainer("TOWER_RAW_HCALOUT"); + compress->AddTowerContainer("TOWER_CALIB_HCALOUT"); + + compress->AddHitContainer("G4HIT_BH_1"); + compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS"); + compress->AddHitContainer("G4HIT_BH_FORWARD_NEG"); + + compress->AddHitContainer("G4HIT_FEMC"); + compress->AddHitContainer("G4HIT_ABSORBER_FEMC"); + compress->AddCellContainer("G4CELL_FEMC"); + compress->AddTowerContainer("TOWER_SIM_FEMC"); + compress->AddTowerContainer("TOWER_RAW_FEMC"); + compress->AddTowerContainer("TOWER_CALIB_FEMC"); + + compress->AddHitContainer("G4HIT_DRCALO"); + compress->AddHitContainer("G4HIT_ABSORBER_DRCALO"); + compress->AddCellContainer("G4CELL_DRCALO"); + compress->AddTowerContainer("TOWER_SIM_DRCALO"); + compress->AddTowerContainer("TOWER_RAW_DRCALO"); + compress->AddTowerContainer("TOWER_CALIB_DRCALO"); + + compress->AddHitContainer("G4HIT_FHCAL"); + compress->AddHitContainer("G4HIT_ABSORBER_FHCAL"); + compress->AddCellContainer("G4CELL_FHCAL"); + compress->AddTowerContainer("TOWER_SIM_FHCAL"); + compress->AddTowerContainer("TOWER_RAW_FHCAL"); + compress->AddTowerContainer("TOWER_CALIB_FHCAL"); + + compress->AddHitContainer("G4HIT_LFHCAL"); + compress->AddHitContainer("G4HIT_ABSORBER_LFHCAL"); + compress->AddCellContainer("G4CELL_LFHCAL"); + compress->AddTowerContainer("TOWER_SIM_LFHCAL"); + compress->AddTowerContainer("TOWER_RAW_LFHCAL"); + compress->AddTowerContainer("TOWER_CALIB_LFHCAL"); + + compress->AddHitContainer("G4HIT_EEMC"); + compress->AddHitContainer("G4HIT_EEMC_glass"); + compress->AddHitContainer("G4HIT_ABSORBER_EEMC"); + compress->AddCellContainer("G4CELL_EEMC"); + compress->AddTowerContainer("TOWER_SIM_EEMC"); + compress->AddTowerContainer("TOWER_RAW_EEMC"); + compress->AddTowerContainer("TOWER_CALIB_EEMC"); + + compress->AddHitContainer("G4HIT_EHCAL"); + compress->AddHitContainer("G4HIT_ABSORBER_EHCAL"); + compress->AddTowerContainer("TOWER_SIM_EHCAL"); + compress->AddTowerContainer("TOWER_RAW_EHCAL"); + compress->AddTowerContainer("TOWER_CALIB_EHCAL"); + + compress->AddHitContainer("G4HIT_B0ECAL"); + compress->AddHitContainer("G4HIT_ABSORBER_B0ECAL"); + compress->AddCellContainer("G4CELL_B0ECAL"); + compress->AddTowerContainer("TOWER_SIM_B0ECAL"); + compress->AddTowerContainer("TOWER_RAW_B0ECAL"); + compress->AddTowerContainer("TOWER_CALIB_B0ECAL"); + + se->registerSubsystem(compress); + + return; +} + +void DstCompress(Fun4AllDstOutputManager *out) +{ + if (out) + { + out->StripNode("G4HIT_PIPE"); + + ////------------------ + //// Disabling these option during the compression, + //// until ZDC, Romanpots, and B0 have real design. + // + // out->StripNode("G4HIT_ZDC"); + // out->StripNode("G4HIT_RomanPots"); + // out->StripNode("G4HIT_B0detectors"); + out->StripNode("G4HIT_b0Truth"); + out->StripNode("G4HIT_SVTXSUPPORT"); + out->StripNode("G4HIT_CEMC_ELECTRONICS"); + out->StripNode("G4HIT_CEMC"); + out->StripNode("G4HIT_ABSORBER_CEMC"); + out->StripNode("G4HIT_CEMC_SPT"); + out->StripNode("G4CELL_CEMC"); + out->StripNode("G4HIT_BECAL"); + out->StripNode("G4CELL_BECAL"); + out->StripNode("G4HIT_ABSORBER_BECAL"); + out->StripNode("G4HIT_ABSORBER_HCALIN"); + out->StripNode("G4HIT_HCALIN"); + out->StripNode("G4HIT_HCALIN_SPT"); + out->StripNode("G4CELL_HCALIN"); + out->StripNode("G4HIT_MAGNET"); + out->StripNode("G4HIT_HCALOUT"); + out->StripNode("G4HIT_ABSORBER_HCALOUT"); + out->StripNode("G4CELL_HCALOUT"); + out->StripNode("G4HIT_BH_1"); + out->StripNode("G4HIT_BH_FORWARD_PLUS"); + out->StripNode("G4HIT_BH_FORWARD_NEG"); + + out->StripNode("G4HIT_FEMC"); + out->StripNode("G4HIT_ABSORBER_FEMC"); + out->StripNode("G4HIT_FHCAL"); + out->StripNode("G4HIT_ABSORBER_FHCAL"); + out->StripNode("G4CELL_FEMC"); + out->StripNode("G4HIT_DRCALO"); + out->StripNode("G4HIT_ABSORBER_DRCALO"); + out->StripNode("G4CELL_DRCALO"); + out->StripNode("G4CELL_FHCAL"); + out->StripNode("G4HIT_LFHCAL"); + out->StripNode("G4HIT_ABSORBER_LFHCAL"); + out->StripNode("G4CELL_LFHCAL"); + out->StripNode("G4HIT_EEMC"); + out->StripNode("G4HIT_EEMC_glass"); + out->StripNode("G4HIT_ABSORBER_EEMC"); + out->StripNode("G4CELL_EEMC"); + out->StripNode("G4HIT_EHCAL"); + out->StripNode("G4HIT_ABSORBER_EHCAL"); + out->StripNode("G4CELL_EHCAL"); + out->StripNode("G4CELL_B0ECAL"); + } +} +#endif diff --git a/detectors/Modular/init_gui_vis.mac b/detectors/Modular/init_gui_vis.mac new file mode 100644 index 00000000..8aca2139 --- /dev/null +++ b/detectors/Modular/init_gui_vis.mac @@ -0,0 +1,20 @@ +# Macro file for the initialization of example B3 +# in interactive session +# +# Set some default verbose +# +/control/verbose 2 +/control/saveHistory +/run/verbose 2 +# +# Change the default number of threads (in multi-threaded mode) +#/run/numberOfThreads 4 +# +# Initialize kernel +/run/initialize +# +# create empty scene +# +/vis/scene/create +# open graphics (opengl QT) +/vis/open OGL diff --git a/detectors/Modular/vis.mac b/detectors/Modular/vis.mac new file mode 100644 index 00000000..a38dbf19 --- /dev/null +++ b/detectors/Modular/vis.mac @@ -0,0 +1,85 @@ +# $Id: vis.mac,v 1.4 2010/04/14 18:32:59 lindenle Exp $ +# +# Macro file for the initialization phase of "exampleN03.cc" +# when running in interactive mode +# +# Sets some default verbose +# +/control/verbose 2 +/control/saveHistory +/run/verbose 2 +# +# create empty scene +# +/vis/scene/create +# +# Create a scene handler for a specific graphics system +# (Edit the next line(s) to choose another graphic system) +# +# Use this open statement to get an .eps and .prim files +# suitable for viewing in DAWN. +###/vis/open DAWNFILE +# +# Use this open statement instead for OpenGL in immediate mode. +# OGLIX works on the desktops in 1008 while OGLSX terminates +# the X server. I've heard similar stories about OGLIX on other +# machines. You might have to play with it. GEANT prints out a +# list of available graphics systems at some point. +#/vis/open OGLIX +/vis/open OGL 1800x1000-0+0 +# increase display limit for more complex detectors +/vis/ogl/set/displayListLimit 5000000 +/vis/viewer/set/viewpointThetaPhi 260 -40 +/vis/viewer/addCutawayPlane 0 0 0 m 1 0 0 +/vis/viewer/addCutawayPlane 0 0 0 m 0 -1 0 +/vis/viewer/panTo 50 0 cm + +# our world is 4x4 meters, the detector is about 1m across +# zooming by 4 makes it fill the display +/vis/viewer/zoom 2 + +# Draw trajectories at end of event, showing trajectory points as +# markers of size 2 pixels + +/vis/scene/add/trajectories smooth rich +# remove low energy stuff +/vis/filtering/trajectories/create/attributeFilter +/vis/filtering/trajectories/attributeFilter-0/setAttribute IMag +/vis/filtering/trajectories/attributeFilter-0/addInterval 10 MeV 1000 GeV + +# /vis/modeling/trajectories/create/drawByParticleID +# /vis/modeling/trajectories/drawByParticleID-0/set e+ steelblue +# /vis/modeling/trajectories/drawByParticleID-0/set e- steelblue +# /vis/modeling/trajectories/drawByParticleID-0/set pi+ red +# /vis/modeling/trajectories/drawByParticleID-0/set pi- red +# /vis/modeling/trajectories/drawByParticleID-0/set kaon- mediumvioletred +# /vis/modeling/trajectories/drawByParticleID-0/set kaon+ mediumvioletred +# /vis/modeling/trajectories/drawByParticleID-0/set kaon0 mediumvioletred +# /vis/modeling/trajectories/drawByParticleID-0/set proton+ orange +# /vis/modeling/trajectories/drawByParticleID-0/set proton- orange +# /vis/modeling/trajectories/drawByParticleID-0/set neutron lightgrey +# /vis/modeling/trajectories/drawByParticleID-0/set gamma wheat + +# remove neutrons and neutrinos +/vis/filtering/trajectories/create/particleFilter +/vis/filtering/trajectories/particleFilter-0/add neutron +/vis/filtering/trajectories/particleFilter-0/add neutrino +/vis/filtering/trajectories/particleFilter-0/invert true + +# /vis/modeling/trajectories/create/drawByCharge +# /vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true +# /vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2 +# (if too many tracks cause core dump => /tracking/storeTrajectory 0) +# +/vis/scene/endOfEventAction accumulate +# +# At end of each run, an automatic flush causes graphical output. +#/run/beamOn 1 +# When you exit Geant4, you will find a file called scene-0.heprep.zip. +# Unzipping this will give you three separate HepRep files suitable for +# viewing in WIRED. +# The first file will contain just detector geometry. +# The second file will contain the detector plus one event. +# The third file will contain the detector plus ten events. + +/vis/viewer/flush