CMS 3D CMS Logo

HcalSimHitDump.cc
Go to the documentation of this file.
3 
8 
13 
21 
23 
24 #include <memory>
25 #include <iostream>
26 #include <fstream>
27 #include <vector>
28 #include <map>
29 #include <string>
30 
32 public:
34  ~HcalSimHitDump() override {}
35 
36 protected:
37  void beginJob() override {}
38  void endJob() override {}
39  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
40 
41  void analyzeHits(std::vector<PCaloHit>&);
42 
43 private:
47 };
48 
50  g4Label_ = ps.getUntrackedParameter<std::string>("ModuleLabel", "g4SimHits");
51  hitLab_ = ps.getUntrackedParameter<std::string>("HCCollection", "HcalHits");
52  maxEvent_ = ps.getUntrackedParameter<int>("MaxEvent", 10);
53 
54  // register for data access
55  toks_calo_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hitLab_));
56 
57  edm::LogVerbatim("HitStudy") << "HcalSimHitDump::Module Label: " << g4Label_ << " Hits: " << hitLab_ << " MaxEvent "
58  << maxEvent_;
59 }
60 
62  ++nevt_;
63  edm::LogVerbatim("HitStudy") << "HcalSimHitDump::Serial # " << nevt_ << " Run # " << e.id().run() << " Event # "
64  << e.id().event();
65 
66  if (nevt_ <= maxEvent_) {
67  std::vector<PCaloHit> hcHits;
69  e.getByToken(toks_calo_, hitsCalo);
70  if (hitsCalo.isValid()) {
71  edm::LogVerbatim("HitStudy") << "HcalValidation: get valid hist for Hcal";
72  std::vector<PCaloHit> caloHits;
73  caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
74  edm::LogVerbatim("HitStudy") << "HcalValidation: Hit buffer " << caloHits.size();
75  analyzeHits(caloHits);
76  }
77  }
78 }
79 
80 void HcalSimHitDump::analyzeHits(std::vector<PCaloHit>& hits) {
81  bool testN(false);
82  for (unsigned int k = 1; k < hits.size(); ++k) {
83  int det = (((hits[k].id()) >> 28) & 0xF);
84  if (det != 4) {
85  testN = true;
86  break;
87  }
88  }
89  edm::LogVerbatim("HitStudy") << "Hit ID uses numbering scheme " << testN << " (0 normal; 1 test)";
90 
91  //Now the dump
92  for (unsigned int i = 0; i < hits.size(); i++) {
93  double edep = hits[i].energy();
94  double time = hits[i].time();
95  unsigned int id_ = hits[i].id();
96  if (testN) {
97  int det, z, depth, eta, phi, lay;
99  std::string sub("HX");
100  if (det == 1)
101  sub = "HB";
102  else if (det == 2)
103  sub = "HE";
104  else if (det == 3)
105  sub = "HO";
106  else if (det == 4)
107  sub = "HF";
108  else if (det == 5)
109  sub = "HT";
110  int side = (z == 0) ? (-1) : (1);
111  edm::LogVerbatim("HitStudy") << "[" << i << "] (" << sub << " " << side * eta << "," << phi << "," << depth << ","
112  << lay << ") E " << edep << " T " << time;
113  } else {
114  edm::LogVerbatim("HitStudy") << "[" << i << "] " << HcalDetId(id_) << " E " << edep << " T " << time;
115  }
116  }
117 }
118 
119 //define this as a plug-in
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
edm::EDGetTokenT< edm::PCaloHitContainer >
PSimHitContainer.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
CaloHitID.h
HcalTestNumbering.h
edm::Handle
Definition: AssociativeIterator.h:50
HcalSimHitDump::endJob
void endJob() override
Definition: HcalSimHitDump.cc:38
HcalSimHitDump::toks_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > toks_calo_
Definition: HcalSimHitDump.cc:45
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
MakerMacros.h
PSimHit.h
HcalTestNumbering::unpackHcalIndex
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
Definition: HcalTestNumbering.cc:18
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalSimHitDump::beginJob
void beginJob() override
Definition: HcalSimHitDump.cc:37
PVValHelper::eta
Definition: PVValidationHelpers.h:69
DDAxes::z
HcalSimHitDump
Definition: HcalSimHitDump.cc:31
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HcalSimHitDump::g4Label_
std::string g4Label_
Definition: HcalSimHitDump.cc:44
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
HcalDetId.h
PCaloHit.h
HcalSimHitDump::~HcalSimHitDump
~HcalSimHitDump() override
Definition: HcalSimHitDump.cc:34
HcalDetId
Definition: HcalDetId.h:12
HcalSimHitDump::HcalSimHitDump
HcalSimHitDump(const edm::ParameterSet &ps)
Definition: HcalSimHitDump.cc:49
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
InputTag.h
HcalSimHitDump::hitLab_
std::string hitLab_
Definition: HcalSimHitDump.cc:44
DDAxes::phi
HcalSimHitDump::maxEvent_
int maxEvent_
Definition: HcalSimHitDump.cc:46
HcalSimHitDump::analyzeHits
void analyzeHits(std::vector< PCaloHit > &)
Definition: HcalSimHitDump.cc:80
Frameworkfwd.h
EventSetup.h
Exception.h
PCaloHitContainer.h
ParameterSet.h
HepMCProduct.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
ntuplemaker.time
time
Definition: ntuplemaker.py:310
edm::Event
Definition: Event.h:73
HcalSimHitDump::nevt_
int nevt_
Definition: HcalSimHitDump.cc:46
edm::InputTag
Definition: InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HcalSimHitDump::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: HcalSimHitDump.cc:61