CMS 3D CMS Logo

HcalCollapseAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-//
2 // Package: Hcal
3 // Class: HcalCollapseAnalyzer
4 //
13 //
14 // Original Author: Sunanda Banerjee
15 // Created: Thu Dec 26 18:52:02 CST 2017
16 //
17 //
18 
19 // system include files
20 #include <string>
21 #include <vector>
22 
23 // Root objects
24 #include "TH1.h"
25 
26 // user include files
29 
32 
43 
46 
48 public:
49  explicit HcalCollapseAnalyzer(const edm::ParameterSet &);
50  ~HcalCollapseAnalyzer() override {}
51 
52  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
53 
54 private:
55  void analyze(edm::Event const &, edm::EventSetup const &) override;
56  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
57 
58  // ----------member data ---------------------------
60  const int verbosity_;
62  const bool doHE_, doHB_;
63 
66 
69 };
70 
72  : topFolderName_(iConfig.getParameter<std::string>("topFolderName")),
73  verbosity_(iConfig.getUntrackedParameter<int>("verbosity", 0)),
74  recHitHBHE_(iConfig.getUntrackedParameter<edm::InputTag>("recHitHBHE", edm::InputTag("hbhereco"))),
75  preRecHitHBHE_(iConfig.getUntrackedParameter<edm::InputTag>("preRecHitHBHE", edm::InputTag("hbheprereco"))),
76  doHE_(iConfig.getUntrackedParameter<bool>("doHE", true)),
77  doHB_(iConfig.getUntrackedParameter<bool>("doHB", false)) {
78  // define tokens for access
79  tok_hbhe_ = consumes<HBHERecHitCollection>(recHitHBHE_);
80  tok_prehbhe_ = consumes<HBHERecHitCollection>(preRecHitHBHE_);
81 
82  edm::LogVerbatim("Collapse") << "Verbosity " << verbosity_ << " with tags " << recHitHBHE_ << " and "
83  << preRecHitHBHE_ << " and Do " << doHB_ << ":" << doHE_;
84 }
85 
88  desc.add<std::string>("topFolderName", "HcalCollapse");
89  desc.addUntracked<int>("verbosity", 0);
90  desc.addUntracked<edm::InputTag>("recHitHBHE", edm::InputTag("hbhereco"));
91  desc.addUntracked<edm::InputTag>("preRecHitHBHE", edm::InputTag("hbheprereco"));
92  desc.addUntracked<bool>("doHE", true);
93  desc.addUntracked<bool>("doHB", false);
94  descriptions.add("hcalCollapseAnalyzer", desc);
95 }
96 
98  if (verbosity_ > 0)
99  edm::LogVerbatim("Collapse") << "Run " << iEvent.id().run() << " Event " << iEvent.id().event()
100  << " starts ==============";
101 
103  iSetup.get<HcalRecNumberingRecord>().get(htopo);
104  const HcalTopology *theHBHETopology = htopo.product();
105 
107  iEvent.getByToken(tok_hbhe_, hbhereco);
109  iEvent.getByToken(tok_prehbhe_, hbheprereco);
110  if (verbosity_ > 0) {
111  edm::LogVerbatim("Collapse") << "Handle Reco " << hbhereco << " Size " << hbhereco->size();
112  edm::LogVerbatim("Collapse") << "Handle PreReco " << hbheprereco << " Size " << hbheprereco->size();
113  }
114  if (hbhereco.isValid() && hbheprereco.isValid()) {
115  const HBHERecHitCollection *recohbhe = hbhereco.product();
116  const HBHERecHitCollection *prerecohbhe = hbheprereco.product();
117  if (verbosity_ > 0)
118  edm::LogVerbatim("Collapse") << "Size of hbhereco: " << recohbhe->size()
119  << " and hbheprereco: " << prerecohbhe->size();
120  double sfrac = (prerecohbhe->empty()) ? 1 : ((double)(recohbhe->size())) / ((double)(prerecohbhe->size()));
121  h_sfrac->Fill(sfrac);
122  h_size->Fill(recohbhe->size());
123  for (const auto &hit : (*recohbhe)) {
124  HcalDetId id = hit.id();
125  if (((id.subdet() == HcalEndcap) && doHE_) || ((id.subdet() == HcalBarrel) && doHB_)) {
126  h_depth->Fill(id.depth());
127  std::vector<HcalDetId> ids;
128  theHBHETopology->unmergeDepthDetId(id, ids);
129  if (verbosity_ > 0) {
130  edm::LogVerbatim("Collapse") << id << " is derived from " << ids.size() << " components";
131  for (unsigned int k = 0; k < ids.size(); ++k)
132  edm::LogVerbatim("Collapse") << "[" << k << "] " << ids[k];
133  }
134  h_merge->Fill(ids.size());
135  double energy = hit.energy();
136  double etot(0);
137  unsigned int k(0);
138  for (const auto phit : (*prerecohbhe)) {
139  if (std::find(ids.begin(), ids.end(), phit.id()) != ids.end()) {
140  etot += phit.energy();
141  double frac = (energy > 0) ? phit.energy() / energy : 1.0;
142  h_frac->Fill(frac);
143  if (verbosity_ > 0)
144  edm::LogVerbatim("Collapse") << "Frac[" << k << "] " << frac << " for " << phit.id();
145  ++k;
146  }
147  }
148  double frac = (energy > 0) ? etot / energy : 1.0;
149  h_balance->Fill(frac);
150  if (verbosity_ > 0)
151  edm::LogVerbatim("Collapse") << "Total energy " << energy << ":" << etot << ":" << frac;
152  }
153  }
154  }
155 }
156 
158  // Book histograms
160  h_merge = ibooker.book1D("h_merge", "Number of hits merged", 10, 0.0, 10.0);
161  h_size = ibooker.book1D("h_size", "Size of the RecHit collection", 100, 500.0, 1500.0);
162  h_depth = ibooker.book1D("h_depth", "Depth of the Id's used", 10, 0.0, 10.0);
163  h_sfrac = ibooker.book1D("h_sfrac", "Ratio of sizes of preRecHit and RecHit collections", 150, 0.0, 1.5);
164  h_frac = ibooker.book1D("h_frac", "Fraction of energy before collapse", 150, 0.0, 1.5);
165  h_balance = ibooker.book1D("h_balance", "Balance of energy between pre- and post-collapse", 100, 0.5, 1.5);
166 }
167 
hcalcalib_dqm_sourceclient-live_cfg.hbhereco
hbhereco
Definition: hcalcalib_dqm_sourceclient-live_cfg.py:104
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
electrons_cff.bool
bool
Definition: electrons_cff.py:393
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
HcalCollapseAnalyzer::h_balance
MonitorElement * h_balance
Definition: HcalCollapseAnalyzer.cc:68
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
HcalCollapseAnalyzer::doHB_
const bool doHB_
Definition: HcalCollapseAnalyzer.cc:62
ESHandle.h
HcalCollapseAnalyzer::h_size
MonitorElement * h_size
Definition: HcalCollapseAnalyzer.cc:67
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HcalTopology
Definition: HcalTopology.h:26
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::SortedCollection
Definition: SortedCollection.h:49
DQMStore.h
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
HcalRecNumberingRecord.h
HcalCollapseAnalyzer::h_sfrac
MonitorElement * h_sfrac
Definition: HcalCollapseAnalyzer.cc:68
HcalCollapseAnalyzer::verbosity_
const int verbosity_
Definition: HcalCollapseAnalyzer.cc:60
EDAnalyzer.h
HcalCollapseAnalyzer::h_merge
MonitorElement * h_merge
Definition: HcalCollapseAnalyzer.cc:67
HcalBarrel
Definition: HcalAssistant.h:33
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
HcalCollapseAnalyzer::recHitHBHE_
const edm::InputTag recHitHBHE_
Definition: HcalCollapseAnalyzer.cc:61
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DivergingColor.frac
float frac
Definition: DivergingColor.py:175
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalCollapseAnalyzer::doHE_
const bool doHE_
Definition: HcalCollapseAnalyzer.cc:62
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
hcalLocalReco_cff.hbheprereco
hbheprereco
Definition: hcalLocalReco_cff.py:8
HcalCollapseAnalyzer::~HcalCollapseAnalyzer
~HcalCollapseAnalyzer() override
Definition: HcalCollapseAnalyzer.cc:50
Service.h
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
edm::ESHandle< HcalTopology >
HcalCollapseAnalyzer::h_depth
MonitorElement * h_depth
Definition: HcalCollapseAnalyzer.cc:67
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HcalCollapseAnalyzer::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: HcalCollapseAnalyzer.cc:97
HcalCollapseAnalyzer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HcalCollapseAnalyzer.cc:86
EDGetToken.h
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
DQMEDAnalyzer.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
funct::true
true
Definition: Factorize.h:173
HcalCollapseAnalyzer::preRecHitHBHE_
const edm::InputTag preRecHitHBHE_
Definition: HcalCollapseAnalyzer.cc:61
edm::ParameterSet
Definition: ParameterSet.h:47
HcalCollapseAnalyzer::tok_hbhe_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: HcalCollapseAnalyzer.cc:64
Event.h
HcalCollapseAnalyzer
Definition: HcalCollapseAnalyzer.cc:47
HcalDetId.h
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
HcalCollapseAnalyzer::topFolderName_
const std::string topFolderName_
Definition: HcalCollapseAnalyzer.cc:59
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
InputTag.h
HcalTopology.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
HcalEndcap
Definition: HcalAssistant.h:34
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HcalRecHitCollections.h
HcalCollapseAnalyzer::tok_prehbhe_
edm::EDGetTokenT< HBHERecHitCollection > tok_prehbhe_
Definition: HcalCollapseAnalyzer.cc:65
HcalTopology::unmergeDepthDetId
void unmergeDepthDetId(const HcalDetId &id, std::vector< HcalDetId > &ids) const
Definition: HcalTopology.h:168
dqm::implementation::IBooker
Definition: DQMStore.h:43
HcalCollapseAnalyzer::HcalCollapseAnalyzer
HcalCollapseAnalyzer(const edm::ParameterSet &)
Definition: HcalCollapseAnalyzer.cc:71
ParameterSet.h
HcalCollapseAnalyzer::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HcalCollapseAnalyzer.cc:157
HcalCollapseAnalyzer::h_frac
MonitorElement * h_frac
Definition: HcalCollapseAnalyzer.cc:68
edm::Event
Definition: Event.h:73
edm::Log
Definition: MessageLogger.h:70
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
edm::SortedCollection::empty
bool empty() const
Definition: SortedCollection.h:210