CMS 3D CMS Logo

HGCalHitIdCheck.cc
Go to the documentation of this file.
3 
7 
13 
16 
19 
23 
24 #include <map>
25 #include <string>
26 #include <vector>
27 
29 public:
31  ~HGcalHitIdCheck() override {}
32  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
33 
34 protected:
35  void analyze(edm::Event const&, edm::EventSetup const&) override;
36  void beginJob() override {}
37  void endJob() override {}
38 
39 private:
41  const int verbosity_;
44 };
45 
47  : g4Label_(ps.getParameter<std::string>("moduleLabel")),
48  caloHitSource_(ps.getParameter<std::string>("caloHitSource")),
49  nameSense_(ps.getParameter<std::string>("nameSense")),
50  nameDetector_(ps.getParameter<std::string>("nameDevice")),
51  verbosity_(ps.getParameter<int>("Verbosity")),
52  tok_calo_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, caloHitSource_))),
54  edm::LogVerbatim("HitStudy") << "Test Hit ID for " << nameDetector_ << " using SimHits for " << nameSense_
55  << " with module Label: " << g4Label_ << " Hits: " << caloHitSource_;
56 }
57 
60  desc.add<std::string>("moduleLabel", "g4SimHits");
61  desc.add<std::string>("caloHitSource", "HGCHitsEE");
62  desc.add<std::string>("nameSense", "HGCalEESensitive");
63  desc.add<std::string>("nameDevice", "HGCal EE");
64  desc.add<int>("Verbosity", 0);
65  descriptions.add("hgcalHitIdCheckEE", desc);
66 }
67 
69  if (verbosity_ > 0)
70  edm::LogVerbatim("HitStudy") << "Run = " << e.id().run() << " Event = " << e.id().event();
71 
72  // get hcalGeometry
73  const HGCalGeometry* geom = &iS.getData(geomToken_);
74  const std::vector<DetId>& validIds = geom->getValidDetIds();
75 
77  e.getByToken(tok_calo_, hitsCalo);
78  bool getHits = (hitsCalo.isValid());
79  uint32_t nhits = (getHits) ? hitsCalo->size() : 0;
80  uint32_t good(0), all(0);
81  if (verbosity_ > 1)
82  edm::LogVerbatim("HitStudy") << "HGcalHitIdCheck: Input flags Hits " << getHits << " with " << nhits << " hits";
83 
84  if (getHits) {
85  std::vector<PCaloHit> hits;
86  hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end());
87  if (!hits.empty()) {
88  for (auto hit : hits) {
89  ++all;
90  DetId id(hit.id());
91  if (std::find(validIds.begin(), validIds.end(), id) != validIds.end()) {
92  ++good;
93  if (verbosity_ > 2) {
94  if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) {
95  edm::LogVerbatim("HitStudy") << "Hit[" << all << ":" << good << "]" << HGCSiliconDetId(id);
96  } else if (id.det() == DetId::HGCalHSc) {
97  edm::LogVerbatim("HitStudy") << "Hit[" << all << ":" << good << "]" << HGCScintillatorDetId(id);
98  } else {
99  edm::LogVerbatim("HitStudy") << "Hit[" << all << ":" << good << "]" << std::hex << id.rawId() << std::dec;
100  }
101  }
102  } else {
103  if (verbosity_ > 0) {
104  if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) {
105  edm::LogVerbatim("HitStudy")
106  << "Hit[" << all << ":" << good << "]" << HGCSiliconDetId(id) << " not valid *****";
107  } else if (id.det() == DetId::HGCalHSc) {
108  HGCScintillatorDetId hid1(id);
109  HGCScintillatorDetId hid2(hid1.type(), hid1.layer(), hid1.ring(), hid1.iphi(), false, 0);
110  bool ok = (std::find(validIds.begin(), validIds.end(), DetId(hid2)) != validIds.end());
111  edm::LogVerbatim("HitStudy") << "Hit[" << all << ":" << good << "]" << hid1 << " not valid ***** but "
112  << hid2 << " in list " << ok;
113  } else {
114  edm::LogVerbatim("HitStudy")
115  << "Hit[" << all << ":" << good << "]" << std::hex << id.rawId() << std::dec << " not valid *****";
116  }
117  }
118  }
119  }
120  }
121  }
122  edm::LogVerbatim("HitStudy") << "Total hits = " << all << ":" << nhits << " Good DetIds = " << good
123  << " Invalid DetIds = " << (all - good);
124 }
125 
126 //define this as a plug-in
ConfigurationDescriptions.h
good
const auto good
min quality of good
Definition: CAHitNtupletGeneratorKernelsImpl.h:760
EDAnalyzer.h
HGCScintillatorDetId::iphi
int iphi() const
get the phi index
Definition: HGCScintillatorDetId.cc:58
MessageLogger.h
HGCScintillatorDetId::ring
int ring() const
get the eta index
Definition: HGCScintillatorDetId.cc:44
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
HGCScintillatorDetId.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HGcalHitIdCheck::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: HGCalHitIdCheck.cc:68
ESInputTag
edm::EDGetTokenT< edm::PCaloHitContainer >
edm
HLT enums.
Definition: AlignableModifier.h:19
HGCSiliconDetId.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::Handle
Definition: AssociativeIterator.h:50
HGCSiliconDetId
Definition: HGCSiliconDetId.h:22
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
HGCScintillatorDetId::layer
int layer() const
get the layer #
Definition: HGCScintillatorDetId.h:50
DetId
Definition: DetId.h:17
DetId::HGCalHSi
Definition: DetId.h:33
DetId::HGCalEE
Definition: DetId.h:32
MakerMacros.h
HGCalTopology.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HGcalHitIdCheck::endJob
void endJob() override
Definition: HGCalHitIdCheck.cc:37
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
nhits
Definition: HIMultiTrackSelector.h:42
HGCalGeometry
Definition: HGCalGeometry.h:29
HGcalHitIdCheck::HGcalHitIdCheck
HGcalHitIdCheck(const edm::ParameterSet &ps)
Definition: HGCalHitIdCheck.cc:46
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HGCalGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HGcalHitIdCheck
Definition: HGCalHitIdCheck.cc:28
HGcalHitIdCheck::verbosity_
const int verbosity_
Definition: HGCalHitIdCheck.cc:41
PCaloHit.h
HGcalHitIdCheck::tok_calo_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
Definition: HGCalHitIdCheck.cc:42
createfilelist.int
int
Definition: createfilelist.py:10
HGcalHitIdCheck::g4Label_
const std::string g4Label_
Definition: HGCalHitIdCheck.cc:40
HGCScintillatorDetId::type
int type() const
get/set the type
Definition: HGCScintillatorDetId.h:43
HGcalHitIdCheck::beginJob
void beginJob() override
Definition: HGCalHitIdCheck.cc:36
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
HGcalHitIdCheck::caloHitSource_
const std::string caloHitSource_
Definition: HGCalHitIdCheck.cc:40
edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
HGcalHitIdCheck::nameDetector_
const std::string nameDetector_
Definition: HGCalHitIdCheck.cc:40
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
HGcalHitIdCheck::~HGcalHitIdCheck
~HGcalHitIdCheck() override
Definition: HGCalHitIdCheck.cc:31
Frameworkfwd.h
HGCScintillatorDetId
Definition: HGCScintillatorDetId.h:23
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
DetId::HGCalHSc
Definition: DetId.h:34
HGcalHitIdCheck::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HGCalHitIdCheck.cc:58
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
EventSetup.h
Exception.h
PCaloHitContainer.h
HGcalHitIdCheck::geomToken_
const edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > geomToken_
Definition: HGCalHitIdCheck.cc:43
ParameterSet.h
HGcalHitIdCheck::nameSense_
const std::string nameSense_
Definition: HGCalHitIdCheck.cc:40
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
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37