@@ -27,8 +27,17 @@ namespace o2
2727{
2828namespace iotof
2929{
30- Layer::Layer (std::string layerName, float rInn, float rOut, float zLength, float zOffset, float layerX2X0, int layout, int nSegments)
31- : mLayerName (layerName), mInnerRadius (rInn), mOuterRadius (rOut), mZLength (zLength), mZOffset (zOffset), mX2X0 (layerX2X0), mLayout (layout), mSegments (nSegments)
30+ Layer::Layer (std::string layerName, float rInn, float rOut, float zLength, float zOffset, float layerX2X0, int layout, int nSegments, float segmentSize, int nSensorsPerSegment, double tiltAngle)
31+ : mLayerName (layerName),
32+ mInnerRadius (rInn),
33+ mOuterRadius(rOut),
34+ mZLength(zLength),
35+ mZOffset(zOffset),
36+ mX2X0(layerX2X0),
37+ mLayout(layout),
38+ mSegments(nSegments, segmentSize),
39+ mSensorsPerSegment(nSensorsPerSegment),
40+ mTiltAngle(tiltAngle)
3241{
3342 float Si_X0 = 9 .5f ;
3443 mChipThickness = mX2X0 * Si_X0;
@@ -47,14 +56,22 @@ Layer::Layer(std::string layerName, float rInn, float rOut, float zLength, float
4756 default :
4857 LOG (fatal) << " Invalid layout " << layout;
4958 }
50- if (mInnerRadius > mOuterRadius ) {
51- LOG (fatal) << " Invalid layer dimensions: rInner " << mInnerRadius << " cm is larger than rOuter " << mOuterRadius << " cm" ;
52- }
53- if (mSegments != 0 && (layout != kBarrelSegmented && layout != kDiskSegmented )) {
54- LOG (fatal) << " Invalid configuration: number of segments " << mSegments << " is set for non-segmented layout " << layout;
55- }
56- if (mSegments <= 1 && (layout == kBarrelSegmented || layout == kDiskSegmented )) {
57- LOG (fatal) << " Invalid configuration: number of segments " << mSegments << " must be positive for segmented layout " << layout;
59+ if (1 ) { // Sanity checks
60+ if (mInnerRadius > mOuterRadius ) {
61+ LOG (fatal) << " Invalid layer dimensions: rInner " << mInnerRadius << " cm is larger than rOuter " << mOuterRadius << " cm" ;
62+ }
63+ if ((mSegments .first != 0 || mSegments .second != 0 .0f ) && (layout != kBarrelSegmented && layout != kDiskSegmented )) {
64+ LOG (fatal) << " Invalid configuration: number of segments " << mSegments .first << " is set for non-segmented layout " << layout;
65+ }
66+ if ((mSegments .first <= 1 || mSegments .second <= 0 .0f ) && (layout == kBarrelSegmented || layout == kDiskSegmented )) {
67+ LOG (fatal) << " Invalid configuration: number of segments " << mSegments .first << " must be positive for segmented layout " << layout;
68+ }
69+ if (mSensorsPerSegment <= 0 && (layout == kBarrelSegmented || layout == kDiskSegmented )) {
70+ LOG (fatal) << " Invalid configuration: number of sensors per segment " << mSensorsPerSegment << " must be positive for segmented layout " << layout;
71+ }
72+ if (std::abs (mTiltAngle ) > 0.1 && (layout != kBarrelSegmented && layout != kDiskSegmented )) {
73+ LOG (fatal) << " Invalid configuration: tilt angle " << mTiltAngle << " is set for non-segmented layout " << layout;
74+ }
5875 }
5976
6077 LOGP (info, " TOF: Creating {} layer: rInner: {} (cm) rOuter: {} (cm) zLength: {} (cm) zOffset: {} x2X0: {}" , name.c_str (), mInnerRadius , mOuterRadius , mZLength , mZOffset , mX2X0 );
@@ -63,8 +80,8 @@ Layer::Layer(std::string layerName, float rInn, float rOut, float zLength, float
6380std::vector<std::string> ITOFLayer::mRegister ;
6481void ITOFLayer::createLayer (TGeoVolume* motherVolume)
6582{
66- std::string chipName = o2::iotof::GeometryTGeo::getITOFChipPattern (),
67- sensName = o2::iotof::GeometryTGeo::getITOFSensorPattern ();
83+ const std::string chipName = o2::iotof::GeometryTGeo::getITOFChipPattern ();
84+ const std::string sensName = o2::iotof::GeometryTGeo::getITOFSensorPattern ();
6885
6986 TGeoMedium* medSi = gGeoManager ->GetMedium (" TF3_SILICON$" );
7087 TGeoMedium* medAir = gGeoManager ->GetMedium (" TF3_AIR$" );
@@ -96,50 +113,50 @@ void ITOFLayer::createLayer(TGeoVolume* motherVolume)
96113 }
97114 case kBarrelSegmented : {
98115 const double circumference = TMath::TwoPi () * 0.5 * (mInnerRadius + mOuterRadius );
99- const double segmentSize = circumference / mSegments ;
116+ const double segmentSize = mSegments . second ; // cm circumference / mSegments;
100117 const double avgRadius = 0.5 * (mInnerRadius + mOuterRadius );
118+ TGeoTube* layer = new TGeoTube (mInnerRadius , mOuterRadius , mZLength / 2 );
119+ TGeoVolume* layerVol = new TGeoVolume (mLayerName .c_str (), layer, medAir);
120+ layerVol->SetLineColor (kRed + 3 );
101121
102- for (int i = 0 ; i < mSegments ; ++i) {
103- LOGP (info, " TOF : Creating segment {}/{} with size {} and thickness {}cm" , i + 1 , mSegments , segmentSize, (mOuterRadius - mInnerRadius ));
122+ for (int i = 0 ; i < mSegments . first ; ++i) {
123+ LOGP (info, " iTOF : Creating segment {}/{} with size {} and thickness {}cm" , i + 1 , mSegments . first , segmentSize, (mOuterRadius - mInnerRadius ));
104124 const double hx = 0.5 * segmentSize;
105125 const double hy = 0.5 * (mOuterRadius - mInnerRadius );
106126 const double hz = 0.5 * mZLength ;
107127 TGeoBBox* sensor = new TGeoBBox (hy, hx, hz);
108128 TGeoBBox* chip = new TGeoBBox (hy, hx, hz);
109- TGeoBBox* layer = new TGeoBBox (hy, hx, hz);
110129 const std::string segmentTag = Form (" segment%d" , i + 1 );
111130 TGeoVolume* sensVol = new TGeoVolume (Form (" %s_%s" , sensName.c_str (), segmentTag.c_str ()), sensor, medSi);
112131 TGeoVolume* chipVol = new TGeoVolume (Form (" %s_%s" , chipName.c_str (), segmentTag.c_str ()), chip, medSi);
113- TGeoVolume* layerVol = new TGeoVolume (Form (" %s_%s" , mLayerName .c_str (), segmentTag.c_str ()), layer, medAir);
114132 sensVol->SetLineColor (kRed + 3 );
115133 chipVol->SetLineColor (kRed + 3 );
116- layerVol->SetLineColor (kRed + 3 );
117134
118- LOGP (info, " Inserting Barrel {} in {} " , sensVol->GetName (), chipVol->GetName ());
135+ LOGP (info, " Inserting Barrel {} in {} " , sensVol->GetName (), chipVol->GetName ());
119136 ITOFLayer::mRegister .push_back (sensVol->GetName ());
120137 chipVol->AddNode (sensVol, 1 , nullptr );
121138
122- LOGP (info, " Inserting Barrel {} in {} " , chipVol->GetName (), layerVol->GetName ());
123- layerVol->AddNode (chipVol, 1 , nullptr );
139+ const double phi = TMath::TwoPi () * i / mSegments .first ;
124140
125- // Position segment around the barrel
126- const double phi = TMath::TwoPi () * i / mSegments ;
127- LOG (info) << " Tilting angle for segment " << i + 1 << " : " << phi * TMath::RadToDeg () << " deg" ;
141+ LOG (info) << " Tilting angle for segment " << i + 1 << " : " << phi * TMath::RadToDeg () << " degrees" ;
128142 const double x = avgRadius * TMath::Cos (phi);
129143 const double y = avgRadius * TMath::Sin (phi);
130- auto * rotation = new TGeoRotation (Form (" segmentRot%d" , i + 1 ), phi * TMath::RadToDeg (), 0 , 0 );
144+ auto * rotation = new TGeoRotation (Form (" segmentRot%d" , i + 1 ), phi * TMath::RadToDeg () + mTiltAngle , 0 , 0 );
131145 auto * transformation = new TGeoCombiTrans (x, y, 0 , rotation);
132146
133- LOGP (info, " Inserting Barrel {} in {} at phi={} deg " , layerVol ->GetName (), motherVolume ->GetName (), phi * TMath::RadToDeg ());
134- motherVolume ->AddNode (layerVol, i + 1 , transformation);
147+ LOGP (info, " Inserting Barrel {} in {} " , chipVol ->GetName (), layerVol ->GetName ());
148+ layerVol ->AddNode (chipVol, 1 + i , transformation);
135149 }
150+ LOGP (info, " Inserting Barrel {} in {} at r={} cm" , layerVol->GetName (), motherVolume->GetName (), avgRadius);
151+ motherVolume->AddNode (layerVol, 1 , nullptr );
136152 return ;
137153 }
138154 default :
139155 LOG (fatal) << " Invalid layout " << mLayout ;
140156 }
141157}
142158
159+ std::vector<std::string> OTOFLayer::mRegister ;
143160void OTOFLayer::createLayer (TGeoVolume* motherVolume)
144161{
145162 std::string chipName = o2::iotof::GeometryTGeo::getOTOFChipPattern (),
@@ -175,43 +192,42 @@ void OTOFLayer::createLayer(TGeoVolume* motherVolume)
175192 }
176193 case kBarrelSegmented : {
177194 const double circumference = TMath::TwoPi () * 0.5 * (mInnerRadius + mOuterRadius );
178- const double segmentSize = circumference / mSegments ;
195+ const double segmentSize = mSegments . second ; // cm circumference / mSegments;
179196 const double avgRadius = 0.5 * (mInnerRadius + mOuterRadius );
197+ TGeoTube* layer = new TGeoTube (mInnerRadius , mOuterRadius , mZLength / 2 );
198+ TGeoVolume* layerVol = new TGeoVolume (mLayerName .c_str (), layer, medAir);
199+ layerVol->SetLineColor (kRed + 3 );
180200
181- for (int i = 0 ; i < mSegments ; ++i) {
182- LOGP (info, " TOF : Creating segment {}/{} with size {} and thickness {}cm" , i + 1 , mSegments , segmentSize, (mOuterRadius - mInnerRadius ));
201+ for (int i = 0 ; i < mSegments . first ; ++i) {
202+ LOGP (info, " oTOF : Creating segment {}/{} with size {} and thickness {}cm" , i + 1 , mSegments . first , segmentSize, (mOuterRadius - mInnerRadius ));
183203 const double hx = 0.5 * segmentSize;
184204 const double hy = 0.5 * (mOuterRadius - mInnerRadius );
185205 const double hz = 0.5 * mZLength ;
186206 TGeoBBox* sensor = new TGeoBBox (hy, hx, hz);
187207 TGeoBBox* chip = new TGeoBBox (hy, hx, hz);
188- TGeoBBox* layer = new TGeoBBox (hy, hx, hz);
189208 const std::string segmentTag = Form (" segment%d" , i + 1 );
190209 TGeoVolume* sensVol = new TGeoVolume (Form (" %s_%s" , sensName.c_str (), segmentTag.c_str ()), sensor, medSi);
191210 TGeoVolume* chipVol = new TGeoVolume (Form (" %s_%s" , chipName.c_str (), segmentTag.c_str ()), chip, medSi);
192- TGeoVolume* layerVol = new TGeoVolume (Form (" %s_%s" , mLayerName .c_str (), segmentTag.c_str ()), layer, medAir);
193211 sensVol->SetLineColor (kRed + 3 );
194212 chipVol->SetLineColor (kRed + 3 );
195- layerVol->SetLineColor (kRed + 3 );
196213
197- LOGP (info, " Inserting Barrel {} in {} " , sensVol->GetName (), chipVol->GetName ());
214+ LOGP (info, " Inserting Barrel {} in {} " , sensVol->GetName (), chipVol->GetName ());
198215 OTOFLayer::mRegister .push_back (sensVol->GetName ());
199216 chipVol->AddNode (sensVol, 1 , nullptr );
200217
201- LOGP (info, " Inserting Barrel {} in {} " , chipVol->GetName (), layerVol->GetName ());
202- layerVol->AddNode (chipVol, 1 , nullptr );
218+ const double phi = TMath::TwoPi () * i / mSegments .first ;
203219
204- // Position segment around the barrel
205- const double phi = TMath::TwoPi () * i / mSegments ;
206- LOG (info) << " Tilting angle for segment " << i + 1 << " : " << phi * TMath::RadToDeg () << " deg" ;
220+ LOG (info) << " Tilting angle for segment " << i + 1 << " : " << phi * TMath::RadToDeg () << " degrees" ;
207221 const double x = avgRadius * TMath::Cos (phi);
208222 const double y = avgRadius * TMath::Sin (phi);
209- auto * rotation = new TGeoRotation (Form (" segmentRot%d" , i + 1 ), phi * TMath::RadToDeg (), 0 , 0 );
223+ auto * rotation = new TGeoRotation (Form (" segmentRot%d" , i + 1 ), phi * TMath::RadToDeg () + mTiltAngle , 0 , 0 );
210224 auto * transformation = new TGeoCombiTrans (x, y, 0 , rotation);
211225
212- LOGP (info, " Inserting Barrel {} in {} at phi={} deg " , layerVol ->GetName (), motherVolume ->GetName (), phi * TMath::RadToDeg ());
213- motherVolume ->AddNode (layerVol, i + 1 , transformation);
226+ LOGP (info, " Inserting Barrel {} in {} " , chipVol ->GetName (), layerVol ->GetName ());
227+ layerVol ->AddNode (chipVol, 1 + i , transformation);
214228 }
229+ LOGP (info, " Inserting Barrel {} in {} at r={} cm" , layerVol->GetName (), motherVolume->GetName (), avgRadius);
230+ motherVolume->AddNode (layerVol, 1 , nullptr );
215231 return ;
216232 }
217233 default :
0 commit comments