CMS 3D CMS Logo

HcalTestSimHitID.cc
Go to the documentation of this file.
3 
12 
25 
26 #include <memory>
27 #include <iostream>
28 #include <fstream>
29 #include <vector>
30 #include <string>
31 
33 public:
35 
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 private:
45  const bool testN_, dumpHits_;
46  const int maxEvent_;
50  int nevt_;
52 };
53 
55  : g4Label_(ps.getUntrackedParameter<std::string>("moduleLabel", "g4SimHits")),
56  hitLab_(ps.getUntrackedParameter<std::string>("hcCollection", "HcalHits")),
57  testN_(ps.getUntrackedParameter<bool>("testNumbering", false)),
58  dumpHits_(ps.getUntrackedParameter<bool>("dumpHits", false)),
59  maxEvent_(ps.getUntrackedParameter<int>("maxEvent", 100)),
63  nevt_(0) {
64  // register for data access
65  toks_calo_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hitLab_));
66 
67  edm::LogVerbatim("HcalSim") << "HcalTestSimHitID::Module Label: " << g4Label_ << " Hits: " << hitLab_
68  << " MaxEvent: " << maxEvent_ << " Numbering scheme: " << testN_ << " (0 normal; 1 test)";
69 }
70 
73  desc.addUntracked<std::string>("moduleLabel", "g4SimHits");
74  desc.addUntracked<std::string>("hcCollection", "HcalHits");
75  desc.addUntracked<bool>("testNumbering", false);
76  desc.addUntracked<bool>("dumpHits", false);
77  desc.addUntracked<int>("maxEvent", 100);
78  descriptions.add("hcalTestSimHitID", desc);
79 }
80 
82  ++nevt_;
83  edm::LogVerbatim("HcalSim") << "HcalTestSimHitID::Serial # " << nevt_ << " Run # " << e.id().run() << " Event # "
84  << e.id().event();
85  const HcalDDDRecConstants* hcr = &iS.getData(tok_hrdd_);
86  const HcalTopology* theHBHETopology = &iS.getData(tok_topo_);
87  const CaloGeometry* caloGeom = &iS.getData(tok_geom_);
88  const HcalGeometry* hcalGeom =
89  static_cast<const HcalGeometry*>(caloGeom->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
90 
91  if (nevt_ <= maxEvent_) {
92  std::vector<PCaloHit> hcHits;
94  e.getByToken(toks_calo_, hitsCalo);
95  if (hitsCalo.isValid()) {
96  std::vector<PCaloHit> hits;
97  hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end());
98  edm::LogVerbatim("HcalSim") << "HcalValidation: Hit buffer " << hits.size();
99 
100  //Now the testing
101  unsigned int good(0);
102  for (unsigned int i = 0; i < hits.size(); i++) {
103  unsigned int id = hits[i].id();
104  HcalDetId hid;
105  GlobalPoint p1, p2;
106  if (testN_) {
107  p1 = hcalGeom->getPosition(id, true);
108  hid = HcalDetId(HcalHitRelabeller::relabel(id, hcr));
109  } else {
110  hid = HcalDetId(id);
111  }
112  p2 = hcalGeom->getPosition(DetId(hid));
113  if (theHBHETopology->validHcal(hid)) {
114  ++good;
115  if (dumpHits_) {
116  edm::LogVerbatim("HcalSim") << "Hit[" << i << "] " << hid;
117  if (testN_)
118  edm::LogVerbatim("HcalSim") << "Test " << p1 << " from HcalDetId " << p2;
119  }
120  } else {
121  edm::LogVerbatim("HcalSim") << "Hit[" << i << "] " << hid << " ***** ERROR *****";
122  }
123  }
124  edm::LogVerbatim("HcalSim") << "\nHcalTestSimHitID:: " << good << " among " << hits.size() << " hits";
125  }
126  }
127 }
128 
129 //define this as a plug-in
ConfigurationDescriptions.h
good
const auto good
min quality of good
Definition: CAHitNtupletGeneratorKernelsImpl.h:760
HcalTestSimHitID::tok_topo_
const edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_topo_
Definition: HcalTestSimHitID.cc:48
HcalTestSimHitID::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: HcalTestSimHitID.cc:81
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
HcalTestSimHitID::toks_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > toks_calo_
Definition: HcalTestSimHitID.cc:51
MessageLogger.h
HcalTopology::validHcal
bool validHcal(const HcalDetId &id) const
Definition: HcalTopology.cc:230
funct::false
false
Definition: Factorize.h:29
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
edm::EDGetTokenT< edm::PCaloHitContainer >
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
HcalTopology
Definition: HcalTopology.h:26
DetId::Hcal
Definition: DetId.h:28
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
HcalTestSimHitID::HcalTestSimHitID
HcalTestSimHitID(const edm::ParameterSet &ps)
Definition: HcalTestSimHitID.cc:54
HcalRecNumberingRecord.h
EDAnalyzer.h
HcalTestNumbering.h
HcalBarrel
Definition: HcalAssistant.h:33
HcalTestSimHitID::maxEvent_
const int maxEvent_
Definition: HcalTestSimHitID.cc:46
edm::Handle
Definition: AssociativeIterator.h:50
HcalTestSimHitID::dumpHits_
const bool dumpHits_
Definition: HcalTestSimHitID.cc:45
HcalGeometry.h
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
HcalTestSimHitID::endJob
void endJob() override
Definition: HcalTestSimHitID.cc:40
DetId
Definition: DetId.h:17
MakerMacros.h
CaloGeometry
Definition: CaloGeometry.h:21
HcalTestSimHitID::tok_geom_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
Definition: HcalTestSimHitID.cc:49
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:50
p2
double p2[4]
Definition: TauolaWrapper.h:90
Point3DBase< float, GlobalTag >
HcalTestSimHitID::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HcalTestSimHitID.cc:71
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
CaloGeometryRecord.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
CaloSubdetectorGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
HcalGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Definition: HcalGeometry.cc:179
Event.h
HcalTestSimHitID::testN_
const bool testN_
Definition: HcalTestSimHitID.cc:45
HcalDetId.h
HcalHitRelabeller.h
PCaloHit.h
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
p1
double p1[4]
Definition: TauolaWrapper.h:89
edm::EventSetup
Definition: EventSetup.h:58
edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
HcalTestSimHitID::beginJob
void beginJob() override
Definition: HcalTestSimHitID.cc:39
HcalHitRelabeller::relabel
DetId relabel(const uint32_t testId) const
Definition: HcalHitRelabeller.cc:49
HcalTopology.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CaloGeometry.h
HcalDDDRecConstants.h
HcalTestSimHitID
Definition: HcalTestSimHitID.cc:32
EventSetup.h
Exception.h
PCaloHitContainer.h
HcalTestSimHitID::hitLab_
const std::string hitLab_
Definition: HcalTestSimHitID.cc:44
HcalDDDRecConstants
Definition: HcalDDDRecConstants.h:23
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
HcalGeometry
Definition: HcalGeometry.h:17
HcalTestSimHitID::g4Label_
const std::string g4Label_
Definition: HcalTestSimHitID.cc:44
edm::InputTag
Definition: InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HcalTestSimHitID::tok_hrdd_
const edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_hrdd_
Definition: HcalTestSimHitID.cc:47