2 contact: Boris.Polishchuk@cern.ch
3 link: see comments in the $ALICE_ROOT/PHOS/AliPHOSRcuDA1.cxx
4 reference run: /castor/cern.ch/alice/phos/2007/10/04/18/07000008249001.1000.root
7 number of events needed: 1000
8 input files: RCU0.data RCU1.data RCU2.data RCU3.data
9 Output files: PHOS_Module2_LED.root
10 Trigger types used: CALIBRATION_EVENT
25 #include <TPluginManager.h>
27 #include "AliRawReader.h"
28 #include "AliRawReaderDate.h"
29 #include "AliPHOSRcuDA1.h"
30 #include "AliPHOSRawFitterv0.h"
31 #include "AliCaloAltroMapping.h"
32 #include "AliCaloRawStreamV3.h"
37 1- monitoring data source
39 int main(int argc, char **argv) {
41 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
50 printf("Wrong number of arguments\n");
54 /* Retrieve mapping files from DAQ DB */
55 const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
57 for(Int_t iFile=0; iFile<4; iFile++) {
58 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
60 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
65 /* Open mapping files */
66 AliAltroMapping *mapping[4];
70 for(Int_t i = 0; i < 4; i++) {
74 mapping[i] = new AliCaloAltroMapping(path2.Data());
78 /* define data source : this is argument 1 */
79 status=monitorSetDataSource( argv[1] );
81 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
86 /* declare monitoring program */
87 status=monitorDeclareMp( __FILE__ );
89 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
94 /* define wait event timeout - 1s max */
96 monitorSetNoWaitNetworkTimeout(1000);
98 /* init some counters */
99 int nevents_physics=0;
102 AliRawReader *rawReader = NULL;
103 AliPHOSRcuDA1* dAs[5];
105 for(Int_t iMod=0; iMod<5; iMod++) {
109 Float_t e[64][56][2];
110 Float_t t[64][56][2];
116 Int_t sigStart, sigLength;
120 TH1I fFiredCells("fFiredCells","Number of fired cells per event",100,0,1000);
122 /* main loop (infinite) */
124 struct eventHeaderStruct *event;
125 eventTypeType eventT;
127 /* check shutdown condition */
128 if (daqDA_checkShutdown()) {break;}
130 /* get next event (blocking call until timeout) */
131 status=monitorGetEventDynamic((void **)&event);
132 if (status==MON_ERR_EOF) {
133 printf ("End of File detected\n");
134 break; /* end of monitoring file has been reached */
138 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
142 /* retry if got no event */
148 /* use event - here, just write event id to result file */
149 eventT=event->eventType;
151 if (eventT==PHYSICS_EVENT) {
155 rawReader = new AliRawReaderDate((void*)event);
156 AliCaloRawStreamV3 stream(rawReader,"PHOS",mapping);
157 AliPHOSRawFitterv0 fitter;
158 fitter.SubtractPedestals(kTRUE); // assume that data is non-ZS
160 while (stream.NextDDL()) {
161 while (stream.NextChannel()) {
163 cellX = stream.GetCellX();
164 cellZ = stream.GetCellZ();
165 caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
167 // In case of oscillating signals with ZS, a channel can have several bunches
169 while (stream.NextBunch()) {
171 if (nBunches > 1) continue;
172 sigStart = stream.GetStartTimeBin();
173 sigLength = stream.GetBunchLength();
174 fitter.SetSamples(stream.GetSignals(),sigStart,sigLength);
175 } // End of NextBunch()
177 fitter.SetNBunches(nBunches);
178 fitter.SetChannelGeo(stream.GetModule(),cellX,cellZ,caloFlag);
181 if(nBunches>1) continue;
182 // if (nBunches>1 || caloFlag!=0 || caloFlag!=1 || fitter.GetSignalQuality()>1) continue;
184 e[cellX][cellZ][caloFlag] = fitter.GetEnergy();
185 t[cellX][cellZ][caloFlag] = fitter.GetTime();
187 if(caloFlag==1 && fitter.GetEnergy()>40)
191 if(dAs[stream.GetModule()])
192 dAs[stream.GetModule()]->FillHistograms(e,t);
194 dAs[stream.GetModule()] = new AliPHOSRcuDA1(stream.GetModule(),-1,0);
196 for(Int_t iX=0; iX<64; iX++) {
197 for(Int_t iZ=0; iZ<56; iZ++) {
198 for(Int_t iGain=0; iGain<2; iGain++) {
199 e[iX][iZ][iGain] = 0.;
200 t[iX][iZ][iGain] = 0.;
207 fFiredCells.Fill(nFired);
218 /* exit when last event received, no need to wait for TERM signal */
219 if (eventT==END_OF_RUN) {
220 printf("EOR event detected\n");
225 for(Int_t i = 0; i < 4; i++) delete mapping[i];
227 /* Be sure that all histograms are saved */
233 Int_t nGood=0; // >10 entries in peak
234 Int_t nMax=-111; // max. number of entries in peak
239 for(Int_t iMod=0; iMod<5; iMod++) {
240 if(!dAs[iMod]) continue;
242 printf("DA1 for module %d detected.\n",iMod);
243 sprintf(localfile,"PHOS_Module%d_LED.root",iMod);
244 TFile* f = new TFile(localfile,"recreate");
246 for(Int_t iX=0; iX<64; iX++) {
247 for(Int_t iZ=0; iZ<56; iZ++) {
249 h1 = dAs[iMod]->GetHgLgRatioHistogram(iX,iZ); // High Gain/Low Gain ratio
251 if(h1->GetMaximum()>10.) nGood++;
252 if(h1->GetMaximum()>nMax) {
253 nMax = (Int_t)h1->GetMaximum(); iXmax=iX; iZmax=iZ; iModMax=iMod;
258 for(Int_t iGain=0; iGain<2; iGain++) {
259 h2 = dAs[iMod]->GetTimeEnergyHistogram(iX,iZ,iGain); // Time vs Energy
269 /* Store output files to the File Exchange Server */
270 daqDA_FES_storeFile(localfile,"LED");
273 printf("%d physics events of %d total processed.\n",nevents_physics,nevents_total);
274 printf("%d histograms has >10 entries in maximum, max. is %d entries ",nGood,nMax);
275 printf("(module,iX,iZ)=(%d,%d,%d)",iModMax,iXmax,iZmax);