ATLAS Offline Software
TileAtlasFactory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "TileAtlasFactory.h"
7 #include "TileGeoCutBuilder.h"
11 
12 #include "CaloIdentifier/TileID.h"
13 
14 #include "GeoModelKernel/GeoPcon.h"
15 #include "GeoModelKernel/GeoTube.h"
16 #include "GeoModelKernel/GeoTubs.h"
17 #include "GeoModelKernel/GeoTrd.h"
18 #include "GeoModelKernel/GeoShapeUnion.h"
19 #include "GeoModelKernel/GeoShapeShift.h"
20 #include "GeoModelKernel/GeoShapeSubtraction.h"
21 #include "GeoModelKernel/GeoMaterial.h"
22 #include "GeoModelKernel/GeoLogVol.h"
23 #include "GeoModelKernel/GeoPhysVol.h"
24 #include "GeoModelKernel/GeoNameTag.h"
25 #include "GeoModelKernel/GeoTransform.h"
26 #include "GeoModelKernel/GeoSerialIdentifier.h"
27 #include "GeoModelKernel/GeoIdentifierTag.h"
28 #include "GeoModelKernel/GeoDefinitions.h"
29 
31 #include "GeoGenericFunctions/AbsFunction.h"
32 #include "GeoGenericFunctions/Variable.h"
33 #include "GeoModelKernel/GeoXF.h"
34 #include "GeoModelKernel/GeoSerialTransformer.h"
35 
37 #include "StoreGate/StoreGateSvc.h"
38 
39 #include "GaudiKernel/MsgStream.h"
40 #include "GaudiKernel/SystemOfUnits.h"
42 
43 #include <stdexcept>
44 #include <iostream>
45 #include <iomanip>
46 #include <algorithm>
47 #include <cmath>
48 #include <string>
49 
50 #define MLOG(x) if (m_log->level()<=MSG::x) *m_log << MSG::x
51 
52 using namespace GeoGenfun;
53 using namespace GeoXF;
54 
55 
56 // Constructor:
59  const TileSwitches & switches,
60  MsgStream *log,
61  bool fullGeo)
62  : m_detectorStore(pDetStore)
63  , m_detectorManager(manager)
64  , m_log(log)
65  , m_switches(switches)
66  , m_verbose(log->level()<=MSG::VERBOSE)
67  , m_fullGeo(fullGeo)
68 {
69  m_switches.testBeam = false;
70 }
71 
72 // Constructor:
75  const TileSwitches & switches,
76  const std::vector<std::string> & volumeNames,
77  std::vector<GeoPhysVol *> & volumePtrs,
78  const std::vector<double> & volumePositions,
79  MsgStream *log,
80  bool fullGeo)
81  : m_detectorStore(pDetStore)
82  , m_detectorManager(manager)
83  , m_log(log)
84  , m_switches(switches)
85  , m_volumeNames(volumeNames)
86  , m_volumePtrs(volumePtrs)
87  , m_volumePositions(volumePositions)
88  , m_verbose(log->level()<=MSG::VERBOSE)
89  , m_fullGeo(fullGeo)
90 {
91  m_switches.testBeam = false;
92 }
93 
94 
95 // Destructor:
97 
98 
99 // Creation of geometry:
100 void TileAtlasFactory::create(GeoPhysVol *world)
101 {
102  // Global geometri definition for debugging
103  bool Filling = true;
104  bool EBC = true /* Negative */, BAR = true /* Barrel */, EBA = true /* Positive */;
105  int NcpFrom = 1, NcpPlus = 63; // Default is all [1-63]
106 
107  //int NcpFrom = 34, NcpPlus = 29; // ext.barrel, special
108 
109  double deltaPhi = 360./64; // we know apriory that 64 modules makes full cylinder
110  double AnglMin = (NcpFrom-1)*deltaPhi*Gaudi::Units::deg, AnglMax = (NcpPlus+1)*deltaPhi*Gaudi::Units::deg;
111 
112  // phi range of modules with special C10
113  // double AnglMin1 = 38. * deltaPhi*Gaudi::Units::deg;
114  // double AnglMax1 = 42. * deltaPhi*Gaudi::Units::deg;
115  // double AnglMin2 = 54. * deltaPhi*Gaudi::Units::deg;
116  // double AnglMax2 = 58. * deltaPhi*Gaudi::Units::deg;
117 
118  (*m_log) << MSG::INFO <<" Entering TileAtlasFactory::create()" << endmsg;
119 
120  // -------- -------- MATERIAL MANAGER -------- ----------
121  StoredMaterialManager* theMaterialManager = nullptr;
122  if (StatusCode::SUCCESS != m_detectorStore->retrieve(theMaterialManager, "MATERIALS")) {
123  (*m_log) << MSG::ERROR << "Could not find Material Manager MATERIALS" << endmsg;
124  return;
125  }
126  const GeoMaterial* matAir = theMaterialManager->getMaterial("std::Air");
127  const GeoMaterial* matIron = theMaterialManager->getMaterial("std::Iron");
128  //const GeoMaterial* matAlu = theMaterialManager->getMaterial("std::Aluminium");
129 
130  // -------- -------- SECTION BUILDER -------- ----------
132  TileGeoSectionBuilder* sectionBuilder = new TileGeoSectionBuilder(theMaterialManager,dbManager,m_switches,m_log);
133 
134  double DzSaddleSupport = 0, RadiusSaddle = 0;
135  if (dbManager->BoolSaddle()) {
136  (*m_log) << MSG::INFO << " Tile Geometry with Saddle supports, starting from TileCal-CSC-02 xxx"<< endmsg;
137 
138  dbManager->SetCurrentSaddle(0);
139 
140  DzSaddleSupport = dbManager->DzSaddleSupport()*Gaudi::Units::cm;
141  RadiusSaddle = dbManager->RadiusSaddle()*Gaudi::Units::cm;
142  if (m_log->level()<=MSG::DEBUG)
143  (*m_log) << MSG::DEBUG << " DzSaddleSupport()= "<<DzSaddleSupport<<" RadiusSaddle= "<<RadiusSaddle
144  << endmsg;
145  }
146 
147  if (m_log->level()<=MSG::DEBUG) {
148  (*m_log) <<MSG::DEBUG << "TileAtlasFactory. addPlates = " <<m_switches.addPlatesToCell<<endmsg;
149  (*m_log) <<MSG::DEBUG << "TileAtlasFactory. crackOption = " <<m_switches.crackOption<<endmsg;
150  }
151  int barrel_flag = m_switches.crackOption/10; // >0 - no barrel, >1 - no ext.bar, >2-no ITC, >3-no Gap, >4-no Crack
152  int crack_flag = m_switches.crackOption%10;
153  if (barrel_flag == 5) crack_flag = 9; // nothing will be created if barrel_flag is 5
154  if (crack_flag == 4 || crack_flag == 5) barrel_flag = 4; // only one crack is created, nothing else
155  bool eb_flag = (barrel_flag<4 || (barrel_flag==4 && crack_flag==0) ); // true if ext.barrel envelope is needed
156  if (m_log->level()<=MSG::DEBUG) {
157  (*m_log) << MSG::DEBUG << "barrel_flag " << barrel_flag << endmsg;
158  (*m_log) << MSG::DEBUG << "crack_flag " << crack_flag << endmsg;
159  }
160 
161  // -------- -------- CUT BUILDER -------- ----------
162  //TileGeoCutBuilder* CutBuilder = new TileGeoCutBuilder(theMaterialManager,dbManager,m_log);
163 
164  // --------------- TILE ------- TILE --------- TILE ---------- TILE ------------
165  // Envelope creation. Building three tree tops for standard setup and only one for commissioning
166  GeoLogVol *lvTileEnvelopeBarrel =0, *lvTileEnvelopePosEndcap =0, *lvTileEnvelopeNegEndcap =0, *lvTileEnvelopePosCrack =0, *lvTileEnvelopeNegCrack =0;
167  GeoPhysVol *pvTileEnvelopeBarrel =0, *pvTileEnvelopePosEndcap =0, *pvTileEnvelopeNegEndcap =0, *pvTileEnvelopePosCrack =0, *pvTileEnvelopeNegCrack =0;
168 
169  if (crack_flag==2) {
170  if ( m_volumeNames.size()<1 ) {
171  (*m_log) <<MSG::WARNING << "Top-level volume names for crack scintillators are missing"<<endmsg;
172  (*m_log) <<MSG::WARNING << "Crack scintillators will not be built"<<endmsg;
173  crack_flag = 9;
174  } else {
175  GeoVolumeVec_t vols = geoGetVolumes (&*world);
176  for (auto v : vols) {
177  if (v.first->getLogVol()->getName() == m_volumeNames[0] ) {
178  GeoPhysVol* tmpPV ATLAS_THREAD_SAFE = (GeoPhysVol *)(v.first);
179  pvTileEnvelopePosCrack = tmpPV;
180  }
181  else if (m_volumeNames.size()>1 && v.first->getLogVol()->getName() == m_volumeNames[1] ) {
182  GeoPhysVol* tmpPV ATLAS_THREAD_SAFE = (GeoPhysVol *)(v.first);
183  pvTileEnvelopeNegCrack = tmpPV;
184  }
185  }
186  }
187  } else if (crack_flag==3) {
188  if ( m_volumePtrs.size()<1 ) {
189  (*m_log) <<MSG::WARNING << "Top-level volume pointers for crack scintillators are missing"<<endmsg;
190  (*m_log) <<MSG::WARNING << "Crack scintillators will not be built"<<endmsg;
191  crack_flag = 9;
192  } else {
193  pvTileEnvelopePosCrack = m_volumePtrs[0];
194  if (m_volumePtrs.size()>1) pvTileEnvelopeNegCrack = m_volumePtrs[1];
195  }
196  } else if (crack_flag==4) {
197  pvTileEnvelopePosCrack = world;
198  } else if (crack_flag==5) {
199  pvTileEnvelopeNegCrack = world;
200  }
201 
202  if (pvTileEnvelopePosCrack || pvTileEnvelopeNegCrack) {
203  (*m_log) <<MSG::DEBUG << "Top-level volume names for crack scintillators are "
204  << " positive: " << ( (pvTileEnvelopePosCrack) ? pvTileEnvelopePosCrack->getLogVol()->getName() : "none" )
205  << " negative: " << ( (pvTileEnvelopeNegCrack) ? pvTileEnvelopeNegCrack->getLogVol()->getName() : "none" )
206  << endmsg;
207  } else if (crack_flag==2) {
208  (*m_log) <<MSG::WARNING << "Top-level volume names for crack scintillators "
209  << ((m_volumeNames.size()>0) ? m_volumeNames[0] : "") << " "
210  << ((m_volumeNames.size()>1) ? m_volumeNames[1] : "") << " "
211  << " were not found" << endmsg;
212  (*m_log) <<MSG::WARNING << "Crack scintillators will not be built"<<endmsg;
213  (*m_log) <<MSG::WARNING << "Available top-level volumes are:";
214  GeoVolumeVec_t vols = geoGetVolumes (&*world);
215  for (auto v : vols) (*m_log) << " " << v.first->getLogVol()->getName();
216  (*m_log) <<endmsg;
217  crack_flag = 9;
218  }
219 
220  // radius for minimization overlap volumes
221  double rless =0.15; // 150 [mkm]
222 
223  double dzITC1 =0, rMinITC1 =0, rMaxITC1 =0;
224  double dzITC2 =0, rMinITC2 =0, rMaxITC2 =0;
225 
226  double thicknessWedgeMother =0, heightWedgeMother =0, dy1WedgeMother =0, dy2WedgeMother =0;
227  double Glue =0, dzGlue =0; //Thickness of glue layer in the absorber
228  int NbPeriod =0;
229  double zEndSection =0;
230 
231  // Positioning coordinates
232  double X =0, Z =0;
233  double zITCStandard =0;
234 
235  double ZLength[] = {0.0,0.0,0.0,0.0,0.0,0.0};
236  double EnvDZPos[] = {0.0,0.0,0.0,0.0,0.0,0.0};
237  double PhiMax[] = {-360.0,-360.0,-360.0,-360.0,-360.0,-360.0};
238  double PhiMin[] = {+360.0,+360.0,+360.0,+360.0,+360.0,+360.0};
239  double RInMin[] = {99999.9,99999.9,99999.9,99999.9,99999.9,99999.9};
240  double ROutMax[] = {0.0,0.0,0.0,0.0,0.0,0.0};
241  double FingerRmax = 0;
242  //unsigned int ienv_size = 6;
243 
244  // set default finger length
245  double BFingerLength =0;
246  double BFingerLengthNeg =0;
247  double BFingerLengthPos =0;
248 
249  // Barrel finger
250  dbManager->SetCurrentTifg(1);
251  BFingerLength = BFingerLengthNeg = BFingerLengthPos = dbManager->TIFGdz()*Gaudi::Units::cm;
252 
253  double EBFingerLength =0;
254  double EBFingerLengthNeg =0;
255  double EBFingerLengthPos =0;
256 
257  // EBarrel finger
258  dbManager->SetCurrentTifg(2);
259  EBFingerLength = EBFingerLengthNeg = EBFingerLengthPos = dbManager->TIFGdz()*Gaudi::Units::cm;
260 
261  int n_env = dbManager->GetNumberOfEnv();
262 
263  //std::cerr <<std::cout.setf(std::ios::right)<<std::setiosflags(std::ios::fixed)<<std::setw(9)<<std::setprecision(2);
264 
265  if (m_log->level()<=MSG::DEBUG)
266  (*m_log) << MSG::DEBUG << "n_env " << n_env << endmsg;
267 
268  for (int i = 0; i < n_env ; ++i) {
269  dbManager->SetCurrentEnvByIndex(i);
270  int Type = dbManager->GetEnvType();
271 
272  /*
273  if (Type == 1) BAR = true;
274  if (Type == 2) EBC = true;
275  if (Type == 3) EBA = true;
276  */
277 
278  ZLength [Type] = dbManager->GetEnvZLength()*Gaudi::Units::cm;
279  EnvDZPos [Type] = dbManager->GetEnvDZ()*Gaudi::Units::cm;
280  PhiMin [Type] = std::min(PhiMin[Type], dbManager->GetEnvDPhi());
281  PhiMax [Type] = std::max(PhiMax[Type], dbManager->GetEnvNModules()*deltaPhi + dbManager->GetEnvDPhi());
282  RInMin [Type] = std::min(RInMin[Type], dbManager->GetEnvRin()*Gaudi::Units::cm);
283  ROutMax [Type] = std::max(ROutMax[Type],dbManager->GetEnvRout()*Gaudi::Units::cm);
284  FingerRmax = std::max(FingerRmax,dbManager->GetEnvRout()*Gaudi::Units::cm);
285 
286  //std::cout << "# Type " <<Type<< " ZLength " <<ZLength [Type]<< " EnvDZPos "<<EnvDZPos [Type]<< "\n";
287  }
288 
289  //
290  // recalculate length of positive barrel finger length if Ext.Barrel is present
291  //
292 
293  double PosDelta =0;
294  PosDelta = EnvDZPos[3] - EnvDZPos[1];
295  if (m_log->level()<=MSG::DEBUG)
296  (*m_log) << MSG::DEBUG <<" BFingerLengthPos "<<BFingerLengthPos<<" PosDelta "<<PosDelta;
297  if (std::abs(PosDelta) < std::abs(EBFingerLength - BFingerLength) ) {
298  BFingerLengthPos += PosDelta;
299  if (m_log->level()<=MSG::DEBUG)
300  (*m_log) <<" => New BFingerLengthPos "<<BFingerLengthPos<<endmsg;
301  } else {
303  BFingerLengthPos = BFingerLength;
304  PosDelta =0;
305  if (m_log->level()<=MSG::DEBUG)
306  (*m_log) <<" => New PosDelta "<<PosDelta<<endmsg;
307  }
308 
309  //
310  // recalculate length of negative barrel finger length if Ext.Barrel is present
311  //
312 
313  double NegDelta =0;
314  NegDelta = (-EnvDZPos[2] + EnvDZPos[1]); // negative shift - bigger finger
315  if (m_log->level()<=MSG::DEBUG)
316  (*m_log) << MSG::DEBUG <<" BFingerLengthNeg "<<BFingerLengthNeg<<" NegDelta "<<NegDelta;
317  if (std::abs(NegDelta) < std::abs(EBFingerLength - BFingerLength) ) {
318  BFingerLengthNeg += NegDelta;
319  if (m_log->level()<=MSG::DEBUG)
320  (*m_log) <<" => New BFingerLengthNeg "<<BFingerLengthNeg<<endmsg;
321  } else {
323  BFingerLengthNeg = BFingerLength;
324  NegDelta =0;
325  if (m_log->level()<=MSG::DEBUG)
326  (*m_log) <<" => New NegDelta "<<NegDelta<<endmsg;
327  }
328 
329  // extra flag sayubg that special C10 goes outside envelope for normal C10
330  bool spC10 = false;
332  double rMinC10 = dbManager->TILBrminimal();
333  if ( dbManager->SetCurrentSection(10+TileDddbManager::TILE_PLUG2, false) ) {
334  double rMinC10sp = dbManager->TILBrminimal();
335  spC10 = (rMinC10sp < rMinC10);
336  if (spC10) {
337  (*m_log) << MSG::DEBUG <<" Special C10, changing Rmin from "<<rMinC10<<" to "<< rMinC10sp << endmsg;
338  rMinC10 = rMinC10sp;
339  }
340  }
341 
343  double rMinE2pos = dbManager->TILBrminimal();
344  double rMinE2neg = rMinE2pos;
345 
346  // extra flag sayubg that E4' present on negative eta side
347  bool spE4 = false;
349  double rMinE4pos = dbManager->TILBrminimal();
350  double rMinE4neg = rMinE4pos;
351  double rMaxE3pos = dbManager->TILBrmaximal();
352  double rMaxE3neg = rMaxE3pos;
353  if ( dbManager->SetCurrentSection(10+TileDddbManager::TILE_PLUG4, false) ) {
354  double rMinE4sp = dbManager->TILBrminimal();
355  spE4 = (rMinE4sp < rMinE4neg);
356  if (spE4) {
357  (*m_log) << MSG::DEBUG <<" E4' present, changing Rmin for negative crack from "<<rMinE4neg<<" to "<< rMinE4sp << endmsg;
358  rMinE4neg = rMinE4sp;
359  }
360  }
361 
363  double BFingerRmin=0, EFingerRmin=0;
365  BFingerRmin = dbManager->TILBrmax()*Gaudi::Units::cm;
367  EFingerRmin = dbManager->TILBrmax()*Gaudi::Units::cm;
368 
369  // ??? Is this needed?
370  dbManager->SetCurrentEnvByType(2);
371 
372 
373  //
374  // Central Barrel
375  //
376 
377  // Z planes
378  double endCentralBarrel = ZLength[1]/2 - BFingerLength; // nominal position of end plate
379  double endEnvelopeNeg = endCentralBarrel + BFingerLengthNeg;
380  double endEnvelopePos = endCentralBarrel + BFingerLengthPos;
381 
382  // R minimal
383  double rminBarrel = RInMin[1];
384 
385  // R maximal
386  double rmaxTotal = ROutMax[1];
387 
388  if (barrel_flag<1) { // >0 - no central barrel
389 
390  GeoPcon* tileEnvPconeBarrel = new GeoPcon(PhiMin[1]*Gaudi::Units::deg, PhiMax[1]*Gaudi::Units::deg);
391 
392  tileEnvPconeBarrel->addPlane(-endEnvelopeNeg, BFingerRmin, rmaxTotal);
393  tileEnvPconeBarrel->addPlane(-endCentralBarrel-DzSaddleSupport, BFingerRmin, rmaxTotal);
394  if (dbManager->BoolSaddle()) {
395  tileEnvPconeBarrel->addPlane(-endCentralBarrel-DzSaddleSupport, BFingerRmin-RadiusSaddle,rmaxTotal);
396  tileEnvPconeBarrel->addPlane(-endCentralBarrel, BFingerRmin-RadiusSaddle,rmaxTotal);
397  }
398  tileEnvPconeBarrel->addPlane(-endCentralBarrel, rminBarrel, rmaxTotal);
399  tileEnvPconeBarrel->addPlane( endCentralBarrel, rminBarrel, rmaxTotal);
400  if (dbManager->BoolSaddle()) {
401  tileEnvPconeBarrel->addPlane( endCentralBarrel, BFingerRmin-RadiusSaddle,rmaxTotal);
402  tileEnvPconeBarrel->addPlane( endCentralBarrel+DzSaddleSupport, BFingerRmin-RadiusSaddle,rmaxTotal);
403  }
404  tileEnvPconeBarrel->addPlane( endCentralBarrel+DzSaddleSupport, BFingerRmin, rmaxTotal);
405  tileEnvPconeBarrel->addPlane( endEnvelopePos, BFingerRmin, rmaxTotal);
406 
407  lvTileEnvelopeBarrel = new GeoLogVol("TileCentralBarrel",tileEnvPconeBarrel,matAir);
408  pvTileEnvelopeBarrel = new GeoPhysVol(lvTileEnvelopeBarrel);
409 
410  }
411 
412  //
413  // Pos Ext. Barrel
414  //
415 
416  // Z planes
417  double PosEndBarrelFinger = ZLength[1]/2; // nominal end of barrel finger
418  double PosEndITC = PosEndBarrelFinger + ZLength[5];
419  double PosEndExBarrelFinger = PosEndITC + ZLength[3];
420  double PosEndExBarrel = PosEndExBarrelFinger - EBFingerLengthPos;
421 
422  if (m_log->level()<=MSG::DEBUG) {
423  (*m_log) << MSG::DEBUG
424  << " EBPos EnvDZPos[3] " << EnvDZPos[3] << " ZLength[5] " <<ZLength[5]<<"+"<<ZLength[3]
425  << " = " << ZLength[3]+ZLength[5] << " EBFingerLengthPos = " <<EBFingerLengthPos
426  <<endmsg;
427 
428  (*m_log) << MSG::DEBUG << " PosEndBarrelFinger = " << PosEndBarrelFinger
429  << " PosEndITC = " << PosEndITC
430  << " PosEndExBarrel = " << PosEndExBarrel
431  << " PosEndExtBarrelFinger = " << PosEndExBarrelFinger
432  << endmsg;
433  }
434 
436  double PosEndITC1 = (dbManager->TILBzoffset() + dbManager->TILEzshift() + dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
437  double corr = PosEndITC - PosEndITC1;
438  if (std::abs(corr)>0.01) {
439  (*m_log) << MSG::WARNING
440  << "Discrepancy between TileGlobals and TILB tables in GeoModel DB "
441  << PosEndITC << " != " << PosEndITC1 << "; take this into account"
442  <<endmsg;
443  }
444 
445  //double beginITC1 = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()-dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
447  double PosBeginITC2 = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()-dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
449  double PosBeginGap = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()-dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
450  double PosEndGap = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()+dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
452  double PosBeginCrack = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()-dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
453  double PosEndCrack = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()+dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
454 
455  if (!spC10) { // recovering old (wrong) positioning of gap scintillators
456  double GapWidth = PosEndGap - PosBeginGap;
457  PosBeginGap = PosBeginCrack + 0.9 * Gaudi::Units::cm;
458  PosEndGap = PosBeginGap + GapWidth;
459  }
460 
461  if (m_log->level()<=MSG::DEBUG)
462  (*m_log) << MSG::DEBUG << " PosBeginITC2 = " << PosBeginITC2
463  << " PosBeginGap = " << PosBeginGap
464  << " PosEndGap = " << PosEndGap
465  << " PosBeginCrack = " << PosBeginCrack
466  << " PosEndCrack = " << PosEndCrack
467  << endmsg;
468 
469  // R minimals
471  double PosRminITC1 = dbManager->TILBrminimal()*Gaudi::Units::cm;
473  double PosRminITC = rMinC10 /* dbManager->TILBrminimal() */ *Gaudi::Units::cm;
475  double PosRminGap = rMinE2pos*Gaudi::Units::cm;
477  double PosRminCrack = rMinE4pos*Gaudi::Units::cm;
478  double PosRmaxCrack = rMaxE3pos*Gaudi::Units::cm;
479 
480  double PosRminExt = RInMin[3];
481 
482  // R maximal
483  double PosRmaxTotal = ROutMax[3];
484 
485  if (m_log->level()<=MSG::DEBUG)
486  (*m_log) << MSG::DEBUG
487  << " PosRminITC1 = " << PosRminITC1
488  << " PosRminITC2 = " << PosRminITC
489  << " PosRminGap = " << PosRminGap
490  << " PosRmaxCrack = " << PosRmaxCrack
491  << " PosRminCrack = " << PosRminCrack
492  << " PosRminExt = " << PosRminExt
493  << " PosRmaxTotal = " << PosRmaxTotal
494  << endmsg;
495 
496  if (eb_flag) {
497 
498  GeoPcon* tileEnvPconePosEndcap = new GeoPcon(PhiMin[3]*Gaudi::Units::deg, PhiMax[3]*Gaudi::Units::deg);
499 
500  // Positive Endcap
501  tileEnvPconePosEndcap->addPlane(PosEndBarrelFinger, PosRminITC1, PosRmaxTotal);
502  tileEnvPconePosEndcap->addPlane(PosBeginITC2, PosRminITC1, PosRmaxTotal);
503  tileEnvPconePosEndcap->addPlane(PosBeginITC2, PosRminITC, PosRmaxTotal);
504  if (crack_flag>0) {
505  // endcap volume without crack scintillators
506  tileEnvPconePosEndcap->addPlane(PosBeginGap, PosRminITC, PosRmaxTotal);
507  tileEnvPconePosEndcap->addPlane(PosBeginGap, PosRminGap, PosRmaxTotal);
508  tileEnvPconePosEndcap->addPlane(PosEndGap, PosRminGap, PosRmaxTotal);
509  tileEnvPconePosEndcap->addPlane(PosEndGap, PosRminExt, PosRmaxTotal);
510  } else {
511  // endcap volume with crack scintillators
512  tileEnvPconePosEndcap->addPlane(PosBeginCrack, PosRminITC, PosRmaxTotal);
513  tileEnvPconePosEndcap->addPlane(PosBeginCrack, PosRminCrack, PosRmaxTotal);
514  tileEnvPconePosEndcap->addPlane(PosEndCrack, PosRminCrack, PosRmaxTotal);
515  tileEnvPconePosEndcap->addPlane(PosEndCrack, PosRminExt, PosRmaxTotal);
516  }
517  tileEnvPconePosEndcap->addPlane(PosEndExBarrel, PosRminExt, PosRmaxTotal);
518  if (dbManager->BoolSaddle()) {
519  tileEnvPconePosEndcap->addPlane(PosEndExBarrel, EFingerRmin-RadiusSaddle, PosRmaxTotal);
520  tileEnvPconePosEndcap->addPlane(PosEndExBarrel+DzSaddleSupport, EFingerRmin-RadiusSaddle, PosRmaxTotal);
521  }
522  tileEnvPconePosEndcap->addPlane(PosEndExBarrel+DzSaddleSupport, EFingerRmin, PosRmaxTotal);
523  tileEnvPconePosEndcap->addPlane(PosEndExBarrelFinger, EFingerRmin, PosRmaxTotal);
524 
525  lvTileEnvelopePosEndcap = new GeoLogVol("TileEndcapPos",tileEnvPconePosEndcap,matAir);
526  pvTileEnvelopePosEndcap = new GeoPhysVol(lvTileEnvelopePosEndcap);
527 
528  }
529 
530  if (crack_flag==1) {
531  // Positive Crack as separate volume
532  GeoPcon* tileEnvPconePosCrack = new GeoPcon(PhiMin[3]*Gaudi::Units::deg, PhiMax[3]*Gaudi::Units::deg);
533 
534  tileEnvPconePosCrack->addPlane(PosBeginCrack, PosRminCrack, PosRmaxCrack);
535  tileEnvPconePosCrack->addPlane(PosEndCrack, PosRminCrack, PosRmaxCrack);
536 
537  lvTileEnvelopePosCrack = new GeoLogVol("TileCrackPos",tileEnvPconePosCrack,matAir);
538  pvTileEnvelopePosCrack = new GeoPhysVol(lvTileEnvelopePosCrack);
539  }
540 
541  //
542  // Neg Ex Barrel
543  //
544 
545  // Z planes
546  double NegEndBarrelFinger = ZLength[1]/2; // nominal end of barrel finger
547  double NegEndITC = NegEndBarrelFinger + ZLength[4];
548  double NegEndExtBarrelFinger = NegEndITC + ZLength[2];
549  double NegEndExBarrel = NegEndExtBarrelFinger - EBFingerLengthNeg;
550 
551  if (m_log->level()<=MSG::DEBUG) {
552  (*m_log) << MSG::DEBUG
553  << " EBNeg EnvDZPos[2] " << EnvDZPos[2] << " ZLength[4] " <<ZLength[4]<<"+"<<ZLength[2]
554  << " = " << ZLength[2]+ZLength[4] << " EBFingerLengthNeg = " <<EBFingerLengthNeg
555  <<endmsg;
556 
557  (*m_log) << MSG::DEBUG << " NegEndBarrelFinger = " << NegEndBarrelFinger
558  << " NegEndITC = " << NegEndITC
559  << " NegEndExBarrel = " << NegEndExBarrel
560  << " NegEndExtBarrelFinger = " << NegEndExtBarrelFinger
561  << endmsg;
562  }
563 
565  double NegEndITC1 = (dbManager->TILBzoffset() + dbManager->TILEzshift() + dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
566  corr = NegEndITC - NegEndITC1;
567 
568  if (std::abs(corr)>0.01) {
569  (*m_log) << MSG::WARNING
570  << "Discrepancy between TileGlobals and TILB tables in GeoModel DB "
571  << NegEndITC << " != " << NegEndITC1 << "; take this into account"
572  << endmsg;
573  }
574  //double NegBeginITC1 = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()-dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
576  double NegBeginITC2 = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()-dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
578  double NegBeginGap = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()-dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
579  double NegEndGap = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()+dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
581  double NegBeginCrack = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()-dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
582  double NegEndCrack = corr + (dbManager->TILBzoffset() + dbManager->TILEzshift()+dbManager->TILBdzmodul()/2)*Gaudi::Units::cm;
583 
584  if (!spC10) { // recovering old (wrong) positioning of gap scintillators
585  double GapWidth = NegEndGap - NegBeginGap;
586  NegBeginGap = NegBeginCrack + 0.9 * Gaudi::Units::cm;
587  NegEndGap = NegBeginGap + GapWidth;
588  }
589 
590  if (m_log->level()<=MSG::DEBUG)
591  (*m_log) << MSG::DEBUG << " NegBeginITC2 = " << NegBeginITC2
592  << " NegBeginGap = " << NegBeginGap
593  << " NegEndGap = " << NegEndGap
594  << " NegBeginCrack = " << NegBeginCrack
595  << " NegEndCrack = " << NegEndCrack
596  << endmsg;
597 
598  // R minimals
600  double NegRminITC1 = dbManager->TILBrminimal()*Gaudi::Units::cm;
602  double NegRminITC = rMinC10 /* dbManager->TILBrminimal() */ *Gaudi::Units::cm;
604  double NegRminGap = rMinE2neg*Gaudi::Units::cm;
606  double NegRminCrack = rMinE4neg*Gaudi::Units::cm;
607  double NegRmaxCrack = rMaxE3neg*Gaudi::Units::cm;
609 
610  double NegRminExt = RInMin[2];
611 
612  // R maximal
613  double NegRmaxTotal = ROutMax[2];
614 
615  if (m_log->level()<=MSG::DEBUG)
616  (*m_log) << MSG::DEBUG
617  << " NegRminITC1 = " << NegRminITC1
618  << " NegRminITC2 = " << NegRminITC
619  << " NegRminGap = " << NegRminGap
620  << " NegRmaxCrack = " << NegRmaxCrack
621  << " NegRminCrack = " << NegRminCrack
622  << " NegRminExt = " << NegRminExt
623  << " NegRmaxTotal = " << NegRmaxTotal
624  << endmsg;
625 
626  if (eb_flag) {
627 
628  GeoPcon* tileEnvPconeNegEndcap = new GeoPcon(PhiMin[2]*Gaudi::Units::deg, PhiMax[2]*Gaudi::Units::deg);
629 
630  // Negative Endcap
631  tileEnvPconeNegEndcap->addPlane(-NegEndExtBarrelFinger, EFingerRmin, NegRmaxTotal);
632  tileEnvPconeNegEndcap->addPlane(-NegEndExBarrel-DzSaddleSupport, EFingerRmin, NegRmaxTotal);
633  if (dbManager->BoolSaddle()) {
634  tileEnvPconeNegEndcap->addPlane(-NegEndExBarrel-DzSaddleSupport, EFingerRmin-RadiusSaddle, NegRmaxTotal);
635  tileEnvPconeNegEndcap->addPlane(-NegEndExBarrel, EFingerRmin-RadiusSaddle, NegRmaxTotal);
636  }
637  tileEnvPconeNegEndcap->addPlane(-NegEndExBarrel, NegRminExt, NegRmaxTotal);
638  if (crack_flag>0) {
639  // endcap volume without crack scintillators
640  tileEnvPconeNegEndcap->addPlane(-NegEndGap, NegRminExt, NegRmaxTotal);
641  tileEnvPconeNegEndcap->addPlane(-NegEndGap, NegRminGap, NegRmaxTotal);
642  tileEnvPconeNegEndcap->addPlane(-NegBeginGap, NegRminGap, NegRmaxTotal);
643  tileEnvPconeNegEndcap->addPlane(-NegBeginGap, NegRminITC, NegRmaxTotal);
644  } else {
645  // endcap volume with crack scintillators
646  tileEnvPconeNegEndcap->addPlane(-NegEndCrack, NegRminExt, NegRmaxTotal);
647  tileEnvPconeNegEndcap->addPlane(-NegEndCrack, NegRminCrack, NegRmaxTotal);
648  tileEnvPconeNegEndcap->addPlane(-NegBeginCrack, NegRminCrack, NegRmaxTotal);
649  tileEnvPconeNegEndcap->addPlane(-NegBeginCrack, NegRminITC, NegRmaxTotal);
650  }
651  tileEnvPconeNegEndcap->addPlane(-NegBeginITC2, NegRminITC, NegRmaxTotal);
652  tileEnvPconeNegEndcap->addPlane(-NegBeginITC2, NegRminITC1, NegRmaxTotal);
653  tileEnvPconeNegEndcap->addPlane(-NegEndBarrelFinger, NegRminITC1, NegRmaxTotal);
654 
655  lvTileEnvelopeNegEndcap = new GeoLogVol("TileEndcapNeg",tileEnvPconeNegEndcap,matAir);
656  pvTileEnvelopeNegEndcap = new GeoPhysVol(lvTileEnvelopeNegEndcap);
657 
658  }
659 
660  if (crack_flag==1) {
661  // Negative Crack as separate volume
662  GeoPcon* tileEnvPconeNegCrack = new GeoPcon(PhiMin[3]*Gaudi::Units::deg, PhiMax[3]*Gaudi::Units::deg);
663 
664  tileEnvPconeNegCrack->addPlane(-NegEndCrack, NegRminCrack, NegRmaxCrack);
665  tileEnvPconeNegCrack->addPlane(-NegBeginCrack, NegRminCrack, NegRmaxCrack);
666 
667  lvTileEnvelopeNegCrack = new GeoLogVol("TileCrackNeg",tileEnvPconeNegCrack,matAir);
668  pvTileEnvelopeNegCrack = new GeoPhysVol(lvTileEnvelopeNegCrack);
669  }
670 
671  // --------------- Configure Section Builder for the Reco geometry --------------------
672  if (!m_fullGeo || barrel_flag!=0) {
673  // Central barrel part
674  dbManager->SetCurrentSectionByNumber(1);
675 
676  dzGlue = (dbManager->TILBdzmodul() - dbManager->TILBdzend1() - dbManager->TILBdzend2()
677  - (dbManager->TILBnperiod()*2.*(dbManager->TILBdzmast() + dbManager->TILBdzspac())
678  - dbManager->TILBdzmast()))/(2.*(2.*dbManager->TILBnperiod() - 1));
679 
680  // TODO: apparently, the value set with the call below is not used: it seems m_barrelPeriodThickness is recomputed inside the GeoSectionBuilder's code; so, the call below is probably useless...
681  sectionBuilder->setBarrelPeriodThickness(2.*(dbManager->TILBdzmast() + dbManager->TILBdzspac() + 2.*dzGlue)*Gaudi::Units::cm);
682  sectionBuilder->setBarrelGlue(dzGlue*Gaudi::Units::cm); // TODO: it's probably the same, here...
683 
684  // Ext barrel part
685  dbManager->SetCurrentSectionByNumber(2);
686 
687  dzGlue = (dbManager->TILBdzmodul() - dbManager->TILBdzend1() - dbManager->TILBdzend2()
688  - dbManager->TILBnperiod()*2.*(dbManager->TILBdzmast() + dbManager->TILBdzspac()))/(4.*dbManager->TILBnperiod());
689 
690  // TODO: apparently, the value set with the call below is not used: it seems m_extendedPeriodThickness is recomputed inside the GeoSectionBuilder's code; so, the call below is probably useless...
691  sectionBuilder->setExtendedPeriodThickness(2.*(dbManager->TILBdzmast() + dbManager->TILBdzspac() + 2.*dzGlue)*Gaudi::Units::cm);
692  }
693 
694  GeoPhysVol *pvBarrelMother{nullptr}, *pvFingerMotherNeg{nullptr}, *pvFingerMotherPos{nullptr}, *pvSaddleMotherNeg{nullptr}, *pvSaddleMotherPos{nullptr};
695  GeoPhysVol *pvEBarrelMotherNeg{nullptr}, *pvEBarrelMotherPos{nullptr};
696  GeoPhysVol *pvEFingerMotherNeg{nullptr}, *pvEFingerMotherPos{nullptr}, *pvESaddleMotherNeg{nullptr}, *pvESaddleMotherPos{nullptr};
697  GeoPhysVol *pvITCMotherNeg{nullptr}, *pvITCMotherPos{nullptr};
698  GeoPhysVol *pvGapMotherNeg{nullptr}, *pvGapMotherPos{nullptr};
699  GeoPhysVol *pvCrackMotherNeg{nullptr}, *pvCrackMotherPos{nullptr};
700 
701  GeoLogVol *lvEBarrelModuleMotherPos{nullptr}, *lvEBarrelModuleMotherNeg{nullptr};
702  GeoPhysVol *pvEBarrelModuleMotherPos{nullptr}, *pvEBarrelModuleMotherNeg{nullptr};
703 
704  /*
705  GeoPhysVol *pvTmp_EBarrelModuleMotherPos =0,*pvTmL_EBarrelModuleMotherPos =0,*pvTmR_EBarrelModuleMotherPos =0;
706  GeoPhysVol *pvTmp_EBarrelModuleMotherNeg =0,*pvTmL_EBarrelModuleMotherNeg =0,*pvTmR_EBarrelModuleMotherNeg =0;
707  */
708 
709  //GeoCutVolAction *action1 =0, *action2 =0, *action3 =0;
710  // -----------------------------------------------------------------------------------------------------------------
711  //
712  // All volumes which absolute forme EnvCounter loop
713  //
714  // -----------------------------------------------------------------------------------------------------------------
715  double dX1 =0, dX2 =0, dY1 =0, dY2 =0, dZ1 =0, dZ2 =0;
716  double dxIron =0, dyIron =0, dxIr =0, dyIr =0;
717  std::string volname ="";
718 
719  // Cuting positioning
720  double PosXcut =0, PosYcut =0, PosY =0;
721  double modl_length =0;
722 
723  const GeoShapeUnion *CutA= 0;
724  GeoShape *CutB= 0;
725 
726  GeoLogVol *lvIrUp =0, *lvIrDw =0, *lvIron3 =0, *lvIron2 =0, *lvIron1 =0, *lvIrBox =0;
727  GeoPhysVol *pvIrUp =0, *pvIrDw =0, *pvIron3 =0, *pvIron2 =0, *pvIron1 =0, *pvIrBox =0;
728 
729  if (m_fullGeo) {
730 
731  // ext. barrel Cuts description
732  if (dbManager->BoolCuts()) {
733  if (m_log->level()<=MSG::DEBUG)
734  (*m_log) << MSG::DEBUG << " Tile Geometry with Ext.Barrel CutOuts and Iron plates, starting form TileCal-CSC-01"
735  << endmsg;
736 
737  volname = "CutB"; dbManager->SetCurrentCuts(volname);
738  PosXcut = dbManager->CutsXpos();
739  PosYcut = dbManager->CutsYpos();
740  modl_length = 4*dbManager->CutsDX1();
741 
742  // Inert materials, CutB1
743  dX1 = dbManager->CutsDX1();
744  dX2 = dbManager->CutsDX2();
745  dY1 = dbManager->CutsDY1();
746  dY2 = dbManager->CutsDY2();
747  dZ1 = dbManager->CutsDZ1();
748 
749  checking("CutB1", false, 1, dX1,dX2,dY1,dY2,dZ1);
750  GeoTrd* CutB1 = new GeoTrd(dX1,dX2,dY1,dY2,dZ1);
751  //const GeoShape& CutB = *CutB1;
752  CutB = CutB1;
753 
754  // Inert materials which are in cuts, special modules
755  // Materials are in cuting region, up Iron plate
756  volname = "IrUp"; dbManager->SetCurrentCuts(volname);
757  dX1 = dbManager->CutsDX1();
758  dX2 = dbManager->CutsDX2();
759  dY1 = dbManager->CutsDY1();
760  dY2 = dbManager->CutsDY2();
761  dZ1 = dbManager->CutsDZ1();
762 
763  checking("IrUp", false, 1,dX1,dX2,dY1,dY2,dZ1);
764  GeoTrd* IrUp = new GeoTrd(dX1,dX2,dY1,dY2,dZ1);
765  lvIrUp = new GeoLogVol("IrUp",IrUp,matIron);
766  pvIrUp = new GeoPhysVol(lvIrUp);
767 
768  // Materials are in cuting region, down Iron plate
769  volname = "IrDw"; dbManager->SetCurrentCuts(volname);
770  dX1 = dbManager->CutsDX1();
771  dX2 = dbManager->CutsDX2();
772  dY1 = dbManager->CutsDY1();
773  dY2 = dbManager->CutsDY2();
774  dZ1 = dbManager->CutsDZ1();
775 
776  checking("IrDw", false, 1, dX1,dX2,dY1,dY2,dZ1);
777  GeoTrd* IrDw = new GeoTrd(dX1,dX2,dY1,dY2,dZ1);
778  lvIrDw = new GeoLogVol("IrDw",IrDw,matIron);
779  pvIrDw = new GeoPhysVol(lvIrDw);
780 
781  // Materials are in cuting region, 1up Iron plate
782  volname = "Cut1up"; dbManager->SetCurrentCuts(volname); //>>
783  PosY = dbManager->CutsYpos();
784 
785  dX1 = dbManager->CutsDX1();
786  dX2 = dbManager->CutsDX2();
787  dY1 = dbManager->CutsDY1();
788  dY2 = dbManager->CutsDY2();
789  dZ1 = dbManager->CutsDZ1();
790 
791  checking("Cut1up", false, 1, dX1,dX2,dY1,dY2,dZ1);
792  GeoTrd* Cut1up = new GeoTrd(dX1,dX2,dY1,dY2,dZ1);
793 
794  volname = "Cut2down"; dbManager->SetCurrentCuts(volname); //>>
795  dX1 = dbManager->CutsDX1();
796  dX2 = dbManager->CutsDX2();
797  dY1 = dbManager->CutsDY1();
798  dY2 = dbManager->CutsDY2();
799  dZ2 = dbManager->CutsDZ1();
800 
801  checking("Cut2down", false, 1, dX1,dX2,dY1,dY2,dZ2);
802  GeoTrd* Cut1down = new GeoTrd(dX1,dX2,dY1,dY2,dZ2);
803 
804  GeoTrf::Translate3D yPosA(0.,0.,-dZ1-dZ2);
805 
806  const GeoShapeUnion& CutA1 = Cut1up->add(*Cut1down<<yPosA);
807  CutA = &CutA1;
808 
809  /*
810  |----------> X
811  |---------------------------------------| (Xdown, -Ydown)
812  | (3) |
813  |---------------------------------------| (2) (Xdown, -Ymiddle)
814  / CutA \
815  |-------------------------------------------| (1) (Xup, -Yup)
816 
817  GeoSimplePolygonBrep *BREP = new GeoSimplePolygonBrep(length/2);
818  BREP->addVertex( Xup, -Yup );
819  BREP->addVertex( Xdown, -Ymiddle);
820  BREP->addVertex( Xdown, -Ydown );
821  BREP->addVertex(-Xdown, -Ydown );
822  BREP->addVertex(-Xdown, -Ymiddle);
823  BREP->addVertex(-Xup, -Yup );
824  const GeoShape& ShapeCut2 = *BREP;
825  */
826 
827  // Inert materials which are in cuts, special modules
828  // Materials are in cuting region, down Iron plate (3)
829  volname = "Iron3"; dbManager->SetCurrentCuts(volname); //>>
830  dX1 = dbManager->CutsDX1();
831  dX2 = dbManager->CutsDX2();
832  dY1 = dbManager->CutsDY1();
833  dY2 = dbManager->CutsDY2();
834  dZ1 = dbManager->CutsDZ1();
835 
836  checking("Iron3", false, 1, dX1,dX2,dY1,dY2,dZ1);
837  GeoTrd* Iron3 = new GeoTrd(dX1,dX2,dY1,dY2,dZ1);
838  lvIron3 = new GeoLogVol("Iron3",Iron3,matIron);
839  pvIron3 = new GeoPhysVol(lvIron3);
840 
841  // Materials are in cuting region, down Iron plate (2)
842  volname = "Iron2"; dbManager->SetCurrentCuts(volname); //>>
843  dX1 = dbManager->CutsDX1();
844  dX2 = dbManager->CutsDX2();
845  dY1 = dbManager->CutsDY1();
846  dY2 = dbManager->CutsDY2();
847  dZ1 = dbManager->CutsDZ1();
848 
849  checking("Iron2", false, 1, dX1,dX2,dY1,dY2,dZ1);
850  GeoTrd* Iron2 = new GeoTrd(dX1,dX2,dY1,dY2,dZ1);
851  lvIron2 = new GeoLogVol("Iron2",Iron2,matIron);
852  pvIron2 = new GeoPhysVol(lvIron2);
853 
854  // Materials are in cuting region, down Iron plate (1)
855  volname = "Iron1"; dbManager->SetCurrentCuts(volname); //>>
856  dX1 = dbManager->CutsDX1();
857  dX2 = dbManager->CutsDX2();
858  dY1 = dbManager->CutsDY1();
859  dY2 = dbManager->CutsDY2();
860  dZ1 = dbManager->CutsDZ1();
861 
862  checking("Iron1", false, 1, dX1,dX2,dY1,dY2,dZ1);
863  GeoTrd* Iron1 = new GeoTrd(dX1,dX2,dY1,dY2,dZ1);
864  lvIron1 = new GeoLogVol("Iron1",Iron1,matIron);
865  pvIron1 = new GeoPhysVol(lvIron1);
866 
867  // Materials are in cuting region, Heavy Iron Box
868  volname = "IrBox"; dbManager->SetCurrentCuts(volname); //>>
869  dX1 = dbManager->CutsDX1();
870  dX2 = dbManager->CutsDX2();
871  dY1 = dbManager->CutsDY1();
872  dY2 = dbManager->CutsDY2();
873  dZ1 = dbManager->CutsDZ1();
874 
875  checking("IrBox", false, 1, dX1,dX2,dY1,dY2,dZ1);
876  GeoTrd* IrBox = new GeoTrd(dX1,dX2,dY1,dY2,dZ1);
877  lvIrBox = new GeoLogVol("IrBox",IrBox,matIron);
878  pvIrBox = new GeoPhysVol(lvIrBox);
879 
880  /*
881  |<-->|----- |Xdown - Xup|
882  (Xdown,-Ymiddle) /| ^
883  / | |
884  (Xup, / | | CutB
885  |----------> X | | |
886  (Xup,-Yup) | | |
887  \ | |
888  \ | |- |Ydown - Ymiddle|
889  (Xdown,-Ydown) \| ---
890  (Ydown+|Ydown-Ymiddle|/2)-Yup
891  Y position = Ydown+|Ydown-Ymiddle|/2
892 
893  GeoSimplePolygonBrep *BREP = new GeoSimplePolygonBrep(length/4);
894  BREP->addVertex( Xup, -Yup );
895  BREP->addVertex( Xdown, -Ydown );
896  BREP->addVertex( Xdown, -Ymiddle);
897  BREP->addVertex(-Xdown, -Ymiddle);
898  BREP->addVertex(-Xdown, -Ydown );
899  BREP->addVertex(-Xup, -Yup );
900  const GeoShape& ShapeCut1 = *BREP;
901  */
902  } // end if, BoolCuts
903  }
904 
905  int NumberOfEnv = dbManager->GetNumberOfEnv();
906  MLOG(DEBUG) << "NumberOfEnv: " << NumberOfEnv << endmsg;
907 
908  for (int EnvCounter = 0; EnvCounter < NumberOfEnv ; ++EnvCounter) { // Loop over Envelopes
909 
910  dbManager->SetCurrentEnvByIndex(EnvCounter);
911  int EnvType = dbManager->GetEnvType();
912  dbManager->SetCurrentEnvByType(EnvType);
913  int NumberOfMod = dbManager->GetEnvNModules();
914 
915  // Break for debugging
916  //if (EnvType != 3) continue;
917 
918  if (m_log->level()<=MSG::DEBUG)
919  (*m_log) << MSG::DEBUG << " EnvCounter " << EnvCounter << " EnvType " << EnvType
920  << " EnvNModules " << NumberOfMod << endmsg;
921 
922  if (EnvType == 1 && barrel_flag < 1) {
923  // nominal position of end plate
924  zEndSection = ZLength[1]/2 - BFingerLength;
925 
926  GeoTubs* GeneralMother = new GeoTubs(dbManager->GetEnvRin()*Gaudi::Units::cm,
927  dbManager->GetEnvRout()*Gaudi::Units::cm,
928  zEndSection,
929  AnglMin, AnglMax);
930 
931  GeoTubs* barrelMother = GeneralMother;
932  GeoLogVol* lvBarrelMother = new GeoLogVol("Barrel",barrelMother,matAir);
933  pvBarrelMother = new GeoPhysVol(lvBarrelMother);
934 
935  if (m_log->level()<=MSG::DEBUG)
936  (*m_log) << MSG::DEBUG << "Barrel envelope parameters: "
937  << " Length=" << zEndSection
938  << " Rmin=" << dbManager->GetEnvRin()*Gaudi::Units::cm
939  << " Rmax=" << dbManager->GetEnvRout()*Gaudi::Units::cm
940  << endmsg;
941 
942  // Envelopes for two barrel fingers, positive finger
943  GeoTubs* fingerMotherPos = new GeoTubs(BFingerRmin,
944  dbManager->GetEnvRout()*Gaudi::Units::cm,
945  BFingerLengthPos/2,
946  AnglMin, AnglMax);
947 
948  GeoLogVol* lvFingerMotherPos = new GeoLogVol("FingerPos",fingerMotherPos,matAir);
949  pvFingerMotherPos = new GeoPhysVol(lvFingerMotherPos);
950 
951  if (dbManager->BoolSaddle()) { // Envelopes for barrel saddle supports, positive
952  GeoTubs* SaddleMotherPos = new GeoTubs(BFingerRmin-RadiusSaddle,
953  BFingerRmin,
954  DzSaddleSupport/2,
955  AnglMin, AnglMax);
956 
957  GeoLogVol* lvSaddleMotherPos = new GeoLogVol("SaddlePos",SaddleMotherPos,matAir);
958  pvSaddleMotherPos = new GeoPhysVol(lvSaddleMotherPos);
959  }
960 
961  // Negative finger
962  GeoTubs* fingerMotherNeg = new GeoTubs(BFingerRmin,
963  dbManager->GetEnvRout()*Gaudi::Units::cm,
964  BFingerLengthNeg/2,
965  AnglMin, AnglMax);
966 
967  GeoLogVol* lvFingerMotherNeg = new GeoLogVol("FingerNeg",fingerMotherNeg,matAir);
968  pvFingerMotherNeg = new GeoPhysVol(lvFingerMotherNeg);
969 
970  if (m_log->level()<=MSG::DEBUG)
971  (*m_log) << MSG::DEBUG << "Barrel finger envelope parameters: "
972  << " length Pos/Neg=" << BFingerLengthPos << "/" << BFingerLengthNeg
973  << " Rmin=" << BFingerRmin << " Rmax=" << dbManager->GetEnvRout()*Gaudi::Units::cm
974  << endmsg;
975 
976  // Envelopes for two barrel saddle supports, positive
977  if (dbManager->BoolSaddle()) {
978  GeoTubs* SaddleMotherNeg = new GeoTubs(BFingerRmin-RadiusSaddle,
979  BFingerRmin,
980  DzSaddleSupport/2,
981  AnglMin, AnglMax);
982 
983  GeoLogVol* lvSaddleMotherNeg = new GeoLogVol("SaddleNeg",SaddleMotherNeg,matAir);
984  pvSaddleMotherNeg = new GeoPhysVol(lvSaddleMotherNeg);
985  }
986  }
987 
988  if (EnvType == 3 && eb_flag) {
989 
990  if (m_log->level()<=MSG::DEBUG)
991  (*m_log) << MSG::DEBUG <<" EBarrelPos DZ "<<(dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthPos)/2<< endmsg;
992 
993  checking("EBarrel (+)", false, 0,
994  dbManager->GetEnvRin()*Gaudi::Units::cm,dbManager->GetEnvRout()*Gaudi::Units::cm,
995  AnglMin,AnglMax,(dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthPos)/2);
996 
997  GeoTubs* GeneralMother = new GeoTubs(dbManager->GetEnvRin()*Gaudi::Units::cm,
998  dbManager->GetEnvRout()*Gaudi::Units::cm,
999  (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthPos)/2,
1000  AnglMin, AnglMax);
1001 
1002  GeoTubs* ebarrelMotherPos = GeneralMother;
1003  GeoLogVol* lvEBarrelMotherPos = new GeoLogVol("EBarrel",ebarrelMotherPos,matAir);
1004  pvEBarrelMotherPos = new GeoPhysVol(lvEBarrelMotherPos);
1005 
1006  if (m_log->level()<=MSG::DEBUG)
1007  (*m_log) << MSG::DEBUG << "Positive ext.barrel envelope parameters: "
1008  << " length=" << (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLength)
1009  << " Rmin=" << dbManager->GetEnvRin()*Gaudi::Units::cm
1010  << " Rmax=" << dbManager->GetEnvRout()*Gaudi::Units::cm
1011  << endmsg;
1012 
1013  if (barrel_flag < 2) {
1014  // Envelope for finger separately
1015  checking("EBarrel (+)", false, 0,
1016  EFingerRmin,dbManager->GetEnvRout()*Gaudi::Units::cm,
1017  AnglMin,AnglMax, EBFingerLength/2);
1018 
1019  GeoTubs* fingerMother = new GeoTubs(EFingerRmin,
1020  dbManager->GetEnvRout()*Gaudi::Units::cm,
1021  EBFingerLength/2,
1022  AnglMin, AnglMax);
1023 
1024  GeoLogVol* lvEFingerMother = new GeoLogVol("EFinger",fingerMother,matAir);
1025  pvEFingerMotherPos = new GeoPhysVol(lvEFingerMother);
1026 
1027  if (m_log->level()<=MSG::DEBUG)
1028  (*m_log) << MSG::DEBUG << "Positive ext.barrel finger envelope parameters: "
1029  << " length=" << EBFingerLength
1030  << " Rmin=" << EFingerRmin
1031  << " Rmax=" << (dbManager->GetEnvRout())*Gaudi::Units::cm
1032  << endmsg;
1033 
1034  if (dbManager->BoolSaddle()) { //Envelopes for two barrel saddle supports, positive
1035  checking("ESaddle (+)", false, 0,
1036  EFingerRmin-RadiusSaddle,EFingerRmin,AnglMin,AnglMax, DzSaddleSupport/2);
1037 
1038  GeoTubs* ESaddleMother = new GeoTubs(EFingerRmin-RadiusSaddle,
1039  EFingerRmin,
1040  DzSaddleSupport/2,
1041  AnglMin, AnglMax);
1042 
1043  GeoLogVol* lvESaddleMother = new GeoLogVol("ESaddlePos",ESaddleMother,matAir);
1044  pvESaddleMotherPos = new GeoPhysVol(lvESaddleMother);
1045  }
1046  }
1047  }
1048 
1049  // Negative Ext.Barrel
1050  if (EnvType == 2 && eb_flag) {
1051  if (m_log->level()<=MSG::DEBUG)
1052  (*m_log) << MSG::DEBUG <<" EBarrelNeg DZ "<<(dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthNeg)/2<< endmsg;
1053 
1054  GeoTubs* GeneralMother = new GeoTubs(dbManager->GetEnvRin()*Gaudi::Units::cm,
1055  dbManager->GetEnvRout()*Gaudi::Units::cm,
1056  (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthNeg)/2,
1057  AnglMin, AnglMax);
1058 
1059  GeoTubs* ebarrelMotherNeg = GeneralMother;
1060  GeoLogVol* lvEBarrelMotherNeg = new GeoLogVol("EBarrel",ebarrelMotherNeg,matAir);
1061  pvEBarrelMotherNeg = new GeoPhysVol(lvEBarrelMotherNeg);
1062 
1063  if (m_log->level()<=MSG::DEBUG)
1064  (*m_log) << MSG::DEBUG << "Nevative ext.barrel envelope parameters: "
1065  << " length=" << (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLength)
1066  << " Rmin=" << dbManager->GetEnvRin()*Gaudi::Units::cm
1067  << " Rmax=" << dbManager->GetEnvRout()*Gaudi::Units::cm
1068  << endmsg;
1069 
1070  if (barrel_flag < 2) {
1071  // Envelope for finger separately
1072  GeoTubs* fingerMother = new GeoTubs(EFingerRmin,
1073  dbManager->GetEnvRout()*Gaudi::Units::cm,
1074  EBFingerLengthNeg/2,
1075  AnglMin, AnglMax);
1076 
1077  GeoLogVol* lvEFingerMother = new GeoLogVol("EFinger",fingerMother,matAir);
1078  pvEFingerMotherNeg = new GeoPhysVol(lvEFingerMother);
1079 
1080  if (m_log->level()<=MSG::DEBUG)
1081  (*m_log) << MSG::DEBUG <<"Negative ext.barrel finger envelope parameters: "
1082  << " length=" << EBFingerLengthNeg
1083  << " Rmin=" << EFingerRmin
1084  << " Rmax=" << dbManager->GetEnvRout()*Gaudi::Units::cm
1085  << endmsg;
1086 
1087  if (dbManager->BoolSaddle()) { //Envelopes for Ext. barrel saddle supports, positive
1088  checking("ESaddle (-)", false, 0,
1089  EFingerRmin-RadiusSaddle,EFingerRmin,AnglMin,AnglMax, DzSaddleSupport/2);
1090 
1091  GeoTubs* ESaddleMother = new GeoTubs(EFingerRmin-RadiusSaddle,
1092  EFingerRmin,
1093  DzSaddleSupport/2,
1094  AnglMin, AnglMax);
1095 
1096  GeoLogVol* lvESaddleMother = new GeoLogVol("ESaddlePos",ESaddleMother,matAir);
1097  pvESaddleMotherNeg = new GeoPhysVol(lvESaddleMother);
1098  }
1099  }
1100  }
1101 
1102  // ITC Positive
1103  if (EnvType == 5) {
1104 
1105  if (barrel_flag < 3) { // allow ITC
1106 
1108 
1109  rMinITC2 = rMinC10; // dbManager->TILBrminimal();
1110  rMaxITC2 = dbManager->TILBrmaximal();
1111  dzITC2 = dbManager->TILBdzmodul();
1112 
1114 
1115  rMinITC1 = dbManager->TILBrminimal();
1116  rMaxITC1 = dbManager->TILErmam();
1117  dzITC1 = dbManager->TILBdzmodul();
1118 
1119  (*m_log) << MSG::INFO << " Positive ITC envelope parameters: PLUG1 "
1120  <<" Rmin= "<<rMinITC1*Gaudi::Units::cm<<" Rmax= "<<rMaxITC1*Gaudi::Units::cm<<" dzITC1= "<<dzITC1/2*Gaudi::Units::cm<< endmsg;
1121  (*m_log) << MSG::INFO << " PLUG2 "
1122  <<" Rmin= "<<rMinITC2*Gaudi::Units::cm<<" Rmax= "<<rMaxITC2*Gaudi::Units::cm<<" dzITC2= "<<dzITC2/2*Gaudi::Units::cm<< endmsg;
1123 
1124  checking("ITC itcWheel1 (+)", false, 0,
1125  rMinITC1*Gaudi::Units::cm,rMaxITC1*Gaudi::Units::cm, AnglMin,AnglMax, dzITC1/2*Gaudi::Units::cm);
1126 
1127  GeoTubs* itcWheel1 = new GeoTubs(rMinITC1*Gaudi::Units::cm,
1128  rMaxITC1*Gaudi::Units::cm,
1129  dzITC1/2*Gaudi::Units::cm,
1130  AnglMin, AnglMax);
1131 
1132  checking("ITC itcWheel2 (+)", false, 0,
1133  rMinITC2*Gaudi::Units::cm,rMaxITC2*Gaudi::Units::cm, AnglMin,AnglMax, dzITC2/2*Gaudi::Units::cm);
1134 
1135  GeoTubs* itcWheel2 = new GeoTubs(rMinITC2*Gaudi::Units::cm,
1136  rMaxITC2*Gaudi::Units::cm,
1137  dzITC2/2*Gaudi::Units::cm,
1138  AnglMin, AnglMax);
1139 
1140  Z = ( dzITC1 - dzITC2)/2*Gaudi::Units::cm;
1141  GeoTrf::Translate3D itcWheel2OffsetPos(0.,0., Z);
1142 
1143  zITCStandard = Z;
1144 
1145  const GeoShapeUnion& itcMotherPos = itcWheel1->add(*itcWheel2<<itcWheel2OffsetPos);
1146 
1147  GeoLogVol* lvITCMotherPos = new GeoLogVol("ITC",&itcMotherPos,matAir);
1148  pvITCMotherPos = new GeoPhysVol(lvITCMotherPos);
1149 
1150  }
1151 
1152  // Gap Positive
1153  if (barrel_flag < 4) { // allow Gap
1154 
1156 
1157  checking("Gap (+)", false, 0,
1158  dbManager->TILBrminimal()*Gaudi::Units::cm,
1160  AnglMin,AnglMax, dbManager->TILBdzmodul()/2*Gaudi::Units::cm);
1161 
1162  GeoTubs* GapMotherPos = new GeoTubs(dbManager->TILBrminimal()*Gaudi::Units::cm,
1164  dbManager->TILBdzmodul()/2*Gaudi::Units::cm,
1165  AnglMin, AnglMax);
1166 
1167  GeoLogVol* lvGapMotherPos = new GeoLogVol("Gap",GapMotherPos,matAir);
1168  pvGapMotherPos = new GeoPhysVol(lvGapMotherPos);
1169 
1170  }
1171 
1172  // Crack Positive
1173  if (crack_flag<=0 || pvTileEnvelopePosCrack) { // allow Crack
1174 
1176 
1177  checking("Crack (+)", spE4, 0,
1178  rMinE4pos*Gaudi::Units::cm,
1180  AnglMin,AnglMax, dbManager->TILBdzmodul()/2*Gaudi::Units::cm);
1181 
1182  GeoTubs* crackMotherPos = new GeoTubs(rMinE4pos*Gaudi::Units::cm,
1184  dbManager->TILBdzmodul()/2*Gaudi::Units::cm,
1185  AnglMin, AnglMax);
1186 
1187  GeoLogVol* lvCrackMotherPos = new GeoLogVol("Crack",crackMotherPos,matAir);
1188  pvCrackMotherPos = new GeoPhysVol(lvCrackMotherPos);
1189  }
1190  }
1191 
1192  // ITC Negative
1193  if (EnvType == 4) {
1194 
1195  if (barrel_flag < 3) { // allow ITC
1196 
1198 
1199  rMinITC2 = rMinC10; // dbManager->TILBrminimal();
1200  rMaxITC2 = dbManager->TILBrmaximal();
1201  dzITC2 = dbManager->TILBdzmodul();
1202 
1204 
1205  rMinITC1 = dbManager->TILBrminimal();
1206  rMaxITC1 = dbManager->TILErmam();
1207  dzITC1 = dbManager->TILBdzmodul();
1208 
1209  (*m_log) << MSG::INFO << " Negative ITC envelope parameters: PLUG1 "
1210  <<" Rmin= "<<rMinITC1*Gaudi::Units::cm<<" Rmax= "<<rMaxITC1*Gaudi::Units::cm<<" dzITC1= "<<dzITC1/2*Gaudi::Units::cm<<endmsg;
1211  (*m_log) << MSG::INFO << " PLUG2 "
1212  <<" Rmin= "<<rMinITC2*Gaudi::Units::cm<<" Rmax= "<<rMaxITC2*Gaudi::Units::cm<<" dzITC2= "<<dzITC2/2*Gaudi::Units::cm<<endmsg;
1213 
1214  checking("ITC itcWheel1 (-)", false, 0,
1215  rMinITC1*Gaudi::Units::cm,rMaxITC1*Gaudi::Units::cm, AnglMin,AnglMax, dzITC1/2*Gaudi::Units::cm);
1216 
1217  GeoTubs* itcWheel1 = new GeoTubs(rMinITC1*Gaudi::Units::cm,
1218  rMaxITC1*Gaudi::Units::cm,
1219  dzITC1/2*Gaudi::Units::cm,
1220  AnglMin, AnglMax);
1221 
1222  checking("ITC itcWheel2 (-)", false, 0,
1223  rMinITC2*Gaudi::Units::cm,rMaxITC2*Gaudi::Units::cm, AnglMin,AnglMax, dzITC2/2*Gaudi::Units::cm);
1224 
1225  GeoTubs* itcWheel2 = new GeoTubs(rMinITC2*Gaudi::Units::cm,
1226  rMaxITC2*Gaudi::Units::cm,
1227  dzITC2/2*Gaudi::Units::cm,
1228  AnglMin, AnglMax);
1229 
1230  Z = (-dzITC1 + dzITC2)/2*Gaudi::Units::cm;
1231  GeoTrf::Translate3D itcWheel2OffsetNeg(0.,0., Z);
1232 
1233  zITCStandard = Z;
1234 
1235  const GeoShapeUnion& itcMotherNeg = itcWheel1->add(*itcWheel2<<itcWheel2OffsetNeg);
1236 
1237  GeoLogVol* lvITCMotherNeg = new GeoLogVol("ITC",&itcMotherNeg,matAir);
1238  pvITCMotherNeg = new GeoPhysVol(lvITCMotherNeg);
1239 
1240  }
1241 
1242  // Gap Negative
1243  if (barrel_flag < 4) { // allow Gap
1244 
1246 
1247  checking("Gap (-)", false, 1,
1248  dbManager->TILBrminimal()*Gaudi::Units::cm,
1250  AnglMin,AnglMax, dbManager->TILBdzmodul()/2*Gaudi::Units::cm);
1251 
1252  GeoTubs* GapMotherNeg = new GeoTubs(dbManager->TILBrminimal()*Gaudi::Units::cm,
1254  dbManager->TILBdzmodul()/2*Gaudi::Units::cm,
1255  AnglMin, AnglMax);
1256 
1257  GeoLogVol* lvGapMotherNeg = new GeoLogVol("Gap",GapMotherNeg,matAir);
1258  pvGapMotherNeg = new GeoPhysVol(lvGapMotherNeg);
1259 
1260  }
1261 
1262  // Crack Negative
1263  if (crack_flag<=0 || pvTileEnvelopeNegCrack) { // allow Crack
1264 
1266 
1267  checking("Crack (-)", spE4, 0,
1268  rMinE4neg*Gaudi::Units::cm,
1270  AnglMin,AnglMax, dbManager->TILBdzmodul()/2*Gaudi::Units::cm);
1271 
1272  GeoTubs* crackMotherNeg = new GeoTubs(rMinE4neg*Gaudi::Units::cm,
1274  dbManager->TILBdzmodul()/2*Gaudi::Units::cm,
1275  AnglMin, AnglMax);
1276 
1277  GeoLogVol* lvCrackMotherNeg = new GeoLogVol("Crack",crackMotherNeg,matAir);
1278  pvCrackMotherNeg = new GeoPhysVol(lvCrackMotherNeg);
1279  }
1280  }
1281 
1282  if (m_fullGeo && (
1283  ((EnvType&6) == 0 && barrel_flag < 1) ||
1284  ((EnvType&6) == 2 && barrel_flag < 2) ||
1285  ((EnvType&6) == 4 && barrel_flag < 5) )) {
1286 
1287  // ModuleNumber[NumberOfMod] array for independent of positrion numeration
1288  int ModuleIndex[64];
1289  for (int i=0; i < NumberOfMod; i++) {
1290  ModuleIndex[i] = i+1;
1291  }
1292 
1293  // the main loop around all phi modules position
1294  int ModuleNcp =0;
1295 
1296  GeoIntrusivePtr<GeoTransform> yrotMod{new GeoTransform(GeoTrf::RotateY3D(90*Gaudi::Units::deg))};
1297  GeoIntrusivePtr<GeoTransform> XYrtMod{new GeoTransform(GeoTrf::RotateX3D(180*Gaudi::Units::deg) * GeoTrf::RotateY3D(90*Gaudi::Units::deg))};
1298 
1299  for (int ModCounter = 0; ModCounter < NumberOfMod; ModCounter++) {
1300 
1301  ModuleNcp = ModuleIndex[ModCounter];
1302 
1303  // General rotation and transformations
1304  double phi = (double(ModuleNcp-1) + 0.5)*deltaPhi;
1305  double ph1 = (double(ModuleNcp-1))*deltaPhi;
1306 
1307  GeoIntrusivePtr<GeoTransform> zrotMod{new GeoTransform(GeoTrf::RotateZ3D(phi*Gaudi::Units::deg))};
1308  GeoIntrusivePtr<GeoTransform> zrotSaddle{new GeoTransform(GeoTrf::RotateZ3D(ph1*Gaudi::Units::deg))};
1309 
1310  dbManager->SetCurrentModuleByIndex(ModuleNcp-1);
1311  int ModType = dbManager->GetModType();
1312  int ModFingpattern = dbManager->TILBfingpattern();
1313 
1314  // Debuging code for cuted modules
1315  if (!(ModuleNcp>=NcpFrom && ModuleNcp<=NcpFrom+NcpPlus)) continue;
1316 
1317  // special Modules with Cuts
1318  //if (ModuleNcp<35 || ModuleNcp>62) continue; if (ModuleNcp>37 && ModuleNcp<60) continue;
1319 
1320  // Saddle Supports
1321  //if (ModuleNcp<39 || ModuleNcp>58) continue; if (ModuleNcp>42 && ModuleNcp<55) continue;
1322 
1323  if (m_log->level()<=MSG::DEBUG)
1324  (*m_log) << MSG::DEBUG <<" ModuleNcp= "<< ModuleNcp <<" ModType "<< ModType <<" Phi "<< phi << endmsg;
1325 
1326  //
1327  // ------------------- BARREL BLOCKS ------------------------
1328  //
1329 
1330  if ( EnvType == 1 && barrel_flag < 1) { // normal barrel module or module zero
1331 
1332  dbManager->SetCurrentSectionByNumber(ModType);
1333 
1334  thicknessWedgeMother = dbManager->TILBdzmodul() * Gaudi::Units::cm;
1335  heightWedgeMother = (dbManager->TILBrmaximal() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
1336  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1337  dy2WedgeMother = dbManager->TILBrmaximal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1338 
1339  dzGlue = (dbManager->TILBdzmodul() - dbManager->TILBdzend1() - dbManager->TILBdzend2()
1340  - (dbManager->TILBnperiod()*2.*(dbManager->TILBdzmast() + dbManager->TILBdzspac())
1341  - dbManager->TILBdzmast()))/(2.*(2.*dbManager->TILBnperiod() - 1));
1342 
1343  GeoTrd* barrelModuleMother = new GeoTrd(thicknessWedgeMother/2,
1344  thicknessWedgeMother/2,
1345  dy1WedgeMother,
1346  dy2WedgeMother,
1347  heightWedgeMother/2);
1348 
1349  GeoLogVol* lvBarrelModuleMother = new GeoLogVol("BarrelModule",barrelModuleMother,matAir);
1350  GeoPhysVol* pvBarrelModuleMother = new GeoPhysVol(lvBarrelModuleMother);
1351 
1352  // Fill the section
1353  if (Filling) {
1354  sectionBuilder->fillSection(pvBarrelModuleMother, 1,
1355  dbManager->TILBrmaximal(),
1356  dbManager->TILBrminimal(),
1357  dzGlue,
1358  deltaPhi);
1359  }
1360 
1361  GeoTransform* xtraMod = new GeoTransform(GeoTrf::TranslateX3D(
1362  (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2 * Gaudi::Units::cm));
1363 
1364  pvBarrelMother->add(zrotMod);
1365  pvBarrelMother->add(xtraMod);
1366  pvBarrelMother->add(XYrtMod);
1367 
1368  pvBarrelMother->add(new GeoIdentifierTag(ModuleNcp));
1369  pvBarrelMother->add(pvBarrelModuleMother);
1370 
1371  // --------------------------BARREL FINGERS MAKING----------------------------
1372 
1373  dbManager->SetCurrentTifg(1); // Barrel finger
1374  zEndSection = dbManager->TILBzoffset() + dbManager->TILBdzmodul()/2;
1375 
1376  heightWedgeMother = (dbManager->TILErmax() - dbManager->TILBrmax())*Gaudi::Units::cm;
1377  dy1WedgeMother = dbManager->TILBrmax() * tan(deltaPhi/2*Gaudi::Units::deg)*Gaudi::Units::cm;
1378  dy2WedgeMother = dbManager->TILErmax() * tan(deltaPhi/2*Gaudi::Units::deg)*Gaudi::Units::cm;
1379 
1380  // Finger Positive, positioning (only Left ModFingpattern == 10)
1381  if ( ModFingpattern != 10 ) {
1382  GeoTrd* fingerModuleMotherPos = new GeoTrd(BFingerLengthPos/2,
1383  BFingerLengthPos/2,
1384  dy1WedgeMother,
1385  dy2WedgeMother,
1386  heightWedgeMother/2);
1387 
1388  GeoLogVol* lvFingerModuleMotherPos = new GeoLogVol("FingerModule",fingerModuleMotherPos,matAir);
1389  GeoPhysVol* pvFingerModuleMotherPos = new GeoPhysVol(lvFingerModuleMotherPos);
1390 
1391  if (Filling)
1392  sectionBuilder->fillFinger(pvFingerModuleMotherPos, 1,
1393  dbManager->TILErmax(),
1394  dbManager->TILBrmax(),
1395  deltaPhi,
1397  ModuleNcp,
1398  BFingerLengthPos*(1./Gaudi::Units::cm));
1399 
1400  GeoTransform* xtraModFingerPos = new GeoTransform(GeoTrf::TranslateX3D((dbManager->TILErmax() + dbManager->TILBrmax())/2*Gaudi::Units::cm));
1401 
1402  //(*m_log) << MSG::DEBUG << "R Index " << ModuleNcp << " Fingpattern "<< ModFingpattern << endmsg;
1403 
1404  pvFingerMotherPos->add(zrotMod);
1405  pvFingerMotherPos->add(xtraModFingerPos);
1406  pvFingerMotherPos->add(XYrtMod);
1407 
1408  pvFingerMotherPos->add(new GeoIdentifierTag(ModuleNcp));
1409  pvFingerMotherPos->add(pvFingerModuleMotherPos);
1410  }
1411 
1412  // Finger Negative, positioning (only Left ModFingpattern == 01)
1413  if ( ModFingpattern != 1 ) {
1414 
1415  GeoTrd* fingerModuleMotherNeg = new GeoTrd(BFingerLengthNeg/2,
1416  BFingerLengthNeg/2,
1417  dy1WedgeMother,
1418  dy2WedgeMother,
1419  heightWedgeMother/2);
1420 
1421  GeoLogVol* lvFingerModuleMotherNeg = new GeoLogVol("FingerModule",fingerModuleMotherNeg,matAir);
1422  GeoPhysVol* pvFingerModuleMotherNeg = new GeoPhysVol(lvFingerModuleMotherNeg);
1423 
1424  if (Filling)
1425  sectionBuilder->fillFinger(pvFingerModuleMotherNeg, 1,
1426  dbManager->TILErmax(),
1427  dbManager->TILBrmax(),
1428  deltaPhi,
1430  ModuleNcp*100,
1431  BFingerLengthNeg*(1./Gaudi::Units::cm));
1432 
1433  GeoTransform* xtraModFingerNeg = new GeoTransform(GeoTrf::TranslateX3D((dbManager->TILErmax() + dbManager->TILBrmax())/2*Gaudi::Units::cm));
1434 
1435  // (*m_log) << MSG::DEBUG << "L Index " << ModuleNcp << " Fingpattern "<< ModFingpattern << endmsg;
1436 
1437  pvFingerMotherNeg->add(zrotMod);
1438  pvFingerMotherNeg->add(xtraModFingerNeg);
1439  pvFingerMotherNeg->add(yrotMod);
1440 
1441  pvFingerMotherNeg->add(new GeoIdentifierTag(ModuleNcp));
1442  pvFingerMotherNeg->add(pvFingerModuleMotherNeg);
1443  }
1444 
1445  // --------------------------BARREL SADDLE MAKING----------------------------
1446  if (dbManager->BoolSaddle()) {
1447  if ( (ModuleNcp >=40 && ModuleNcp <=41) || (ModuleNcp >=56 && ModuleNcp <=57) ) {
1448  GeoTubs* SaddleModule = new GeoTubs(BFingerRmin-RadiusSaddle,
1449  BFingerRmin,
1450  DzSaddleSupport/2,
1452 
1453  GeoLogVol* lvSaddleModule = new GeoLogVol("SaddleModule",SaddleModule,matIron);
1454  GeoPhysVol* pvSaddleModule = new GeoPhysVol(lvSaddleModule);
1455 
1456  pvSaddleMotherPos->add(zrotSaddle);
1457  pvSaddleMotherPos->add(new GeoIdentifierTag(ModuleNcp));
1458  pvSaddleMotherPos->add(pvSaddleModule);
1459 
1460  pvSaddleMotherNeg->add(zrotSaddle);
1461  pvSaddleMotherNeg->add(new GeoIdentifierTag(ModuleNcp));
1462  pvSaddleMotherNeg->add(pvSaddleModule);
1463  }
1464  }
1465  }
1466 
1467  //------------------- Extended Barrel Module Positive ----------------------------------------------------------
1468 
1469  if (EnvType == 3 && barrel_flag < 2) {
1470 
1471  dbManager->SetCurrentSectionByNumber(ModType);
1472 
1473  // Mother module
1474  thicknessWedgeMother = dbManager->TILBdzmodul() * Gaudi::Units::cm;
1475  heightWedgeMother = (dbManager->TILBrmaximal() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
1476  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1477  dy2WedgeMother = dbManager->TILBrmaximal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1478 
1479  dzGlue = (dbManager->TILBdzmodul() - dbManager->TILBdzend1() - dbManager->TILBdzend2()
1480  - dbManager->TILBnperiod()*2.*(dbManager->TILBdzmast() + dbManager->TILBdzspac()))
1481  / (4.* dbManager->TILBnperiod());
1482 
1483  double Radius = (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2 * Gaudi::Units::cm;
1484 
1485  checking("EBarrelModule (+)", false, 1,
1486  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
1487 
1488  GeoTrd* ebarrelModuleMotherPos = new GeoTrd(thicknessWedgeMother/2,
1489  thicknessWedgeMother/2,
1490  dy1WedgeMother,
1491  dy2WedgeMother,
1492  heightWedgeMother/2);
1493 
1494  if (!dbManager->BoolCuts()) {
1495  if (m_log->level()<=MSG::DEBUG)
1496  (*m_log) << MSG::DEBUG << " BoolCuts NO "<< dbManager->BoolCuts() << endmsg;
1497 
1498  lvEBarrelModuleMotherPos = new GeoLogVol("EBarrelModule",ebarrelModuleMotherPos,matAir);
1499  pvEBarrelModuleMotherPos = new GeoPhysVol(lvEBarrelModuleMotherPos);
1500 
1501  } else {
1502 
1503  //gdb
1504  if (m_log->level()<=MSG::DEBUG)
1505  (*m_log) << MSG::DEBUG << " BoolCuts YES "<< dbManager->BoolCuts() << endmsg;
1506 
1507  double PoZ2 =0, PoZ1 =0, thicknessEndPlate =dbManager->TILBdzend1()*Gaudi::Units::cm;
1508 
1509  PoZ1 = thicknessEndPlate + modl_length/4 - (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthPos)/2;
1510  PoZ2 = PoZ1 + modl_length/4;
1511 
1512  if ((ModuleNcp>=35 && ModuleNcp<=37) || (ModuleNcp>=60 && ModuleNcp<=62)) {
1513  GeoTrf::Transform3D TransCut2 = GeoTrf::TranslateZ3D(-Radius) * GeoTrf::RotateX3D((90-phi)*Gaudi::Units::deg) * GeoTrf::RotateY3D(180*Gaudi::Units::deg)
1514  * GeoTrf::Translate3D(-PoZ2,0.,-PosY);
1515 
1516  if (ModuleNcp>=60 && ModuleNcp<=62) {
1517  GeoTrf::Transform3D TransCutL = GeoTrf::TranslateZ3D(-Radius)
1518  * GeoTrf::RotateY3D(180*Gaudi::Units::deg) * GeoTrf::RotateX3D(phi*Gaudi::Units::deg)
1519  * GeoTrf::Translate3D(PoZ1,PosYcut,-PosXcut);
1520 
1521  // Cuting of module (Left)
1522  const GeoShape& TmL_EBarrelModuleMotherPos = ebarrelModuleMotherPos->subtract((*CutA)<<TransCut2).
1523  subtract((*CutB)<<TransCutL);
1524 
1525  lvEBarrelModuleMotherPos = new GeoLogVol("EBarrelModule",&TmL_EBarrelModuleMotherPos,matAir);
1526 
1527  } else if (ModuleNcp>=35 && ModuleNcp<=37) {
1528  GeoTrf::Transform3D TransCutR = GeoTrf::TranslateZ3D(-Radius)
1529  * GeoTrf::RotateY3D(180*Gaudi::Units::deg) * GeoTrf::RotateX3D(phi*Gaudi::Units::deg)
1530  * GeoTrf::Translate3D(PoZ1,PosYcut,PosXcut) * GeoTrf::RotateY3D(180*Gaudi::Units::deg);
1531 
1532  // Cuting of module (Right)
1533  const GeoShape& TmR_EBarrelModuleMotherPos = ebarrelModuleMotherPos->subtract((*CutA)<<TransCut2).
1534  subtract((*CutB)<<TransCutR);
1535 
1536  lvEBarrelModuleMotherPos = new GeoLogVol("EBarrelModule",&TmR_EBarrelModuleMotherPos,matAir);
1537  }
1538 
1539  pvEBarrelModuleMotherPos = new GeoPhysVol(lvEBarrelModuleMotherPos);
1540 
1541  } else {
1542  lvEBarrelModuleMotherPos = new GeoLogVol("EBarrelModule",ebarrelModuleMotherPos,matAir);
1543  pvEBarrelModuleMotherPos = new GeoPhysVol(lvEBarrelModuleMotherPos);
1544  } // end special modules
1545  } // end if, BoolCuts()
1546 
1547  // Fill the section
1548  if (Filling) {
1549  sectionBuilder->fillSection(pvEBarrelModuleMotherPos, 2,
1550  dbManager->TILBrmaximal(),
1551  dbManager->TILBrminimal(),
1552  dzGlue,
1553  deltaPhi,
1554  ModuleNcp);
1555  }
1556 
1557  GeoTransform* xtraModPos = new GeoTransform(GeoTrf::TranslateX3D(Radius));
1558 
1559  pvEBarrelMotherPos->add(zrotMod);
1560  pvEBarrelMotherPos->add(xtraModPos);
1561  pvEBarrelMotherPos->add(XYrtMod);
1562 
1563  pvEBarrelMotherPos->add(new GeoIdentifierTag(ModuleNcp));
1564  pvEBarrelMotherPos->add(pvEBarrelModuleMotherPos);
1565 
1566  /*
1567  if (!dbManager->BoolCuts()) {
1568  pvEBarrelMotherPos->add(pvEBarrelModuleMotherPos);
1569  (*m_log) << MSG::DEBUG << " BoolCuts NO "<< dbManager->BoolCuts() << endmsg;
1570 
1571  } else {
1572 
1573  (*m_log) << MSG::DEBUG << " BoolCuts YES "<< dbManager->BoolCuts() << endmsg;
1574 
1575  double PoZ2 =0, PoZ1 =0;
1576  double thicknessEndPlate = dbManager->TILBdzend1()*Gaudi::Units::cm;
1577 
1578  PoZ1 = thicknessEndPlate + modl_length/4 - (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthPos)/2;
1579  PoZ2 = modl_length/4 + PoZ1;
1580 
1581  if ((ModuleNcp>=35 && ModuleNcp<=37) || (ModuleNcp>=60 && ModuleNcp<=62)) {
1582  GeoTrf::Transform3D TransCut2 = GeoTrf::TranslateZ3D(-Radius) * GeoTrf::RotateX3D((90-phi)*Gaudi::Units::deg) * GeoTrf::RotateY3D(180*Gaudi::Units::deg)
1583  * GeoTrf::Translate3D(-PoZ2,0.,-PosY);
1584 
1585  // Cuting of pvEBarrelModuleMotherPos (-)
1586  GeoCutVolAction action1(*CutA, TransCut2);
1587  pvEBarrelModuleMotherPos->apply(&action1);
1588  pvTmp_EBarrelModuleMotherPos = action1.getPV();
1589 
1590  if (ModuleNcp>=60 && ModuleNcp<=62) {
1591  GeoTrf::Transform3D TransCutL = GeoTrf::TranslateZ3D(-Radius)
1592  * GeoTrf::RotateY3D(180*Gaudi::Units::deg) * GeoTrf::RotateX3D(phi*Gaudi::Units::deg)
1593  * GeoTrf::Translate3D(PoZ1,PosYcut,-PosXcut);
1594 
1595  // Cuting of pvEBarrelModuleMotherPos (Left)
1596  GeoCutVolAction action2(*CutB, TransCutL);
1597  pvTmp_EBarrelModuleMotherPos->apply(&action2);
1598  pvTmL_EBarrelModuleMotherPos = action2.getPV();
1599 
1600  pvEBarrelMotherPos->add(pvTmL_EBarrelModuleMotherPos);
1601 
1602  } else if (ModuleNcp>=35 && ModuleNcp<=37) {
1603  GeoTrf::Transform3D TransCutR = GeoTrf::TranslateZ3D(-Radius)
1604  * GeoTrf::RotateY3D(180*Gaudi::Units::deg) * GeoTrf::RotateX3D(phi*Gaudi::Units::deg)
1605  * GeoTrf::Translate3D(PoZ1,PosYcut,PosXcut) * GeoTrf::RotateY3D(180*Gaudi::Units::deg);
1606 
1607  // Cuting of pvEBarrelModuleMotherPos (Right)
1608  GeoCutVolAction action3(*CutB, TransCutR);
1609  pvTmp_EBarrelModuleMotherPos->apply(&action3);
1610  pvTmR_EBarrelModuleMotherPos = action3.getPV();
1611 
1612  pvEBarrelMotherPos->add(pvTmR_EBarrelModuleMotherPos);
1613  }
1614  } else {
1615  pvEBarrelMotherPos->add(pvEBarrelModuleMotherPos);
1616  } // end special modules
1617  pvEBarrelMotherPos->add(pvEBarrelModuleMotherPos);
1618  } // end if, BoolCuts()
1619  */
1620 
1621  //--------------------------EBARREL FINGERS MAKING------------------------------
1622 
1623  dbManager->SetCurrentTifg(2); //barrel efinger (small)
1624 
1625  // Trd - one finger mother
1626  thicknessWedgeMother = dbManager->TIFGdz() * Gaudi::Units::cm;
1627  heightWedgeMother = (dbManager->TILErmax() - dbManager->TILBrmax()) * Gaudi::Units::cm;
1628  dy1WedgeMother = dbManager->TILBrmax() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1629  dy2WedgeMother = dbManager->TILErmax() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1630 
1631  checking("EFingerModule (+)", false, 1,
1632  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
1633 
1634  GeoTrd* efingerModuleMother = new GeoTrd(thicknessWedgeMother/2,
1635  thicknessWedgeMother/2,
1636  dy1WedgeMother,
1637  dy2WedgeMother,
1638  heightWedgeMother/2);
1639 
1640  GeoLogVol* lvEFingerModuleMother = new GeoLogVol("EFingerModule",efingerModuleMother,matAir);
1641  GeoPhysVol* pvEFingerModuleMother = new GeoPhysVol(lvEFingerModuleMother);
1642 
1643  // Fill the section
1644  if (Filling) {
1645  sectionBuilder->fillFinger(pvEFingerModuleMother, 2,
1646  dbManager->TILErmax(),
1647  dbManager->TILBrmax(),
1648  deltaPhi,
1650  ModuleNcp);
1651  }
1652  GeoTransform* xtraModFingerPos = new GeoTransform(GeoTrf::TranslateX3D(
1653  (dbManager->TILErmax() + dbManager->TILBrmax())/2*Gaudi::Units::cm));
1654  pvEFingerMotherPos->add(zrotMod);
1655  pvEFingerMotherPos->add(xtraModFingerPos);
1656  pvEFingerMotherPos->add(XYrtMod);
1657 
1658  pvEFingerMotherPos->add(new GeoIdentifierTag(ModuleNcp));
1659  pvEFingerMotherPos->add(pvEFingerModuleMother);
1660 
1661  // --------------------------BARREL SADDLE MAKING----------------------------
1662  if (dbManager->BoolSaddle()) {
1663  if ( (ModuleNcp >=39 && ModuleNcp <=42) || (ModuleNcp >=55 && ModuleNcp <=58) ) {
1664  GeoTubs* SaddleModule = new GeoTubs(BFingerRmin-RadiusSaddle,
1665  BFingerRmin,
1666  DzSaddleSupport/2,
1668 
1669  GeoLogVol* lvSaddleModule = new GeoLogVol("SaddleModule",SaddleModule,matIron);
1670  GeoPhysVol* pvSaddleModule = new GeoPhysVol(lvSaddleModule);
1671 
1672  pvESaddleMotherPos->add(zrotSaddle);
1673  pvESaddleMotherPos->add(new GeoIdentifierTag(ModuleNcp));
1674  pvESaddleMotherPos->add(pvSaddleModule);
1675  }
1676  }
1677 
1678  } // end if (EnvType == 3)
1679 
1680  //------------------- Extended Barrel Module Negative ----------------------------------------------------------
1681 
1682  if (EnvType == 2 && barrel_flag < 2) {
1683 
1684  dbManager->SetCurrentSectionByNumber(ModType);
1685 
1686  // Mother module
1687  thicknessWedgeMother = dbManager->TILBdzmodul() * Gaudi::Units::cm;
1688  heightWedgeMother = (dbManager->TILBrmaximal() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
1689  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1690  dy2WedgeMother = dbManager->TILBrmaximal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1691 
1692  dzGlue = (dbManager->TILBdzmodul() - dbManager->TILBdzend1() - dbManager->TILBdzend2()
1693  - dbManager->TILBnperiod()*2.*(dbManager->TILBdzmast()
1694  + dbManager->TILBdzspac()))/(4.*dbManager->TILBnperiod());
1695 
1696  double Radius = (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2 * Gaudi::Units::cm;
1697 
1698  checking("EBarrelModule (-)", false, 1,
1699  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
1700 
1701  GeoTrd* ebarrelModuleMotherNeg = new GeoTrd(thicknessWedgeMother/2,
1702  thicknessWedgeMother/2,
1703  dy1WedgeMother,
1704  dy2WedgeMother,
1705  heightWedgeMother/2);
1706 
1707  if (!dbManager->BoolCuts()) {
1708  if (m_log->level()<=MSG::DEBUG)
1709  (*m_log) << MSG::DEBUG << " BoolCuts NO "<< dbManager->BoolCuts() << endmsg;
1710 
1711  lvEBarrelModuleMotherNeg = new GeoLogVol("EBarrelModule",ebarrelModuleMotherNeg,matAir);
1712  pvEBarrelModuleMotherNeg = new GeoPhysVol(lvEBarrelModuleMotherNeg);
1713 
1714  } else {
1715 
1716  //gdb
1717  if (m_log->level()<=MSG::DEBUG)
1718  (*m_log) << MSG::DEBUG << " BoolCuts YES "<< dbManager->BoolCuts() << endmsg;
1719 
1720  double PoZ2 =0, PoZ1 =0, thicknessEndPlate = dbManager->TILBdzend1()*Gaudi::Units::cm;
1721 
1722  PoZ1 = thicknessEndPlate + modl_length/4 - (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthNeg)/2;
1723  PoZ2 = PoZ1 + modl_length/4;
1724 
1725  if ((ModuleNcp>=35 && ModuleNcp<=37) || (ModuleNcp>=60 && ModuleNcp<=62)) {
1726  GeoTrf::Transform3D TransCut2 = GeoTrf::TranslateZ3D(-Radius)
1727  * GeoTrf::RotateX3D((phi-90)*Gaudi::Units::deg) * GeoTrf::RotateY3D(180*Gaudi::Units::deg)
1728  * GeoTrf::Translate3D(-PoZ2,0,-PosY);
1729 
1730  if (ModuleNcp>=60 && ModuleNcp<=62) {
1731  GeoTrf::Transform3D TransCutL = GeoTrf::TranslateZ3D(-Radius)
1732  * GeoTrf::RotateY3D(180*Gaudi::Units::deg) * GeoTrf::RotateX3D(-phi*Gaudi::Units::deg)
1733  * GeoTrf::Translate3D(PoZ1,-PosYcut,-PosXcut);
1734 
1735  // Cuting of module (Left)
1736  const GeoShape& TmL_EBarrelModuleMotherNeg = ebarrelModuleMotherNeg->subtract((*CutA)<<TransCut2).
1737  subtract((*CutB)<<TransCutL);
1738 
1739  lvEBarrelModuleMotherNeg = new GeoLogVol("EBarrelModule",&TmL_EBarrelModuleMotherNeg,matAir);
1740 
1741  } else if (ModuleNcp>=35 && ModuleNcp<=37) {
1742  GeoTrf::Transform3D TransCutR = GeoTrf::TranslateZ3D(-Radius)
1743  * GeoTrf::RotateY3D(180*Gaudi::Units::deg) * GeoTrf::RotateX3D(-phi*Gaudi::Units::deg)
1744  * GeoTrf::Translate3D(PoZ1,-PosYcut,PosXcut) * GeoTrf::RotateY3D(180*Gaudi::Units::deg);
1745 
1746  // Cuting of module (Right)
1747  const GeoShape& TmR_EBarrelModuleMotherNeg = ebarrelModuleMotherNeg->subtract((*CutA)<<TransCut2).
1748  subtract((*CutB)<<TransCutR);
1749 
1750  lvEBarrelModuleMotherNeg = new GeoLogVol("EBarrelModule",&TmR_EBarrelModuleMotherNeg,matAir);
1751  }
1752 
1753  pvEBarrelModuleMotherNeg = new GeoPhysVol(lvEBarrelModuleMotherNeg);
1754 
1755  } else {
1756  lvEBarrelModuleMotherNeg = new GeoLogVol("EBarrelModule",ebarrelModuleMotherNeg,matAir);
1757  pvEBarrelModuleMotherNeg = new GeoPhysVol(lvEBarrelModuleMotherNeg);
1758  } // end special modules
1759  } // end if, BoolCuts()
1760 
1761  // Fill the section
1762  if (Filling) {
1763  sectionBuilder->fillSection(pvEBarrelModuleMotherNeg, 2,
1764  dbManager->TILBrmaximal(),
1765  dbManager->TILBrminimal(),
1766  dzGlue,
1767  deltaPhi,
1768  ModuleNcp,
1769  0.,true);
1770  }
1771 
1772  GeoTransform* xtraModNeg = new GeoTransform(GeoTrf::TranslateX3D(Radius));
1773 
1774  pvEBarrelMotherNeg->add(zrotMod);
1775  pvEBarrelMotherNeg->add(xtraModNeg);
1776  pvEBarrelMotherNeg->add(yrotMod);
1777 
1778  pvEBarrelMotherNeg->add(new GeoIdentifierTag(ModuleNcp));
1779  pvEBarrelMotherNeg->add(pvEBarrelModuleMotherNeg);
1780 
1781  /*
1782  if (!dbManager->BoolCuts()) {
1783  pvEBarrelMotherNeg->add(pvEBarrelModuleMotherNeg);
1784  (*m_log) << MSG::DEBUG << " BoolCuts NO "<< dbManager->BoolCuts() << endmsg;
1785 
1786  } else {
1787  (*m_log) << MSG::DEBUG << " BoolCuts YES "<< dbManager->BoolCuts() << endmsg;
1788 
1789  double PoZ2 =0, PoZ1 =0;
1790  double thicknessEndPlate = dbManager->TILBdzend1()*Gaudi::Units::cm;
1791 
1792  PoZ1 = thicknessEndPlate + modl_length/4 - (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthPos)/2;
1793  PoZ2 = modl_length/4 + PoZ1;
1794 
1795  if ((ModuleNcp>=35 && ModuleNcp<=37) || (ModuleNcp>=60 && ModuleNcp<=62)) {
1796  GeoTrf::Transform3D TransCut2 = GeoTrf::TranslateZ3D(-Radius)
1797  * GeoTrf::RotateX3D((phi-90)*Gaudi::Units::deg) * GeoTrf::RotateY3D(180*Gaudi::Units::deg)
1798  * GeoTrf::Translate3D(-PoZ2,0.,-PosY);
1799 
1800  // Cuting of pvEBarrelModuleMotherNeg (-)
1801  GeoCutVolAction action1(*CutA, TransCut2);
1802  pvEBarrelModuleMotherNeg->apply(&action1);
1803  pvTmp_EBarrelModuleMotherNeg = action1.getPV();
1804 
1805  if (ModuleNcp>=60 && ModuleNcp<=62) {
1806  GeoTrf::Transform3D TransCutL = GeoTrf::TranslateZ3D(-Radius)
1807  * GeoTrf::RotateY3D(180*Gaudi::Units::deg) * GeoTrf::RotateX3D(-phi*Gaudi::Units::deg)
1808  * GeoTrf::Translate3D(PoZ1,-PosYcut,-PosXcut);
1809 
1810  // Cuting of pvEBarrelModuleMotherNeg (Left)
1811  GeoCutVolAction action2(*CutB, TransCutL);
1812  pvTmp_EBarrelModuleMotherNeg->apply(&action2);
1813  pvTmL_EBarrelModuleMotherNeg = action2.getPV();
1814 
1815  pvEBarrelMotherNeg->add(pvTmL_EBarrelModuleMotherNeg);
1816 
1817  } else if (ModuleNcp>=35 && ModuleNcp<=37) {
1818  GeoTrf::Transform3D TransCutR = GeoTrf::TranslateZ3D(-Radius)
1819  * GeoTrf::RotateY3D(180*Gaudi::Units::deg) * GeoTrf::RotateX3D(-phi*Gaudi::Units::deg)
1820  * GeoTrf::Translate3D(PoZ1,-PosYcut,PosXcut) * GeoTrf::RotateY3D(180*Gaudi::Units::deg);
1821 
1822  // Cuting of pvEBarrelModuleMotherNeg (Right)
1823  GeoCutVolAction action3(*CutB, TransCutR);
1824  pvTmp_EBarrelModuleMotherNeg->apply(&action3);
1825  pvTmR_EBarrelModuleMotherNeg = action3.getPV();
1826 
1827  pvEBarrelMotherNeg->add(pvTmR_EBarrelModuleMotherNeg);
1828  }
1829  } else {
1830  pvEBarrelMotherNeg->add(pvEBarrelModuleMotherNeg);
1831  } // end special modules
1832  pvEBarrelMotherNeg->add(pvEBarrelModuleMotherNeg);
1833  } // end if, BoolCuts()
1834  */
1835 
1836  //--------------------------EBARREL FINGERS MAKING------------------------------
1837 
1838  dbManager->SetCurrentTifg(2); //barrel efinger (small)
1839 
1840  //zEndSection = extOffset + dbManager->TILBdzmodul()/2 + dbManager->TILEzshift();
1841 
1842  // Trd - one finger mother
1843  thicknessWedgeMother = dbManager->TIFGdz() * Gaudi::Units::cm;
1844  heightWedgeMother = (dbManager->TILErmax() - dbManager->TILBrmax()) * Gaudi::Units::cm;
1845  dy1WedgeMother = dbManager->TILBrmax() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1846  dy2WedgeMother = dbManager->TILErmax() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1847 
1848  checking("EFingerModule (-)", false, 1,
1849  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
1850 
1851  GeoTrd* efingerModuleMother = new GeoTrd(thicknessWedgeMother/2,
1852  thicknessWedgeMother/2,
1853  dy1WedgeMother,
1854  dy2WedgeMother,
1855  heightWedgeMother/2);
1856 
1857  GeoLogVol* lvEFingerModuleMother = new GeoLogVol("EFingerModule",efingerModuleMother,matAir);
1858  GeoPhysVol* pvEFingerModuleMother = new GeoPhysVol(lvEFingerModuleMother);
1859 
1860  // Fill the section
1861  if (Filling) {
1862  sectionBuilder->fillFinger(pvEFingerModuleMother, 2,
1863  dbManager->TILErmax(),
1864  dbManager->TILBrmax(),
1865  deltaPhi,
1867  ModuleNcp*100);
1868  }
1869  GeoTransform* xtraModFingerNeg = new GeoTransform(GeoTrf::TranslateX3D(
1870  (dbManager->TILErmax() + dbManager->TILBrmax())/2*Gaudi::Units::cm));
1871  pvEFingerMotherNeg->add(zrotMod);
1872  pvEFingerMotherNeg->add(xtraModFingerNeg);
1873  pvEFingerMotherNeg->add(yrotMod);
1874 
1875  pvEFingerMotherNeg->add(new GeoIdentifierTag(ModuleNcp));
1876  pvEFingerMotherNeg->add(pvEFingerModuleMother);
1877 
1878  // --------------------------BARREL SADDLE MAKING----------------------------
1879  if (dbManager->BoolSaddle()) {
1880  if ( (ModuleNcp >=39 && ModuleNcp <=42) || (ModuleNcp >=55 && ModuleNcp <=58) ) {
1881  GeoTubs* SaddleModule = new GeoTubs(BFingerRmin-RadiusSaddle,
1882  BFingerRmin,
1883  DzSaddleSupport/2,
1885 
1886  GeoLogVol* lvSaddleModule = new GeoLogVol("SaddleModule",SaddleModule,matIron);
1887  GeoPhysVol* pvSaddleModule = new GeoPhysVol(lvSaddleModule);
1888 
1889  pvESaddleMotherNeg->add(zrotSaddle);
1890  pvESaddleMotherNeg->add(new GeoIdentifierTag(ModuleNcp));
1891  pvESaddleMotherNeg->add(pvSaddleModule);
1892  }
1893  }
1894 
1895  } // end if (EnvType == 2)
1896 
1897  //------------------- D4/C10/Gap/Crack
1898 
1899  if (((EnvType == 4) || (EnvType == 5)) && barrel_flag < 5) {
1900 
1901  int Id4 = ModType%100;
1902  int Ic10 = (ModType/100)%100;
1903  int Igap = (ModType/10000)%100;
1904  int Icrack = (ModType/1000000)%100;
1905 
1906  bool Ifd4 = ( Id4 != 0);
1907  bool Ifc10 = ( Ic10 != 0);
1908  bool Ifgap = ( Igap != 0);
1909  bool Ifcrack = ( Icrack != 0);
1910 
1911  bool Ifspecialgirder = (Id4 == 7);
1912 
1913  if (m_log->level()<=MSG::DEBUG)
1914  (*m_log) << MSG::DEBUG <<" ITC : EnvType "<<EnvType<<" Size = "<<dbManager->GetModTypeSize()
1915  <<" Ncp= "<<ModuleNcp<<" D4 "<<Id4<<" specialflag = "<<Ifspecialgirder<<" C10 "<<Ic10<<" Gap "<<Igap<<" Crack "<<Icrack
1916  << endmsg;
1917 
1918  if (Ifc10) {
1919  dbManager->SetCurrentSectionByNumber(Ic10); // TILE_PLUG2
1920  rMinITC2 = dbManager->TILBrminimal();
1921  rMaxITC2 = dbManager->TILBrmaximal();
1922  dzITC2 = dbManager->TILBdzmodul();
1923  } else {
1924  if (m_log->level()<=MSG::DEBUG)
1925  (*m_log) << MSG::DEBUG <<" C10 unavailable "<<endmsg;
1926  }
1927 
1928  if (Ifd4) {
1929  dbManager->SetCurrentSectionByNumber(Id4); // TILE_PLUG1
1930  rMinITC1 = dbManager->TILBrminimal();
1931  rMaxITC1 = dbManager->TILBrmaximal();
1932  dzITC1 = dbManager->TILBdzmodul();
1933  if (Ifspecialgirder) {
1934  if (m_log->level()<=MSG::DEBUG)
1935  (*m_log) << MSG::DEBUG <<" dzITC1 changed from "<<dzITC1<<" to "<<dbManager->TILBdzgir()<<endmsg;
1936  dzITC1 = dbManager->TILBdzgir();
1937  }
1938  } else {
1939  (*m_log) << MSG::INFO <<" D4 unavailable "<<endmsg;
1940  dzITC1 = 9.485; //sb [Gaudi::Units::cm]
1941  }
1942 
1943  bool specialC10 = (Ifd4 && Ifc10 && rMaxITC2 < rMinITC1);
1944  if (specialC10) {
1945  rMaxITC2 = rMinITC1; // for special C10 make outer radius equal to inner radius of D4
1946  }
1947 
1948  //------------------- ITC BLOCKS Negative --------------------------------
1949  if (EnvType == 4) {
1950 
1951  // Common mother for ITC1/2 modules
1952  if ((Ifd4 || Ifc10) && pvITCMotherNeg) {
1953 
1954  // The first sub shape
1955  thicknessWedgeMother = dzITC1 * Gaudi::Units::cm;
1956  heightWedgeMother = (rMaxITC1 - rMinITC1) * Gaudi::Units::cm;
1957  dy1WedgeMother = rMinITC1 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1958  dy2WedgeMother = rMaxITC1 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1959 
1960  checking("ITCModule tcModuleSub1Neg (-) ", false, 1,
1961  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
1962 
1963  GeoTrd* itcModuleSub1Neg = new GeoTrd(thicknessWedgeMother/2,
1964  thicknessWedgeMother/2,
1965  dy1WedgeMother,
1966  dy2WedgeMother,
1967  heightWedgeMother/2);
1968  // The second sub shape
1969  thicknessWedgeMother = dzITC2 * Gaudi::Units::cm;
1970  heightWedgeMother = (rMaxITC2 - rMinITC2) * Gaudi::Units::cm;
1971  dy1WedgeMother = rMinITC2 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1972  dy2WedgeMother = rMaxITC2 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
1973 
1974  checking("ITCModule itcModuleSub2Neg (-)", false, 1,
1975  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
1976 
1977  GeoTrd* itcModuleSub2Neg = new GeoTrd(thicknessWedgeMother/2,
1978  thicknessWedgeMother/2,
1979  dy1WedgeMother,
1980  dy2WedgeMother,
1981  heightWedgeMother/2 );
1982 
1983  X = (dzITC1 - dzITC2)/2*Gaudi::Units::cm;
1984  Z = ((rMinITC2+rMaxITC2)-(rMaxITC1 + rMinITC1))/2*Gaudi::Units::cm;
1985  if (m_log->level()<=MSG::DEBUG)
1986  (*m_log) << MSG::DEBUG <<" ITCModule Negative, position X= "<<X<<" Z= "<<Z<< endmsg;
1987 
1988  GeoTrf::Translate3D itcModule_SubShiftNeg(X, 0., Z);
1989  const GeoShapeUnion& itcModuleMotherNeg = itcModuleSub1Neg->add(*itcModuleSub2Neg<<itcModule_SubShiftNeg);
1990 
1991  GeoTrf::Translate3D itcModuleSubShiftNeg(X, 0., Z);
1992 
1993  GeoLogVol* lvITCModuleMotherNeg = new GeoLogVol("ITCModule",&itcModuleMotherNeg,matAir);
1994  GeoPhysVol* pvITCModuleMotherNeg = new GeoPhysVol(lvITCModuleMotherNeg);
1995 
1996  //Mother volume for ITC1
1997  //In plug1 it's necessary to produce GeoShapeUnion for mother volume that is composed by two parts:
1998  // 1. Mother for absorber and girder
1999  // 2. Mother for frontplate (since it's short)
2000 
2001  // The D4, PLUG1
2002  dbManager->SetCurrentSectionByNumber(Id4);
2003 
2004  thicknessWedgeMother = dzITC1 * Gaudi::Units::cm;
2005  heightWedgeMother = (rMaxITC1 - dbManager->TILBrmin()) * Gaudi::Units::cm;
2006  dy1WedgeMother = dbManager->TILBrmin() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2007  dy2WedgeMother = rMaxITC1 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2008  // ps changes dzITC1 -> dzmodul
2009  Glue = dbManager->TILBdzmodul() - dbManager->TILBdzend1() - dbManager->TILBdzend2();
2010  NbPeriod = dbManager->TILBnperiod();
2011 
2012  if (m_log->level()<=MSG::DEBUG)
2013  (*m_log) << MSG::DEBUG <<" Plug1Module : Glue= "<<Glue<<" dzITC1= "<<dzITC1
2014  <<" TILBdzend1= "<<dbManager->TILBdzend1()
2015  <<" TILBdzend2= "<<dbManager->TILBdzend2()
2016  <<endmsg;
2017 
2018  if (NbPeriod > 6) {
2019  dzGlue = (Glue - 2*NbPeriod * (dbManager->TILBdzmast() + dbManager->TILBdzspac())) / (4.*NbPeriod);
2020  } else {
2021  dzGlue = (Glue - (2*(NbPeriod-1) * (dbManager->TILBdzmast() + dbManager->TILBdzspac()) + dbManager->TILBdzspac())) / (4.*(NbPeriod-1));
2022  }
2023 
2024  if (m_log->level()<=MSG::DEBUG)
2025  (*m_log) << MSG::DEBUG <<" Plug1Module : Glue= "<<Glue<<" dzGlue= "<<dzGlue<<" NbPeriod= "<<NbPeriod
2026  <<" TILBdzmast= "<<dbManager->TILBdzmast()<<" TILBdzspac= "<<dbManager->TILBdzspac()
2027  <<endmsg;
2028 
2029  if (dzGlue <= 0.) {
2030  (*m_log) << MSG::WARNING <<" Plug1Module warning: "<<" dzGlue= "<<dzGlue
2031  <<endmsg;
2032  }
2033 
2034  checking("Plug1Module plug1SubMotherNeg (-)", false, 2,
2035  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2036 
2037  GeoTrd* plug1SubMotherNeg = new GeoTrd(thicknessWedgeMother/2,
2038  thicknessWedgeMother/2,
2039  dy1WedgeMother,
2040  dy2WedgeMother,
2041  heightWedgeMother/2);
2042  //Second submother for frontplate
2043  double dzITC2Bis = (specialC10) ? 0.0 : dzITC2; // for special C10 D4 and C10 do not overlap
2044  thicknessWedgeMother = (dbManager->TILBdzmodul() - dzITC2Bis) * Gaudi::Units::cm;
2045  if (m_log->level()<=MSG::DEBUG)
2046  if (specialC10)
2047  (*m_log) << MSG::DEBUG <<" Separate C10 and D4 in module " << ModuleNcp << endmsg;
2048 
2049  GeoLogVol *lvPlug1ModuleMotherNeg=0;
2050  if (thicknessWedgeMother > rless) {
2051  heightWedgeMother = (dbManager->TILBrmin() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
2052  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2053  dy2WedgeMother = dbManager->TILBrmin() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2054 
2055  checking("Plug1Module plug2SubMotherNeg (-)", false, 2,
2056  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2057 
2058  GeoTrd* plug2SubMotherNeg = new GeoTrd(thicknessWedgeMother/2,
2059  thicknessWedgeMother/2,
2060  dy1WedgeMother,
2061  dy2WedgeMother,
2062  heightWedgeMother/2);
2063 
2064  GeoTrf::Translate3D plug1SubOffsetNeg(-dzITC2Bis*Gaudi::Units::cm/2, 0.,
2065  (dbManager->TILBrminimal()-dbManager->TILBrmaximal())*Gaudi::Units::cm/2);
2066 
2067  const GeoShapeUnion& plug1ModuleMotherNeg =
2068  plug1SubMotherNeg->add(*plug2SubMotherNeg<<plug1SubOffsetNeg);
2069 
2070  lvPlug1ModuleMotherNeg = new GeoLogVol("Plug1Module",&plug1ModuleMotherNeg,matAir);
2071  } else {
2072  lvPlug1ModuleMotherNeg = new GeoLogVol("Plug1Module",plug1SubMotherNeg,matAir);
2073  }
2074 
2075  GeoPhysVol* pvPlug1ModuleMotherNeg = new GeoPhysVol(lvPlug1ModuleMotherNeg);
2076 
2077  // Fill the section
2078  if (Filling) {
2079  sectionBuilder->fillSection(pvPlug1ModuleMotherNeg, 3,
2080  dbManager->TILBrmaximal(),
2081  (thicknessWedgeMother > rless) ? dbManager->TILBrminimal() : dbManager->TILBrmin(),
2082  dzGlue,
2083  deltaPhi,
2084  ModuleNcp,
2085  dzITC2Bis);
2086  }
2087 
2088  Z = (dbManager->TILBrmin()-dbManager->TILBrminimal())*Gaudi::Units::cm/2;
2089  GeoTransform* tfPlug1ModuleMotherNeg = new GeoTransform(GeoTrf::Translate3D(0.,0.,Z));
2090 
2091  pvITCModuleMotherNeg->add(tfPlug1ModuleMotherNeg);
2092  pvITCModuleMotherNeg->add(pvPlug1ModuleMotherNeg);
2093 
2094  //Mother volume for ITC2
2095  if (Ifc10) {
2096 
2097  // TILE_PLUG2
2098  dbManager->SetCurrentSectionByNumber(Ic10);
2099 
2100  thicknessWedgeMother = dbManager->TILBdzmodul() * Gaudi::Units::cm;
2101  heightWedgeMother = (dbManager->TILBrmaximal() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
2102  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2103  dy2WedgeMother = dbManager->TILBrmaximal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2104 
2105  if (dbManager->TILBnperiod() > 1) {
2106  dzGlue = (dbManager->TILBdzmodul() - dbManager->TILBdzend1() - dbManager->TILBdzend2()
2107  - ((dbManager->TILBnperiod()-1)*2*(dbManager->TILBdzmast() + dbManager->TILBdzspac())
2108  + dbManager->TILBdzspac()))/(4.*(dbManager->TILBnperiod() - 1));
2109  } else {
2110  dzGlue = 0; // add for special missing C10 modules
2111  }
2112 
2113  checking("Plug2Module (-)", false, 2,
2114  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2115 
2116  GeoTrd* plug2ModuleMotherNeg = new GeoTrd(thicknessWedgeMother/2,
2117  thicknessWedgeMother/2,
2118  dy1WedgeMother,
2119  dy2WedgeMother,
2120  heightWedgeMother/2);
2121 
2122  GeoLogVol* lvPlug2ModuleMotherNeg = new GeoLogVol("Plug2Module",plug2ModuleMotherNeg,matAir);
2123  GeoPhysVol* pvPlug2ModuleMotherNeg = new GeoPhysVol(lvPlug2ModuleMotherNeg);
2124 
2125  // Fill the section
2126  if (Filling) {
2127  sectionBuilder->fillSection(pvPlug2ModuleMotherNeg, Ic10,
2128  dbManager->TILBrmaximal(),
2129  dbManager->TILBrminimal(),
2130  dzGlue,
2131  deltaPhi);
2132  }
2133 
2134  // TILE_PLUG1, D4
2135  if (Ifd4) {
2136  dbManager->SetCurrentSectionByNumber(Id4);
2137 
2138  GeoTransform* tfPlug2ModuleMotherNeg = new GeoTransform(itcModuleSubShiftNeg);
2139 
2140  pvITCModuleMotherNeg->add(tfPlug2ModuleMotherNeg);
2141  pvITCModuleMotherNeg->add(pvPlug2ModuleMotherNeg);
2142  }
2143  }//if C10
2144 
2145  double zShift = 0;
2146  NbPeriod = dbManager->TILBnperiod();
2147  // Z = (dbManager->TILBdzmodul()-dzITC2)/2*Gaudi::Units::cm;
2148  // ps Zshift calculated from length of volumes rather than modules (account for special modules)
2149  //
2150  Z = (dzITC1 - dzITC2)/2*Gaudi::Units::cm;
2151 
2152  if (NbPeriod == 6 && !Ifspecialgirder && std::abs(Z) < std::abs(zITCStandard)) zShift = zITCStandard*(1./Gaudi::Units::cm);
2153 
2154  if (m_log->level()<=MSG::DEBUG)
2155  (*m_log) << MSG::DEBUG <<" ITCModule Negative, position X= "<<X<<" Z= "<<Z
2156  <<" zStandard= "<<zITCStandard<< " zShift= " <<zShift
2157  <<endmsg;
2158 
2159  GeoTransform* xtraITCNeg = new GeoTransform(GeoTrf::TranslateX3D(
2160  (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2*Gaudi::Units::cm));
2161  GeoTransform* ztraITCNeg = new GeoTransform(GeoTrf::TranslateZ3D(zShift*Gaudi::Units::cm));
2162 
2163  pvITCMotherNeg->add(zrotMod);
2164  pvITCMotherNeg->add(xtraITCNeg);
2165  pvITCMotherNeg->add(ztraITCNeg);
2166  pvITCMotherNeg->add(yrotMod);
2167 
2168  pvITCMotherNeg->add(new GeoIdentifierTag(ModuleNcp));
2169  pvITCMotherNeg->add(pvITCModuleMotherNeg);
2170 
2171  }//if (Ifd4 || Ifc10)
2172 
2173  //-------------------------- G A P Negative ---------------------------------
2174  if (Ifgap && pvGapMotherNeg) {
2175 
2176  // TILE_PLUG3
2177  dbManager->SetCurrentSectionByNumber(Igap);
2178 
2179  // Trd - module mother
2180  thicknessWedgeMother = dbManager->TILBdzmodul() * Gaudi::Units::cm;
2181  heightWedgeMother = (dbManager->TILBrmaximal() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
2182  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2183  dy2WedgeMother = dbManager->TILBrmaximal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2184 
2185  dzGlue = 0.;
2186 
2187  checking("GapModule (-)", false, 2,
2188  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2189 
2190  GeoTrd* gapModuleMotherNeg = new GeoTrd(thicknessWedgeMother/2,
2191  thicknessWedgeMother/2,
2192  dy1WedgeMother,
2193  dy2WedgeMother,
2194  heightWedgeMother/2);
2195 
2196  GeoLogVol* lvGapModuleMotherNeg = new GeoLogVol("GapModule",gapModuleMotherNeg,matAir);
2197  GeoPhysVol* pvGapModuleMotherNeg = new GeoPhysVol(lvGapModuleMotherNeg);
2198 
2199  // Fill the section
2200  if (Filling) {
2201  sectionBuilder->fillSection(pvGapModuleMotherNeg, 5, // probably better to have Igap instead of 5
2202  dbManager->TILBrmaximal(),
2203  dbManager->TILBrminimal(),
2204  dzGlue,
2205  deltaPhi);
2206  }
2207 
2208  // Module position inside mother
2209  GeoTransform* xtraGapNeg = new GeoTransform(GeoTrf::TranslateX3D(
2210  (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2*Gaudi::Units::cm));
2211  pvGapMotherNeg->add(zrotMod);
2212  pvGapMotherNeg->add(xtraGapNeg);
2213  pvGapMotherNeg->add(yrotMod);
2214 
2215  pvGapMotherNeg->add(new GeoIdentifierTag(ModuleNcp));
2216  pvGapMotherNeg->add(pvGapModuleMotherNeg);
2217  }
2218 
2219  //-------------------------- Crack Negative ---------------------------------
2220  if (Ifcrack && pvCrackMotherNeg) {
2221 
2222  // TILE_PLUG4
2223  dbManager->SetCurrentSectionByNumber(Icrack);
2224 
2225  // mother
2226  thicknessWedgeMother = dbManager->TILBdzmodul() * Gaudi::Units::cm;
2227  heightWedgeMother = (dbManager->TILBrmaximal() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
2228  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2229  dy2WedgeMother = dbManager->TILBrmaximal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2230 
2231  dzGlue = 0.;
2232 
2233  checking("CrackModule (-)", spE4, 2,
2234  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2235 
2236  GeoTrd* crackModuleMotherNeg = new GeoTrd(thicknessWedgeMother/2,
2237  thicknessWedgeMother/2,
2238  dy1WedgeMother,
2239  dy2WedgeMother,
2240  heightWedgeMother/2);
2241 
2242  GeoLogVol* lvCrackModuleMotherNeg = new GeoLogVol("CrackModule",crackModuleMotherNeg,matAir);
2243  GeoPhysVol* pvCrackModuleMotherNeg = new GeoPhysVol(lvCrackModuleMotherNeg);
2244 
2245  // Fill the section
2246  if (Filling) {
2247  sectionBuilder->fillSection(pvCrackModuleMotherNeg, 6,
2248  dbManager->TILBrmaximal(),
2249  dbManager->TILBrminimal(),
2250  dzGlue,
2251  deltaPhi);
2252  }
2253  // Module position inside mother
2254  GeoTransform* xtraCrackNeg = new GeoTransform(GeoTrf::TranslateX3D(
2255  (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2*Gaudi::Units::cm));
2256  pvCrackMotherNeg->add(zrotMod);
2257  pvCrackMotherNeg->add(xtraCrackNeg);
2258  pvCrackMotherNeg->add(yrotMod);
2259 
2260  pvCrackMotherNeg->add(new GeoIdentifierTag(ModuleNcp));
2261  pvCrackMotherNeg->add(pvCrackModuleMotherNeg);
2262 
2263  }
2264  }
2265 
2266  //-------------------------------------- ITC BLOCKS Positive --------------------------------------
2267  if (EnvType == 5) {
2268 
2269  // Common mother for ITC1/2 modules
2270  if ((Ifd4 || Ifc10) && pvITCMotherPos) {
2271 
2272  // The first sub shape
2273  thicknessWedgeMother = dzITC1 * Gaudi::Units::cm;
2274  heightWedgeMother = (rMaxITC1 - rMinITC1) * Gaudi::Units::cm;
2275  dy1WedgeMother = rMinITC1 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2276  dy2WedgeMother = rMaxITC1 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2277 
2278  checking("ITCModule itcModuleSub2Pos (+)", false, 1,
2279  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2280 
2281  GeoTrd* itcModuleSub1Pos = new GeoTrd(thicknessWedgeMother/2,
2282  thicknessWedgeMother/2,
2283  dy1WedgeMother ,
2284  dy2WedgeMother ,
2285  heightWedgeMother/2 );
2286  // The second sub shape
2287  thicknessWedgeMother = dzITC2 * Gaudi::Units::cm;
2288  heightWedgeMother = (rMaxITC2 - rMinITC2) * Gaudi::Units::cm;
2289  dy1WedgeMother = rMinITC2 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2290  dy2WedgeMother = rMaxITC2 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2291 
2292  checking("ITCModule itcModuleSub2Pos (+)", false, 1,
2293  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2294 
2295  GeoTrd* itcModuleSub2Pos = new GeoTrd(thicknessWedgeMother/2,
2296  thicknessWedgeMother/2,
2297  dy1WedgeMother ,
2298  dy2WedgeMother ,
2299  heightWedgeMother/2 );
2300 
2301  X = (dzITC1 - dzITC2)/2*Gaudi::Units::cm;
2302  Z = ((rMinITC2+rMaxITC2)-(rMaxITC1 + rMinITC1))/2*Gaudi::Units::cm;
2303  if (m_log->level()<=MSG::DEBUG)
2304  (*m_log) << MSG::DEBUG <<" ITCModule Positive, position X= "<<X<<" Z= "<<Z<< endmsg;
2305 
2306  GeoTrf::Translate3D itcModule_SubShiftPos(X, 0., Z);
2307  const GeoShapeUnion& itcModuleMotherPos = itcModuleSub1Pos->add(*itcModuleSub2Pos<<itcModule_SubShiftPos);
2308 
2309  GeoTrf::Translate3D itcModuleSubShiftPos(X, 0., Z);
2310 
2311  GeoLogVol* lvITCModuleMotherPos = new GeoLogVol("ITCModule",&itcModuleMotherPos,matAir);
2312  GeoPhysVol* pvITCModuleMotherPos = new GeoPhysVol(lvITCModuleMotherPos);
2313 
2314  // Mother volume for ITC1
2315  // In plug1 it's necessary to produce GeoShapeUnion for mother volume that is composed by two parts:
2316  // 1. Mother for absorber and girder
2317  // 2. Mother for frontplate (since it's short)
2318 
2319  // The D4, PLUG1
2320  dbManager->SetCurrentSectionByNumber(Id4);
2321 
2322  thicknessWedgeMother = dzITC1 * Gaudi::Units::cm;
2323  dy1WedgeMother = dbManager->TILBrmin() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2324  dy2WedgeMother = rMaxITC1 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2325  heightWedgeMother = (rMaxITC1 - dbManager->TILBrmin()) * Gaudi::Units::cm;
2326 
2327  // ps changes dzITC1 -> dzmodul
2328  Glue = dbManager->TILBdzmodul() - dbManager->TILBdzend1() - dbManager->TILBdzend2();
2329  NbPeriod = dbManager->TILBnperiod();
2330 
2331  if (m_log->level()<=MSG::DEBUG)
2332  (*m_log) << MSG::DEBUG <<" Plug1Module : Glue= "<<Glue<<" dzITC1= "<<dzITC1
2333  <<" TILBdzend1= "<<dbManager->TILBdzend1()
2334  <<" TILBdzend2= "<<dbManager->TILBdzend2()
2335  <<endmsg;
2336 
2337  if (NbPeriod > 6) {
2338  dzGlue = (Glue - 2*NbPeriod * (dbManager->TILBdzmast() + dbManager->TILBdzspac())) / (4.*NbPeriod);
2339  } else {
2340  dzGlue = (Glue - (2*(NbPeriod-1) * (dbManager->TILBdzmast() + dbManager->TILBdzspac())
2341  + dbManager->TILBdzspac())) / (4.*(NbPeriod-1));
2342  }
2343 
2344  if (m_log->level()<=MSG::DEBUG)
2345  (*m_log) << MSG::DEBUG <<" Plug1Module : Glue= "<<Glue<<" dzGlue= "<<dzGlue<<" NbPeriod= "<<NbPeriod
2346  <<" TILBdzmast= "<<dbManager->TILBdzmast()<<" TILBdzspac= "<<dbManager->TILBdzspac()
2347  <<endmsg;
2348 
2349  if (dzGlue <= 0.) {
2350  (*m_log) << MSG::WARNING <<" Plug1Module warning: "<<" dzGlue= "<<dzGlue
2351  <<endmsg;
2352  }
2353 
2354  checking("Plug1Module plug1SubMotherPos (+)", false, 2,
2355  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2356 
2357  GeoTrd* plug1SubMotherPos = new GeoTrd(thicknessWedgeMother/2,
2358  thicknessWedgeMother/2,
2359  dy1WedgeMother ,
2360  dy2WedgeMother ,
2361  heightWedgeMother/2 );
2362 
2363  //Second submother C10, PLUG2
2364  double dzITC2Bis = (specialC10) ? 0.0 : dzITC2; // for special C10 D4 and C10 do not overlap
2365  thicknessWedgeMother = (dbManager->TILBdzmodul() - dzITC2Bis) * Gaudi::Units::cm;
2366  if (m_log->level()<=MSG::DEBUG)
2367  if (specialC10)
2368  (*m_log) << MSG::DEBUG <<" Separate C10 and D4 in module " << ModuleNcp << endmsg;
2369 
2370  GeoLogVol *lvPlug1ModuleMotherPos=0;
2371  if (thicknessWedgeMother > rless) {
2372  heightWedgeMother = (dbManager->TILBrmin() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
2373  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2374  dy2WedgeMother = dbManager->TILBrmin() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2375 
2376  checking("Plug1Module plug2SubMotherPos (+)", false, 2,
2377  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2378 
2379  GeoTrd* plug2SubMotherPos = new GeoTrd(thicknessWedgeMother/2,
2380  thicknessWedgeMother/2,
2381  dy1WedgeMother ,
2382  dy2WedgeMother ,
2383  heightWedgeMother/2 );
2384 
2385  GeoTrf::Translate3D plug1SubOffsetPos(-dzITC2Bis/2*Gaudi::Units::cm, 0.,
2386  (dbManager->TILBrminimal()-dbManager->TILBrmaximal())/2*Gaudi::Units::cm);
2387 
2388  const GeoShapeUnion& plug1ModuleMotherPos = plug1SubMotherPos->add(*plug2SubMotherPos<<plug1SubOffsetPos);
2389 
2390  lvPlug1ModuleMotherPos = new GeoLogVol("Plug1Module",&plug1ModuleMotherPos,matAir);
2391  } else {
2392  lvPlug1ModuleMotherPos = new GeoLogVol("Plug1Module",plug1SubMotherPos,matAir);
2393  }
2394 
2395  GeoPhysVol* pvPlug1ModuleMotherPos = new GeoPhysVol(lvPlug1ModuleMotherPos);
2396 
2397  // Fill the section
2398  if (Filling) {
2399  sectionBuilder->fillSection(pvPlug1ModuleMotherPos, 3,
2400  dbManager->TILBrmaximal(),
2401  (thicknessWedgeMother > rless) ? dbManager->TILBrminimal() : dbManager->TILBrmin(),
2402  dzGlue,
2403  deltaPhi,
2404  ModuleNcp,
2405  dzITC2Bis);
2406  }
2407 
2408  Z = (dbManager->TILBrmin()-dbManager->TILBrminimal())*Gaudi::Units::cm/2;
2409  GeoTransform* tfPlug1ModuleMotherPos = new GeoTransform(GeoTrf::Translate3D(0.,0.,Z));
2410 
2411  pvITCModuleMotherPos->add(tfPlug1ModuleMotherPos);
2412  pvITCModuleMotherPos->add(pvPlug1ModuleMotherPos);
2413 
2414  //Mother volume for ITC2 Positive
2415  if (Ifc10) {
2416 
2417  // TILE_PLUG2, C10
2418  dbManager->SetCurrentSectionByNumber(Ic10);
2419 
2420  thicknessWedgeMother = dzITC2 * Gaudi::Units::cm;
2421  heightWedgeMother = (rMaxITC2 - rMinITC2) * Gaudi::Units::cm;
2422  dy1WedgeMother = rMinITC2 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2423  dy2WedgeMother = rMaxITC2 * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2424 
2425  if (dbManager->TILBnperiod() > 1) {
2426  dzGlue = (dzITC2 - dbManager->TILBdzend1() - dbManager->TILBdzend2()
2427  - ((dbManager->TILBnperiod()-1)*2*(dbManager->TILBdzmast()
2428  + dbManager->TILBdzspac()) + dbManager->TILBdzspac()))/(4*(dbManager->TILBnperiod()-1));
2429  } else {
2430  dzGlue = 0; // add for special missing C10 modules
2431  }
2432 
2433  checking("Plug2Module (+)", false, 2,
2434  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2435 
2436  GeoTrd* plug2ModuleMotherPos = new GeoTrd(thicknessWedgeMother/2,
2437  thicknessWedgeMother/2,
2438  dy1WedgeMother,
2439  dy2WedgeMother,
2440  heightWedgeMother/2);
2441 
2442  GeoLogVol* lvPlug2ModuleMotherPos = new GeoLogVol("Plug2Module",plug2ModuleMotherPos,matAir);
2443  GeoPhysVol* pvPlug2ModuleMotherPos = new GeoPhysVol(lvPlug2ModuleMotherPos);
2444 
2445  // Fill the section
2446  if (Filling) {
2447  sectionBuilder->fillSection(pvPlug2ModuleMotherPos, Ic10,
2448  dbManager->TILBrmaximal(),
2449  dbManager->TILBrminimal(),
2450  dzGlue,
2451  deltaPhi);
2452  }
2453 
2454  // TILE_PLUG1, D4
2455  if ((Ifd4)) {
2456  dbManager->SetCurrentSectionByNumber(Id4);
2457 
2458  GeoTransform* tfPlug2ModuleMotherPos = new GeoTransform(itcModuleSubShiftPos);
2459 
2460  pvITCModuleMotherPos->add(tfPlug2ModuleMotherPos);
2461  pvITCModuleMotherPos->add(pvPlug2ModuleMotherPos);
2462  }
2463  }//if C10
2464 
2465  double zShift = 0;
2466  NbPeriod = dbManager->TILBnperiod();
2467  //ps Z = (dbManager->TILBdzmodul()-dzITC2)/2*Gaudi::Units::cm;
2468  Z = (dzITC1 - dzITC2)/2*Gaudi::Units::cm;
2469 
2470  if (NbPeriod == 6 && !Ifspecialgirder && std::abs(Z) < std::abs(zITCStandard)) zShift = zITCStandard*(1./Gaudi::Units::cm);
2471 
2472  if (m_log->level()<=MSG::DEBUG)
2473  (*m_log) << MSG::DEBUG <<" ITCModule Positive, position X= "<<X<<" Z= "<<Z
2474  <<" zStandard= "<<zITCStandard<< " zShift= " <<zShift
2475  <<endmsg;
2476 
2477  GeoTransform* xtraITCPos = new GeoTransform(GeoTrf::TranslateX3D(
2478  (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2*Gaudi::Units::cm));
2479  GeoTransform* ztraITCPos = new GeoTransform(GeoTrf::TranslateZ3D(zShift*Gaudi::Units::cm));
2480 
2481  pvITCMotherPos->add(zrotMod);
2482  pvITCMotherPos->add(xtraITCPos);
2483  pvITCMotherPos->add(ztraITCPos);
2484  pvITCMotherPos->add(XYrtMod);
2485 
2486  pvITCMotherPos->add(new GeoIdentifierTag(ModuleNcp));
2487  pvITCMotherPos->add(pvITCModuleMotherPos);
2488 
2489  }//if (Ifd4 || Ifc10)
2490 
2491 
2492  //-------------------------- G A P Positive ---------------------------------
2493  if (Ifgap && pvGapMotherPos) {
2494 
2495  // TILE_PLUG3
2496  dbManager->SetCurrentSectionByNumber(Igap);
2497 
2498  // Mother
2499  thicknessWedgeMother = dbManager->TILBdzmodul() * Gaudi::Units::cm;
2500  heightWedgeMother = (dbManager->TILBrmaximal() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
2501  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2502  dy2WedgeMother = dbManager->TILBrmaximal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2503 
2504  dzGlue = 0;
2505 
2506  checking("Plug2Module (+)", false, 2,
2507  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2508 
2509  GeoTrd* gapModuleMotherPos = new GeoTrd(thicknessWedgeMother/2,
2510  thicknessWedgeMother/2,
2511  dy1WedgeMother,
2512  dy2WedgeMother,
2513  heightWedgeMother/2);
2514 
2515  GeoLogVol* lvGapModuleMotherPos = new GeoLogVol("GapModule",gapModuleMotherPos,matAir);
2516  GeoPhysVol* pvGapModuleMotherPos = new GeoPhysVol(lvGapModuleMotherPos);
2517 
2518  // Fill the section
2519  if (Filling) {
2520  sectionBuilder->fillSection(pvGapModuleMotherPos, 5,
2521  dbManager->TILBrmaximal(),
2522  dbManager->TILBrminimal(),
2523  dzGlue,
2524  deltaPhi);
2525  }
2526 
2527  // Module position inside mother
2528  GeoTransform* xtraGapPos = new GeoTransform(GeoTrf::TranslateX3D(
2529  (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2*Gaudi::Units::cm));
2530  pvGapMotherPos->add(zrotMod);
2531  pvGapMotherPos->add(xtraGapPos);
2532  pvGapMotherPos->add(XYrtMod);
2533 
2534  pvGapMotherPos->add(new GeoIdentifierTag(ModuleNcp));
2535  pvGapMotherPos->add(pvGapModuleMotherPos);
2536  }
2537 
2538  //-------------------------- Crack Positive ---------------------------------
2539  if (Ifcrack && pvCrackMotherPos) {
2540 
2541  // TILE_PLUG4
2542  dbManager->SetCurrentSectionByNumber(Icrack);
2543 
2544  // Trd - module mother
2545  thicknessWedgeMother = dbManager->TILBdzmodul() * Gaudi::Units::cm;
2546  heightWedgeMother = (dbManager->TILBrmaximal() - dbManager->TILBrminimal()) * Gaudi::Units::cm;
2547  dy1WedgeMother = dbManager->TILBrminimal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2548  dy2WedgeMother = dbManager->TILBrmaximal() * tan(deltaPhi/2*Gaudi::Units::deg) * Gaudi::Units::cm;
2549 
2550  dzGlue = 0.;
2551 
2552  checking("CrackModule (+)", spE4, 2,
2553  thicknessWedgeMother/2,thicknessWedgeMother/2,dy1WedgeMother,dy2WedgeMother,heightWedgeMother/2);
2554 
2555  GeoTrd* crackModuleMotherPos = new GeoTrd(thicknessWedgeMother/2,
2556  thicknessWedgeMother/2,
2557  dy1WedgeMother,
2558  dy2WedgeMother,
2559  heightWedgeMother/2);
2560 
2561  GeoLogVol* lvCrackModuleMotherPos = new GeoLogVol("CrackModule",crackModuleMotherPos,matAir);
2562  GeoPhysVol* pvCrackModuleMotherPos = new GeoPhysVol(lvCrackModuleMotherPos);
2563 
2564  // Fill the section
2565  if (Filling) {
2566  sectionBuilder->fillSection(pvCrackModuleMotherPos, 6,
2567  dbManager->TILBrmaximal(),
2568  dbManager->TILBrminimal(),
2569  dzGlue,
2570  deltaPhi);
2571  }
2572 
2573  // Module position inside mother
2574  GeoTransform* xtraCrackPos = new GeoTransform(GeoTrf::TranslateX3D(
2575  (dbManager->TILBrmaximal() + dbManager->TILBrminimal())/2*Gaudi::Units::cm));
2576  pvCrackMotherPos->add(zrotMod);
2577  pvCrackMotherPos->add(xtraCrackPos);
2578  pvCrackMotherPos->add(XYrtMod);
2579 
2580  pvCrackMotherPos->add(new GeoIdentifierTag(ModuleNcp));
2581  pvCrackMotherPos->add(pvCrackModuleMotherPos);
2582 
2583  }
2584  }
2585 
2586  } // if (EnvType == 4 || EnvType == 5)
2587 
2588  }// ModCounter, end
2589 
2590 
2591  }
2592 
2593  //
2594  // Global Envelop positioning, BARREL Positive
2595  //
2596 
2597  //
2598  // ---------------------------------------- BARREL Positive -----------------------------------------------------
2599  //
2600 
2601  double ztrans =0;
2602  dbManager->SetCurrentEnvByType(EnvType);
2603 
2604  if (EnvType == 1 && barrel_flag < 1) {
2605 
2606  GeoTransform* tfBarrelMother;
2607 
2608  // consider 3 options - with/without ext.barrels and take into account DZ correction
2609  ztrans = 0;
2610 
2611  tfBarrelMother = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::RotateZ3D((dbManager->GetEnvDPhi())*Gaudi::Units::deg));
2612 
2613  (*m_log) << MSG::INFO <<" Positioning barrel with translation "<<ztrans*Gaudi::Units::cm<< endmsg;
2614 
2615  GeoNameTag* ntBarrelModuleMother = new GeoNameTag("Barrel");
2616 
2617  pvTileEnvelopeBarrel->add(tfBarrelMother);
2618  pvTileEnvelopeBarrel->add(ntBarrelModuleMother);
2619  pvTileEnvelopeBarrel->add(pvBarrelMother);
2620 
2621  GeoTransform* tfFingerMotherPos;
2622 
2623  ztrans = (dbManager->GetEnvZLength()*Gaudi::Units::cm/2 - BFingerLengthPos/2 + PosDelta)*(1./Gaudi::Units::cm);
2624 
2625  tfFingerMotherPos = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*GeoTrf::RotateZ3D((dbManager->GetEnvDPhi())*Gaudi::Units::deg));
2626 
2627  (*m_log) << MSG::INFO <<" Positioning positive barrel finger with translation "<<ztrans*Gaudi::Units::cm<< endmsg;
2628 
2629  GeoNameTag* ntFingerMotherPos = new GeoNameTag("TileFingerPos");
2630 
2631  pvTileEnvelopeBarrel->add(tfFingerMotherPos);
2632  pvTileEnvelopeBarrel->add(ntFingerMotherPos);
2633  pvTileEnvelopeBarrel->add(pvFingerMotherPos);
2634 
2635  if (dbManager->BoolSaddle()) {
2636  GeoTransform* tfSaddleMotherPos;
2637 
2638  ztrans = (dbManager->GetEnvZLength()*Gaudi::Units::cm/2 - BFingerLengthPos + DzSaddleSupport/2 + PosDelta)*(1./Gaudi::Units::cm);
2639 
2640  tfSaddleMotherPos = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*GeoTrf::RotateZ3D((dbManager->GetEnvDPhi())*Gaudi::Units::deg));
2641 
2642  GeoNameTag* ntSaddleMotherPos = new GeoNameTag("TileSaddlePos");
2643 
2644  pvTileEnvelopeBarrel->add(tfSaddleMotherPos);
2645  pvTileEnvelopeBarrel->add(ntSaddleMotherPos);
2646  pvTileEnvelopeBarrel->add(pvSaddleMotherPos);
2647  }
2648 
2649  //*> negative barrel
2650 
2651  GeoTransform* tfFingerMotherNeg;
2652 
2653  ztrans = (-dbManager->GetEnvZLength()*Gaudi::Units::cm/2 + BFingerLengthNeg/2 - NegDelta)*(1./Gaudi::Units::cm);
2654 
2655  tfFingerMotherNeg = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*GeoTrf::RotateZ3D((dbManager->GetEnvDPhi())*Gaudi::Units::deg));
2656 
2657  (*m_log) << MSG::INFO <<" Positioning negative barrel finger with translation "<<ztrans*Gaudi::Units::cm<< endmsg;
2658 
2659  GeoNameTag* ntFingerMotherNeg = new GeoNameTag("TileFingerNeg");
2660  pvTileEnvelopeBarrel->add(tfFingerMotherNeg);
2661  pvTileEnvelopeBarrel->add(ntFingerMotherNeg);
2662  pvTileEnvelopeBarrel->add(pvFingerMotherNeg);
2663 
2664  if (dbManager->BoolSaddle()) {
2665  GeoTransform* tfSaddleMotherNeg;
2666 
2667  ztrans = (-dbManager->GetEnvZLength()*Gaudi::Units::cm/2 + BFingerLengthNeg - DzSaddleSupport/2 - NegDelta)*(1./Gaudi::Units::cm);
2668 
2669  tfSaddleMotherNeg = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*GeoTrf::RotateZ3D((dbManager->GetEnvDPhi())*Gaudi::Units::deg));
2670 
2671  GeoNameTag* ntSaddleMotherNeg = new GeoNameTag("TileSaddleNeg");
2672 
2673  pvTileEnvelopeBarrel->add(tfSaddleMotherNeg);
2674  pvTileEnvelopeBarrel->add(ntSaddleMotherNeg);
2675  pvTileEnvelopeBarrel->add(pvSaddleMotherNeg);
2676  }
2677  }
2678 
2679  //
2680  //----------------------------------------- EBarrel Positive -----------------------------------------------------
2681 
2682  if (EnvType == 3 && eb_flag) { // positive ext.barrel is always at positive boundary, after finger
2683 
2685  double thicknessEndPlate = dbManager->TILBdzend1()*Gaudi::Units::cm;
2686 
2687  double PoZ1 = thicknessEndPlate + modl_length/4 - (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthPos)/2;
2688  double PoZ2 = modl_length/4 + PoZ1;
2689 
2690  //--------------------------------------------------------------------------------------------------------------
2691  // CutA in Tile (Positive) (close center)
2692  if (m_fullGeo) {
2693  if (dbManager->BoolCuts() && barrel_flag < 2) {
2694 
2695  // Iron1, down
2696  volname = "Iron1"; dbManager->SetCurrentCuts(volname); //>>
2697  dxIron = dbManager->CutsXpos();
2698  dyIron = dbManager->CutsYpos();
2699  if (m_log->level()<=MSG::DEBUG)
2700  (*m_log) << MSG::DEBUG << " Iron1: " << dxIron << " " << dyIron << endmsg;
2701 
2702  GeoTransform* tfIron1 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(dxIron,PosY-dyIron,PoZ2)
2703  * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2704  pvEBarrelMotherPos->add(tfIron1);
2705  pvEBarrelMotherPos->add(new GeoIdentifierTag(1));
2706  pvEBarrelMotherPos->add(pvIron1);
2707 
2708  tfIron1 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(-dxIron,PosY-dyIron,PoZ2)
2709  * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Right
2710  pvEBarrelMotherPos->add(tfIron1);
2711  pvEBarrelMotherPos->add(pvIron1);
2712 
2713  // Iron2, middle
2714  volname = "Iron2"; dbManager->SetCurrentCuts(volname); //>>
2715  dxIron = dbManager->CutsXpos();
2716  dyIron = dbManager->CutsYpos();
2717  if (m_log->level()<=MSG::DEBUG)
2718  (*m_log) << MSG::DEBUG << " Iron2: " << dxIron << " " << dyIron << endmsg;
2719 
2720  GeoTransform* tfIron2 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(dxIron,PosY+dyIron,PoZ2)
2721  * GeoTrf::RotateZ3D(-84.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2722  pvEBarrelMotherPos->add(tfIron2);
2723  pvEBarrelMotherPos->add(new GeoIdentifierTag(2));
2724  pvEBarrelMotherPos->add(pvIron2);
2725 
2726  tfIron2 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(-dxIron,PosY+dyIron,PoZ2)
2727  * GeoTrf::RotateZ3D(84.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2728  pvEBarrelMotherPos->add(tfIron2);
2729  pvEBarrelMotherPos->add(pvIron2);
2730 
2731  // Iron3, middle
2732  volname = "Iron3"; dbManager->SetCurrentCuts(volname); //>>
2733  dxIron = dbManager->CutsXpos();
2734  dyIron = dbManager->CutsYpos();
2735  if (m_log->level()<=MSG::DEBUG)
2736  (*m_log) << MSG::DEBUG << " Iron3: " << dxIron << " " << dyIron << endmsg;
2737 
2738  GeoTransform* tfIron3 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(dxIron,PosY+dyIron,PoZ2)
2739  * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2740  pvEBarrelMotherPos->add(tfIron3);
2741  pvEBarrelMotherPos->add(new GeoIdentifierTag(3));
2742  pvEBarrelMotherPos->add(pvIron3);
2743 
2744  tfIron3 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(-dxIron,PosY+dyIron,PoZ2)
2745  * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Right
2746  pvEBarrelMotherPos->add(tfIron3);
2747  pvEBarrelMotherPos->add(pvIron3);
2748 
2749  // Heavy Iron Box
2750  volname = "IrBox"; dbManager->SetCurrentCuts(volname); //>>
2751  dxIron = dbManager->CutsXpos();
2752  dyIron = dbManager->CutsYpos();
2753 
2754  GeoTransform* tfIrBoxL = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(dxIron,PosY-dyIron,PoZ2)
2755  * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2756  pvEBarrelMotherPos->add(tfIrBoxL);
2757  pvEBarrelMotherPos->add(new GeoIdentifierTag(4));
2758  pvEBarrelMotherPos->add(pvIrBox);
2759 
2760  GeoTransform* tfIrBoxR = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(-dxIron,PosY-dyIron,PoZ2)
2761  * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Right
2762  pvEBarrelMotherPos->add(tfIrBoxR);
2763  pvEBarrelMotherPos->add(pvIrBox);
2764 
2765  // CutB in Tile (Positive) (outer center)
2766  volname = "IrUp"; dbManager->SetCurrentCuts(volname); //>>
2767  dxIr = dbManager->CutsXpos();
2768  dyIr = dbManager->CutsYpos();
2769  if (m_log->level()<=MSG::DEBUG)
2770  (*m_log) << MSG::DEBUG << " IrUp: " <<dxIr<< " " <<dyIr<< endmsg;
2771 
2772  GeoTransform* tfIrUp = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)
2773  * GeoTrf::Translate3D(PosXcut+dxIr,-PosYcut+dyIr,-PoZ1)
2774  * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2775  pvEBarrelMotherPos->add(tfIrUp);
2776  pvEBarrelMotherPos->add(new GeoIdentifierTag(5));
2777  pvEBarrelMotherPos->add(pvIrUp);
2778 
2779  tfIrUp = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)
2780  * GeoTrf::Translate3D(-PosXcut-dxIr,-PosYcut+dyIr,-PoZ1)
2781  * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Right
2782  pvEBarrelMotherPos->add(tfIrUp);
2783  pvEBarrelMotherPos->add(pvIrUp);
2784 
2785  // CutB in Tile (Positive) (outer center)
2786  volname = "IrDw"; dbManager->SetCurrentCuts(volname); //>>
2787  dxIr = dbManager->CutsXpos();
2788  dyIr = dbManager->CutsYpos();
2789  if (m_log->level()<=MSG::DEBUG)
2790  (*m_log) << MSG::DEBUG << " IrDw: " <<dxIr<< " " <<dyIr<< endmsg;
2791 
2792  GeoTransform* tfIrDw = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)
2793  * GeoTrf::Translate3D(PosXcut+dxIr,-PosYcut+dyIr,-PoZ1)
2794  * GeoTrf::RotateZ3D(70.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2795  pvEBarrelMotherPos->add(tfIrDw);
2796  pvEBarrelMotherPos->add(new GeoIdentifierTag(6));
2797  pvEBarrelMotherPos->add(pvIrDw);
2798 
2799  tfIrDw = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)
2800  * GeoTrf::Translate3D(-PosXcut+dxIr,-PosYcut+dyIr,-PoZ1)
2801  * GeoTrf::RotateZ3D(-70.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2802 
2803  pvEBarrelMotherPos->add(tfIrDw);
2804  pvEBarrelMotherPos->add(pvIrDw);
2805  } // end if BoolCuts
2806  }
2807  //--------------------------------------------------------------------------------------------------------------
2808  // Ext.Barrel
2809  ztrans = (PosEndCrack + (dbManager->GetEnvZLength()*Gaudi::Units::cm - EBFingerLengthPos)/2 + 19.5)*(1./Gaudi::Units::cm);
2810 
2811  GeoTransform* tfEBarrelMotherPos = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) *
2812  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi()*Gaudi::Units::deg));
2813 
2814  (*m_log) << MSG::INFO <<" Positioning positive ext.barrel with translation "<< ztrans*Gaudi::Units::cm << endmsg;
2815 
2816  //
2817  GeoNameTag* ntEBarrelMotherPos = new GeoNameTag("EBarrelPos");
2818  pvTileEnvelopePosEndcap->add(tfEBarrelMotherPos);
2819  pvTileEnvelopePosEndcap->add(ntEBarrelMotherPos);
2820  pvTileEnvelopePosEndcap->add(new GeoIdentifierTag(3));
2821  pvTileEnvelopePosEndcap->add(pvEBarrelMotherPos);
2822  //
2823 
2824  if (barrel_flag < 2) {
2825 
2826  //--------------------------------------------------------------------------------------------------------------
2827  // Finger
2828  ztrans = (PosEndExBarrel + EBFingerLengthPos/2)*(1./Gaudi::Units::cm);
2829 
2830  GeoTransform* tfEFingerMotherPos = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) *
2831  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi() * Gaudi::Units::deg));
2832 
2833  (*m_log) << MSG::INFO <<" Positioning positive ext.barrel finger with translation ztrans= "<<ztrans*Gaudi::Units::cm<<endmsg;
2834 
2835  GeoNameTag* ntEFingerMotherPos = new GeoNameTag("TileEFingerPos");
2836 
2837  pvTileEnvelopePosEndcap->add(tfEFingerMotherPos);
2838  pvTileEnvelopePosEndcap->add(ntEFingerMotherPos);
2839  pvTileEnvelopePosEndcap->add(pvEFingerMotherPos);
2840 
2841  //--------------------------------------------------------------------------------------------------------------
2842  // Ext. Saddle Support
2843  if (dbManager->BoolSaddle()) {
2844  ztrans = (PosEndExBarrel + DzSaddleSupport/2)*(1./Gaudi::Units::cm);
2845 
2846  GeoTransform* tfESaddleMotherPos = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) *
2847  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi() * Gaudi::Units::deg));
2848 
2849  (*m_log) << MSG::INFO <<" Positioning positive ext.barrel saddle with translation ztrans= "<<ztrans*Gaudi::Units::cm
2850  << endmsg;
2851 
2852  GeoNameTag* ntESaddleMotherPos = new GeoNameTag("TileESaddlePos");
2853 
2854  pvTileEnvelopePosEndcap->add(tfESaddleMotherPos);
2855  pvTileEnvelopePosEndcap->add(ntESaddleMotherPos);
2856  pvTileEnvelopePosEndcap->add(pvESaddleMotherPos);
2857  }
2858 
2859  }
2860  }
2861 
2862  //----------------------------------------- EBarrel Negative -----------------------------------------------------
2863  //
2864  if (EnvType == 2 && eb_flag) { // negative ext.barrel is always at negative boundary, after finger
2865 
2867  double thicknessEndPlate = dbManager->TILBdzend1()*Gaudi::Units::cm;
2868 
2869  double PoZ1 = thicknessEndPlate + modl_length/4 - (dbManager->GetEnvZLength()*Gaudi::Units::cm- EBFingerLengthNeg)/2;
2870  double PoZ2 = modl_length/4 + PoZ1;
2871 
2872  //*>------------------------------------------------------------------------------------------------------
2873  // LArPart in Tile (Negative) (close center)
2874  if (m_fullGeo) {
2875  if (dbManager->BoolCuts() && barrel_flag < 2) {
2876  // Iron1, down
2877  volname = "Iron1"; dbManager->SetCurrentCuts(volname); //>>
2878  dxIron = dbManager->CutsXpos();
2879  dyIron = dbManager->CutsYpos();
2880 
2881  GeoTransform* tfIron1 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(dxIron,PosY-dyIron,-PoZ2)
2882  * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2883  pvEBarrelMotherNeg->add(tfIron1);
2884  pvEBarrelMotherNeg->add(new GeoIdentifierTag(1));
2885  pvEBarrelMotherNeg->add(pvIron1);
2886 
2887  tfIron1 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(-dxIron,PosY-dyIron,-PoZ2)
2888  * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Right
2889  pvEBarrelMotherNeg->add(tfIron1);
2890  pvEBarrelMotherNeg->add(new GeoIdentifierTag(2));
2891  pvEBarrelMotherNeg->add(pvIron1);
2892 
2893  // Iron2, middle
2894  volname = "Iron2"; dbManager->SetCurrentCuts(volname); //>>
2895  dxIron = dbManager->CutsXpos();
2896  dyIron = dbManager->CutsYpos();
2897 
2898  GeoTransform* tfIron2 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(dxIron,PosY+dyIron,-PoZ2)
2899  * GeoTrf::RotateZ3D(-84.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2900  pvEBarrelMotherNeg->add(tfIron2);
2901  pvEBarrelMotherNeg->add(new GeoIdentifierTag(2));
2902  pvEBarrelMotherNeg->add(pvIron2);
2903 
2904  tfIron2 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(-dxIron,PosY+dyIron,-PoZ2)
2905  * GeoTrf::RotateZ3D(84.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2906  pvEBarrelMotherNeg->add(tfIron2);
2907  pvEBarrelMotherNeg->add(pvIron2);
2908 
2909  // Iron3, middle
2910  volname = "Iron3"; dbManager->SetCurrentCuts(volname); //>>
2911  dxIron = dbManager->CutsXpos();
2912  dyIron = dbManager->CutsYpos();
2913 
2914  GeoTransform* tfIron3 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(dxIron,PosY+dyIron,-PoZ2)
2915  * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2916  pvEBarrelMotherNeg->add(tfIron3);
2917  pvEBarrelMotherNeg->add(new GeoIdentifierTag(3));
2918  pvEBarrelMotherNeg->add(pvIron3);
2919 
2920  tfIron3 = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(-dxIron,PosY+dyIron,-PoZ2)
2921  * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Right
2922  pvEBarrelMotherNeg->add(tfIron3);
2923  pvEBarrelMotherNeg->add(pvIron3);
2924 
2925  // Heavy Iron Box
2926  volname = "IrBox"; dbManager->SetCurrentCuts(volname); //>>
2927  dxIron = dbManager->CutsXpos();
2928  dyIron = dbManager->CutsYpos();
2929  GeoTransform* tfIrBoxL = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) * GeoTrf::Translate3D(dxIron,PosY-dyIron,-PoZ2)
2930  * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2931  pvEBarrelMotherNeg->add(tfIrBoxL);
2932  pvEBarrelMotherNeg->add(new GeoIdentifierTag(4));
2933  pvEBarrelMotherNeg->add(pvIrBox);
2934 
2935  GeoTransform* tfIrBoxR = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) *GeoTrf::Translate3D(-dxIron,PosY-dyIron,-PoZ2)
2936  * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Right
2937  pvEBarrelMotherNeg->add(tfIrBoxR);
2938  pvEBarrelMotherNeg->add(pvIrBox);
2939 
2940  // LArPart in Tile (Positive) (outer center)
2941  volname = "IrUp"; dbManager->SetCurrentCuts(volname); //>>
2942  dxIr = dbManager->CutsXpos();
2943  dyIr = dbManager->CutsYpos();
2944 
2945  GeoTransform* tfIrUp = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)
2946  * GeoTrf::Translate3D(PosXcut+dxIr,-PosYcut+dyIr,PoZ1)
2947  * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2948  pvEBarrelMotherNeg->add(tfIrUp);
2949  pvEBarrelMotherNeg->add(new GeoIdentifierTag(5));
2950  pvEBarrelMotherNeg->add(pvIrUp);
2951 
2952  tfIrUp = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)
2953  * GeoTrf::Translate3D(-PosXcut-dxIr,-PosYcut+dyIr,PoZ1)
2954  * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Right
2955  pvEBarrelMotherNeg->add(tfIrUp);
2956  pvEBarrelMotherNeg->add(pvIrUp);
2957 
2958  // CutB in Tile (Positive) (outer center)
2959  volname = "IrDw"; dbManager->SetCurrentCuts(volname); //>>
2960  dxIr = dbManager->CutsXpos();
2961  dyIr = dbManager->CutsYpos();
2962 
2963  GeoTransform* tfIrDw = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)
2964  * GeoTrf::Translate3D(PosXcut+dxIr,-PosYcut+dyIr,PoZ1)
2965  * GeoTrf::RotateZ3D(70.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2966  pvEBarrelMotherNeg->add(tfIrDw);
2967  pvEBarrelMotherNeg->add(new GeoIdentifierTag(6));
2968  pvEBarrelMotherNeg->add(pvIrDw);
2969 
2970  tfIrDw = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)
2971  * GeoTrf::Translate3D(-PosXcut+dxIr,-PosYcut+dyIr,PoZ1)
2972  * GeoTrf::RotateZ3D(-70.*Gaudi::Units::deg) * GeoTrf::RotateX3D(90.*Gaudi::Units::deg) * GeoTrf::RotateZ3D(90.*Gaudi::Units::deg)); // Left
2973 
2974  pvEBarrelMotherNeg->add(tfIrDw);
2975  pvEBarrelMotherNeg->add(pvIrDw);
2976  } // end if BoolCuts
2977  }
2978  //
2979  //*>------------------------------------------------------------------------------------------------------
2980  // Ext.Barrel
2981  ztrans = (-NegEndCrack - (dbManager->GetEnvZLength()*Gaudi::Units::cm - EBFingerLengthNeg)/2 - 19.5)*(1./Gaudi::Units::cm);
2982 
2983  GeoTransform* tfEBarrelMotherNeg = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) *
2984  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi()*Gaudi::Units::deg));
2985 
2986  (*m_log) << MSG::INFO <<" Positioning negative ext.barrel with translation ztrans "<<ztrans*Gaudi::Units::cm<<endmsg;
2987 
2988  GeoNameTag* ntEBarrelMotherNeg = new GeoNameTag("EBarrelNeg");
2989 
2990  pvTileEnvelopeNegEndcap->add(tfEBarrelMotherNeg);
2991  pvTileEnvelopeNegEndcap->add(ntEBarrelMotherNeg);
2992  pvTileEnvelopeNegEndcap->add(new GeoIdentifierTag(2));
2993  pvTileEnvelopeNegEndcap->add(pvEBarrelMotherNeg);
2994 
2995  if (barrel_flag < 2) {
2996 
2997  //*>------------------------------------------------------------------------------------------------------
2998  // Finger
2999  ztrans = (-NegEndExBarrel - EBFingerLengthPos/2)*(1./Gaudi::Units::cm);
3000 
3001  GeoTransform* tfEFingerMotherNeg = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) *
3002  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi() * Gaudi::Units::deg));
3003 
3004  (*m_log) << MSG::INFO <<" Positioning negative ext.barrel finger with translation ztrans= "<<ztrans*Gaudi::Units::cm<< endmsg;
3005 
3006  GeoNameTag* ntEFingerMotherNeg = new GeoNameTag("TileEFingerNeg");
3007 
3008  pvTileEnvelopeNegEndcap->add(tfEFingerMotherNeg);
3009  pvTileEnvelopeNegEndcap->add(ntEFingerMotherNeg);
3010  pvTileEnvelopeNegEndcap->add(pvEFingerMotherNeg);
3011 
3012  //*>------------------------------------------------------------------------------------------------------
3013  // Ext. Saddle Support
3014  if (dbManager->BoolSaddle()) {
3015  ztrans = (-NegEndExBarrel - DzSaddleSupport/2)*(1./Gaudi::Units::cm);
3016 
3017  GeoTransform* tfESaddleMotherNeg = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) *
3018  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi() * Gaudi::Units::deg));
3019 
3020  (*m_log) << MSG::INFO <<" Positioning negative ext.barrel saddle with translation ztrans= "<<ztrans*Gaudi::Units::cm
3021  << endmsg;
3022 
3023  GeoNameTag* ntESaddleMotherNeg = new GeoNameTag("TileESaddleNeg");
3024 
3025  pvTileEnvelopeNegEndcap->add(tfESaddleMotherNeg);
3026  pvTileEnvelopeNegEndcap->add(ntESaddleMotherNeg);
3027  pvTileEnvelopeNegEndcap->add(pvESaddleMotherNeg);
3028  }
3029 
3030  }
3031  }
3032 
3033  //
3034  // ---------------------------------------- ITC Positive -----------------------------------------------------
3035  //
3036 
3037  if (EnvType == 5) { // positive ITC attached to positive ext.barrel
3038 
3039  if (barrel_flag < 3) {
3040 
3042 
3043  ztrans = PosEndBarrelFinger*(1./Gaudi::Units::cm) + dbManager->TILBdzmodul()/2;
3044 
3045  //std::cout <<" ztrans "<<ztrans<<" PosEndBarrelFinger/Gaudi::Units::cm "<<PosEndBarrelFinger/Gaudi::Units::cm
3046  // <<" dbManager->TILBdzmodul()/2*Gaudi::Units::cm"<<dbManager->TILBdzmodul()/2<<"\n";
3047 
3048  (*m_log) << MSG::INFO <<" Positioning positive ITC with translation "<<ztrans*Gaudi::Units::cm<< endmsg;
3049 
3050  GeoTransform* tfITCMotherPos = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm) *
3051  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi() * Gaudi::Units::deg));
3052 
3053  GeoNameTag* ntITCMotherPos = new GeoNameTag("ITCPos");
3054 
3055  pvTileEnvelopePosEndcap->add(tfITCMotherPos);
3056  pvTileEnvelopePosEndcap->add(ntITCMotherPos);
3057  pvTileEnvelopePosEndcap->add(pvITCMotherPos);
3058 
3059  }
3060 
3061  if (barrel_flag < 4) {
3062 
3064  ztrans = PosBeginGap*(1./Gaudi::Units::cm) + dbManager->TILBdzmodul()/2;
3065 
3066  (*m_log) << MSG::INFO <<" Positioning positive Gap with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3067 
3068  GeoTransform* tfGapMotherPos = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*
3069  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi()*Gaudi::Units::deg));
3070 
3071  GeoNameTag* ntGapMotherPos = new GeoNameTag("GapPos");
3072 
3073  pvTileEnvelopePosEndcap->add(tfGapMotherPos);
3074  pvTileEnvelopePosEndcap->add(ntGapMotherPos);
3075  pvTileEnvelopePosEndcap->add(pvGapMotherPos);
3076 
3077  }
3078 
3079  // Crack
3080  if (crack_flag<=0 || pvTileEnvelopePosCrack) {
3081 
3083  ztrans = PosBeginCrack*(1./Gaudi::Units::cm) + dbManager->TILBdzmodul()/2;
3084 
3085  if (crack_flag<=0) {
3086  (*m_log) << MSG::INFO <<" Positioning positive Crack with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3087  } else if (crack_flag==1) {
3088  (*m_log) << MSG::INFO <<" Positioning positive Crack in separate mother volume with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3089  } else {
3090  ztrans = (m_volumePositions.size()>0) ? m_volumePositions[0] : 0.0;
3091  (*m_log) << MSG::INFO <<" Positioning positive Crack in " << pvTileEnvelopePosCrack->getLogVol()->getName() << " mother volume with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3092  }
3093 
3094  GeoTransform* tfCrackMotherPos = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*
3095  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi()*Gaudi::Units::deg));
3096 
3097  GeoNameTag* ntCrackMotherPos = new GeoNameTag("CrackPos");
3098 
3099  if (crack_flag<=0) {
3100  pvTileEnvelopePosEndcap->add(tfCrackMotherPos);
3101  pvTileEnvelopePosEndcap->add(ntCrackMotherPos);
3102  pvTileEnvelopePosEndcap->add(pvCrackMotherPos);
3103  } else {
3104  pvTileEnvelopePosCrack->add(tfCrackMotherPos);
3105  pvTileEnvelopePosCrack->add(ntCrackMotherPos);
3106  pvTileEnvelopePosCrack->add(pvCrackMotherPos);
3107  }
3108  } else {
3109  (*m_log) << MSG::INFO <<" Do not create positive Crack"<<endmsg;
3110  }
3111 
3112  }
3113 
3114  //
3115  // ---------------------------------------- ITC Negative -----------------------------------------------------
3116  //
3117 
3118  // negative ITC attached to negative ext.barrel
3119  if (EnvType == 4) {
3120 
3121  if (barrel_flag < 3) {
3122 
3124  ztrans = -NegEndBarrelFinger*(1./Gaudi::Units::cm) - dbManager->TILBdzmodul()/2;
3125 
3126  (*m_log) << MSG::INFO <<" Positioning negative ITC with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3127 
3128  GeoTransform* tfITCMotherNeg = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*
3129  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi()*Gaudi::Units::deg));
3130 
3131  GeoNameTag* ntITCMotherNeg = new GeoNameTag("ITCNeg");
3132 
3133  pvTileEnvelopeNegEndcap->add(tfITCMotherNeg);
3134  pvTileEnvelopeNegEndcap->add(ntITCMotherNeg);
3135  pvTileEnvelopeNegEndcap->add(pvITCMotherNeg);
3136 
3137  }
3138 
3139  if (barrel_flag < 4) {
3140 
3142  ztrans = -NegBeginGap*(1./Gaudi::Units::cm) - dbManager->TILBdzmodul()/2;
3143 
3144  (*m_log) << MSG::INFO <<" Positioning negative Gap with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3145 
3146  GeoTransform* tfGapMotherNeg = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*
3147  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi()*Gaudi::Units::deg));
3148 
3149  GeoNameTag* ntGapMotherNeg = new GeoNameTag("GapNeg");
3150 
3151  pvTileEnvelopeNegEndcap->add(tfGapMotherNeg);
3152  pvTileEnvelopeNegEndcap->add(ntGapMotherNeg);
3153  pvTileEnvelopeNegEndcap->add(pvGapMotherNeg);
3154 
3155  }
3156 
3157  // Crack
3158  if (crack_flag<=0 || pvTileEnvelopeNegCrack) {
3159 
3161  ztrans = -NegBeginCrack*(1./Gaudi::Units::cm) - dbManager->TILBdzmodul()/2;
3162 
3163  if (crack_flag<=0) {
3164  (*m_log) << MSG::INFO <<" Positioning negative Crack with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3165  } else if (crack_flag==1) {
3166  (*m_log) << MSG::INFO <<" Positioning negative Crack in separate mother volume with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3167  } else {
3168  ztrans = (m_volumePositions.size()>1) ? m_volumePositions[1] : (m_volumePositions.size()>0) ? m_volumePositions[0] : 0.0;
3169  (*m_log) << MSG::INFO <<" Positioning positive Crack in " << pvTileEnvelopeNegCrack->getLogVol()->getName() << " mother volume with translation "<<ztrans*Gaudi::Units::cm<<endmsg;
3170  }
3171 
3172  GeoTransform* tfCrackMotherNeg = new GeoTransform(GeoTrf::TranslateZ3D(ztrans*Gaudi::Units::cm)*
3173  GeoTrf::RotateZ3D(dbManager->GetEnvDPhi()*Gaudi::Units::deg));
3174 
3175  GeoNameTag* ntCrackMotherNeg = new GeoNameTag("CrackNeg");
3176 
3177  if (crack_flag<=0) {
3178  pvTileEnvelopeNegEndcap->add(tfCrackMotherNeg);
3179  pvTileEnvelopeNegEndcap->add(ntCrackMotherNeg);
3180  pvTileEnvelopeNegEndcap->add(pvCrackMotherNeg);
3181  } else {
3182  pvTileEnvelopeNegCrack->add(tfCrackMotherNeg);
3183  pvTileEnvelopeNegCrack->add(ntCrackMotherNeg);
3184  pvTileEnvelopeNegCrack->add(pvCrackMotherNeg);
3185  }
3186  } else {
3187  (*m_log) << MSG::INFO <<" Do not create negative Crack"<<endmsg;
3188  }
3189 
3190  }
3191  } // EnvCounter, end
3192 
3193  //
3194  // creating Descriptiors and CaloDetDescrElements
3195  //
3196 
3197  if (barrel_flag<4 || (barrel_flag==4 && crack_flag<2) ) { // create descriptors only if top-level volumes were created
3198 
3199  (*m_log) << MSG::DEBUG << "Creating descriptors for " << dbManager->GetNumberOfEnv() << " envelopes..." << endmsg;
3200 
3201  int nModulesInSection[6] = {0,0,0,0,0,0};
3202  double zShiftInSection[6] = {0.0,0.0,0.0,0.0,0.0,0.0,};
3203 
3204 
3205  for (int EnvCounter = 0; EnvCounter < dbManager->GetNumberOfEnv(); ++EnvCounter) { //Loop over Envelopes
3206 
3207  dbManager->SetCurrentEnvByIndex(EnvCounter);
3208  int EnvType = dbManager->GetEnvType();
3209  int NumberOfMod = dbManager->GetEnvNModules();
3210  double Zshift = dbManager->GetEnvZShift()*Gaudi::Units::cm;
3211 
3212  if (m_log->level()<=MSG::DEBUG)
3213  (*m_log) << MSG::DEBUG
3214  << " EnvCounter is " << EnvCounter
3215  << " EnvType is " << EnvType
3216  << " Zshift is " << Zshift*(1./Gaudi::Units::cm) << " cm"
3217  << endmsg;
3218 
3219  // Central barrel
3220  if (EnvType == 1 || EnvType == 0) {
3221  nModulesInSection[0] = nModulesInSection[1] = NumberOfMod;
3222  zShiftInSection[0] = zShiftInSection[1] = Zshift;
3223  } else if (EnvType < 6) {
3224  nModulesInSection[EnvType] = NumberOfMod;
3225  zShiftInSection[EnvType] = Zshift;
3226  }
3227  }
3228 
3229  const TileID* tileID = m_detectorManager->get_id();
3230 
3233  int side[6] = {0,1,0,1,0,1};
3234 
3235 
3236  (*m_log) << MSG::DEBUG << "Loop over Tile detector regions, and call computeCellDim() when needed..." << endmsg;
3237  for (int ii=0; ii<6; ++ii) {
3238 
3239  (*m_log) << MSG::DEBUG << "ii: " << ii << ", region: " << dete[ii] << endmsg;
3240 
3241  if (ii%2 == 0) {
3242  (*m_log) << MSG::DEBUG << "ii: " << ii << ", region: " << dete[ii] << " --> calling computeCellDim()..." << endmsg;
3243  sectionBuilder->computeCellDim(m_detectorManager, dete[ii],
3245  zShiftInSection[ii+1], // zShiftPos
3246  zShiftInSection[ii]); // zShiftNeg
3247  }
3248 
3249  (*m_log) << MSG::DEBUG << "calling fillDescriptor()..." << endmsg;
3250  TileDetDescriptor* descriptor = new TileDetDescriptor();
3251  sectionBuilder->fillDescriptor(descriptor, dete[ii], side[ii],
3252  m_switches.testBeam, // set to false - ATLAS geometry
3253  m_switches.addPlatesToCell, // add front/end plates to cell volume
3254  nModulesInSection[ii], // 0-64 modules
3255  zShiftInSection[ii]); // Z-shift
3256 
3257  (*m_log) << MSG::DEBUG << "Get an Identifier for the region and add it to the detectorManager..." << endmsg;
3258  Identifier idRegion = tileID->region_id(ii);
3259  descriptor->set(idRegion);
3260  m_detectorManager->add(descriptor);
3261  m_detectorManager->add(new TileDetDescrRegion(idRegion, descriptor));
3262  }
3263  }
3264 
3265  // --------- ----------- --------- -------- ------ --------- ------- ----------
3266  GeoNameTag *nTag = new GeoNameTag("Tile");
3267 
3268  if (BAR && barrel_flag<1) {
3269  world->add(nTag);
3270 
3271  // Top transform for the Central barrel
3272  dbManager->SetCurrentEnvByType(1);
3273  GeoTrf::Transform3D mz = GeoTrf::RotateZ3D(dbManager->GetEnvDPhi());
3274  GeoTrf::Transform3D my = GeoTrf::RotateY3D(dbManager->GetEnvDTheta());
3275  GeoTrf::Transform3D mx = GeoTrf::RotateZ3D(dbManager->GetEnvDPsi());
3276  GeoTrf::Transform3D vpos = GeoTrf::Translate3D(dbManager->GetEnvDX()*Gaudi::Units::cm,dbManager->GetEnvDY()*Gaudi::Units::cm,dbManager->GetEnvDZ()*Gaudi::Units::cm);
3277  GeoTransform* barrelTT = new GeoTransform(GeoTrf::Transform3D(vpos*(mx*(my*(mz)))));
3278 
3279  (*m_log) << MSG::INFO << " Global positioning of barrel with rotation ("
3280  << dbManager->GetEnvDPhi() << "," << dbManager->GetEnvDTheta() << "," << dbManager->GetEnvDPsi() << ")"
3281  << ") and translation (" << dbManager->GetEnvDX() << "," << dbManager->GetEnvDY() << "," << dbManager->GetEnvDZ()
3282  << ") Gaudi::Units::cm" << endmsg;
3283 
3284  world->add(barrelTT);
3285  world->add(pvTileEnvelopeBarrel);
3286  m_detectorManager->addTreeTop(pvTileEnvelopeBarrel);
3287  }
3288 
3289  if (EBA && eb_flag) {
3290  world->add(nTag);
3291 
3292  // Top transform for the Positive endcap
3293  dbManager->SetCurrentEnvByType(3);
3294  GeoTrf::Transform3D mz = GeoTrf::RotateZ3D(dbManager->GetEnvDPhi());
3295  GeoTrf::Transform3D my = GeoTrf::RotateY3D(dbManager->GetEnvDTheta());
3296  GeoTrf::Transform3D mx = GeoTrf::RotateZ3D(dbManager->GetEnvDPsi());
3297  GeoTrf::Transform3D vpos = GeoTrf::Translate3D(dbManager->GetEnvDX()*Gaudi::Units::cm,dbManager->GetEnvDY()*Gaudi::Units::cm,dbManager->GetEnvDZ()*Gaudi::Units::cm);
3298  GeoTransform* posEcTT = new GeoTransform(GeoTrf::Transform3D(vpos*(mx*(my*(mz)))));
3299 
3300  (*m_log) << MSG::INFO << " Global positioning of positive ext.barrel with rotation ("
3301  << dbManager->GetEnvDPhi() << "," << dbManager->GetEnvDTheta() << "," << dbManager->GetEnvDPsi() << ")"
3302  << ") and translation (" << dbManager->GetEnvDX() << "," << dbManager->GetEnvDY() << "," << dbManager->GetEnvDZ()
3303  << ") Gaudi::Units::cm" << endmsg;
3304 
3305  world->add(posEcTT);
3306  world->add(pvTileEnvelopePosEndcap);
3307  m_detectorManager->addTreeTop(pvTileEnvelopePosEndcap);
3308  }
3309 
3310  if (EBC && eb_flag) {
3311  world->add(nTag);
3312 
3313  // Top transform for the Negative endcap
3314  dbManager->SetCurrentEnvByType(2);
3315  GeoTrf::Transform3D mz = GeoTrf::RotateZ3D(dbManager->GetEnvDPhi());
3316  GeoTrf::Transform3D my = GeoTrf::RotateY3D(dbManager->GetEnvDTheta());
3317  GeoTrf::Transform3D mx = GeoTrf::RotateZ3D(dbManager->GetEnvDPsi());
3318  GeoTrf::Transform3D vpos = GeoTrf::Translate3D(dbManager->GetEnvDX()*Gaudi::Units::cm,dbManager->GetEnvDY()*Gaudi::Units::cm,dbManager->GetEnvDZ()*Gaudi::Units::cm);
3319  GeoTransform* negEcTT = new GeoTransform(GeoTrf::Transform3D(vpos*(mx*(my*(mz)))));
3320 
3321  (*m_log) << MSG::INFO << " Global positioning of negative ext.barrel with rotation ("
3322  << dbManager->GetEnvDPhi() << "," << dbManager->GetEnvDTheta() << "," << dbManager->GetEnvDPsi() << ")"
3323  << ") and translation (" << dbManager->GetEnvDX() << "," << dbManager->GetEnvDY() << "," << dbManager->GetEnvDZ()
3324  << ") Gaudi::Units::cm" << endmsg;
3325 
3326  world->add(negEcTT);
3327  world->add(pvTileEnvelopeNegEndcap);
3328  m_detectorManager->addTreeTop(pvTileEnvelopeNegEndcap);
3329 
3330  }
3331 
3332  if (crack_flag==1) {
3333 
3334  // repeating the same for crack in EBA
3335  if (EBA && pvTileEnvelopePosCrack) {
3336  //GeoNameTag *nTag = new GeoNameTag("TileCrackEBA");
3337  world->add(nTag);
3338 
3339  // Top transform for the Positive crack
3340  dbManager->SetCurrentEnvByType(5);
3341  GeoTrf::Transform3D mz = GeoTrf::RotateZ3D(dbManager->GetEnvDPhi());
3342  GeoTrf::Transform3D my = GeoTrf::RotateY3D(dbManager->GetEnvDTheta());
3343  GeoTrf::Transform3D mx = GeoTrf::RotateZ3D(dbManager->GetEnvDPsi());
3344  GeoTrf::Transform3D vpos = GeoTrf::Translate3D(dbManager->GetEnvDX()*Gaudi::Units::cm,dbManager->GetEnvDY()*Gaudi::Units::cm,dbManager->GetEnvDZ()*Gaudi::Units::cm);
3345  GeoTransform* posCrackTT = new GeoTransform(GeoTrf::Transform3D(vpos*(mx*(my*(mz)))));
3346 
3347  (*m_log) << MSG::INFO << " Global positioning of positive Crack with rotation ("
3348  << dbManager->GetEnvDPhi() << "," << dbManager->GetEnvDTheta() << "," << dbManager->GetEnvDPsi() << ")"
3349  << ") and translation (" << dbManager->GetEnvDX() << "," << dbManager->GetEnvDY() << "," << dbManager->GetEnvDZ()
3350  << ") Gaudi::Units::cm" << endmsg;
3351 
3352  world->add(posCrackTT);
3353  world->add(pvTileEnvelopePosCrack);
3354  m_detectorManager->addTreeTop(pvTileEnvelopePosCrack);
3355 
3356  }
3357 
3358  // repeating the same for crack in EBC
3359  if (EBC && pvTileEnvelopeNegCrack) {
3360  //GeoNameTag *nTag = new GeoNameTag("TileCrackEBC");
3361  world->add(nTag);
3362 
3363  // Top transform for the Negative endcap
3364  dbManager->SetCurrentEnvByType(4);
3365  GeoTrf::Transform3D mz = GeoTrf::RotateZ3D(dbManager->GetEnvDPhi());
3366  GeoTrf::Transform3D my = GeoTrf::RotateY3D(dbManager->GetEnvDTheta());
3367  GeoTrf::Transform3D mx = GeoTrf::RotateZ3D(dbManager->GetEnvDPsi());
3368  GeoTrf::Transform3D vpos = GeoTrf::Translate3D(dbManager->GetEnvDX()*Gaudi::Units::cm,dbManager->GetEnvDY()*Gaudi::Units::cm,dbManager->GetEnvDZ()*Gaudi::Units::cm);
3369  GeoTransform* negCrackTT = new GeoTransform(GeoTrf::Transform3D(vpos*(mx*(my*(mz)))));
3370 
3371  (*m_log) << MSG::INFO << " Global positioning of negative Crack with rotation ("
3372  << dbManager->GetEnvDPhi() << "," << dbManager->GetEnvDTheta() << "," << dbManager->GetEnvDPsi() << ")"
3373  << ") and translation (" << dbManager->GetEnvDX() << "," << dbManager->GetEnvDY() << "," << dbManager->GetEnvDZ()
3374  << ") Gaudi::Units::cm" << endmsg;
3375 
3376  world->add(negCrackTT);
3377  world->add(pvTileEnvelopeNegCrack);
3378  m_detectorManager->addTreeTop(pvTileEnvelopeNegCrack);
3379  }
3380 
3381  }
3382 
3383  delete sectionBuilder;
3384  //delete CutBuilder;
3385 
3386 }
3387 
3388 
3389 // Checking geometry dimensions for all directions
3390 
3391 void TileAtlasFactory::checking(const std::string& Name, bool print, int level,
3392  double X1, double X2, double Y1, double Y2, double Z)
3393 {
3394  double rless = .150; //150 [mkm]
3395  std::string Step[8] = {" "," "," "," "," "," "," "," "};
3396 
3397  if (print) {
3398  if (m_log->level()<=MSG::DEBUG)
3399  (*m_log) << MSG::DEBUG <<Step[level]<<Name<<"-"<<level
3400  <<" dX1,dX2= "<<X1<<","<<X2<<" dY1,dY2= "<<Y1<<","<<Y2<<",dZ= "<<Z
3401  <<endmsg;
3402  }
3403  if (X1 < rless && X2 < rless) {
3404  (*m_log) << MSG::WARNING <<" volume "<<Name<<" is empty, X1 or X2<0 "<<endmsg;
3405  }
3406  if (Y1 < rless && Y2 < rless) {
3407  (*m_log) << MSG::WARNING <<" volume "<<Name<<" is empty, Y1 or Y2<0 "<<endmsg;
3408  }
3409  if (Z < rless) {
3410  (*m_log) << MSG::WARNING <<" volume "<<Name<<" is empty, Z<0 "<<endmsg;
3411  }
3412 }
geoGetVolumes
GeoVolumeVec_t geoGetVolumes(const GeoGraphNode *node, int depthLimit=1, int sizeHint=20)
Return the child volumes and associated transforms.
Definition: GeoVisitVolumes.cxx:211
TBXMLWriter_jobOptions.PhiMin
PhiMin
Definition: TBXMLWriter_jobOptions.py:32
TileDddbManager::TILE_PLUG3
@ TILE_PLUG3
Definition: TileDddbManager.h:46
TileDddbManager::GetEnvRin
double GetEnvRin() const
Definition: TileDddbManager.cxx:274
TileDddbManager::SetCurrentEnvByIndex
int SetCurrentEnvByIndex(unsigned int envelope)
Definition: TileDddbManager.cxx:209
TileDddbManager::SetCurrentEnvByType
int SetCurrentEnvByType(unsigned int envelope)
Definition: TileDddbManager.cxx:174
TileDddbManager::TIFGdz
double TIFGdz() const
Definition: TileDddbManager.cxx:1336
TileDddbManager::TILE_BARREL
@ TILE_BARREL
Definition: TileDddbManager.h:42
max
#define max(a, b)
Definition: cfImp.cxx:41
TileGeoSectionBuilder.h
Definition of TileGeoSectionBuilder class.
TileDddbManager::SetCurrentSection
int SetCurrentSection(unsigned int section, bool print=true)
Definition: TileDddbManager.cxx:616
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
fitman.my
my
Definition: fitman.py:523
TileDddbManager::TILE_PLUG1
@ TILE_PLUG1
Definition: TileDddbManager.h:44
GeoVolumeVec_t
std::vector< std::pair< const GeoVPhysVol *, GeoTrf::Transform3D > > GeoVolumeVec_t
Return the child volumes and associated transforms.
Definition: GeoVisitVolumes.h:219
TileDddbManager::GetEnvDZ
double GetEnvDZ() const
Definition: TileDddbManager.cxx:331
TileDddbManager::SetCurrentTifg
int SetCurrentTifg(int section)
Definition: TileDddbManager.cxx:1294
TileDddbManager::RadiusSaddle
double RadiusSaddle() const
Definition: TileDddbManager.cxx:1196
TileDddbManager::TILBrmax
double TILBrmax() const
Definition: TileDddbManager.cxx:679
TileDddbManager::TILE_PLUG4
@ TILE_PLUG4
Definition: TileDddbManager.h:47
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
TileDetDescrManager::addTreeTop
void addTreeTop(PVConstLink)
Definition: TileDetDescrManager.cxx:88
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
TileDddbManager::GetEnvDPsi
double GetEnvDPsi() const
Definition: TileDddbManager.cxx:371
TileAtlasFactory::create
virtual void create(GeoPhysVol *world)
Creation of Tile geometry.
Definition: TileAtlasFactory.cxx:100
TileDddbManager::BoolSaddle
bool BoolSaddle()
Definition: TileDddbManager.cxx:1177
TileDddbManager::SetCurrentCuts
int SetCurrentCuts(std::string input)
Fields of CUTS structure (see also Oracle comments):
Definition: TileDddbManager.cxx:1048
TileDddbManager::GetEnvDY
double GetEnvDY() const
Definition: TileDddbManager.cxx:360
TileAtlasFactory::TileAtlasFactory
TileAtlasFactory(StoreGateSvc *pDetStore, TileDetDescrManager *manager, const TileSwitches &switches, MsgStream *log, bool fullGeo)
Constructor.
Definition: TileAtlasFactory.cxx:57
TileDddbManager::GetEnvDPhi
double GetEnvDPhi() const
Definition: TileDddbManager.cxx:314
deg
#define deg
Definition: SbPolyhedron.cxx:17
TBXMLWriter_jobOptions.PhiMax
PhiMax
Definition: TBXMLWriter_jobOptions.py:33
TileDddbManager::GetModType
int GetModType() const
Definition: TileDddbManager.cxx:471
TileAtlasFactory.h
Definition of TileAtlasFactory class.
TileSwitches::testBeam
bool testBeam
setting up testbeam geometry or ATLAS geometry
Definition: TileSwitches.h:31
TileDddbManager::GetNumberOfEnv
int GetNumberOfEnv() const
Definition: TileDddbManager.cxx:158
fitman.mx
mx
Definition: fitman.py:520
TileDddbManager::TILBdzmodul
double TILBdzmodul() const
Definition: TileDddbManager.cxx:800
TileDddbManager::TILEzshift
double TILEzshift() const
Definition: TileDddbManager.cxx:147
TILE_REGION_EXTENDED
#define TILE_REGION_EXTENDED
Definition: TileGeoSectionBuilder.h:23
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
TileGeoSectionBuilder::setBarrelGlue
void setBarrelGlue(double val)
Definition: TileGeoSectionBuilder.cxx:3466
TileDddbManager::SetCurrentSectionByNumber
int SetCurrentSectionByNumber(unsigned int section)
Definition: TileDddbManager.cxx:611
TileAtlasFactory::m_detectorStore
StoreGateSvc * m_detectorStore
Detector pointer to Store Gate service.
Definition: TileAtlasFactory.h:63
TileDddbManager::TILE_PLUG2
@ TILE_PLUG2
Definition: TileDddbManager.h:45
TileDddbManager::TILBrmin
double TILBrmin() const
Definition: TileDddbManager.cxx:668
TileDddbManager::TILBzoffset
double TILBzoffset() const
Definition: TileDddbManager.cxx:767
TileDddbManager::TILErmam
double TILErmam() const
Definition: TileDddbManager.cxx:127
TileID.h
TileDetDescrManager.h
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
TRT::Hit::side
@ side
Definition: HitInfo.h:83
TileAtlasFactory::m_log
MsgStream * m_log
Get message SVC.
Definition: TileAtlasFactory.h:69
TileAtlasFactory::m_fullGeo
bool m_fullGeo
Geometry configuration: FULL, RECO.
Definition: TileAtlasFactory.h:83
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
TileGeoSectionBuilder::fillDescriptor
void fillDescriptor(TileDetDescriptor *&descriptor, unsigned int detector, int side, bool testbeam, bool addPlates, unsigned int nphi, float zshift)
Readout Descriptor parameters are the following:
Definition: TileGeoSectionBuilder.cxx:2454
GeoVisitVolumes.h
Visitor to process all volumes under a GeoModel node.
Tile_Base_ID::region_id
Identifier region_id(int index) const
build single region, module, tower, cell, pmt, adc identifiers
Definition: Tile_Base_ID.cxx:405
Type
RootType Type
Definition: TrigTSerializer.h:30
TileDetDescriptor::set
void set(const Identifier &id)
Definition: TileDetDescriptor.h:244
TileDddbManager::CutsXpos
double CutsXpos() const
Definition: TileDddbManager.cxx:1140
TileAtlasFactory::~TileAtlasFactory
~TileAtlasFactory()
Destructor.
Definition: TileAtlasFactory.cxx:96
lumiFormat.i
int i
Definition: lumiFormat.py:92
TileDetDescrManager
Definition: TileDetDescrManager.h:33
TileID
Helper class for TileCal offline identifiers.
Definition: TileID.h:68
TileDddbManager::GetEnvDX
double GetEnvDX() const
Definition: TileDddbManager.cxx:349
MSG
Definition: MsgLevel.h:28
Atlas.StoreGateSvc
StoreGateSvc
Definition: Atlas.UnixStandardJob.py:25
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TileDetDescrRegion
Definition: TileDetDescrRegion.h:40
TileDddbManager::DzSaddleSupport
double DzSaddleSupport() const
Definition: TileDddbManager.cxx:1186
TileDddbManager::TILBdzgir
double TILBdzgir() const
Definition: TileDddbManager.cxx:925
TileDddbManager::GetEnvZShift
double GetEnvZShift() const
Definition: TileDddbManager.cxx:393
TileDetDescriptor
Definition: TileDetDescriptor.h:46
TileDddbManager::GetEnvZLength
double GetEnvZLength() const
Definition: TileDddbManager.cxx:296
fitman.mz
mz
Definition: fitman.py:526
TileDddbManager::TILBdzend1
double TILBdzend1() const
Definition: TileDddbManager.cxx:833
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
TileGeoSectionBuilder::fillFinger
void fillFinger(GeoPhysVol *&mother, int sec_number, double tile_rmax, double tilb_rmax, double delta_phi_not_used, bool testbeam, int ModuleNcp=0, double corrected_dz=0.)
Finger parameters are the following:
Definition: TileGeoSectionBuilder.cxx:1435
TileDddbManager::TILBrmaximal
double TILBrmaximal() const
Definition: TileDddbManager.cxx:701
TileSwitches
Definition: TileSwitches.h:15
TileAtlasFactory::m_switches
TileSwitches m_switches
all switches
Definition: TileAtlasFactory.h:72
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
xAODType
Definition: ObjectType.h:13
TileAtlasFactory::checking
void checking(const std::string &VolumeName, bool print, int level, double X1, double X2, double Y1, double Y2, double Z)
Function for checking empty volumes:
Definition: TileAtlasFactory.cxx:3391
min
#define min(a, b)
Definition: cfImp.cxx:40
TileDddbManager::GetModTypeSize
unsigned int GetModTypeSize() const
Definition: TileDddbManager.cxx:575
TileAtlasFactory::m_volumeNames
std::vector< std::string > m_volumeNames
all additional variables which passed to constructor
Definition: TileAtlasFactory.h:75
TILE_REGION_CENTRAL
#define TILE_REGION_CENTRAL
Definition: TileGeoSectionBuilder.h:22
TileSwitches::addPlatesToCell
bool addPlatesToCell
calculate cell volumes with or without front-plates and end-plates
Definition: TileSwitches.h:34
TileDddbManager::BoolCuts
bool BoolCuts()
Definition: TileDddbManager.cxx:1071
TILE_REGION_GAP
#define TILE_REGION_GAP
Definition: TileGeoSectionBuilder.h:24
StoredMaterialManager.h
TileDddbManager::CutsDY2
double CutsDY2() const
Definition: TileDddbManager.cxx:1120
TileDddbManager::TILBdzspac
double TILBdzspac() const
Definition: TileDddbManager.cxx:822
TileDddbManager::TILE_EBARREL
@ TILE_EBARREL
Definition: TileDddbManager.h:43
TileGeoSectionBuilder::setBarrelPeriodThickness
void setBarrelPeriodThickness(double val)
Definition: TileGeoSectionBuilder.cxx:3460
TileGeoCutBuilder.h
Definition of TileGeoSectionBuioder class.
TileDddbManager::CutsDX1
double CutsDX1() const
Definition: TileDddbManager.cxx:1090
TileDetDescrManager::add
void add(TileDetDescrRegion *region)
Definition: TileDetDescrManager.cxx:894
TileDddbManager.h
python.PyAthena.v
v
Definition: PyAthena.py:157
TileDddbManager::TILBrminimal
double TILBrminimal() const
Definition: TileDddbManager.cxx:690
TileDddbManager::CutsYpos
double CutsYpos() const
Definition: TileDddbManager.cxx:1150
TileSwitches::crackOption
int crackOption
0: crack scintillators in ext.barrel top-level envelopes 1: crack scintillators in separate TileCal t...
Definition: TileSwitches.h:70
Name
JetDumper::Name Name
Definition: JetDumper.cxx:19
TileAtlasFactory::m_detectorManager
TileDetDescrManager * m_detectorManager
Detector pointer to TileDetDescrManager.
Definition: TileAtlasFactory.h:66
GeoGenfun
Definition: ArrayFunction.cxx:7
TileDddbManager::CutsDZ1
double CutsDZ1() const
Definition: TileDddbManager.cxx:1130
DEBUG
#define DEBUG
Definition: page_access.h:11
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
StoredMaterialManager::getMaterial
virtual const GeoMaterial * getMaterial(const std::string &name)=0
TileDetDescriptor.h
TileDddbManager::TILErmax
double TILErmax() const
Definition: TileDddbManager.cxx:142
TileDddbManager::TILBdzend2
double TILBdzend2() const
Definition: TileDddbManager.cxx:844
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
TileGeoSectionBuilder::setExtendedPeriodThickness
void setExtendedPeriodThickness(double val)
Definition: TileGeoSectionBuilder.cxx:3472
TileDetDescrManager::getDbManager
TileDddbManager * getDbManager() const
Definition: TileDetDescrManager.cxx:94
TileDddbManager::TILBdzmast
double TILBdzmast() const
Definition: TileDddbManager.cxx:811
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
TileGeoSectionBuilder::computeCellDim
void computeCellDim(TileDetDescrManager *&manager, int detector, bool addPlates, float zShiftPos, float zShiftNeg)
Cell dimension parameters are the following:
Definition: TileGeoSectionBuilder.cxx:2709
TileDddbManager::CutsDY1
double CutsDY1() const
Definition: TileDddbManager.cxx:1110
TileDddbManager::GetEnvRout
double GetEnvRout() const
Definition: TileDddbManager.cxx:285
TileDddbManager::TILBnperiod
int TILBnperiod() const
Definition: TileDddbManager.cxx:646
TileAtlasFactory::m_volumePtrs
std::vector< GeoPhysVol * > m_volumePtrs
Definition: TileAtlasFactory.h:76
TileDddbManager::GetEnvType
int GetEnvType() const
Definition: TileDddbManager.cxx:163
TileGeoSectionBuilder::fillSection
void fillSection(GeoPhysVol *&mother, int sec_number, double tile_rmax, double rminb, double dzglue, double delta_phi, int ModuleNcp=0, double zlen_itc2=0., bool neg=false)
Section parameters are the following:
Definition: TileGeoSectionBuilder.cxx:74
checker_macros.h
Define macros for attributes used to control the static checker.
TileDddbManager::SetCurrentModuleByIndex
int SetCurrentModuleByIndex(unsigned int Id)
Definition: TileDddbManager.cxx:406
TileDddbManager
This class provides access to constants in the Geometry DB.
Definition: TileDddbManager.h:38
TileDddbManager::SetCurrentSaddle
int SetCurrentSaddle(unsigned int index)
Fields of SADDLE structure (see also Oracle comments):
Definition: TileDddbManager.cxx:1162
multiIoVMCRecoTag.nTag
nTag
Definition: multiIoVMCRecoTag.py:70
TileDddbManager::CutsDX2
double CutsDX2() const
Definition: TileDddbManager.cxx:1100
TileDddbManager::TILBfingpattern
int TILBfingpattern() const
Definition: TileDddbManager.cxx:877
StoreGateSvc.h
TileDddbManager::GetEnvDTheta
double GetEnvDTheta() const
Definition: TileDddbManager.cxx:382
TileDddbManager::GetEnvNModules
int GetEnvNModules() const
Definition: TileDddbManager.cxx:262
MLOG
#define MLOG(x)
Definition: TileAtlasFactory.cxx:50
TileDetDescrManager::get_id
const TileID * get_id() const
Definition: TileDetDescrManager.h:172
TileGeoSectionBuilder
Definition: TileGeoSectionBuilder.h:38
TileAtlasFactory::m_volumePositions
std::vector< double > m_volumePositions
Definition: TileAtlasFactory.h:77