CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HcalCollapseAnalyzer Class Reference

#include <DQMOffline/Hcal/src/HcalCollapseAnalyzer.cc>

Inheritance diagram for HcalCollapseAnalyzer:
one::DQMEDAnalyzer< T > one::dqmimplementation::DQMBaseClass< T... >

Public Member Functions

 HcalCollapseAnalyzer (const edm::ParameterSet &)
 
 ~HcalCollapseAnalyzer () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (edm::Event const &, edm::EventSetup const &) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 

Private Attributes

const bool doHB_
 
const bool doHE_
 
MonitorElementh_balance
 
MonitorElementh_depth
 
MonitorElementh_frac
 
MonitorElementh_merge
 
MonitorElementh_sfrac
 
MonitorElementh_size
 
const edm::InputTag preRecHitHBHE_
 
const edm::InputTag recHitHBHE_
 
edm::EDGetTokenT< HBHERecHitCollectiontok_hbhe_
 
edm::EDGetTokenT< HBHERecHitCollectiontok_prehbhe_
 
const std::string topFolderName_
 
const int verbosity_
 

Detailed Description

Description: Studies the collapsing of HcalRecHits

Implementation: <Notes on="" implementation>="">

Definition at line 47 of file HcalCollapseAnalyzer.cc.

Constructor & Destructor Documentation

HcalCollapseAnalyzer::HcalCollapseAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 72 of file HcalCollapseAnalyzer.cc.

References doHB_, doHE_, preRecHitHBHE_, recHitHBHE_, tok_hbhe_, tok_prehbhe_, and verbosity_.

72  :
73  topFolderName_(iConfig.getParameter<std::string>("topFolderName")),
74  verbosity_(iConfig.getUntrackedParameter<int>("verbosity",0)),
75  recHitHBHE_(iConfig.getUntrackedParameter<edm::InputTag>("recHitHBHE",edm::InputTag("hbhereco"))),
76  preRecHitHBHE_(iConfig.getUntrackedParameter<edm::InputTag>("preRecHitHBHE",edm::InputTag("hbheprereco"))),
77  doHE_(iConfig.getUntrackedParameter<bool>("doHE", true)),
78  doHB_(iConfig.getUntrackedParameter<bool>("doHB", false)) {
79 
80  // define tokens for access
81  tok_hbhe_ = consumes<HBHERecHitCollection>(recHitHBHE_);
82  tok_prehbhe_ = consumes<HBHERecHitCollection>(preRecHitHBHE_);
83 
84  edm::LogVerbatim("Collapse") << "Verbosity " << verbosity_ << " with tags "
85  << recHitHBHE_ << " and " << preRecHitHBHE_
86  << " and Do " << doHB_ << ":" << doHE_;
87 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const edm::InputTag preRecHitHBHE_
edm::EDGetTokenT< HBHERecHitCollection > tok_prehbhe_
const edm::InputTag recHitHBHE_
const std::string topFolderName_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
HcalCollapseAnalyzer::~HcalCollapseAnalyzer ( )
inlineoverride

Definition at line 51 of file HcalCollapseAnalyzer.cc.

References analyze(), bookHistograms(), and fillDescriptions().

51 { }

Member Function Documentation

void HcalCollapseAnalyzer::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 100 of file HcalCollapseAnalyzer.cc.

References egammaForCoreTracking_cff::depth, doHB_, doHE_, edm::EventID::event(), MonitorElement::Fill(), spr::find(), cropTnPTrees::frac, edm::EventSetup::get(), edm::Event::getByToken(), h_balance, h_depth, h_frac, h_merge, h_sfrac, h_size, hcalLocalReco_cff::hbheprereco, HiIsolationCommonParameters_cff::hbhereco, HcalBarrel, HcalEndcap, edm::EventBase::id(), hit::id, photons_cff::ids, edm::HandleBase::isValid(), gen::k, edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::EventID::run(), edm::SortedCollection< T, SORT >::size(), tok_hbhe_, tok_prehbhe_, HcalTopology::unmergeDepthDetId(), and verbosity_.

Referenced by ~HcalCollapseAnalyzer().

100  {
101  if (verbosity_ > 0)
102  edm::LogVerbatim("Collapse") << "Run " << iEvent.id().run() << " Event "
103  << iEvent.id().event() << " starts ==============";
104 
106  iSetup.get<HcalRecNumberingRecord>().get(htopo);
107  const HcalTopology* theHBHETopology = htopo.product();
108 
110  iEvent.getByToken(tok_hbhe_, hbhereco);
112  iEvent.getByToken(tok_prehbhe_, hbheprereco);
113  if (verbosity_ > 0) {
114  edm::LogVerbatim("Collapse") << "Handle Reco " << hbhereco << " Size "
115  << hbhereco->size();
116  edm::LogVerbatim("Collapse") << "Handle PreReco " << hbheprereco <<" Size "
117  << hbheprereco->size();
118  }
119  if (hbhereco.isValid() && hbheprereco.isValid()) {
120  const HBHERecHitCollection* recohbhe = hbhereco.product();
121  const HBHERecHitCollection* prerecohbhe = hbheprereco.product();
122  if (verbosity_ > 0)
123  edm::LogVerbatim("Collapse") << "Size of hbhereco: " << recohbhe->size()
124  << " and hbheprereco: " << prerecohbhe->size();
125  double sfrac = (prerecohbhe->size() == 0) ? 1 :
126  ((double)(recohbhe->size()))/((double)(prerecohbhe->size()));
127  h_sfrac->Fill(sfrac);
128  h_size->Fill(recohbhe->size());
129  for (const auto & hit : (*recohbhe)) {
130  HcalDetId id = hit.id();
131  if (((id.subdet() == HcalEndcap) && doHE_) ||
132  ((id.subdet() == HcalBarrel) && doHB_)) {
133  h_depth->Fill(id.depth());
134  std::vector<HcalDetId> ids;
135  theHBHETopology->unmergeDepthDetId(id, ids);
136  if (verbosity_ > 0) {
137  edm::LogVerbatim("Collapse") << id << " is derived from " << ids.size()
138  << " components";
139  for (unsigned int k=0; k<ids.size(); ++k)
140  edm::LogVerbatim("Collapse") << "[" << k << "] " << ids[k];
141  }
142  h_merge->Fill(ids.size());
143  double energy = hit.energy();
144  double etot(0);
145  unsigned int k(0);
146  for (const auto phit : (*prerecohbhe)) {
147  if (std::find(ids.begin(),ids.end(),phit.id()) != ids.end()) {
148  etot += phit.energy();
149  double frac = (energy > 0) ? phit.energy()/energy : 1.0;
150  h_frac->Fill(frac);
151  if (verbosity_ > 0)
152  edm::LogVerbatim("Collapse") << "Frac[" << k << "] " << frac
153  << " for " <<phit.id();
154  ++k;
155  }
156  }
157  double frac = (energy > 0) ? etot/energy : 1.0;
158  h_balance->Fill(frac);
159  if (verbosity_ > 0)
160  edm::LogVerbatim("Collapse") << "Total energy " << energy << ":" << etot
161  << ":" << frac;
162  }
163  }
164  }
165 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
void unmergeDepthDetId(const HcalDetId &id, std::vector< HcalDetId > &ids) const
Definition: HcalTopology.h:171
bool isValid() const
Definition: HandleBase.h:74
int k[5][pyjets_maxn]
unsigned int id
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< HBHERecHitCollection > tok_prehbhe_
size_type size() const
MonitorElement * h_balance
T const * product() const
Definition: ESHandle.h:84
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
void HcalCollapseAnalyzer::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 167 of file HcalCollapseAnalyzer.cc.

References DQMStore::IBooker::book1D(), DEFINE_FWK_MODULE, h_balance, h_depth, h_frac, h_merge, h_sfrac, h_size, DQMStore::IBooker::setCurrentFolder(), and topFolderName_.

Referenced by ~HcalCollapseAnalyzer().

169  {
170  // Book histograms
172  h_merge = ibooker.book1D("h_merge","Number of hits merged",10,0.0,10.0);
173  h_size = ibooker.book1D("h_size","Size of the RecHit collection",100,500.0,1500.0);
174  h_depth = ibooker.book1D("h_depth","Depth of the Id's used",10,0.0,10.0);
175  h_sfrac = ibooker.book1D("h_sfrac","Ratio of sizes of preRecHit and RecHit collections",150,0.0,1.5);
176  h_frac = ibooker.book1D("h_frac", "Fraction of energy before collapse",150,0.0,1.5);
177  h_balance= ibooker.book1D("h_balance", "Balance of energy between pre- and post-collapse",100,0.5,1.5);
178 }
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
const std::string topFolderName_
MonitorElement * h_balance
void HcalCollapseAnalyzer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 89 of file HcalCollapseAnalyzer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~HcalCollapseAnalyzer().

89  {
91  desc.add<std::string>("topFolderName", "HcalCollapse");
92  desc.addUntracked<int>("verbosity", 0);
93  desc.addUntracked<edm::InputTag>("recHitHBHE", edm::InputTag("hbhereco"));
94  desc.addUntracked<edm::InputTag>("preRecHitHBHE",edm::InputTag("hbheprereco"));
95  desc.addUntracked<bool>("doHE", true);
96  desc.addUntracked<bool>("doHB", false);
97  descriptions.add("hcalCollapseAnalyzer",desc);
98 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

const bool HcalCollapseAnalyzer::doHB_
private

Definition at line 63 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and HcalCollapseAnalyzer().

const bool HcalCollapseAnalyzer::doHE_
private

Definition at line 63 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and HcalCollapseAnalyzer().

MonitorElement * HcalCollapseAnalyzer::h_balance
private

Definition at line 69 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and bookHistograms().

MonitorElement * HcalCollapseAnalyzer::h_depth
private

Definition at line 68 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and bookHistograms().

MonitorElement * HcalCollapseAnalyzer::h_frac
private

Definition at line 69 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and bookHistograms().

MonitorElement* HcalCollapseAnalyzer::h_merge
private

Definition at line 68 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and bookHistograms().

MonitorElement* HcalCollapseAnalyzer::h_sfrac
private

Definition at line 69 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and bookHistograms().

MonitorElement * HcalCollapseAnalyzer::h_size
private

Definition at line 68 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and bookHistograms().

const edm::InputTag HcalCollapseAnalyzer::preRecHitHBHE_
private

Definition at line 62 of file HcalCollapseAnalyzer.cc.

Referenced by HcalCollapseAnalyzer().

const edm::InputTag HcalCollapseAnalyzer::recHitHBHE_
private

Definition at line 62 of file HcalCollapseAnalyzer.cc.

Referenced by HcalCollapseAnalyzer().

edm::EDGetTokenT<HBHERecHitCollection> HcalCollapseAnalyzer::tok_hbhe_
private

Definition at line 65 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and HcalCollapseAnalyzer().

edm::EDGetTokenT<HBHERecHitCollection> HcalCollapseAnalyzer::tok_prehbhe_
private

Definition at line 66 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and HcalCollapseAnalyzer().

const std::string HcalCollapseAnalyzer::topFolderName_
private

Definition at line 60 of file HcalCollapseAnalyzer.cc.

Referenced by bookHistograms().

const int HcalCollapseAnalyzer::verbosity_
private

Definition at line 61 of file HcalCollapseAnalyzer.cc.

Referenced by analyze(), and HcalCollapseAnalyzer().