50{
51 MsgStream
log(msgSvc,
"buildCaloDetDescr");
52
53
54 SmartIF<StoreGateSvc>
detStore{svcLocator->service(
"DetectorStore")};
55 if(!detStore)
56 throw std::runtime_error("buildCaloDetDescr failed to acquire a pointer to DetectorStore");
57
59 if(
detStore->retrieve(cell_id,
"CaloCell_ID")!=StatusCode::SUCCESS)
60 throw std::runtime_error("buildCaloDetDescr failed to acquire a pointer to CaloCell_ID helper");
61 log << MSG::DEBUG <<
"Found the CaloCell_ID helper. " <<
endmsg;
62
64 if(
detStore->retrieve(caloId_mgr,
"CaloIdManager")!=StatusCode::SUCCESS)
65 throw std::runtime_error("buildCaloDetDescr failed to acquire a pointer to CaloIdManager helper");
66 log << MSG::DEBUG <<
"Found the CaloIdManager helper. " <<
endmsg;
67
68
69
70 std::unique_ptr<CaloDetDescrManager> caloMgr = std::make_unique<CaloDetDescrManager>();
71
72
73 caloMgr->set_helper(cell_id);
74 caloMgr->set_helper(caloId_mgr);
75
76 caloMgr->initialize();
77
78
79
81
82
83 caloMgr->set_lar_geometry(cellVol.layout());
84
88
89
90 bool isTestBeam = false;
94 log << MSG::WARNING <<
"Could not get LArDetectorManager. Assuming TestBeam=false" <<
endmsg;
95 }
96 else {
98 }
99
100
103
104
107
108
109
110
111
112
116 log << MSG::WARNING <<
"Could not get the EMBDetectorManager. No Calo Elements will be built for EMB" <<
endmsg;
117 }
118 else {
119
121
124
125
126
127
128
129 int barrel_ec = 0;
132 barrel_ec = -1;
133 break;
135 barrel_ec = 1;
136 break;
137 default:
138 throw std::runtime_error(
"buildCaloDetDescr Wrong Side Index for EMB region " + std::to_string(embRegion->
getEndcapIndex()));
139 }
140
144
147 , cell_id
148 , embRegion
149 , geoAlignStore);
150 caloMgr->add(embDescr);
151
152 double phi_min = 0.;
153 double z_min = 10000.;
154 double z_max = -10000.;
155 double r_min = 10000.;
156 double r_max = -10000.;
157
158 double reg_min = 10000.;
159 double reg_max = -10000.;
160
161 std::vector<double> depth_in;
162 std::vector<double> depth_out;
163
164
165
166 for (
unsigned int iPhi=embRegion->
beginPhiIndex(); iPhi<embRegion->endPhiIndex(); ++
iPhi) {
167 for (
unsigned int iEta=embRegion->
beginEtaIndex(); iEta<embRegion->endEtaIndex(); ++
iEta) {
169
170
172 , cellPtr->getSamplingIndex()
173 , cellPtr->getRegionIndex()
174 , iEta
175 , iPhi);
176
177
178 if(cellPosShift) {
180 elementPosShift.
dx = cellPosShift->
deltaX(posShiftInd);
181 elementPosShift.
dy = cellPosShift->
deltaY(posShiftInd);
182 elementPosShift.
dz = cellPosShift->
deltaZ(posShiftInd);
183 }
185 , 0
186 , 0
187 , embDescr
188 , cellPtr
189 , embRegion
190 , isTestBeam
191 , geoAlignStore
192 , cellPosShift ? &elementPosShift : nullptr);
193 if(cellPosShift) {
194 if(iPhi==0 && (iEta==0||iEta==1)) {
195 phi_min = embElement->
phi() - 0.5*embElement->
dphi();
196 }
197 }
198 else {
200 phi_min = embElement->
phi() - 0.5*embElement->
dphi();
201 }
202 }
203
204
205 embElement->
set_volume(cellVol.CellVolume(chanId));
206
207 caloMgr->add(embElement);
208
209 if(r_min > embElement->
r()-0.5*embElement->
dr())
210 r_min = embElement->
r()-0.5*embElement->
dr();
211 if(r_max < embElement->
r()+0.5*embElement->
dr())
212 r_max = embElement->
r()+0.5*embElement->
dr();
213
214 if(z_min > std::abs(embElement->
z_raw())-0.5*embElement->
dz())
215 z_min = std::abs(embElement->
z_raw())-0.5*embElement->
dz();
216 if(z_max < std::abs(embElement->
z_raw())+0.5*embElement->
dz())
217 z_max = std::abs(embElement->
z_raw())+0.5*embElement->
dz();
218
219 if(reg_min > embElement->
eta()-0.5*embElement->
deta())
220 reg_min = embElement->
eta()-0.5*embElement->
deta();
221 if(reg_max < embElement->
eta()+0.5*embElement->
deta())
222 reg_max = embElement->
eta()+0.5*embElement->
deta();
223
224
228 }
229 }
230 }
231
232
236
237 double eta_max = (embRegion->
getDescriptor()->getEtaBinning()).getEnd();
239
240
249
250
254
255
259 if(cellPosShift) {
262 }
263 else {
265 }
266 }
267 else {
269 }
270 }
271 }
272
273
274
275
276
277
278
279
280
281
285 log << MSG::WARNING <<
"Could not get the EMECDetectorManager. No Calo Elements will be built for EMEC" <<
endmsg;
286 }
287 else {
288
290
293
294
295
296
297
299
301 int barrel_ec;
302
303 switch(endcapInd) {
305 barrel_ec = -1;
306 break;
308 barrel_ec = 1;
309 break;
310 default:
311 throw std::runtime_error("Wrong Endcap Index for EMEC region " + std::to_string(endcapInd));
312 }
313
314 switch(radialInd) {
315 case 0:
316 barrel_ec *= 2;
317 break;
318 case 1:
319 barrel_ec *= 3;
320 break;
321 default:
322 throw std::runtime_error("Wrong Radial Index for EMEC region " + std::to_string(radialInd));
323 }
324
328
331 , cell_id
332 , emecRegion
333 , geoAlignStore);
334 caloMgr->add(emecDescr);
335
336 double phi_min = 0.;
337 double z_min = 10000.;
338 double z_max = -10000.;
339 double r_min = 10000.;
340 double r_max = -10000.;
341
342 double reg_min = 10000.;
343 double reg_max = -10000.;
344
345 std::vector<double> depth_in;
346 std::vector<double> depth_out;
347
348
349
350 for (
unsigned int iPhi=emecRegion->
beginPhiIndex(); iPhi<emecRegion->endPhiIndex(); ++
iPhi) {
351 for (
unsigned int iEta=emecRegion->
beginEtaIndex(); iEta<emecRegion->endEtaIndex(); ++
iEta) {
353
355 , cellPtr->getSamplingIndex()
356 , cellPtr->getRegionIndex()
357 , iEta
358 , iPhi);
359
360
361 if(cellPosShift) {
363 elementPosShift.
dx = cellPosShift->
deltaX(posShiftInd);
364 elementPosShift.
dy = cellPosShift->
deltaY(posShiftInd);
365 elementPosShift.
dz = cellPosShift->
deltaZ(posShiftInd);
366 }
368 , 0
369 , 0
370 , emecDescr
371 , cellPtr
372 , emecRegion
373 , isTestBeam
374 , geoAlignStore
375 , cellPosShift ? &elementPosShift : nullptr);
376 if((cellPosShift && iPhi==0)
378 phi_min = emecElement->
phi() - 0.5*emecElement->
dphi();
379 }
380
381
382 emecElement->
set_volume(cellVol.CellVolume(chanId));
383 caloMgr->add(emecElement);
384
385 if(r_min > emecElement->
r()-0.5*emecElement->
dr())
386 r_min = emecElement->
r()-0.5*emecElement->
dr();
387 if(r_max < emecElement->
r()+0.5*emecElement->
dr())
388 r_max = emecElement->
r()+0.5*emecElement->
dr();
389
390 if(z_min > std::abs(emecElement->
z_raw())-0.5*emecElement->
dz())
391 z_min = std::abs(emecElement->
z_raw())-0.5*emecElement->
dz();
392 if(z_max < std::abs(emecElement->
z_raw())+0.5*emecElement->
dz())
393 z_max = std::abs(emecElement->
z_raw())+0.5*emecElement->
dz();
394
395 if(reg_min > emecElement->
eta()-0.5*emecElement->
deta())
396 reg_min = emecElement->
eta()-0.5*emecElement->
deta();
397 if(reg_max < emecElement->
eta()+0.5*emecElement->
deta())
398 reg_max = emecElement->
eta()+0.5*emecElement->
deta();
399
400
402 depth_in.push_back(std::abs(emecElement->
z_raw())-emecElement->
dz());
403 depth_out.push_back(std::abs(emecElement->
z_raw())+emecElement->
dz());
404 }
405 }
406 }
407
408
412
413
422
423
427
428
432 if(cellPosShift) {
435 }
436 else {
438 }
439 }
440 else {
442 }
443 }
444 }
445
446
447
448
449
450
451
452
453
454
455
459 log << MSG::WARNING <<
"Could not get the HECDetectorManager. No Calo Elements will be built for HEC" <<
endmsg;
460 }
461 else {
462
464
467
468
469
470
471
474
478
481 , cell_id
482 , hecregion
483 , geoAlignStore);
484 caloMgr->add(hecDescr);
485
486 double phi_min = 0.;
487 float z_min = 10000.f;
488 float z_max = -10000.f;
489 double r_min = 10000.;
490 double r_max = -10000.;
491
492 double reg_min = 10000.;
493 double reg_max = -10000.;
494
495 std::vector<double> depth_in;
496 std::vector<double> depth_out;
497
498
499
500 for (
unsigned int iPhi=hecregion->
beginPhiIndex(); iPhi<hecregion->endPhiIndex(); ++
iPhi) {
501 for (
unsigned int iEta=hecregion->
beginEtaIndex(); iEta<hecregion->endEtaIndex(); ++
iEta) {
503
504
505
506 if(cellPtr) {
508 , cellPtr->getSamplingIndex()
509 , cellPtr->getRegionIndex()
510 , iEta
511 , iPhi);
512
513
514 if(cellPosShift) {
516 elementPosShift.
dx = cellPosShift->
deltaX(posShiftInd);
517 elementPosShift.
dy = cellPosShift->
deltaY(posShiftInd);
518 elementPosShift.
dz = cellPosShift->
deltaZ(posShiftInd);
519 }
521 , 0
522 , 0
523 , hecDescr
524 , cellPtr
525 , hecregion
526 , isTestBeam
527 , geoAlignStore
528 , cellPosShift ? &elementPosShift : nullptr);
529
530 if((cellPosShift && iPhi==0)
532 phi_min = hecElement->
phi() - 0.5*hecElement->
dphi();
533 }
534
535
536 hecElement->
set_volume(cellVol.CellVolume(chanId));
537
538 caloMgr->add(hecElement);
539
544
545 if(z_min > std::abs(hecElement->
z_raw())-hecElement->
dz())
546 z_min = std::abs(hecElement->
z_raw())-hecElement->
dz();
547 if(z_max < std::abs(hecElement->
z_raw())+hecElement->
dz())
548 z_max = std::abs(hecElement->
z_raw())+hecElement->
dz();
549
550 if(reg_min > hecElement->
eta()-0.5*hecElement->
deta())
551 reg_min = hecElement->
eta()-0.5*hecElement->
deta();
552 if(reg_max < hecElement->
eta()+0.5*hecElement->
deta())
553 reg_max = hecElement->
eta()+0.5*hecElement->
deta();
554
556 depth_in.push_back(std::abs(hecElement->
z_raw())-hecElement->
dz());
557 depth_out.push_back(std::abs(hecElement->
z_raw())+hecElement->
dz());
558 }
559
560 }
561 }
562 }
563
564
568
569
578
579
583
584
588 if(cellPosShift) {
591 }
592 else {
594 }
595 }
596 else {
598 }
599
600 }
601 }
602
603
604
605
606
607
608
609
610
611
612
616 log << MSG::WARNING <<
"Could not get the FCALDetectorManager. No Calo Elements will be built for FCAL" <<
endmsg;
617 }
618 else {
619
621
622 for (fcalmodIt=fcalManager->
beginFCAL(); fcalmodIt!=fcalManager->
endFCAL(); ++fcalmodIt) {
624
625
626
627
628
629
631
633
635
638 , cell_id
639 , fcalmodule
640 , geoAlignStore);
641 caloMgr->add(fcalDescr);
642
643 double eta_min = 10000.;
644 double eta_max = -10000.;
645 double z_min = 10000.;
646 double z_max = -10000.;
647 double r_min = 10000.;
648 double r_max = -10000.;
649
650 double reg_min = 10000.;
651 double reg_max = -10000.;
652
653 std::vector<double> depth_in;
654 std::vector<double> depth_out;
655
656
657
659 for (fcaltileIt=fcalmodule->
beginTiles(); fcaltileIt!=fcalmodule->
endTiles(); ++fcaltileIt) {
662 , fcaltileIt->getIndexJ()
663 , fcaltileIt->getIndexI());
664
665 if(cellPosShift) {
667 elementPosShift.
dx = cellPosShift->
deltaX(posShiftInd);
668 elementPosShift.
dy = cellPosShift->
deltaY(posShiftInd);
669 elementPosShift.
dz = cellPosShift->
deltaZ(posShiftInd);
670 }
672 , 0
673 , 0
674 , fcalDescr
675 , &(*fcaltileIt)
676 , fcalmodule
677 , isTestBeam
678 , geoAlignStore
679 , cellPosShift ? &elementPosShift : nullptr);
680
681 double tubeSpacing = cellVol.getFcalTubeSpacing((
int)fcalmodule->
getModuleIndex());
682 unsigned int numTubes = fcaltileIt->getNumTubes();
684 fcalElement->
set_volume(.5*sqrt(3)*numTubes*tubeSpacing*tubeSpacing*dz);
685
686 caloMgr->add(fcalElement);
687
688 if(eta_min > std::abs(fcalElement->
eta_raw())-0.5*fcalElement->
deta())
689 eta_min = std::abs(fcalElement->
eta_raw())-0.5*fcalElement->
deta();
690 if(eta_max < std::abs(fcalElement->
eta_raw())+0.5*fcalElement->
deta())
691 eta_max = std::abs(fcalElement->
eta_raw())+0.5*fcalElement->
deta();
692 if(r_min > fcalElement->
r() - 0.5*fcalElement->
dr())
693 r_min = fcalElement->
r() - 0.5*fcalElement->
dr();
694 if(r_max < fcalElement->
r() + 0.5*fcalElement->
dr())
695 r_max = fcalElement->
r() + 0.5*fcalElement->
dr();
696 if(z_min > std::abs(fcalElement->
z_raw()) - 0.5*fcalElement->
dz())
697 z_min = std::abs(fcalElement->
z_raw()) - 0.5*fcalElement->
dz();
698 if(z_max < std::abs(fcalElement->
z_raw()) + 0.5*fcalElement->
dz())
699 z_max = std::abs(fcalElement->
z_raw()) + 0.5*fcalElement->
dz();
700 if(reg_min > fcalElement->
eta()-0.5*fcalElement->
deta())
701 reg_min = fcalElement->
eta()-0.5*fcalElement->
deta();
702 if(reg_max < fcalElement->
eta()+0.5*fcalElement->
deta())
703 reg_max = fcalElement->
eta()+0.5*fcalElement->
deta();
704
706 depth_in.push_back(std::abs(fcalElement->
z_raw()) - fcalElement->
dz());
707 depth_out.push_back(std::abs(fcalElement->
z_raw()) + fcalElement->
dz());
708 }
709 }
710
711
715
716
725
726
730
733 }
734 else {
736 }
737 }
738 }
739
740
741
742
743
744
745
746
747
751 log << MSG::WARNING <<
"Could not get the TileDetectorManager. No Calo Elements will be built for Tile" <<
endmsg;
752 }
753 else {
754 log << MSG::DEBUG <<
" Found the TileDetDescrManager " <<
endmsg;
756 unsigned idHashMax = maxHash-minHash;
757 for(unsigned int idhash=0; idhash < idHashMax; ++idhash) {
759 if(newelt) {
760 caloMgr->add(newelt);
761 }
762 }
763
766
767 for(; itr !=
end; ++itr) {
768 caloMgr->add_tile(*itr);
769 }
770 }
771
772
773
774
775
776
777
778 if(isTestBeam) {
780 if(
detStore->retrieve(cDDEvec) == StatusCode::SUCCESS) {
781
783 caloMgr->add (elt);
784 }
785 }
786 }
787
788 return caloMgr;
789}
Scalar eta() const
pseudorapidity method
GeoIntrusivePtr< const EMBCell > EMBCellConstLink
GeoIntrusivePtr< const HECCell > HECCellConstLink
@Class: HECCellConstLink
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
void calo_cell_hash_range(const Identifier id, IdentifierHash &caloCellMin, IdentifierHash &caloCellMax) const
to loop on 'global' cell hashes of one sub-calorimeter alone
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
Helper class for offline cell identifiers.
This class groups all DetDescr information related to a CaloCell.
float eta_raw() const
cell eta_raw
float dphi() const
cell dphi
void set_volume(double volume)
set cell volume
float eta() const
cell eta
float phi() const
cell phi
float deta() const
cell deta
float z_raw() const
cell z_raw
void set_depth_out(std::vector< double > &calo_depth)
set vector of out depths
void setLArRegMin(double reg_min)
Set LAr Region Eta Min.
int n_phi() const
phi granularity
void setLArPhiMin(double phi_min)
Set LAr Region Phi Min.
void setCaloRMin(double r_min)
Set R Min.
void setLArRegMax(double reg_max)
Set LAr Region Eta Max.
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 setLArEtaMin(double eta_min)
Set LAr Region Phi Max.
void setCaloEtaMax(double eta_max)
Set Eta Max.
This class initializes the Calo (LAr and Tile) offline identifiers.
const LArHEC_ID * getHEC_ID(void) const
const LArFCAL_ID * getFCAL_ID(void) const
const LArEM_ID * getEM_ID(void) const
contType::size_type size_type
float deltaX(const size_type &hashID) const
float deltaY(const size_type &hashID) const
float deltaZ(const size_type &hashID) const
const CellBinning & getPhiBinning() const
The Binning in Phi.
const CellBinning & getEtaBinning() const
The Binning in Eta.
LAr EMB Detector Element.
A manager class providing access to readout geometry information for the electromagnetic barrel calor...
EMBDetectorManager::DetectorRegionConstIterator beginDetectorRegion() const
Iterate over detector regions.
std::vector< constEMBDetectorRegion * >::const_iterator DetectorRegionConstIterator
EMBDetectorManager::DetectorRegionConstIterator endDetectorRegion() const
Iterate over detector regions.
const EMBDetDescr * getDescriptor() const
Returns the Descriptor for this region.
unsigned int beginPhiIndex() const
Returns the first phi index in the region.
EMBCellConstLink getEMBCell(unsigned int ieta, unsigned int iphi) const
Access to Cells.
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index.
EMBDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
unsigned int getRegionIndex() const
Returns the Region Index.
unsigned int beginEtaIndex() const
Returns the first eta index in the region.
Smart Pointer to EMEC Cells.
const CellBinning & getEtaBinning() const
The Binning in Eta.
const CellBinning & getPhiBinning() const
The Binning in Phi.
LAr EMEC Detector Element.
A manager class providing access to readout geometry information for the electromagnetic endcap calor...
EMECDetectorManager::DetectorRegionConstIterator endDetectorRegion() const
Iterate over detector regions.
EMECDetectorManager::DetectorRegionConstIterator beginDetectorRegion() const
Iterate over detector regions.
std::vector< constEMECDetectorRegion * >::const_iterator DetectorRegionConstIterator
EMECCellConstLink getEMECCell(unsigned int ieta, unsigned int iphi) const
Access to Cells.
unsigned int beginPhiIndex() const
returns the first phi index in the region.
unsigned int getRadialIndex() const
Returns the Radial (Outer Wheel=0,InnerWheel=1) Index.
unsigned int getRegionIndex() const
Returns the Region Index.
EMECDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
const EMECDetDescr * getDescriptor() const
Returns the Descriptor for this region.
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index.
unsigned int beginEtaIndex() const
returns the first eta index in the region.
LAr FCAL Detector Element.
A manager class providing access to readout geometry information for the forward calorimeter.
std::vector< constFCALModule * >::const_iterator ConstIterator
FCALDetectorManager::ConstIterator beginFCAL() const
Iterate over FCAL Modules.
FCALDetectorManager::ConstIterator endFCAL() const
Iterate over FCAL Modules.
FCALModule::Endcap getEndcapIndex() const
Returns the side (O=Negative, 1=Positive)
double getFullDepthZ(const FCALTile &) const
Gets Tile (full) Depth.
std::vector< FCALTile >::const_iterator ConstIterator
FCALModule::ConstIterator beginTiles() const
Iteration over FCAL Tiles.
FCALModule::Module getModuleIndex() const
Returns the Module (1,2, or 3)
FCALModule::ConstIterator endTiles() const
Iteration over FCAL Tiles.
const CellBinning & getPhiBinning() const
The Binning in Phi.
const CellBinning & getEtaBinning() const
The Binning in Eta.
LAr HEC Detector Element.
A manager class providing access to readout geometry information for the hadronic endcap calorimeter.
HECDetectorManager::DetectorRegionConstIterator endDetectorRegion() const
Iterate over detector regions.
HECDetectorManager::DetectorRegionConstIterator beginDetectorRegion() const
Iterate over detector regions.
std::vector< constHECDetectorRegion * >::const_iterator DetectorRegionConstIterator
Description of a region of homogenous granularity in the hadronic endcap calorimeter.
unsigned int getRegionIndex() const
Returns the Region Index.
HECCellConstLink getHECCell(unsigned int ieta, unsigned int iphi) const
Retrieve a cell with eta index and phi index.
unsigned int beginPhiIndex() const
returns the first phi index in the region.
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index (0-3)
const HECDetDescr * getDescriptor() const
Returns the Descriptor for this region.
unsigned int beginEtaIndex() const
returns the first eta index in the region.
HECDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
This is a "hash" representation of an Identifier.
void isTestBeam(bool flag)
Set Test Beam flag.
Identifier region_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
Helper class for LArEM offline identifiers.
Identifier module_id(const ExpandedIdentifier &exp_id) const
module identifier for a channel from ExpandedIdentifier
IdentifierHash channel_hash(Identifier channelId) const
Convert a connected channel (cell) Identifier to a hash code.
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
Helper class for LArFCAL offline identifiers.
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
Identifier region_id(const ExpandedIdentifier &exp_id) const
region identifier for a channel from ExpandedIdentifier
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
Helper class for LArHEC offline identifiers.
calo_descr_const_iterator calo_descriptors_end() const
CaloDetDescrElement * get_cell_element(unsigned int cell_hash) const
calo_descr_const_iterator calo_descriptors_begin() const
setScale setgFexType iEta
dx,dy,dz displacement of the calorimeter cell caused by sagging