ATLAS Offline Software
Loading...
Searching...
No Matches
VP1CaloCells.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11#include <Inventor/nodes/SoSeparator.h>
12
14#include "CaloDetDescr/CaloDetDescrElement.h"
15#include "TileEvent/TileCell.h"
17
23
24#include <stdexcept>
25#include <sstream>
26
27// MBTS
29#include <Inventor/nodes/SoTransform.h>
30
31// Epsilon for changing MBTS cell dimensions with respect to the volume dimensions
32#define MBTS_EPS 10
33
34// ************ Base Class ***************
36 m_caloCell(caloCell)
37{
38 // Cannot draw object if it has no Calo DDE
39 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
40 if (!ddElement)
41 throw std::runtime_error("VP1CaloCell: Calo Cell has no Calo DDE");
42}
43
47
49{
50 return m_caloCell;
51}
52
54{
55 return m_caloCell->ID();
56}
57
58double VP1CaloCell::energyToTransverse(const double& e) const
59{
60 return m_caloCell->sinTh()*e;
61}
62
64{
65 // only do this if it's something significant
66 if (globalCuts.clipRadius<10e8){
67 if (!isInsideClipVolume(globalCuts)) return false;
68 // double radius = sqrt(m_caloCell->x()*m_caloCell->x() + m_caloCell->y()*m_caloCell->y() + m_caloCell->z()*m_caloCell->z());
69
70 }
71
72 // Check side and Eta cut
73 bool passed = (m_caloCell->eta()>=0 && globalCuts.sideA)
74 || (m_caloCell->eta()<0 && globalCuts.sideC);
75 passed = passed && globalCuts.allowedEta.contains(m_caloCell->eta());
76 if(!passed) return false;
77 // Check Phi Cut
78 passed = false;
79 for(const VP1Interval& i : globalCuts.allowedPhi){
80 if(i.contains(m_caloCell->phi())
81 ||i.contains(m_caloCell->phi()+2*M_PI)
82 ||i.contains(m_caloCell->phi()-2*M_PI)) {
83 passed = true;
84 break;
85 }
86 }
87 return passed;
88}
89
91 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
92 double radius = ddElement->r();
93 double z = ddElement->z();
94 double radialDistance = sqrt(radius*radius + z*z);
95 if (radialDistance < globalCuts.clipRadius ) return true;
96 return false;
97}
98
100 bool useEt,
101 const QPair<bool,double>& scale,
102 bool outline,
103 const VP1CC_GlobalCuts& globalCuts)
104{
105 if(cutPassed(globalCuts))
106 build3DObjects(node2cc,useEt,scale,outline, globalCuts);
107 else
108 remove3DObjects(node2cc);
109}
110
111// ************ LAr ***************
113 VP1CaloCell(caloCell),
114 m_hit(0),
115 m_helper(0)
116{
121}
122
126
128{
129 if(m_hit) {
130 node2cc->erase(m_hit);
131 m_helper->removeNode(m_hit);
132 m_hit = 0;
133 }
134}
135
136// ************ LArEMB ***************
138 const VP1CC_SeparatorMap* separators):
139 VP1CC_LAr(caloCell)
140{
141 // define Separator type depending on Cell energy
142 if(!separators)
143 throw std::runtime_error("VP1CC_LArEMB: 0 pointer to VP1CC Separator Map");
144
145 VP1CC_SeparatorTypes mySeparatorType;
146 if(caloCell->energy()<0)
147 mySeparatorType = VP1CC_SepLArEMBNeg;
148 else
149 mySeparatorType = VP1CC_SepLArEMBPos;
150
151 // get SoSeparator from the map
152 VP1CC_SeparatorMap::const_iterator it = separators->find(mySeparatorType);
153 if(it ==separators->end())
154 throw std::runtime_error("VP1CC_LArEMB: Missing separator helper in the map");
155
156 m_helper = it->second;
157
158 if(!m_helper)
159 throw std::runtime_error("VP1CC_LArEMB: 0 pointer to separator helper");
160}
161
165
167 bool useEt,
168 const QPair<bool,double>& scale,
169 bool outline,
170 const VP1CC_GlobalCuts& globalCuts)
171{
172 bool createNewHit = false;
173 if(!m_hit){
174 m_hit = new SoGenericBox();
175 createNewHit = true;
176 }
177
178 // Build new Hit object
179 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
180
181 // auxiliary variables
182 double eta = ddElement->eta();
183 double deta = ddElement->deta()*0.5;
184 double phi = ddElement->phi();
185 double dphi = ddElement->dphi()*0.5;
186 double radius = ddElement->r();
187 double energy = (useEt ? energyToTransverse(m_caloCell->energy()) : m_caloCell->energy());
188
189 double z = std::fabs(ddElement->z());
190 double radialDistance = sqrt(radius*radius + z*z);
191
192 double depth = cellDepth(scale,energy);
193 depth = std::min(depth, std::fabs(globalCuts.clipRadius - radialDistance ) ) ;
194
195 // std::cout<<"z "<<ddElement->z()<<"\t radialDistance "<<radialDistance<<"\t clipRadius "<<globalCuts.clipRadius<<"\t depth "<<depth<<std::endl;
196
197 m_hit->setParametersForBarrelEtaPhiCell( eta-deta,eta+deta,phi-dphi,phi+dphi,
198 depth, radius, 0.9, 0.9 );
199 m_hit->drawEdgeLines = outline;
200
201 if(createNewHit) {
202 m_helper->addNode(m_hit);
203 (*node2cc)[m_hit] = this;
204 }
205}
206
207std::vector<std::string> VP1CC_LArEMB::ToString(const CaloCell_ID*, const std::string& extrainfos)
208{
209 std::vector<std::string> result;
210 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
211 std::ostringstream msg, msg1, msg2, msg3;
212
213 std::string stars("***");
214 result.push_back(stars);
215
216 msg << "LAr EMB. ID = " << m_caloCell->ID().getString() << " " << extrainfos;
217
218 msg1 << " Eta = " << ddElement->eta()
219 << " Phi = " << ddElement->phi();
220
221 msg2 << "Energy = " << m_caloCell->energy() << " (Mev)"
222 << " Gain " << m_caloCell->gain();
223
224 msg3 << "Time = " << m_caloCell->time()
225 << " Quality = " << m_caloCell->quality()
226 << " Provenance = " << m_caloCell->provenance();
227
228 result.push_back(msg.str());
229 result.push_back(msg1.str());
230 result.push_back(msg2.str());
231 result.push_back(msg3.str());
232
233 result.push_back(stars);
234 return result;
235}
236
237// ************ LArEMECHEC ***************
239 const CaloCell_ID* calo_id,
240 const VP1CC_SeparatorMap* separators):
241 VP1CC_LAr(caloCell)
242{
243 if(!separators)
244 throw std::runtime_error("VP1CC_LArEMECHEC: 0 pointer to VP1CC Separator Map");
245
246 bool isEMEC = false;
247 if(calo_id->is_em_endcap(caloCell->ID()))
248 isEMEC = true;
249 else if(calo_id->is_hec(caloCell->ID()))
250 isEMEC = false;
251 else
252 throw std::runtime_error("VP1CC_LArEMECHEC: Calo Cell is neither EMEC nor HEC!");
253
254 // define Separator type depending on Cell energy
255 VP1CC_SeparatorTypes mySeparatorType;
256 if(caloCell->energy()<0) {
257 if(isEMEC)
258 mySeparatorType = VP1CC_SepLArEMECNeg;
259 else
260 mySeparatorType = VP1CC_SepLArHECNeg;
261 } else {
262 if(isEMEC)
263 mySeparatorType = VP1CC_SepLArEMECPos;
264 else
265 mySeparatorType = VP1CC_SepLArHECPos;
266 }
267
268 // get SoSeparator from the map
269 VP1CC_SeparatorMap::const_iterator it = separators->find(mySeparatorType);
270 if(it ==separators->end())
271 throw std::runtime_error("VP1CC_LArEMECHEC: Missing separator in the map");
272
273 m_helper = it->second;
274
275 if(!m_helper)
276 throw std::runtime_error("VP1CC_LArEMECHEC: 0 pointer to the separator helper");
277}
278
282
283std::vector<std::string> VP1CC_LArEMECHEC::ToString(const CaloCell_ID* calo_id, const std::string& extrainfos)
284{
285 std::vector<std::string> result;
286 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
287
288 std::ostringstream msg, msg1, msg2, msg3;
289
290 std::string stars("***");
291 result.push_back(stars);
292
293 if(calo_id->is_em_endcap(m_caloCell->ID()))
294 msg << "LAr EMEC. ID = " << m_caloCell->ID().getString();
295 else
296 msg << "LAr HEC. ID = " << m_caloCell->ID().getString();
297 msg << " " << extrainfos;
298
299 msg1 << " Eta = " << ddElement->eta()
300 << " Phi = " << ddElement->phi();
301
302 msg2 << "Energy = " << m_caloCell->energy() << " (Mev)"
303 << " Gain " << m_caloCell->gain();
304
305 msg3 << "Time = " << m_caloCell->time()
306 << " Quality = " << m_caloCell->quality()
307 << " Provenance = " << m_caloCell->provenance();
308
309 result.push_back(msg.str());
310 result.push_back(msg1.str());
311 result.push_back(msg2.str());
312 result.push_back(msg3.str());
313
314 result.push_back(stars);
315 return result;
316}
317
319 bool useEt,
320 const QPair<bool,double>& scale,
321 bool outline,
322 const VP1CC_GlobalCuts& globalCuts)
323{
324 bool createNewHit = false;
325 if(!m_hit){
326 m_hit = new SoGenericBox();
327 createNewHit = true;
328 }
329
330 // Build new Hit object
331 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
332
333 // auxiliary variables
334 double eta = ddElement->eta();
335 double deta = ddElement->deta()*0.5;
336 double phi = ddElement->phi();
337 double dphi = ddElement->dphi()*0.5;
338 double z = ddElement->z();
339 double energy = (useEt ? energyToTransverse(m_caloCell->energy()) : m_caloCell->energy());
340
341 double depth = cellDepth(scale,energy);
342 depth = std::min(depth, std::fabs(globalCuts.clipRadius - z));
343
344 m_hit->setParametersForEndCapEtaPhiCell( eta-deta,eta+deta,phi-dphi,phi+dphi,
345 depth, z, 0.9, 0.9 );
346 m_hit->drawEdgeLines = outline;
347
348 if(createNewHit) {
349 m_helper->addNode(m_hit);
350 (*node2cc)[m_hit] = this;
351 }
352}
353
354// ************ LArFCAL ***************
356 const VP1CC_SeparatorMap* separators):
357 VP1CC_LAr(caloCell)
358{
359 if(!separators)
360 throw std::runtime_error("VP1CC_LArFCAL: 0 pointer to VP1CC Separator Map");
361
362 // define Separator type depending on Cell energy
363 VP1CC_SeparatorTypes mySeparatorType;
364
365 if(m_caloCell->energy()<0)
366 mySeparatorType = VP1CC_SepLArFCALNeg;
367 else
368 mySeparatorType = VP1CC_SepLArFCALPos;
369
370 VP1CC_SeparatorMap::const_iterator it = separators->find(mySeparatorType);
371 if(it ==separators->end())
372 throw std::runtime_error("VP1CC_LArFCAL: Missing separator in the map");
373
374 m_helper = it->second;
375
376 if(!m_helper)
377 throw std::runtime_error("VP1CC_LArFCAL: Wrong 0 pointer to the separator helper");
378}
379
383
384std::vector<std::string> VP1CC_LArFCAL::ToString(const CaloCell_ID*, const std::string& extrainfos )
385{
386 std::vector<std::string> result;
387 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
388 std::ostringstream msg, msg1, msg2, msg3;
389
390 std::string stars("***");
391 result.push_back(stars);
392
393 msg << "LAr FCAL. ID = " << m_caloCell->ID().getString() << " " << extrainfos;
394
395 msg1 << " Eta = " << ddElement->eta()
396 << " Phi = " << ddElement->phi();
397
398 msg2 << " Energy = " << m_caloCell->energy() << " (Mev)"
399 << " Gain " << m_caloCell->gain();
400
401 msg3 << "Time = " << m_caloCell->time()
402 << " Quality = " << m_caloCell->quality()
403 << " Provenance = " << m_caloCell->provenance();
404
405 result.push_back(msg.str());
406 result.push_back(msg1.str());
407 result.push_back(msg2.str());
408 result.push_back(msg3.str());
409
410 result.push_back(stars);
411 return result;
412}
413
415 bool useEt,
416 const QPair<bool,double>& scale,
417 bool outline,
418 const VP1CC_GlobalCuts& globalCuts)
419{
420 bool createNewHit = false;
421 if(!m_hit) {
422 m_hit = new SoGenericBox();
423 createNewHit = true;
424 }
425
426 // Build new Hit object
427 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
428
429 // auxiliary variables
430 double x = ddElement->x();
431 double dx = ddElement->dx()*0.5;
432 double y = ddElement->y();
433 double dy = ddElement->dy()*0.5;
434 double z = ddElement->z();
435 double dz = ddElement->dz()*0.5;
436 double energy = (useEt ? energyToTransverse(m_caloCell->energy()) : m_caloCell->energy());
437
438 double halfdepth(0.5*cellDepth(scale,energy));
439 halfdepth = std::min(halfdepth, std::fabs(0.5 * (globalCuts.clipRadius - std::fabs(z))));
440 // std::cout<<"cellDepth: "<<0.5*cellDepth(scale,energy)<<"\t halfdepth: "<<halfdepth<<"\t z "<<z<<"\t dz "<<dz<<std::endl;
441 if(z>0){
442 m_hit->setParametersForBox( dx*0.9, dy*0.9, halfdepth,x,y,z-dz+halfdepth);
443 } else {
444 m_hit->setParametersForBox( dx*0.9, dy*0.9, halfdepth,x,y,z+dz-halfdepth);
445 }
446 m_hit->drawEdgeLines = outline;
447
448 if(createNewHit) {
449 m_helper->addNode(m_hit);
450 (*node2cc)[m_hit] = this;
451 }
452}
453
455 const TileID* tile_id):
456 VP1CaloCell(caloCell),
457 m_tileID(tile_id)
458{
459}
460
464
465// ************ Tile ***************
467 const TileID* tile_id,
468 const VP1CC_SeparatorMap* separators):
469 VP1CC_Tile(caloCell,tile_id),
470 m_hitUp(0),
471 m_hitDown(0)
472{
478 if(!separators)
479 throw std::runtime_error("VP1CC_TileBarEc: 0 pointer to VP1CC Separator Map");
480
481 // The CaloCell has to be of type TileCell
482 const TileCell* tile_cell = dynamic_cast<const TileCell*>(caloCell);
483 if(tile_cell==0)
484 throw std::runtime_error("VP1CC_TileBarEc: CaloCell is not TileCell");
485
486 // define Separator types (Up/Down) depending on Cell energy
487 VP1CC_SeparatorTypes mySeparatorTypeUp;
488 VP1CC_SeparatorTypes mySeparatorTypeDown;
489
490 double energy1 = tile_cell->ene1();
491 double energy2 = tile_cell->ene2();
492
493 if(caloCell->energy()<0)
494 {
495 if(energy1>=0)
496 mySeparatorTypeDown = VP1CC_SepTileNegativePos;
497 else
498 mySeparatorTypeDown = VP1CC_SepTileNegativeDown;
499
500 if(energy2>=0)
501 mySeparatorTypeUp = VP1CC_SepTileNegativePos;
502 else
503 mySeparatorTypeUp = VP1CC_SepTileNegativeUp;
504 }
505 else
506 {
507 if(energy1<=0)
508 mySeparatorTypeDown = VP1CC_SepTilePositiveNeg;
509 else
510 mySeparatorTypeDown = VP1CC_SepTilePositiveDown;
511
512 if(energy2<=0)
513 mySeparatorTypeUp = VP1CC_SepTilePositiveNeg;
514 else
515 mySeparatorTypeUp = VP1CC_SepTilePositiveUp;
516 }
517
518 VP1CC_SeparatorMap::const_iterator it = separators->find(mySeparatorTypeDown);
519 if(it ==separators->end())
520 throw std::runtime_error("VP1CC_TileBarEc: Missing separator helper in the map");
521
522 m_helperDown = it->second;
523
524 it = separators->find(mySeparatorTypeUp);
525 if(it ==separators->end())
526 throw std::runtime_error("VP1CC_TileBarEc: Missing separator helper in the map");
527
528 m_helperUp = it->second;
529
530 if(!m_helperDown || !m_helperUp)
531 throw std::runtime_error("VP1CC_TileBarEc: 0 pointer to one of separator helpers" );
532}
533
537
538std::vector<std::string> VP1CC_TileBarEc::ToString(const CaloCell_ID*, const std::string& extrainfos)
539{
540 std::vector<std::string> result;
541 const TileCell* tile_cell = dynamic_cast<const TileCell*>(m_caloCell);
542 if (not tile_cell) return result;
543 Identifier cellid = m_caloCell->ID();
544
545 double total_energy = m_caloCell->energy();
546 double total_time = m_caloCell->time();
547 double pmt_energy1 = tile_cell->ene1();
548 double pmt_time1 = tile_cell->time1();
549 double pmt_energy2 = tile_cell->ene2();
550 double pmt_time2 = tile_cell->time2();
551
552 std::ostringstream msg, msg1, msg2, msg3, msg4;
553 msg << "Cell: " << id2name(cellid) << " " << extrainfos;
554 msg1 << "Energy = " << total_energy << " (Mev)";
555 msg2 << "Time = " << total_time;
556 msg3 << " PMT1 Energy = " << pmt_energy1 << " (Mev)"
557 << " PMT1 Time = " << pmt_time1;
558 msg4 << " PMT2 Energy = " << pmt_energy2 << " (Mev)"
559 << " PMT2 Time = " << pmt_time2;
560
561 std::string stars("***");
562 result.push_back(stars);
563
564 result.push_back(msg.str());
565 result.push_back(msg1.str());
566 result.push_back(msg2.str());
567 result.push_back(msg3.str());
568 result.push_back(msg4.str());
569
570 result.push_back(stars);
571 return result;
572}
573
575 bool up,
576 int& frag,
577 int& channel)
578{
579 HWIdentifier hwId;
580 IdContext context = tile_hw_id->channel_context();
581
582 int result = 0;
583
584 if(up)
585 result = tile_hw_id->get_id(m_caloCell->caloDDE()->onl2(),hwId,&context);
586 else
587 result = tile_hw_id->get_id(m_caloCell->caloDDE()->onl1(),hwId,&context);
588
589 if(result!=0)
590 return result;
591
592 frag = tile_hw_id->frag(hwId);
593 channel = tile_hw_id->channel(hwId);
594
595 return 0;
596}
597
599 bool useEt,
600 const QPair<bool,double>& scale,
601 bool outline,
602 const VP1CC_GlobalCuts& globalCuts)
603{
604 bool createNewHit = false;
605 if(!m_hitUp){
606 m_hitUp = new SoGenericBox();
607 m_hitDown = new SoGenericBox();
608 createNewHit = true;
609 }
610
611 const TileCell* tile_cell = dynamic_cast<const TileCell*>(m_caloCell);
612 if (not tile_cell) return;
613 double energy1 = (useEt ? energyToTransverse(tile_cell->ene1()) : tile_cell->ene1());
614 double energy2 = (useEt ? energyToTransverse(tile_cell->ene2()) : tile_cell->ene2());
615
616 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
617
618 double eta = ddElement->eta();
619 double deta = ddElement->deta()*0.5;
620 double phi = ddElement->phi();
621 double dphi = ddElement->dphi()*0.5;
622 double radius = ddElement->r();
623 double dradius = ddElement->dr()*0.5;
624
625 double z = ddElement->z();
626 double minR = radius - dradius;
627 double radialDistance = sqrt(minR*minR + z*z);
628
629
630 double depth1 = cellDepth(scale,energy1);
631 depth1 = std::min(depth1, std::fabs(globalCuts.clipRadius - radialDistance));
632 double depth2 = cellDepth(scale,energy2);
633 depth2 = std::min(depth2, std::fabs(globalCuts.clipRadius - radialDistance));
634 // std::cout<<"VP1CC_TileBarEc clipRadius: "<<globalCuts.clipRadius<<"\t radius "<<radius<<"\t depth1 "
635 // <<cellDepth(scale,energy1)<<"\t depth2 "<<cellDepth(scale,energy2)<<"\t cd1 "<<depth1<<"\t cd1 "<<depth1<<std::endl;
636
637 //double etaMin, double etaMax,
638 // double phiMin, double phiMax,
639 // double cellDepth, double cellDistance,
640 // double etasqueezefact, double phisqueezefact
641 m_hitUp->setParametersForBarrelEtaPhiCell(eta,eta+deta,phi-dphi,phi+dphi,
642 depth1,radius-dradius,0.9,0.9);
643 m_hitUp->drawEdgeLines = outline;
644 m_hitDown->setParametersForBarrelEtaPhiCell(eta-deta,eta,phi-dphi,phi+dphi,
645 depth2,radius-dradius,0.9,0.9);
646 m_hitDown->drawEdgeLines = outline;
647
648 if(createNewHit) {
649 (*node2cc)[m_hitUp] = this;
650 (*node2cc)[m_hitDown] = this;
651 m_helperUp->addNode(m_hitUp);
652 m_helperDown->addNode(m_hitDown);
653 }
654}
655
657 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
658 double z = ddElement->z();
659 double radius = ddElement->r();
660 double dradius = ddElement->dr()*0.5;
661 double minR = radius - dradius;
662
663 double radialDistance = sqrt(minR*minR + z*z);
664
665 if ( radialDistance > globalCuts.clipRadius ) return false;
666 return true;
667}
668
669
671{
672 if(m_hitUp) {
673 // Remove entries from node2cc map
674 node2cc->erase(m_hitUp);
675 node2cc->erase(m_hitDown);
676
677 // Drop the hit from the scene and delete hit object
678 m_helperUp->removeNode(m_hitUp);
679 m_helperDown->removeNode(m_hitDown);
680
681 m_hitUp = 0;
682 m_hitDown = 0;
683 }
684}
685
687{
688 std::string name("");
689
690 // Barrel/EC
691 if(m_tileID->is_tile_barrel(id))
692 name += std::string("LB");
693 else
694 name += std::string("EB");
695
696 // Pos/Neg
697 if(m_tileID->side(id)==1)
698 name += std::string("A");
699 else
700 name += std::string("C");
701
702 // Module number
703 std::ostringstream modnum;
704 modnum << m_tileID->module(id) + 1;
705 name += (modnum.str() + std::string(" "));
706
707 // Sample
708 int sample = m_tileID->sample(id);
709 switch(sample)
710 {
711 case 0:
712 {
713 name += std::string("A");
714 break;
715 }
716 case 1:
717 {
718 if(m_tileID->is_tile_barrel(id))
719 {
720 name += std::string("B");
721 if(m_tileID->tower(id)<9)
722 name += std::string("C");
723 }
724 else
725 {
726 if(m_tileID->section(id)==2)
727 name += std::string("B");
728 else
729 name += std::string("C");
730 }
731 break;
732 }
733 case 2:
734 {
735 name += std::string("D");
736 break;
737 }
738 default:
739 break;
740 }
741
742 // Tower
743 std::ostringstream townum;
744 if(m_tileID->sample(id)==2)
745 townum << m_tileID->tower(id)/2;
746 else
747 townum << m_tileID->tower(id)+1;
748
749 name += townum.str();
750 return name;
751}
752
753// ************ TileCrack ***************
754VP1CC_TileCrack::VP1CC_TileCrack(const CaloCell* caloCell,const TileID* tile_id,
755 const VP1CC_SeparatorMap* separators):VP1CC_Tile(caloCell,tile_id), m_hit(0){
761 if(!separators)
762 throw std::runtime_error("VP1CC_TileCrack: 0 pointer to VP1CC Separator Map");
763
764 // define Separator type depending on Cell energy
765 VP1CC_SeparatorTypes mySeparatorType;
766
767 if(caloCell->energy()<0)
768 mySeparatorType = VP1CC_SepTileNegativeDown;
769 else
770 mySeparatorType = VP1CC_SepTilePositiveDown;
771
772 VP1CC_SeparatorMap::const_iterator it = separators->find(mySeparatorType);
773 if(it ==separators->end())
774 throw std::runtime_error("VP1CC_TileCrack: Missing separator in the map");
775
776 m_helper = it->second;
777
778 if(!m_helper)
779 throw std::runtime_error("VP1CC_TileCrack: 0 pointer to the separator");
780}
781
785
786std::vector<std::string> VP1CC_TileCrack::ToString(const CaloCell_ID* calo_id, const std::string& extrainfos)
787{
788 std::vector<std::string> result;
789 std::ostringstream msg, msg1;
790
791 std::string stars("***");
792 result.push_back(stars);
793 result.push_back(std::string("TileCrack Calo Cell"));
794
795 // Create cell name (string)
796 std::string cellName("EB");
797 if(calo_id->side(m_caloCell->ID()) > 0)
798 cellName += std::string("A");
799 else
800 cellName += std::string("C");
801
802 // Module number
803 std::ostringstream modnum;
804 modnum << calo_id->module(m_caloCell->ID()) + 1;
805 cellName += (modnum.str() + std::string(" E"));
806
807 switch(calo_id->tower(m_caloCell->ID()))
808 {
809 case 10:
810 {
811 cellName += std::string("1");
812 break;
813 }
814 case 11:
815 {
816 cellName += std::string("2");
817 break;
818 }
819 case 13:
820 {
821 cellName += std::string("3");
822 break;
823 }
824 case 15:
825 {
826 cellName += std::string("4");
827 break;
828 }
829 default:
830 break;
831 }
832
833 msg << "Cell: " << cellName << " " << extrainfos;
834
835 msg1 << " Energy = " << m_caloCell->energy() << " (Mev)"
836 << " Time = " << m_caloCell->time();
837 result.push_back(msg.str());
838 result.push_back(msg1.str());
839
840 result.push_back(stars);
841 return result;
842}
843
845 bool /*up*/,//TK: Not used?
846 int& frag,
847 int& channel )
848{
849 HWIdentifier hwId;
850 IdContext context = tile_hw_id->channel_context();
851
852 int result = tile_hw_id->get_id(m_caloCell->caloDDE()->onl1(),hwId,&context);
853
854 if(result!=0)
855 return result;
856
857 frag = tile_hw_id->frag(hwId);
858 channel = tile_hw_id->channel(hwId);
859
860 return 0;
861}
862
864 bool useEt,
865 const QPair<bool,double>& scale,
866 bool outline,
867 const VP1CC_GlobalCuts& globalCuts)
868{
869 bool createNewHit = false;
870 if(!m_hit) {
871 m_hit = new SoGenericBox();
872 createNewHit = true;
873 }
874
875 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
876 double eta = ddElement->eta();
877 double deta = ddElement->deta()*0.5;
878 double phi = ddElement->phi();
879 double dphi = ddElement->dphi()*0.5;
880 double z = ddElement->z();
881 double dz = ddElement->dz()*0.5;
882 double energy = (useEt ? energyToTransverse(m_caloCell->energy()) : m_caloCell->energy());
883
884 double radius = ddElement->r();
885 double minZ = std::fabs(z)-dz;
886 double radialDistance = sqrt(radius*radius + minZ*minZ);
887
888 double depth = cellDepth(scale,energy);
889 depth = std::min(depth, std::fabs(globalCuts.clipRadius - radialDistance));
890 // std::cout<<"z "<<z<<"\t dz "<<dz<<"\t r "<<ddElement->r()<<"\t clipRadius"<<globalCuts.clipRadius<<"\t depth "<<depth<<"\t cellDepth "<<cellDepth(scale,energy)<<std::endl;
891
892 // std::cout<<"VP1CC_TileCrack clipRadius: "<<globalCuts.clipRadius<<"\t radialDistance "<<radialDistance<<"\t depth "
893 // <<cellDepth(scale,energy)<<"\t cd1 "<<depth<<std::endl;
894
895
896 // double etaMin, double etaMax, double phiMin, double phiMax,
897 // double cellDepth, double cellDistance, double etasqueezefact, double phisqueezefact
898 m_hit->setParametersForEndCapEtaPhiCell( eta-deta,eta+deta,phi-dphi,phi+dphi,
899 depth,z-dz,0.9,0.9);
900 m_hit->drawEdgeLines = outline;
901
902 if(createNewHit) {
903 (*node2cc)[m_hit] = this;
904 m_helper->addNode(m_hit);
905 }
906}
907
909 const CaloDetDescrElement* ddElement = m_caloCell->caloDDE();
910 double z = ddElement->z();
911 double dz = ddElement->dz()*0.5;
912 double radius = ddElement->r();
913 double minZ = std::fabs(z)-dz;
914 double radialDistance = sqrt(radius*radius + minZ*minZ);
915
916 if ( radialDistance > globalCuts.clipRadius ) return false;
917 return true;
918}
919
920
922{
923 if(m_hit) {
924 node2cc->erase(m_hit);
925 m_helper->removeNode(m_hit);
926 m_hit = 0;
927 }
928}
929
930// ---------------------------------------------------
931//
932// *** *** MBTS *** ***
933//
934// ---------------------------------------------------
935
937 const TileTBID* idhelper,
938 SoSeparator* separator,
939 bool run2Geo):
940 m_cell(cell),
941 m_idhelper(idhelper),
942 m_separator(separator),
943 m_run2Geo(run2Geo)
944{
945}
946
950
952 VP1CC_SoNode2MbtsMap* node2mbts,
953 double energy,
954 bool outline,
955 double clipRadius)
956{
957 // Draw object only when cell energy is above threshold
958 if(m_cell->energy() < energy)
959 return false;
960
961 // FIXME!
962 // std::cout<<"clipRadius "<<clipRadius<<std::endl;
963 if (clipRadius < 350 )
964 return false;
965
966 // Decode cell identifier in order to find draw info - shape and transformation
967 Identifier id = m_cell->ID();
968
969 int type = m_idhelper->type(id); // -1 neg, 1 pos
970 int module = m_idhelper->module(id); // 0-7 scintillator copy number
971 int channel = m_idhelper->channel(id); // 0 scin1, 1 scin2
972
973 if(drawinfo->find(channel) ==drawinfo->end())
974 throw std::runtime_error("Unable to find scintillator global info");
975
976 VP1CC_MbtsScinInfo* scinInfo = (*drawinfo)[channel];
977
978 // Get the transform
979 SoTransform* scinXF = 0;
980 if(type == -1) {
981 if(scinInfo->cTransforms.find(module)==scinInfo->cTransforms.end())
982 throw std::runtime_error("Unable to find global transform for the scintillator");
983 scinXF = VP1LinAlgUtils::toSoTransform(scinInfo->cTransforms[module]);
984 }
985 else if( type == 1) {
986 if(scinInfo->aTransforms.find(module)==scinInfo->aTransforms.end())
987 throw std::runtime_error("Unable to find global transform for the scintillator");
988 scinXF = VP1LinAlgUtils::toSoTransform(scinInfo->aTransforms[module]);
989 } else
990 return false;
991
992 // 3D object - Trd
993 SoGenericBox* scinTrd = new SoGenericBox();
994 scinTrd->setParametersForTrd(scinInfo->dx1 + MBTS_EPS,
995 scinInfo->dx2 + MBTS_EPS,
996 scinInfo->dy1 - MBTS_EPS,
997 scinInfo->dy2 - MBTS_EPS,
998 scinInfo->dz - MBTS_EPS);
999 scinTrd->drawEdgeLines = outline;
1000
1001 // Now add the object to the scene
1002 SoSeparator* scinSep = new SoSeparator;
1003 scinSep->addChild(scinXF);
1004 scinSep->addChild(scinTrd);
1005 m_separator->addChild(scinSep);
1006
1007 // Keep the pointer to the 3D object in the map
1008 (*node2mbts)[scinTrd] = this;
1009
1010 // ________________________________________________________________________________________
1011 // RUN2: if channel=1 draw two scintillators instead of one
1012 if(m_run2Geo && channel==1) {
1013 SoTransform* scinXF1 = 0;
1014 if(type == -1) {
1015 if(scinInfo->cTransforms.find(module+1)==scinInfo->cTransforms.end())
1016 throw std::runtime_error("Unable to find global transform for the scintillator");
1017 scinXF1 = VP1LinAlgUtils::toSoTransform(scinInfo->cTransforms[module+1]);
1018 }
1019 else if( type == 1) {
1020 if(scinInfo->aTransforms.find(module+1)==scinInfo->aTransforms.end())
1021 throw std::runtime_error("Unable to find global transform for the scintillator");
1022 scinXF1 = VP1LinAlgUtils::toSoTransform(scinInfo->aTransforms[module+1]);
1023 }
1024 SoGenericBox* scinTrd1 = new SoGenericBox();
1025 scinTrd1->setParametersForTrd(scinInfo->dx1 + MBTS_EPS,
1026 scinInfo->dx2 + MBTS_EPS,
1027 scinInfo->dy1 - MBTS_EPS,
1028 scinInfo->dy2 - MBTS_EPS,
1029 scinInfo->dz - MBTS_EPS);
1030 scinTrd1->drawEdgeLines = outline;
1031 // Now add the object to the scene
1032 SoSeparator* scinSep1 = new SoSeparator();
1033 scinSep1->addChild(scinXF1);
1034 scinSep1->addChild(scinTrd1);
1035 m_separator->addChild(scinSep1);
1036
1037 // Keep the pointer to the 3D object in the map
1038 (*node2mbts)[scinTrd1] = this;
1039 }
1040 // ________________________________________________________________________________________
1041 // RUN2: if channel=1 draw two scintillators instead of one
1042
1043 return true;
1044}
1045
1046std::vector<std::string> VP1Mbts::ToString()
1047{
1048 std::vector<std::string> result;
1049
1050 // Decode ID
1051 Identifier id = m_cell->ID();
1052
1053 int type = m_idhelper->type(id); // -1 neg, 1 pos
1054 int module = m_idhelper->module(id); // 0-7 scintillator copy number
1055 int channel = m_idhelper->channel(id); // 0 scin1, 1 scin2
1056
1057
1058 std::ostringstream msg, msg1, msg2, msg3;
1059 msg << " MBTS. Side = " << type << ". Scintillator Type = " << channel
1060 << ", Num = " << module;
1061 msg1 << " Energy = " << m_cell->energy();
1062 msg2 << " Time = " << m_cell->time();
1063
1064 std::string stars("***");
1065 result.push_back(stars);
1066
1067 result.push_back(msg.str());
1068 result.push_back(msg1.str());
1069 result.push_back(msg2.str());
1070
1071 result.push_back(stars);
1072 return result;
1073}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
#define y
#define x
#define z
#define MBTS_EPS
std::map< int, VP1CC_MbtsScinInfo *, std::less< int > > VP1CC_MbtsScinInfoMap
VP1CC_SeparatorTypes
@ VP1CC_SepTileNegativeDown
@ VP1CC_SepTilePositiveDown
@ VP1CC_SepLArEMBPos
@ VP1CC_SepLArFCALPos
@ VP1CC_SepLArEMBNeg
@ VP1CC_SepLArFCALNeg
std::map< SoNode *, VP1Mbts *, std::less< SoNode * > > VP1CC_SoNode2MbtsMap
std::map< VP1CC_SeparatorTypes, VP1ExtraSepLayerHelper *, std::less< VP1CC_SeparatorTypes > > VP1CC_SeparatorMap
std::map< SoNode *, VP1CaloCell *, std::less< SoNode * > > VP1CC_SoNode2CCMap
bool is_em_endcap(const Identifier id) const
test if the id belongs to the EM Endcap
int side(const Identifier id) const
Tile field values (NOT_VALID == invalid request)
bool is_hec(const Identifier id) const
test if the id belongs to the HEC
int tower(const Identifier id) const
Tile field values (NOT_VALID == invalid request)
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
double energy() const
get energy (data member)
Definition CaloCell.h:327
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
This class groups all DetDescr information related to a CaloCell.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
void setParametersForTrd(float dx1, float dx2, float dy1, float dy2, float dz)
SoSFBool drawEdgeLines
float time1(void) const
get time of first PMT
Definition TileCell.h:192
float ene1(void) const
get energy of first PMT
Definition TileCell.h:187
float time2(void) const
get time of second PMT
Definition TileCell.h:194
float ene2(void) const
get energy of second PMT
Definition TileCell.h:189
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
Definition TileHWID.h:181
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition TileHWID.h:189
virtual int get_id(const IdentifierHash &hash_id, HWIdentifier &id, const IdContext *context=0) const
create compact HW ID from hash id (return == 0 for OK)
Definition TileHWID.cxx:491
IdContext channel_context() const
idContext for channels
Definition TileHWID.cxx:478
Helper class for TileCal offline identifiers.
Definition TileID.h:67
Helper class for TileCal offline identifiers of ancillary testbeam detectors and MBTS.
QList< VP1Interval > allowedPhi
VP1Interval allowedEta
virtual ~VP1CC_LArEMB()
VP1CC_LArEMB(const CaloCell *caloCell, const VP1CC_SeparatorMap *separators)
virtual void build3DObjects(VP1CC_SoNode2CCMap *node2cc, bool useEt, const QPair< bool, double > &scale, bool outline, const VP1CC_GlobalCuts &)
std::vector< std::string > ToString(const CaloCell_ID *calo_id, const std::string &extrainfos="")
virtual ~VP1CC_LArEMECHEC()
VP1CC_LArEMECHEC(const CaloCell *caloCell, const CaloCell_ID *calo_id, const VP1CC_SeparatorMap *separators)
std::vector< std::string > ToString(const CaloCell_ID *calo_id, const std::string &extrainfos="")
virtual void build3DObjects(VP1CC_SoNode2CCMap *node2cc, bool useEt, const QPair< bool, double > &scale, bool outline, const VP1CC_GlobalCuts &)
virtual void build3DObjects(VP1CC_SoNode2CCMap *node2cc, bool useEt, const QPair< bool, double > &scale, bool outline, const VP1CC_GlobalCuts &)
std::vector< std::string > ToString(const CaloCell_ID *calo_id, const std::string &extrainfos="")
virtual ~VP1CC_LArFCAL()
VP1CC_LArFCAL(const CaloCell *caloCell, const VP1CC_SeparatorMap *separators)
virtual ~VP1CC_LAr()
VP1ExtraSepLayerHelper * m_helper
VP1CC_LAr(const CaloCell *caloCell)
virtual void remove3DObjects(VP1CC_SoNode2CCMap *node2cc)
SoGenericBox * m_hit
int GetFragChannel(const TileHWID *tile_hw_id, bool up, int &frag, int &channel)
SoGenericBox * m_hitDown
virtual void build3DObjects(VP1CC_SoNode2CCMap *node2cc, bool useEt, const QPair< bool, double > &scale, bool outline, const VP1CC_GlobalCuts &)
SoGenericBox * m_hitUp
virtual void remove3DObjects(VP1CC_SoNode2CCMap *node2cc)
VP1ExtraSepLayerHelper * m_helperUp
VP1CC_TileBarEc(const CaloCell *caloCell, const TileID *tile_id, const VP1CC_SeparatorMap *separators)
std::string id2name(Identifier &id)
bool isInsideClipVolume(const VP1CC_GlobalCuts &globalCuts)
std::vector< std::string > ToString(const CaloCell_ID *calo_id, const std::string &extrainfos="")
virtual ~VP1CC_TileBarEc()
VP1ExtraSepLayerHelper * m_helperDown
virtual void remove3DObjects(VP1CC_SoNode2CCMap *node2cc)
VP1CC_TileCrack(const CaloCell *caloCell, const TileID *tile_id, const VP1CC_SeparatorMap *separators)
int GetFragChannel(const TileHWID *tile_hw_id, bool up, int &frag, int &channel)
virtual void build3DObjects(VP1CC_SoNode2CCMap *node2cc, bool useEt, const QPair< bool, double > &scale, bool outline, const VP1CC_GlobalCuts &)
SoGenericBox * m_hit
VP1ExtraSepLayerHelper * m_helper
virtual ~VP1CC_TileCrack()
bool isInsideClipVolume(const VP1CC_GlobalCuts &globalCuts)
std::vector< std::string > ToString(const CaloCell_ID *calo_id, const std::string &extrainfos="")
virtual ~VP1CC_Tile()
VP1CC_Tile(const CaloCell *caloCell, const TileID *tile_id)
const TileID * m_tileID
void updateScene(VP1CC_SoNode2CCMap *node2cc, bool useEt, const QPair< bool, double > &scale, bool outline, const VP1CC_GlobalCuts &globalCuts)
const CaloCell * m_caloCell
VP1CaloCell(const CaloCell *caloCell)
double energyToTransverse(const double &) const
virtual void remove3DObjects(VP1CC_SoNode2CCMap *node2cc)=0
virtual bool isInsideClipVolume(const VP1CC_GlobalCuts &globalCuts)
const CaloCell * getCaloCell()
double cellDepth(const QPair< bool, double > &scale, const double &energy)
virtual ~VP1CaloCell()
bool cutPassed(const VP1CC_GlobalCuts &globalCuts)
Identifier getID()
virtual void build3DObjects(VP1CC_SoNode2CCMap *node2cc, bool useEt, const QPair< bool, double > &scale, bool outline, const VP1CC_GlobalCuts &)=0
bool contains(const double &x) const
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
std::vector< std::string > ToString()
SoSeparator * m_separator
bool m_run2Geo
const TileCell * m_cell
bool UpdateScene(VP1CC_MbtsScinInfoMap *drawinfo, VP1CC_SoNode2MbtsMap *node2mbts, double energy, bool outline, double clipRadius)
const TileTBID * m_idhelper
VP1Mbts(const TileCell *cell, const TileTBID *idhelper, SoSeparator *separator, bool run2Geo)
std::string depth
tag string for intendation
Definition fastadd.cxx:46
VP1CC_MbtsXfMap cTransforms
VP1CC_MbtsXfMap aTransforms
MsgStream & msg
Definition testRead.cxx:32