CMS 3D CMS Logo

HGCalTBAnalyzer.cc
Go to the documentation of this file.
1 // system include files
2 #include <fstream>
3 #include <iostream>
4 #include <map>
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 // user include files
14 
26 
39 
41 
42 // Root objects
43 #include "TFile.h"
44 #include "TH1.h"
45 #include "TH2.h"
46 #include "TProfile.h"
47 #include "TProfile2D.h"
48 #include "TROOT.h"
49 #include "TSystem.h"
50 #include "TTree.h"
51 
52 //#define EDM_ML_DEBUG
53 
54 class HGCalTBAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns,
55  edm::one::SharedResources> {
56  public:
57  explicit HGCalTBAnalyzer(edm::ParameterSet const&);
58  ~HGCalTBAnalyzer() override;
59 
60  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
61 
62  private:
63  void beginJob() override;
64  void beginRun(edm::Run const&, edm::EventSetup const&) override;
65  void endRun(edm::Run const&, edm::EventSetup const&) override {}
66  void analyze(edm::Event const&, edm::EventSetup const&) override;
67  void analyzeSimHits(int type, std::vector<PCaloHit>& hits, double zFront);
70  template <class T1>
71  void analyzeDigi(int type, const T1& detId, uint16_t adc);
74  int subdet);
75 
78  const HGCalGeometry* hgeom_[2];
82  bool doPassive_;
87  std::vector<int> idBeams_;
97 
98  TTree* tree_;
99  TH1D *hSimHitE_[4], *hSimHitT_[4];
100  TH1D *hDigiADC_[3], *hDigiLng_[2];
101  TH1D *hRecHitE_[3], *hSimHitEn_[4], *hBeam_;
102  TH2D *hDigiOcc_[3], *hRecHitOcc_[3];
103  TProfile *hSimHitLng_[3], *hSimHitLng1_[3];
104  TProfile* hSimHitLng2_[3];
105  TProfile *hRecHitLng_[3], *hRecHitLng1_[3];
106  TProfile2D *hSimHitLat_[3], *hRecHitLat_[3];
107  std::vector<TH1D*> hSimHitLayEn1EE_, hSimHitLayEn2EE_;
108  std::vector<TH1D*> hSimHitLayEn1FH_, hSimHitLayEn2FH_;
109  std::vector<TH1D*> hSimHitLayEn1BH_, hSimHitLayEn2BH_;
110  std::vector<TH1D*> hSimHitLayEnBeam_;
111  std::vector<float> simHitLayEn1EE_, simHitLayEn2EE_;
112  std::vector<float> simHitLayEn1FH_, simHitLayEn2FH_;
113  std::vector<float> simHitLayEn1BH_, simHitLayEn2BH_;
114  std::vector<float> simHitLayEnBeam_;
115  std::vector<uint32_t> simHitCellIdEE_, simHitCellIdFH_;
116  std::vector<uint32_t> simHitCellIdBH_, simHitCellIdBeam_;
117  std::vector<float> simHitCellEnEE_, simHitCellEnFH_;
118  std::vector<float> simHitCellEnBH_, simHitCellEnBeam_;
119 
122  std::vector<std::string> hgcPassiveEEName_, hgcPassiveFHName_,
126 
128 };
129 
131  usesResource("TFileService");
132 
133  // now do whatever initialization is needed
134  detectorEE_ = iConfig.getParameter<std::string>("DetectorEE");
135  detectorFH_ = iConfig.getParameter<std::string>("DetectorFH");
136  detectorBH_ = iConfig.getParameter<std::string>("DetectorBH");
137  detectorBeam_ = iConfig.getParameter<std::string>("DetectorBeam");
138  ifEE_ = iConfig.getParameter<bool>("UseEE");
139  ifFH_ = iConfig.getParameter<bool>("UseFH");
140  ifBH_ = iConfig.getParameter<bool>("UseBH");
141  ifBeam_ = iConfig.getParameter<bool>("UseBeam");
142  zFrontEE_ = iConfig.getParameter<double>("ZFrontEE");
143  zFrontFH_ = iConfig.getParameter<double>("ZFrontFH");
144  zFrontBH_ = iConfig.getParameter<double>("ZFrontBH");
145  idBeams_ = iConfig.getParameter<std::vector<int>>("IDBeams");
146  doSimHits_ = iConfig.getParameter<bool>("DoSimHits");
147  doDigis_ = iConfig.getParameter<bool>("DoDigis");
148  sampleIndex_ = iConfig.getParameter<int>("SampleIndex");
149  doRecHits_ = iConfig.getParameter<bool>("DoRecHits");
150  doTree_ = iConfig.getUntrackedParameter<bool>("DoTree", false);
151  doTreeCell_ = iConfig.getUntrackedParameter<bool>("DoTreeCell", false);
152  doPassive_ = iConfig.getUntrackedParameter<bool>("DoPassive", false);
153 
154 #ifdef EDM_ML_DEBUG
155  edm::LogVerbatim("HGCSim")
156  << "HGCalTBAnalyzer:: SimHits = " << doSimHits_ << " Digis = " << doDigis_
157  << ":" << sampleIndex_ << " RecHits = " << doRecHits_ << " useDets "
158  << ifEE_ << ":" << ifFH_ << ":" << ifBH_ << ":" << ifBeam_ << " zFront "
159  << zFrontEE_ << ":" << zFrontFH_ << ":" << zFrontBH_ << " IdBeam "
160  << idBeams_.size() << ":";
161  for (unsigned int k = 0; k < idBeams_.size(); ++k)
162  edm::LogVerbatim("HGCSim") << " [" << k << "] " << idBeams_[k];
163 #endif
164  if (idBeams_.empty()) idBeams_.push_back(1001);
165 
166  edm::InputTag tmp0 = iConfig.getParameter<edm::InputTag>("GeneratorSrc");
167  tok_hepMC_ = consumes<edm::HepMCProduct>(tmp0);
168 
169 #ifdef EDM_ML_DEBUG
170  edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: GeneratorSource = " << tmp0;
171 #endif
172  std::string tmp1 = iConfig.getParameter<std::string>("CaloHitSrcEE");
173  tok_hitsEE_ =
174  consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", tmp1));
175  tok_simTk_ = consumes<edm::SimTrackContainer>(edm::InputTag("g4SimHits"));
176  tok_simVtx_ = consumes<edm::SimVertexContainer>(edm::InputTag("g4SimHits"));
177  edm::InputTag tmp2 = iConfig.getParameter<edm::InputTag>("DigiSrcEE");
178  tok_digiEE_ = consumes<HGCalDigiCollection>(tmp2);
179  edm::InputTag tmp3 = iConfig.getParameter<edm::InputTag>("RecHitSrcEE");
180  tok_hitrEE_ = consumes<HGCRecHitCollection>(tmp3);
181 #ifdef EDM_ML_DEBUG
182  if (ifEE_) {
183  edm::LogVerbatim("HGCSim")
184  << "HGCalTBAnalyzer:: Detector " << detectorEE_ << " with tags " << tmp1
185  << ", " << tmp2 << ", " << tmp3;
186  }
187 #endif
188  tmp1 = iConfig.getParameter<std::string>("CaloHitSrcFH");
189  tok_hitsFH_ =
190  consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", tmp1));
191  tmp2 = iConfig.getParameter<edm::InputTag>("DigiSrcFH");
192  tok_digiFH_ = consumes<HGCalDigiCollection>(tmp2);
193  tmp3 = iConfig.getParameter<edm::InputTag>("RecHitSrcFH");
194  tok_hitrFH_ = consumes<HGCRecHitCollection>(tmp3);
195 #ifdef EDM_ML_DEBUG
196  if (ifFH_) {
197  edm::LogVerbatim("HGCSim")
198  << "HGCalTBAnalyzer:: Detector " << detectorFH_ << " with tags " << tmp1
199  << ", " << tmp2 << ", " << tmp3;
200  }
201 #endif
202  tmp1 = iConfig.getParameter<std::string>("CaloHitSrcBH");
203  tok_hitsBH_ =
204  consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", tmp1));
205  tmp2 = iConfig.getParameter<edm::InputTag>("DigiSrcBH");
206  tok_digiBH_ = consumes<HGCalDigiCollection>(tmp2);
207  tmp3 = iConfig.getParameter<edm::InputTag>("RecHitSrcBH");
208  tok_hitrBH_ = consumes<HGCRecHitCollection>(tmp3);
209 
211  edm::InputTag tmp = iConfig.getParameter<edm::InputTag>("HGCPassiveEE");
212  tok_hgcPHEE_ = consumes<edm::PassiveHitContainer>(tmp);
213 
214  tmp = iConfig.getParameter<edm::InputTag>("HGCPassiveFH");
215  tok_hgcPHFH_ = consumes<edm::PassiveHitContainer>(tmp);
216 
217  tmp = iConfig.getParameter<edm::InputTag>("HGCPassiveBH");
218  tok_hgcPHBH_ = consumes<edm::PassiveHitContainer>(tmp);
219 
220  tmp = iConfig.getParameter<edm::InputTag>("HGCPassiveCMSE");
221  tok_hgcPHCMSE_ = consumes<edm::PassiveHitContainer>(tmp);
222 
223 #ifdef EDM_ML_DEBUG
224  if (ifBH_) {
225  edm::LogVerbatim("HGCSim")
226  << "HGCalTBAnalyzer:: Detector " << detectorBH_ << " with tags " << tmp1
227  << ", " << tmp2 << ", " << tmp3;
228  }
229 #endif
230  tmp1 = iConfig.getParameter<std::string>("CaloHitSrcBeam");
231  tok_hitsBeam_ =
232  consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", tmp1));
233 #ifdef EDM_ML_DEBUG
234  if (ifBeam_) {
235  edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorBeam_
236  << " with tags " << tmp1;
237  }
238 #endif
239 }
240 
242 
244  edm::ConfigurationDescriptions& descriptions) {
246  desc.setUnknown();
247  desc.add<std::string>("DetectorEE", "HGCalEESensitive");
248  desc.add<bool>("UseEE", true);
249  desc.add<double>("ZFrontEE", 0.0);
250  desc.add<std::string>("CaloHitSrcEE", "HGCHitsEE");
251  desc.add<edm::InputTag>("DigiSrcEE", edm::InputTag("hgcalDigis", "EE"));
252  desc.add<edm::InputTag>("RecHitSrcEE",
253  edm::InputTag("HGCalRecHit", "HGCEERecHits"));
254  desc.add<std::string>("DetectorFH", "HGCalHESiliconSensitive");
255  desc.add<bool>("UseFH", false);
256  desc.add<double>("ZFrontFH", 0.0);
257  desc.add<std::string>("CaloHitSrcFH", "HGCHitsHEfront");
258  desc.add<edm::InputTag>("DigiSrcFH", edm::InputTag("hgcalDigis", "HEfront"));
259  desc.add<edm::InputTag>("RecHitSrcFH",
260  edm::InputTag("HGCalRecHit", "HGCHEFRecHits"));
261  desc.add<std::string>("DetectorBH", "AHCal");
262  desc.add<bool>("UseBH", false);
263  desc.add<double>("ZFrontBH", 0.0);
264  desc.add<std::string>("CaloHitSrcBH", "HcalHits");
265  desc.add<edm::InputTag>("DigiSrcBH", edm::InputTag("hgcalDigis", "HEback"));
266  desc.add<edm::InputTag>("RecHitSrcBH",
267  edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
268  desc.add<std::string>("DetectorBeam", "HcalTB06BeamDetector");
269  desc.add<bool>("UseBeam", false);
270  desc.add<std::string>("CaloHitSrcBeam", "HcalTB06BeamHits");
271  std::vector<int> ids = {1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008,
272  1011, 1012, 1013, 1014, 2001, 2002, 2003, 2004, 2005};
273  desc.add<std::vector<int>>("IDBeams", ids);
274  desc.add<edm::InputTag>("GeneratorSrc", edm::InputTag("generatorSmeared"));
275  desc.add<edm::InputTag>("HGCPassiveEE",
276  edm::InputTag("g4SimHits", "HGCalEEPassiveHits"));
277  desc.add<edm::InputTag>("HGCPassiveFH",
278  edm::InputTag("g4SimHits", "HGCalHEPassiveHits"));
279  desc.add<edm::InputTag>("HGCPassiveBH",
280  edm::InputTag("g4SimHits", "HGCalAHPassiveHits"));
281  desc.add<edm::InputTag>("HGCPassiveCMSE",
282  edm::InputTag("g4SimHits", "CMSEPassiveHits"));
283 
284  desc.add<bool>("DoSimHits", true);
285  desc.add<bool>("DoDigis", true);
286  desc.add<bool>("DoRecHits", true);
287  desc.add<int>("SampleIndex", 0);
288  desc.addUntracked<bool>("DoTree", true);
289  desc.addUntracked<bool>("DoTreeCell", true);
290  desc.addUntracked<bool>("DoPassive", false);
291 
292  descriptions.add("HGCalTBAnalyzer", desc);
293 }
294 
296  char name[40], title[100];
297  hBeam_ = fs_->make<TH1D>("BeamP", "Beam Momentum", 1000, 0, 1000.0);
298  for (int i = 0; i < 3; ++i) {
299  bool book(ifEE_);
301  if (i == 1) {
302  book = ifFH_;
303  det = detectorFH_;
304  } else if (i == 2) {
305  book = ifBH_;
306  det = detectorBH_;
307  }
308 
309  if (doSimHits_ && book) {
310  sprintf(name, "SimHitEn%s", det.c_str());
311  sprintf(title, "Sim Hit Energy for %s", det.c_str());
312  hSimHitE_[i] = fs_->make<TH1D>(name, title, 100000, 0., 0.2);
313  sprintf(name, "SimHitEnX%s", det.c_str());
314  sprintf(title, "Sim Hit Energy for %s", det.c_str());
315  hSimHitEn_[i] = fs_->make<TH1D>(name, title, 100000, 0., 0.2);
316  sprintf(name, "SimHitTm%s", det.c_str());
317  sprintf(title, "Sim Hit Timing for %s", det.c_str());
318  hSimHitT_[i] = fs_->make<TH1D>(name, title, 5000, 0., 500.0);
319  sprintf(name, "SimHitLat%s", det.c_str());
320  sprintf(title, "Lateral Shower profile (Sim Hit) for %s", det.c_str());
321  hSimHitLat_[i] = fs_->make<TProfile2D>(name, title, 100, -100., 100., 100,
322  -100., 100.);
323  sprintf(name, "SimHitLng%s", det.c_str());
324  sprintf(title, "Longitudinal Shower profile (Sim Hit) for %s",
325  det.c_str());
326  hSimHitLng_[i] = fs_->make<TProfile>(name, title, 50, 0., 100.);
327  sprintf(name, "SimHitLng1%s", det.c_str());
328  sprintf(title, "Longitudinal Shower profile (Layer) for %s", det.c_str());
329  hSimHitLng1_[i] = fs_->make<TProfile>(name, title, 200, 0., 100.);
330  sprintf(name, "SimHitLng2%s", det.c_str());
331  sprintf(title, "Longitudinal Shower profile (Layer) for %s", det.c_str());
332  hSimHitLng2_[i] = fs_->make<TProfile>(name, title, 200, 0., 100.);
333  }
334 
335  if (doDigis_ && book) {
336  sprintf(name, "DigiADC%s", det.c_str());
337  sprintf(title, "ADC at Digi level for %s", det.c_str());
338  hDigiADC_[i] = fs_->make<TH1D>(name, title, 100, 0., 100.0);
339  sprintf(name, "DigiOcc%s", det.c_str());
340  sprintf(title, "Occupancy (Digi)for %s", det.c_str());
341  hDigiOcc_[i] =
342  fs_->make<TH2D>(name, title, 100, -10., 10., 100, -10., 10.);
343  sprintf(name, "DigiLng%s", det.c_str());
344  sprintf(title, "Longitudinal Shower profile (Digi) for %s", det.c_str());
345  hDigiLng_[i] = fs_->make<TH1D>(name, title, 100, 0., 10.);
346  }
347 
348  if (doRecHits_ && book) {
349  sprintf(name, "RecHitEn%s", det.c_str());
350  sprintf(title, "Rec Hit Energy for %s", det.c_str());
351  hRecHitE_[i] = fs_->make<TH1D>(name, title, 1000, 0., 10.0);
352  sprintf(name, "RecHitOcc%s", det.c_str());
353  sprintf(title, "Occupancy (Rec Hit)for %s", det.c_str());
354  hRecHitOcc_[i] =
355  fs_->make<TH2D>(name, title, 100, -10., 10., 100, -10., 10.);
356  sprintf(name, "RecHitLat%s", det.c_str());
357  sprintf(title, "Lateral Shower profile (Rec Hit) for %s", det.c_str());
358  hRecHitLat_[i] =
359  fs_->make<TProfile2D>(name, title, 100, -10., 10., 100, -10., 10.);
360  sprintf(name, "RecHitLng%s", det.c_str());
361  sprintf(title, "Longitudinal Shower profile (Rec Hit) for %s",
362  det.c_str());
363  hRecHitLng_[i] = fs_->make<TProfile>(name, title, 100, 0., 10.);
364  sprintf(name, "RecHitLng1%s", det.c_str());
365  sprintf(title, "Longitudinal Shower profile vs Layer for %s",
366  det.c_str());
367  hRecHitLng1_[i] = fs_->make<TProfile>(name, title, 120, 0., 60.);
368  }
369  }
370  if (ifBeam_ && doSimHits_) {
371  sprintf(name, "SimHitEn%s", detectorBeam_.c_str());
372  sprintf(title, "Sim Hit Energy for %s", detectorBeam_.c_str());
373  hSimHitE_[3] = fs_->make<TH1D>(name, title, 100000, 0., 0.2);
374  sprintf(name, "SimHitEnX%s", detectorBeam_.c_str());
375  sprintf(title, "Sim Hit Energy for %s", detectorBeam_.c_str());
376  hSimHitEn_[3] = fs_->make<TH1D>(name, title, 100000, 0., 0.2);
377  sprintf(name, "SimHitTm%s", detectorBeam_.c_str());
378  sprintf(title, "Sim Hit Timing for %s", detectorBeam_.c_str());
379  hSimHitT_[3] = fs_->make<TH1D>(name, title, 5000, 0., 500.0);
380  }
381  if (doSimHits_ && doTree_) {
382  tree_ = fs_->make<TTree>("HGCTB", "SimHitEnergy");
383  tree_->Branch("simHitLayEn1EE", &simHitLayEn1EE_);
384  tree_->Branch("simHitLayEn2EE", &simHitLayEn2EE_);
385  tree_->Branch("simHitLayEn1FH", &simHitLayEn1FH_);
386  tree_->Branch("simHitLayEn2FH", &simHitLayEn2FH_);
387  tree_->Branch("simHitLayEn1BH", &simHitLayEn1BH_);
388  tree_->Branch("simHitLayEn2BH", &simHitLayEn2BH_);
389  tree_->Branch("xBeam", &xBeam_, "xBeam/D");
390  tree_->Branch("yBeam", &yBeam_, "yBeam/D");
391  tree_->Branch("zBeam", &zBeam_, "zBeam/D");
392  tree_->Branch("pBeam", &pBeam_, "pBeam/D");
393  if (doTreeCell_) {
394  tree_->Branch("simHitCellIdEE", &simHitCellIdEE_);
395  tree_->Branch("simHitCellEnEE", &simHitCellEnEE_);
396  tree_->Branch("simHitCellIdFH", &simHitCellIdFH_);
397  tree_->Branch("simHitCellEnFH", &simHitCellEnFH_);
398  tree_->Branch("simHitCellIdBH", &simHitCellIdBH_);
399  tree_->Branch("simHitCellEnBH", &simHitCellEnBH_);
400  tree_->Branch("simHitCellIdBeam", &simHitCellIdBeam_);
401  tree_->Branch("simHitCellEnBeam", &simHitCellEnBeam_);
402  }
403  }
404 
405  if (doPassive_ && doTree_) {
406  tree_->Branch("hgcPassiveEEEnergy", &hgcPassiveEEEnergy_);
407  tree_->Branch("hgcPassiveEEName", &hgcPassiveEEName_);
408  tree_->Branch("hgcPassiveEEID", &hgcPassiveEEID_);
409  tree_->Branch("hgcPassiveFHEnergy", &hgcPassiveFHEnergy_);
410  tree_->Branch("hgcPassiveFHName", &hgcPassiveFHName_);
411  tree_->Branch("hgcPassiveFHID", &hgcPassiveFHID_);
412  tree_->Branch("hgcPassiveBHEnergy", &hgcPassiveBHEnergy_);
413  tree_->Branch("hgcPassiveBHName", &hgcPassiveBHName_);
414  tree_->Branch("hgcPassiveBHID", &hgcPassiveBHID_);
415  tree_->Branch("hgcPassiveCMSEEnergy", &hgcPassiveCMSEEnergy_);
416  tree_->Branch("hgcPassiveCMSEName", &hgcPassiveCMSEName_);
417  tree_->Branch("hgcPassiveCMSEID", &hgcPassiveCMSEID_);
418  }
419 }
420 
422  char name[40], title[100];
423  if (ifEE_) {
425  iSetup.get<IdealGeometryRecord>().get(detectorEE_, pHGDC);
426  hgcons_[0] = &(*pHGDC);
427  if (doDigis_ || doRecHits_) {
429  iSetup.get<IdealGeometryRecord>().get(detectorEE_, geom);
430  hgeom_[0] = geom.product();
431  } else {
432  hgeom_[0] = nullptr;
433  }
434  for (unsigned int l = 0; l < hgcons_[0]->layers(false); ++l) {
435  sprintf(name, "SimHitEnA%d%s", l, detectorEE_.c_str());
436  sprintf(title, "Sim Hit Energy in SIM layer %d for %s", l + 1,
437  detectorEE_.c_str());
438  hSimHitLayEn1EE_.push_back(fs_->make<TH1D>(name, title, 100000, 0., 0.2));
439  if (l % 3 == 0) {
440  sprintf(name, "SimHitEnB%d%s", (l / 3 + 1), detectorEE_.c_str());
441  sprintf(title, "Sim Hit Energy in layer %d for %s", (l / 3 + 1),
442  detectorEE_.c_str());
443  hSimHitLayEn2EE_.push_back(
444  fs_->make<TH1D>(name, title, 100000, 0., 0.2));
445  }
446  }
447 #ifdef EDM_ML_DEBUG
448  edm::LogVerbatim("HGCSim")
449  << "HGCalTBAnalyzer::" << detectorEE_ << " defined with "
450  << hgcons_[0]->layers(false) << " layers";
451 #endif
452  } else {
453  hgcons_[0] = nullptr;
454  hgeom_[0] = nullptr;
455  }
456 
457  if (ifFH_) {
459  iSetup.get<IdealGeometryRecord>().get(detectorFH_, pHGDC);
460  hgcons_[1] = &(*pHGDC);
461  if (doDigis_ || doRecHits_) {
463  iSetup.get<IdealGeometryRecord>().get(detectorFH_, geom);
464  hgeom_[1] = geom.product();
465  } else {
466  hgeom_[1] = nullptr;
467  }
468  for (unsigned int l = 0; l < hgcons_[1]->layers(false); ++l) {
469  sprintf(name, "SimHitEnA%d%s", l, detectorFH_.c_str());
470  sprintf(title, "Sim Hit Energy in layer %d for %s", l + 1,
471  detectorFH_.c_str());
472  hSimHitLayEn1FH_.push_back(fs_->make<TH1D>(name, title, 100000, 0., 0.2));
473  if (l % 3 == 0) {
474  sprintf(name, "SimHitEnB%d%s", (l / 3 + 1), detectorFH_.c_str());
475  sprintf(title, "Sim Hit Energy in layer %d for %s", (l / 3 + 1),
476  detectorFH_.c_str());
477  hSimHitLayEn2FH_.push_back(
478  fs_->make<TH1D>(name, title, 100000, 0., 0.2));
479  }
480  }
481 #ifdef EDM_ML_DEBUG
482  edm::LogVerbatim("HGCSim")
483  << "HGCalTBAnalyzer::" << detectorFH_ << " defined with "
484  << hgcons_[1]->layers(false) << " layers";
485 #endif
486  } else {
487  hgcons_[1] = nullptr;
488  hgeom_[1] = nullptr;
489  }
490 
491  if (ifBH_) {
492  for (int l = 0; l < AHCalDetId::MaxDepth; ++l) {
493  sprintf(name, "SimHitEnA%d%s", l, detectorBH_.c_str());
494  sprintf(title, "Sim Hit Energy in layer %d for %s", l + 1,
495  detectorBH_.c_str());
496  hSimHitLayEn1BH_.push_back(fs_->make<TH1D>(name, title, 100000, 0., 0.2));
497  sprintf(name, "SimHitEnB%d%s", l, detectorBH_.c_str());
498  sprintf(title, "Sim Hit Energy in layer %d for %s", l + 1,
499  detectorBH_.c_str());
500  hSimHitLayEn2BH_.push_back(fs_->make<TH1D>(name, title, 100000, 0., 0.2));
501  }
502  }
503 
504  if (ifBeam_) {
505  for (unsigned int l = 0; l < idBeams_.size(); ++l) {
506  sprintf(name, "SimHitEna%d%s", l, detectorBeam_.c_str());
507  sprintf(title, "Sim Hit Energy in type %d for %s", idBeams_[l],
508  detectorBeam_.c_str());
509  hSimHitLayEnBeam_.push_back(
510  fs_->make<TH1D>(name, title, 100000, 0., 0.2));
511  }
512  }
513 }
514 
516  const edm::EventSetup& iSetup) {
517  // Generator input
519  iEvent.getByToken(tok_hepMC_, evtMC);
520  if (!evtMC.isValid()) {
521  edm::LogWarning("HGCal") << "no HepMCProduct found";
522  } else {
523  const HepMC::GenEvent* myGenEvent = evtMC->GetEvent();
524  unsigned int k(0);
525  for (HepMC::GenEvent::particle_const_iterator p =
526  myGenEvent->particles_begin();
527  p != myGenEvent->particles_end(); ++p, ++k) {
528  if (k == 0) hBeam_->Fill((*p)->momentum().rho());
529 #ifdef EDM_ML_DEBUG
530  edm::LogVerbatim("HGCSim")
531  << "Particle[" << k << "] with p " << (*p)->momentum().rho()
532  << " theta " << (*p)->momentum().theta() << " phi "
533  << (*p)->momentum().phi();
534 #endif
535  }
536  }
537 
538  // Now the Simhits
539  if (doSimHits_) {
541  iEvent.getByToken(tok_simTk_, SimTk);
543  iEvent.getByToken(tok_simVtx_, SimVtx);
544  analyzeSimTracks(SimTk, SimVtx);
545 
546  simHitLayEn1EE_.clear();
547  simHitLayEn2EE_.clear();
548  simHitLayEn1FH_.clear();
549  simHitLayEn2FH_.clear();
550  simHitLayEn1BH_.clear();
551  simHitLayEn2BH_.clear();
552  simHitLayEnBeam_.clear();
553  simHitCellIdEE_.clear();
554  simHitCellEnEE_.clear();
555  simHitCellIdFH_.clear();
556  simHitCellEnFH_.clear();
557  simHitCellIdBH_.clear();
558  simHitCellEnBH_.clear();
559  simHitCellIdBeam_.clear();
560  simHitCellEnBeam_.clear();
561  edm::Handle<edm::PCaloHitContainer> theCaloHitContainers;
562  std::vector<PCaloHit> caloHits;
563  if (ifEE_) {
564  simHitLayEn1EE_ = std::vector<float>(hgcons_[0]->layers(false), 0);
565  simHitLayEn2EE_ = std::vector<float>(hgcons_[0]->layers(true), 0);
566  iEvent.getByToken(tok_hitsEE_, theCaloHitContainers);
567  if (theCaloHitContainers.isValid()) {
568 #ifdef EDM_ML_DEBUG
569  edm::LogVerbatim("HGCSim")
570  << "PcalohitContainer for " << detectorEE_ << " has "
571  << theCaloHitContainers->size() << " hits";
572 #endif
573  caloHits.clear();
574  caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
575  theCaloHitContainers->end());
576  analyzeSimHits(0, caloHits, zFrontEE_);
577  } else {
578 #ifdef EDM_ML_DEBUG
579  edm::LogVerbatim("HGCSim")
580  << "PCaloHitContainer does not exist for " << detectorEE_ << " !!!";
581 #endif
582  }
583  }
584  if (ifFH_) {
585  simHitLayEn1FH_ = std::vector<float>(hgcons_[1]->layers(false), 0);
586  simHitLayEn2FH_ = std::vector<float>(hgcons_[1]->layers(true), 0);
587  iEvent.getByToken(tok_hitsFH_, theCaloHitContainers);
588  if (theCaloHitContainers.isValid()) {
589 #ifdef EDM_ML_DEBUG
590  edm::LogVerbatim("HGCSim")
591  << "PcalohitContainer for " << detectorFH_ << " has "
592  << theCaloHitContainers->size() << " hits";
593 #endif
594  caloHits.clear();
595  caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
596  theCaloHitContainers->end());
597  analyzeSimHits(1, caloHits, zFrontFH_);
598  } else {
599 #ifdef EDM_ML_DEBUG
600  edm::LogVerbatim("HGCSim")
601  << "PCaloHitContainer does not exist for " << detectorFH_ << " !!!";
602 #endif
603  }
604  }
605  if (ifBH_) {
606  simHitLayEn1BH_ = std::vector<float>(AHCalDetId::MaxDepth, 0);
607  simHitLayEn2BH_ = std::vector<float>(AHCalDetId::MaxDepth, 0);
608  iEvent.getByToken(tok_hitsBH_, theCaloHitContainers);
609  if (theCaloHitContainers.isValid()) {
610 #ifdef EDM_ML_DEBUG
611  edm::LogVerbatim("HGCSim")
612  << "PcalohitContainer for " << detectorBH_ << " has "
613  << theCaloHitContainers->size() << " hits";
614 #endif
615  caloHits.clear();
616  caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
617  theCaloHitContainers->end());
618  analyzeSimHits(2, caloHits, zFrontBH_);
619  } else {
620 #ifdef EDM_ML_DEBUG
621  edm::LogVerbatim("HGCSim")
622  << "PCaloHitContainer does not exist for " << detectorBH_ << " !!!";
623 #endif
624  }
625  }
626  if (ifBeam_) {
627  simHitLayEnBeam_ = std::vector<float>(idBeams_.size(), 0);
628  iEvent.getByToken(tok_hitsBeam_, theCaloHitContainers);
629  if (theCaloHitContainers.isValid()) {
630 #ifdef EDM_ML_DEBUG
631  edm::LogVerbatim("HGCSim")
632  << "PcalohitContainer for " << detectorBeam_ << " has "
633  << theCaloHitContainers->size() << " hits";
634 #endif
635  caloHits.clear();
636  caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
637  theCaloHitContainers->end());
638  analyzeSimHits(3, caloHits, 0.0);
639  } else {
640 #ifdef EDM_ML_DEBUG
641  edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for "
642  << detectorBeam_ << " !!!";
643 #endif
644  }
645  }
646  // if (doTree_) tree_->Fill();
647  } // if (doSimHits_)
648 
650  if (doPassive_) {
651  hgcPassiveEEEnergy_.clear();
652  hgcPassiveFHEnergy_.clear();
653  hgcPassiveBHEnergy_.clear();
654  hgcPassiveCMSEEnergy_.clear();
655  hgcPassiveEEName_.clear();
656  hgcPassiveFHName_.clear();
657  hgcPassiveBHName_.clear();
658  hgcPassiveCMSEName_.clear();
659  hgcPassiveEEID_.clear();
660  hgcPassiveFHID_.clear();
661  hgcPassiveBHID_.clear();
662  hgcPassiveCMSEID_.clear();
663 
666  iEvent.getByToken(tok_hgcPHEE_, hgcPHEE);
667  analyzePassiveHits(hgcPHEE, 1);
668 
671  iEvent.getByToken(tok_hgcPHFH_, hgcPHFH);
672  analyzePassiveHits(hgcPHFH, 2);
673 
676  iEvent.getByToken(tok_hgcPHBH_, hgcPHBH);
677  analyzePassiveHits(hgcPHBH, 3);
678 
681  iEvent.getByToken(tok_hgcPHCMSE_, hgcPHCMSE);
682  analyzePassiveHits(hgcPHCMSE, 4);
683  }
684 
685  if ((doSimHits_ || doPassive_) && (doTree_)) tree_->Fill();
686 
687  // Now the Digis
688  if (doDigis_) {
689  if (ifEE_) {
690  edm::Handle<HGCalDigiCollection> theDigiContainers;
691  iEvent.getByToken(tok_digiEE_, theDigiContainers);
692  if (theDigiContainers.isValid()) {
693 #ifdef EDM_ML_DEBUG
694  edm::LogVerbatim("HGCSim")
695  << "HGCDigiCintainer for " << detectorEE_ << " with "
696  << theDigiContainers->size() << " element(s)";
697 #endif
698  for (auto it : *theDigiContainers) {
699  HGCalDetId detId = (it.id());
700  const HGCSample& hgcSample = it.sample(sampleIndex_);
701  uint16_t adc = hgcSample.data();
702  analyzeDigi(0, detId, adc);
703  }
704  }
705  }
706  if (ifFH_) {
707  edm::Handle<HGCalDigiCollection> theDigiContainers;
708  iEvent.getByToken(tok_digiFH_, theDigiContainers);
709  if (theDigiContainers.isValid()) {
710 #ifdef EDM_ML_DEBUG
711  edm::LogVerbatim("HGCSim")
712  << "HGCDigiContainer for " << detectorFH_ << " with "
713  << theDigiContainers->size() << " element(s)";
714 #endif
715  for (auto it : *theDigiContainers) {
716  HGCalDetId detId = (it.id());
717  const HGCSample& hgcSample = it.sample(sampleIndex_);
718  uint16_t adc = hgcSample.data();
719  analyzeDigi(1, detId, adc);
720  }
721  }
722  }
723  }
724 
725  // The Rechits
726  if (doRecHits_) {
727  edm::Handle<HGCRecHitCollection> theCaloHitContainers;
728  if (ifEE_) {
729  iEvent.getByToken(tok_hitrEE_, theCaloHitContainers);
730  if (theCaloHitContainers.isValid()) {
731 #ifdef EDM_ML_DEBUG
732  edm::LogVerbatim("HGCSim")
733  << "HGCRecHitCollection for " << detectorEE_ << " has "
734  << theCaloHitContainers->size() << " hits";
735 #endif
736  analyzeRecHits(0, theCaloHitContainers);
737  } else {
738 #ifdef EDM_ML_DEBUG
739  edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for "
740  << detectorEE_ << " !!!";
741 #endif
742  }
743  }
744  if (ifFH_) {
745  iEvent.getByToken(tok_hitrFH_, theCaloHitContainers);
746  if (theCaloHitContainers.isValid()) {
747 #ifdef EDM_ML_DEBUG
748  edm::LogVerbatim("HGCSim")
749  << "HGCRecHitCollection for " << detectorFH_ << " has "
750  << theCaloHitContainers->size() << " hits";
751 #endif
752  analyzeRecHits(1, theCaloHitContainers);
753  } else {
754 #ifdef EDM_ML_DEBUG
755  edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for "
756  << detectorFH_ << " !!!";
757 #endif
758  } // else
759  } // if (ifFH_)
760  } // if (doRecHits_)
761 
762 } // void HGCalTBAnalyzer::analyze
763 
764 void HGCalTBAnalyzer::analyzeSimHits(int type, std::vector<PCaloHit>& hits,
765  double zFront) {
766  std::map<uint32_t, double> map_hits, map_hitn;
767  std::map<int, double> map_hitDepth;
768  std::map<int, std::pair<uint32_t, double>> map_hitLayer, map_hitCell;
769  double entot(0);
770  for (unsigned int i = 0; i < hits.size(); i++) {
771  double energy = hits[i].energy();
772  double time = hits[i].time();
773  uint32_t id = hits[i].id();
774  entot += energy;
775  int subdet, zside, layer, sector, subsector(0), cell, depth(0), idx(0);
776  if (type == 2) {
777  subdet = HcalDetId(id).subdet();
778  if (subdet != HcalOther) continue;
779  AHCalDetId hid(id);
780  layer = depth = hid.depth();
781  zside = hid.zside();
782  sector = hid.irow();
783  cell = hid.icol();
784  idx = ((hid.irowAbs() * 100) + (hid.icolAbs()));
785  } else if (type == 3) {
786  HcalTestBeamNumbering::unpackIndex(id, subdet, layer, sector, cell);
787  depth = layer;
788  zside = 1;
789  idx = subdet * 1000 + layer;
790  layer = idx;
791  } else {
792  HGCalTestNumbering::unpackHexagonIndex(id, subdet, zside, layer, sector,
793  subsector, cell);
794  depth = hgcons_[type]->simToReco(cell, layer, sector, true).second;
795  idx = sector * 1000 + cell;
796  }
797 #ifdef EDM_ML_DEBUG
798  edm::LogVerbatim("HGCSim")
799  << "SimHit:Hit[" << i << "] Id " << subdet << ":" << zside << ":"
800  << layer << ":" << sector << ":" << subsector << ":" << cell << ":"
801  << depth << " Energy " << energy << " Time " << time;
802 #endif
803  if (map_hits.count(id) != 0) {
804  map_hits[id] += energy;
805  } else {
806  map_hits[id] = energy;
807  }
808  if (map_hitLayer.count(layer) != 0) {
809  double ee = energy + map_hitLayer[layer].second;
810  map_hitLayer[layer] = std::pair<uint32_t, double>(id, ee);
811  } else {
812  map_hitLayer[layer] = std::pair<uint32_t, double>(id, energy);
813  }
814  if (depth >= 0) {
815  if (map_hitCell.count(idx) != 0) {
816  double ee = energy + map_hitCell[idx].second;
817  map_hitCell[idx] = std::pair<uint32_t, double>(id, ee);
818  } else {
819  map_hitCell[idx] = std::pair<uint32_t, double>(id, energy);
820  }
821  if (map_hitDepth.count(depth) != 0) {
822  map_hitDepth[depth] += energy;
823  } else {
824  map_hitDepth[depth] = energy;
825  }
826  uint32_t idn = (type >= 2)
827  ? id
829  subdet, zside, depth, sector, subsector, cell);
830  if (map_hitn.count(idn) != 0) {
831  map_hitn[idn] += energy;
832  } else {
833  map_hitn[idn] = energy;
834  }
835  }
836  hSimHitT_[type]->Fill(time, energy);
837  }
838 
839  hSimHitEn_[type]->Fill(entot);
840  for (auto itr : map_hits) {
841  hSimHitE_[type]->Fill(itr.second);
842  }
843 
844  for (auto itr : map_hitLayer) {
845  int layer = itr.first - 1;
846  double energy = (itr.second).second;
847  double zp(0);
848  if (type < 2)
849  zp = hgcons_[type]->waferZ(layer + 1, false);
850  else if (type == 2)
851  zp = AHCalDetId((itr.second).first).getZ();
852 #ifdef EDM_ML_DEBUG
853  edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer + 1 << " Z " << zp
854  << ":" << zp - zFront << " E " << energy;
855 #endif
856  if (type < 3) {
857  hSimHitLng_[type]->Fill(zp - zFront, energy);
858  hSimHitLng2_[type]->Fill(layer + 1, energy);
859  }
860  if (type == 0) {
861  if (layer < (int)(hSimHitLayEn1EE_.size())) {
862  simHitLayEn1EE_[layer] = energy;
863  hSimHitLayEn1EE_[layer]->Fill(energy);
864  }
865  } else if (type == 1) {
866  if (layer < (int)(hSimHitLayEn1FH_.size())) {
867  simHitLayEn1FH_[layer] = energy;
868  hSimHitLayEn1FH_[layer]->Fill(energy);
869  }
870  } else if (type == 2) {
871  if (layer < (int)(hSimHitLayEn1BH_.size())) {
872  simHitLayEn1BH_[layer] = energy;
873  hSimHitLayEn1BH_[layer]->Fill(energy);
874  }
875  } else {
876  for (unsigned int k = 0; k < idBeams_.size(); ++k) {
877  if (layer + 1 == idBeams_[k]) {
879  hSimHitLayEnBeam_[k]->Fill(energy);
880  break;
881  }
882  }
883  }
884  }
885  for (auto itr : map_hitDepth) {
886  int layer = itr.first - 1;
887  double energy = itr.second;
888 #ifdef EDM_ML_DEBUG
889  edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer + 1 << " " << energy;
890 #endif
891  hSimHitLng1_[type]->Fill(layer + 1, energy);
892  if (type == 0) {
893  if (layer < (int)(hSimHitLayEn2EE_.size())) {
894  simHitLayEn2EE_[layer] = energy;
895  hSimHitLayEn2EE_[layer]->Fill(energy);
896  }
897  } else if (type == 1) {
898  if (layer < (int)(hSimHitLayEn2FH_.size())) {
899  simHitLayEn2FH_[layer] = energy;
900  hSimHitLayEn2FH_[layer]->Fill(energy);
901  }
902  } else if (type == 2) {
903  if (layer < (int)(hSimHitLayEn2BH_.size())) {
904  simHitLayEn2BH_[layer] = energy;
905  hSimHitLayEn2BH_[layer]->Fill(energy);
906  }
907  }
908  }
909 
910  if (type < 3) {
911  for (auto itr : map_hitCell) {
912  uint32_t id = ((itr.second).first);
913  double energy = ((itr.second).second);
914  std::pair<float, float> xy(0, 0);
915  double xx(0);
916  if (type == 2) {
917  xy = AHCalDetId(id).getXY();
918  xx = xy.first;
919  } else {
920  int subdet, zside, layer, sector, subsector, cell;
921  HGCalTestNumbering::unpackHexagonIndex(id, subdet, zside, layer, sector,
922  subsector, cell);
923  xy = hgcons_[type]->locateCell(cell, layer, sector, false);
924  double zp = hgcons_[type]->waferZ(layer, false);
925  xx = (zp < 0) ? -xy.first : xy.first;
926  }
927  hSimHitLat_[type]->Fill(xx, xy.second, energy);
928  }
929  }
930 
931  for (auto itr : map_hitn) {
932  uint32_t id = itr.first;
933  double energy = itr.second;
934  if (type == 0) {
935  simHitCellIdEE_.push_back(id);
936  simHitCellEnEE_.push_back(energy);
937  } else if (type == 1) {
938  simHitCellIdFH_.push_back(id);
939  simHitCellEnFH_.push_back(energy);
940  } else if (type == 2) {
941  simHitCellIdBH_.push_back(id);
942  simHitCellEnBH_.push_back(energy);
943  } else if (type == 3) {
944  simHitCellIdBeam_.push_back(id);
945  simHitCellEnBeam_.push_back(energy);
946  }
947  }
948 }
949 
952  edm::Handle<edm::SimVertexContainer> const& SimVtx) {
953  xBeam_ = yBeam_ = zBeam_ = pBeam_ = -1000000;
954  int vertIndex(-1);
955  for (auto simTrkItr : *SimTk) {
956 #ifdef EDM_ML_DEBUG
957  edm::LogVerbatim("HGCSim")
958  << "Track " << simTrkItr.trackId() << " Vertex "
959  << simTrkItr.vertIndex() << " Type " << simTrkItr.type() << " Charge "
960  << simTrkItr.charge() << " momentum " << simTrkItr.momentum() << " "
961  << simTrkItr.momentum().P();
962 #endif
963  if (vertIndex == -1) {
964  vertIndex = simTrkItr.vertIndex();
965  pBeam_ = simTrkItr.momentum().P();
966  }
967  }
968  if (vertIndex != -1 && vertIndex < (int)SimVtx->size()) {
969  edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin();
970  for (int iv = 0; iv < vertIndex; iv++) simVtxItr++;
971 #ifdef EDM_ML_DEBUG
972  edm::LogVerbatim("HGCSim")
973  << "Vertex " << vertIndex << " position " << simVtxItr->position();
974 #endif
975  xBeam_ = simVtxItr->position().X();
976  yBeam_ = simVtxItr->position().Y();
977  zBeam_ = simVtxItr->position().Z();
978  }
979 }
980 
981 template <class T1>
982 void HGCalTBAnalyzer::analyzeDigi(int type, const T1& detId, uint16_t adc) {
983  DetId id1 = DetId(detId.rawId());
984  GlobalPoint global = hgeom_[type]->getPosition(id1);
985  hDigiOcc_[type]->Fill(global.x(), global.y());
986  hDigiLng_[type]->Fill(global.z());
987  hDigiADC_[type]->Fill(adc);
988 }
989 
992  std::map<int, double> map_hitLayer;
993  std::map<int, std::pair<DetId, double>> map_hitCell;
994  for (auto it : *hits) {
995  DetId detId = it.id();
996  GlobalPoint global = hgeom_[type]->getPosition(detId);
997  double energy = it.energy();
998  int layer = HGCalDetId(detId).layer();
999  int cell = HGCalDetId(detId).cell();
1000  hRecHitOcc_[type]->Fill(global.x(), global.y(), energy);
1001  hRecHitE_[type]->Fill(energy);
1002  if (map_hitLayer.count(layer) != 0) {
1003  map_hitLayer[layer] += energy;
1004  } else {
1005  map_hitLayer[layer] = energy;
1006  }
1007  if (map_hitCell.count(cell) != 0) {
1008  double ee = energy + map_hitCell[cell].second;
1009  map_hitCell[cell] = std::pair<uint32_t, double>(detId, ee);
1010  } else {
1011  map_hitCell[cell] = std::pair<uint32_t, double>(detId, energy);
1012  }
1013 #ifdef EDM_ML_DEBUG
1014  edm::LogVerbatim("HGCSim")
1015  << "RecHit: " << layer << " " << global.x() << " " << global.y() << " "
1016  << global.z() << " " << energy;
1017 #endif
1018  }
1019 
1020  for (auto itr : map_hitLayer) {
1021  int layer = itr.first;
1022  double energy = itr.second;
1023  double zp = hgcons_[type]->waferZ(layer, true);
1024 #ifdef EDM_ML_DEBUG
1025  edm::LogVerbatim("HGCSim")
1026  << "SimHit:Layer " << layer << " " << zp << " " << energy;
1027 #endif
1028  hRecHitLng_[type]->Fill(zp, energy);
1029  hRecHitLng1_[type]->Fill(layer, energy);
1030  }
1031 
1032  for (auto itr : map_hitCell) {
1033  DetId detId = ((itr.second).first);
1034  double energy = ((itr.second).second);
1035  GlobalPoint global = hgeom_[type]->getPosition(detId);
1036  hRecHitLat_[type]->Fill(global.x(), global.y(), energy);
1037  }
1038 }
1039 
1041  edm::Handle<edm::PassiveHitContainer> const& hgcPH, int subdet) {
1042  for (auto v : *hgcPH) {
1043  double energy = v.energy();
1044  std::string name = v.vname();
1045  unsigned int id = v.id();
1046 #ifdef EDM_ML_DEBUG
1047  double time = v.time();
1048  edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::analyzePassiveHits:Energy:"
1049  << "Time:Name:Id : " << energy << ":" << time
1050  << ":" << name << ":" << id;
1051 #endif
1052 
1053  if (subdet == 1) {
1054  hgcPassiveEEEnergy_.push_back(energy);
1055  hgcPassiveEEName_.push_back(name);
1056  hgcPassiveEEID_.push_back(id);
1057  } else if (subdet == 2) {
1058  hgcPassiveFHEnergy_.push_back(energy);
1059  hgcPassiveFHName_.push_back(name);
1060  hgcPassiveFHID_.push_back(id);
1061  } else if (subdet == 3) {
1062  hgcPassiveBHEnergy_.push_back(energy);
1063  hgcPassiveBHName_.push_back(name);
1064  hgcPassiveBHID_.push_back(id);
1065  } else if (subdet == 4) {
1066  hgcPassiveCMSEEnergy_.push_back(energy);
1067  hgcPassiveCMSEName_.push_back(name);
1068  hgcPassiveCMSEID_.push_back(id);
1069  }
1070  }
1071 }
1072 
1073 // define this as a plug-in
std::vector< TH1D * > hSimHitLayEn2EE_
std::string detectorEE_
std::vector< float > simHitLayEn2EE_
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
uint32_t data() const
Definition: HGCSample.h:62
std::vector< float > simHitLayEn2BH_
std::vector< uint32_t > simHitCellIdFH_
std::string detectorBH_
void analyzeSimTracks(edm::Handle< edm::SimTrackContainer > const &SimTk, edm::Handle< edm::SimVertexContainer > const &SimVtx)
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:146
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
int icolAbs() const
Definition: AHCalDetId.h:40
edm::EDGetToken tok_hitrBH_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
TProfile * hSimHitLng1_[3]
TProfile * hSimHitLng2_[3]
TProfile * hRecHitLng_[3]
std::vector< std::string > hgcPassiveFHName_
std::vector< float > simHitLayEn1EE_
std::vector< float > hgcPassiveBHEnergy_
static const int MaxDepth
get the layer number
Definition: AHCalDetId.h:42
static uint32_t packHexagonIndex(int subdet, int z, int lay, int wafer, int celltyp, int cell)
std::string detectorFH_
T y() const
Definition: PV3DBase.h:63
edm::Service< TFileService > fs_
HGCalTBAnalyzer(edm::ParameterSet const &)
void beginRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetToken tok_digiFH_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsFH_
double getZ() const
Definition: AHCalDetId.cc:59
int irow() const
get the row number
Definition: AHCalDetId.cc:34
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
GlobalPoint getPosition(const DetId &id) const
int zside(DetId const &)
std::vector< std::string > hgcPassiveBHName_
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
std::vector< float > hgcPassiveCMSEEnergy_
std::vector< int > hgcPassiveEEID_
std::vector< float > hgcPassiveEEEnergy_
wrapper for a data word
Definition: HGCSample.h:13
int depth() const
Definition: AHCalDetId.cc:46
std::vector< float > simHitCellEnFH_
TProfile2D * hSimHitLat_[3]
U second(std::pair< T, U > const &p)
std::vector< TH1D * > hSimHitLayEn1EE_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsBH_
void analyzeSimHits(int type, std::vector< PCaloHit > &hits, double zFront)
int icol() const
get the column number
Definition: AHCalDetId.cc:40
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< TH1D * > hSimHitLayEn2BH_
unsigned int layers(bool reco) const
std::vector< int > idBeams_
void analyzeRecHits(int type, edm::Handle< HGCRecHitCollection > &hits)
const HGCalGeometry * hgeom_[2]
std::vector< std::string > hgcPassiveCMSEName_
std::pair< double, double > getXY() const
get the local coordinate in the plane and along depth
Definition: AHCalDetId.cc:50
~HGCalTBAnalyzer() override
T z() const
Definition: PV3DBase.h:64
edm::EDGetTokenT< edm::SimTrackContainer > tok_simTk_
void analyze(edm::Event const &, edm::EventSetup const &) override
std::vector< TH1D * > hSimHitLayEnBeam_
const HGCalDDDConstants * hgcons_[2]
edm::EDGetToken tok_hitrFH_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsBeam_
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
std::vector< TH1D * > hSimHitLayEn1FH_
std::vector< uint32_t > simHitCellIdBH_
void analyzePassiveHits(edm::Handle< edm::PassiveHitContainer > const &hgcPh, int subdet)
double waferZ(int layer, bool reco) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int k[5][pyjets_maxn]
Definition: DetId.h:18
std::vector< float > hgcPassiveFHEnergy_
edm::EDGetTokenT< edm::PassiveHitContainer > tok_hgcPHEE_
std::vector< int > hgcPassiveCMSEID_
TProfile2D * hRecHitLat_[3]
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
edm::EDGetTokenT< edm::PassiveHitContainer > tok_hgcPHBH_
int cell() const
get the absolute value of the cell #&#39;s in x and y
Definition: HGCalDetId.h:39
std::vector< float > simHitCellEnBeam_
TProfile * hSimHitLng_[3]
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< std::string > hgcPassiveEEName_
void endRun(edm::Run const &, edm::EventSetup const &) override
std::string detectorBeam_
void analyzeDigi(int type, const T1 &detId, uint16_t adc)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int irowAbs() const
Definition: AHCalDetId.h:35
size_type size() const
std::vector< int > hgcPassiveBHID_
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsEE_
std::vector< float > simHitLayEn1FH_
edm::EDGetToken tok_digiBH_
std::vector< int > hgcPassiveFHID_
std::vector< float > simHitCellEnBH_
static void unpackIndex(const uint32_t &idx, int &det, int &lay, int &x, int &y)
edm::EDGetTokenT< edm::PassiveHitContainer > tok_hgcPHFH_
std::vector< float > simHitLayEn1BH_
std::vector< uint32_t > simHitCellIdEE_
std::vector< TH1D * > hSimHitLayEn1BH_
int zside() const
get the z-side of the cell (1/-1)
Definition: AHCalDetId.h:32
std::vector< float > simHitCellEnEE_
T x() const
Definition: PV3DBase.h:62
std::vector< uint32_t > simHitCellIdBeam_
T const * product() const
Definition: ESHandle.h:86
edm::EDGetToken tok_hitrEE_
std::vector< float > simHitLayEn2FH_
edm::EDGetTokenT< edm::SimVertexContainer > tok_simVtx_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
int layer() const
get the layer #
Definition: HGCalDetId.h:48
TProfile * hRecHitLng1_[3]
Definition: Run.h:45
std::vector< TH1D * > hSimHitLayEn2FH_
void beginJob() override
edm::EDGetToken tok_digiEE_
edm::EDGetTokenT< edm::PassiveHitContainer > tok_hgcPHCMSE_
std::vector< float > simHitLayEnBeam_