00001 #include <iostream>
00002 #include <fstream>
00003 using namespace std;
00004 #include <TH1F.h>
00005 #include <TH2F.h>
00006 #include <TFile.h>
00007 #include <TCanvas.h>
00008 #include <TLine.h>
00009 #include <TArrow.h>
00010 #include <TLatex.h>
00011 #include <TString.h>
00012 #include <TBox.h>
00013 #include <TObjArray.h>
00014 #include <TDatime.h>
00015
00016 #ifndef NEW_DAQ_READER
00017 # include "evpReader.hh"
00018 # include "emcReader.h"
00019 # include "trgReader.h"
00020 #define BSMD_FIBERS 12
00021 #define BSMD_DATSIZE 4800
00022 #else
00023 # include "DAQ_READER/daqReader.h"
00024 # include "DAQ_READER/daq_dta.h"
00025 # include "DAQ_BSMD/daq_bsmd.h"
00026 # include "DAQ_BTOW/daq_btow.h"
00027 # include "DAQ_EMC/daq_emc.h"
00028 # include "DAQ_TRG/daq_trg.h"
00029 # include <RTS/include/daqFormats.h>
00030 #endif
00031
00032 #include <StEmcUtil/database/StEmcDecoder.h>
00033 #include <StEmcUtil/geometry/StEmcGeom.h>
00034
00035 #include "BEMCPlots.h"
00036 #include "BEMC_DSM_decoder.h"
00037 #include "BEMCPlotsNames.h"
00038
00039
00040 BEMCPlots *BEMCPlotsInstance = 0;
00041 StEmcDecoder *BEMCDecoder = 0;
00042
00043
00044 #define BEMCOK 1
00045 #define BEMCNOTINSTALLED 2
00046 #define BEMCCORRUPTED 3
00047
00048
00049
00050
00051
00052
00053
00054 void BEMCPlots::initHisto(TObjArray *list, const char *bemcStatus) {
00055 if (BEMCPlotsInstance) delete BEMCPlotsInstance; BEMCPlotsInstance = 0;
00056 BEMCPlotsInstance = new BEMCPlots(list);
00057 if (BEMCPlotsInstance) {
00058 BEMCPlotsInstance->setDebug(0);
00059 BEMCPlotsInstance->clear(bemcStatus);
00060 }
00061
00062 }
00063
00064
00065 void BEMCPlots::resetHisto(const char *bemcStatus) {
00066 if (BEMCPlotsInstance) {
00067 BEMCPlotsInstance->clear(bemcStatus);
00068 }
00069 }
00070
00071 void BEMCPlots::saveHisto(TFile *hfile) {
00072 if (BEMCPlotsInstance) {
00073 BEMCPlotsInstance->saveHistograms(hfile);
00074 }
00075 }
00076
00077 void BEMCPlots::fillHisto( char *datap
00078 , const unsigned char *dsmL0WestInput
00079 , const unsigned char *dsmL0EastInput
00080 , const unsigned short *dsmL1Input
00081 , const unsigned short *dsmL2Input
00082 , const unsigned short *dsmL3Input
00083 ) {
00084
00085 if (BEMCPlotsInstance) {
00086 BEMCPlotsInstance->processEvent(datap, dsmL0WestInput, dsmL0EastInput, dsmL1Input, dsmL2Input, dsmL3Input);
00087 }
00088 }
00089
00090 BEMCPlots::BEMCPlots(TObjArray *list)
00091 : mDebug(0)
00092 {
00093
00094 #define ADDHIST(hist) if (list && (hist)) list->Add(hist);
00095
00096 this->mHistTot = new TH1F(HistTotName, "BEMC, Total number of events processed;;Number of events", 1, 0, 1);
00097 ADDHIST(this->mHistTot)
00098
00099 this->mHistDsmL0InputHighTower = new TH2F(HistDsmL0InputHighTowerName, "BEMC DSM L0 Input - HighTower;triggerPatch;HighTower", 300, -0.5, 300 - 0.5, 64, 0, 64);
00100 ADDHIST(this->mHistDsmL0InputHighTower)
00101 this->mHistDsmL0InputPatchSum = new TH2F(HistDsmL0InputPatchSumName, "BEMC DSM L0 Input - PatchSum;triggerPatch;PatchSum", 300, -0.5, 300 - 0.5, 64, 0, 64);
00102 ADDHIST(this->mHistDsmL0InputPatchSum)
00103
00104 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);
00105 ADDHIST(this->mHistDsmL1InputHighTowerBits)
00106 this->mHistDsmL1InputPatchSum = new TH2F(HistDsmL1InputPatchSumName, "BEMC DSM L1 Input - PatchSum;Channel;PatchSum", 36, -0.5, 36-0.5, 128, 0, 256);
00107 ADDHIST(this->mHistDsmL1InputPatchSum)
00108
00109 this->mHistDsmL2InputHighTowerBits = new TH2F(HistDsmL2InputHighTowerBitsName, "BEMC DSM L2 Input - HighTower bits;JetPatch;HighTower bits", BEMCNJET, -0.5, BEMCNJET-0.5, 5, 0, 5);
00110 ADDHIST(this->mHistDsmL2InputHighTowerBits)
00111 this->mHistDsmL2InputPatchSumBits = new TH2F(HistDsmL2InputPatchSumBitsName, "BEMC DSM L2 Input - PatchSum bits;JetPatch;PatchSum bits", BEMCNJET, -0.5, BEMCNJET-0.5, 4, 0, 4);
00112 ADDHIST(this->mHistDsmL2InputPatchSumBits)
00113 this->mHistDsmL2InputPatchSum = new TH2F(HistDsmL2InputPatchSumName, "BEMC DSM L2 Input - PatchSum;JetPatch pair;PatchSum", 6, -0.5, 6-0.5, 256, 0, 256);
00114 ADDHIST(this->mHistDsmL2InputPatchSum)
00115
00116 this->mHistDsmL3InputHighTowerBits = new TH1F(HistDsmL3InputHighTowerBitsName, "BEMC DSM L3 Input - HighTower bits;HighTower bits", 4, -0.5, 4-0.5);
00117 ADDHIST(this->mHistDsmL3InputHighTowerBits)
00118 this->mHistDsmL3InputPatchSumBits = new TH1F(HistDsmL3InputPatchSumBitsName, "BEMC DSM L3 Input - PatchSum bits;PatchSum bits", 4, -0.5, 4-0.5);
00119 ADDHIST(this->mHistDsmL3InputPatchSumBits)
00120 this->mHistDsmL3InputBackToBackBit = new TH1F(HistDsmL3InputBackToBackBitName, "BEMC DSM L3 Input - Back-to-Back bit;Back-to-Back bit", 2, -0.5, 2-0.5);
00121 ADDHIST(this->mHistDsmL3InputBackToBackBit)
00122 this->mHistDsmL3InputJPsiTopoBit = new TH1F(HistDsmL3InputJPsiTopoBitName, "BEMC DSM L3 Input - J/Psi topology bit;J/Psi bit", 2, -0.5, 2-0.5);
00123 ADDHIST(this->mHistDsmL3InputJPsiTopoBit)
00124 this->mHistDsmL3InputJetPatchTopoBit = new TH1F(HistDsmL3InputJetPatchTopoBitName, "BEMC DSM L3 Input - JetPatch topology bit;JetPatch bit", 2, -0.5, 2-0.5);
00125 ADDHIST(this->mHistDsmL3InputJetPatchTopoBit)
00126
00127 this->mHistRawAdc1 = new TH2F(HistRawAdc1Name, "BTOW ADC, 1 <= SoftId <= 1220;SoftId;ADC", 1220, 0000.5, 1220.5, 300, -0.5, 4096-0.5);
00128 this->mHistRawAdc2 = new TH2F(HistRawAdc2Name, "BTOW ADC, 1221 <= SoftId <= 2400;SoftId;ADC", 1180, 1220.5, 2400.5, 300, -0.5, 4096-0.5);
00129 this->mHistRawAdc3 = new TH2F(HistRawAdc3Name, "BTOW ADC, 2401 <= SoftId <= 3540;SoftId;ADC", 1140, 2400.5, 3540.5, 300, -0.5, 4096-0.5);
00130 this->mHistRawAdc4 = new TH2F(HistRawAdc4Name, "BTOW ADC, 3541 <= SoftId <= 4800;SoftId;ADC", 1260, 3540.5, 4800.5, 300, -0.5, 4096-0.5);
00131
00132 this->mHistRawAdc1zoom = new TH2F(HistRawAdc1NameZoom, "BTOW ADC, 1 <= SoftId <= 1220;SoftId;ADC", 1220, 0000.5, 1220.5, 300, -0.5, 500-0.5);
00133 this->mHistRawAdc2zoom = new TH2F(HistRawAdc2NameZoom, "BTOW ADC, 1221 <= SoftId <= 2400;SoftId;ADC", 1180, 1220.5, 2400.5, 300, -0.5, 500-0.5);
00134 this->mHistRawAdc3zoom = new TH2F(HistRawAdc3NameZoom, "BTOW ADC, 2401 <= SoftId <= 3540;SoftId;ADC", 1140, 2400.5, 3540.5, 300, -0.5, 500-0.5);
00135 this->mHistRawAdc4zoom = new TH2F(HistRawAdc4NameZoom, "BTOW ADC, 3541 <= SoftId <= 4800;SoftId;ADC", 1260, 3540.5, 4800.5, 300, -0.5, 500-0.5);
00136
00137 this->mHistRawAdcPsd1 = new TH2F(HistRawAdcPsd1Name, "BPRS ADC, 1 <= SoftId <= 1220;SoftId;ADC", 1220, 0000.5, 1220.5, 300, -0.5, 1000-0.5);
00138 this->mHistRawAdcPsd2 = new TH2F(HistRawAdcPsd2Name, "BPRS ADC, 1221 <= SoftId <= 2400;SoftId;ADC", 1180, 1220.5, 2400.5, 300, -0.5, 1000-0.5);
00139 this->mHistRawAdcPsd3 = new TH2F(HistRawAdcPsd3Name, "BPRS ADC, 2401 <= SoftId <= 3540;SoftId;ADC", 1140, 2400.5, 3540.5, 300, -0.5, 1000-0.5);
00140 this->mHistRawAdcPsd4 = new TH2F(HistRawAdcPsd4Name, "BPRS ADC, 3541 <= SoftId <= 4800;SoftId;ADC", 1260, 3540.5, 4800.5, 300, -0.5, 1000-0.5);
00141
00142 this->mHistSmdFeeSum = new TH2F(HistSmdFeeSumName, "BSMD FEE Sum;Module;Sum", 120, 0.5, 120+0.5, 100, -0.5, 5000-0.5);
00143 this->mHistPsdFeeSum = new TH2F(HistPsdFeeSumName, "BPRS FEE Sum;PMT Box;Sum", 60, 0.5, 60+0.5, 100, -0.5, 5000-0.5);
00144
00145 this->mHistSmdFeeSumNonZS = new TH2F(HistSmdFeeSumNonZSName, "BSMD FEE Sum, Non-ZS;Module;Sum", 120, 0.5, 120+0.5, 100, -0.5, 100000-0.5);
00146 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);
00147
00148 ADDHIST(this->mHistRawAdc1)
00149 ADDHIST(this->mHistRawAdc2)
00150 ADDHIST(this->mHistRawAdc3)
00151 ADDHIST(this->mHistRawAdc4)
00152
00153 ADDHIST(this->mHistRawAdc1zoom)
00154 ADDHIST(this->mHistRawAdc2zoom)
00155 ADDHIST(this->mHistRawAdc3zoom)
00156 ADDHIST(this->mHistRawAdc4zoom)
00157
00158 ADDHIST(this->mHistRawAdcPsd1)
00159 ADDHIST(this->mHistRawAdcPsd2)
00160 ADDHIST(this->mHistRawAdcPsd3)
00161 ADDHIST(this->mHistRawAdcPsd4)
00162
00163 ADDHIST(this->mHistSmdFeeSum)
00164 ADDHIST(this->mHistPsdFeeSum)
00165
00166 ADDHIST(this->mHistSmdFeeSumNonZS)
00167 ADDHIST(this->mHistPsdFeeSumNonZS)
00168
00169 for (int i = 0;i < BEMCNJET;i++) {
00170 TString name;
00171 TString title;
00172 name = Form("%s_%u", HistHighTowerSpectrumName, i);
00173 title = Form("JetPatch %u - HighTower spectrum;HighTower", i);
00174 this->mHistHighTowerSpectrum[i] = new TH1F(name.Data(), title.Data(), 64, -0.5, 64-0.5);
00175 ADDHIST(this->mHistHighTowerSpectrum[i])
00176 name = Form("%s_%u", HistPatchSumSpectrumName, i);
00177 title = Form("JetPatch %u - PatchSum spectrum;PatchSum", i);
00178 this->mHistPatchSumSpectrum[i] = new TH1F(name.Data(), title.Data(), 200, -0.5, 300-0.5);
00179 ADDHIST(this->mHistPatchSumSpectrum[i])
00180 }
00181
00182 this->mHistTriggerCorruptionHighTower = new TH1F(HistTriggerCorruptionHighTowerName, "HighTower DSM L0 Input; triggerPatch;events", 300, -0.5, 300-0.5);
00183 this->mHistTriggerCorruptionPatchSum = new TH1F(HistTriggerCorruptionPatchSumName, "PatchSum DSM L0 Input; triggerPatch;events", 300, -0.5, 300-0.5);
00184 this->mHistDSM0HTCorr = new TH2F(HistDSM0HTCorrName, "HighTower DSM L0 Input; DSM HighTower;Simulated HighTower", 64, 0, 64, 64, 0, 64);
00185 this->mHistDSM0TPCorr = new TH2F(HistDSM0TPCorrName, "PatchSum DSM L0 Input; DSM PatchSum;Simulated PatchSum", 64, 0, 64, 64, 0, 64);
00186
00187 ADDHIST(this->mHistTriggerCorruptionHighTower)
00188 ADDHIST(this->mHistTriggerCorruptionPatchSum)
00189 ADDHIST(this->mHistDSM0HTCorr)
00190 ADDHIST(this->mHistDSM0TPCorr)
00191
00192 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);
00193 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);
00194 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);
00195 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);
00196
00197 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);
00198 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);
00199 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);
00200
00201 this->mHist_smd_spectra = new TH1F(Hist_smd_spectraName, "BEMC SMD total ADC",250,100000.,6000000.);
00202 this->mHist_smd_spectraNonZS= new TH1F(Hist_smd_spectraNonZSName, "BEMC SMD total ADC, Non-ZS",250,100000.,6000000.);
00203 this->mHist_smd_capacitor = new TH2F(Hist_smd_capacitorName, "BEMC SMD capacitor distribution",128,-0.5,127.5,8,-0.5,7.5);
00204 this->mHist_smd_sum = new TH2F(Hist_smd_sumName, "BEMC SMD total ADC per fiber",250,100000.,1000000.,8,-0.5,7.5);
00205 this->mHist_psd_spectra = new TH1F(Hist_psd_spectraName, "BEMC PSD total ADC",250,100000.,4000000.);
00206 this->mHist_psd_spectraNonZS= new TH1F(Hist_psd_spectraNonZSName, "BEMC PSD total ADC, Non-ZS",250,100000.,4000000.);
00207 this->mHist_psd_capacitor = new TH2F(Hist_psd_capacitorName, "BEMC PSD capacitor distribution",128,-0.5,127.5,4,-0.5,3.5);
00208 this->mHist_psd_sum = new TH2F(Hist_psd_sumName, "BEMC PSD total ADC per fiber",250,100000.,1000000.,4,-0.5,3.5);
00209
00210 this->mHist_HTMAX_spectra = new TH2F(Hist_HTMAX_spectraName, "BEMC Maximum High Tower spectrum", 300,-0.5,299.5,64,-0.5,63.5);
00211 this->mHist_PAMAX_spectra = new TH2F(Hist_PAMAX_spectraName, "BEMC Maximum Patch Sum spectrum", 300,-0.5,299.5,64,-0.5,63.5);
00212 this->mHist_HTMAX_dist = new TH1F(Hist_HTMAX_distName, "BEMC Maximum High Tower distribution", 300,-0.5,299.5);
00213 this->mHist_PAMAX_dist = new TH1F(Hist_PAMAX_distName, "BEMC Maximum Patch Sum distribution", 300,-0.5,299.5);
00214
00215 this->mHist_JET_spectra = new TH2F(Hist_JET_spectraName, "BEMC Jet sum spectrum", BEMCNJET,-0.5,BEMCNJET-0.5,80,-0.5,79.5);
00216 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);
00217 this->mHist_JET_ped = new TH2F(Hist_JET_pedName, "BEMC Jet sum pedestal", BEMCNJET,-0.5,BEMCNJET-0.5,30,15,45);
00218 this->mHist_JETMAX_dist = new TH1F(Hist_JETMAX_distName, "BEMC Maximum Jet sum distribution", BEMCNJET,-0.5,BEMCNJET-0.5);
00219
00220 ADDHIST(this->mHist_TDC_status)
00221 ADDHIST(this->mHist_SMD_status)
00222 ADDHIST(this->mHist_PSD_status)
00223 ADDHIST(this->mHist_BTOW_Corruption)
00224
00225 ADDHIST(this->mHist_btow_spectra_1)
00226 ADDHIST(this->mHist_btow_spectra_2)
00227 ADDHIST(this->mHist_btow_spectra_3)
00228
00229 ADDHIST(this->mHist_smd_spectra)
00230 ADDHIST(this->mHist_smd_spectraNonZS)
00231 ADDHIST(this->mHist_smd_capacitor)
00232 ADDHIST(this->mHist_smd_sum)
00233 ADDHIST(this->mHist_psd_spectra)
00234 ADDHIST(this->mHist_psd_spectraNonZS)
00235 ADDHIST(this->mHist_psd_capacitor)
00236 ADDHIST(this->mHist_psd_sum)
00237
00238 ADDHIST(this->mHist_HTMAX_spectra)
00239 ADDHIST(this->mHist_PAMAX_spectra)
00240 ADDHIST(this->mHist_HTMAX_dist)
00241 ADDHIST(this->mHist_PAMAX_dist)
00242
00243 ADDHIST(this->mHist_JET_spectra)
00244 ADDHIST(this->mHist_JETMAX_spectra)
00245 ADDHIST(this->mHist_JET_ped)
00246 ADDHIST(this->mHist_JETMAX_dist)
00247
00248 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);
00249 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);
00250
00251 ADDHIST(this->mHist_ADCEtaPhi_TowHits)
00252 ADDHIST(this->mHist_ADCEtaPhi_Pre1Hits)
00253
00254
00255 #undef ADDHIST
00256
00257 for (int i = 0;i < 4800;i++) {
00258 this->mTowerData[i][0] = 1;
00259 this->mTowerData[i][1] = 0;
00260 this->mTowerData[i][2] = 0;
00261 }
00262 this->mTriggerPedestalShift = 24 * 100;
00263 for (int i = 0;i < 300;i++) {
00264 this->mPatchData[i][0] = 1;
00265 this->mPatchData[i][1] = 1;
00266 this->mPatchData[i][2] = 3;
00267 this->mPatchData[i][3] = 2;
00268 this->mPatchData[i][4] = 1;
00269 this->mPatchData[i][5] = 0;
00270 this->mPatchData[i][6] = 0;
00271 this->mPatchData[i][7] = 1;
00272 this->mPatchData[i][8] = 0;
00273 this->mPatchData[i][9] = 0;
00274 this->mPatchData[i][10] = 0;
00275 }
00276 memset(this->BEMCJPPED, 0, sizeof(this->BEMCJPPED));
00277 memset(this->BEMCNJPPED, 0, sizeof(this->BEMCNJPPED));
00278
00279 }
00280
00281 BEMCPlots::~BEMCPlots() {
00282 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00283
00284 #define DELETEHIST(HIST) if (HIST) delete (HIST); (HIST) = 0;
00285
00286 DELETEHIST(this->mHistTot)
00287
00288 DELETEHIST(this->mHistDsmL0InputHighTower)
00289 DELETEHIST(this->mHistDsmL0InputPatchSum)
00290
00291 DELETEHIST(this->mHistDsmL1InputHighTowerBits)
00292 DELETEHIST(this->mHistDsmL1InputPatchSum)
00293
00294 DELETEHIST(this->mHistDsmL2InputHighTowerBits)
00295 DELETEHIST(this->mHistDsmL2InputPatchSumBits)
00296 DELETEHIST(this->mHistDsmL2InputPatchSum)
00297
00298 DELETEHIST(this->mHistDsmL3InputHighTowerBits)
00299 DELETEHIST(this->mHistDsmL3InputPatchSumBits)
00300 DELETEHIST(this->mHistDsmL3InputBackToBackBit)
00301 DELETEHIST(this->mHistDsmL3InputJPsiTopoBit)
00302 DELETEHIST(this->mHistDsmL3InputJetPatchTopoBit)
00303
00304 DELETEHIST(this->mHistRawAdc1)
00305 DELETEHIST(this->mHistRawAdc2)
00306 DELETEHIST(this->mHistRawAdc3)
00307 DELETEHIST(this->mHistRawAdc4)
00308
00309 DELETEHIST(this->mHistRawAdc1zoom)
00310 DELETEHIST(this->mHistRawAdc2zoom)
00311 DELETEHIST(this->mHistRawAdc3zoom)
00312 DELETEHIST(this->mHistRawAdc4zoom)
00313
00314 DELETEHIST(this->mHistRawAdcPsd1)
00315 DELETEHIST(this->mHistRawAdcPsd2)
00316 DELETEHIST(this->mHistRawAdcPsd3)
00317 DELETEHIST(this->mHistRawAdcPsd4)
00318
00319 DELETEHIST(this->mHistSmdFeeSum)
00320 DELETEHIST(this->mHistPsdFeeSum)
00321
00322 DELETEHIST(this->mHistSmdFeeSumNonZS)
00323 DELETEHIST(this->mHistPsdFeeSumNonZS)
00324
00325 for (int i = 0;i < BEMCNJET;i++) {
00326 DELETEHIST(this->mHistHighTowerSpectrum[i])
00327 DELETEHIST(this->mHistPatchSumSpectrum[i])
00328 }
00329
00330 DELETEHIST(this->mHistTriggerCorruptionHighTower)
00331 DELETEHIST(this->mHistTriggerCorruptionPatchSum)
00332 DELETEHIST(this->mHistDSM0HTCorr)
00333 DELETEHIST(this->mHistDSM0TPCorr)
00334
00335 DELETEHIST(this->mHist_TDC_status)
00336 DELETEHIST(this->mHist_SMD_status)
00337 DELETEHIST(this->mHist_PSD_status)
00338 DELETEHIST(this->mHist_BTOW_Corruption)
00339
00340 DELETEHIST(this->mHist_btow_spectra_1)
00341 DELETEHIST(this->mHist_btow_spectra_2)
00342 DELETEHIST(this->mHist_btow_spectra_3)
00343
00344 DELETEHIST(this->mHist_smd_spectra)
00345 DELETEHIST(this->mHist_smd_spectraNonZS)
00346 DELETEHIST(this->mHist_smd_capacitor)
00347 DELETEHIST(this->mHist_smd_sum)
00348 DELETEHIST(this->mHist_psd_spectra)
00349 DELETEHIST(this->mHist_psd_spectraNonZS)
00350 DELETEHIST(this->mHist_psd_capacitor)
00351 DELETEHIST(this->mHist_psd_sum)
00352
00353 DELETEHIST(this->mHist_HTMAX_spectra)
00354 DELETEHIST(this->mHist_PAMAX_spectra)
00355 DELETEHIST(this->mHist_HTMAX_dist)
00356 DELETEHIST(this->mHist_PAMAX_dist)
00357
00358 DELETEHIST(this->mHist_JET_spectra)
00359 DELETEHIST(this->mHist_JETMAX_spectra)
00360 DELETEHIST(this->mHist_JET_ped)
00361
00362 DELETEHIST(this->mHist_JETMAX_dist)
00363
00364 DELETEHIST(this->mHist_ADCEtaPhi_TowHits)
00365 DELETEHIST(this->mHist_ADCEtaPhi_Pre1Hits)
00366
00367
00368 #undef DELETEHIST
00369
00370 this->clear(0);
00371 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00372 }
00373
00374 void BEMCPlots::init(unsigned int date, unsigned int time, const char *bemcStatus) {
00375
00376 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00377 this->clear(bemcStatus);
00378 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00379
00380 }
00381
00382 void BEMCPlots::clear(const char *bemcStatus) {
00383 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00384 if (mDebug >= 2) cout << "bemcStatus = " << bemcStatus << endl;
00385
00386 #define RESETHIST(HIST) if (HIST) (HIST)->Reset();
00387
00388 RESETHIST(this->mHistTot)
00389
00390 RESETHIST(this->mHistDsmL0InputHighTower)
00391 RESETHIST(this->mHistDsmL0InputPatchSum)
00392
00393 RESETHIST(this->mHistDsmL1InputHighTowerBits)
00394 RESETHIST(this->mHistDsmL1InputPatchSum)
00395
00396 RESETHIST(this->mHistDsmL2InputHighTowerBits)
00397 RESETHIST(this->mHistDsmL2InputPatchSumBits)
00398 RESETHIST(this->mHistDsmL2InputPatchSum)
00399
00400 RESETHIST(this->mHistDsmL3InputHighTowerBits)
00401 RESETHIST(this->mHistDsmL3InputPatchSumBits)
00402 RESETHIST(this->mHistDsmL3InputBackToBackBit)
00403 RESETHIST(this->mHistDsmL3InputJPsiTopoBit)
00404 RESETHIST(this->mHistDsmL3InputJetPatchTopoBit)
00405
00406 RESETHIST(this->mHistRawAdc1)
00407 RESETHIST(this->mHistRawAdc2)
00408 RESETHIST(this->mHistRawAdc3)
00409 RESETHIST(this->mHistRawAdc4)
00410
00411 RESETHIST(this->mHistRawAdc1zoom)
00412 RESETHIST(this->mHistRawAdc2zoom)
00413 RESETHIST(this->mHistRawAdc3zoom)
00414 RESETHIST(this->mHistRawAdc4zoom)
00415
00416 RESETHIST(this->mHistRawAdcPsd1)
00417 RESETHIST(this->mHistRawAdcPsd2)
00418 RESETHIST(this->mHistRawAdcPsd3)
00419 RESETHIST(this->mHistRawAdcPsd4)
00420
00421 RESETHIST(this->mHistSmdFeeSum)
00422 RESETHIST(this->mHistPsdFeeSum)
00423
00424 RESETHIST(this->mHistSmdFeeSumNonZS)
00425 RESETHIST(this->mHistPsdFeeSumNonZS)
00426
00427 for (int i = 0;i < BEMCNJET;i++) {
00428 RESETHIST(this->mHistHighTowerSpectrum[i])
00429 RESETHIST(this->mHistPatchSumSpectrum[i])
00430 }
00431
00432 RESETHIST(this->mHistTriggerCorruptionHighTower)
00433 RESETHIST(this->mHistTriggerCorruptionPatchSum)
00434 RESETHIST(this->mHistDSM0HTCorr)
00435 RESETHIST(this->mHistDSM0TPCorr)
00436
00437 RESETHIST(this->mHist_TDC_status)
00438 RESETHIST(this->mHist_SMD_status)
00439 RESETHIST(this->mHist_PSD_status)
00440 RESETHIST(this->mHist_BTOW_Corruption)
00441
00442 RESETHIST(this->mHist_btow_spectra_1)
00443 RESETHIST(this->mHist_btow_spectra_2)
00444 RESETHIST(this->mHist_btow_spectra_3)
00445
00446 RESETHIST(this->mHist_smd_spectra)
00447 RESETHIST(this->mHist_smd_spectraNonZS)
00448 RESETHIST(this->mHist_smd_capacitor)
00449 RESETHIST(this->mHist_smd_sum)
00450 RESETHIST(this->mHist_psd_spectra)
00451 RESETHIST(this->mHist_psd_spectraNonZS)
00452 RESETHIST(this->mHist_psd_capacitor)
00453 RESETHIST(this->mHist_psd_sum)
00454
00455 RESETHIST(this->mHist_HTMAX_spectra)
00456 RESETHIST(this->mHist_PAMAX_spectra)
00457 RESETHIST(this->mHist_HTMAX_dist)
00458 RESETHIST(this->mHist_PAMAX_dist)
00459
00460 RESETHIST(this->mHist_JET_spectra)
00461 RESETHIST(this->mHist_JETMAX_spectra)
00462 RESETHIST(this->mHist_JET_ped)
00463 RESETHIST(this->mHist_JETMAX_dist)
00464
00465 RESETHIST(this->mHist_ADCEtaPhi_TowHits)
00466 RESETHIST(this->mHist_ADCEtaPhi_Pre1Hits)
00467
00468
00469 #undef RESETHIST
00470
00471 for (int i = 0;i < 4800;i++) {
00472 this->mTowerData[i][0] = 1;
00473 this->mTowerData[i][1] = 0;
00474 this->mTowerData[i][2] = 0;
00475 }
00476 this->mTriggerPedestalShift = 24 * 100;
00477 for (int i = 0;i < 300;i++) {
00478 this->mPatchData[i][0] = 1;
00479 this->mPatchData[i][1] = 1;
00480 this->mPatchData[i][2] = 3;
00481 this->mPatchData[i][3] = 2;
00482 this->mPatchData[i][4] = 1;
00483 this->mPatchData[i][5] = 0;
00484 this->mPatchData[i][6] = 0;
00485 this->mPatchData[i][7] = 1;
00486 this->mPatchData[i][8] = 0;
00487 this->mPatchData[i][9] = 0;
00488 this->mPatchData[i][10] = 0;
00489 }
00490 memset(this->BEMCJPPED, 0, sizeof(this->BEMCJPPED));
00491 memset(this->BEMCNJPPED, 0, sizeof(this->BEMCNJPPED));
00492
00493 if (!BEMCDecoder) BEMCDecoder = new StEmcDecoder();
00494
00495 if (bemcStatus) {
00496 ifstream ifstr(bemcStatus);
00497 if (ifstr.good()) {
00498 cout << "Reading BEMC trigger status file " << bemcStatus << endl;
00499 } else {
00500 cout << "Cannot open BEMC trigger status file! " << bemcStatus << endl;
00501 }
00502 while (ifstr.good()) {
00503 string token;
00504 do {
00505 if (token == "#") {
00506 char dummy[4096];
00507 ifstr.getline(dummy, sizeof(dummy));
00508 }
00509 ifstr >> token;
00510 } while (ifstr.good() && (token != "SoftId") && (token != "triggerPatch") && (token != "TriggerPedestalShift"));
00511 if (ifstr.good()) {
00512 if (token == "SoftId") {
00513 int softId, crate, crateSeq, unmaskTower, unmaskHT, unmaskPA, triggerPatch;
00514 float ped;
00515 ifstr >> softId >> crate >> crateSeq >> unmaskTower >> unmaskHT >> unmaskPA >> ped >> triggerPatch;
00516 if (mDebug >= 2) cout << "Read: " << token << " " << softId << "\t" << crate << "\t" << crateSeq << "\t" << unmaskTower << "\t" << unmaskHT << "\t" << unmaskPA << "\t" << ped << "\t" << triggerPatch << endl;
00517 if ((softId >= 1) && (softId <= 4800)) {
00518 towerPed[softId-1]=ped;
00519 this->mTowerData[softId - 1][0] = unmaskTower;
00520 this->mTowerData[softId - 1][1] = int(ped * 100.0);
00521
00522
00523 if ((triggerPatch >= 0) && (triggerPatch < 300)) {
00524 this->mPatchData[triggerPatch][10] += 1;
00525 }
00526
00527 }
00528 } else if (token == "triggerPatch") {
00529 int triggerPatch, crate, crateSeq, unmaskHT, unmaskPA, bitConv, formula, formulaParam0, formulaParam1, formulaParam2, formulaParam3, formulaParam4, formulaParam5;
00530 ifstr >> triggerPatch >> crate >> crateSeq >> unmaskHT >> unmaskPA >> bitConv >> formula >> formulaParam0 >> formulaParam1 >> formulaParam2 >> formulaParam3 >> formulaParam4 >> formulaParam5;
00531 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;
00532 if ((triggerPatch >= 0) && (triggerPatch < 300)) {
00533 this->mPatchData[triggerPatch][0] = unmaskHT;
00534 this->mPatchData[triggerPatch][1] = unmaskPA;
00535 this->mPatchData[triggerPatch][2] = bitConv;
00536 this->mPatchData[triggerPatch][3] = formula;
00537 this->mPatchData[triggerPatch][4] = formulaParam0;
00538 this->mPatchData[triggerPatch][5] = formulaParam1;
00539 this->mPatchData[triggerPatch][6] = formulaParam2;
00540 this->mPatchData[triggerPatch][7] = formulaParam3;
00541 this->mPatchData[triggerPatch][8] = formulaParam4;
00542 this->mPatchData[triggerPatch][9] = formulaParam5;
00543 }
00544 } else if (token == "TriggerPedestalShift") {
00545 float pedShift;
00546 ifstr >> pedShift;
00547 this->mTriggerPedestalShift = int(pedShift * 100.0);
00548 if (mDebug >= 2) cout << "Read: " << token << " " << pedShift << endl;
00549 }
00550 }
00551 }
00552 ifstr.close();
00553 for (int i = 0;i < 4800;i++) {
00554 this->mTowerData[i][2] = getFEEpedestal(float(this->mTowerData[i][1]) / 100.0, this->mTriggerPedestalShift / 100.0, false);
00555 }
00556 }
00557 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00558 }
00559
00560 void BEMCPlots::saveHistograms(TFile *hfile) {
00561 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00562 if (!hfile || (mDebug >= 2)) cout << "hfile = " << hfile << endl;
00563 if (hfile) {
00564 hfile->cd();
00565
00566 #define SAVEHIST(HIST) if (HIST) (HIST)->Write();
00567
00568 SAVEHIST(this->mHistTot)
00569
00570 SAVEHIST(this->mHistDsmL0InputHighTower)
00571 SAVEHIST(this->mHistDsmL0InputPatchSum)
00572
00573 SAVEHIST(this->mHistDsmL1InputHighTowerBits)
00574 SAVEHIST(this->mHistDsmL1InputPatchSum)
00575
00576 SAVEHIST(this->mHistDsmL2InputHighTowerBits)
00577 SAVEHIST(this->mHistDsmL2InputPatchSumBits)
00578 SAVEHIST(this->mHistDsmL2InputPatchSum)
00579
00580 SAVEHIST(this->mHistDsmL3InputHighTowerBits)
00581 SAVEHIST(this->mHistDsmL3InputPatchSumBits)
00582 SAVEHIST(this->mHistDsmL3InputBackToBackBit)
00583 SAVEHIST(this->mHistDsmL3InputJPsiTopoBit)
00584 SAVEHIST(this->mHistDsmL3InputJetPatchTopoBit)
00585
00586 SAVEHIST(this->mHistRawAdc1)
00587 SAVEHIST(this->mHistRawAdc2)
00588 SAVEHIST(this->mHistRawAdc3)
00589 SAVEHIST(this->mHistRawAdc4)
00590
00591 SAVEHIST(this->mHistRawAdc1zoom)
00592 SAVEHIST(this->mHistRawAdc2zoom)
00593 SAVEHIST(this->mHistRawAdc3zoom)
00594 SAVEHIST(this->mHistRawAdc4zoom)
00595
00596 SAVEHIST(this->mHistRawAdcPsd1)
00597 SAVEHIST(this->mHistRawAdcPsd2)
00598 SAVEHIST(this->mHistRawAdcPsd3)
00599 SAVEHIST(this->mHistRawAdcPsd4)
00600
00601 SAVEHIST(this->mHistSmdFeeSum)
00602 SAVEHIST(this->mHistPsdFeeSum)
00603
00604 SAVEHIST(this->mHistSmdFeeSumNonZS)
00605 SAVEHIST(this->mHistPsdFeeSumNonZS)
00606
00607 for (int i = 0;i < BEMCNJET;i++) {
00608 SAVEHIST(this->mHistHighTowerSpectrum[i])
00609 SAVEHIST(this->mHistPatchSumSpectrum[i])
00610 }
00611
00612 SAVEHIST(this->mHistTriggerCorruptionHighTower)
00613 SAVEHIST(this->mHistTriggerCorruptionPatchSum)
00614 SAVEHIST(this->mHistDSM0HTCorr)
00615 SAVEHIST(this->mHistDSM0TPCorr)
00616
00617 SAVEHIST(this->mHist_TDC_status)
00618 SAVEHIST(this->mHist_SMD_status)
00619 SAVEHIST(this->mHist_PSD_status)
00620 SAVEHIST(this->mHist_BTOW_Corruption)
00621
00622 SAVEHIST(this->mHist_btow_spectra_1)
00623 SAVEHIST(this->mHist_btow_spectra_2)
00624 SAVEHIST(this->mHist_btow_spectra_3)
00625
00626 SAVEHIST(this->mHist_smd_spectra)
00627 SAVEHIST(this->mHist_smd_spectraNonZS)
00628 SAVEHIST(this->mHist_smd_capacitor)
00629 SAVEHIST(this->mHist_smd_sum)
00630 SAVEHIST(this->mHist_psd_spectra)
00631 SAVEHIST(this->mHist_psd_spectraNonZS)
00632 SAVEHIST(this->mHist_psd_capacitor)
00633 SAVEHIST(this->mHist_psd_sum)
00634
00635 SAVEHIST(this->mHist_HTMAX_spectra)
00636 SAVEHIST(this->mHist_PAMAX_spectra)
00637 SAVEHIST(this->mHist_HTMAX_dist)
00638 SAVEHIST(this->mHist_PAMAX_dist)
00639
00640 SAVEHIST(this->mHist_JET_spectra)
00641 SAVEHIST(this->mHist_JETMAX_spectra)
00642 SAVEHIST(this->mHist_JET_ped)
00643
00644 SAVEHIST(this->mHist_JETMAX_dist)
00645
00646 SAVEHIST(this->mHist_ADCEtaPhi_TowHits)
00647 SAVEHIST(this->mHist_ADCEtaPhi_Pre1Hits)
00648
00649
00650
00651 #undef SAVEHIST
00652
00653 }
00654 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00655 }
00656
00657
00658
00659
00660
00661 void BEMCPlots::processEvent( char *datap
00662 , const unsigned char *dsmL0WestInput
00663 , const unsigned char *dsmL0EastInput
00664 , const unsigned short *dsmL1Input
00665 , const unsigned short *dsmL2Input
00666 , const unsigned short *dsmL3Input
00667 ) {
00668
00669 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
00670 #ifdef NEW_DAQ_READER
00671 daqReader *rdr = (daqReader*)(datap);
00672 #else
00673 evpReader *evp_reader = (evpReader*)(datap);
00674 int ret = emcReader(datap);
00675 #endif
00676
00677 {
00678 #ifdef NEW_DAQ_READER
00679 TDatime evt_time(rdr->evt_time);
00680 #else
00681 TDatime evt_time(evp_reader->evt_time);
00682 #endif
00683 if (BEMCDecoder) BEMCDecoder->SetDateTime(evt_time.GetDate(),evt_time.GetTime());
00684 }
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711 if (!datap || (mDebug >= 2)) cout << "datap = " << (int*)datap << endl;
00712 if (!dsmL0WestInput || (mDebug >= 2)) cout << "dsmL0WestInput = " << (int*)dsmL0WestInput << endl;
00713 if (!dsmL0EastInput || (mDebug >= 2)) cout << "dsmL0EastInput = " << (int*)dsmL0EastInput << endl;
00714 if (!dsmL1Input || (mDebug >= 2)) cout << "dsmL1Input = " << (int*)dsmL1Input << endl;
00715 if (!dsmL2Input || (mDebug >= 2)) cout << "dsmL2Input = " << (int*)dsmL2Input << endl;
00716 if (!dsmL3Input || (mDebug >= 2)) cout << "dsmL3Input = " << (int*)dsmL3Input << endl;
00717 if (!BEMCDecoder || (mDebug >= 2)) cout << "BEMCDecoder = " << BEMCDecoder << endl;
00718
00719 bool DSM_L0_present = BEMC_DSM_L0_decoder(dsmL0WestInput, dsmL0EastInput, &(this->mDsmL0InputHighTower[0]), &(this->mDsmL0InputPatchSum[0]));
00720
00721 bool DSM_L1_present = BEMC_DSM_L1_decoder(dsmL1Input, &(this->mDsmL1InputHighTowerBits[0][0]), &(this->mDsmL1InputPatchSum[0][0]));
00722
00723 bool DSM_L2_present = BEMC_DSM_L2_decoder(dsmL2Input, &(this->mDsmL2InputHighTowerBits[0]), &(this->mDsmL2InputPatchSumBits[0]), &(this->mDsmL2InputPatchSum[0]));
00724
00725 bool DSM_L3_present = BEMC_DSM_L3_decoder(dsmL3Input, &(this->mDsmL3InputHighTowerBits[0]), &(this->mDsmL3InputPatchSumBits[0]), &(this->mDsmL3InputBackToBackBit[0]), &(this->mDsmL3InputJPsiTopoBit[0]), &(this->mDsmL3InputJetPatchTopoBit[0]));
00726
00727
00728 if (this->mHistTot) this->mHistTot->Fill(0.5);
00729
00730 if (DSM_L0_present) {
00731 int jetPatchSum[BEMCNJET];
00732 int jetPatchHT[BEMCNJET];
00733 memset(jetPatchSum, 0, sizeof(jetPatchSum));
00734 memset(jetPatchHT, 0, sizeof(jetPatchHT));
00735 int MAXHT = 0;
00736 int MAXPA = 0;
00737 int MAXHTID = 0;
00738 int MAXPAID = 0;
00739 for (int i = 0;i < 300;i++) {
00740 if (this->mHistDsmL0InputHighTower) this->mHistDsmL0InputHighTower->Fill(i, this->mDsmL0InputHighTower[i]);
00741 if (this->mHistDsmL0InputPatchSum) this->mHistDsmL0InputPatchSum->Fill(i, this->mDsmL0InputPatchSum[i]);
00742
00743 if((this->mDsmL0InputHighTower[i] > MAXHT) && (this->mDsmL0InputHighTower[i] < 63)) {MAXHT = this->mDsmL0InputHighTower[i]; MAXHTID = i;}
00744 if((this->mDsmL0InputPatchSum[i] > MAXPA) && (this->mDsmL0InputPatchSum[i] < 63)) {MAXPA = this->mDsmL0InputPatchSum[i]; MAXPAID = i;}
00745
00746 if (BEMCDecoder) {
00747 int jetPatch = -1, jetPatchSeq = -1;
00748 if (BEMCDecoder->GetJetPatchAndSequenceFromTriggerPatch(i, jetPatch, jetPatchSeq)) {
00749 if ((jetPatch >= 0) && (jetPatch < BEMCNJET)) {
00750 if (jetPatchHT[jetPatch] < this->mDsmL0InputHighTower[i]) jetPatchHT[jetPatch] = this->mDsmL0InputHighTower[i];
00751 jetPatchSum[jetPatch] += this->mDsmL0InputPatchSum[i];
00752 }
00753 }
00754 }
00755
00756 if (mDebug >= 3) cout << "TriggerPatch " << i << ": HighTower = " << this->mDsmL0InputHighTower[i] << ", PatchSum = " << this->mDsmL0InputPatchSum[i] << endl;
00757 }
00758 if(this->mHist_HTMAX_spectra) this->mHist_HTMAX_spectra->Fill((float)MAXHTID,(float)MAXHT);
00759 if(this->mHist_PAMAX_spectra) this->mHist_PAMAX_spectra->Fill((float)MAXPAID,(float)MAXPA);
00760
00761 int HTTH = 12;
00762 int PATH = 12;
00763 if((MAXHT > HTTH) && this->mHist_HTMAX_dist) this->mHist_HTMAX_dist->Fill((float)MAXHTID);
00764 if((MAXPA > PATH) && this->mHist_PAMAX_dist) this->mHist_PAMAX_dist->Fill((float)MAXPAID);
00765
00766 int MAXJETID =0;
00767 int MAXJETVALUE =-9999;
00768 for (int i = 0;i < BEMCNJET;i++) {
00769 if (this->mHistHighTowerSpectrum[i]) this->mHistHighTowerSpectrum[i]->Fill(jetPatchHT[i]);
00770 if (this->mHistPatchSumSpectrum[i]) this->mHistPatchSumSpectrum[i]->Fill(jetPatchSum[i]);
00771 if (jetPatchSum[i] > MAXJETVALUE) { MAXJETVALUE = jetPatchSum[i]; MAXJETID = i;}
00772 if (this->mHist_JET_spectra) this->mHist_JET_spectra->Fill(i, jetPatchSum[i]);
00773 }
00774 if (this->mHist_JETMAX_spectra) this->mHist_JETMAX_spectra->Fill(MAXJETID,MAXJETVALUE);
00775 int JETPATH = 35;
00776 if ((MAXJETVALUE > JETPATH) && this->mHist_JETMAX_dist) this->mHist_JETMAX_dist->Fill(MAXJETID);
00777
00778 for (int i=0;i<BEMCNJET;i++) {
00779 if (i != MAXJETID) {
00780 BEMCJPPED[i] += jetPatchSum[i];
00781 BEMCNJPPED[i]++;
00782 if(BEMCNJPPED[i]==10) {
00783 if (this->mHist_JET_ped) this->mHist_JET_ped->Fill(i,(float)BEMCJPPED[i]/(float)BEMCNJPPED[i]);
00784 BEMCJPPED[i] = 0;
00785 BEMCNJPPED[i] = 0;
00786 }
00787 }
00788 }
00789 }
00790
00791 if (DSM_L1_present) {
00792 int ch = 0;
00793 for (int idsmL1 = 0;idsmL1 < 6;idsmL1++) {
00794 for (int idsmL1ch = 0;idsmL1ch < 6;idsmL1ch++) {
00795 int idsmL1WestFirst = (idsmL1 < 3) ? (idsmL1 + 3) : (idsmL1 - 3);
00796 if (this->mHistDsmL1InputHighTowerBits) this->mHistDsmL1InputHighTowerBits->Fill(ch, this->mDsmL1InputHighTowerBits[idsmL1WestFirst][idsmL1ch]);
00797 if (this->mHistDsmL1InputPatchSum) this->mHistDsmL1InputPatchSum->Fill(ch, this->mDsmL1InputPatchSum[idsmL1WestFirst][idsmL1ch]);
00798 ch++;
00799 }
00800 }
00801 }
00802
00803 if (DSM_L2_present) {
00804 for (int ijp = 0;ijp < BEMCNJET;ijp++) {
00805 if (this->mHistDsmL2InputHighTowerBits) this->mHistDsmL2InputHighTowerBits->Fill(ijp, this->mDsmL2InputHighTowerBits[ijp]);
00806 if (this->mHistDsmL2InputPatchSumBits) this->mHistDsmL2InputPatchSumBits->Fill(ijp, this->mDsmL2InputPatchSumBits[ijp]);
00807 }
00808 for (int ijpp = 0;ijpp < 6;ijpp++) {
00809 int ijppWestFirst = (ijpp < 3) ? (ijpp + 3) : (ijpp - 3);
00810 if (this->mHistDsmL2InputPatchSum) this->mHistDsmL2InputPatchSum->Fill(ijppWestFirst, this->mDsmL2InputPatchSum[ijpp]);
00811 }
00812 }
00813
00814 if (DSM_L3_present) {
00815 if (this->mHistDsmL3InputHighTowerBits) this->mHistDsmL3InputHighTowerBits->Fill(this->mDsmL3InputHighTowerBits[0]);
00816 if (this->mHistDsmL3InputPatchSumBits) this->mHistDsmL3InputPatchSumBits->Fill(this->mDsmL3InputPatchSumBits[0]);
00817 if (this->mHistDsmL3InputBackToBackBit) this->mHistDsmL3InputBackToBackBit->Fill(this->mDsmL3InputBackToBackBit[0]);
00818 if (this->mHistDsmL3InputJPsiTopoBit) this->mHistDsmL3InputJPsiTopoBit->Fill(this->mDsmL3InputJPsiTopoBit[0]);
00819 if (this->mHistDsmL3InputJetPatchTopoBit) this->mHistDsmL3InputJetPatchTopoBit->Fill(this->mDsmL3InputJetPatchTopoBit[0]);
00820 }
00821
00822 int STATUS = BEMCNOTINSTALLED;
00823 #ifdef NEW_DAQ_READER
00824 daq_dta *dd_btow = rdr ? (rdr->det("btow")->get("adc")) : 0;
00825 if (dd_btow) while (dd_btow->iterate()) {
00826 btow_t *d = (btow_t *) dd_btow->Void;
00827 if (d) {
00828 #else
00829 if ((ret >= 0) && emc.btow_in) {
00830 unsigned short *header = emc.btow_raw;
00831 if (header) {
00832 #endif
00833 if (DSM_L0_present) {
00834 memset(this->mDsmSimuHighTower, 0, sizeof(this->mDsmSimuHighTower));
00835 memset(this->mDsmSimuPatchSum, 0, sizeof(this->mDsmSimuPatchSum));
00836 }
00837 int TDCStatus[BTOW_MAXFEE];
00838 memset(TDCStatus, BEMCNOTINSTALLED, sizeof(TDCStatus));
00839 int TDCTotal = 0;
00840 STATUS = BEMCOK;
00841 for (int tdc = 0; tdc < BTOW_MAXFEE;tdc++) {
00842 #ifdef NEW_DAQ_READER
00843 int count = d->preamble[tdc][0];
00844 int error = d->preamble[tdc][1];
00845 #else
00846 int count = (*(header + tdc));
00847 int error = (*(header + tdc + 30));
00848 #endif
00849 if ((error == 0) && (count == (BTOW_PRESIZE + BTOW_DATSIZE))) TDCStatus[tdc] = BEMCOK;
00850 else if ((error == 4095) && (count == 4095)) TDCStatus[tdc] = BEMCNOTINSTALLED;
00851 else TDCStatus[tdc] = BEMCCORRUPTED;
00852 if (TDCStatus[tdc] == BEMCCORRUPTED) STATUS = BEMCCORRUPTED;
00853 if (this->mHist_TDC_status) this->mHist_TDC_status->Fill(0.0, tdc);
00854 if (this->mHist_TDC_status) this->mHist_TDC_status->Fill((float)TDCStatus[tdc], tdc);
00855 }
00856 for(int i = 0;i < (BTOW_MAXFEE * BTOW_DATSIZE);i++) {
00857 int tdc = i % BTOW_MAXFEE;
00858 #ifdef NEW_DAQ_READER
00859 int tdc_channel = i / BTOW_MAXFEE;
00860 int count = d->preamble[tdc][0];
00861 int error = d->preamble[tdc][1];
00862 #else
00863 int count = (*(header + tdc));
00864 int error = (*(header + tdc + 30));
00865 #endif
00866 if((error==0) && (count == (BTOW_PRESIZE + BTOW_DATSIZE))) {
00867
00868 #ifdef NEW_DAQ_READER
00869 int adc = d->adc[tdc][tdc_channel];
00870 #else
00871 int adc = emc.btow[i];
00872 #endif
00873 TDCTotal += adc;
00874 int daqid = ((tdc * BTOW_DATSIZE) + tdc_channel);
00875 if ((tdc >= 0) && (tdc < 10) && (TDCStatus[tdc]!=BEMCNOTINSTALLED) && this->mHist_btow_spectra_1) this->mHist_btow_spectra_1->Fill(daqid, adc);
00876 if ((tdc >= 10) && (tdc < 20) && (TDCStatus[tdc]!=BEMCNOTINSTALLED) && this->mHist_btow_spectra_2) this->mHist_btow_spectra_2->Fill(daqid, adc);
00877 if ((tdc >= 20) && (tdc < 30) && (TDCStatus[tdc]!=BEMCNOTINSTALLED) && this->mHist_btow_spectra_3) this->mHist_btow_spectra_3->Fill(daqid, adc);
00878 int softId = -1;
00879 float iphi, eta, adcped;
00880
00881 if (BEMCDecoder && BEMCDecoder->GetTowerIdFromDaqId(i, softId)) {
00882
00883 adcped=adc-towerPed[softId-1];
00884
00885 StEmcGeom *BEMCGeom = StEmcGeom::instance("bemc");
00886
00887 if(adcped>20)
00888 {
00889 BEMCGeom->getEta(softId, eta);
00890 BEMCGeom->getPhi(softId, iphi);
00891 if ((this->mHist_ADCEtaPhi_TowHits) && (this->mTowerData[softId - 1][0] != 0) ) this->mHist_ADCEtaPhi_TowHits->Fill(iphi, eta);
00892 }
00893
00894 if ((softId >= 1) && (softId <= 4800)) {
00895 if ((softId >= 1) && (softId <= 1220)) {
00896 if (this->mHistRawAdc1) this->mHistRawAdc1->Fill(softId, adc);
00897 if (this->mHistRawAdc1zoom) this->mHistRawAdc1zoom->Fill(softId, adc);
00898 } else if ((softId >= 1221) && (softId <= 2400)) {
00899 if (this->mHistRawAdc2) this->mHistRawAdc2->Fill(softId, adc);
00900 if (this->mHistRawAdc2zoom) this->mHistRawAdc2zoom->Fill(softId, adc);
00901 } else if ((softId >= 2401) && (softId <= 3540)) {
00902 if (this->mHistRawAdc3) this->mHistRawAdc3->Fill(softId, adc);
00903 if (this->mHistRawAdc3zoom) this->mHistRawAdc3zoom->Fill(softId, adc);
00904 } else if ((softId >= 3541) && (softId <= 4800)) {
00905 if (this->mHistRawAdc4) this->mHistRawAdc4->Fill(softId, adc);
00906 if (this->mHistRawAdc4zoom) this->mHistRawAdc4zoom->Fill(softId, adc);
00907 }
00908
00909 if (DSM_L0_present && (this->mTowerData[softId - 1][0] != 0)) {
00910 int crate = -1, crateSeq = -1;
00911 if (BEMCDecoder->GetTowerCrateFromDaqId(i, crate, crateSeq)) {
00912 int triggerPatch = -1;
00913 if (BEMCDecoder->GetTriggerPatchFromCrate(crate, crateSeq, triggerPatch)) {
00914 if ((triggerPatch >= 0) && (triggerPatch < 300)) {
00915 int ht = -1, pa = -1;
00916 if (triggerPatch == 27300) cout << "SoftId " << softId << " ";
00917 simulateFEEaction(adc, this->mTowerData[softId - 1][2], this->mPatchData[triggerPatch][2], ht, pa, (triggerPatch == 27300));
00918 if (ht > this->mDsmSimuHighTower[triggerPatch]) this->mDsmSimuHighTower[triggerPatch] = ht;
00919 this->mDsmSimuPatchSum[triggerPatch] += pa;
00920 }
00921 }
00922 }
00923 }
00924 }
00925 }
00926 }
00927 }
00928 for (int i = 0;i < 300;i++) {
00929 if (this->mPatchData[i][0] == 0) this->mDsmSimuHighTower[i] = 0;
00930 if (this->mPatchData[i][1] == 0) {
00931 this->mDsmSimuPatchSum[i] = 0;
00932 } else {
00933 int lut = -1;
00934 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));
00935 this->mDsmSimuPatchSum[i] = lut;
00936 }
00937
00938 if (this->mDsmL0InputHighTower[i] != this->mDsmSimuHighTower[i]) {
00939 if (mDebug >= 2) cout << i << ": HT " << this->mDsmSimuHighTower[i] << " != " << this->mDsmL0InputHighTower[i] << endl;
00940 if (this->mHistTriggerCorruptionHighTower) this->mHistTriggerCorruptionHighTower->Fill(i);
00941 if (this->mHistDSM0HTCorr) this->mHistDSM0HTCorr->Fill(this->mDsmL0InputHighTower[i], this->mDsmSimuHighTower[i]);
00942 } else {
00943
00944 }
00945 if (this->mDsmL0InputPatchSum[i] != this->mDsmSimuPatchSum[i]) {
00946 if (mDebug >= 2) cout << i << ": PA " << this->mDsmSimuPatchSum[i] << " != " << this->mDsmL0InputPatchSum[i] << endl;
00947 if (this->mHistTriggerCorruptionPatchSum) this->mHistTriggerCorruptionPatchSum->Fill(i);
00948 if (this->mHistDSM0TPCorr) this->mHistDSM0TPCorr->Fill(this->mDsmL0InputPatchSum[i], this->mDsmSimuPatchSum[i]);
00949 } else {
00950
00951 }
00952
00953 }
00954 }
00955 }
00956 if (this->mHist_BTOW_Corruption) this->mHist_BTOW_Corruption->Fill(0.0);
00957 if (this->mHist_BTOW_Corruption) this->mHist_BTOW_Corruption->Fill(STATUS);
00958
00959 {
00960 int totalSumSMD = 0;
00961 int totalSumPSD = 0;
00962 int feeSum[120];
00963 int pmtSum[60];
00964 memset(feeSum, 0, sizeof(feeSum));
00965 memset(pmtSum, 0, sizeof(pmtSum));
00966 bool smdPresent = false;
00967 bool psdPresent = false;
00968 for (int bsmd_fiber = 0;bsmd_fiber < BSMD_FIBERS;bsmd_fiber++) {
00969 int bprs_fiber = bsmd_fiber - 8;
00970 #ifdef NEW_DAQ_READER
00971 daq_dta *dd_bsmd = rdr ? (rdr->det("bsmd")->get("adc", 0, bsmd_fiber + 1)) : 0;
00972 if (dd_bsmd) while (dd_bsmd->iterate()) {
00973 bsmd_t *d = (bsmd_t *) dd_bsmd->Void;
00974 if (d && BEMCDecoder) {
00975 #else
00976 if (emc.bsmd_in && BEMCDecoder) {
00977 {
00978 #endif
00979 int fiberSum = 0;
00980 int det = -1, m = -1, e = -1, s = -1;
00981 int softId = -1, box = -1, wire = -1, Avalue = -1;
00982 #ifdef NEW_DAQ_READER
00983 int cap = d->cap;
00984 #else
00985 int cap = emc.bsmd_cap[bsmd_fiber];
00986 #endif
00987 for (int fiber_channel = 0;fiber_channel < BSMD_DATSIZE;fiber_channel++) {
00988 #ifdef NEW_DAQ_READER
00989 int adc = d->adc[fiber_channel];
00990 #else
00991 int adc = emc.bsmd[bsmd_fiber][fiber_channel];
00992 #endif
00993 fiberSum += adc;
00994 if ((bsmd_fiber >= 0) && (bsmd_fiber < 8)) {
00995 if (BEMCDecoder->GetSmdCoord(bsmd_fiber, fiber_channel, det, m, e, s)) {
00996 smdPresent = true;
00997 totalSumSMD += adc;
00998 if ((m >= 1) && (m <= 120)) {
00999 feeSum[m - 1] += adc;
01000 }
01001 }
01002 } else {
01003 if (BEMCDecoder->GetPsdId(bprs_fiber, fiber_channel, softId, box, wire, Avalue)) {
01004 psdPresent = true;
01005 totalSumPSD += adc;
01006 if ((box >= 1) && (box <= 60)) {
01007 pmtSum[box - 1] += adc;
01008 float iphi, eta;
01009 StEmcGeom *BEMCGeom = StEmcGeom::instance("bemc");
01010 if(adc>20){
01011 BEMCGeom->getEta(softId, eta);
01012 BEMCGeom->getPhi(softId, iphi);
01013 if (this->mHist_ADCEtaPhi_Pre1Hits) this->mHist_ADCEtaPhi_Pre1Hits->Fill(iphi, eta);
01014 }
01015 if ((softId >= 1) && (softId <= 1220)) {
01016 if (this->mHistRawAdcPsd1) this->mHistRawAdcPsd1->Fill(softId, adc);
01017 } else if ((softId >= 1221) && (softId <= 2400)) {
01018 if (this->mHistRawAdcPsd2) this->mHistRawAdcPsd2->Fill(softId, adc);
01019 } else if ((softId >= 2401) && (softId <= 3540)) {
01020 if (this->mHistRawAdcPsd3) this->mHistRawAdcPsd3->Fill(softId, adc);
01021 } else if ((softId >= 3541) && (softId <= 4800)) {
01022 if (this->mHistRawAdcPsd4) this->mHistRawAdcPsd4->Fill(softId, adc);
01023 }
01024 }
01025 }
01026 }
01027 }
01028 int BSMD_STATUS = BEMCOK;
01029 if (fiberSum == 0) BSMD_STATUS = BEMCNOTINSTALLED;
01030
01031 if((bsmd_fiber >= 0) && (bsmd_fiber < 8)) {
01032 if (this->mHist_SMD_status) this->mHist_SMD_status->Fill(0.0, bsmd_fiber);
01033 if (this->mHist_SMD_status) this->mHist_SMD_status->Fill(BSMD_STATUS, bsmd_fiber);
01034 if(BSMD_STATUS==BEMCOK) {
01035 if (this->mHist_smd_capacitor) this->mHist_smd_capacitor->Fill(cap, bsmd_fiber);
01036 if (this->mHist_smd_sum) this->mHist_smd_sum->Fill(fiberSum, bsmd_fiber);
01037 }
01038 } else {
01039 if (this->mHist_PSD_status) this->mHist_PSD_status->Fill(0.0, bprs_fiber);
01040 if (this->mHist_PSD_status) this->mHist_PSD_status->Fill(BSMD_STATUS, bprs_fiber);
01041 if(BSMD_STATUS==BEMCOK) {
01042 if (this->mHist_psd_capacitor) this->mHist_psd_capacitor->Fill(cap, bprs_fiber);
01043 if (this->mHist_psd_sum) this->mHist_psd_sum->Fill(fiberSum, bprs_fiber);
01044 }
01045 }
01046 }
01047 }
01048 }
01049 if (smdPresent) for (int i = 0;i < 120;i++) {
01050 if (this->mHistSmdFeeSum) this->mHistSmdFeeSum->Fill(i + 1, feeSum[i]);
01051 }
01052 if (psdPresent) for (int i = 0;i < 60;i++) {
01053 if (this->mHistPsdFeeSum) this->mHistPsdFeeSum->Fill(i + 1, pmtSum[i]);
01054 }
01055 if (smdPresent && this->mHist_smd_spectra) this->mHist_smd_spectra->Fill(totalSumSMD);
01056 if (psdPresent && this->mHist_psd_spectra) this->mHist_psd_spectra->Fill(totalSumPSD);
01057 }
01058
01059 {
01060 int totalSumSMDNonZS = 0;
01061 int totalSumPSDNonZS = 0;
01062 int feeSumNonZS[120];
01063 int pmtSumNonZS[60];
01064 memset(feeSumNonZS, 0, sizeof(feeSumNonZS));
01065 memset(pmtSumNonZS, 0, sizeof(pmtSumNonZS));
01066 bool smdPresentNonZS = false;
01067 bool psdPresentNonZS = false;
01068 for (int bsmd_fiber = 0;bsmd_fiber < BSMD_FIBERS;bsmd_fiber++) {
01069 int bprs_fiber = bsmd_fiber - 8;
01070 #ifdef NEW_DAQ_READER
01071 daq_dta *dd_bsmd = rdr ? (rdr->det("bsmd")->get("adc_non_zs", 0, bsmd_fiber + 1)) : 0;
01072 if (dd_bsmd) while (dd_bsmd->iterate()) {
01073 bsmd_t *d = (bsmd_t *) dd_bsmd->Void;
01074 if (d && BEMCDecoder) {
01075 #else
01076 if (emc.bsmd_in && BEMCDecoder) {
01077 {
01078 #endif
01079 int fiberSum = 0;
01080 int det = -1, m = -1, e = -1, s = -1;
01081 int softId = -1, box = -1, wire = -1, Avalue = -1;
01082 #ifdef NEW_DAQ_READER
01083 int cap = d->cap;
01084 #else
01085 int cap = emc.bsmd_cap[bsmd_fiber];
01086 #endif
01087 for (int fiber_channel = 0;fiber_channel < BSMD_DATSIZE;fiber_channel++) {
01088 #ifdef NEW_DAQ_READER
01089 int adc = d->adc[fiber_channel];
01090 #else
01091 int adc = emc.bsmd[bsmd_fiber][fiber_channel];
01092 #endif
01093 fiberSum += adc;
01094 if ((bsmd_fiber >= 0) && (bsmd_fiber < 8)) {
01095 if (BEMCDecoder->GetSmdCoord(bsmd_fiber, fiber_channel, det, m, e, s)) {
01096 smdPresentNonZS = true;
01097 totalSumSMDNonZS += adc;
01098 if ((m >= 1) && (m <= 120)) {
01099 feeSumNonZS[m - 1] += adc;
01100 }
01101 }
01102 } else {
01103 if (BEMCDecoder->GetPsdId(bprs_fiber, fiber_channel, softId, box, wire, Avalue)) {
01104 psdPresentNonZS = true;
01105 totalSumPSDNonZS += adc;
01106 if ((box >= 1) && (box <= 60)) {
01107 pmtSumNonZS[box - 1] += adc;
01108 }
01109 }
01110 }
01111 }
01112 }
01113 }
01114 }
01115 if (smdPresentNonZS) for (int i = 0;i < 120;i++) {
01116 if (this->mHistSmdFeeSumNonZS) this->mHistSmdFeeSumNonZS->Fill(i + 1, feeSumNonZS[i]);
01117 }
01118 if (psdPresentNonZS) for (int i = 0;i < 60;i++) {
01119 if (this->mHistPsdFeeSumNonZS) this->mHistPsdFeeSumNonZS->Fill(i + 1, pmtSumNonZS[i]);
01120 }
01121 if (smdPresentNonZS && this->mHist_smd_spectraNonZS) this->mHist_smd_spectraNonZS->Fill(totalSumSMDNonZS);
01122 if (psdPresentNonZS && this->mHist_psd_spectraNonZS) this->mHist_psd_spectraNonZS->Fill(totalSumPSDNonZS);
01123 }
01124
01125 if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
01126 }
01127
01128
01129