CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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_
 
int centralTower_
 
unsigned int count_
 
edm::ESGetToken
< HcalDDDSimConstants,
HcalSimNumberingRecord
ddconsToken_
 
double edepEB_
 
double edepEE_
 
double edepHB_
 
double edepHE_
 
double edepHO_
 
double edepl_ [20]
 
double eta0_
 
std::string fileName_
 
std::vector< int > group_
 
const HcalDDDSimConstantshcons_
 
double mudist_ [20]
 
std::unique_ptr< HcalQiemyqie_
 
std::vector< std::string > names_
 
int nGroup_
 
int nTower_
 
std::unique_ptr
< HcalNumberingFromDDD
numberingFromDDD_
 
std::unique_ptr
< HcalTestNumberingScheme
org_
 
double phi0_
 
std::vector< int > tower_
 
std::unique_ptr
< HcalTestHistoClass
tuples_
 

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 42 of file HcalTestAnalysis.cc.

Constructor & Destructor Documentation

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

Definition at line 104 of file HcalTestAnalysis.cc.

References addTower_, centralTower_, count_, eta0_, fileName_, edm::ParameterSet::getParameter(), group_, mps_fire::i, layerGrouping(), myqie_, names_, nGroup_, nTower_, numberingFromDDD_, org_, AlCaHLTBitMon_ParallelJobs::p, phi0_, AlCaHLTBitMon_QueryRunRegistry::string, tower_, towersToAdd(), and tuples_.

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

Definition at line 137 of file HcalTestAnalysis.cc.

References count_, and org_.

137  {
138  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: --------> Total number of selected entries : " << count_;
139  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Pointers:: Numbering Scheme " << org_.get();
140 }
Log< level::Info, true > LogVerbatim
unsigned int count_
std::unique_ptr< HcalTestNumberingScheme > org_

Member Function Documentation

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

Reimplemented from SimWatcher.

Definition at line 222 of file HcalTestAnalysis.cc.

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

222  {
223  // Numbering From DDD
224  hcons_ = &es.getData(ddconsToken_);
225  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Initialise HcalNumberingFromDDD for " << names_[0];
226  numberingFromDDD_ = std::make_unique<HcalNumberingFromDDD>(hcons_);
227 
228  // Numbering scheme
229  org_ = std::make_unique<HcalTestNumberingScheme>(false);
230 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD_
std::vector< std::string > names_
const HcalDDDSimConstants * hcons_
std::unique_ptr< HcalTestNumberingScheme > org_
edm::ESGetToken< HcalDDDSimConstants, HcalSimNumberingRecord > ddconsToken_
void HcalTestAnalysis::fill ( const EndOfEvent ev)
private

Definition at line 389 of file HcalTestAnalysis.cc.

References caloHitCache_, alignCSCRings::e, PVValHelper::eta, CaloG4Hit::getEnergyDeposit(), CaloG4Hit::getPosition(), CaloG4Hit::getTimeSlice(), CaloG4Hit::getUnitID(), GeV, HcalEndcap, HcalForward, dqmiolumiharvest::j, phase1PixelTopology::layer, log, names_, numberingFromDDD_, org_, phi, AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), theta(), timeOfFlight(), and ecaldqm::zside().

Referenced by update().

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

Definition at line 643 of file HcalTestAnalysis.cc.

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

Referenced by update().

643  {
644  int i = 0;
645  edm::LogVerbatim("HcalSim") << "\n ===>>> HcalTestAnalysis: Energy deposit "
646  << "\n at EB : " << std::setw(6) << edepEB_ / MeV << "\n at EE : " << std::setw(6)
647  << edepEE_ / MeV << "\n at HB : " << std::setw(6) << edepHB_ / MeV
648  << "\n at HE : " << std::setw(6) << edepHE_ / MeV << "\n at HO : " << std::setw(6)
649  << edepHO_ / MeV << "\n ---- HcalTestAnalysis: Energy deposit in Layers";
650  for (i = 0; i < 20; i++)
651  edm::LogVerbatim("HcalSim") << " Layer " << std::setw(2) << i << " E " << std::setw(8) << edepl_[i] / MeV << " MeV";
652 
653  tuples_->fillLayers(edepl_, edepHO_, edepHB_ + edepHE_, mudist_);
654 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HcalTestHistoClass > tuples_
const double MeV
std::vector< int > HcalTestAnalysis::layerGrouping ( int  group)
private

Definition at line 152 of file HcalTestAnalysis.cc.

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

Referenced by HcalTestAnalysis().

152  {
153  std::vector<int> temp(19);
154  if (group <= 1) {
155  int grp[19] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};
156  for (int i = 0; i < 19; i++)
157  temp[i] = grp[i];
158  } else if (group == 2) {
159  int grp[19] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
160  for (int i = 0; i < 19; i++)
161  temp[i] = grp[i];
162  } else if (group == 3) {
163  int grp[19] = {1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7};
164  for (int i = 0; i < 19; i++)
165  temp[i] = grp[i];
166  } else if (group == 4) {
167  int grp[19] = {1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7};
168  for (int i = 0; i < 19; i++)
169  temp[i] = grp[i];
170  } else {
171  int grp[19] = {1, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7};
172  for (int i = 0; i < 19; i++)
173  temp[i] = grp[i];
174  }
175 
176  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Layer Grouping ";
177  for (int i = 0; i < 19; i++)
178  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Group[" << i << "] = " << temp[i];
179  return temp;
180 }
Log< level::Info, true > LogVerbatim
tuple group
Definition: watchdog.py:82
void HcalTestAnalysis::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 147 of file HcalTestAnalysis.cc.

References eostools::move(), edm::Event::put(), and tuples_.

147  {
148  e.put(std::move(tuples_));
149  tuples_.reset(nullptr);
150 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::unique_ptr< HcalTestHistoClass > tuples_
def move
Definition: eostools.py:511
void HcalTestAnalysis::qieAnalysis ( CLHEP::HepRandomEngine *  engine)
private

Definition at line 521 of file HcalTestAnalysis.cc.

References addTower_, caloHitCache_, hippyaddtobaddatafiles::cd(), centralTower_, CaloHit::det(), CaloHit::e(), eta0_, watchdog::group, group_, HcalBarrel, HcalEndcap, mps_fire::i, CaloHit::id(), CaloHit::layer(), phase1PixelTopology::layer, myqie_, nGroup_, nt, nTower_, numberingFromDDD_, org_, phi0_, AlCaHLTBitMon_QueryRunRegistry::string, tower_, tuples_, and ecaldqm::zside().

Referenced by update().

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

Reimplemented from SimWatcher.

Definition at line 142 of file HcalTestAnalysis.cc.

References edm::BeginRun, ddconsToken_, and edm::ConsumesCollector::esConsumes().

142  {
144  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Initialize ESGetToken for HcalDDDSimConstants";
145 }
Log< level::Info, true > LogVerbatim
edm::ESGetToken< HcalDDDSimConstants, HcalSimNumberingRecord > ddconsToken_
double HcalTestAnalysis::timeOfFlight ( int  det,
int  layer,
double  eta 
)
private

Definition at line 657 of file HcalTestAnalysis.cc.

References funct::cos(), funct::exp(), HcalBarrel, funct::sin(), theta(), and createJobs::tmp.

Referenced by fill().

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

Definition at line 182 of file HcalTestAnalysis.cc.

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

Referenced by HcalTestAnalysis().

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 233 of file HcalTestAnalysis.cc.

References HcalDDDSimConstants::cell(), centralTower_, HcalCellType::HcalCell::eta, PVValHelper::eta, eta0_, HcalBarrel, HcalEndcap, HcalForward, hcons_, heppy_loop::loop, names_, HcalCellType::HcalCell::ok, org_, phi, HcalCellType::HcalCell::phi, phi0_, sd, 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().

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 292 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().

292  {
293  // create tuple object
294  tuples_ = std::make_unique<HcalTestHistoClass>();
295  // Reset counters
296  tuples_->setCounters();
297 
298  int i = 0;
299  edepEB_ = edepEE_ = edepHB_ = edepHE_ = edepHO_ = 0.;
300  for (i = 0; i < 20; i++)
301  edepl_[i] = 0.;
302  for (i = 0; i < 20; i++)
303  mudist_[i] = -1.;
304 
305  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Begin of event = " << (*evt)()->GetEventID();
306 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HcalTestHistoClass > tuples_
void HcalTestAnalysis::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 372 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().

372  {
373  ++count_;
374  // Fill event input
375  fill(evt);
376  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after Fill";
377 
378  // Qie analysis
379  CLHEP::HepRandomEngine* engine = G4Random::getTheEngine();
380  qieAnalysis(engine);
381  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after QieAnalysis";
382 
383  // Layers tuples filling
384  layerAnalysis();
385  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after LayerAnalysis";
386 }
Log< level::Info, true > LogVerbatim
void fill(const EndOfEvent *ev)
unsigned int count_
void qieAnalysis(CLHEP::HepRandomEngine *)
void HcalTestAnalysis::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 309 of file HcalTestAnalysis.cc.

References edepEB_, edepEE_, edepHB_, edepHE_, edepHO_, edepl_, PVValHelper::eta, eta0_, phase1PixelTopology::layer, log, MeV, mudist_, mergeVDriftHistosByStation::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().

309  {
310  if (aStep != nullptr) {
311  G4VPhysicalVolume* curPV = aStep->GetPreStepPoint()->GetPhysicalVolume();
312  G4String name = curPV->GetName();
313  name.assign(name, 0, 3);
314  double edeposit = aStep->GetTotalEnergyDeposit();
315  int layer = -1;
316  if (name == "EBR") {
317  edepEB_ += edeposit;
318  } else if (name == "EFR") {
319  edepEE_ += edeposit;
320  } else if (name == "HBS") {
321  layer = (curPV->GetCopyNo() / 10) % 100;
322  if (layer >= 0 && layer < 17) {
323  edepHB_ += edeposit;
324  } else {
325  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HB " << curPV->GetName() << curPV->GetCopyNo();
326  layer = -1;
327  }
328  } else if (name == "HES") {
329  layer = (curPV->GetCopyNo() / 10) % 100;
330  if (layer >= 0 && layer < 19) {
331  edepHE_ += edeposit;
332  } else {
333  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HE " << curPV->GetName() << curPV->GetCopyNo();
334  layer = -1;
335  }
336  } else if (name == "HTS") {
337  layer = (curPV->GetCopyNo() / 10) % 100;
338  if (layer >= 17 && layer < 20) {
339  edepHO_ += edeposit;
340  } else {
341  edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HO " << curPV->GetName() << curPV->GetCopyNo();
342  layer = -1;
343  }
344  }
345  if (layer >= 0 && layer < 20) {
346  edepl_[layer] += edeposit;
347 
348  // Calculate the distance if it is a muon
349  G4String part = aStep->GetTrack()->GetDefinition()->GetParticleName();
350  if ((part == "mu-" || part == "mu+") && mudist_[layer] < 0) {
351  math::XYZPoint pos(aStep->GetPreStepPoint()->GetPosition().x(),
352  aStep->GetPreStepPoint()->GetPosition().y(),
353  aStep->GetPreStepPoint()->GetPosition().z());
354  double theta = pos.theta();
355  double eta = -log(tan(theta * 0.5));
356  double phi = pos.phi();
357  double dist = sqrt((eta - eta0_) * (eta - eta0_) + (phi - phi0_) * (phi - phi0_));
358  mudist_[layer] = dist * std::sqrt(pos.perp2());
359  }
360  }
361 
362  if (layer >= 0 && layer < 20) {
363  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: G4Step: " << name << " Layer " << std::setw(3) << layer
364  << " Edep " << std::setw(6) << edeposit / MeV << " MeV";
365  }
366  } else {
367  edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: G4Step: Null Step";
368  }
369 }
Log< level::Info, true > LogVerbatim
static std::vector< std::string > checklist log
Geom::Theta< T > theta() const
constexpr std::array< uint8_t, layerIndexSize > layer
const double MeV
T sqrt(T t)
Definition: SSEVec.h:19
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

Member Data Documentation

int HcalTestAnalysis::addTower_
private

Definition at line 76 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

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

Definition at line 88 of file HcalTestAnalysis.cc.

Referenced by fill(), and qieAnalysis().

int HcalTestAnalysis::centralTower_
private

Definition at line 95 of file HcalTestAnalysis.cc.

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

unsigned int HcalTestAnalysis::count_
private

Definition at line 98 of file HcalTestAnalysis.cc.

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

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

Definition at line 82 of file HcalTestAnalysis.cc.

Referenced by beginRun(), and registerConsumes().

double HcalTestAnalysis::edepEB_
private

Definition at line 99 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

double HcalTestAnalysis::edepEE_
private

Definition at line 99 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

double HcalTestAnalysis::edepHB_
private

Definition at line 99 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

double HcalTestAnalysis::edepHE_
private

Definition at line 99 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

double HcalTestAnalysis::edepHO_
private

Definition at line 100 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

double HcalTestAnalysis::edepl_[20]
private

Definition at line 100 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

double HcalTestAnalysis::eta0_
private

Definition at line 94 of file HcalTestAnalysis.cc.

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

std::string HcalTestAnalysis::fileName_
private

Definition at line 72 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis().

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

Definition at line 89 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

const HcalDDDSimConstants* HcalTestAnalysis::hcons_
private

Definition at line 84 of file HcalTestAnalysis.cc.

Referenced by beginRun(), and update().

double HcalTestAnalysis::mudist_[20]
private

Definition at line 101 of file HcalTestAnalysis.cc.

Referenced by layerAnalysis(), and update().

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

Definition at line 75 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

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

Definition at line 93 of file HcalTestAnalysis.cc.

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

int HcalTestAnalysis::nGroup_
private

Definition at line 90 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

int HcalTestAnalysis::nTower_
private

Definition at line 90 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

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

Definition at line 83 of file HcalTestAnalysis.cc.

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

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

Definition at line 94 of file HcalTestAnalysis.cc.

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

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

Definition at line 89 of file HcalTestAnalysis.cc.

Referenced by HcalTestAnalysis(), and qieAnalysis().

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

Definition at line 79 of file HcalTestAnalysis.cc.

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