CMS 3D CMS Logo

HGCalBHValidation.cc
Go to the documentation of this file.
1 // system include files
2 #include <iostream>
3 #include <fstream>
4 #include <vector>
5 #include <map>
6 #include <string>
7 
8 // user include files
11 
20 
24 
25 // Root objects
26 #include "TROOT.h"
27 #include "TSystem.h"
28 #include "TFile.h"
29 #include "TH1.h"
30 #include "TH2.h"
31 
32 class HGCalBHValidation : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
33 public:
34  explicit HGCalBHValidation(const edm::ParameterSet& ps);
35  ~HGCalBHValidation() override {}
36 
37  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
38 
39 protected:
40  void beginJob() override {}
41  void beginRun(edm::Run const&, edm::EventSetup const&) override;
42  void endRun(edm::Run const&, edm::EventSetup const&) override {}
43  void analyze(edm::Event const&, edm::EventSetup const&) override;
44  template <class T>
45  void analyzeDigi(const T&, double const&, bool const&, int const&, unsigned int&);
46 
47 private:
51  const int iSample_;
52  const double threshold_;
55  const int etaMax_;
56 
57  TH1D *hsimE1_, *hsimE2_, *hsimTm_;
58  TH1D *hsimLn_, *hdigEn_, *hdigLn_;
59  TH2D *hsimOc_, *hsi2Oc_, *hsi3Oc_;
60  TH2D *hdigOc_, *hdi2Oc_, *hdi3Oc_;
61 };
62 
64  : g4Label_(ps.getParameter<std::string>("ModuleLabel")),
65  hits_((ps.getParameter<std::string>("HitCollection"))),
66  digis_(ps.getParameter<edm::InputTag>("DigiCollection")),
67  iSample_(ps.getParameter<int>("Sample")),
68  threshold_(ps.getParameter<double>("Threshold")),
69  tok_hits_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hits_))),
70  tok_digi_(consumes<HGCalDigiCollection>(digis_)),
71  etaMax_(100) {
72  usesResource(TFileService::kSharedResource);
73 
74  edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation::Input for SimHit:" << edm::InputTag(g4Label_, hits_)
75  << " Digits:" << digis_ << " Sample: " << iSample_ << " Threshold "
76  << threshold_;
77 }
78 
81  desc.add<std::string>("ModuleLabel", "g4SimHits");
82  desc.add<std::string>("HitCollection", "HGCHitsHEback");
83  desc.add<edm::InputTag>("DigiCollection", edm::InputTag("simHGCalUnsuppressedDigis", "HEback"));
84  desc.add<int>("Sample", 5);
85  desc.add<double>("Threshold", 15.0);
86  descriptions.add("hgcalBHAnalysis", desc);
87 }
88 
90  edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation::Maximum Number of"
91  << " eta sectors:" << etaMax_ << "\nHitsValidationHcal::Booking the Histograms";
92 
93  //Histograms for Sim Hits
94  hsimE1_ = fs_->make<TH1D>("SimHitEn1", "Sim Hit Energy", 1000, 0.0, 1.0);
95  hsimE2_ = fs_->make<TH1D>("SimHitEn2", "Sim Hit Energy", 1000, 0.0, 1.0);
96  hsimTm_ = fs_->make<TH1D>("SimHitTime", "Sim Hit Time", 1000, 0.0, 500.0);
97  hsimLn_ = fs_->make<TH1D>("SimHitLong", "Sim Hit Long. Profile", 50, 0.0, 25.0);
98  hsimOc_ = fs_->make<TH2D>("SimHitOccup", "Sim Hit Occupnacy", 2 * etaMax_ + 1, -etaMax_, etaMax_ + 1, 360, 0, 360);
99  hsi2Oc_ = fs_->make<TH2D>("SimHitOccu2", "Sim Hit Occupnacy", 2 * etaMax_ + 1, -etaMax_, etaMax_ + 1, 360, 0, 360);
100  hsi3Oc_ = fs_->make<TH2D>("SimHitOccu3", "Sim Hit Occupnacy", 2 * etaMax_ + 1, -etaMax_, etaMax_ + 1, 50, 0, 25);
101  //Histograms for Digis
102  hdigEn_ = fs_->make<TH1D>("DigiEnergy", "Digi ADC Sample", 1000, 0.0, 1000.0);
103  hdigLn_ = fs_->make<TH1D>("DigiLong", "Digi Long. Profile", 50, 0.0, 25.0);
104  hdigOc_ = fs_->make<TH2D>("DigiOccup", "Digi Occupnacy", 2 * etaMax_ + 1, -etaMax_, etaMax_ + 1, 360, 0, 360);
105  hdi2Oc_ = fs_->make<TH2D>("DigiOccu2", "Digi Occupnacy", 2 * etaMax_ + 1, -etaMax_, etaMax_ + 1, 360, 0, 360);
106  hdi3Oc_ = fs_->make<TH2D>("DigiOccu3", "Digi Occupnacy", 2 * etaMax_ + 1, -etaMax_, etaMax_ + 1, 50, 0, 25);
107 }
108 
110  edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation:Run = " << e.id().run() << " Event = " << e.id().event();
111 
112  //SimHits
114  e.getByToken(tok_hits_, hitsHE);
115  edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation.: PCaloHitContainer"
116  << " obtained with flag " << hitsHE.isValid();
117  if (hitsHE.isValid()) {
118  edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation: PCaloHit buffer " << hitsHE->size();
119  unsigned i(0);
120  std::map<unsigned int, double> map_try;
121  for (edm::PCaloHitContainer::const_iterator it = hitsHE->begin(); it != hitsHE->end(); ++it) {
122  double energy = it->energy();
123  double time = it->time();
124  unsigned int id = it->id();
125  int eta(0), phi(0), lay(0);
126  bool bh = (DetId(id).det() == DetId::HGCalHSc);
127  if (bh) {
128  eta = HGCScintillatorDetId(id).ieta();
129  phi = HGCScintillatorDetId(id).iphi();
130  lay = HGCScintillatorDetId(id).layer();
131  }
132  double eta1 = (eta >= 0) ? (eta + 0.1) : (eta - 0.1);
133  if (bh) {
134  hsi2Oc_->Fill(eta1, (phi - 0.1), energy);
135  hsimE1_->Fill(energy);
136  hsimTm_->Fill(time, energy);
137  hsimOc_->Fill(eta1, (phi - 0.1), energy);
138  hsimLn_->Fill(lay, energy);
139  hsi3Oc_->Fill(eta1, lay, energy);
140  double ensum(0);
141  if (map_try.count(id) != 0)
142  ensum = map_try[id];
143  ensum += energy;
144  map_try[id] = ensum;
145  ++i;
146  edm::LogVerbatim("HGCalValidation") << "HGCalBHHit[" << i << "] ID " << std::hex << " " << id << std::dec << " "
147  << HGCScintillatorDetId(id) << " E " << energy << " time " << time;
148  }
149  }
150  for (std::map<unsigned int, double>::iterator itr = map_try.begin(); itr != map_try.end(); ++itr) {
151  hsimE2_->Fill((*itr).second);
152  }
153  }
154 
155  //Digits
156  unsigned int kount(0);
158  e.getByToken(tok_digi_, hecoll);
159  edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation.: "
160  << "HGCalDigiCollection obtained with"
161  << " flag " << hecoll.isValid();
162  if (hecoll.isValid()) {
163  edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation: HGCalDigi "
164  << "buffer " << hecoll->size();
165  for (HGCalDigiCollection::const_iterator it = hecoll->begin(); it != hecoll->end(); ++it) {
166  HGCalDataFrame df(*it);
167  double energy = df[iSample_].data();
168  bool bh = (DetId(df.id()).det() == DetId::HGCalHSc);
169  if (bh) {
170  HGCScintillatorDetId cell(df.id());
171  int depth = cell.layer();
172  analyzeDigi(cell, energy, bh, depth, kount);
173  }
174  }
175  }
176 }
177 
178 template <class T>
180  const T& cell, double const& energy, bool const& bh, int const& depth, unsigned int& kount) {
181  if (energy > threshold_) {
182  int eta = cell.ieta();
183  int phi = cell.iphi();
184  double eta1 = (eta >= 0) ? (eta + 0.1) : (eta - 0.1);
185  hdi2Oc_->Fill(eta1, (phi - 0.1));
186  if (bh) {
187  hdigEn_->Fill(energy);
188  hdigOc_->Fill(eta1, (phi - 0.1));
189  hdigLn_->Fill(depth);
190  hdi3Oc_->Fill(eta1, depth);
191  ++kount;
192  edm::LogVerbatim("HGCalValidation")
193  << "HGCalBHDigit[" << kount << "] ID " << cell << " E " << energy << ":" << (energy > threshold_);
194  }
195  }
196 }
197 
HGCalBHValidation::hdi3Oc_
TH2D * hdi3Oc_
Definition: HGCalBHValidation.cc:60
HGCalBHValidation::digis_
const edm::InputTag digis_
Definition: HGCalBHValidation.cc:50
HGCalBHValidation
Definition: HGCalBHValidation.cc:32
EDAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HGCScintillatorDetId::iphi
int iphi() const
get the phi index
Definition: HGCScintillatorDetId.cc:58
HGCalBHValidation::hsimTm_
TH1D * hsimTm_
Definition: HGCalBHValidation.cc:57
MessageLogger.h
HGCScintillatorDetId.h
HGCalBHValidation::hdigEn_
TH1D * hdigEn_
Definition: HGCalBHValidation.cc:58
HGCalBHValidation::hsimE1_
TH1D * hsimE1_
Definition: HGCalBHValidation.cc:57
HGCScintillatorDetId::ieta
int ieta() const
Definition: HGCScintillatorDetId.h:57
HGCalBHValidation::tok_digi_
const edm::EDGetToken tok_digi_
Definition: HGCalBHValidation.cc:54
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< edm::PCaloHitContainer >
edm
HLT enums.
Definition: AlignableModifier.h:19
HGCalBHValidation::iSample_
const int iSample_
Definition: HGCalBHValidation.cc:51
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HGCalBHValidation::hdi2Oc_
TH2D * hdi2Oc_
Definition: HGCalBHValidation.cc:60
protons_cff.time
time
Definition: protons_cff.py:35
edm::SortedCollection
Definition: SortedCollection.h:49
HGCalBHValidation::hits_
const std::string hits_
Definition: HGCalBHValidation.cc:49
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
HGCalBHValidation::tok_hits_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
Definition: HGCalBHValidation.cc:53
HGCalBHValidation::hsimE2_
TH1D * hsimE2_
Definition: HGCalBHValidation.cc:57
HGCalBHValidation::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HGCalBHValidation.cc:79
HGCalBHValidation::hdigLn_
TH1D * hdigLn_
Definition: HGCalBHValidation.cc:58
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
HGCalBHValidation::g4Label_
const std::string g4Label_
Definition: HGCalBHValidation.cc:49
HGCalBHValidation::hsimOc_
TH2D * hsimOc_
Definition: HGCalBHValidation.cc:59
edm::Handle
Definition: AssociativeIterator.h:50
HGCalBHValidation::~HGCalBHValidation
~HGCalBHValidation() override
Definition: HGCalBHValidation.cc:35
HGCScintillatorDetId::layer
int layer() const
get the layer #
Definition: HGCScintillatorDetId.h:50
DetId
Definition: DetId.h:17
MakerMacros.h
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
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
Service.h
PVValHelper::eta
Definition: PVValidationHelpers.h:70
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
HGCalBHValidation::etaMax_
const int etaMax_
Definition: HGCalBHValidation.cc:55
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HGCalBHValidation::fs_
edm::Service< TFileService > fs_
Definition: HGCalBHValidation.cc:48
TFileService.h
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9550
HGCalBHValidation::hdigOc_
TH2D * hdigOc_
Definition: HGCalBHValidation.cc:60
HGCalBHValidation::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: HGCalBHValidation.cc:109
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HGCalBHValidation::threshold_
const double threshold_
Definition: HGCalBHValidation.cc:52
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
PCaloHit.h
HGCDataFrame
Readout digi for HGC.
Definition: HGCDataFrame.h:14
edm::Service< TFileService >
createfilelist.int
int
Definition: createfilelist.py:10
HGCalBHValidation::HGCalBHValidation
HGCalBHValidation(const edm::ParameterSet &ps)
Definition: HGCalBHValidation.cc:63
HGCDigiCollections.h
edm::EventSetup
Definition: EventSetup.h:58
edm::EDGetToken
Definition: EDGetToken.h:35
TFileService::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalBHValidation::hsi2Oc_
TH2D * hsi2Oc_
Definition: HGCalBHValidation.cc:59
DDAxes::phi
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
HGCalBHValidation::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: HGCalBHValidation.cc:89
std
Definition: JetResolutionObject.h:76
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:733
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
T
long double T
Definition: Basic3DVectorLD.h:48
DetId::HGCalHSc
Definition: DetId.h:34
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
EventSetup.h
PCaloHitContainer.h
HGCalBHValidation::analyzeDigi
void analyzeDigi(const T &, double const &, bool const &, int const &, unsigned int &)
Definition: HGCalBHValidation.cc:179
HGCalBHValidation::beginJob
void beginJob() override
Definition: HGCalBHValidation.cc:40
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HGCalBHValidation::hsi3Oc_
TH2D * hsi3Oc_
Definition: HGCalBHValidation.cc:59
edm::Event
Definition: Event.h:73
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
edm::InputTag
Definition: InputTag.h:15
HGCalBHValidation::hsimLn_
TH1D * hsimLn_
Definition: HGCalBHValidation.cc:58
HGCalBHValidation::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: HGCalBHValidation.cc:42
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37