CMS 3D CMS Logo

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