CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalQLPlotHistoMgr.cc
Go to the documentation of this file.
4 #include "TProfile.h"
5 
6 //Declare Histogram Bin parameters
7 static const int PED_BINS=50;
8 static const int LED_BINS=50;
9 static const int LASER_BINS=70;
10 static const int BEAM_BINS=70;
11 static const int OTHER_BINS=100;
12 static const int TIME_BINS=75;
13 static const int PULSE_BINS=10;
14 
16  const edm::ParameterSet& histoParams) {
17  pedHistDir=parent->mkdir("PEDESTAL");
18  ledHistDir=parent->mkdir("LED");
19  laserHistDir=parent->mkdir("LASER");
20  beamHistDir=parent->mkdir("BEAM");
21  otherHistDir=parent->mkdir("OTHER");
22  histoParams_ = histoParams;
23 }
24 
26  switch (ht) {
27  case(ENERGY): return "Energy"; break;
28  case(TIME): return "Time"; break;
29  case(PULSE): return "Pulse"; break;
30  case(ADC): return "ADC"; break;
31  default: return ""; break;
32  }
33 }
34 
36  switch(et) {
37  case(PEDESTAL): return "Pedestal"; break;
38  case(LED): return "LED"; break;
39  case(LASER): return "Laser"; break;
40  case(BEAM): return "Beam"; break;
41  default: return "Other"; break;
42  }
43 }
44 
46  const HcalElectronicsId& eid,
47  HistType ht, EventType et)
48 {
49  std::string flavor=nameForFlavor(ht);
50 
51  char name[120];
52 
53  std::string subdetStr;
54  switch (id.subdet()) {
55  case (HcalBarrel) : subdetStr="HB"; break;
56  case (HcalEndcap) : subdetStr="HE"; break;
57  case (HcalOuter) : subdetStr="HO"; break;
58  case (HcalForward) : subdetStr="HF"; break;
59  default: subdetStr="Other"; break;
60  }
61 
62  sprintf(name,"%s_%s_%d_%d_%d_eid=%d_%d_%d_%d_HTR_%d:%d%c",
63  flavor.c_str(),subdetStr.c_str(),id.ieta(),id.iphi(),id.depth(),
64  eid.dccid(),eid.spigot(), eid.fiberIndex(), eid.fiberChanId(),
65  eid.readoutVMECrateId(), eid.htrSlot(),(eid.htrTopBottom()==1)?('t'):('b') );
66 
67  return GetAHistogramImpl(name,ht,et);
68 }
69 
71  const HcalElectronicsId& eid,
72  HistType ht, EventType et)
73 {
74  std::string flavor=nameForFlavor(ht);
75 
76  char name[120];
77 
78  std::string subdetStr;
79  switch (id.hcalSubdet()) {
80  case (HcalBarrel) : subdetStr="HB"; break;
81  case (HcalEndcap) : subdetStr="HE"; break;
82  case (HcalOuter) : subdetStr="HO"; break;
83  case (HcalForward) : subdetStr="HF"; break;
84  default: subdetStr="Other"; break;
85  }
86 
87  std::string chanstring = id.cboxChannelString();
88  if (!chanstring.size()) {
89  chanstring = "Unknown";
90  edm::LogInfo("HcalQLPlotHistoMgr::GetAHistogram") << "Unknown calibration channel " << id.cboxChannel();
91  }
92 
93  sprintf(name,"%s_CALIB_%s_%d_%d_chan=%s_eid=%d_%d_%d_%d_HTR_%d:%d%c",
94  flavor.c_str(),subdetStr.c_str(),id.ieta(),id.iphi(),chanstring.c_str(),
95  eid.dccid(),eid.spigot(), eid.fiberIndex(), eid.fiberChanId(),
96  eid.readoutVMECrateId(), eid.htrSlot(),(eid.htrTopBottom()==1)?('t'):('b') );
97 
98  return GetAHistogramImpl(name,ht,et);
99 }
100 
102  HistType ht, EventType et)
103 {
104  TDirectory* td;
105 
106  switch (et) {
107  case(PEDESTAL): td=pedHistDir; break;
108  case(LED): td=ledHistDir; break;
109  case(LASER): td=laserHistDir; break;
110  case(BEAM): td=beamHistDir; break;
111  case(UNKNOWN): td=otherHistDir; break;
112  default: td=0; break;
113  }
114 
115  if (td==0) {
116  printf("Unknown %d !\n", et);
117  return 0;
118  }
119 
120  TH1* retval=0;
121 
122  retval=(TH1*)td->Get(name);
123  int bins=0; double lo=0, hi=0;
124 
125  // If the histogram doesn't exist and we are authorized,
126  // create it!
127  //
128  if (retval==0) {
129  td->cd();
130  switch (ht) {
131  case(ENERGY): {
132  switch (et) {
133  case(PEDESTAL):
134  bins=PED_BINS;
135  try {
136  lo=histoParams_.getParameter<double>("pedGeVlo");
137  hi=histoParams_.getParameter<double>("pedGeVhi");
138  } catch (std::exception& e) { // can't find it!
139  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) pedGeVlo/hi not found.";
140  throw e;
141  }
142  break;
143  case(LED):
144  bins=LED_BINS;
145  try {
146  lo=histoParams_.getParameter<double>("ledGeVlo");
147  hi=histoParams_.getParameter<double>("ledGeVhi");
148  } catch (std::exception& e) { // can't find it!
149  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) ledGeVlo/hi not found.";
150  throw e;
151  }
152  break;
153  case(LASER):
154  bins=LASER_BINS;
155  try {
156  lo=histoParams_.getParameter<double>("laserGeVlo");
157  hi=histoParams_.getParameter<double>("laserGeVhi");
158  } catch (std::exception& e) { // can't find it!
159  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) laserGeVlo/hi not found.";
160  throw e;
161  }
162  break;
163  case(BEAM):
164  bins=BEAM_BINS;
165  try {
166  lo=histoParams_.getParameter<double>("beamGeVlo");
167  hi=histoParams_.getParameter<double>("beamGeVhi");
168  } catch (std::exception& e) { // can't find it!
169  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) beamGeVlo/hi not found.";
170  throw e;
171  }
172  break;
173  case(UNKNOWN):
174  bins=OTHER_BINS;
175  try {
176  lo=histoParams_.getParameter<double>("otherGeVlo");
177  hi=histoParams_.getParameter<double>("otherGeVhi");
178  } catch (std::exception& e) { // can't find it!
179  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) otherGeVlo/hi not found.";
180  throw e;
181  }
182  break;
183  default: break;
184  };
185  }
186  break;
187  case(TIME):
188  bins=TIME_BINS;
189  try {
190  lo=histoParams_.getParameter<double>("timeNSlo");
191  hi=histoParams_.getParameter<double>("timeNShi");
192  } catch (std::exception& e) { // can't find it!
193  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) timeNSlo/hi not found.";
194  throw e;
195  }
196  break;
197  case(PULSE):
198  bins=PULSE_BINS;
199  lo=-0.5;
200  hi=PULSE_BINS-0.5;
201  break;
202  case(ADC):
203  bins=PED_BINS;
204  try {
205  lo=histoParams_.getParameter<double>("pedADClo");
206  hi=histoParams_.getParameter<double>("pedADChi");
207  } catch (std::exception& e) { // can't find it!
208  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) pedADClo/hi not found.";
209  throw e;
210  }
211  break;
212  }
213 
214  if (bins>0){
215  if (ht==PULSE){
216  retval=new TProfile(name,name,bins,lo,hi);
217  retval->GetXaxis()->SetTitle("TimeSlice(25ns)");
218  retval->GetYaxis()->SetTitle("fC");
219  }
220  else if (ht==TIME){
221  retval=new TH1F(name,name,bins,lo,hi);
222  retval->GetXaxis()->SetTitle("Timing(ns)");
223  }
224  else if (ht==ENERGY){
225  retval=new TH1F(name,name,bins,lo,hi);
226  retval->GetXaxis()->SetTitle("Energy(GeV)");
227  }
228  else if (ht==ADC){
229  retval=new TH1F(name,name,bins,lo,hi);
230  retval->GetXaxis()->SetTitle("ADC Counts");
231  }
232  }
233  }
234 
235  return retval;
236 }
T getParameter(std::string const &) const
int fiberIndex() const
get the fiber index [1-8] (which of eight fibers carried by a spigot) (valid only for non-trigger-cha...
static const int TIME_BINS
list parent
Definition: dbtoconf.py:74
static const int BEAM_BINS
HcalQLPlotHistoMgr(TDirectory *parent, const edm::ParameterSet &histoParams)
static const int OTHER_BINS
int htrSlot() const
get the htr slot
edm::ParameterSet histoParams_
int readoutVMECrateId() const
get the readout VME crate number
static const int LED_BINS
static std::string nameForFlavor(HistType ht)
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom)
TDirectory * beamHistDir
TDirectory * laserHistDir
int dccid() const
get the (Hcal local) DCC id
int fiberChanId() const
get the fiber channel id (which of three channels on a readout fiber) (valid only for non-trigger-cha...
int spigot() const
get the spigot (input number on DCC)
static const int PULSE_BINS
TH1 * GetAHistogramImpl(const char *name, HistType ht, EventType et)
static const int LASER_BINS
TH1 * GetAHistogram(const HcalDetId &id, const HcalElectronicsId &eid, HistType ht, EventType et)
static std::string nameForEvent(EventType et)
static const int PED_BINS
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
TDirectory * otherHistDir