ATLAS Offline Software
Loading...
Searching...
No Matches
TileDetDescrManager.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 * Updates:
7 * - 2022 Jan, Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch>
8 * Added checks to catch issues when quantities needed
9 * to build the readout geometry are not set correctly.
10 */
11
15#include "GeoModelKernel/Units.h"
16
21
22#include "GaudiKernel/MsgStream.h"
23#include "GaudiKernel/SystemOfUnits.h"
25
26#include <iostream>
27#include <iomanip>
28#include <cmath>
29
30
31// 23-feb-2005
32
52
53// Temporary solution for cell volumes
54#include "CellVolumes.h"
55// ------------- Temporary solution for cell volumes
56
58 : AthMessaging ("TileDetDescrManager")
59 , m_dbManager(std::move(dbManager))
60 , m_elements_created(false)
61 , m_tile_id(0)
62 , m_cell_id(0)
63 , m_tile_hwid(0)
64{
65 setName("Tile");
66}
67
72
73// -------- Access to raw geometry: -----------
75{
76 return m_treeTops.size();
77}
78
79PVConstLink TileDetDescrManager::getTreeTop(unsigned int i) const
80{
81 if (i<m_treeTops.size())
82 return m_treeTops[i];
83 else
84 return 0;
85}
86
87// -------------- Add a Tree top: ------------
88void TileDetDescrManager::addTreeTop(PVConstLink link)
89{
90 m_treeTops.push_back(link);
91}
92
93// --- Readonly access to TileDddbManager object ----
98
99// --- Release DB Manager ---
104
106{
107 std::cout << "TileDetDescrManager : " << std::endl;
108 std::cout << " Number of Tile regions : " << m_tile_region_vec.size() << std::endl;
109 std::cout << " Number of Tile descr : " << m_tile_descr_vec.size() << std::endl;
110
113
114 for (; first != last; ++first) {
115 (*first)->print();
116 }
117
118 std::cout << " Number of Tile modules : "
119 << m_tile_module_vec.size() << std::endl;
120
123 for (; first1 != last1; ++first1) {
124 (*first1)->print(); // too many !
125 }
126
127 std::cout << " Number of Tile cells : "
128 << m_tile_cell_vec.size() << std::endl;
129
132 for (; first2 != last2; ++first2) {
133 (*first2)->print(); // too many !
134 }
135
136 std::cout << std::endl;
137}
138
144{
145 ATH_MSG_INFO( "Entering create_elements()" );
146
147 // resize vectors :
148 m_tile_module_vec.resize( (int) m_tile_id->module_hash_max(),0);
149 m_tile_cell_vec.resize( (int) m_tile_id->cell_hash_max(),0);
150
151 IdContext module_context = m_tile_id->module_context();
152 IdContext cell_context = m_tile_id->cell_context();
153
156
157 int n_regions = 0;
158 int n_modules = 0;
159 int n_cells = 0;
160
161 // For each descriptor :
162 ATH_MSG_DEBUG( "Looping over descriptors..." );
163
164 for (; first != last; ++first) {
165
166 TileDetDescriptor* descr = *first;
167 Identifier reg_id = descr->identify();
168
169 int section = m_tile_id->section(reg_id);
170 int side = m_tile_id->side(reg_id);
171
172 double zshift = descr->zshift();
173 bool doZshift = (zshift != 0.0);
174
175 int etasign = descr->sign_eta();
176 if (side != etasign) {
177 ATH_MSG_ERROR( "side and eta sign in TileDetDescriptor[" << n_regions
178 << "] do not match" );
179 }
180 ++n_regions;
181
182 ATH_MSG_DEBUG( "descriptor - " << reg_id << ", " << section << ", " << side
183 << ", " << zshift << ", " << doZshift
184 << ", " << etasign << ", " << n_regions );
185
186 int nsamp = descr->n_samp();
187
188 int nphi = descr->n_phi();
189 double dphi = descr->dphi();
190 double phi_min = descr->phi_min();
191 double phi_max = descr->phi_max();
192
193 // create calo descriptors per one calo sample firsrt ( 6 * 3 = 18 in total)
194 CaloDetDescriptor* caloDescr;
195
196 int calo_sample0;
197 if ( m_tile_id->is_tile_barrel(reg_id))
198 calo_sample0 = (int)CaloCell_ID::TileBar0;
199 else if ( m_tile_id->is_tile_extbarrel(reg_id))
200 calo_sample0 = (int)CaloCell_ID::TileExt0;
201 else if ( m_tile_id->is_tile_gap(reg_id))
202 calo_sample0 = (int)CaloCell_ID::TileGap1 - 1;
203 else
204 calo_sample0 = CaloCell_ID::Unknown;
205 std::vector<double> depth_in(1);
206 std::vector<double> depth_out(1);
207
208 bool gap = (nsamp > (int)TileID::SAMP_E);
209 for (int isamp=0; isamp<(int)TileID::SAMP_E; ++isamp) {
210
211 int neta = descr->n_eta(isamp);
212
213 if (neta>0) {
214 int neta = descr->n_eta(isamp);
215 double deta = descr->deta(isamp);
216 double emin = descr->eta_min(isamp);
217 double emax = descr->eta_max(isamp);
218 double rmin = descr->rcenter(isamp)-descr->dr(isamp)/2;
219 double rmax = descr->rcenter(isamp)+descr->dr(isamp)/2;
220 double zmin = descr->zcenter(isamp)-descr->dz(isamp)/2;
221 double zmax = descr->zcenter(isamp)+descr->dz(isamp)/2;
222 depth_in[0] = rmin;
223 depth_out[0] = rmax;
224
225 if ((zmax+zmin)/2. < 0) {
226 double ztmp = zmax;
227 zmax = -zmin;
228 zmin = -ztmp;
229 }
230
231 CaloCell_ID::CaloSample sample = (CaloCell_ID::CaloSample)(calo_sample0 + isamp);
232
233 caloDescr = new CaloDetDescriptor(reg_id,static_cast<const AtlasDetectorID *>(m_tile_id),m_cell_id,sample,isamp);
234 // caloDescr->set_cylindric(emin,emax,phi_min,phi_max,rmin,rmax,zmin,zmax,gap);
235 // --
236 caloDescr->setCaloEtaMin(emin);
237 caloDescr->setCaloEtaMax(emax);
238 caloDescr->setCaloPhiMin(phi_min);
239 caloDescr->setCaloPhiMax(phi_max);
240 caloDescr->setCaloRMin(rmin);
241 caloDescr->setCaloRMax(rmax);
242 caloDescr->setCaloZMin(zmin);
243 caloDescr->setCaloZMax(zmax);
244 // --
245
246 caloDescr->set_eta_phi_granularity(neta,deta,nphi,dphi);
247 caloDescr->set_n_calo_depth(1);
248 caloDescr->set_depth_in(depth_in);
249 caloDescr->set_depth_out(depth_out);
250 add_calodescr(caloDescr);
251 }
252 }
253
254 // special case - all gap scin in one sample
255 if (gap) {
256 double emin = 1.e+10;
257 double emax =-1.e+10;
258 double rmin = 1.e+10;
259 double rmax =-1.e+10;
260 double zmin = 1.e+10;
261 double zmax =-1.e+10;
262
263 for (int isamp=TileID::SAMP_E; isamp<nsamp; ++isamp) {
264
265 int neta = descr->n_eta(isamp);
266
267 if (neta>0) {
268 emin = std::min(emin,(double)descr->eta_min(isamp));
269 emax = std::max(emax,(double)descr->eta_max(isamp));
270 rmin = std::min(rmin,(double)(descr->rcenter(isamp)-descr->dr(isamp)/2));
271 rmax = std::max(rmax,(double)(descr->rcenter(isamp)+descr->dr(isamp)/2));
272 zmin = std::min(zmin,(double)(descr->zcenter(isamp)-descr->dz(isamp)/2));
273 zmax = std::max(zmax,(double)(descr->zcenter(isamp)+descr->dz(isamp)/2));
274 }
275 }
276
277 if ((zmax+zmin)/2. < 0) {
278 double ztmp = zmax;
279 zmax = -zmin;
280 zmin = -ztmp;
281 }
282
283 double deta = 0.1; // fixed deta for gap scin
284 int neta = (emax>1.65) ? 7 : 6; // fixed number of eta bins for gap scin - 6 for RUN1/RUN2, 7 for RUN3/RUN4
285 depth_in[0] = zmin;
286 depth_out[0] = zmax;
287 CaloCell_ID::CaloSample sample = CaloCell_ID::TileGap3;
288
289 caloDescr = new CaloDetDescriptor(reg_id,static_cast<const AtlasDetectorID *>(m_tile_id),m_cell_id,sample,TileID::SAMP_E);
290 // caloDescr->set_cylindric(emin,emax,phi_min,phi_max,rmin,rmax,zmin,zmax,true);
291 // --
292 caloDescr->setCaloEtaMin(emin);
293 caloDescr->setCaloEtaMax(emax);
294 caloDescr->setCaloPhiMin(phi_min);
295 caloDescr->setCaloPhiMax(phi_max);
296 caloDescr->setCaloRMin(rmin);
297 caloDescr->setCaloRMax(rmax);
298 caloDescr->setCaloZMin(zmin);
299 caloDescr->setCaloZMax(zmax);
300 // --
301
302 caloDescr->set_eta_phi_granularity(neta,deta,nphi,dphi);
303 caloDescr->set_n_calo_depth(1);
304 caloDescr->set_depth_in(depth_in);
305 caloDescr->set_depth_out(depth_out);
306 add_calodescr(caloDescr);
307 }
308
309
310 double emin = 99999.0;
311 double emax =-99999.0;
312 double rmin = 99999.0;
313 double rmax =-99999.0;
314 std::vector<double> delr;
315
316 for (int isamp=0; isamp<nsamp; ++isamp) {
317 delr.push_back(descr->dr(isamp));
318 emin = std::min(emin,(double)descr->eta_min(isamp));
319 emax = std::max(emax,(double)descr->eta_max(isamp));
320 rmin = std::min(rmin,(double)(descr->rcenter(isamp)-descr->dr(isamp)/2));
321 rmax = std::max(rmax,(double)(descr->rcenter(isamp)+descr->dr(isamp)/2));
322 }
323 if (emin < 0.0 ) emin = 0.0; // avoid emin = -0.1 because of D0 in barrel
324 if (etasign < 0) {
325 double etmp = emax;
326 emax = -emin;
327 emin = -etmp;
328 }
329
330 // and now create calo descriptors per every module ( 6 * 64 = 384 in total)
331 double phi = descr->phi_min() + dphi/2.;
332
333 for (int iphi=0; iphi<nphi; ++iphi) {
334
335 int module = iphi; // we count modules from 0 to N always
336
337 // Temporary solution for cell volumes
338 int volumeIndex = 0;
339 // ------------ Temporary solution for cell volumes
340
341 CaloDetDescriptor* modDescr;
342
343 try {
344 Identifier id = m_tile_id->module_id(section,side,module, checks);
345 IdentifierHash idhash;
346 /* int result = */ m_tile_id->get_hash(id,idhash,&module_context);
347 modDescr = new CaloDetDescriptor(id,static_cast<const AtlasDetectorID *>(m_tile_id),m_cell_id);
348 // modDescr->set_cylindric(emin,emax,phi-dphi/2.,phi+dphi/2,rmin,rmax);
349 // --
350 modDescr->setCaloEtaMin(emin);
351 modDescr->setCaloEtaMax(emax);
352 modDescr->setCaloPhiMin(phi-dphi/2.);
353 modDescr->setCaloPhiMax(phi+dphi/2.);
354 modDescr->setCaloRMin(rmin);
355 modDescr->setCaloRMax(rmax);
356 modDescr->setCaloZMin(rmin*sinh(emin));
357 modDescr->setCaloZMax(rmax*sinh(emax));
358
359 // --
360 // modDescr->set_depth(delr,nsamp);
361 modDescr->set_n_calo_depth(nsamp);
362 modDescr->set_depth_in(delr);
363 add_module(idhash,modDescr);
364 ++n_modules;
365 } catch ( const TileID_Exception& ) {
366 ATH_MSG_ERROR( "can't build module ID from ("
367 << section << ","
368 << side << ","
369 << module << ")" );
370 continue;
371 }
372
373 for (int isamp=0; isamp<nsamp; ++isamp) {
374
375 int neta = descr->n_eta(isamp);
376
377 if (neta>0) {
378
379 int sample = std::min(isamp,(int)TileID::SAMP_E); // all gap scin are in sampling 3
380 double rcenter = descr->rcenter(isamp);
381 double dr = descr->dr(isamp);
382
383 double deta = descr->deta(isamp);
384 double eta = descr->eta_min(isamp) + deta/2.; // this is unsigned eta
385
386 for (int ieta=0; ieta<neta; ++ieta) {
387
388 int tower = (sample == (int)TileID::SAMP_E) ? isamp : (int)((eta + 0.01) * 10); // tower number in 0.1 granularity
389
390 try {
391 Identifier id = m_tile_id->cell_id(section,side,module,tower,sample,checks);
392 IdentifierHash idhash;
393 /* int result = */ m_tile_id->get_hash(id,idhash,&cell_context);
394
397
398 TileCellDim* cell_dim = get_cell_dim(id);
399
400 // ideal eta/phi for all the cells
401 elt->set_cylindric_raw(eta*etasign,phi,rcenter);
402
403 if (doZshift) {
404
405 double eta1 = shiftEta(eta-deta/2,rcenter,zshift);
406 double eta2 = shiftEta(eta+deta/2,rcenter,zshift);
407
408 if (0 == iphi) {
409 ATH_MSG_VERBOSE( "side/sec/mod/twr/samp="
410 <<side<<"/"<<section<<"/"<<module<<"/"<<tower<<"/"<<sample
411 << " rcen = "<<rcenter
412 << " dr = "<<dr
413 << " eta = " << eta
414 << " eta1 = " << eta1
415 << " eta2 = " << eta2
416 << " eta' = " << (eta1+eta2)/2.
417 << " deta = " << (eta2-eta1)
418 << " iphi = " << iphi
419 << " dphi = " << dphi );
420 }
421
422 elt->set_cylindric((eta1+eta2)/2.*etasign,phi,rcenter);
423// elt->set_cylindric_size((eta2-eta1),dphi,dr);
424// keep ideal deta for the cell (0.1 or 0.2) instead of (eta2-eta1),
425// otherwise algorithms which use "eta_raw" and "deta" might fail
426// elt->set_cylindric_size(deta,dphi,dr);
427 elt->set_deta(deta);
428 elt->set_dphi(dphi);
429 elt->set_dr(dr);
430
431 } else {
432
433 if (0 == iphi) {
434 ATH_MSG_VERBOSE( "side/sec/mod/twr/samp="
435 <<side<<"/"<<section<<"/"<<module<<"/"<<tower<<"/"<<sample
436 << " rcen = "<<rcenter
437 << " dr = "<<dr
438 << " eta = " << eta
439 << " deta = " << deta
440 << " iphi = " << iphi
441 << " dphi = " << dphi );
442 }
443
444 elt->set_cylindric(eta*etasign,phi,rcenter);
445 // elt->set_cylindric_size(deta,dphi,dr);
446 elt->set_deta(deta);
447 elt->set_dphi(dphi);
448 elt->set_dr(dr);
449 }
450
451 // Temporary solution for cell volumes
452 if (section == TileID::BARREL && side == -1 && ieta == 0 && sample == 2)
453 ++volumeIndex; // skip D0 in negative side
454 if (section == TileID::BARREL)
455 elt->set_volume(vBarrelCells[volumeIndex++]);
456 else if (section == TileID::EXTBAR)
457 elt->set_volume(vExtendedCells[volumeIndex++]);
458 else if (section == TileID::GAPDET)
459 elt->set_volume(vItcGapCells[volumeIndex++]);
460
461 // ----------------- Final solution for cell volumes
462 if (cell_dim) {
463
464 double oldz = elt->z();
465 double olddz = elt->dz();
466 int ic=cell_dim->getNRows()-1;
467 double z1=0,z2=0;
468 if (side < 0) {
469 z1 = cell_dim->getZMax(0);
470 for ( ; ic>=0; --ic) {
471 z2 = cell_dim->getZMin(ic);
472 if (0 == iphi)
473 ATH_MSG_DEBUG( "z2: " << z2 << ", ZMax: " << cell_dim->getZMax(ic) << ", diff: " << z2-cell_dim->getZMax(ic) );
474 if (fabs(z2-cell_dim->getZMax(ic))>0.1) break;
475 }
476 } else {
477 z1 = cell_dim->getZMin(0);
478 for ( ; ic>=0; --ic) {
479 z2 = cell_dim->getZMax(ic);
480 if (0 == iphi)
481 ATH_MSG_DEBUG( "z2: " << z2 << ", ZMin: " << cell_dim->getZMin(ic) << ", diff: " << z2-cell_dim->getZMin(ic) );
482 if (fabs(z2-cell_dim->getZMin(ic))>0.1) break;
483 }
484 }
485
486 if (ic<0) {
487 ATH_MSG_WARNING( "TileDetDescrManager -- ic < 0! Expect crashes or misbehavior! ==> This should be checked, because 'ic' should be related to the numbers of rows!! Note: 'ic' gets < 0 when z2-cell_dim is too small and does not make the above loop break; that can be caused, for example, if 'barrelPeriodThickness' and 'extendedPeriodThickness' are not set (or set to the default 0. value) and, as a result, ZMax is not properly set." );
488 }
489
490 double z = (z1+z2)/2.;
491
492 // D-layer has cells that are centered at 0.
493 // For these cells, the above calculation will usually
494 // come out to ~ 1e-14, the exact value varying depending
495 // on platform. For reproducibility, force very small
496 // numbers to 0.
497 if (std::abs(z) < 1e-8 * Gaudi::Units::mm) {
498 if (0 == iphi)
499 ATH_MSG_DEBUG( "Cell D0 - put cell center at Z=0" );
500 z = 0;
501 }
502
503 double dz = 0.5 * fabs(cell_dim->getZMax(0) // special
504 -cell_dim->getZMin(0) // calculations
505 +cell_dim->getZMax(ic) // to get BC cells
506 -cell_dim->getZMin(ic)); // size and position right
507
508 if (section == TileID::BARREL && sample==1 && tower < 8) {
509 if (msgLvl (MSG::VERBOSE) && 0 == iphi) {
510 double z1 = 0.5*(cell_dim->getZMax(0)+cell_dim->getZMin(0));
511 double dz1 = fabs(cell_dim->getZMax(0)-cell_dim->getZMin(0));
512 double z2 = 0.5*(cell_dim->getZMax(ic)+cell_dim->getZMin(ic));
513 double dz2 = fabs(cell_dim->getZMax(ic)-cell_dim->getZMin(ic));
514 ATH_MSG_VERBOSE( "old z/dz: " << oldz << " " << olddz << std::endl
515 <<"new z/dz: " << z << " " << dz << " ( B: " << z1 << " " << dz1 << " C: " << z2 << " " << dz2 << " ) "
516 << z/oldz*100-100 << " % diff "
517 <<"do not change z/dz for BC cells in barrel" );
518 }
519 } else if ( (section == TileID::GAPDET) && (sample == TileID::SAMP_E) ) {
520
521 elt->set_z( descr->zcenter(isamp) );
522 elt->set_dz( descr->dz(isamp) );
523 if (0 == iphi) {
524 ATH_MSG_VERBOSE( "old z/dz: " << oldz << " " << olddz << std::endl
525 <<"new z/dz: " << elt->z() << " " << elt->dz() << " "
526 << elt->z()/oldz*100-100 << " % diff "
527 <<"use z/dz from descriptor for E cells" );
528 }
529
530 } else {
531 // elt->set_z_pos_and_size(z,dz);
532 elt->set_z(z);
533 elt->set_dz(dz);
534 if (0 == iphi) {
535 ATH_MSG_VERBOSE( "old z/dz: " << oldz << " " << olddz << std::endl
536 <<"new z/dz: " << elt->z() << " " << elt->dz() << " "
537 << elt->z()/(oldz+1.e-10)*100-100 << " % diff" );
538 }
539 }
540
541
542 double oldr = elt->r();
543 double olddr = elt->dr();
544 double r1 = cell_dim->getRMin(0);
545 double r2 = cell_dim->getRMax(ic);
546 // elt->set_r_pos_and_size((r1+r2)/2.,fabs(r2-r1));
547
548 elt->set_r((r1+r2)/2.);
549 elt->set_dr(fabs(r2-r1));
550 if (0 == iphi) {
551 ATH_MSG_VERBOSE( "old r/dr: " << oldr << " " << olddr << std::endl
552 <<"new r/dr: " << elt->r() << " " << elt->dr() << " "
553 << elt->r()/(oldr+1.e-10)*100-100 << " % diff" );
554 }
555
556 double oldv=elt->volume();
557 double newv = cell_dim->getVolume(); // ps cell volume to correct for special cells
558 elt->set_volume(newv);
559 //
560 // ps cutout region in ext. barrel
561 //
562 int ModuleNcp = module + 1;
563
564 if ( ( section == TileID::EXTBAR ) && ( TileID::SAMP_A == sample ) && ((ModuleNcp>=35 && ModuleNcp<=37) || (ModuleNcp>=60 && ModuleNcp<=62)) && ( (tower == 11) || (tower == 12) || (tower == 15) ) )
565 {
566 double oldv=elt->volume();
567
568 if (msgLvl (MSG::VERBOSE)) {
569 ATH_MSG_VERBOSE( "CUTOUT CELL VOLUME UPDATE"<< std::endl
570 <<"old volume: " << oldv << std::endl
571 << " iphi = " << iphi
572 << " phi = " << (module + 0.5)*dphi <<" phi2 = "<<elt->phi()
573 << std::endl
574 << " Mod# = " << ModuleNcp <<" module = "<<module<<" tower = "<<tower
575 << std::endl
576 <<"sample = "<<sample
577 <<" A = " << (TileID::SAMP_A == sample)
578 <<" BC = "<< (TileID::SAMP_BC == sample)
579 <<" D = " << (TileID::SAMP_D == sample)
580 <<" ---------------------" );
581 cell_dim->print();
582 }
583
584 double Radius2HL = tan ( M_PI / 64. );
585
586 m_dbManager->SetCurrentSection(TileID::EXTBAR);
587 double epThickness = 0.0; // only used for tower == 15
588 double epVolume = 0.0; // only used for tower == 15
589 if ( tower == 15 ) epThickness = m_dbManager->TILBdzend2() * Gaudi::Units::cm;
590
591 double volumeInRow[5]; // book large array
592 for (int iRow = 0; iRow < 5; iRow++) volumeInRow[iRow] = 0.;
593
594
595 for (unsigned int iRow = 0; iRow < cell_dim->getNRows(); iRow++)
596 {
597 double rowVolume = cell_dim->computeRowVolume(iRow);
598 double oldrv = rowVolume;
599
600 ATH_MSG_VERBOSE( " *** rowVolume = "<<rowVolume<<" volumeInRow = "<< volumeInRow[iRow] );
601
602 ATH_MSG_DEBUG( "Computing radMax and deltaZ..." );
603 double radMax = cell_dim->getRMax(iRow), radMin = cell_dim->getRMin(iRow);
604 double deltaZ = cell_dim->getZMax(iRow) - cell_dim->getZMin(iRow);
605
606 ATH_MSG_VERBOSE( "deltaz = "<<deltaZ<<" rmax = "<<radMax<<" rmin = "<<radMin<<" rowVolume = "<<rowVolume<<" oldrv = "<<oldrv<<" irow = "<<iRow<<" tower = "<<tower );
607
608 if ( 15 == tower )
609 {
610 if ( m_dbManager->addPlatesToCell() )
611 {
612 epVolume = ( rowVolume/deltaZ ) * epThickness;
613 rowVolume -= epVolume;
614 deltaZ -= epThickness;
615
616 ATH_MSG_VERBOSE( " \t\t epV = "<<epVolume<<" epT = "<<epThickness << " diff = "<<(volumeInRow[iRow] - oldrv)/oldrv*100. );
617 }
618
619 volumeInRow[iRow] += (rowVolume * (32./48) ); // the remaining 32 periods which are not cutted out
620 deltaZ *= 16./48.; // dz of the cutted part
621 rowVolume *= 16./48.; // volume of the cutted part of the cell, but before cut
622 ATH_MSG_VERBOSE( " *** 15 rowVolume = "<<rowVolume<<" volumeInRow = "<< volumeInRow[iRow] <<" diff = "<<(volumeInRow[iRow] - oldrv)/oldrv*100. );
623 }
624 else if ( 12 == tower )
625 {
626 volumeInRow[iRow] += (rowVolume * (2./25) ); // the remaining 2 periods which are not cutted out
627 deltaZ *= 23./25.; // dz of the cutted part
628 rowVolume *= 23./25.; // volume of the cutted part of the cell, but before cut
629 ATH_MSG_VERBOSE( " *** 12 rowVolume = "<<rowVolume<<" volumeInRow = "<< volumeInRow[iRow] << " % = "<<(volumeInRow[iRow] - oldrv)/oldrv*100. );
630 }
631
632 ATH_MSG_VERBOSE( "deltaz = "<<deltaZ<<" rmax = "<<radMax<<" rmin = "<<radMin<<" changed dz ?"<<(volumeInRow[iRow] - oldrv)/oldrv*100. );
633
634 if ( (ModuleNcp == 61) || (ModuleNcp == 36) )
635 {
636 if ( iRow == 0 )
637 rowVolume = 0.;
638 else if ( iRow == 1 )
639 {
640 if (15 != tower)
641 {
642 rowVolume = 2.*radMax + radMin;
643 rowVolume *= 0.5*(radMax - radMin);
644 rowVolume *= Radius2HL * deltaZ;
645 }
646 else
647 {
648 rowVolume += epVolume;
649 }
650 }
651 else if (15 == tower) rowVolume += epVolume;
652
653 volumeInRow[iRow] += rowVolume;
654
655 ATH_MSG_VERBOSE( " *** rowVolume = "<<rowVolume<<" volumeInRow = "<< volumeInRow[iRow] << " % = "<<(volumeInRow[iRow] - oldrv)/oldrv*100. );
656 } // Module 61 36
657
658 if ( (ModuleNcp == 62) || (ModuleNcp == 35) )
659 {
660 if ( iRow == 0 )
661 {
662 if (15 == tower)
663 {
664 rowVolume = radMax + radMin;
665 rowVolume *= (radMax - radMin);
666 rowVolume -= 0.5*radMin*(27*Gaudi::Units::mm);
667 rowVolume *= Radius2HL * ( deltaZ + epThickness ); // adding volume of cutted endplate
668 }
669 else
670 {
671 rowVolume = radMax - radMin - 35*Gaudi::Units::mm;
672 rowVolume *= (radMax + radMin);
673 rowVolume *= Radius2HL * deltaZ;
674 }
675 }
676 else if (15 == tower) rowVolume += epVolume;
677
678 volumeInRow[iRow] += rowVolume;
679 ATH_MSG_VERBOSE( " *** rowVolume = "<<rowVolume<<" volumeInRow = "<< volumeInRow[iRow] << " % = "<<(volumeInRow[iRow] - oldrv)/oldrv*100. );
680 } // Module 62 35
681
682 if ( (ModuleNcp == 60) || (ModuleNcp == 37) )
683 {
684 double deltax = 38.7*std::cos(25.3125*Gaudi::Units::deg);
685 double pstan = std::tan(25.3125*Gaudi::Units::deg);
686 double inv_pstan = 1. / pstan;
687 if ( ( 15 == tower ) )
688 {
689 if ( iRow < 2 )
690 rowVolume = 0;
691 else
692 rowVolume += epVolume;
693 }
694 else if ( iRow == 0 )
695 {
696 rowVolume = (radMax + radMin) * Radius2HL ;
697
698 rowVolume += 2.*deltax + (radMax - radMin)* pstan ;
699
700 // std::cout <<"\t\t\t test = "<<( 2.*deltax + (radMax - radMin)* pstan)/(radMax + radMin)* Radius2HL<<" dx = "<<deltax<<" rmin = "<<radMin<<" rmax = "<<radMax<<" pstan = "<<pstan<<std::endl;
701
702 rowVolume *= 0.5 * (radMax - radMin) * deltaZ;
703
704 // rowVolume *= (radMax - radMin) * Radius2HL * deltaZ;
705 }
706 else if ( iRow == 1 )
707 {
708 double radMin0 = cell_dim->getRMin(0);
709 rowVolume = (radMax + radMin) * Radius2HL;
710 rowVolume += 2.*deltax + (radMax + radMin - 2.*radMin0 )* pstan ;
711 rowVolume *= 0.5 * (radMax - radMin) ;
712 rowVolume -= 0.5 * std::pow( deltax + (radMax - radMin0) * pstan - radMax * Radius2HL, 2) * inv_pstan;
713 rowVolume *= deltaZ;
714 }
715
716 volumeInRow[iRow] += rowVolume;
717 ATH_MSG_VERBOSE( " *** rowVolume = "<<rowVolume<<" volumeInRow = "<< volumeInRow[iRow] << " % = "<<(volumeInRow[iRow] - oldrv)/oldrv*100. );
718 } // Module 60 37
719
720 ATH_MSG_VERBOSE( " *** rowVolume = "<<rowVolume<<" volumeInRow = "<< volumeInRow[iRow] << " % = "<<(volumeInRow[iRow] - oldrv)/oldrv*100. );
721 } // for iRow
722
723
724 double totalVolume = 0;
725 for (unsigned int iRow = 0; iRow < cell_dim->getNRows(); iRow++) totalVolume += volumeInRow[iRow];
726 elt->set_volume( totalVolume );
727
728 ATH_MSG_VERBOSE( "\n total volume = "
729 << elt->volume() << " cell_dim xCheck ( "
730 << cell_dim->getVolume() <<" ) "
731 << elt->volume()/oldv*100-100 << " % diff" );
732
733
734 ATH_MSG_VERBOSE( "-----------------------------------------------" );
735 }
736 //
737 // ps special D4
738 //
739 if ( (section == TileID::GAPDET) && (sample == TileID::SAMP_D) )
740 {
741 if (side == -1) m_dbManager->SetCurrentEnvByType(4);
742 if (side == 1) m_dbManager->SetCurrentEnvByType(5);
743
744 m_dbManager->SetCurrentModuleByIndex(module);
745 m_dbManager->SetCurrentSection(TileDddbManager::TILE_PLUG1);
746 int Id4 = int(fmod(m_dbManager->GetModType(),10));
747 m_dbManager->SetCurrentSection(Id4);
748
749 double standardD4dz = elt->dz();
750 double specialD4dz = m_dbManager->TILBdzmodul()*Gaudi::Units::cm;
751 if (! m_dbManager->addPlatesToCell()) specialD4dz -= m_dbManager->TILBdzend1()*Gaudi::Units::cm;
752 // special case of non-existing D4 in EBA15 and EBC18
753 // if ( Id4 == 8 ) specialD4dz = 0.; commented out - don't set size to zero - it'll be used in TICAL derivation code
754
755 if (elt->z() > 0.)
756 elt->set_z(elt->z()+0.5*(standardD4dz-specialD4dz));
757 else
758 elt->set_z(elt->z()-0.5*(standardD4dz-specialD4dz));
759 elt->set_dz(specialD4dz);
760 elt->set_volume(newv * specialD4dz/(standardD4dz));
761
762 if (Id4 > 3) {
763 ATH_MSG_VERBOSE( "spD4 old z/dz: " << oldz << " " << standardD4dz << std::endl
764 <<"spD4 new z/dz: " << elt->z() << " " << elt->dz() << " "
765 << elt->z()/(oldz+1.e-10)*100-100 << " % diff" );
766
767 ATH_MSG_VERBOSE( "spD4 old volume: " << oldv << std::endl
768 <<"spD4 new volume: " << elt->volume() << " "
769 << elt->volume()/oldv*100-100 << " % diff"
770 << " iphi = " << iphi
771 << " dphi = " << dphi << " phi = " << (module + 0.5)*dphi - M_PI <<" phi2 = "<<elt->phi() );
772 }
773 }
774 //
775 // ps special C10
776 //
777
778 /*
779 if ( (section == TileID::GAPDET) && (sample == TileID::SAMP_C) )
780 {
781 if (side == -1) m_dbManager->SetCurrentEnvByType(4);
782 if (side == 1) m_dbManager->SetCurrentEnvByType(5);
783
784 m_dbManager->SetCurrentModuleByIndex(module);
785 m_dbManager->SetCurrentSection(TileDddbManager::TILE_PLUG2);
786 int Ic10 = int(fmod(m_dbManager->GetModType()/100,100));
787
788 double standardC10dz = elt->dz();
789 double standardC10vol = elt->volume();
790
791 if ( Ic10 == 14 )
792 {
793 m_dbManager->SetCurrentSection( Ic10 );
794 m_dbManager->SetCurrentScin( m_dbManager->TILBcurscint() );
795
796 double specialC10dz = m_dbManager->SCNTdt();
797 elt->set_dz(specialC10dz);
798 elt->set_volume(standardC10vol * specialC10dz/standardC10dz );
799
800 if ( m_verbose )
801 std::cout<<"C10 old z/dz: " << oldz << " " << standardC10dz << std::endl
802 <<"C10 new z/dz: " << elt->z() << " " << elt->dz() << " "
803 << elt->z()/(oldz+1.e-10)*100-100 << " % diff" << std::endl;
804 if ( m_verbose )
805 std::cout<<"spC10 old volume: " << newv << std::endl
806 <<"spC10 new volume: " << elt->volume() << " "
807 << elt->volume()/oldv*100-100 << " % diff"
808 << " iphi = " << iphi
809 << " dphi = " << dphi
810 << std::endl;
811 }
812 }
813 */
814
815 //
816 // ps special D5+D4
817 //
818 if ( (section == TileID::EXTBAR) && (sample == TileID::SAMP_D) && (tower == 10) )
819 {
820 // this is needed to read special D4 type and its size
821 if (side == -1) m_dbManager->SetCurrentEnvByType(4);
822 if (side == 1) m_dbManager->SetCurrentEnvByType(5);
823 m_dbManager->SetCurrentModuleByIndex(module);
824 m_dbManager->SetCurrentSection(TileDddbManager::TILE_PLUG1);
825 int Id4 = int(fmod(m_dbManager->GetModType(),10));
826 m_dbManager->SetCurrentSection(Id4);
827
828 if ( Id4 == 8 )
829 {
830 oldz = elt->z();
831 double standardD5dz = elt->dz();
832 double specialD4dz = m_dbManager->TILBdzmodul()*Gaudi::Units::cm;
833 double specialD4Rin = m_dbManager->TILBrmin()*Gaudi::Units::cm;
834 if (m_dbManager->addPlatesToCell()) {
835 specialD4Rin -= m_dbManager->TILBdrfront()*Gaudi::Units::cm;
836 } else {
837 specialD4dz -= m_dbManager->TILBdzend1()*Gaudi::Units::cm;
838 }
839 double newS = (pow((elt->r() + elt->dr()/2.),2) - specialD4Rin*specialD4Rin)/(2.*elt->r()*elt->dr());
840 elt->set_volume(elt->volume()* (1. + newS*specialD4dz/standardD5dz));
841 /* commented out - don't change z and dz for special D5+D4
842 elt->set_dz(specialD4dz + standardD5dz);
843 if (elt->z() > 0.)
844 elt->set_z(elt->z()-0.5*specialD4dz);
845 else
846 elt->set_z(elt->z()+0.5*specialD4dz);
847 */
848
849 ATH_MSG_VERBOSE( "D5 old z/dz: " << oldz << " " << standardD5dz << " spD4 dz: " << specialD4dz );
850 ATH_MSG_VERBOSE( "D5+D4 new z/dz: " << elt->z() << " " << elt->dz() << " " );
851 ATH_MSG_VERBOSE( "D5+D4 old volume: " << newv << std::endl
852 <<"D5+D4 new volume: " << elt->volume() << " "
853 << elt->volume()/oldv*100-100 << " % diff"
854 << " iphi = " << iphi
855 << " dphi = " << dphi <<" Id4 = "<< Id4 <<" modType = "<<m_dbManager->GetModType()
856 << " phi = " << (module + 0.5)*dphi - M_PI<<" phi2 = "<<elt->phi() );
857 ATH_MSG_VERBOSE( " module = "<< module
858 << " sample = " << sample
859 << " section = " << section
860 << " tower = " << tower );
861 }
862 }
863
864 if (0 == iphi) {
865 ATH_MSG_VERBOSE( "old volume: " << oldv << std::endl
866 <<"new volume: " << elt->volume() << " "
867 << elt->volume()/oldv*100-100 << " % diff"
868 << " iphi = " << iphi
869 << " dphi = " << dphi );
870 }
871 }
872
873 add_cell(elt);
874 ++n_cells;
875 } catch ( const TileID_Exception& ) {
876 ATH_MSG_ERROR( "can't build cell ID from ("
877 << section << "," << side << "," << module << ","
878 << tower << "," << sample << ")" );
879 }
880 eta += deta;
881 }
882 }
883 }
884 phi += dphi;
885 }
886 }
887
888 ATH_MSG_DEBUG( n_cells << " cells and "
889 << n_modules << " half-modules were created for "
890 << n_regions << " Tile Regions" );
891}
892
893
895{
896 m_tile_region_vec.push_back(region);
898}
899
901{
902 m_tile_descr_vec.push_back(descriptor);
903}
904
906{
907 int index = descr->getSampling(0)*descr->calo_sign();
908 m_calo_descr_vec.push_back(descr);
909 m_calo_descr_map[index] = descr;
910
911 ATH_MSG_VERBOSE( "new Tile CaloDetDescriptor" );
912 ATH_MSG_VERBOSE( " index " << index );
913 ATH_MSG_VERBOSE( " calo_sample " << descr->getSampling(0) );
914 ATH_MSG_VERBOSE( " calo_sign " << descr->calo_sign() );
915 ATH_MSG_VERBOSE( " layer " << descr->layer() );
916 ATH_MSG_VERBOSE( " is tile " << ((descr->is_tile()) ? "true" : "false" ) );
917 // ATH_MSG_VERBOSE( " is cylindric " << (descr->is_cylindric() ? "true" : "false") );
918 // ATH_MSG_VERBOSE( " is ec_cylindric " << (descr->is_ec_cylindric() ? "true" : "false") );
919 ATH_MSG_VERBOSE( " deta " << descr->deta() );
920 ATH_MSG_VERBOSE( " dphi " << descr->dphi() );
921 ATH_MSG_VERBOSE( " n_eta " << descr->n_eta() );
922 ATH_MSG_VERBOSE( " n_phi " << descr->n_phi() );
923 ATH_MSG_VERBOSE( " calo_eta_min " << descr->calo_eta_min() );
924 ATH_MSG_VERBOSE( " calo_eta_max " << descr->calo_eta_max() );
925 ATH_MSG_VERBOSE( " calo_phi_min " << descr->calo_phi_min() );
926 ATH_MSG_VERBOSE( " calo_phi_max " << descr->calo_phi_max() );
927 ATH_MSG_VERBOSE( " calo_r_min " << descr->calo_r_min() );
928 ATH_MSG_VERBOSE( " calo_r_max " << descr->calo_r_max() );
929 ATH_MSG_VERBOSE( " calo_z_min " << descr->calo_z_min() );
930 ATH_MSG_VERBOSE( " calo_z_max " << descr->calo_z_max() );
931}
932
934{
935 m_tile_module_vec[idhash] = module;
936 m_tile_module_map[module->identify().get_identifier32().get_compact()] = module;
937}
938
940{
941 m_tile_cell_vec[cell->subcalo_hash()] = cell;
942 unsigned int id = m_tile_id->cell_id(cell->subcalo_hash()).get_identifier32().get_compact();
943 m_tile_cell_map[id] = cell;
944}
945
946void TileDetDescrManager::add_cellDim(int section, int side, int tower, int sample, TileCellDim* cellDim)
947{
948 unsigned int ID = m_tile_id->cell_id(section,side,0,tower,sample).get_identifier32().get_compact();
949 m_cell_dim_map[ID] = cellDim;
950}
951
953{
954 int section = m_tile_id->section(cell_id);
955 if (section == Tile_Base_ID::AUXDET) return NULL;
956 int side = m_tile_id->side(cell_id);
957 int tower = m_tile_id->tower(cell_id);
958 int sample = m_tile_id->sample(cell_id);
959
960 unsigned int newCell = m_tile_id->cell_id(section,side,0,tower,sample).get_identifier32().get_compact();
961 if (m_cell_dim_map.find(newCell) != m_cell_dim_map.end()) {
962 return (*m_cell_dim_map.find(newCell)).second;
963 } else {
964 return NULL;
965 }
966}
967
969{
970 // Remove regions and descriptors
973 for (; first != last; ++first) delete (*first);
974 m_tile_region_vec.clear();
975
978 for (; first2 != last2; ++first2) delete (*first2);
979 m_tile_descr_vec.clear();
980
983 for (; first3 != last3; ++first3) delete (*first3);
984 m_tile_module_vec.clear();
985
988 for (; first4 != last4; ++first4) delete (*first4);
989 m_tile_cell_vec.clear();
990
991 // Remove Cell Dim's
992 cell_dim_map::const_iterator first5 = m_cell_dim_map.begin();
993 cell_dim_map::const_iterator last5 = m_cell_dim_map.end();
994 for (; first5 != last5; ++first5) delete (*first5).second;
995
996 // clear cell descriptors used in CaloDetDescrManager
999 for (; first6 != last6; ++first6) delete (*first6);
1000 m_calo_descr_vec.clear();
1001}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::vector< Identifier > ID
Definition of CaloDetDescriptor.
Calo Subsystem specific Detector Elements + Dummy element for testing.
void section(const std::string &sec)
std::shared_ptr< TileDddbManager > TileDddbManager_ptr
#define z
constexpr int pow(int base, int exp) noexcept
bool msgLvl(const MSG::Level lvl) const
Test the output level.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
This class groups all DetDescr information related to a CaloCell.
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
void set_depth_out(std::vector< double > &calo_depth)
set vector of out depths
void setCaloRMin(double r_min)
Set R Min.
void set_eta_phi_granularity(int neta, double deta, int nphi, double dphi)
Set Phi granularity.
void setCaloZMax(double z_max)
Set Z Max.
void set_n_calo_depth(int n_calo_depth)
set number of calo depths
void setCaloZMin(double z_min)
Set Z Min.
void setCaloPhiMin(double phi_min)
Set Phi Min.
void setCaloPhiMax(double phi_max)
Set Phi Max.
void setCaloRMax(double r_max)
Set R Max.
void set_depth_in(std::vector< double > &calo_depth)
set vector of in depths
void setCaloEtaMin(double eta_min)
Set Eta Min.
void setCaloEtaMax(double eta_max)
Set Eta Max.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
double getZMax(unsigned int index) const
unsigned int getNRows() const
Definition TileCellDim.h:25
void print() const
double getVolume() const
Definition TileCellDim.h:26
double getRMax(unsigned int index) const
double getZMin(unsigned int index) const
double computeRowVolume(int iRow)
double getRMin(unsigned int index) const
This class provides access to constants in the Geometry DB.
void add_calodescr(CaloDetDescriptor *descriptor)
calo_descr_map m_tile_module_map
std::vector< PVConstLink > m_treeTops
calo_element_map m_tile_cell_map
tile_region_const_iterator tile_region_begin() const
virtual PVConstLink getTreeTop(unsigned int i) const override
calo_element_const_iterator tile_cell_end() const
tile_region_map m_tile_region_map
calo_element_vec::const_iterator calo_element_const_iterator
virtual unsigned int getNumTreeTops() const override
calo_element_const_iterator tile_cell_begin() const
scalo_descr_map m_calo_descr_map
void add_cellDim(int section, int side, int tower, int sample, TileCellDim *cellDim)
double shiftEta(double eta, double Rcen, double zshift)
tile_descr_const_iterator tile_descriptors_begin() const
calo_descr_const_iterator tile_module_end() const
tile_descr_const_iterator tile_descriptors_end() const
TileDddbManager * getDbManager() const
calo_descr_const_iterator tile_module_begin() const
const CaloCell_ID * m_cell_id
tile_descr_vec m_tile_descr_vec
const TileHWID * m_tile_hwid
void add_module(IdentifierHash idhash, CaloDetDescriptor *module)
calo_element_vec m_tile_cell_vec
void add(TileDetDescrRegion *region)
calo_descr_vec m_calo_descr_vec
tile_region_vec m_tile_region_vec
TileDddbManager_ptr m_dbManager
tile_descr_vec::const_iterator tile_descr_const_iterator
void add_cell(CaloDetDescrElement *cell)
tile_region_vec::const_iterator tile_region_const_iterator
static const double vBarrelCells[23]
tile_region_const_iterator tile_region_end() const
static const double vItcGapCells[6]
calo_descr_vec::const_iterator calo_descr_const_iterator
static const double vExtendedCells[12]
TileDetDescrManager(TileDddbManager_ptr dbManager)
Z-shift for ext.barrel introduced with Z-shift > 0, eta coordinate of the cell is shifted by Deta = t...
void addTreeTop(PVConstLink)
calo_descr_vec m_tile_module_vec
TileCellDim * get_cell_dim(const Identifier &cell_id) const
virtual Identifier identify() const
Tile Detector Element.
void set_r(double r)
set r
void set_cylindric(double eta, double phi, double r)
set cylindric coordinates
void set_dz(double dz)
set cartezian size dz
void set_z(double z)
set z
void set_dr(double dr)
set cylindric size dr
void set_dphi(double dphi)
set cylindric size dphi
void set_cylindric_raw(double eta_raw, double phi_raw, double r_raw)
set raw cylindric coordinates
void set_deta(double deta)
set cylindric size deta
@ NOT_VALID_HASH
Definition TileHWID.h:314
Exception class for Tile Identifiers.
singleton-like access to IMessageSvc via open function and helper
Definition index.py:1
STL namespace.