13 #include <TObjArray.h>
16 #ifndef NEW_DAQ_READER
17 # include "evpReader.hh"
18 # include "emcReader.h"
19 # include "trgReader.h"
20 #define BSMD_FIBERS 12
21 #define BSMD_DATSIZE 4800
23 # include "DAQ_READER/daqReader.h"
24 # include "DAQ_READER/daq_dta.h"
25 # include "DAQ_BSMD/daq_bsmd.h"
26 # include "DAQ_BTOW/daq_btow.h"
27 # include "DAQ_EMC/daq_emc.h"
28 # include "DAQ_TRG/daq_trg.h"
29 # include <RTS/include/daqFormats.h>
32 #include <StEmcUtil/database/StEmcDecoder.h>
33 #include <StEmcUtil/geometry/StEmcGeom.h>
35 #include "BEMCPlots.h"
36 #include "BEMC_DSM_decoder.h"
37 #include "BEMCPlotsNames.h"
45 #define BEMCNOTINSTALLED 2
46 #define BEMCCORRUPTED 3
54 void BEMCPlots::initHisto(TObjArray *list,
const char *bemcStatus) {
55 if (BEMCPlotsInstance)
delete BEMCPlotsInstance; BEMCPlotsInstance = 0;
57 if (BEMCPlotsInstance) {
58 BEMCPlotsInstance->setDebug(0);
59 BEMCPlotsInstance->clear(bemcStatus);
65 void BEMCPlots::resetHisto(
const char *bemcStatus) {
66 if (BEMCPlotsInstance) {
67 BEMCPlotsInstance->clear(bemcStatus);
71 void BEMCPlots::saveHisto(TFile *hfile) {
72 if (BEMCPlotsInstance) {
73 BEMCPlotsInstance->saveHistograms(hfile);
77 void BEMCPlots::fillHisto(
char *datap
78 ,
const unsigned char *dsmL0WestInput
79 ,
const unsigned char *dsmL0EastInput
80 ,
const unsigned short *dsmL1Input
81 ,
const unsigned short *dsmL2Input
82 ,
const unsigned short *dsmL3Input
85 if (BEMCPlotsInstance) {
86 BEMCPlotsInstance->processEvent(datap, dsmL0WestInput, dsmL0EastInput, dsmL1Input, dsmL2Input, dsmL3Input);
90 BEMCPlots::BEMCPlots(TObjArray *list)
94 #define ADDHIST(hist) if (list && (hist)) list->Add(hist);
96 this->mHistTot =
new TH1F(HistTotName,
"BEMC, Total number of events processed;;Number of events", 1, 0, 1);
97 ADDHIST(this->mHistTot)
99 this->mHistDsmL0InputHighTower = new TH2F(HistDsmL0InputHighTowerName, "BEMC
DSM L0 Input - HighTower;triggerPatch;HighTower", 300, -0.5, 300 - 0.5, 64, 0, 64);
100 ADDHIST(this->mHistDsmL0InputHighTower)
101 this->mHistDsmL0InputPatchSum = new TH2F(HistDsmL0InputPatchSumName, "BEMC
DSM L0 Input - PatchSum;triggerPatch;PatchSum", 300, -0.5, 300 - 0.5, 64, 0, 64);
102 ADDHIST(this->mHistDsmL0InputPatchSum)
104 this->mHistDsmL1InputHighTowerBits = new TH2F(HistDsmL1InputHighTowerBitsName, "BEMC
DSM L1 Input - HighTower bits;
DSM Level-1 channels;HighTower bits", 36, -0.5, 36-0.5, 5, 0, 5);
105 ADDHIST(this->mHistDsmL1InputHighTowerBits)
106 this->mHistDsmL1InputPatchSum = new TH2F(HistDsmL1InputPatchSumName, "BEMC
DSM L1 Input - PatchSum;Channel;PatchSum", 36, -0.5, 36-0.5, 128, 0, 256);
107 ADDHIST(this->mHistDsmL1InputPatchSum)
109 this->mHistDsmL2InputHighTowerBits = new TH2F(HistDsmL2InputHighTowerBitsName, "BEMC
DSM L2 Input - HighTower bits;JetPatch;HighTower bits", BEMCNJET, -0.5, BEMCNJET-0.5, 5, 0, 5);
110 ADDHIST(this->mHistDsmL2InputHighTowerBits)
111 this->mHistDsmL2InputPatchSumBits = new TH2F(HistDsmL2InputPatchSumBitsName, "BEMC
DSM L2 Input - PatchSum bits;JetPatch;PatchSum bits", BEMCNJET, -0.5, BEMCNJET-0.5, 4, 0, 4);
112 ADDHIST(this->mHistDsmL2InputPatchSumBits)
113 this->mHistDsmL2InputPatchSum = new TH2F(HistDsmL2InputPatchSumName, "BEMC
DSM L2 Input - PatchSum;JetPatch pair;PatchSum", 6, -0.5, 6-0.5, 256, 0, 256);
114 ADDHIST(this->mHistDsmL2InputPatchSum)
116 this->mHistDsmL3InputHighTowerBits = new TH1F(HistDsmL3InputHighTowerBitsName, "BEMC
DSM L3 Input - HighTower bits;HighTower bits", 4, -0.5, 4-0.5);
117 ADDHIST(this->mHistDsmL3InputHighTowerBits)
118 this->mHistDsmL3InputPatchSumBits = new TH1F(HistDsmL3InputPatchSumBitsName, "BEMC
DSM L3 Input - PatchSum bits;PatchSum bits", 4, -0.5, 4-0.5);
119 ADDHIST(this->mHistDsmL3InputPatchSumBits)
120 this->mHistDsmL3InputBackToBackBit = new TH1F(HistDsmL3InputBackToBackBitName, "BEMC
DSM L3 Input - Back-to-Back bit;Back-to-Back bit", 2, -0.5, 2-0.5);
121 ADDHIST(this->mHistDsmL3InputBackToBackBit)
122 this->mHistDsmL3InputJPsiTopoBit = new TH1F(HistDsmL3InputJPsiTopoBitName, "BEMC
DSM L3 Input - J/Psi topology bit;J/Psi bit", 2, -0.5, 2-0.5);
123 ADDHIST(this->mHistDsmL3InputJPsiTopoBit)
124 this->mHistDsmL3InputJetPatchTopoBit = new TH1F(HistDsmL3InputJetPatchTopoBitName, "BEMC
DSM L3 Input - JetPatch topology bit;JetPatch bit", 2, -0.5, 2-0.5);
125 ADDHIST(this->mHistDsmL3InputJetPatchTopoBit)
127 this->mHistRawAdc1 = new TH2F(HistRawAdc1Name, "BTOW ADC, 1 <= SoftId <= 1220;SoftId;ADC", 1220, 0000.5, 1220.5, 300, -0.5, 4096-0.5);
128 this->mHistRawAdc2 = new TH2F(HistRawAdc2Name, "BTOW ADC, 1221 <= SoftId <= 2400;SoftId;ADC", 1180, 1220.5, 2400.5, 300, -0.5, 4096-0.5);
129 this->mHistRawAdc3 = new TH2F(HistRawAdc3Name, "BTOW ADC, 2401 <= SoftId <= 3540;SoftId;ADC", 1140, 2400.5, 3540.5, 300, -0.5, 4096-0.5);
130 this->mHistRawAdc4 = new TH2F(HistRawAdc4Name, "BTOW ADC, 3541 <= SoftId <= 4800;SoftId;ADC", 1260, 3540.5, 4800.5, 300, -0.5, 4096-0.5);
132 this->mHistRawAdc1zoom = new TH2F(HistRawAdc1NameZoom, "BTOW ADC, 1 <= SoftId <= 1220;SoftId;ADC", 1220, 0000.5, 1220.5, 300, -0.5, 500-0.5);
133 this->mHistRawAdc2zoom = new TH2F(HistRawAdc2NameZoom, "BTOW ADC, 1221 <= SoftId <= 2400;SoftId;ADC", 1180, 1220.5, 2400.5, 300, -0.5, 500-0.5);
134 this->mHistRawAdc3zoom = new TH2F(HistRawAdc3NameZoom, "BTOW ADC, 2401 <= SoftId <= 3540;SoftId;ADC", 1140, 2400.5, 3540.5, 300, -0.5, 500-0.5);
135 this->mHistRawAdc4zoom = new TH2F(HistRawAdc4NameZoom, "BTOW ADC, 3541 <= SoftId <= 4800;SoftId;ADC", 1260, 3540.5, 4800.5, 300, -0.5, 500-0.5);
137 this->mHistRawAdcPsd1 = new TH2F(HistRawAdcPsd1Name, "BPRS ADC, 1 <= SoftId <= 1220;SoftId;ADC", 1220, 0000.5, 1220.5, 300, -0.5, 1000-0.5);
138 this->mHistRawAdcPsd2 = new TH2F(HistRawAdcPsd2Name, "BPRS ADC, 1221 <= SoftId <= 2400;SoftId;ADC", 1180, 1220.5, 2400.5, 300, -0.5, 1000-0.5);
139 this->mHistRawAdcPsd3 = new TH2F(HistRawAdcPsd3Name, "BPRS ADC, 2401 <= SoftId <= 3540;SoftId;ADC", 1140, 2400.5, 3540.5, 300, -0.5, 1000-0.5);
140 this->mHistRawAdcPsd4 = new TH2F(HistRawAdcPsd4Name, "BPRS ADC, 3541 <= SoftId <= 4800;SoftId;ADC", 1260, 3540.5, 4800.5, 300, -0.5, 1000-0.5);
142 this->mHistSmdFeeSum = new TH2F(HistSmdFeeSumName, "BSMD FEE Sum;Module;Sum", 120, 0.5, 120+0.5, 100, -0.5, 5000-0.5);
143 this->mHistPsdFeeSum = new TH2F(HistPsdFeeSumName, "BPRS FEE Sum;PMT Box;Sum", 60, 0.5, 60+0.5, 100, -0.5, 5000-0.5);
145 this->mHistSmdFeeSumNonZS = new TH2F(HistSmdFeeSumNonZSName, "BSMD FEE Sum, Non-ZS;Module;Sum", 120, 0.5, 120+0.5, 100, -0.5, 100000-0.5);
146 this->mHistPsdFeeSumNonZS = new TH2F(HistPsdFeeSumNonZSName, "BPRS FEE Sum, Non-ZS;PMT Box;Sum", 60, 0.5, 60+0.5, 100, -0.5, 40000-0.5);
148 ADDHIST(this->mHistRawAdc1)
149 ADDHIST(this->mHistRawAdc2)
150 ADDHIST(this->mHistRawAdc3)
151 ADDHIST(this->mHistRawAdc4)
153 ADDHIST(this->mHistRawAdc1zoom)
154 ADDHIST(this->mHistRawAdc2zoom)
155 ADDHIST(this->mHistRawAdc3zoom)
156 ADDHIST(this->mHistRawAdc4zoom)
158 ADDHIST(this->mHistRawAdcPsd1)
159 ADDHIST(this->mHistRawAdcPsd2)
160 ADDHIST(this->mHistRawAdcPsd3)
161 ADDHIST(this->mHistRawAdcPsd4)
163 ADDHIST(this->mHistSmdFeeSum)
164 ADDHIST(this->mHistPsdFeeSum)
166 ADDHIST(this->mHistSmdFeeSumNonZS)
167 ADDHIST(this->mHistPsdFeeSumNonZS)
169 for (
int i = 0;i < BEMCNJET;i++) {
172 name = Form(
"%s_%u", HistHighTowerSpectrumName, i);
173 title = Form(
"JetPatch %u - HighTower spectrum;HighTower", i);
174 this->mHistHighTowerSpectrum[i] =
new TH1F(name.Data(), title.Data(), 64, -0.5, 64-0.5);
175 ADDHIST(this->mHistHighTowerSpectrum[i])
176 name = Form(
"%s_%u", HistPatchSumSpectrumName, i);
177 title = Form(
"JetPatch %u - PatchSum spectrum;PatchSum", i);
178 this->mHistPatchSumSpectrum[i] =
new TH1F(name.Data(), title.Data(), 200, -0.5, 300-0.5);
179 ADDHIST(this->mHistPatchSumSpectrum[i])
182 this->mHistTriggerCorruptionHighTower =
new TH1F(HistTriggerCorruptionHighTowerName,
"HighTower DSM L0 Input; triggerPatch;events", 300, -0.5, 300-0.5);
183 this->mHistTriggerCorruptionPatchSum =
new TH1F(HistTriggerCorruptionPatchSumName,
"PatchSum DSM L0 Input; triggerPatch;events", 300, -0.5, 300-0.5);
184 this->mHistDSM0HTCorr =
new TH2F(HistDSM0HTCorrName,
"HighTower DSM L0 Input; DSM HighTower;Simulated HighTower", 64, 0, 64, 64, 0, 64);
185 this->mHistDSM0TPCorr =
new TH2F(HistDSM0TPCorrName,
"PatchSum DSM L0 Input; DSM PatchSum;Simulated PatchSum", 64, 0, 64, 64, 0, 64);
187 ADDHIST(this->mHistTriggerCorruptionHighTower)
188 ADDHIST(this->mHistTriggerCorruptionPatchSum)
189 ADDHIST(this->mHistDSM0HTCorr)
190 ADDHIST(this->mHistDSM0TPCorr)
192 this->mHist_TDC_status = new TH2F(Hist_TDC_statusName, "BEMC TDC Status;0=total 1=OK 2=Not Installed3=Corrupted",5,-0.5,4.5,30,-0.5,29.5);
193 this->mHist_SMD_status = new TH2F(Hist_SMD_statusName, "BEMC SMD Status;0=total 1=OK 2=Not Installed3=Corrupted",5,-0.5,4.5,8,-0.5,7.5);
194 this->mHist_PSD_status = new TH2F(Hist_PSD_statusName, "BEMC PSD Status;0=total 1=OK 2=Not Installed 3=Corrupted",5,-0.5,4.5,4,-0.5,3.5);
195 this->mHist_BTOW_Corruption = new TH1F(Hist_BTOW_CorruptionName, "BEMC TDC corruption frequency;0=total 1=OK 2=Not Installed 3=Corrupted",5,-0.5,4.5);
197 this->mHist_btow_spectra_1 = new TH2F(Hist_btow_spectra_1Name, "BEMC tower spectrum 0 < TDC < 10;X = 160*TDC + index", 1600, -0.5,1599.5,100,0,500);
198 this->mHist_btow_spectra_2 = new TH2F(Hist_btow_spectra_2Name, "BEMC tower spectrum 10 < TDC < 20;X = 160*TDC + index", 1600,1599.5,3199.5,100,0,500);
199 this->mHist_btow_spectra_3 = new TH2F(Hist_btow_spectra_3Name, "BEMC tower spectrum 20 < TDC < 30;X = 160*TDC + index", 1600,3199.5,4799.5,100,0,500);
201 this->mHist_smd_spectra = new TH1F(Hist_smd_spectraName, "BEMC SMD total ADC",250,100000.,6000000.);
202 this->mHist_smd_spectraNonZS= new TH1F(Hist_smd_spectraNonZSName, "BEMC SMD total ADC, Non-ZS",250,100000.,6000000.);
203 this->mHist_smd_capacitor = new TH2F(Hist_smd_capacitorName, "BEMC SMD capacitor distribution",128,-0.5,127.5,8,-0.5,7.5);
204 this->mHist_smd_sum = new TH2F(Hist_smd_sumName, "BEMC SMD total ADC per fiber",250,100000.,1000000.,8,-0.5,7.5);
205 this->mHist_psd_spectra = new TH1F(Hist_psd_spectraName, "BEMC PSD total ADC",250,100000.,4000000.);
206 this->mHist_psd_spectraNonZS= new TH1F(Hist_psd_spectraNonZSName, "BEMC PSD total ADC, Non-ZS",250,100000.,4000000.);
207 this->mHist_psd_capacitor = new TH2F(Hist_psd_capacitorName, "BEMC PSD capacitor distribution",128,-0.5,127.5,4,-0.5,3.5);
208 this->mHist_psd_sum = new TH2F(Hist_psd_sumName, "BEMC PSD total ADC per fiber",250,100000.,1000000.,4,-0.5,3.5);
210 this->mHist_HTMAX_spectra = new TH2F(Hist_HTMAX_spectraName, "BEMC Maximum High
Tower spectrum", 300,-0.5,299.5,64,-0.5,63.5);
211 this->mHist_PAMAX_spectra = new TH2F(Hist_PAMAX_spectraName, "BEMC Maximum Patch Sum spectrum", 300,-0.5,299.5,64,-0.5,63.5);
212 this->mHist_HTMAX_dist = new TH1F(Hist_HTMAX_distName, "BEMC Maximum High
Tower distribution", 300,-0.5,299.5);
213 this->mHist_PAMAX_dist = new TH1F(Hist_PAMAX_distName, "BEMC Maximum Patch Sum distribution", 300,-0.5,299.5);
215 this->mHist_JET_spectra = new TH2F(Hist_JET_spectraName, "BEMC Jet sum spectrum", BEMCNJET,-0.5,BEMCNJET-0.5,80,-0.5,79.5);
216 this->mHist_JETMAX_spectra = new TH2F(Hist_JETMAX_spectraName, "BEMC Maximum Jet sum spectrum", BEMCNJET,-0.5,BEMCNJET-0.5,80,-0.5,79.5);
217 this->mHist_JET_ped = new TH2F(Hist_JET_pedName, "BEMC Jet sum pedestal", BEMCNJET,-0.5,BEMCNJET-0.5,30,15,45);
218 this->mHist_JETMAX_dist = new TH1F(Hist_JETMAX_distName, "BEMC Maximum Jet sum distribution", BEMCNJET,-0.5,BEMCNJET-0.5);
220 ADDHIST(this->mHist_TDC_status)
221 ADDHIST(this->mHist_SMD_status)
222 ADDHIST(this->mHist_PSD_status)
223 ADDHIST(this->mHist_BTOW_Corruption)
225 ADDHIST(this->mHist_btow_spectra_1)
226 ADDHIST(this->mHist_btow_spectra_2)
227 ADDHIST(this->mHist_btow_spectra_3)
229 ADDHIST(this->mHist_smd_spectra)
230 ADDHIST(this->mHist_smd_spectraNonZS)
231 ADDHIST(this->mHist_smd_capacitor)
232 ADDHIST(this->mHist_smd_sum)
233 ADDHIST(this->mHist_psd_spectra)
234 ADDHIST(this->mHist_psd_spectraNonZS)
235 ADDHIST(this->mHist_psd_capacitor)
236 ADDHIST(this->mHist_psd_sum)
238 ADDHIST(this->mHist_HTMAX_spectra)
239 ADDHIST(this->mHist_PAMAX_spectra)
240 ADDHIST(this->mHist_HTMAX_dist)
241 ADDHIST(this->mHist_PAMAX_dist)
243 ADDHIST(this->mHist_JET_spectra)
244 ADDHIST(this->mHist_JETMAX_spectra)
245 ADDHIST(this->mHist_JET_ped)
246 ADDHIST(this->mHist_JETMAX_dist)
248 this->mHist_ADCEtaPhi_TowHits = new TH2F(Hist_ADCEtaPhi_TowHitsName, "
Tower hits>ped+20; Phi Bin; Eta Bin",120 ,-3.15 ,3.15, 40, -1, 1);
249 this->mHist_ADCEtaPhi_Pre1Hits = new TH2F(Hist_ADCEtaPhi_Pre1HitsName, "BPSD hits>ped+20;Phi Bin; Eta Bin",120, -3.15, 3.15, 40, -1, 1);
251 ADDHIST(this->mHist_ADCEtaPhi_TowHits)
252 ADDHIST(this->mHist_ADCEtaPhi_Pre1Hits)
257 for (
int i = 0;i < 4800;i++) {
258 this->mTowerData[i][0] = 1;
259 this->mTowerData[i][1] = 0;
260 this->mTowerData[i][2] = 0;
262 this->mTriggerPedestalShift = 24 * 100;
263 for (
int i = 0;i < 300;i++) {
264 this->mPatchData[i][0] = 1;
265 this->mPatchData[i][1] = 1;
266 this->mPatchData[i][2] = 3;
267 this->mPatchData[i][3] = 2;
268 this->mPatchData[i][4] = 1;
269 this->mPatchData[i][5] = 0;
270 this->mPatchData[i][6] = 0;
271 this->mPatchData[i][7] = 1;
272 this->mPatchData[i][8] = 0;
273 this->mPatchData[i][9] = 0;
274 this->mPatchData[i][10] = 0;
276 memset(this->BEMCJPPED, 0,
sizeof(this->BEMCJPPED));
277 memset(this->BEMCNJPPED, 0,
sizeof(this->BEMCNJPPED));
281 BEMCPlots::~BEMCPlots() {
282 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
284 #define DELETEHIST(HIST) if (HIST) delete (HIST); (HIST) = 0;
286 DELETEHIST(this->mHistTot)
288 DELETEHIST(this->mHistDsmL0InputHighTower)
289 DELETEHIST(this->mHistDsmL0InputPatchSum)
291 DELETEHIST(this->mHistDsmL1InputHighTowerBits)
292 DELETEHIST(this->mHistDsmL1InputPatchSum)
294 DELETEHIST(this->mHistDsmL2InputHighTowerBits)
295 DELETEHIST(this->mHistDsmL2InputPatchSumBits)
296 DELETEHIST(this->mHistDsmL2InputPatchSum)
298 DELETEHIST(this->mHistDsmL3InputHighTowerBits)
299 DELETEHIST(this->mHistDsmL3InputPatchSumBits)
300 DELETEHIST(this->mHistDsmL3InputBackToBackBit)
301 DELETEHIST(this->mHistDsmL3InputJPsiTopoBit)
302 DELETEHIST(this->mHistDsmL3InputJetPatchTopoBit)
304 DELETEHIST(this->mHistRawAdc1)
305 DELETEHIST(this->mHistRawAdc2)
306 DELETEHIST(this->mHistRawAdc3)
307 DELETEHIST(this->mHistRawAdc4)
309 DELETEHIST(this->mHistRawAdc1zoom)
310 DELETEHIST(this->mHistRawAdc2zoom)
311 DELETEHIST(this->mHistRawAdc3zoom)
312 DELETEHIST(this->mHistRawAdc4zoom)
314 DELETEHIST(this->mHistRawAdcPsd1)
315 DELETEHIST(this->mHistRawAdcPsd2)
316 DELETEHIST(this->mHistRawAdcPsd3)
317 DELETEHIST(this->mHistRawAdcPsd4)
319 DELETEHIST(this->mHistSmdFeeSum)
320 DELETEHIST(this->mHistPsdFeeSum)
322 DELETEHIST(this->mHistSmdFeeSumNonZS)
323 DELETEHIST(this->mHistPsdFeeSumNonZS)
325 for (
int i = 0;i < BEMCNJET;i++) {
326 DELETEHIST(this->mHistHighTowerSpectrum[i])
327 DELETEHIST(this->mHistPatchSumSpectrum[i])
330 DELETEHIST(this->mHistTriggerCorruptionHighTower)
331 DELETEHIST(this->mHistTriggerCorruptionPatchSum)
332 DELETEHIST(this->mHistDSM0HTCorr)
333 DELETEHIST(this->mHistDSM0TPCorr)
335 DELETEHIST(this->mHist_TDC_status)
336 DELETEHIST(this->mHist_SMD_status)
337 DELETEHIST(this->mHist_PSD_status)
338 DELETEHIST(this->mHist_BTOW_Corruption)
340 DELETEHIST(this->mHist_btow_spectra_1)
341 DELETEHIST(this->mHist_btow_spectra_2)
342 DELETEHIST(this->mHist_btow_spectra_3)
344 DELETEHIST(this->mHist_smd_spectra)
345 DELETEHIST(this->mHist_smd_spectraNonZS)
346 DELETEHIST(this->mHist_smd_capacitor)
347 DELETEHIST(this->mHist_smd_sum)
348 DELETEHIST(this->mHist_psd_spectra)
349 DELETEHIST(this->mHist_psd_spectraNonZS)
350 DELETEHIST(this->mHist_psd_capacitor)
351 DELETEHIST(this->mHist_psd_sum)
353 DELETEHIST(this->mHist_HTMAX_spectra)
354 DELETEHIST(this->mHist_PAMAX_spectra)
355 DELETEHIST(this->mHist_HTMAX_dist)
356 DELETEHIST(this->mHist_PAMAX_dist)
358 DELETEHIST(this->mHist_JET_spectra)
359 DELETEHIST(this->mHist_JETMAX_spectra)
360 DELETEHIST(this->mHist_JET_ped)
362 DELETEHIST(this->mHist_JETMAX_dist)
364 DELETEHIST(this->mHist_ADCEtaPhi_TowHits)
365 DELETEHIST(this->mHist_ADCEtaPhi_Pre1Hits)
371 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
374 void BEMCPlots::init(
unsigned int date,
unsigned int time,
const char *bemcStatus) {
376 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
377 this->clear(bemcStatus);
378 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
382 void BEMCPlots::clear(
const char *bemcStatus) {
383 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
384 if (mDebug >= 2) cout <<
"bemcStatus = " << bemcStatus << endl;
386 #define RESETHIST(HIST) if (HIST) (HIST)->Reset();
388 RESETHIST(this->mHistTot)
390 RESETHIST(this->mHistDsmL0InputHighTower)
391 RESETHIST(this->mHistDsmL0InputPatchSum)
393 RESETHIST(this->mHistDsmL1InputHighTowerBits)
394 RESETHIST(this->mHistDsmL1InputPatchSum)
396 RESETHIST(this->mHistDsmL2InputHighTowerBits)
397 RESETHIST(this->mHistDsmL2InputPatchSumBits)
398 RESETHIST(this->mHistDsmL2InputPatchSum)
400 RESETHIST(this->mHistDsmL3InputHighTowerBits)
401 RESETHIST(this->mHistDsmL3InputPatchSumBits)
402 RESETHIST(this->mHistDsmL3InputBackToBackBit)
403 RESETHIST(this->mHistDsmL3InputJPsiTopoBit)
404 RESETHIST(this->mHistDsmL3InputJetPatchTopoBit)
406 RESETHIST(this->mHistRawAdc1)
407 RESETHIST(this->mHistRawAdc2)
408 RESETHIST(this->mHistRawAdc3)
409 RESETHIST(this->mHistRawAdc4)
411 RESETHIST(this->mHistRawAdc1zoom)
412 RESETHIST(this->mHistRawAdc2zoom)
413 RESETHIST(this->mHistRawAdc3zoom)
414 RESETHIST(this->mHistRawAdc4zoom)
416 RESETHIST(this->mHistRawAdcPsd1)
417 RESETHIST(this->mHistRawAdcPsd2)
418 RESETHIST(this->mHistRawAdcPsd3)
419 RESETHIST(this->mHistRawAdcPsd4)
421 RESETHIST(this->mHistSmdFeeSum)
422 RESETHIST(this->mHistPsdFeeSum)
424 RESETHIST(this->mHistSmdFeeSumNonZS)
425 RESETHIST(this->mHistPsdFeeSumNonZS)
427 for (
int i = 0;i < BEMCNJET;i++) {
428 RESETHIST(this->mHistHighTowerSpectrum[i])
429 RESETHIST(this->mHistPatchSumSpectrum[i])
432 RESETHIST(this->mHistTriggerCorruptionHighTower)
433 RESETHIST(this->mHistTriggerCorruptionPatchSum)
434 RESETHIST(this->mHistDSM0HTCorr)
435 RESETHIST(this->mHistDSM0TPCorr)
437 RESETHIST(this->mHist_TDC_status)
438 RESETHIST(this->mHist_SMD_status)
439 RESETHIST(this->mHist_PSD_status)
440 RESETHIST(this->mHist_BTOW_Corruption)
442 RESETHIST(this->mHist_btow_spectra_1)
443 RESETHIST(this->mHist_btow_spectra_2)
444 RESETHIST(this->mHist_btow_spectra_3)
446 RESETHIST(this->mHist_smd_spectra)
447 RESETHIST(this->mHist_smd_spectraNonZS)
448 RESETHIST(this->mHist_smd_capacitor)
449 RESETHIST(this->mHist_smd_sum)
450 RESETHIST(this->mHist_psd_spectra)
451 RESETHIST(this->mHist_psd_spectraNonZS)
452 RESETHIST(this->mHist_psd_capacitor)
453 RESETHIST(this->mHist_psd_sum)
455 RESETHIST(this->mHist_HTMAX_spectra)
456 RESETHIST(this->mHist_PAMAX_spectra)
457 RESETHIST(this->mHist_HTMAX_dist)
458 RESETHIST(this->mHist_PAMAX_dist)
460 RESETHIST(this->mHist_JET_spectra)
461 RESETHIST(this->mHist_JETMAX_spectra)
462 RESETHIST(this->mHist_JET_ped)
463 RESETHIST(this->mHist_JETMAX_dist)
465 RESETHIST(this->mHist_ADCEtaPhi_TowHits)
466 RESETHIST(this->mHist_ADCEtaPhi_Pre1Hits)
471 for (
int i = 0;i < 4800;i++) {
472 this->mTowerData[i][0] = 1;
473 this->mTowerData[i][1] = 0;
474 this->mTowerData[i][2] = 0;
476 this->mTriggerPedestalShift = 24 * 100;
477 for (
int i = 0;i < 300;i++) {
478 this->mPatchData[i][0] = 1;
479 this->mPatchData[i][1] = 1;
480 this->mPatchData[i][2] = 3;
481 this->mPatchData[i][3] = 2;
482 this->mPatchData[i][4] = 1;
483 this->mPatchData[i][5] = 0;
484 this->mPatchData[i][6] = 0;
485 this->mPatchData[i][7] = 1;
486 this->mPatchData[i][8] = 0;
487 this->mPatchData[i][9] = 0;
488 this->mPatchData[i][10] = 0;
490 memset(this->BEMCJPPED, 0,
sizeof(this->BEMCJPPED));
491 memset(this->BEMCNJPPED, 0,
sizeof(this->BEMCNJPPED));
496 ifstream ifstr(bemcStatus);
498 cout <<
"Reading BEMC trigger status file " << bemcStatus << endl;
500 cout <<
"Cannot open BEMC trigger status file! " << bemcStatus << endl;
502 while (ifstr.good()) {
507 ifstr.getline(dummy,
sizeof(dummy));
510 }
while (ifstr.good() && (token !=
"SoftId") && (token !=
"triggerPatch") && (token !=
"TriggerPedestalShift"));
512 if (token ==
"SoftId") {
513 int softId, crate, crateSeq, unmaskTower, unmaskHT, unmaskPA, triggerPatch;
515 ifstr >> softId >> crate >> crateSeq >> unmaskTower >> unmaskHT >> unmaskPA >> ped >> triggerPatch;
516 if (mDebug >= 2) cout <<
"Read: " << token <<
" " << softId <<
"\t" << crate <<
"\t" << crateSeq <<
"\t" << unmaskTower <<
"\t" << unmaskHT <<
"\t" << unmaskPA <<
"\t" << ped <<
"\t" << triggerPatch << endl;
517 if ((softId >= 1) && (softId <= 4800)) {
518 towerPed[softId-1]=ped;
519 this->mTowerData[softId - 1][0] = unmaskTower;
520 this->mTowerData[softId - 1][1] = int(ped * 100.0);
523 if ((triggerPatch >= 0) && (triggerPatch < 300) && (unmaskTower == 0)) {
524 this->mPatchData[triggerPatch][10] += 1;
528 }
else if (token ==
"triggerPatch") {
529 int triggerPatch, crate, crateSeq, unmaskHT, unmaskPA, bitConv, formula, formulaParam0, formulaParam1, formulaParam2, formulaParam3, formulaParam4, formulaParam5;
530 ifstr >> triggerPatch >> crate >> crateSeq >> unmaskHT >> unmaskPA >> bitConv >> formula >> formulaParam0 >> formulaParam1 >> formulaParam2 >> formulaParam3 >> formulaParam4 >> formulaParam5;
531 if (mDebug >= 2) cout <<
"Read: " << token <<
" " << triggerPatch <<
"\t" << crate <<
"\t" << crateSeq <<
"\t" << unmaskHT <<
"\t" << unmaskPA <<
"\t" << bitConv <<
"\t" << formula <<
"\t" << formulaParam0 <<
"\t" << formulaParam1 <<
"\t" << formulaParam2 <<
"\t" << formulaParam3 <<
"\t" << formulaParam4 <<
"\t" << formulaParam5 << endl;
532 if ((triggerPatch >= 0) && (triggerPatch < 300)) {
533 this->mPatchData[triggerPatch][0] = unmaskHT;
534 this->mPatchData[triggerPatch][1] = unmaskPA;
535 this->mPatchData[triggerPatch][2] = bitConv;
536 this->mPatchData[triggerPatch][3] = formula;
537 this->mPatchData[triggerPatch][4] = formulaParam0;
538 this->mPatchData[triggerPatch][5] = formulaParam1;
539 this->mPatchData[triggerPatch][6] = formulaParam2;
540 this->mPatchData[triggerPatch][7] = formulaParam3;
541 this->mPatchData[triggerPatch][8] = formulaParam4;
542 this->mPatchData[triggerPatch][9] = formulaParam5;
544 }
else if (token ==
"TriggerPedestalShift") {
547 this->mTriggerPedestalShift = int(pedShift * 100.0);
548 if (mDebug >= 2) cout <<
"Read: " << token <<
" " << pedShift << endl;
553 for (
int i = 0;i < 4800;i++) {
554 this->mTowerData[i][2] = getFEEpedestal(
float(this->mTowerData[i][1]) / 100.0, this->mTriggerPedestalShift / 100.0,
false);
557 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
560 void BEMCPlots::saveHistograms(TFile *hfile) {
561 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
562 if (!hfile || (mDebug >= 2)) cout <<
"hfile = " << hfile << endl;
566 #define SAVEHIST(HIST) if (HIST) (HIST)->Write();
568 SAVEHIST(this->mHistTot)
570 SAVEHIST(this->mHistDsmL0InputHighTower)
571 SAVEHIST(this->mHistDsmL0InputPatchSum)
573 SAVEHIST(this->mHistDsmL1InputHighTowerBits)
574 SAVEHIST(this->mHistDsmL1InputPatchSum)
576 SAVEHIST(this->mHistDsmL2InputHighTowerBits)
577 SAVEHIST(this->mHistDsmL2InputPatchSumBits)
578 SAVEHIST(this->mHistDsmL2InputPatchSum)
580 SAVEHIST(this->mHistDsmL3InputHighTowerBits)
581 SAVEHIST(this->mHistDsmL3InputPatchSumBits)
582 SAVEHIST(this->mHistDsmL3InputBackToBackBit)
583 SAVEHIST(this->mHistDsmL3InputJPsiTopoBit)
584 SAVEHIST(this->mHistDsmL3InputJetPatchTopoBit)
586 SAVEHIST(this->mHistRawAdc1)
587 SAVEHIST(this->mHistRawAdc2)
588 SAVEHIST(this->mHistRawAdc3)
589 SAVEHIST(this->mHistRawAdc4)
591 SAVEHIST(this->mHistRawAdc1zoom)
592 SAVEHIST(this->mHistRawAdc2zoom)
593 SAVEHIST(this->mHistRawAdc3zoom)
594 SAVEHIST(this->mHistRawAdc4zoom)
596 SAVEHIST(this->mHistRawAdcPsd1)
597 SAVEHIST(this->mHistRawAdcPsd2)
598 SAVEHIST(this->mHistRawAdcPsd3)
599 SAVEHIST(this->mHistRawAdcPsd4)
601 SAVEHIST(this->mHistSmdFeeSum)
602 SAVEHIST(this->mHistPsdFeeSum)
604 SAVEHIST(this->mHistSmdFeeSumNonZS)
605 SAVEHIST(this->mHistPsdFeeSumNonZS)
607 for (
int i = 0;i < BEMCNJET;i++) {
608 SAVEHIST(this->mHistHighTowerSpectrum[i])
609 SAVEHIST(this->mHistPatchSumSpectrum[i])
612 SAVEHIST(this->mHistTriggerCorruptionHighTower)
613 SAVEHIST(this->mHistTriggerCorruptionPatchSum)
614 SAVEHIST(this->mHistDSM0HTCorr)
615 SAVEHIST(this->mHistDSM0TPCorr)
617 SAVEHIST(this->mHist_TDC_status)
618 SAVEHIST(this->mHist_SMD_status)
619 SAVEHIST(this->mHist_PSD_status)
620 SAVEHIST(this->mHist_BTOW_Corruption)
622 SAVEHIST(this->mHist_btow_spectra_1)
623 SAVEHIST(this->mHist_btow_spectra_2)
624 SAVEHIST(this->mHist_btow_spectra_3)
626 SAVEHIST(this->mHist_smd_spectra)
627 SAVEHIST(this->mHist_smd_spectraNonZS)
628 SAVEHIST(this->mHist_smd_capacitor)
629 SAVEHIST(this->mHist_smd_sum)
630 SAVEHIST(this->mHist_psd_spectra)
631 SAVEHIST(this->mHist_psd_spectraNonZS)
632 SAVEHIST(this->mHist_psd_capacitor)
633 SAVEHIST(this->mHist_psd_sum)
635 SAVEHIST(this->mHist_HTMAX_spectra)
636 SAVEHIST(this->mHist_PAMAX_spectra)
637 SAVEHIST(this->mHist_HTMAX_dist)
638 SAVEHIST(this->mHist_PAMAX_dist)
640 SAVEHIST(this->mHist_JET_spectra)
641 SAVEHIST(this->mHist_JETMAX_spectra)
642 SAVEHIST(this->mHist_JET_ped)
644 SAVEHIST(this->mHist_JETMAX_dist)
646 SAVEHIST(this->mHist_ADCEtaPhi_TowHits)
647 SAVEHIST(this->mHist_ADCEtaPhi_Pre1Hits)
654 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
661 void BEMCPlots::processEvent(
char *datap
662 ,
const unsigned char *dsmL0WestInput
663 ,
const unsigned char *dsmL0EastInput
664 ,
const unsigned short *dsmL1Input
665 ,
const unsigned short *dsmL2Input
666 ,
const unsigned short *dsmL3Input
669 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
670 #ifdef NEW_DAQ_READER
674 int ret = emcReader(datap);
678 #ifdef NEW_DAQ_READER
679 TDatime evt_time(rdr->evt_time);
681 TDatime evt_time(evp_reader->evt_time);
683 if (BEMCDecoder) BEMCDecoder->SetDateTime(evt_time.GetDate(),evt_time.GetTime());
711 if (!datap || (mDebug >= 2)) cout <<
"datap = " << (
int*)datap << endl;
712 if (!dsmL0WestInput || (mDebug >= 2)) cout <<
"dsmL0WestInput = " << (
int*)dsmL0WestInput << endl;
713 if (!dsmL0EastInput || (mDebug >= 2)) cout <<
"dsmL0EastInput = " << (
int*)dsmL0EastInput << endl;
714 if (!dsmL1Input || (mDebug >= 2)) cout <<
"dsmL1Input = " << (
int*)dsmL1Input << endl;
715 if (!dsmL2Input || (mDebug >= 2)) cout <<
"dsmL2Input = " << (
int*)dsmL2Input << endl;
716 if (!dsmL3Input || (mDebug >= 2)) cout <<
"dsmL3Input = " << (
int*)dsmL3Input << endl;
717 if (!BEMCDecoder || (mDebug >= 2)) cout <<
"BEMCDecoder = " << BEMCDecoder << endl;
719 bool DSM_L0_present = BEMC_DSM_L0_decoder(dsmL0WestInput, dsmL0EastInput, &(this->mDsmL0InputHighTower[0]), &(this->mDsmL0InputPatchSum[0]));
721 bool DSM_L1_present = BEMC_DSM_L1_decoder(dsmL1Input, &(this->mDsmL1InputHighTowerBits[0][0]), &(this->mDsmL1InputPatchSum[0][0]));
723 bool DSM_L2_present = BEMC_DSM_L2_decoder(dsmL2Input, &(this->mDsmL2InputHighTowerBits[0]), &(this->mDsmL2InputPatchSumBits[0]), &(this->mDsmL2InputPatchSum[0]));
725 bool DSM_L3_present = BEMC_DSM_L3_decoder(dsmL3Input, &(this->mDsmL3InputHighTowerBits[0]), &(this->mDsmL3InputPatchSumBits[0]), &(this->mDsmL3InputBackToBackBit[0]), &(this->mDsmL3InputJPsiTopoBit[0]), &(this->mDsmL3InputJetPatchTopoBit[0]));
728 if (this->mHistTot) this->mHistTot->Fill(0.5);
730 if (DSM_L0_present) {
731 int jetPatchSum[BEMCNJET];
732 int jetPatchHT[BEMCNJET];
733 memset(jetPatchSum, 0,
sizeof(jetPatchSum));
734 memset(jetPatchHT, 0,
sizeof(jetPatchHT));
739 for (
int i = 0;i < 300;i++) {
740 if (this->mHistDsmL0InputHighTower) this->mHistDsmL0InputHighTower->Fill(i, this->mDsmL0InputHighTower[i]);
741 if (this->mHistDsmL0InputPatchSum) this->mHistDsmL0InputPatchSum->Fill(i, this->mDsmL0InputPatchSum[i]);
743 if((this->mDsmL0InputHighTower[i] > MAXHT) && (this->mDsmL0InputHighTower[i] < 63)) {MAXHT = this->mDsmL0InputHighTower[i]; MAXHTID = i;}
744 if((this->mDsmL0InputPatchSum[i] > MAXPA) && (this->mDsmL0InputPatchSum[i] < 63)) {MAXPA = this->mDsmL0InputPatchSum[i]; MAXPAID = i;}
747 int jetPatch = -1, jetPatchSeq = -1;
749 if ((jetPatch >= 0) && (jetPatch < BEMCNJET)) {
750 if (jetPatchHT[jetPatch] < this->mDsmL0InputHighTower[i]) jetPatchHT[jetPatch] = this->mDsmL0InputHighTower[i];
751 jetPatchSum[jetPatch] += this->mDsmL0InputPatchSum[i];
756 if (mDebug >= 3) cout <<
"TriggerPatch " << i <<
": HighTower = " << this->mDsmL0InputHighTower[i] <<
", PatchSum = " << this->mDsmL0InputPatchSum[i] << endl;
758 if(this->mHist_HTMAX_spectra) this->mHist_HTMAX_spectra->Fill((
float)MAXHTID,(
float)MAXHT);
759 if(this->mHist_PAMAX_spectra) this->mHist_PAMAX_spectra->Fill((
float)MAXPAID,(
float)MAXPA);
763 if((MAXHT > HTTH) && this->mHist_HTMAX_dist) this->mHist_HTMAX_dist->Fill((
float)MAXHTID);
764 if((MAXPA > PATH) && this->mHist_PAMAX_dist) this->mHist_PAMAX_dist->Fill((
float)MAXPAID);
767 int MAXJETVALUE =-9999;
768 for (
int i = 0;i < BEMCNJET;i++) {
769 if (this->mHistHighTowerSpectrum[i]) this->mHistHighTowerSpectrum[i]->Fill(jetPatchHT[i]);
770 if (this->mHistPatchSumSpectrum[i]) this->mHistPatchSumSpectrum[i]->Fill(jetPatchSum[i]);
771 if (jetPatchSum[i] > MAXJETVALUE) { MAXJETVALUE = jetPatchSum[i]; MAXJETID = i;}
772 if (this->mHist_JET_spectra) this->mHist_JET_spectra->Fill(i, jetPatchSum[i]);
774 if (this->mHist_JETMAX_spectra) this->mHist_JETMAX_spectra->Fill(MAXJETID,MAXJETVALUE);
776 if ((MAXJETVALUE > JETPATH) && this->mHist_JETMAX_dist) this->mHist_JETMAX_dist->Fill(MAXJETID);
778 for (
int i=0;i<BEMCNJET;i++) {
780 BEMCJPPED[i] += jetPatchSum[i];
782 if(BEMCNJPPED[i]==10) {
783 if (this->mHist_JET_ped) this->mHist_JET_ped->Fill(i,(
float)BEMCJPPED[i]/(
float)BEMCNJPPED[i]);
791 if (DSM_L1_present) {
793 for (
int idsmL1 = 0;idsmL1 < 6;idsmL1++) {
794 for (
int idsmL1ch = 0;idsmL1ch < 6;idsmL1ch++) {
795 int idsmL1WestFirst = (idsmL1 < 3) ? (idsmL1 + 3) : (idsmL1 - 3);
796 if (this->mHistDsmL1InputHighTowerBits) this->mHistDsmL1InputHighTowerBits->Fill(ch, this->mDsmL1InputHighTowerBits[idsmL1WestFirst][idsmL1ch]);
797 if (this->mHistDsmL1InputPatchSum) this->mHistDsmL1InputPatchSum->Fill(ch, this->mDsmL1InputPatchSum[idsmL1WestFirst][idsmL1ch]);
803 if (DSM_L2_present) {
804 for (
int ijp = 0;ijp < BEMCNJET;ijp++) {
805 if (this->mHistDsmL2InputHighTowerBits) this->mHistDsmL2InputHighTowerBits->Fill(ijp, this->mDsmL2InputHighTowerBits[ijp]);
806 if (this->mHistDsmL2InputPatchSumBits) this->mHistDsmL2InputPatchSumBits->Fill(ijp, this->mDsmL2InputPatchSumBits[ijp]);
808 for (
int ijpp = 0;ijpp < 6;ijpp++) {
809 int ijppWestFirst = (ijpp < 3) ? (ijpp + 3) : (ijpp - 3);
810 if (this->mHistDsmL2InputPatchSum) this->mHistDsmL2InputPatchSum->Fill(ijppWestFirst, this->mDsmL2InputPatchSum[ijpp]);
814 if (DSM_L3_present) {
815 if (this->mHistDsmL3InputHighTowerBits) this->mHistDsmL3InputHighTowerBits->Fill(this->mDsmL3InputHighTowerBits[0]);
816 if (this->mHistDsmL3InputPatchSumBits) this->mHistDsmL3InputPatchSumBits->Fill(this->mDsmL3InputPatchSumBits[0]);
817 if (this->mHistDsmL3InputBackToBackBit) this->mHistDsmL3InputBackToBackBit->Fill(this->mDsmL3InputBackToBackBit[0]);
818 if (this->mHistDsmL3InputJPsiTopoBit) this->mHistDsmL3InputJPsiTopoBit->Fill(this->mDsmL3InputJPsiTopoBit[0]);
819 if (this->mHistDsmL3InputJetPatchTopoBit) this->mHistDsmL3InputJetPatchTopoBit->Fill(this->mDsmL3InputJetPatchTopoBit[0]);
822 int STATUS = BEMCNOTINSTALLED;
823 #ifdef NEW_DAQ_READER
824 daq_dta *dd_btow = rdr ? (rdr->det(
"btow")->get(
"adc")) : 0;
825 if (dd_btow)
while (dd_btow->iterate()) {
829 if ((ret >= 0) && emc.btow_in) {
830 unsigned short *header = emc.btow_raw;
833 if (DSM_L0_present) {
834 memset(this->mDsmSimuHighTower, 0,
sizeof(this->mDsmSimuHighTower));
835 memset(this->mDsmSimuPatchSum, 0,
sizeof(this->mDsmSimuPatchSum));
837 int TDCStatus[BTOW_MAXFEE];
838 memset(TDCStatus, BEMCNOTINSTALLED,
sizeof(TDCStatus));
841 for (
int tdc = 0; tdc < BTOW_MAXFEE;tdc++) {
842 #ifdef NEW_DAQ_READER
843 int count = d->preamble[tdc][0];
844 int error = d->preamble[tdc][1];
846 int count = (*(header + tdc));
847 int error = (*(header + tdc + 30));
849 if ((error == 0) && (count == (BTOW_PRESIZE + BTOW_DATSIZE))) TDCStatus[tdc] = BEMCOK;
850 else if ((error == 4095) && (count == 4095)) TDCStatus[tdc] = BEMCNOTINSTALLED;
851 else TDCStatus[tdc] = BEMCCORRUPTED;
852 if (TDCStatus[tdc] == BEMCCORRUPTED) STATUS = BEMCCORRUPTED;
853 if (this->mHist_TDC_status) this->mHist_TDC_status->Fill(0.0, tdc);
854 if (this->mHist_TDC_status) this->mHist_TDC_status->Fill((
float)TDCStatus[tdc], tdc);
856 for(
int i = 0;i < (BTOW_MAXFEE * BTOW_DATSIZE);i++) {
857 int tdc = i % BTOW_MAXFEE;
858 #ifdef NEW_DAQ_READER
859 int tdc_channel = i / BTOW_MAXFEE;
860 int count = d->preamble[tdc][0];
861 int error = d->preamble[tdc][1];
863 int count = (*(header + tdc));
864 int error = (*(header + tdc + 30));
866 if((error==0) && (count == (BTOW_PRESIZE + BTOW_DATSIZE))) {
868 #ifdef NEW_DAQ_READER
869 int adc = d->adc[tdc][tdc_channel];
871 int adc = emc.btow[i];
874 int daqid = ((tdc * BTOW_DATSIZE) + tdc_channel);
875 if ((tdc >= 0) && (tdc < 10) && (TDCStatus[tdc]!=BEMCNOTINSTALLED) && this->mHist_btow_spectra_1) this->mHist_btow_spectra_1->Fill(daqid, adc);
876 if ((tdc >= 10) && (tdc < 20) && (TDCStatus[tdc]!=BEMCNOTINSTALLED) && this->mHist_btow_spectra_2) this->mHist_btow_spectra_2->Fill(daqid, adc);
877 if ((tdc >= 20) && (tdc < 30) && (TDCStatus[tdc]!=BEMCNOTINSTALLED) && this->mHist_btow_spectra_3) this->mHist_btow_spectra_3->Fill(daqid, adc);
879 float iphi, eta, adcped;
883 adcped=adc-towerPed[softId-1];
885 StEmcGeom *BEMCGeom = StEmcGeom::instance(
"bemc");
889 BEMCGeom->getEta(softId, eta);
890 BEMCGeom->getPhi(softId, iphi);
891 if ((this->mHist_ADCEtaPhi_TowHits) && (this->mTowerData[softId - 1][0] != 0) ) this->mHist_ADCEtaPhi_TowHits->Fill(iphi, eta);
894 if ((softId >= 1) && (softId <= 4800)) {
895 if ((softId >= 1) && (softId <= 1220)) {
896 if (this->mHistRawAdc1) this->mHistRawAdc1->Fill(softId, adc);
897 if (this->mHistRawAdc1zoom) this->mHistRawAdc1zoom->Fill(softId, adc);
898 }
else if ((softId >= 1221) && (softId <= 2400)) {
899 if (this->mHistRawAdc2) this->mHistRawAdc2->Fill(softId, adc);
900 if (this->mHistRawAdc2zoom) this->mHistRawAdc2zoom->Fill(softId, adc);
901 }
else if ((softId >= 2401) && (softId <= 3540)) {
902 if (this->mHistRawAdc3) this->mHistRawAdc3->Fill(softId, adc);
903 if (this->mHistRawAdc3zoom) this->mHistRawAdc3zoom->Fill(softId, adc);
904 }
else if ((softId >= 3541) && (softId <= 4800)) {
905 if (this->mHistRawAdc4) this->mHistRawAdc4->Fill(softId, adc);
906 if (this->mHistRawAdc4zoom) this->mHistRawAdc4zoom->Fill(softId, adc);
909 if (DSM_L0_present && (this->mTowerData[softId - 1][0] != 0)) {
910 int crate = -1, crateSeq = -1;
912 int triggerPatch = -1;
914 if ((triggerPatch >= 0) && (triggerPatch < 300)) {
915 int ht = -1, pa = -1;
916 if (triggerPatch == 27300) cout <<
"SoftId " << softId <<
" ";
917 simulateFEEaction(adc, this->mTowerData[softId - 1][2], this->mPatchData[triggerPatch][2], ht, pa, (triggerPatch == 27300));
918 if (ht > this->mDsmSimuHighTower[triggerPatch]) this->mDsmSimuHighTower[triggerPatch] = ht;
919 this->mDsmSimuPatchSum[triggerPatch] += pa;
928 for (
int i = 0;i < 300;i++) {
929 if (this->mPatchData[i][0] == 0) this->mDsmSimuHighTower[i] = 0;
930 if (this->mPatchData[i][1] == 0) {
931 this->mDsmSimuPatchSum[i] = 0;
934 simulateFEELUT(this->mDsmSimuPatchSum[i], this->mPatchData[i][3], this->mPatchData[i][4], this->mPatchData[i][5], this->mPatchData[i][6], this->mPatchData[i][7], this->mPatchData[i][8], this->mPatchData[i][9], this->mPatchData[i][10], (
int)(this->mTriggerPedestalShift / 100.0), lut, (i == 27300));
935 this->mDsmSimuPatchSum[i] = lut;
938 if (this->mDsmL0InputHighTower[i] != this->mDsmSimuHighTower[i]) {
939 if (mDebug >= 2) cout << i <<
": HT " << this->mDsmSimuHighTower[i] <<
" != " << this->mDsmL0InputHighTower[i] << endl;
940 if (this->mHistTriggerCorruptionHighTower) this->mHistTriggerCorruptionHighTower->Fill(i);
941 if (this->mHistDSM0HTCorr) this->mHistDSM0HTCorr->Fill(this->mDsmL0InputHighTower[i], this->mDsmSimuHighTower[i]);
945 if (this->mDsmL0InputPatchSum[i] != this->mDsmSimuPatchSum[i]) {
946 if (mDebug >= 2) cout << i <<
": PA " << this->mDsmSimuPatchSum[i] <<
" != " << this->mDsmL0InputPatchSum[i] << endl;
947 if (this->mHistTriggerCorruptionPatchSum) this->mHistTriggerCorruptionPatchSum->Fill(i);
948 if (this->mHistDSM0TPCorr) this->mHistDSM0TPCorr->Fill(this->mDsmL0InputPatchSum[i], this->mDsmSimuPatchSum[i]);
956 if (this->mHist_BTOW_Corruption) this->mHist_BTOW_Corruption->Fill(0.0);
957 if (this->mHist_BTOW_Corruption) this->mHist_BTOW_Corruption->Fill(STATUS);
964 memset(feeSum, 0,
sizeof(feeSum));
965 memset(pmtSum, 0,
sizeof(pmtSum));
966 bool smdPresent =
false;
967 bool psdPresent =
false;
968 for (
int bsmd_fiber = 0;bsmd_fiber < BSMD_FIBERS;bsmd_fiber++) {
969 int bprs_fiber = bsmd_fiber - 8;
970 #ifdef NEW_DAQ_READER
971 daq_dta *dd_bsmd = rdr ? (rdr->det(
"bsmd")->get(
"adc", 0, bsmd_fiber + 1)) : 0;
972 if (dd_bsmd)
while (dd_bsmd->iterate()) {
974 if (d && BEMCDecoder) {
976 if (emc.bsmd_in && BEMCDecoder) {
980 int det = -1, m = -1, e = -1, s = -1;
981 int softId = -1, box = -1, wire = -1, Avalue = -1;
982 #ifdef NEW_DAQ_READER
985 int cap = emc.bsmd_cap[bsmd_fiber];
987 for (
int fiber_channel = 0;fiber_channel < BSMD_DATSIZE;fiber_channel++) {
988 #ifdef NEW_DAQ_READER
989 int adc = d->adc[fiber_channel];
991 int adc = emc.bsmd[bsmd_fiber][fiber_channel];
994 if ((bsmd_fiber >= 0) && (bsmd_fiber < 8)) {
995 if (BEMCDecoder->
GetSmdCoord(bsmd_fiber, fiber_channel, det, m, e, s)) {
998 if ((m >= 1) && (m <= 120)) {
999 feeSum[m - 1] += adc;
1003 if (BEMCDecoder->
GetPsdId(bprs_fiber, fiber_channel, softId, box, wire, Avalue)) {
1006 if ((box >= 1) && (box <= 60)) {
1007 pmtSum[box - 1] += adc;
1009 StEmcGeom *BEMCGeom = StEmcGeom::instance(
"bemc");
1011 BEMCGeom->getEta(softId, eta);
1012 BEMCGeom->getPhi(softId, iphi);
1013 if (this->mHist_ADCEtaPhi_Pre1Hits) this->mHist_ADCEtaPhi_Pre1Hits->Fill(iphi, eta);
1015 if ((softId >= 1) && (softId <= 1220)) {
1016 if (this->mHistRawAdcPsd1) this->mHistRawAdcPsd1->Fill(softId, adc);
1017 }
else if ((softId >= 1221) && (softId <= 2400)) {
1018 if (this->mHistRawAdcPsd2) this->mHistRawAdcPsd2->Fill(softId, adc);
1019 }
else if ((softId >= 2401) && (softId <= 3540)) {
1020 if (this->mHistRawAdcPsd3) this->mHistRawAdcPsd3->Fill(softId, adc);
1021 }
else if ((softId >= 3541) && (softId <= 4800)) {
1022 if (this->mHistRawAdcPsd4) this->mHistRawAdcPsd4->Fill(softId, adc);
1028 int BSMD_STATUS = BEMCOK;
1029 if (fiberSum == 0) BSMD_STATUS = BEMCNOTINSTALLED;
1031 if((bsmd_fiber >= 0) && (bsmd_fiber < 8)) {
1032 if (this->mHist_SMD_status) this->mHist_SMD_status->Fill(0.0, bsmd_fiber);
1033 if (this->mHist_SMD_status) this->mHist_SMD_status->Fill(BSMD_STATUS, bsmd_fiber);
1034 if(BSMD_STATUS==BEMCOK) {
1035 if (this->mHist_smd_capacitor) this->mHist_smd_capacitor->Fill(cap, bsmd_fiber);
1036 if (this->mHist_smd_sum) this->mHist_smd_sum->Fill(fiberSum, bsmd_fiber);
1039 if (this->mHist_PSD_status) this->mHist_PSD_status->Fill(0.0, bprs_fiber);
1040 if (this->mHist_PSD_status) this->mHist_PSD_status->Fill(BSMD_STATUS, bprs_fiber);
1041 if(BSMD_STATUS==BEMCOK) {
1042 if (this->mHist_psd_capacitor) this->mHist_psd_capacitor->Fill(cap, bprs_fiber);
1043 if (this->mHist_psd_sum) this->mHist_psd_sum->Fill(fiberSum, bprs_fiber);
1049 if (smdPresent)
for (
int i = 0;i < 120;i++) {
1050 if (this->mHistSmdFeeSum) this->mHistSmdFeeSum->Fill(i + 1, feeSum[i]);
1052 if (psdPresent)
for (
int i = 0;i < 60;i++) {
1053 if (this->mHistPsdFeeSum) this->mHistPsdFeeSum->Fill(i + 1, pmtSum[i]);
1055 if (smdPresent && this->mHist_smd_spectra) this->mHist_smd_spectra->Fill(totalSumSMD);
1056 if (psdPresent && this->mHist_psd_spectra) this->mHist_psd_spectra->Fill(totalSumPSD);
1060 int totalSumSMDNonZS = 0;
1061 int totalSumPSDNonZS = 0;
1062 int feeSumNonZS[120];
1063 int pmtSumNonZS[60];
1064 memset(feeSumNonZS, 0,
sizeof(feeSumNonZS));
1065 memset(pmtSumNonZS, 0,
sizeof(pmtSumNonZS));
1066 bool smdPresentNonZS =
false;
1067 bool psdPresentNonZS =
false;
1068 for (
int bsmd_fiber = 0;bsmd_fiber < BSMD_FIBERS;bsmd_fiber++) {
1069 int bprs_fiber = bsmd_fiber - 8;
1070 #ifdef NEW_DAQ_READER
1071 daq_dta *dd_bsmd = rdr ? (rdr->det(
"bsmd")->get(
"adc_non_zs", 0, bsmd_fiber + 1)) : 0;
1072 if (dd_bsmd)
while (dd_bsmd->iterate()) {
1074 if (d && BEMCDecoder) {
1076 if (emc.bsmd_in && BEMCDecoder) {
1080 int det = -1, m = -1, e = -1, s = -1;
1081 int softId = -1, box = -1, wire = -1, Avalue = -1;
1082 #ifdef NEW_DAQ_READER
1085 int cap = emc.bsmd_cap[bsmd_fiber];
1087 for (
int fiber_channel = 0;fiber_channel < BSMD_DATSIZE;fiber_channel++) {
1088 #ifdef NEW_DAQ_READER
1089 int adc = d->adc[fiber_channel];
1091 int adc = emc.bsmd[bsmd_fiber][fiber_channel];
1094 if ((bsmd_fiber >= 0) && (bsmd_fiber < 8)) {
1095 if (BEMCDecoder->
GetSmdCoord(bsmd_fiber, fiber_channel, det, m, e, s)) {
1096 smdPresentNonZS =
true;
1097 totalSumSMDNonZS += adc;
1098 if ((m >= 1) && (m <= 120)) {
1099 feeSumNonZS[m - 1] += adc;
1103 if (BEMCDecoder->
GetPsdId(bprs_fiber, fiber_channel, softId, box, wire, Avalue)) {
1104 psdPresentNonZS =
true;
1105 totalSumPSDNonZS += adc;
1106 if ((box >= 1) && (box <= 60)) {
1107 pmtSumNonZS[box - 1] += adc;
1115 if (smdPresentNonZS)
for (
int i = 0;i < 120;i++) {
1116 if (this->mHistSmdFeeSumNonZS) this->mHistSmdFeeSumNonZS->Fill(i + 1, feeSumNonZS[i]);
1118 if (psdPresentNonZS)
for (
int i = 0;i < 60;i++) {
1119 if (this->mHistPsdFeeSumNonZS) this->mHistPsdFeeSumNonZS->Fill(i + 1, pmtSumNonZS[i]);
1121 if (smdPresentNonZS && this->mHist_smd_spectraNonZS) this->mHist_smd_spectraNonZS->Fill(totalSumSMDNonZS);
1122 if (psdPresentNonZS && this->mHist_psd_spectraNonZS) this->mHist_psd_spectraNonZS->Fill(totalSumPSDNonZS);
1125 if (mDebug >= 10) cout << __FILE__ <<
":" << __LINE__ << endl;
int GetTriggerPatchFromCrate(int crate, int sequence, int &patchId) const
returns the trigger patch from crate and sequence in the crate
int GetSmdCoord(int RDO, int posInFiber, int &det, int &m, int &e, int &s, bool print=false) const
Get SMD detector (3==SMDE, 4==SMDP), m, e, s from RDO and position for SMD.
int GetTowerCrateFromDaqId(int RDO, int &crate, int &sequence) const
Get crate number from Daq Id for towers.
int GetTowerIdFromDaqId(int RDO, int &softId) const
Get Sofwtare Id from Daq Id for towers.
int GetJetPatchAndSequenceFromTriggerPatch(int patchId, int &jetPatch, int &sequence) const
return the big jet patch and sequence number within it from the
int GetPsdId(int RDO, int posInFiber, int &softId, bool print=false) const
Get PSD id.