@@ -59,88 +59,6 @@ Detector::Detector()
5959{
6060}
6161
62- // _________________________________________________________________________________________________
63- void Detector::buildFT3FromFile (std::string configFileName)
64- {
65- // Geometry description from file. One line per disk
66- // z_layer r_in r_out Layerx2X0
67- // This simple file reader is not failproof. Do not add empty lines!
68-
69- /*
70- # Sample FT3 configuration
71- # z_layer r_in r_out Layerx2X0
72- -45.3 2.5 9.26 0.0042
73- -46.7 2.5 9.26 0.0042
74- -48.6 2.5 9.8 0.0042
75- -50.0 2.5 9.8 0.0042
76- -52.4 2.5 10.43 0.0042
77- -53.8 2.5 10.43 0.0042
78- -67.7 3.82 13.01 0.0042
79- -69.1 3.82 13.01 0.0042
80- -76.1 3.92 14.35 0.0042
81- -77.5 3.92 14.35 0.0042
82- */
83-
84- mLayerID .clear ();
85-
86- LOG (info) << " Building FT3 Detector: From file" ;
87- LOG (info) << " FT3 detector configuration: " << configFileName;
88- std::ifstream ifs (configFileName.c_str ());
89- if (!ifs.good ()) {
90- LOG (fatal) << " Invalid FT3Base.configFile!" ;
91- }
92- std::string tempstr;
93- float z_layer, r_in, r_out, Layerx2X0;
94- char delimiter;
95- int layerNumber = 0 ;
96- while (std::getline (ifs, tempstr)) {
97- if (tempstr[0 ] == ' #' ) {
98- LOG (info) << " Comment: " << tempstr;
99- continue ;
100- }
101- std::istringstream iss (tempstr);
102- iss >> z_layer;
103- iss >> r_in;
104- iss >> r_out;
105- iss >> Layerx2X0;
106-
107- const int direction = z_layer < 0 ? IdxBackwardDisks : IdxForwardDisks;
108- std::string directionName = std::to_string (direction);
109- std::string layerName = GeometryTGeo::getFT3LayerPattern () + directionName + std::string (" _" ) + std::to_string (layerNumber);
110- mLayerName [direction].push_back (layerName);
111- LOG (info) << " Adding Layer " << layerName << " at z = " << z_layer << " ; direction = " << direction << " ; r_in = " << r_in << " ; r_out = " << r_out << " x/X0 = " << Layerx2X0;
112- const bool isMiddleLayer = layerNumber < 3 ;
113- auto & thisLayer = mLayers [direction].emplace_back (direction, layerNumber, layerName, z_layer, r_in, r_out, Layerx2X0, isMiddleLayer);
114- layerNumber++;
115- }
116-
117- LOG (info) << " Loaded FT3 Detector with " << layerNumber << " layers" ;
118- }
119-
120- // _________________________________________________________________________________________________
121- void Detector::exportLayout ()
122- {
123- // Export FT3 Layout description to file.
124- // One line per disk:
125- // z_layer r_in r_out Layerx2X0
126-
127- std::string configFileName = " FT3_layout.cfg" ;
128-
129- LOG (info) << " Exporting FT3 Detector layout to " << configFileName;
130-
131- std::ofstream fOut (configFileName.c_str (), std::ios::out);
132- if (!fOut ) {
133- printf (" Cannot open file\n " );
134- return ;
135- }
136- fOut << " # z_layer r_in r_out Layerx2X0" << std::endl;
137- for (auto layers_dir : mLayers ) {
138- for (auto layer : layers_dir) {
139- fOut << layer.getZ () << " " << layer.getInnerRadius () << " " << layer.getOuterRadius () << " " << layer.getx2X0 () << std::endl;
140- }
141- }
142- }
143-
14462// _________________________________________________________________________________________________
14563void Detector::buildBasicFT3 (const FT3BaseParam& param)
14664{
@@ -360,13 +278,17 @@ void Detector::buildFT3ScopingV3()
360278 LayerConfig{150 ., 20.0 , 68 .f , layersx2X0},
361279 LayerConfig{180 ., 20.0 , 68 .f , layersx2X0},
362280 LayerConfig{220 ., 20.0 , 68 .f , layersx2X0}};
281+ const std::array<bool , numberOfLayers> enabled{true , true , true , true , true , true }; // To enable or disable layers for debug purpose
363282
364283 mLayerID .clear ();
365284
366285 for (int direction : {IdxBackwardDisks, IdxForwardDisks}) {
367286 mLayerName [direction].clear ();
368287 const std::array<LayerConfig, numberOfLayers>& layerConfig = (direction == IdxBackwardDisks) ? layersConfigCSide : layersConfigASide;
369288 for (int layerNumber = 0 ; layerNumber < numberOfLayers; layerNumber++) {
289+ if (!enabled[layerNumber]) {
290+ continue ;
291+ }
370292 const std::string directionName = std::to_string (direction);
371293 const std::string layerName = GeometryTGeo::getFT3LayerPattern () + directionName + std::string (" _" ) + std::to_string (layerNumber);
372294 mLayerName [direction].push_back (layerName.c_str ());
@@ -438,24 +360,17 @@ Detector::Detector(bool active)
438360 // FT3 Base configuration parameters
439361 auto & ft3BaseParam = FT3BaseParam::Instance ();
440362
441- if (ft3BaseParam.configFile != " " ) {
442- LOG (info) << " FT3 Geometry configuration file provided. Overriding FT3Base.geoModel configuration." ;
443- buildFT3FromFile (ft3BaseParam.configFile );
444-
445- } else {
446- switch (ft3BaseParam.geoModel ) {
447- case Default:
448- buildFT3ScopingV3 (); // v3 Dec 25
449- break ;
450- case Telescope:
451- buildBasicFT3 (ft3BaseParam); // BasicFT3 = Parametrized telescopic detector (equidistant layers)
452- break ;
453- default :
454- LOG (fatal) << " Invalid Geometry.\n " ;
455- break ;
456- }
363+ switch (ft3BaseParam.geoModel ) {
364+ case Default:
365+ buildFT3ScopingV3 (); // v3 Dec 25
366+ break ;
367+ case Telescope:
368+ buildBasicFT3 (ft3BaseParam); // BasicFT3 = Parametrized telescopic detector (equidistant layers)
369+ break ;
370+ default :
371+ LOG (fatal) << " Invalid Geometry.\n " ;
372+ break ;
457373 }
458- exportLayout ();
459374}
460375
461376// _________________________________________________________________________________________________
@@ -679,67 +594,39 @@ void Detector::createGeometry()
679594 }
680595
681596 // This will need to adapt to the new scheme
682- if (mLayers .size () == 2 ) { // V1 and telescope
683- if (!A3IPvac) {
684- for (int direction : {IdxBackwardDisks, IdxForwardDisks}) { // Backward layers at mLayers[0]; Forward layers at mLayers[1]
685- const std::string directionString = direction ? " Forward" : " Backward" ;
686- LOG (info) << " Creating FT3 without beampipe " << directionString << " layers:" ;
687- for (int iLayer = 0 ; iLayer < mLayers [direction].size (); iLayer++) {
688- mLayers [direction][iLayer].createLayer (volFT3);
689- }
690- }
691- vALIC->AddNode (volFT3, 2 , new TGeoTranslation (0 ., 30 ., 0 .));
692- } else { // If beampipe is enabled append inner disks to beampipe filling volume, this should be temporary.
693- for (int direction : {IdxBackwardDisks, IdxForwardDisks}) {
694- const std::string directionString = direction ? " Forward" : " Backward" ;
695- LOG (info) << " Creating FT3 " << directionString << " layers:" ;
696- for (int iLayer = 0 ; iLayer < mLayers [direction].size (); iLayer++) {
697- LOG (info) << " Creating " << directionString << " layer " << iLayer;
698- if (mLayers [direction][iLayer].getIsInMiddleLayer ()) { // ML disks
699- mLayers [direction][iLayer].createLayer (volIFT3);
700- } else {
701- mLayers [direction][iLayer].createLayer (volFT3);
702- }
703- }
704- }
705- A3IPvac->AddNode (volIFT3, 2 , new TGeoTranslation (0 ., 0 ., 0 .));
706- vALIC->AddNode (volFT3, 2 , new TGeoTranslation (0 ., 30 ., 0 .));
707- }
708-
709- for (auto direction : {IdxBackwardDisks, IdxForwardDisks}) {
710- std::string directionString = direction ? " Forward" : " Backward" ;
711- LOG (info) << " Registering FT3 " << directionString << " LayerIDs for " << mLayers [direction].size () << " layers:" ;
597+ if (!A3IPvac) {
598+ for (int direction : {IdxBackwardDisks, IdxForwardDisks}) { // Backward layers at mLayers[0]; Forward layers at mLayers[1]
599+ const std::string directionString = direction ? " Forward" : " Backward" ;
600+ LOG (info) << " Creating FT3 without beampipe " << directionString << " layers:" ;
712601 for (int iLayer = 0 ; iLayer < mLayers [direction].size (); iLayer++) {
713- auto layerID = gMC ? TVirtualMC::GetMC ()->VolId (Form (" %s_%d_%d" , GeometryTGeo::getFT3SensorPattern (), direction, iLayer)) : 0 ;
714- mLayerID .push_back (layerID);
715- LOG (info) << " " << directionString << " layer " << iLayer << " LayerID " << layerID;
602+ mLayers [direction][iLayer].createLayer (volFT3);
716603 }
717604 }
718- }
719-
720- if (mLayers .size () == 1 ) { // All layers registered at mLayers[0], used when building from file
721- LOG (info) << " Creating FT3 layers:" ;
722- if (A3IPvac) {
723- for (int iLayer = 0 ; iLayer < mLayers [0 ].size (); iLayer++) {
724- if (std::abs (mLayers [0 ][iLayer].getZ ()) < 25 ) {
725- mLayers [0 ][iLayer].createLayer (volIFT3);
605+ vALIC->AddNode (volFT3, 2 , new TGeoTranslation (0 ., 30 ., 0 .));
606+ } else { // If beampipe is enabled append inner disks to beampipe filling volume, this should be temporary.
607+ for (int direction : {IdxBackwardDisks, IdxForwardDisks}) {
608+ const std::string directionString = direction ? " Forward" : " Backward" ;
609+ LOG (info) << " Creating FT3 " << directionString << " layers:" ;
610+ for (int iLayer = 0 ; iLayer < mLayers [direction].size (); iLayer++) {
611+ LOG (info) << " Creating " << directionString << " layer " << iLayer;
612+ if (mLayers [direction][iLayer].getIsInMiddleLayer ()) { // ML disks
613+ mLayers [direction][iLayer].createLayer (volIFT3);
726614 } else {
727- mLayers [0 ][iLayer].createLayer (volFT3);
615+ mLayers [direction ][iLayer].createLayer (volFT3);
728616 }
729617 }
730- A3IPvac->AddNode (volIFT3, 2 , new TGeoTranslation (0 ., 0 ., 0 .));
731- vALIC->AddNode (volFT3, 2 , new TGeoTranslation (0 ., 30 ., 0 .));
732- } else {
733- for (int iLayer = 0 ; iLayer < mLayers [0 ].size (); iLayer++) {
734- mLayers [0 ][iLayer].createLayer (volFT3);
735- }
736- vALIC->AddNode (volFT3, 2 , new TGeoTranslation (0 ., 30 ., 0 .));
737618 }
738- LOG (info) << " Registering FT3 LayerIDs:" ;
739- for (int iLayer = 0 ; iLayer < mLayers [0 ].size (); iLayer++) {
740- auto layerID = gMC ? TVirtualMC::GetMC ()->VolId (Form (" %s_%d_%d" , GeometryTGeo::getFT3SensorPattern (), 0 , iLayer)) : 0 ;
619+ A3IPvac->AddNode (volIFT3, 2 , new TGeoTranslation (0 ., 0 ., 0 .));
620+ vALIC->AddNode (volFT3, 2 , new TGeoTranslation (0 ., 30 ., 0 .));
621+ }
622+
623+ for (auto direction : {IdxBackwardDisks, IdxForwardDisks}) {
624+ std::string directionString = direction ? " Forward" : " Backward" ;
625+ LOG (info) << " Registering FT3 " << directionString << " LayerIDs for " << mLayers [direction].size () << " layers:" ;
626+ for (int iLayer = 0 ; iLayer < mLayers [direction].size (); iLayer++) {
627+ auto layerID = gMC ? TVirtualMC::GetMC ()->VolId (Form (" %s_%d_%d" , GeometryTGeo::getFT3SensorPattern (), direction, iLayer)) : 0 ;
741628 mLayerID .push_back (layerID);
742- LOG (info) << " mLayerID[ " << iLayer << " ] = " << layerID;
629+ LOG (info) << " " << directionString << " layer " << iLayer << " LayerID " << layerID;
743630 }
744631 }
745632}
0 commit comments