CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalTestAnalysis Class Reference
Inheritance diagram for HcalTestAnalysis:
SimProducer Observer< const BeginOfRun *> Observer< const BeginOfEvent *> Observer< const EndOfEvent *> Observer< const G4Step *> SimWatcher

Public Member Functions

void beginRun (edm::EventSetup const &) override
 
 HcalTestAnalysis (const edm::ParameterSet &p)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void registerConsumes (edm::ConsumesCollector) override
 
 ~HcalTestAnalysis () override
 
- Public Member Functions inherited from SimProducer
const SimProduceroperator= (const SimProducer &)=delete
 
void registerProducts (edm::ProducesCollector producesCollector)
 
 SimProducer ()
 
 SimProducer (const SimProducer &)=delete
 
- Public Member Functions inherited from SimWatcher
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfRun *>
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent *>
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent *>
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step *>
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 

Private Member Functions

void fill (const EndOfEvent *ev)
 
void layerAnalysis ()
 
std::vector< int > layerGrouping (int)
 
void qieAnalysis (CLHEP::HepRandomEngine *)
 
double timeOfFlight (int det, int layer, double eta)
 
std::vector< int > towersToAdd (int centre, int nadd)
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

int addTower_
 
std::vector< CaloHitcaloHitCache_
 
const int centralTower_
 
unsigned int count_
 
edm::ESGetToken< HcalDDDSimConstants, HcalSimNumberingRecordddconsToken_
 
double edepEB_
 
double edepEE_
 
double edepHB_
 
double edepHE_
 
double edepHO_
 
double edepl_ [20]
 
double eta0_
 
const std::string fileName_
 
std::vector< int > group_
 
const HcalDDDSimConstantshcons_
 
const int laygroup_
 
const edm::ParameterSet m_Anal
 
double mudist_ [20]
 
std::unique_ptr< HcalQiemyqie_
 
const std::vector< std::string > names_
 
int nGroup_
 
int nTower_
 
std::unique_ptr< HcalNumberingFromDDDnumberingFromDDD_
 
std::unique_ptr< HcalTestNumberingSchemeorg_
 
double phi0_
 
std::vector< int > tower_
 
std::unique_ptr< HcalTestHistoClasstuples_
 

Additional Inherited Members

- Protected Member Functions inherited from SimProducer
template<class T >
void produces ()
 
template<class T >
void produces (const std::string &instanceName)
 
- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 49 of file HcalTestAnalysis.cc.

Constructor & Destructor Documentation

◆ HcalTestAnalysis()

HcalTestAnalysis::HcalTestAnalysis ( const edm::ParameterSet p)

Definition at line 111 of file HcalTestAnalysis.cc.

References addTower_, centralTower_, count_, group_, mps_fire::i, layerGrouping(), laygroup_, myqie_, nGroup_, nTower_, numberingFromDDD_, org_, AlCaHLTBitMon_ParallelJobs::p, tower_, towersToAdd(), and tuples_.

112  : addTower_(3),
113  m_Anal(p.getParameter<edm::ParameterSet>("HcalTestAnalysis")),
114  eta0_(m_Anal.getParameter<double>("Eta0")),
115  phi0_(m_Anal.getParameter<double>("Phi0")),
116  laygroup_(m_Anal.getParameter<int>("LayerGrouping")),
117  centralTower_(m_Anal.getParameter<int>("CentralTower")),
118  names_(m_Anal.getParameter<std::vector<std::string> >("Names")),
120  hcons_(nullptr) {
121  org_.reset(nullptr);
122 
123  tuples_.reset(nullptr);
124  numberingFromDDD_.reset(nullptr);
125  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Initialised as observer of begin/end events"
126  << " and of G4step";
127 
128  count_ = 0;
130  nGroup_ = 0;
131  for (unsigned int i = 0; i < group_.size(); i++)
132  if (group_[i] > nGroup_)
133  nGroup_ = group_[i];
135  nTower_ = tower_.size() / 2;
136 
137  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: initialised for " << nGroup_ << " Longitudinal groups and "
138  << nTower_ << " towers";
139 
140  // qie
141  myqie_ = std::make_unique<HcalQie>(p);
142 
143  produces<HcalTestHistoClass>();
144 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const std::vector< std::string > names_
std::unique_ptr< HcalTestHistoClass > tuples_
std::vector< int > layerGrouping(int)
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD_
const edm::ParameterSet m_Anal
std::vector< int > towersToAdd(int centre, int nadd)
const std::string fileName_
std::vector< int > tower_
const HcalDDDSimConstants * hcons_
std::unique_ptr< HcalQie > myqie_
std::unique_ptr< HcalTestNumberingScheme > org_
std::vector< int > group_

◆ ~HcalTestAnalysis()

HcalTestAnalysis::~HcalTestAnalysis ( )
override

Definition at line 146 of file HcalTestAnalysis.cc.

References count_, and org_.

146  {
147  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: --------> Total number of selected entries : " << count_;
148  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Pointers:: Numbering Scheme " << org_.get();
149 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HcalTestNumberingScheme > org_

Member Function Documentation

◆ beginRun()

void HcalTestAnalysis::beginRun ( edm::EventSetup const &  es)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 231 of file HcalTestAnalysis.cc.

References ddconsToken_, edm::EventSetup::getData(), hcons_, names_, numberingFromDDD_, and org_.

231  {
232  // Numbering From DDD
233  hcons_ = &es.getData(ddconsToken_);
234  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Initialise HcalNumberingFromDDD for " << names_[0];
235  numberingFromDDD_ = std::make_unique<HcalNumberingFromDDD>(hcons_);
236 
237  // Numbering scheme
238  org_ = std::make_unique<HcalTestNumberingScheme>(false);
239 }
Log< level::Info, true > LogVerbatim
const std::vector< std::string > names_
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD_
const HcalDDDSimConstants * hcons_
std::unique_ptr< HcalTestNumberingScheme > org_
edm::ESGetToken< HcalDDDSimConstants, HcalSimNumberingRecord > ddconsToken_

◆ fill()

void HcalTestAnalysis::fill ( const EndOfEvent ev)
private

Definition at line 398 of file HcalTestAnalysis.cc.

References caloHitCache_, MillePedeFileConverter_cfg::e, PVValHelper::eta, CaloG4Hit::getEnergyDeposit(), CaloG4Hit::getPosition(), CaloG4Hit::getTimeSlice(), CaloG4Hit::getUnitID(), HcalEndcap, HcalForward, hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, dqmiolumiharvest::j, nano_mu_digi_cff::layer, dqm-mbProfile::log, names_, numberingFromDDD_, org_, phi, AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), theta(), hcalRecHitTable_cff::time, timeOfFlight(), and ecaldqm::zside().

Referenced by update().

398  {
399  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Fill event " << (*evt)()->GetEventID();
400 
401  // access to the G4 hit collections
402  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
403 
404  int nhc = 0, neb = 0, nef = 0, j = 0;
405  caloHitCache_.erase(caloHitCache_.begin(), caloHitCache_.end());
406 
407  // Hcal
408  int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names_[0]);
409  CaloG4HitCollection* theHCHC = (CaloG4HitCollection*)allHC->GetHC(HCHCid);
410  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[0] << " of ID " << HCHCid
411  << " is obtained at " << theHCHC;
412  int hchc_entries = theHCHC->entries();
413  if (HCHCid >= 0 && theHCHC != nullptr) {
414  for (j = 0; j < hchc_entries; j++) {
415  CaloG4Hit* aHit = (*theHCHC)[j];
416 
417  double e = aHit->getEnergyDeposit() / GeV;
418  double time = aHit->getTimeSlice();
419 
420  math::XYZPoint pos = aHit->getPosition();
421  double theta = pos.theta();
422  double eta = -log(tan(theta * 0.5));
423  double phi = pos.phi();
424 
425  uint32_t unitID = aHit->getUnitID();
426  int subdet, zside, layer, etaIndex, phiIndex, lay;
427  org_->unpackHcalIndex(unitID, subdet, zside, layer, etaIndex, phiIndex, lay);
428  double jitter = time - timeOfFlight(subdet, lay, eta);
429  if (jitter < 0)
430  jitter = 0;
431  CaloHit hit(subdet, lay, e, eta, phi, jitter, unitID);
432  caloHitCache_.push_back(hit);
433  nhc++;
434 
435  std::string det = "HB";
436  if (subdet == static_cast<int>(HcalForward)) {
437  det = "HF";
438  } else if (subdet == static_cast<int>(HcalEndcap)) {
439  if (etaIndex <= 20) {
440  det = "HES";
441  } else {
442  det = "HED";
443  }
444  }
445 
446  edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2) << layer << " time "
447  << std::setw(6) << time << " theta " << std::setw(8) << theta << " eta "
448  << std::setw(8) << eta << " phi " << std::setw(8) << phi << " e " << std::setw(8)
449  << e;
450  }
451  }
452  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::HCAL hits : " << nhc;
453 
454  // EB
455  int EBHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names_[1]);
456  CaloG4HitCollection* theEBHC = (CaloG4HitCollection*)allHC->GetHC(EBHCid);
457  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[1] << " of ID " << EBHCid
458  << " is obtained at " << theEBHC;
459  int ebhc_entries = theEBHC->entries();
460  if (EBHCid >= 0 && theEBHC != nullptr) {
461  for (j = 0; j < ebhc_entries; j++) {
462  CaloG4Hit* aHit = (*theEBHC)[j];
463 
464  double e = aHit->getEnergyDeposit() / GeV;
465  double time = aHit->getTimeSlice();
466  std::string det = "EB";
467 
468  math::XYZPoint pos = aHit->getPosition();
469  double theta = pos.theta();
470  double eta = -log(tan(theta / 2.));
471  double phi = pos.phi();
472 
474  uint32_t unitID = org_->getUnitID(id);
475  int subdet, zside, layer, ieta, iphi, lay;
476  org_->unpackHcalIndex(unitID, subdet, zside, layer, ieta, iphi, lay);
477  subdet = 10;
478  layer = 0;
479  unitID = org_->packHcalIndex(subdet, zside, layer, ieta, iphi, lay);
480  CaloHit hit(subdet, lay, e, eta, phi, time, unitID);
481  caloHitCache_.push_back(hit);
482  neb++;
483  edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2) << layer << " time "
484  << std::setw(6) << time << " theta " << std::setw(8) << theta << " eta "
485  << std::setw(8) << eta << " phi " << std::setw(8) << phi << " e " << std::setw(8)
486  << e;
487  }
488  }
489  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::EB hits : " << neb;
490 
491  // EE
492  int EEHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names_[2]);
493  CaloG4HitCollection* theEEHC = (CaloG4HitCollection*)allHC->GetHC(EEHCid);
494  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[2] << " of ID " << EEHCid
495  << " is obtained at " << theEEHC;
496  int eehc_entries = theEEHC->entries();
497  if (EEHCid >= 0 && theEEHC != nullptr) {
498  for (j = 0; j < eehc_entries; j++) {
499  CaloG4Hit* aHit = (*theEEHC)[j];
500 
501  double e = aHit->getEnergyDeposit() / GeV;
502  double time = aHit->getTimeSlice();
503  std::string det = "EE";
504 
505  math::XYZPoint pos = aHit->getPosition();
506  double theta = pos.theta();
507  double eta = -log(tan(theta / 2.));
508  double phi = pos.phi();
509 
511  uint32_t unitID = org_->getUnitID(id);
512  int subdet, zside, layer, ieta, iphi, lay;
513  org_->unpackHcalIndex(unitID, subdet, zside, layer, ieta, iphi, lay);
514  subdet = 11;
515  layer = 0;
516  unitID = org_->packHcalIndex(subdet, zside, layer, ieta, iphi, lay);
517  CaloHit hit(subdet, lay, e, eta, phi, time, unitID);
518  caloHitCache_.push_back(hit);
519  nef++;
520  edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2) << layer << " time "
521  << std::setw(6) << time << " theta " << std::setw(8) << theta << " eta "
522  << std::setw(8) << eta << " phi " << std::setw(8) << phi << " e " << std::setw(8)
523  << e;
524  }
525  }
526  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::EE hits : " << nef;
527 }
Log< level::Info, true > LogVerbatim
const std::vector< std::string > names_
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD_
int zside(DetId const &)
double timeOfFlight(int det, int layer, double eta)
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:52
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::unique_ptr< HcalTestNumberingScheme > org_
double getEnergyDeposit() const
Definition: CaloG4Hit.h:79
uint32_t getUnitID() const
Definition: CaloG4Hit.h:66
std::vector< CaloHit > caloHitCache_
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
double getTimeSlice() const
Definition: CaloG4Hit.h:67
Geom::Theta< T > theta() const

◆ layerAnalysis()

void HcalTestAnalysis::layerAnalysis ( )
private

Definition at line 652 of file HcalTestAnalysis.cc.

References edepEB_, edepEE_, edepHB_, edepHE_, edepHO_, edepl_, mps_fire::i, mudist_, and tuples_.

Referenced by update().

652  {
653  int i = 0;
654  edm::LogVerbatim("HcalSim") << "\n ===>>> HcalTestAnalysis: Energy deposit "
655  << "\n at EB : " << std::setw(6) << edepEB_ / MeV << "\n at EE : " << std::setw(6)
656  << edepEE_ / MeV << "\n at HB : " << std::setw(6) << edepHB_ / MeV
657  << "\n at HE : " << std::setw(6) << edepHE_ / MeV << "\n at HO : " << std::setw(6)
658  << edepHO_ / MeV << "\n ---- HcalTestAnalysis: Energy deposit in Layers";
659  for (i = 0; i < 20; i++)
660  edm::LogVerbatim("HcalSim") << " Layer " << std::setw(2) << i << " E " << std::setw(8) << edepl_[i] / MeV << " MeV";
661 
662  tuples_->fillLayers(edepl_, edepHO_, edepHB_ + edepHE_, mudist_);
663 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HcalTestHistoClass > tuples_

◆ layerGrouping()

std::vector< int > HcalTestAnalysis::layerGrouping ( int  group)
private

Definition at line 161 of file HcalTestAnalysis.cc.

References watchdog::group, mps_fire::i, and groupFilesInBlocks::temp.

Referenced by HcalTestAnalysis().

161  {
162  std::vector<int> temp(19);
163  if (group <= 1) {
164  int grp[19] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};
165  for (int i = 0; i < 19; i++)
166  temp[i] = grp[i];
167  } else if (group == 2) {
168  int grp[19] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
169  for (int i = 0; i < 19; i++)
170  temp[i] = grp[i];
171  } else if (group == 3) {
172  int grp[19] = {1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7};
173  for (int i = 0; i < 19; i++)
174  temp[i] = grp[i];
175  } else if (group == 4) {
176  int grp[19] = {1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7};
177  for (int i = 0; i < 19; i++)
178  temp[i] = grp[i];
179  } else {
180  int grp[19] = {1, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7};
181  for (int i = 0; i < 19; i++)
182  temp[i] = grp[i];
183  }
184 
185  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Layer Grouping ";
186  for (int i = 0; i < 19; i++)
187  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Group[" << i << "] = " << temp[i];
188  return temp;
189 }
Log< level::Info, true > LogVerbatim

◆ produce()

void HcalTestAnalysis::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 156 of file HcalTestAnalysis.cc.

References MillePedeFileConverter_cfg::e, eostools::move(), and tuples_.

156  {
157  e.put(std::move(tuples_));
158  tuples_.reset(nullptr);
159 }
std::unique_ptr< HcalTestHistoClass > tuples_
def move(src, dest)
Definition: eostools.py:511

◆ qieAnalysis()

void HcalTestAnalysis::qieAnalysis ( CLHEP::HepRandomEngine *  engine)
private

Definition at line 530 of file HcalTestAnalysis.cc.

References addTower_, caloHitCache_, hippyaddtobaddatafiles::cd(), centralTower_, eta0_, watchdog::group, group_, HcalBarrel, HcalEndcap, hfClusterShapes_cfi::hits, mps_fire::i, hit::id, heavyIonCSV_trainingSettings::idx, hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, nano_mu_digi_cff::layer, myqie_, nGroup_, nt, nTower_, numberingFromDDD_, org_, phi0_, AlCaHLTBitMon_QueryRunRegistry::string, tower_, tuples_, and ecaldqm::zside().

Referenced by update().

530  {
531  //Fill tuple with hit information
532  int hittot = caloHitCache_.size();
533  tuples_->fillHits(caloHitCache_);
534 
535  //Get the index of the central tower
537  uint32_t unitID = org_->getUnitID(id);
538  int subdet, zside, layer, ieta, iphi, lay;
539  org_->unpackHcalIndex(unitID, subdet, zside, layer, ieta, iphi, lay);
540  int laymax = 0;
541  std::string det = "Unknown";
542  if (subdet == static_cast<int>(HcalBarrel)) {
543  laymax = 4;
544  det = "HB";
545  } else if (subdet == static_cast<int>(HcalEndcap)) {
546  laymax = 2;
547  det = "HES";
548  }
549  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Qie: " << det << " Eta " << ieta << " Phi " << iphi << " Laymax "
550  << laymax << " Hits " << hittot;
551 
552  if (laymax > 0 && hittot > 0) {
553  std::vector<CaloHit> hits(hittot);
554  std::vector<double> eqielay(80, 0.0), esimlay(80, 0.0), esimtot(4, 0.0);
555  std::vector<double> eqietow(200, 0.0), esimtow(200, 0.0), eqietot(4, 0.0);
556  int etac = (centralTower_ / 100) % 100;
557  int phic = (centralTower_ % 100);
558 
559  for (int layr = 0; layr < nGroup_; layr++) {
560  /*
561  int layx, layy=20;
562  for (int i=0; i<20; i++)
563  if (group_[i] == layr+1 && i < layy) layy = i+1;
564  if (subdet == static_cast<int>(HcalBarrel)) {
565  if (layy < 2) layx = 0;
566  else if (layy < 17) layx = 1;
567  else if (layy == 17) layx = 2;
568  else layx = 3;
569  } else {
570  if (layy < 2) layx = 0;
571  else layx = 1;
572  }
573  */
574  for (int it = 0; it < nTower_; it++) {
575  int nhit = 0;
576  double esim = 0;
577  for (int k1 = 0; k1 < hittot; k1++) {
578  CaloHit hit = caloHitCache_[k1];
579  int subdetc = hit.det();
580  int layer = hit.layer();
581  int group = 0;
582  if (layer > 0 && layer < 20)
583  group = group_[layer];
584  if (subdetc == subdet && group == layr + 1) {
585  int zsidec, ietac, iphic, idx;
586  unitID = hit.id();
587  org_->unpackHcalIndex(unitID, subdetc, zsidec, layer, ietac, iphic, lay);
588  if (etac > 0 && phic > 0) {
589  idx = ietac * 100 + iphic;
590  } else if (etac > 0) {
591  idx = ietac * 100;
592  } else if (phic > 0) {
593  idx = iphic;
594  } else {
595  idx = 0;
596  }
597  if (zsidec == zside && idx == tower_[it]) {
598  hits[nhit] = hit;
599  edm::LogVerbatim("HcalSim") << "HcalTest: Hit " << nhit << " " << hit;
600  nhit++;
601  esim += hit.e();
602  }
603  }
604  }
605 
606  std::vector<int> cd = myqie_->getCode(nhit, hits, engine);
607  double eqie = myqie_->getEnergy(cd);
608 
609  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Qie: Energy in layer " << layr << " Sim " << esim
610  << " After QIE " << eqie;
611  for (int i = 0; i < 4; i++) {
612  if (tower_[nTower_ + it] <= i) {
613  esimtot[i] += esim;
614  eqietot[i] += eqie;
615  esimlay[20 * i + layr] += esim;
616  eqielay[20 * i + layr] += eqie;
617  esimtow[50 * i + it] += esim;
618  eqietow[50 * i + it] += eqie;
619  }
620  }
621  }
622  }
623  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Qie: Total energy " << esimtot[3] << " (SimHit) " << eqietot[3]
624  << " (After QIE)";
625 
626  std::vector<double> latphi(10);
627  int nt = 2 * addTower_ + 1;
628  for (int it = 0; it < nt; it++)
629  latphi[it] = it - addTower_;
630  for (int i = 0; i < 4; i++) {
631  double scals = 1, scalq = 1;
632  std::vector<double> latfs(10, 0.), latfq(10, 0.), longs(20), longq(20);
633  if (esimtot[i] > 0)
634  scals = 1. / esimtot[i];
635  if (eqietot[i] > 0)
636  scalq = 1. / eqietot[i];
637  for (int it = 0; it < nTower_; it++) {
638  int phib = it % nt;
639  latfs[phib] += scals * esimtow[50 * i + it];
640  latfq[phib] += scalq * eqietow[50 * i + it];
641  }
642  for (int layr = 0; layr <= nGroup_; layr++) {
643  longs[layr] = scals * esimlay[20 * i + layr];
644  longq[layr] = scalq * eqielay[20 * i + layr];
645  }
646  tuples_->fillQie(i, esimtot[i], eqietot[i], nGroup_, longs, longq, nt, latphi, latfs, latfq);
647  }
648  }
649 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HcalTestHistoClass > tuples_
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD_
int zside(DetId const &)
std::vector< int > tower_
std::unique_ptr< HcalQie > myqie_
int nt
Definition: AMPTWrapper.h:42
unsigned int id
std::unique_ptr< HcalTestNumberingScheme > org_
std::vector< CaloHit > caloHitCache_
std::vector< int > group_

◆ registerConsumes()

void HcalTestAnalysis::registerConsumes ( edm::ConsumesCollector  cc)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 151 of file HcalTestAnalysis.cc.

References edm::BeginRun, gpuPixelDoublets::cc, and ddconsToken_.

151  {
153  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Initialize ESGetToken for HcalDDDSimConstants";
154 }
Log< level::Info, true > LogVerbatim
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< HcalDDDSimConstants, HcalSimNumberingRecord > ddconsToken_

◆ timeOfFlight()

double HcalTestAnalysis::timeOfFlight ( int  det,
int  layer,
double  eta 
)
private

Definition at line 666 of file HcalTestAnalysis.cc.

References funct::cos(), PVValHelper::eta, JetChargeProducer_cfi::exp, HcalBarrel, nano_mu_digi_cff::layer, funct::sin(), theta(), and createJobs::tmp.

Referenced by fill().

666  {
667  double theta = 2.0 * atan(exp(-eta));
668  double dist = 0.;
669  if (det == static_cast<int>(HcalBarrel)) {
670  const double rLay[19] = {1836.0,
671  1902.0,
672  1962.0,
673  2022.0,
674  2082.0,
675  2142.0,
676  2202.0,
677  2262.0,
678  2322.0,
679  2382.0,
680  2448.0,
681  2514.0,
682  2580.0,
683  2646.0,
684  2712.0,
685  2776.0,
686  2862.5,
687  3847.0,
688  4052.0};
689  if (layer > 0 && layer < 20)
690  dist += rLay[layer - 1] * mm / sin(theta);
691  } else {
692  const double zLay[19] = {4034.0,
693  4032.0,
694  4123.0,
695  4210.0,
696  4297.0,
697  4384.0,
698  4471.0,
699  4558.0,
700  4645.0,
701  4732.0,
702  4819.0,
703  4906.0,
704  4993.0,
705  5080.0,
706  5167.0,
707  5254.0,
708  5341.0,
709  5428.0,
710  5515.0};
711  if (layer > 0 && layer < 20)
712  dist += zLay[layer - 1] * mm / cos(theta);
713  }
714  double tmp = dist / c_light / ns;
715  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::timeOfFlight " << tmp << " for det/lay " << det << " " << layer
716  << " eta/theta " << eta << " " << theta / deg << " dist " << dist;
717  return tmp;
718 }
Log< level::Info, true > LogVerbatim
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tmp
align.sh
Definition: createJobs.py:716
Geom::Theta< T > theta() const

◆ towersToAdd()

std::vector< int > HcalTestAnalysis::towersToAdd ( int  centre,
int  nadd 
)
private

Definition at line 191 of file HcalTestAnalysis.cc.

References funct::abs(), PVValHelper::eta, TrackingDataMCValidation_Standalone_cff::etamax, TrackingDataMCValidation_Standalone_cff::etamin, mps_fire::i, SiStripPI::max, phi, phimax, phimin, and groupFilesInBlocks::temp.

Referenced by HcalTestAnalysis().

191  {
192  int etac = (centre / 100) % 100;
193  int phic = (centre % 100);
194  int etamin, etamax, phimin, phimax;
195  if (etac > 0) {
196  etamin = etac - nadd;
197  etamax = etac + nadd;
198  } else {
199  etamin = etac;
200  etamax = etac;
201  }
202  if (phic > 0) {
203  phimin = phic - nadd;
204  phimax = phic + nadd;
205  } else {
206  phimin = phic;
207  phimax = phic;
208  }
209 
210  int nbuf, kount = 0;
211  nbuf = (etamax - etamin + 1) * (phimax - phimin + 1);
212  std::vector<int> temp(2 * nbuf);
213  for (int eta = etamin; eta <= etamax; eta++) {
214  for (int phi = phimin; phi <= phimax; phi++) {
215  temp[kount] = (eta * 100 + phi);
216  temp[kount + nbuf] = std::max(abs(eta - etac), abs(phi - phic));
217  kount++;
218  }
219  }
220 
221  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Towers to be considered for Central " << centre << " and " << nadd
222  << " on either side";
223  for (int i = 0; i < nbuf; i++)
224  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Tower[" << std::setw(3) << i << "] " << temp[i] << " "
225  << temp[nbuf + i];
226  return temp;
227 }
Log< level::Info, true > LogVerbatim
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ update() [1/4]

void HcalTestAnalysis::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 242 of file HcalTestAnalysis.cc.

References HcalDDDSimConstants::cell(), centralTower_, PVValHelper::eta, eta0_, HcalBarrel, HcalEndcap, HcalForward, hcons_, heppy_loop::loop, names_, org_, phi, phi0_, HCalSD::setNumberingScheme(), AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

242  {
243  int irun = (*run)()->GetRunID();
244  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Begin of Run = " << irun;
245 
246  bool loop = true, eta = true, phi = true;
247  int etac = (centralTower_ / 100) % 100;
248  if (etac == 0) {
249  etac = 1;
250  eta = false;
251  }
252  int phic = (centralTower_ % 100);
253  if (phic == 0) {
254  phic = 1;
255  phi = false;
256  }
257  int idet = static_cast<int>(HcalBarrel);
258  while (loop) {
259  HcalCellType::HcalCell tmp = hcons_->cell(idet, 1, 1, etac, phic);
260  if (tmp.ok) {
261  if (eta)
262  eta0_ = tmp.eta;
263  if (phi)
264  phi0_ = tmp.phi;
265  loop = false;
266  } else if (idet == static_cast<int>(HcalBarrel)) {
267  idet = static_cast<int>(HcalEndcap);
268  } else if (idet == static_cast<int>(HcalEndcap)) {
269  idet = static_cast<int>(HcalForward);
270  } else {
271  loop = false;
272  }
273  }
274 
275  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Central Tower " << centralTower_
276  << " corresponds to eta0 = " << eta0_ << " phi0 = " << phi0_;
277 
278  std::string sdname = names_[0];
279  G4SDManager* sd = G4SDManager::GetSDMpointerIfExist();
280  if (sd != nullptr) {
281  G4VSensitiveDetector* aSD = sd->FindSensitiveDetector(sdname);
282  if (aSD == nullptr) {
283  edm::LogWarning("HcalSim") << "HcalTestAnalysis::beginOfRun: No SD with "
284  << "name " << sdname << " in this Setup";
285  } else {
286  HCalSD* theCaloSD = dynamic_cast<HCalSD*>(aSD);
287  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::beginOfRun: Finds SD with name " << theCaloSD->GetName()
288  << " in this Setup";
289  if (org_.get()) {
290  theCaloSD->setNumberingScheme(org_.get());
291  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::beginOfRun: set a new numbering scheme";
292  }
293  }
294  } else {
295  edm::LogWarning("HcalSim") << "HcalTestAnalysis::beginOfRun: Could not get"
296  << " SD Manager!";
297  }
298 }
HcalCellType::HcalCell cell(const int &det, const int &zside, const int &depth, const int &etaR, const int &iphi) const
Log< level::Info, true > LogVerbatim
const std::vector< std::string > names_
void setNumberingScheme(HcalNumberingScheme *)
Definition: HCalSD.cc:564
Definition: HCalSD.h:38
const HcalDDDSimConstants * hcons_
std::unique_ptr< HcalTestNumberingScheme > org_
Log< level::Warning, false > LogWarning
tmp
align.sh
Definition: createJobs.py:716

◆ update() [2/4]

void HcalTestAnalysis::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 301 of file HcalTestAnalysis.cc.

References edepEB_, edepEE_, edepHB_, edepHE_, edepHO_, edepl_, mps_fire::i, mudist_, and tuples_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

301  {
302  // create tuple object
303  tuples_ = std::make_unique<HcalTestHistoClass>();
304  // Reset counters
305  tuples_->setCounters();
306 
307  int i = 0;
308  edepEB_ = edepEE_ = edepHB_ = edepHE_ = edepHO_ = 0.;
309  for (i = 0; i < 20; i++)
310  edepl_[i] = 0.;
311  for (i = 0; i < 20; i++)
312  mudist_[i] = -1.;
313 
314  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Begin of event = " << (*evt)()->GetEventID();
315 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HcalTestHistoClass > tuples_

◆ update() [3/4]

void HcalTestAnalysis::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent *>.

Definition at line 381 of file HcalTestAnalysis.cc.

References count_, fill(), layerAnalysis(), and qieAnalysis().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

381  {
382  ++count_;
383  // Fill event input
384  fill(evt);
385  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after Fill";
386 
387  // Qie analysis
388  CLHEP::HepRandomEngine* engine = G4Random::getTheEngine();
389  qieAnalysis(engine);
390  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after QieAnalysis";
391 
392  // Layers tuples filling
393  layerAnalysis();
394  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after LayerAnalysis";
395 }
Log< level::Info, true > LogVerbatim
void fill(const EndOfEvent *ev)
void qieAnalysis(CLHEP::HepRandomEngine *)

◆ update() [4/4]

void HcalTestAnalysis::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step *>.

Definition at line 318 of file HcalTestAnalysis.cc.

References edepEB_, edepEE_, edepHB_, edepHE_, edepHO_, edepl_, PVValHelper::eta, eta0_, nano_mu_digi_cff::layer, dqm-mbProfile::log, mudist_, Skims_PA_cff::name, phi, phi0_, mathSSE::sqrt(), funct::tan(), and theta().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

318  {
319  if (aStep != nullptr) {
320  G4VPhysicalVolume* curPV = aStep->GetPreStepPoint()->GetPhysicalVolume();
321  G4String name = curPV->GetName();
322  name.assign(name, 0, 3);
323  double edeposit = aStep->GetTotalEnergyDeposit();
324  int layer = -1;
325  if (name == "EBR") {
326  edepEB_ += edeposit;
327  } else if (name == "EFR") {
328  edepEE_ += edeposit;
329  } else if (name == "HBS") {
330  layer = (curPV->GetCopyNo() / 10) % 100;
331  if (layer >= 0 && layer < 17) {
332  edepHB_ += edeposit;
333  } else {
334  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HB " << curPV->GetName() << curPV->GetCopyNo();
335  layer = -1;
336  }
337  } else if (name == "HES") {
338  layer = (curPV->GetCopyNo() / 10) % 100;
339  if (layer >= 0 && layer < 19) {
340  edepHE_ += edeposit;
341  } else {
342  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HE " << curPV->GetName() << curPV->GetCopyNo();
343  layer = -1;
344  }
345  } else if (name == "HTS") {
346  layer = (curPV->GetCopyNo() / 10) % 100;
347  if (layer >= 17 && layer < 20) {
348  edepHO_ += edeposit;
349  } else {
350  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HO " << curPV->GetName() << curPV->GetCopyNo();
351  layer = -1;
352  }
353  }
354  if (layer >= 0 && layer < 20) {
355  edepl_[layer] += edeposit;
356 
357  // Calculate the distance if it is a muon
358  G4String part = aStep->GetTrack()->GetDefinition()->GetParticleName();
359  if ((part == "mu-" || part == "mu+") && mudist_[layer] < 0) {
360  math::XYZPoint pos(aStep->GetPreStepPoint()->GetPosition().x(),
361  aStep->GetPreStepPoint()->GetPosition().y(),
362  aStep->GetPreStepPoint()->GetPosition().z());
363  double theta = pos.theta();
364  double eta = -log(tan(theta * 0.5));
365  double phi = pos.phi();
366  double dist = sqrt((eta - eta0_) * (eta - eta0_) + (phi - phi0_) * (phi - phi0_));
367  mudist_[layer] = dist * std::sqrt(pos.perp2());
368  }
369  }
370 
371  if (layer >= 0 && layer < 20) {
372  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: G4Step: " << name << " Layer " << std::setw(3) << layer
373  << " Edep " << std::setw(6) << edeposit / MeV << " MeV";
374  }
375  } else {
376  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: G4Step: Null Step";
377  }
378 }
Log< level::Info, true > LogVerbatim
T sqrt(T t)
Definition: SSEVec.h:23
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
part
Definition: HCALResponse.h:20
Log< level::Warning, false > LogWarning
Geom::Theta< T > theta() const

Member Data Documentation

◆ addTower_

int HcalTestAnalysis::addTower_
private

Definition at line 80 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

◆ caloHitCache_

std::vector<CaloHit> HcalTestAnalysis::caloHitCache_
private

Definition at line 100 of file HcalTestAnalysis.cc.

Referenced by fill(), and qieAnalysis().

◆ centralTower_

const int HcalTestAnalysis::centralTower_
private

Definition at line 88 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), qieAnalysis(), and update().

◆ count_

unsigned int HcalTestAnalysis::count_
private

Definition at line 105 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), update(), and ~HcalTestAnalysis().

◆ ddconsToken_

edm::ESGetToken<HcalDDDSimConstants, HcalSimNumberingRecord> HcalTestAnalysis::ddconsToken_
private

Definition at line 94 of file HcalTestAnalysis.cc.

Referenced by beginRun(), and registerConsumes().

◆ edepEB_

double HcalTestAnalysis::edepEB_
private

Definition at line 106 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

◆ edepEE_

double HcalTestAnalysis::edepEE_
private

Definition at line 106 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

◆ edepHB_

double HcalTestAnalysis::edepHB_
private

Definition at line 106 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

◆ edepHE_

double HcalTestAnalysis::edepHE_
private

Definition at line 106 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

◆ edepHO_

double HcalTestAnalysis::edepHO_
private

Definition at line 107 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

◆ edepl_

double HcalTestAnalysis::edepl_[20]
private

Definition at line 107 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

◆ eta0_

double HcalTestAnalysis::eta0_
private

Definition at line 87 of file HcalTestAnalysis.cc.

Referenced by qieAnalysis(), and update().

◆ fileName_

const std::string HcalTestAnalysis::fileName_
private

Definition at line 91 of file HcalTestAnalysis.cc.

◆ group_

std::vector<int> HcalTestAnalysis::group_
private

Definition at line 101 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

◆ hcons_

const HcalDDDSimConstants* HcalTestAnalysis::hcons_
private

Definition at line 96 of file HcalTestAnalysis.cc.

Referenced by beginRun(), and update().

◆ laygroup_

const int HcalTestAnalysis::laygroup_
private

Definition at line 88 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis().

◆ m_Anal

const edm::ParameterSet HcalTestAnalysis::m_Anal
private

Definition at line 86 of file HcalTestAnalysis.cc.

◆ mudist_

double HcalTestAnalysis::mudist_[20]
private

Definition at line 108 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

◆ myqie_

std::unique_ptr<HcalQie> HcalTestAnalysis::myqie_
private

Definition at line 79 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

◆ names_

const std::vector<std::string> HcalTestAnalysis::names_
private

Definition at line 89 of file HcalTestAnalysis.cc.

Referenced by beginRun(), fill(), and update().

◆ nGroup_

int HcalTestAnalysis::nGroup_
private

Definition at line 102 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

◆ nTower_

int HcalTestAnalysis::nTower_
private

Definition at line 102 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

◆ numberingFromDDD_

std::unique_ptr<HcalNumberingFromDDD> HcalTestAnalysis::numberingFromDDD_
private

Definition at line 95 of file HcalTestAnalysis.cc.

Referenced by beginRun(), fill(), HcalTestAnalysis(), and qieAnalysis().

◆ org_

std::unique_ptr<HcalTestNumberingScheme> HcalTestAnalysis::org_
private

◆ phi0_

double HcalTestAnalysis::phi0_
private

Definition at line 87 of file HcalTestAnalysis.cc.

Referenced by qieAnalysis(), and update().

◆ tower_

std::vector<int> HcalTestAnalysis::tower_
private

Definition at line 101 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

◆ tuples_

std::unique_ptr<HcalTestHistoClass> HcalTestAnalysis::tuples_
private

Definition at line 83 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), layerAnalysis(), produce(), qieAnalysis(), and update().