CMS 3D CMS Logo

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