CMS 3D CMS Logo

HcalTestSimHitID.cc
Go to the documentation of this file.
3 
13 
22 
23 #include <memory>
24 #include <iostream>
25 #include <fstream>
26 #include <vector>
27 #include <string>
28 
30 public:
32 
33  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
34 
35 protected:
36  void beginJob() override {}
37  void endJob() override {}
38  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
39 
40 private:
42  const bool testN_, dumpHits_;
43  const int maxEvent_;
44  int nevt_;
46 };
47 
49  : g4Label_(ps.getUntrackedParameter<std::string>("moduleLabel", "g4SimHits")),
50  hitLab_(ps.getUntrackedParameter<std::string>("hcCollection", "HcalHits")),
51  testN_(ps.getUntrackedParameter<bool>("testNumbering", false)),
52  dumpHits_(ps.getUntrackedParameter<bool>("dumpHits", false)),
53  maxEvent_(ps.getUntrackedParameter<int>("maxEvent", 100)),
54  nevt_(0) {
55  // register for data access
56  toks_calo_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hitLab_));
57 
58  std::cout << "HcalTestSimHitID::Module Label: " << g4Label_ << " Hits: " << hitLab_ << " MaxEvent: " << maxEvent_
59  << " Numbering scheme: " << testN_ << " (0 normal; 1 test)\n";
60 }
61 
64  desc.addUntracked<std::string>("moduleLabel", "g4SimHits");
65  desc.addUntracked<std::string>("hcCollection", "HcalHits");
66  desc.addUntracked<bool>("testNumbering", false);
67  desc.addUntracked<bool>("dumpHits", false);
68  desc.addUntracked<int>("maxEvent", 100);
69  descriptions.add("hcalGeometryDetIdTester", desc);
70 }
71 
73  ++nevt_;
74  std::cout << "HcalTestSimHitID::Serial # " << nevt_ << " Run # " << e.id().run() << " Event # " << e.id().event()
75  << std::endl;
77  iS.get<HcalRecNumberingRecord>().get(pHRNDC);
78  const HcalDDDRecConstants* hcr = static_cast<const HcalDDDRecConstants*>(&(*pHRNDC));
80  iS.get<HcalRecNumberingRecord>().get(htopo);
81  const HcalTopology* theHBHETopology = htopo.product();
82 
83  if (nevt_ <= maxEvent_) {
84  std::vector<PCaloHit> hcHits;
86  e.getByToken(toks_calo_, hitsCalo);
87  if (hitsCalo.isValid()) {
88  std::vector<PCaloHit> hits;
89  hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end());
90  std::cout << "HcalValidation: Hit buffer " << hits.size() << std::endl;
91 
92  //Now the testing
93  unsigned int good(0);
94  for (unsigned int i = 0; i < hits.size(); i++) {
95  unsigned int id = hits[i].id();
96  HcalDetId hid;
97  if (testN_) {
98  hid = HcalDetId(HcalHitRelabeller::relabel(id, hcr));
99  } else {
100  hid = HcalDetId(id);
101  }
102  if (theHBHETopology->validHcal(hid)) {
103  ++good;
104  if (dumpHits_)
105  std::cout << "Hit[" << i << "] " << hid << " \n";
106  } else {
107  std::cout << "Hit[" << i << "] " << hid << " ***** ERROR *****\n";
108  }
109  }
110  std::cout << "HcalTestSimHitID:: " << good << " among " << hits.size() << " hits\n";
111  }
112  }
113 }
114 
115 //define this as a plug-in
ConfigurationDescriptions.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
HcalTestSimHitID::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: HcalTestSimHitID.cc:72
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
HcalTestSimHitID::toks_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > toks_calo_
Definition: HcalTestSimHitID.cc:45
MessageLogger.h
HcalTopology::validHcal
bool validHcal(const HcalDetId &id) const
Definition: HcalTopology.cc:230
funct::false
false
Definition: Factorize.h:34
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
edm::EDGetTokenT< edm::PCaloHitContainer >
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalTopology
Definition: HcalTopology.h:26
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HcalTestSimHitID::HcalTestSimHitID
HcalTestSimHitID(const edm::ParameterSet &ps)
Definition: HcalTestSimHitID.cc:48
HcalRecNumberingRecord.h
EDAnalyzer.h
HcalTestNumbering.h
HcalTestSimHitID::maxEvent_
const int maxEvent_
Definition: HcalTestSimHitID.cc:43
edm::Handle
Definition: AssociativeIterator.h:50
HcalTestSimHitID::dumpHits_
const bool dumpHits_
Definition: HcalTestSimHitID.cc:42
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
HcalTestSimHitID::endJob
void endJob() override
Definition: HcalTestSimHitID.cc:37
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
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
HcalTestSimHitID::nevt_
int nevt_
Definition: HcalTestSimHitID.cc:44
edm::ESHandle
Definition: DTSurvey.h:22
HcalTestSimHitID::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HcalTestSimHitID.cc:62
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
HcalTestSimHitID::testN_
const bool testN_
Definition: HcalTestSimHitID.cc:42
HcalDetId.h
HcalHitRelabeller.h
PCaloHit.h
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
get
#define get
InputTag.h
HcalTestSimHitID::beginJob
void beginJob() override
Definition: HcalTestSimHitID.cc:36
HcalHitRelabeller::relabel
DetId relabel(const uint32_t testId) const
Definition: HcalHitRelabeller.cc:49
HcalTopology.h
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
HcalDDDRecConstants.h
HcalTestSimHitID
Definition: HcalTestSimHitID.cc:29
EventSetup.h
Exception.h
PCaloHitContainer.h
HcalTestSimHitID::hitLab_
const std::string hitLab_
Definition: HcalTestSimHitID.cc:41
HcalDDDRecConstants
Definition: HcalDDDRecConstants.h:23
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
HcalTestSimHitID::g4Label_
const std::string g4Label_
Definition: HcalTestSimHitID.cc:41
edm::InputTag
Definition: InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37