CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes
CaloSimHitAnalysis Class Reference
Inheritance diagram for CaloSimHitAnalysis:
edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 CaloSimHitAnalysis (const edm::ParameterSet &ps)
 
 ~CaloSimHitAnalysis () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::SharedResources >
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

void analyze (edm::Event const &, edm::EventSetup const &) override
 
void analyzeHits (std::vector< PCaloHit > &, int)
 
void analyzePassiveHits (std::vector< PassiveHit > &hits)
 
void beginJob () override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Attributes

const CaloGeometrycaloGeometry_
 
const std::vector< std::string > detNames_
 
const std::string g4Label_
 
TH1F * h_edep1_ [nCalo_]
 
TH1F * h_edep_ [nCalo_]
 
TH1F * h_edepEM_ [nCalo_]
 
TH1F * h_edepHad_ [nCalo_]
 
TH1F * h_edepp_
 
TH1F * h_edepT1_ [nCalo_]
 
TH1F * h_edepT_ [nCalo_]
 
std::vector< TH1F * > h_edepTk_
 
TH1F * h_eta_ [nCalo_]
 
TH2F * h_etaphi_
 
TH1F * h_etot_ [nCalo_]
 
TH1F * h_etotg_ [nCalo_]
 
TH1F * h_hit_ [nCalo_]
 
TH1F * h_hitp_
 
TH1F * h_phi_ [nCalo_]
 
TH1F * h_rr_ [nCalo_]
 
TH2F * h_rz1_
 
TH2F * h_rz_
 
TH1F * h_stepp_
 
TH1F * h_time_ [nCalo_]
 
TH1F * h_timep_
 
TH1F * h_timeT_ [nCalo_]
 
std::vector< TH1F * > h_timeTk_
 
TH1F * h_trackp_
 
TH1F * h_zz_ [nCalo_]
 
const HcalGeometryhcalGeom_
 
const std::vector< std::string > hitLab_
 
const double maxEnergy_
 
const double maxTime_
 
const bool passive_
 
const double tCut_
 
const bool testNumber_
 
const std::vector< double > timeSliceUnit_
 
const double tMax_
 
edm::EDGetTokenT< edm::PassiveHitContainertok_passive_
 
std::vector< edm::EDGetTokenT< edm::PCaloHitContainer > > toks_calo_
 
const double tScale_
 

Static Private Attributes

static int nCalo_ = 6
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Detailed Description

Definition at line 45 of file CaloSimHitAnalysis.cc.

Constructor & Destructor Documentation

CaloSimHitAnalysis::CaloSimHitAnalysis ( const edm::ParameterSet ps)

Definition at line 83 of file CaloSimHitAnalysis.cc.

References detNames_, g4Label_, h_edep1_, h_edep_, h_edepEM_, h_edepHad_, h_edepp_, h_edepT1_, h_edepT_, h_edepTk_, h_eta_, h_etaphi_, h_etot_, h_etotg_, h_hit_, h_hitp_, h_phi_, h_rr_, h_rz1_, h_rz_, h_stepp_, h_time_, h_timep_, h_timeT_, h_timeTk_, h_trackp_, h_zz_, hitLab_, mps_fire::i, HLT_2018_cff::InputTag, edm::Service< T >::isAvailable(), dqmdumpme::k, TFileService::kSharedResource, M_PI, TFileService::make(), maxEnergy_, maxTime_, Skims_PA_cff::name, nCalo_, passive_, AlCaHLTBitMon_QueryRunRegistry::string, tCut_, compare::tfile, timeSliceUnit_, overlapproblemtsosanalyzer_cfi::title, tMax_, tok_passive_, toks_calo_, and L1TOccupancyClient_cfi::ymax.

84  : g4Label_(ps.getUntrackedParameter<std::string>("moduleLabel", "g4SimHits")),
85  hitLab_(ps.getParameter<std::vector<std::string> >("hitCollection")),
86  timeSliceUnit_(ps.getParameter<std::vector<double> >("timeSliceUnit")),
87  maxEnergy_(ps.getUntrackedParameter<double>("maxEnergy", 250.0)),
88  maxTime_(ps.getUntrackedParameter<double>("maxTime", 1000.0)),
89  tMax_(ps.getUntrackedParameter<double>("timeCut", 100.0)),
90  tScale_(ps.getUntrackedParameter<double>("timeScale", 1.0)),
91  tCut_(ps.getUntrackedParameter<double>("timeThreshold", 15.0)),
92  testNumber_(ps.getUntrackedParameter<bool>("testNumbering", false)),
93  passive_(ps.getUntrackedParameter<bool>("passiveHits", false)),
94  detNames_(ps.getUntrackedParameter<std::vector<std::string> >("detNames")) {
95  usesResource(TFileService::kSharedResource);
96 
97  // register for data access
98  for (unsigned int i = 0; i < hitLab_.size(); i++)
99  toks_calo_.emplace_back(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hitLab_[i])));
100  tok_passive_ = consumes<edm::PassiveHitContainer>(edm::InputTag(g4Label_, "AllPassiveHits"));
101 
102  edm::LogVerbatim("HitStudy") << "Module Label: " << g4Label_ << " Hits|timeSliceUnit:";
103  for (unsigned int i = 0; i < hitLab_.size(); i++)
104  edm::LogVerbatim("HitStudy") << "[" << i << "] " << hitLab_[i] << " " << timeSliceUnit_[i];
105  edm::LogVerbatim("HitStudy") << "Passive Hits " << passive_ << " from AllPassiveHits";
106  edm::LogVerbatim("HitStudy") << "maxEnergy: " << maxEnergy_ << " maxTime: " << maxTime_ << " tMax: " << tMax_;
107  for (unsigned int k = 0; k < detNames_.size(); ++k)
108  edm::LogVerbatim("HitStudy") << "Detector[" << k << "] " << detNames_[k];
109 
111  if (!tfile.isAvailable())
112  throw cms::Exception("BadConfig") << "TFileService unavailable: "
113  << "please add it to config file";
114  char name[20], title[120];
115  std::string dets[nCalo_] = {"EB", "EE", "HB", "HE", "HO", "HF"};
116  for (int i = 0; i < nCalo_; i++) {
117  sprintf(name, "Hit%d", i);
118  sprintf(title, "Number of hits in %s", dets[i].c_str());
119  h_hit_[i] = tfile->make<TH1F>(name, title, 100, 0., 20000.);
120  h_hit_[i]->GetXaxis()->SetTitle(title);
121  h_hit_[i]->GetYaxis()->SetTitle("Events");
122  sprintf(name, "Time%d", i);
123  sprintf(title, "Time of the hit (ns) in %s", dets[i].c_str());
124  h_time_[i] = tfile->make<TH1F>(name, title, 100, 0., 200.);
125  h_time_[i]->GetXaxis()->SetTitle(title);
126  h_time_[i]->GetYaxis()->SetTitle("Hits");
127  sprintf(name, "TimeT%d", i);
128  sprintf(title, "Time of each hit (ns) in %s", dets[i].c_str());
129  h_timeT_[i] = tfile->make<TH1F>(name, title, 100, 0., 200.);
130  h_timeT_[i]->GetXaxis()->SetTitle(title);
131  h_timeT_[i]->GetYaxis()->SetTitle("Hits");
132  double ymax = (i > 1) ? 0.01 : 0.1;
133  double ymx0 = (i > 1) ? 0.0025 : 0.025;
134  sprintf(name, "Edep%d", i);
135  sprintf(title, "Energy deposit (GeV) in %s", dets[i].c_str());
136  h_edep_[i] = tfile->make<TH1F>(name, title, 100, 0., ymax);
137  h_edep_[i]->GetXaxis()->SetTitle(title);
138  h_edep_[i]->GetYaxis()->SetTitle("Hits");
139  sprintf(name, "EdepT%d", i);
140  sprintf(title, "Energy deposit (GeV) of each hit in %s", dets[i].c_str());
141  h_edepT_[i] = tfile->make<TH1F>(name, title, 100, 0., ymx0);
142  h_edepT_[i]->GetXaxis()->SetTitle(title);
143  h_edepT_[i]->GetYaxis()->SetTitle("Hits");
144  sprintf(name, "EdepEM%d", i);
145  sprintf(title, "Energy deposit (GeV) by EM particles in %s", dets[i].c_str());
146  h_edepEM_[i] = tfile->make<TH1F>(name, title, 100, 0., ymx0);
147  h_edepEM_[i]->GetXaxis()->SetTitle(title);
148  h_edepEM_[i]->GetYaxis()->SetTitle("Hits");
149  sprintf(name, "EdepHad%d", i);
150  sprintf(title, "Energy deposit (GeV) by hadrons in %s", dets[i].c_str());
151  h_edepHad_[i] = tfile->make<TH1F>(name, title, 100, 0., ymx0);
152  h_edepHad_[i]->GetXaxis()->SetTitle(title);
153  h_edepHad_[i]->GetYaxis()->SetTitle("Hits");
154  sprintf(name, "Edep15%d", i);
155  sprintf(title, "Energy deposit (GeV) for T > %4.0f ns in %s", tCut_, dets[i].c_str());
156  h_edep1_[i] = tfile->make<TH1F>(name, title, 100, 0., ymax);
157  h_edep1_[i]->GetXaxis()->SetTitle(title);
158  h_edep1_[i]->GetYaxis()->SetTitle("Hits");
159  sprintf(name, "EdepT15%d", i);
160  sprintf(title, "Energy deposit (GeV) of each hit for T > %4.0f in %s", tCut_, dets[i].c_str());
161  h_edepT1_[i] = tfile->make<TH1F>(name, title, 100, 0., ymx0);
162  h_edepT1_[i]->GetXaxis()->SetTitle(title);
163  h_edepT1_[i]->GetYaxis()->SetTitle("Hits");
164  ymax = (i > 1) ? 1.0 : maxEnergy_;
165  sprintf(name, "Etot%d", i);
166  sprintf(title, "Total energy deposit (GeV) in %s", dets[i].c_str());
167  h_etot_[i] = tfile->make<TH1F>(name, title, 50, 0., ymax);
168  h_etot_[i]->GetXaxis()->SetTitle(title);
169  h_etot_[i]->GetYaxis()->SetTitle("Events");
170  sprintf(name, "EtotG%d", i);
171  sprintf(title, "Total energy deposit (GeV) in %s (t < 100 ns)", dets[i].c_str());
172  h_etotg_[i] = tfile->make<TH1F>(name, title, 50, 0., ymax);
173  h_etotg_[i]->GetXaxis()->SetTitle(title);
174  h_etotg_[i]->GetYaxis()->SetTitle("Events");
175  sprintf(name, "rr%d", i);
176  sprintf(title, "R of hit point (cm) in %s", dets[i].c_str());
177  h_rr_[i] = tfile->make<TH1F>(name, title, 100, 0., 250.);
178  h_rr_[i]->GetXaxis()->SetTitle(title);
179  h_rr_[i]->GetYaxis()->SetTitle("Hits");
180  sprintf(name, "zz%d", i);
181  sprintf(title, "z of hit point (cm) in %s", dets[i].c_str());
182  h_zz_[i] = tfile->make<TH1F>(name, title, 240, -600., 600.);
183  h_zz_[i]->GetXaxis()->SetTitle(title);
184  h_zz_[i]->GetYaxis()->SetTitle("Hits");
185  sprintf(name, "eta%d", i);
186  sprintf(title, "#eta of hit point in %s", dets[i].c_str());
187  h_eta_[i] = tfile->make<TH1F>(name, title, 100, -5.0, 5.0);
188  h_eta_[i]->GetXaxis()->SetTitle(title);
189  h_eta_[i]->GetYaxis()->SetTitle("Hits");
190  sprintf(name, "phi%d", i);
191  sprintf(title, "#phi of hit point in %s", dets[i].c_str());
192  h_phi_[i] = tfile->make<TH1F>(name, title, 100, -M_PI, M_PI);
193  h_phi_[i]->GetXaxis()->SetTitle(title);
194  h_phi_[i]->GetYaxis()->SetTitle("Hits");
195  }
196  sprintf(title, "R vs Z of hit point");
197  h_rz_ = tfile->make<TH2F>("rz", title, 120, 0., 600., 100, 0., 250.);
198  h_rz_->GetXaxis()->SetTitle("z (cm)");
199  h_rz_->GetYaxis()->SetTitle("R (cm)");
200  sprintf(title, "R vs Z of hit point for hits with T > %4.0f ns", tCut_);
201  h_rz1_ = tfile->make<TH2F>("rz2", title, 120, 0., 600., 100, 0., 250.);
202  h_rz1_->GetXaxis()->SetTitle("z (cm)");
203  h_rz1_->GetYaxis()->SetTitle("R (cm)");
204  sprintf(title, "#phi vs #eta of hit point");
205  h_etaphi_ = tfile->make<TH2F>("etaphi", title, 100, 0., 5., 100, 0., M_PI);
206  h_etaphi_->GetXaxis()->SetTitle("#eta");
207  h_etaphi_->GetYaxis()->SetTitle("#phi");
208 
209  if (passive_) {
210  h_hitp_ = tfile->make<TH1F>("hitp", "All Steps", 100, 0.0, 20000.0);
211  h_hitp_->GetXaxis()->SetTitle("Hits");
212  h_hitp_->GetYaxis()->SetTitle("Events");
213  h_trackp_ = tfile->make<TH1F>("trackp", "All Steps", 100, 0.0, 200000.0);
214  h_hitp_->GetXaxis()->SetTitle("Tracks");
215  h_hitp_->GetYaxis()->SetTitle("Events");
216  h_edepp_ = tfile->make<TH1F>("edepp", "All Steps", 100, 0.0, 50.0);
217  h_edepp_->GetXaxis()->SetTitle("Energy Deposit (MeV)");
218  h_edepp_->GetYaxis()->SetTitle("Hits");
219  h_timep_ = tfile->make<TH1F>("timep", "All Steps", 100, 0.0, 100.0);
220  h_timep_->GetXaxis()->SetTitle("Hits");
221  h_timep_->GetYaxis()->SetTitle("Hit Time (ns)");
222  h_stepp_ = tfile->make<TH1F>("stepp", "All Steps", 1000, 0.0, 100.0);
223  h_stepp_->GetXaxis()->SetTitle("Hits");
224  h_stepp_->GetYaxis()->SetTitle("Step length (cm)");
225  for (unsigned int k = 0; k < detNames_.size(); ++k) {
226  sprintf(name, "edept%d", k);
227  sprintf(title, "Energy Deposit (MeV) in %s", detNames_[k].c_str());
228  h_edepTk_.emplace_back(tfile->make<TH1F>(name, title, 100, 0.0, 1.0));
229  h_edepTk_.back()->GetYaxis()->SetTitle("Hits");
230  h_edepTk_.back()->GetXaxis()->SetTitle(title);
231  sprintf(name, "timet%d", k);
232  sprintf(title, "Hit Time (ns) in %s", detNames_[k].c_str());
233  h_timeTk_.emplace_back(tfile->make<TH1F>(name, title, 100, 0.0, 100.0));
234  h_timeTk_.back()->GetYaxis()->SetTitle("Hits");
235  h_timeTk_.back()->GetXaxis()->SetTitle(title);
236  }
237  }
238 }
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::PassiveHitContainer > tok_passive_
TH1F * h_edepT1_[nCalo_]
const std::vector< std::string > hitLab_
TH1F * h_timeT_[nCalo_]
TH1F * h_edepT_[nCalo_]
std::vector< TH1F * > h_edepTk_
TH1F * h_time_[nCalo_]
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< TH1F * > h_timeTk_
const std::string g4Label_
const std::vector< std::string > detNames_
std::vector< edm::EDGetTokenT< edm::PCaloHitContainer > > toks_calo_
TH1F * h_edep_[nCalo_]
TH1F * h_edepHad_[nCalo_]
bool isAvailable() const
Definition: Service.h:40
TH1F * h_edep1_[nCalo_]
#define M_PI
TH1F * h_etot_[nCalo_]
const std::vector< double > timeSliceUnit_
TH1F * h_etotg_[nCalo_]
TH1F * h_edepEM_[nCalo_]
CaloSimHitAnalysis::~CaloSimHitAnalysis ( )
inlineoverride

Definition at line 48 of file CaloSimHitAnalysis.cc.

References fillDescriptions().

48 {}

Member Function Documentation

void CaloSimHitAnalysis::analyze ( edm::Event const &  e,
edm::EventSetup const &  set 
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 259 of file CaloSimHitAnalysis.cc.

References analyzeHits(), analyzePassiveHits(), caloGeometry_, edm::EventID::event(), edm::Event::getByToken(), CaloGeometry::getSubdetectorGeometry(), DetId::Hcal, HcalBarrel, hcalGeom_, mps_fire::i, edm::EventBase::id(), edm::HandleBase::isValid(), passive_, edm::ESHandle< T >::product(), edm::EventID::run(), tok_passive_, and toks_calo_.

Referenced by beginJob().

259  {
260  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis:Run = " << e.id().run() << " Event = " << e.id().event();
261 
262  edm::ESHandle<CaloGeometry> calo_handle;
263  set.get<CaloGeometryRecord>().get(calo_handle);
264  caloGeometry_ = calo_handle.product();
266 
267  for (unsigned int i = 0; i < toks_calo_.size(); i++) {
269  e.getByToken(toks_calo_[i], hitsCalo);
270  bool getHits = (hitsCalo.isValid());
271  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis: Input flags Hits[" << i << "]: " << getHits;
272 
273  if (getHits) {
274  std::vector<PCaloHit> caloHits;
275  caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
276  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis: Hit buffer [" << i << "] " << caloHits.size();
277  analyzeHits(caloHits, i);
278  }
279  }
280 
281  if (passive_) {
283  e.getByToken(tok_passive_, hitsPassive);
284  bool getHits = (hitsPassive.isValid());
285  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis: Passive: " << getHits;
286 
287  if (getHits) {
288  std::vector<PassiveHit> passiveHits;
289  passiveHits.insert(passiveHits.end(), hitsPassive->begin(), hitsPassive->end());
290  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis: Passive Hit buffer " << passiveHits.size();
291  analyzePassiveHits(passiveHits);
292  }
293  }
294 }
void analyzeHits(std::vector< PCaloHit > &, int)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
edm::EDGetTokenT< edm::PassiveHitContainer > tok_passive_
void analyzePassiveHits(std::vector< PassiveHit > &hits)
std::vector< edm::EDGetTokenT< edm::PCaloHitContainer > > toks_calo_
const HcalGeometry * hcalGeom_
bool isValid() const
Definition: HandleBase.h:70
const CaloGeometry * caloGeometry_
T const * product() const
Definition: ESHandle.h:86
void CaloSimHitAnalysis::analyzeHits ( std::vector< PCaloHit > &  hits,
int  indx 
)
protected

Definition at line 296 of file CaloSimHitAnalysis.cc.

References funct::abs(), caloGeometry_, TauDecayModes::dec, LEDCalibrationChannels::depth, PV3DBase< T, PVType, FrameType >::eta(), dqmdumpme::first, CaloGeometry::getPosition(), HcalGeometry::getPosition(), h_edep1_, h_edep_, h_edepEM_, h_edepHad_, h_edepT1_, h_edepT_, h_eta_, h_etaphi_, h_etot_, h_etotg_, h_hit_, h_phi_, h_rr_, h_rz1_, h_rz_, h_time_, h_timeT_, h_zz_, HcalBarrel, HcalEndcap, HcalForward, hcalGeom_, HcalOuter, triggerObjects_cff::id, hit::id, training_settings::idx, LEDCalibrationChannels::ieta, dqmdumpme::k, nCalo_, PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), point, DetId::rawId(), edm::second(), HcalDetId::subdet(), tCut_, testNumber_, ntuplemaker::time, timeSliceUnit_, tMax_, tScale_, HcalTestNumbering::unpackHcalIndex(), z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by analyze(), and endRun().

296  {
297  int nHit = hits.size();
298  int nHB = 0, nHE = 0, nHO = 0, nHF = 0, nEB = 0, nEE = 0, nBad = 0, iHit = 0;
299  std::map<CaloHitID, std::pair<double, double> > hitMap;
300  double etot[nCalo_], etotG[nCalo_];
301  for (unsigned int k = 0; k < nCalo_; ++k) {
302  etot[k] = etotG[k] = 0;
303  }
304  for (const auto& hit : hits) {
305  double edep = hit.energy();
306  double time = tScale_ * hit.time();
307  uint32_t id = hit.id();
308  int itra = hit.geantTrackId();
309  double edepEM = hit.energyEM();
310  double edepHad = hit.energyHad();
311  int idx(-1);
312  if (indx != 2) {
313  idx = indx;
314  if (indx == 0)
315  ++nEB;
316  else
317  ++nEE;
318  } else {
319  int subdet(0);
320  if (testNumber_) {
321  int ieta(0), phi(0), z(0), lay(0), depth(0);
322  HcalTestNumbering::unpackHcalIndex(id, subdet, z, depth, ieta, phi, lay);
323  id = HcalDetId(static_cast<HcalSubdetector>(subdet), z * ieta, phi, depth).rawId();
324  } else {
325  subdet = HcalDetId(id).subdet();
326  }
327  if (subdet == static_cast<int>(HcalBarrel)) {
328  idx = indx;
329  nHB++;
330  } else if (subdet == static_cast<int>(HcalEndcap)) {
331  idx = indx + 1;
332  nHE++;
333  } else if (subdet == static_cast<int>(HcalOuter)) {
334  idx = indx + 2;
335  nHO++;
336  } else if (subdet == static_cast<int>(HcalForward)) {
337  idx = indx + 3;
338  nHF++;
339  }
340  }
341 #ifdef EDM_ML_DEBUG
342  edm::LogVerbatim("HitStudy") << "Hit[" << iHit << ":" << nHit << ":" << idx << "] E " << edep << ":" << edepEM
343  << ":" << edepHad << " T " << time << " itra " << itra << " ID " << std::hex << id
344  << std::dec;
345 #endif
346  ++iHit;
347  if (idx >= 0) {
348  CaloHitID hid(id, time, itra, 0, timeSliceUnit_[indx]);
349  auto itr = hitMap.find(hid);
350  if (itr == hitMap.end())
351  hitMap[hid] = std::make_pair(time, edep);
352  else
353  ((itr->second).second) += edep;
354  h_edepT_[idx]->Fill(edep);
355  h_timeT_[idx]->Fill(time);
356  if (edepEM > 0)
357  h_edepEM_[idx]->Fill(edepEM);
358  if (edepHad > 0)
359  h_edepHad_[idx]->Fill(edepHad);
360  if (time > tCut_)
361  h_edepT1_[idx]->Fill(edep);
362  } else {
363  ++nBad;
364  }
365  }
366 
367  //Now make plots
368  for (auto itr = hitMap.begin(); itr != hitMap.end(); ++itr) {
369  int idx = -1;
371  DetId id((itr->first).unitID());
372 #ifdef EDM_ML_DEBUG
373  edm::LogVerbatim("HitStudy") << "Index " << indx << " Geom " << caloGeometry_ << ":" << hcalGeom_ << " "
374  << std::hex << id.rawId() << std::dec;
375 #endif
376  if (indx != 2) {
377  idx = indx;
378  point = caloGeometry_->getPosition(id);
379  } else {
380  int subdet = id.subdetId();
381  if (subdet == static_cast<int>(HcalBarrel)) {
382  idx = indx;
383  } else if (subdet == static_cast<int>(HcalEndcap)) {
384  idx = indx + 1;
385  } else if (subdet == static_cast<int>(HcalOuter)) {
386  idx = indx + 2;
387  } else if (subdet == static_cast<int>(HcalForward)) {
388  idx = indx + 3;
389  }
390  point = hcalGeom_->getPosition(id);
391  }
392  double edep = (itr->second).second;
393  double time = (itr->second).first;
394 #ifdef EDM_ML_DEBUG
395  edm::LogVerbatim("HitStudy") << "Index " << idx << ":" << nCalo_ << " Point " << point << " E " << edep << " T "
396  << time;
397 #endif
398  if (idx >= 0) {
399  h_time_[idx]->Fill(time);
400  h_edep_[idx]->Fill(edep);
401  h_rr_[idx]->Fill(point.perp());
402  h_zz_[idx]->Fill(point.z());
403  h_eta_[idx]->Fill(point.eta());
404  h_phi_[idx]->Fill(point.phi());
405  h_rz_->Fill(std::abs(point.z()), point.perp());
406  h_etaphi_->Fill(std::abs(point.eta()), std::abs(point.phi()));
407  etot[idx] += edep;
408  if (time < tMax_)
409  etotG[idx] += edep;
410  if (time > tCut_) {
411  h_edep1_[idx]->Fill(edep);
412  h_rz1_->Fill(std::abs(point.z()), point.perp());
413  }
414  }
415  }
416 
417  if (indx < 2) {
418  h_etot_[indx]->Fill(etot[indx]);
419  h_etotg_[indx]->Fill(etotG[indx]);
420  if (indx == 0)
421  h_hit_[indx]->Fill(double(nEB));
422  else
423  h_hit_[indx]->Fill(double(nEE));
424  } else {
425  h_hit_[2]->Fill(double(nHB));
426  h_hit_[3]->Fill(double(nHE));
427  h_hit_[4]->Fill(double(nHO));
428  h_hit_[5]->Fill(double(nHF));
429  for (int idx = 2; idx < nCalo_; idx++) {
430  h_etot_[idx]->Fill(etot[idx]);
431  h_etotg_[idx]->Fill(etotG[idx]);
432  }
433  }
434 
435  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis::analyzeHits: EB " << nEB << " EE " << nEE << " HB " << nHB
436  << " HE " << nHE << " HO " << nHO << " HF " << nHF << " Bad " << nBad << " All " << nHit
437  << " Reduced " << hitMap.size();
438 }
T perp() const
Definition: PV3DBase.h:69
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
TH1F * h_edepT1_[nCalo_]
TH1F * h_timeT_[nCalo_]
TH1F * h_edepT_[nCalo_]
TH1F * h_time_[nCalo_]
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
U second(std::pair< T, U > const &p)
TH1F * h_edep_[nCalo_]
TH1F * h_edepHad_[nCalo_]
T z() const
Definition: PV3DBase.h:61
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
const HcalGeometry * hcalGeom_
TH1F * h_edep1_[nCalo_]
GlobalPoint getPosition(const DetId &id) const
unsigned int id
const CaloGeometry * caloGeometry_
Definition: DetId.h:17
TH1F * h_etot_[nCalo_]
const std::vector< double > timeSliceUnit_
T eta() const
Definition: PV3DBase.h:73
TH1F * h_etotg_[nCalo_]
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
TH1F * h_edepEM_[nCalo_]
void CaloSimHitAnalysis::analyzePassiveHits ( std::vector< PassiveHit > &  hits)
protected

Definition at line 440 of file CaloSimHitAnalysis.cc.

References DEFINE_FWK_MODULE, detNames_, h_edepp_, h_edepTk_, h_hitp_, h_stepp_, h_timep_, h_timeTk_, h_trackp_, hit::id, dqmdumpme::k, Skims_PA_cff::name, AlCaHLTBitMon_QueryRunRegistry::string, and PDWG_EXOHSCP_cff::tracks.

Referenced by analyze(), and endRun().

440  {
441  const std::string active = "Active";
442  const std::string sensor = "Sensor";
443  std::map<std::pair<std::string, uint32_t>, int> hitx;
444  std::map<int, int> tracks;
445  for (auto& hit : hits) {
446  std::string name = hit.vname();
447  std::pair<std::string, uint32_t> volume = std::make_pair(name, (hit.id() % 1000000));
448  auto itr = hitx.find(volume);
449  if (itr == hitx.end())
450  hitx[volume] = 1;
451  else
452  ++(itr->second);
453  auto ktr = tracks.find(hit.trackId());
454  if (ktr == tracks.end())
455  tracks[hit.trackId()] = 1;
456  else
457  ++(ktr->second);
458  h_edepp_->Fill(hit.energy());
459  h_timep_->Fill(hit.time());
460  h_stepp_->Fill(hit.stepLength());
461  if ((name.find(active) != std::string::npos) || (name.find(sensor) != std::string::npos)) {
462  unsigned idet = detNames_.size();
463  for (unsigned int k = 0; k < detNames_.size(); ++k) {
464  if (name.find(detNames_[k]) != std::string::npos) {
465  idet = k;
466  break;
467  }
468  }
469  if (idet < detNames_.size()) {
470  h_edepTk_[idet]->Fill(hit.energy());
471  h_timeTk_[idet]->Fill(hit.time());
472  }
473  }
474  }
475  h_hitp_->Fill(hitx.size());
476  h_trackp_->Fill(tracks.size());
477  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis::analyzPassiveHits: Total " << hits.size() << " Cells "
478  << hitx.size() << " Tracks " << tracks.size();
479 }
std::vector< TH1F * > h_edepTk_
std::vector< TH1F * > h_timeTk_
const std::vector< std::string > detNames_
unsigned int id
void CaloSimHitAnalysis::beginJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 52 of file CaloSimHitAnalysis.cc.

References analyze().

52 {}
void CaloSimHitAnalysis::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprotected

Definition at line 54 of file CaloSimHitAnalysis.cc.

54 {}
void CaloSimHitAnalysis::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprotected

Definition at line 55 of file CaloSimHitAnalysis.cc.

References analyzeHits(), analyzePassiveHits(), and hfClusterShapes_cfi::hits.

55 {}
void CaloSimHitAnalysis::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 240 of file CaloSimHitAnalysis.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), SummaryClient_cfi::labels, names, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~CaloSimHitAnalysis().

240  {
242  std::vector<std::string> labels = {"EcalHitsEB1", "EcalHitsEE1", "HcalHits1"};
243  std::vector<double> times = {1, 1, 1};
244  desc.addUntracked<std::string>("moduleLabel", "g4SimHits");
245  desc.add<std::vector<std::string> >("hitCollection", labels);
246  desc.add<std::vector<double> >("timeSliceUnit", times);
247  desc.addUntracked<double>("maxEnergy", 250.0);
248  desc.addUntracked<double>("maxTime", 1000.0);
249  desc.addUntracked<double>("timeCut", 100.0);
250  desc.addUntracked<double>("timeScale", 1.0);
251  desc.addUntracked<double>("timeThreshold", 15.0);
252  desc.addUntracked<bool>("testNumbering", false);
253  desc.addUntracked<bool>("passiveHits", false);
254  std::vector<std::string> names = {"PixelBarrel", "PixelForward", "TIB", "TID", "TOB", "TEC"};
255  desc.addUntracked<std::vector<std::string> >("detNames", names);
256  descriptions.add("caloSimHitAnalysis", desc);
257 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const std::string names[nVars_]
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

const CaloGeometry* CaloSimHitAnalysis::caloGeometry_
private

Definition at line 70 of file CaloSimHitAnalysis.cc.

Referenced by analyze(), and analyzeHits().

const std::vector<std::string> CaloSimHitAnalysis::detNames_
private

Definition at line 66 of file CaloSimHitAnalysis.cc.

Referenced by analyzePassiveHits(), and CaloSimHitAnalysis().

const std::string CaloSimHitAnalysis::g4Label_
private

Definition at line 61 of file CaloSimHitAnalysis.cc.

Referenced by CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_edep1_[nCalo_]
private

Definition at line 75 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_edep_[nCalo_]
private

Definition at line 74 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F* CaloSimHitAnalysis::h_edepEM_[nCalo_]
private

Definition at line 76 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_edepHad_[nCalo_]
private

Definition at line 76 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_edepp_
private

Definition at line 79 of file CaloSimHitAnalysis.cc.

Referenced by analyzePassiveHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_edepT1_[nCalo_]
private

Definition at line 75 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_edepT_[nCalo_]
private

Definition at line 74 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

std::vector<TH1F*> CaloSimHitAnalysis::h_edepTk_
private

Definition at line 80 of file CaloSimHitAnalysis.cc.

Referenced by analyzePassiveHits(), and CaloSimHitAnalysis().

TH1F* CaloSimHitAnalysis::h_eta_[nCalo_]
private

Definition at line 77 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH2F * CaloSimHitAnalysis::h_etaphi_
private

Definition at line 78 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_etot_[nCalo_]
private

Definition at line 77 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_etotg_[nCalo_]
private

Definition at line 77 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F* CaloSimHitAnalysis::h_hit_[nCalo_]
private

Definition at line 74 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F* CaloSimHitAnalysis::h_hitp_
private

Definition at line 79 of file CaloSimHitAnalysis.cc.

Referenced by analyzePassiveHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_phi_[nCalo_]
private

Definition at line 77 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_rr_[nCalo_]
private

Definition at line 76 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH2F * CaloSimHitAnalysis::h_rz1_
private

Definition at line 78 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH2F* CaloSimHitAnalysis::h_rz_
private

Definition at line 78 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_stepp_
private

Definition at line 79 of file CaloSimHitAnalysis.cc.

Referenced by analyzePassiveHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_time_[nCalo_]
private

Definition at line 74 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_timep_
private

Definition at line 79 of file CaloSimHitAnalysis.cc.

Referenced by analyzePassiveHits(), and CaloSimHitAnalysis().

TH1F* CaloSimHitAnalysis::h_timeT_[nCalo_]
private

Definition at line 75 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

std::vector<TH1F*> CaloSimHitAnalysis::h_timeTk_
private

Definition at line 80 of file CaloSimHitAnalysis.cc.

Referenced by analyzePassiveHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_trackp_
private

Definition at line 79 of file CaloSimHitAnalysis.cc.

Referenced by analyzePassiveHits(), and CaloSimHitAnalysis().

TH1F * CaloSimHitAnalysis::h_zz_[nCalo_]
private

Definition at line 76 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

const HcalGeometry* CaloSimHitAnalysis::hcalGeom_
private

Definition at line 71 of file CaloSimHitAnalysis.cc.

Referenced by analyze(), and analyzeHits().

const std::vector<std::string> CaloSimHitAnalysis::hitLab_
private

Definition at line 62 of file CaloSimHitAnalysis.cc.

Referenced by CaloSimHitAnalysis().

const double CaloSimHitAnalysis::maxEnergy_
private

Definition at line 64 of file CaloSimHitAnalysis.cc.

Referenced by CaloSimHitAnalysis().

const double CaloSimHitAnalysis::maxTime_
private

Definition at line 64 of file CaloSimHitAnalysis.cc.

Referenced by CaloSimHitAnalysis().

int CaloSimHitAnalysis::nCalo_ = 6
staticprivate

Definition at line 73 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

const bool CaloSimHitAnalysis::passive_
private

Definition at line 65 of file CaloSimHitAnalysis.cc.

Referenced by analyze(), and CaloSimHitAnalysis().

const double CaloSimHitAnalysis::tCut_
private

Definition at line 64 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

const bool CaloSimHitAnalysis::testNumber_
private

Definition at line 65 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits().

const std::vector<double> CaloSimHitAnalysis::timeSliceUnit_
private

Definition at line 63 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

const double CaloSimHitAnalysis::tMax_
private

Definition at line 64 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits(), and CaloSimHitAnalysis().

edm::EDGetTokenT<edm::PassiveHitContainer> CaloSimHitAnalysis::tok_passive_
private

Definition at line 68 of file CaloSimHitAnalysis.cc.

Referenced by analyze(), and CaloSimHitAnalysis().

std::vector<edm::EDGetTokenT<edm::PCaloHitContainer> > CaloSimHitAnalysis::toks_calo_
private

Definition at line 67 of file CaloSimHitAnalysis.cc.

Referenced by analyze(), and CaloSimHitAnalysis().

const double CaloSimHitAnalysis::tScale_
private

Definition at line 64 of file CaloSimHitAnalysis.cc.

Referenced by analyzeHits().