CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  pedHistDir = parent->mkdir("PEDESTAL");
17  ledHistDir = parent->mkdir("LED");
18  laserHistDir = parent->mkdir("LASER");
19  beamHistDir = parent->mkdir("BEAM");
20  otherHistDir = parent->mkdir("OTHER");
21  histoParams_ = histoParams;
22 }
23 
25  switch (ht) {
26  case (ENERGY):
27  return "Energy";
28  break;
29  case (TIME):
30  return "Time";
31  break;
32  case (PULSE):
33  return "Pulse";
34  break;
35  case (ADC):
36  return "ADC";
37  break;
38  default:
39  return "";
40  break;
41  }
42 }
43 
45  switch (et) {
46  case (PEDESTAL):
47  return "Pedestal";
48  break;
49  case (LED):
50  return "LED";
51  break;
52  case (LASER):
53  return "Laser";
54  break;
55  case (BEAM):
56  return "Beam";
57  break;
58  default:
59  return "Other";
60  break;
61  }
62 }
63 
65  std::string flavor = nameForFlavor(ht);
66 
67  char name[120];
68 
69  std::string subdetStr;
70  switch (id.subdet()) {
71  case (HcalBarrel):
72  subdetStr = "HB";
73  break;
74  case (HcalEndcap):
75  subdetStr = "HE";
76  break;
77  case (HcalOuter):
78  subdetStr = "HO";
79  break;
80  case (HcalForward):
81  subdetStr = "HF";
82  break;
83  default:
84  subdetStr = "Other";
85  break;
86  }
87 
88  sprintf(name,
89  "%s_%s_%d_%d_%d_eid=%d_%d_%d_%d_HTR_%d:%d%c",
90  flavor.c_str(),
91  subdetStr.c_str(),
92  id.ieta(),
93  id.iphi(),
94  id.depth(),
95  eid.dccid(),
96  eid.spigot(),
97  eid.fiberIndex(),
98  eid.fiberChanId(),
99  eid.readoutVMECrateId(),
100  eid.htrSlot(),
101  (eid.htrTopBottom() == 1) ? ('t') : ('b'));
102 
103  return GetAHistogramImpl(name, ht, et);
104 }
105 
107  const HcalElectronicsId& eid,
108  HistType ht,
109  EventType et) {
110  std::string flavor = nameForFlavor(ht);
111 
112  char name[120];
113 
114  std::string subdetStr;
115  switch (id.hcalSubdet()) {
116  case (HcalBarrel):
117  subdetStr = "HB";
118  break;
119  case (HcalEndcap):
120  subdetStr = "HE";
121  break;
122  case (HcalOuter):
123  subdetStr = "HO";
124  break;
125  case (HcalForward):
126  subdetStr = "HF";
127  break;
128  default:
129  subdetStr = "Other";
130  break;
131  }
132 
133  std::string chanstring = id.cboxChannelString();
134  if (chanstring.empty()) {
135  chanstring = "Unknown";
136  edm::LogInfo("HcalQLPlotHistoMgr::GetAHistogram") << "Unknown calibration channel " << id.cboxChannel();
137  }
138 
139  sprintf(name,
140  "%s_CALIB_%s_%d_%d_chan=%s_eid=%d_%d_%d_%d_HTR_%d:%d%c",
141  flavor.c_str(),
142  subdetStr.c_str(),
143  id.ieta(),
144  id.iphi(),
145  chanstring.c_str(),
146  eid.dccid(),
147  eid.spigot(),
148  eid.fiberIndex(),
149  eid.fiberChanId(),
150  eid.readoutVMECrateId(),
151  eid.htrSlot(),
152  (eid.htrTopBottom() == 1) ? ('t') : ('b'));
153 
154  return GetAHistogramImpl(name, ht, et);
155 }
156 
158  TDirectory* td;
159 
160  switch (et) {
161  case (PEDESTAL):
162  td = pedHistDir;
163  break;
164  case (LED):
165  td = ledHistDir;
166  break;
167  case (LASER):
168  td = laserHistDir;
169  break;
170  case (BEAM):
171  td = beamHistDir;
172  break;
173  case (UNKNOWN):
174  td = otherHistDir;
175  break;
176  default:
177  td = nullptr;
178  break;
179  }
180 
181  if (td == nullptr) {
182  printf("Unknown %d !\n", et);
183  return nullptr;
184  }
185 
186  TH1* retval = nullptr;
187 
188  retval = (TH1*)td->Get(name);
189  int bins = 0;
190  double lo = 0, hi = 0;
191 
192  // If the histogram doesn't exist and we are authorized,
193  // create it!
194  //
195  if (retval == nullptr) {
196  td->cd();
197  switch (ht) {
198  case (ENERGY): {
199  switch (et) {
200  case (PEDESTAL):
201  bins = PED_BINS;
202  try {
203  lo = histoParams_.getParameter<double>("pedGeVlo");
204  hi = histoParams_.getParameter<double>("pedGeVhi");
205  } catch (std::exception& e) { // can't find it!
206  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) pedGeVlo/hi not found.";
207  throw e;
208  }
209  break;
210  case (LED):
211  bins = LED_BINS;
212  try {
213  lo = histoParams_.getParameter<double>("ledGeVlo");
214  hi = histoParams_.getParameter<double>("ledGeVhi");
215  } catch (std::exception& e) { // can't find it!
216  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) ledGeVlo/hi not found.";
217  throw e;
218  }
219  break;
220  case (LASER):
221  bins = LASER_BINS;
222  try {
223  lo = histoParams_.getParameter<double>("laserGeVlo");
224  hi = histoParams_.getParameter<double>("laserGeVhi");
225  } catch (std::exception& e) { // can't find it!
226  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) laserGeVlo/hi not found.";
227  throw e;
228  }
229  break;
230  case (BEAM):
231  bins = BEAM_BINS;
232  try {
233  lo = histoParams_.getParameter<double>("beamGeVlo");
234  hi = histoParams_.getParameter<double>("beamGeVhi");
235  } catch (std::exception& e) { // can't find it!
236  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) beamGeVlo/hi not found.";
237  throw e;
238  }
239  break;
240  case (UNKNOWN):
241  bins = OTHER_BINS;
242  try {
243  lo = histoParams_.getParameter<double>("otherGeVlo");
244  hi = histoParams_.getParameter<double>("otherGeVhi");
245  } catch (std::exception& e) { // can't find it!
246  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) otherGeVlo/hi not found.";
247  throw e;
248  }
249  break;
250  default:
251  break;
252  };
253  } break;
254  case (TIME):
255  bins = TIME_BINS;
256  try {
257  lo = histoParams_.getParameter<double>("timeNSlo");
258  hi = histoParams_.getParameter<double>("timeNShi");
259  } catch (std::exception& e) { // can't find it!
260  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) timeNSlo/hi not found.";
261  throw e;
262  }
263  break;
264  case (PULSE):
265  bins = PULSE_BINS;
266  lo = -0.5;
267  hi = PULSE_BINS - 0.5;
268  break;
269  case (ADC):
270  bins = PED_BINS;
271  try {
272  lo = histoParams_.getParameter<double>("pedADClo");
273  hi = histoParams_.getParameter<double>("pedADChi");
274  } catch (std::exception& e) { // can't find it!
275  edm::LogError("HcalQLPlotHistoMgr::GetAHistogram") << "Parameter(s) pedADClo/hi not found.";
276  throw e;
277  }
278  break;
279  }
280 
281  if (bins > 0) {
282  if (ht == PULSE) {
283  retval = new TProfile(name, name, bins, lo, hi);
284  retval->GetXaxis()->SetTitle("TimeSlice(25ns)");
285  retval->GetYaxis()->SetTitle("fC");
286  } else if (ht == TIME) {
287  retval = new TH1F(name, name, bins, lo, hi);
288  retval->GetXaxis()->SetTitle("Timing(ns)");
289  } else if (ht == ENERGY) {
290  retval = new TH1F(name, name, bins, lo, hi);
291  retval->GetXaxis()->SetTitle("Energy(GeV)");
292  } else if (ht == ADC) {
293  retval = new TH1F(name, name, bins, lo, hi);
294  retval->GetXaxis()->SetTitle("ADC Counts");
295  }
296  }
297  }
298 
299  return retval;
300 }
static const int TIME_BINS
static const int BEAM_BINS
HcalQLPlotHistoMgr(TDirectory *parent, const edm::ParameterSet &histoParams)
static const int OTHER_BINS
Log< level::Error, false > LogError
constexpr int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
edm::ParameterSet histoParams_
static const int LED_BINS
static std::string nameForFlavor(HistType ht)
constexpr int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
constexpr int htrSlot() const
get the htr slot
TDirectory * beamHistDir
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
TDirectory * laserHistDir
constexpr int readoutVMECrateId() const
get the readout VME crate number
constexpr int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
Log< level::Info, false > LogInfo
constexpr int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
static const int PULSE_BINS
TH1 * GetAHistogramImpl(const char *name, HistType ht, EventType et)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const int LASER_BINS
TH1 * GetAHistogram(const HcalDetId &id, const HcalElectronicsId &eid, HistType ht, EventType et)
static std::string nameForEvent(EventType et)
constexpr int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
static const int PED_BINS
Readout chain identification for Hcal.
TDirectory * otherHistDir