CMS 3D CMS Logo

HcalSimHitDump.cc
Go to the documentation of this file.
3 
7 
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  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
36 
37 protected:
38  void beginJob() override {}
39  void endJob() override {}
40  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
41 
42  void analyzeHits(std::vector<PCaloHit>&);
43 
44 private:
46  const int maxEvent_;
47  const bool testNumber_;
49  int nevt_;
50 };
51 
53  : g4Label_(ps.getParameter<std::string>("ModuleLabel")),
54  hitLab_(ps.getParameter<std::string>("HCCollection")),
55  maxEvent_(ps.getParameter<int>("MaxEvent")),
56  testNumber_(ps.getParameter<bool>("TestNumber")),
57  nevt_(0) {
58  // register for data access
59  toks_calo_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hitLab_));
60 
61  edm::LogVerbatim("HitStudy") << "HcalSimHitDump::Module Label: " << g4Label_ << " Hits: " << hitLab_ << " MaxEvent "
62  << maxEvent_ << " TestNumbering " << testNumber_;
63 }
64 
67  desc.add<std::string>("ModuleLabel", "g4SimHits");
68  desc.add<std::string>("HCCollection", "HcalHits");
69  desc.add<int>("MaxEvent", 10);
70  desc.add<bool>("TestNumber", true);
71  descriptions.add("hcalSimHitDump", desc);
72 }
73 
75  ++nevt_;
76  edm::LogVerbatim("HitStudy") << "HcalSimHitDump::Serial # " << nevt_ << " Run # " << e.id().run() << " Event # "
77  << e.id().event();
78 
79  if (nevt_ <= maxEvent_) {
80  std::vector<PCaloHit> hcHits;
82  e.getByToken(toks_calo_, hitsCalo);
83  if (hitsCalo.isValid()) {
84  edm::LogVerbatim("HitStudy") << "HcalValidation: get valid hist for Hcal";
85  std::vector<PCaloHit> caloHits;
86  caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
87  edm::LogVerbatim("HitStudy") << "HcalValidation: Hit buffer " << caloHits.size();
88  analyzeHits(caloHits);
89  }
90  }
91 }
92 
93 void HcalSimHitDump::analyzeHits(std::vector<PCaloHit>& hits) {
94  //Now the dump
95  for (unsigned int i = 0; i < hits.size(); i++) {
96  double edep = hits[i].energy();
97  double time = hits[i].time();
98  unsigned int id_ = hits[i].id();
99  if (testNumber_) {
100  int det, z, depth, eta, phi, lay;
101  HcalTestNumbering::unpackHcalIndex(id_, det, z, depth, eta, phi, lay);
102  std::string sub("HX");
103  if (det == 1)
104  sub = "HB";
105  else if (det == 2)
106  sub = "HE";
107  else if (det == 3)
108  sub = "HO";
109  else if (det == 4)
110  sub = "HF";
111  else if (det == 5)
112  sub = "HT";
113  int side = (z == 0) ? (-1) : (1);
114  edm::LogVerbatim("HitStudy") << "[" << i << "] (" << sub << " " << side * eta << "," << phi << "," << depth << ","
115  << lay << ") E " << edep << " T " << time;
116  } else {
117  edm::LogVerbatim("HitStudy") << "[" << i << "] " << HcalDetId(id_) << " E " << edep << " T " << time;
118  }
119  }
120 }
121 
122 //define this as a plug-in
ConfigurationDescriptions.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
EDAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HcalSimHitDump::g4Label_
const std::string g4Label_
Definition: HcalSimHitDump.cc:45
edm::EDGetTokenT< edm::PCaloHitContainer >
PSimHitContainer.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
protons_cff.time
time
Definition: protons_cff.py:35
HcalSimHitDump::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HcalSimHitDump.cc:65
CaloHitID.h
HcalTestNumbering.h
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle
Definition: AssociativeIterator.h:50
HcalSimHitDump::endJob
void endJob() override
Definition: HcalSimHitDump.cc:39
HcalSimHitDump::toks_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > toks_calo_
Definition: HcalSimHitDump.cc:48
HcalSimHitDump::hitLab_
const std::string hitLab_
Definition: HcalSimHitDump.cc:45
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
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HcalSimHitDump::beginJob
void beginJob() override
Definition: HcalSimHitDump.cc:38
PVValHelper::eta
Definition: PVValidationHelpers.h:70
DDAxes::z
HcalSimHitDump
Definition: HcalSimHitDump.cc:31
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HcalSimHitDump::testNumber_
const bool testNumber_
Definition: HcalSimHitDump.cc:47
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HcalDetId.h
PCaloHit.h
HcalSimHitDump::~HcalSimHitDump
~HcalSimHitDump() override
Definition: HcalSimHitDump.cc:34
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
HcalSimHitDump::HcalSimHitDump
HcalSimHitDump(const edm::ParameterSet &ps)
Definition: HcalSimHitDump.cc:52
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
DDAxes::phi
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
HcalSimHitDump::analyzeHits
void analyzeHits(std::vector< PCaloHit > &)
Definition: HcalSimHitDump.cc:93
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HcalSimHitDump::maxEvent_
const int maxEvent_
Definition: HcalSimHitDump.cc:46
EventSetup.h
Exception.h
PCaloHitContainer.h
ParameterSet.h
HepMCProduct.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
HcalSimHitDump::nevt_
int nevt_
Definition: HcalSimHitDump.cc:49
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:74