8 #include <onlmon/OnlMon.h>
9 #include <onlmon/OnlMonDB.h>
10 #include <onlmon/OnlMonServer.h>
11 #include <onlmon/pseudoRunningMean.h>
13 #include <calobase/TowerInfoDefs.h>
14 #include <caloreco/CaloWaveformFitting.h>
16 #include <Event/Event.h>
17 #include <Event/msg_profile.h>
18 #include <Event/eventReceiverClient.h>
48 else if (name[0] ==
'I')
55 std::cout <<
"HcalMon::HcalMon - unknown name(need to be OHCALMON or IHCALMON to know what packet to run) " << name << std::endl;
116 printf(
"doing the Init\n");
118 h2_hcal_hits =
new TH2F(
"h2_hcal_hits",
"", 24, 0, 24, 64, 0, 64);
120 h_hcal_trig =
new TH1F(
"h_hcal_trig",
"", 64, 0, 64);
121 h2_hcal_rm =
new TH2F(
"h2_hcal_rm",
"", 24, 0, 24, 64, 0, 64);
122 h2_hcal_mean =
new TH2F(
"h2_hcal_mean",
"", 24, 0, 24, 64, 0, 64);
125 h_event =
new TH1F(
"h_event",
"", 1, 0, 1);
131 h_ntower =
new TH1F(
"h_ntower",
"", 100, 0, 800);
139 for (
int ih = 0; ih <
Nsector; ih++)
141 for (
int ieta = 0; ieta < 24; ieta++)
143 for (
int iphi = 0; iphi < 64; iphi++)
145 h_rm_tower[ieta][iphi] =
new TH1F(Form(
"h_rm_tower_%d_%d", ieta, iphi), Form(
"running mean of tower ieta=%d, iphi=%d", ieta, iphi),
historyLength, 0,
historyLength * historyScaleDown);
158 for (
int i = 0;
i < 8;
i++)
186 for (
int ih = 0; ih <
Nsector; ih++)
189 for (
int ieta = 0; ieta < 24; ieta++)
191 for (
int iphi = 0; iphi < 64; iphi++)
203 if (getenv(
"HCALCALIB"))
205 hcaltemplate = getenv(
"HCALCALIB");
211 hcaltemplate +=
std::string(
"/testbeam_ohcal_template.root");
224 for (
int s = 0;
s < 3;
s++)
226 baseline += p->
iValue(
s, channel);
232 for (
int s = 3;
s < p->
iValue(0,
"SAMPLES");
s++)
234 if (signal > p->
iValue(
s, channel))
236 signal = p->
iValue(
s, channel);
242 std::vector<float> result;
243 result.push_back(signal);
244 result.push_back(sample);
245 result.push_back(baseline);
252 std::vector<float> waveform;
253 for (
int s = 0;
s < p->
iValue(0,
"SAMPLES");
s++)
255 waveform.push_back(p->
iValue(
s, channel));
257 std::vector<std::vector<float>> multiple_wfs;
258 multiple_wfs.push_back(waveform);
260 std::vector<std::vector<float>> fitresults_ohcal;
264 std::vector<float> result;
265 result = fitresults_ohcal.at(0);
275 std::vector<runningMean*>::iterator rm_it;
308 unsigned int towerNumber = 0;
309 float sectorAvg[
Nsector] = {0};
316 bool trig_fire =
false;
317 std::vector<bool> trig_bools;
318 long long int gl1_clock = 0;
325 gl1_clock = p->
lValue(0,
"BCO");
326 int triggervec = p->
lValue(0,
"TriggerVector");
327 for (
int i = 0;
i < 64;
i++ ) {
328 bool trig_decision = (bool) triggervec & 1;
329 trig_bools.push_back(trig_decision);
331 triggervec = triggervec >> 1;
333 trig_fire = trig_bools[2];
352 long long int p_clock = p->
iValue(0,
"CLOCK");
353 long long int diff = (p_clock - gl1_clock) % 65536;
355 int nChannels = p->
iValue(0,
"CHANNELS");
366 for (
int c = 0;
c < nChannels;
c++)
372 float signal = result.at(0);
373 float time = result.at(1);
375 if (signal > 15 && signal< 15000) energy1 +=
signal;
381 int sectorNumber = phi_bin / 2 + 1;
385 sectorAvg[sectorNumber - 1] +=
signal;
389 int bin =
h2_hcal_mean->FindBin(eta_bin + 0.5, phi_bin + 0.5);
397 if (
evtcnt % historyScaleDown == 0)
405 if (
evtcnt % historyScaleDown == 0)
425 for (
int s = 0;
s < p->
iValue(0,
"SAMPLES");
s++)
449 for (
int i = packetlowdiff;
i <= packethighdiff;
i++)
454 int nChannels = p->
iValue(0,
"CHANNELS");
463 for (
int c = 0;
c < nChannels;
c++)
467 float signal = result.at(0);
468 if (signal > 15 && signal<15000) energy2 +=
signal;
474 if (npacket1 == 4 && npacket2 == 4)
482 for (
int isec = 0; isec <
Nsector; isec++)
484 sectorAvg[isec] /= 48;
490 if (
evtcnt % historyScaleDown == 0)
498 if (
evtcnt % historyScaleDown == 0)