CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimHitsValidationHcal.cc
Go to the documentation of this file.
3 
4 //#include "FWCore/Utilities/interface/Exception.h"
5 
7 
8  g4Label = ps.getUntrackedParameter<std::string>("moduleLabel","g4SimHits");
9  hcalHits = ps.getUntrackedParameter<std::string>("HitCollection","HcalHits");
10  verbose_ = ps.getUntrackedParameter<bool>("Verbose", false);
11 
12  edm::LogInfo("HitsValidationHcal") << "Module Label: " << g4Label << " Hits: "
13  << hcalHits;
14 
16  if (dbe_) {
17  if (verbose_) {
18  dbe_->setVerbose(1);
19  sleep (3);
21  } else {
22  dbe_->setVerbose(0);
23  }
24  }
25 }
26 
28 
30 
31  if (dbe_) {
32  std::cout << "Histograms booked\n";
33  dbe_->setCurrentFolder("HcalHitsV/SimHitsValidationHcal");
34 
35  //Histograms for Hits
36  std::string divisions[25]={"HB0","HB1","HE0+z","HE1+z","HE2+z","HE0-z","HE1-z",
37  "HE2-z","HO0","HFL0+z","HFS0+z","HFL1+z","HFS1+z",
38  "HFL2+z","HFS2+z","HFL3+z","HFS3+z","HFL0-z","HFS0-z",
39  "HFL1-z","HFS1-z","HFL2-z","HFS2-z","HFL3-z","HFS3-z"};
40  double etaLow[25]={-16,-16,16,16,16,-29,-29,-29,-15,29,29,29,29,29,29,29,29,
41  -41,-41,-41,-41,-41,-41,-41,-41};
42  double etaHigh[25]={16,16,30,30,30,-30,-30,-30,15,41,41,41,41,41,41,41,41,
43  -29,-29,-29,-29,-29,-29,-29,-29};
44  int etaBins[25]={32,32,14,14,14,14,14,14,30,12,12,12,12,12,12,12,12,
45  12,12,12,12,12,12,12,12};
46  char name[40], title[100];
47  for (int i=0; i<25; ++i) {
48  sprintf (name, "HcalHitEta%s", divisions[i].c_str());
49  sprintf (name, "Hit energy as a function of eta tower index in %s", divisions[i].c_str());
50  meHcalHitEta_[i] = dbe_->book1D(name, title, etaBins[i], etaLow[i], etaHigh[i]);
51  }
52  }
53 }
54 
56 
58 
59  LogDebug("HitsValidationHcal") << "Run = " << e.id().run() << " Event = "
60  << e.id().event();
61 
62  std::vector<PCaloHit> caloHits;
64 
65  bool getHits = false;
66  e.getByLabel(g4Label,hcalHits,hitsHcal);
67  if (hitsHcal.isValid()) getHits = true;
68 
69  LogDebug("HitsValidationHcal") << "HcalValidation: Input flags Hits " << getHits;
70 
71  if (getHits) {
72  caloHits.insert(caloHits.end(),hitsHcal->begin(),hitsHcal->end());
73  LogDebug("HitsValidationHcal") << "HcalValidation: Hit buffer "
74  << caloHits.size();
75  analyzeHits (caloHits);
76  }
77 }
78 
79 void SimHitsValidationHcal::analyzeHits (std::vector<PCaloHit>& hits) {
80 
81  int nHit = hits.size();
82  double entotHB = 0, entotHE = 0, entotHF = 0, entotHO = 0;
83  int nHB=0, nHE=0, nHO=0, nHF=0;
84 
85  for (int i=0; i<nHit; i++) {
86  double energy = hits[i].energy();
87  double time = hits[i].time();
88  unsigned int id_ = hits[i].id();
89  HcalDetId id = HcalDetId(id_);
90  int det = id.det();
91  int subdet = id.subdet();
92  int depth = id.depth();
93  int eta = id.ieta();
94  int phi = id.iphi();
95  unsigned int dep = hits[i].depth();
96  int type =-1;
97  if (subdet == static_cast<int>(HcalBarrel)) {
98  entotHB += energy;
99  nHB++;
100  type = depth-1;
101  } else if (subdet == static_cast<int>(HcalEndcap)) {
102  entotHE += energy;
103  nHE++;
104  type = depth+2;
105  if (eta < 0) type += 3;
106  } else if (subdet == static_cast<int>(HcalOuter)) {
107  entotHO += energy;
108  nHO++;
109  type = 8;
110  } else if (subdet == static_cast<int>(HcalForward)) {
111  entotHF += energy;
112  nHF++;
113  type = depth+8+2*dep;
114  if (eta < 0) type += 8;
115  }
116  LogDebug("HitsValidationHcal") << "Hit[" << i << "] ID " << std::hex << id_
117  << std::dec << " Det " << det << " Sub "
118  << subdet << " depth " << depth << " depthX "
119  << dep << " Eta " << eta << " Phi " << phi
120  << " E " << energy << " time " << time
121  << " type " << type;
122  double etax = eta - 0.5;
123  if (eta < 0) etax += 1;
124  if (dbe_ && type >= 0) {
125  meHcalHitEta_[type]->Fill(etax,energy);
126  }
127  }
128 
129  /*
130  if (dbe_) {
131  if( entotHB != 0 ) for( int i=0; i<140; i++ ) meHBL10EneP_->Fill( -10.+(float(i)+0.5)/10., encontHB[i]/entotHB );
132  if( entotHE != 0 ) for( int i=0; i<140; i++ ) meHEL10EneP_->Fill( -10.+(float(i)+0.5)/10., encontHE[i]/entotHE );
133  if( entotHF != 0 ) for( int i=0; i<140; i++ ) meHFL10EneP_->Fill( -10.+(float(i)+0.5)/10., encontHF[i]/entotHF );
134  if( entotHO != 0 ) for( int i=0; i<140; i++ ) meHOL10EneP_->Fill( -10.+(float(i)+0.5)/10., encontHO[i]/entotHO );
135  meAllNHit_->Fill(double(nHit));
136  meHBNHit_->Fill(double(nHB));
137  meHENHit_->Fill(double(nHE));
138  meHONHit_->Fill(double(nHO));
139  meHFNHit_->Fill(double(nHF));
140  }
141  */
142  LogDebug("HitsValidationHcal") << "SimHitsValidationHcal::analyzeHits: HB " << nHB
143  << " HE " << nHE << " HO " << nHO << " HF " << nHF
144  << " All " << nHit;
145 
146 }
147 
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
SimHitsValidationHcal(const edm::ParameterSet &ps)
type
Definition: HCALResponse.h:22
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
void analyze(const edm::Event &e, const edm::EventSetup &c)
T eta() const
void sleep(Duration_t)
Definition: Utils.h:163
void Fill(long long x)
void setVerbose(unsigned level)
Definition: DQMStore.cc:393
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:121
void showDirStructure(void) const
Definition: DQMStore.cc:2761
MonitorElement * meHcalHitEta_[25]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: DDAxes.h:10
void analyzeHits(std::vector< PCaloHit > &)