2 contact: Boris.Polishchuk@cern.ch
3 link: see comments in the $ALICE_ROOT/PHOS/AliPHOSRcuDA1.cxx
4 reference run: /alice/data/2009/LHC09b_PHOS/000075883/raw/09000075883017.20.root
7 number of events needed: 1000
8 input files: Mod0RCU0.data Mod0RCU1.data Mod0RCU2.data Mod0RCU3.data Mod1RCU0.data Mod1RCU1.data Mod1RCU2.data Mod1RCU3.data Mod2RCU0.data Mod2RCU1.data Mod2RCU2.data Mod2RCU3.data Mod3RCU0.data Mod3RCU1.data Mod3RCU2.data Mod3RCU3.data Mod4RCU0.data Mod4RCU1.data Mod4RCU2.data Mod4RCU3.data zs.txt
9 Output files: PHOS_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"
38 1- monitoring data source
40 int main(int argc, char **argv) {
42 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
48 AliLog::SetGlobalDebugLevel(0) ;
49 AliLog::SetGlobalLogLevel(AliLog::kFatal);
54 printf("Wrong number of arguments\n");
58 /* Retrieve ZS parameters from DAQ DB */
59 const char* zsfile = "zs.txt";
60 int failZS = daqDA_DB_getFile(zsfile, zsfile);
62 short offset,threshold;
65 FILE *f = fopen(zsfile,"r");
66 int scan = fscanf(f,"%d %d",&offset,&threshold);
69 /* Retrieve mapping files from DAQ DB */
70 const char* mapFiles[20] = {
93 for(Int_t iFile=0; iFile<20; iFile++) {
94 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
96 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
101 /* Open mapping files */
102 AliAltroMapping *mapping[20];
110 for(Int_t iMod = 0; iMod < 5; iMod++) {
115 for(Int_t iRCU=0; iRCU<4; iRCU++) {
119 mapping[iMap] = new AliCaloAltroMapping(path3.Data());
124 /* define data source : this is argument 1 */
125 status=monitorSetDataSource( argv[1] );
127 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
132 /* declare monitoring program */
133 status=monitorDeclareMp( __FILE__ );
135 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
140 /* define wait event timeout - 1s max */
142 monitorSetNoWaitNetworkTimeout(1000);
144 /* init some counters */
145 int nevents_physics=0;
148 AliRawReader *rawReader = NULL;
149 AliPHOSRcuDA1* dAs[5];
151 for(Int_t iMod=0; iMod<5; iMod++) {
155 Float_t e[64][56][2];
156 Float_t t[64][56][2];
158 for(Int_t iX=0; iX<64; iX++) {
159 for(Int_t iZ=0; iZ<56; iZ++) {
160 for(Int_t iGain=0; iGain<2; iGain++) {
161 e[iX][iZ][iGain] = 0.;
162 t[iX][iZ][iGain] = 0.;
171 Int_t sigStart, sigLength;
175 TH1I fFiredCells("fFiredCells","Number of fired cells per event",100,0,1000);
177 /* main loop (infinite) */
179 struct eventHeaderStruct *event;
180 eventTypeType eventT;
182 /* check shutdown condition */
183 if (daqDA_checkShutdown()) {break;}
185 /* get next event (blocking call until timeout) */
186 status=monitorGetEventDynamic((void **)&event);
187 if (status==MON_ERR_EOF) {
188 printf ("End of File detected\n");
189 break; /* end of monitoring file has been reached */
193 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
197 /* retry if got no event */
203 /* use event - here, just write event id to result file */
204 eventT=event->eventType;
206 if (eventT==PHYSICS_EVENT) {
210 rawReader = new AliRawReaderDate((void*)event);
211 AliCaloRawStreamV3 stream(rawReader,"PHOS",mapping);
212 AliPHOSRawFitterv0 fitter;
213 fitter.SubtractPedestals(kTRUE); // assume that data is non-ZS
216 fitter.SubtractPedestals(kFALSE);
217 fitter.SetAmpOffset(offset);
218 fitter.SetAmpThreshold(threshold);
221 while (stream.NextDDL()) {
222 while (stream.NextChannel()) {
224 /* Retrieve ZS parameters from data*/
226 short value = stream.GetAltroCFG1();
227 bool ZeroSuppressionEnabled = (value >> 15) & 0x1;
228 bool AutomaticBaselineSubtraction = (value >> 14) & 0x1;
229 if(ZeroSuppressionEnabled) {
230 offset = (value >> 10) & 0xf;
231 threshold = value & 0x3ff;
232 fitter.SubtractPedestals(kFALSE);
233 fitter.SetAmpOffset(offset);
234 fitter.SetAmpThreshold(threshold);
238 cellX = stream.GetCellX();
239 cellZ = stream.GetCellZ();
240 caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
242 if(caloFlag!=0 && caloFlag!=1) continue; //TRU data!
244 // In case of oscillating signals with ZS, a channel can have several bunches
246 while (stream.NextBunch()) {
248 if (nBunches > 1) continue;
249 sigStart = stream.GetStartTimeBin();
250 sigLength = stream.GetBunchLength();
251 fitter.SetChannelGeo(stream.GetModule(),cellX,cellZ,caloFlag);
252 fitter.Eval(stream.GetSignals(),sigStart,sigLength);
253 } // End of NextBunch()
255 if(nBunches != 1) continue;
257 e[cellX][cellZ][caloFlag] = fitter.GetEnergy();
258 t[cellX][cellZ][caloFlag] = fitter.GetTime();
260 if(caloFlag==1 && fitter.GetEnergy()>40)
264 if(stream.GetModule()<0 || stream.GetModule()>4) continue;
266 if(dAs[stream.GetModule()])
267 dAs[stream.GetModule()]->FillHistograms(e,t);
269 dAs[stream.GetModule()] = new AliPHOSRcuDA1(stream.GetModule(),-1,0);
270 dAs[stream.GetModule()]->FillHistograms(e,t);
273 for(Int_t iX=0; iX<64; iX++) {
274 for(Int_t iZ=0; iZ<56; iZ++) {
275 for(Int_t iGain=0; iGain<2; iGain++) {
276 e[iX][iZ][iGain] = 0.;
277 t[iX][iZ][iGain] = 0.;
284 fFiredCells.Fill(nFired);
295 /* exit when last event received, no need to wait for TERM signal */
296 if (eventT==END_OF_RUN) {
297 printf("EOR event detected\n");
302 for(Int_t i = 0; i < 20; i++) delete mapping[i];
304 /* Be sure that all histograms are saved */
310 Int_t nGood=0; // >10 entries in peak
311 Int_t nMax=-111; // max. number of entries in peak
316 sprintf(localfile,"PHOS_LED.root");
317 TFile* f = new TFile(localfile,"recreate");
319 for(Int_t iMod=0; iMod<5; iMod++) {
320 if(!dAs[iMod]) continue;
322 printf("DA1 for module %d detected.\n",iMod);
324 for(Int_t iX=0; iX<64; iX++) {
325 for(Int_t iZ=0; iZ<56; iZ++) {
327 h1 = dAs[iMod]->GetHgLgRatioHistogram(iX,iZ); // High Gain/Low Gain ratio
329 if(h1->GetMaximum()>10.) nGood++;
330 if(h1->GetMaximum()>nMax) {
331 nMax = (Int_t)h1->GetMaximum(); iXmax=iX; iZmax=iZ; iModMax=iMod;
336 for(Int_t iGain=0; iGain<2; iGain++) {
337 h2 = dAs[iMod]->GetTimeEnergyHistogram(iX,iZ,iGain); // Time vs Energy
349 /* Store output files to the File Exchange Server */
350 daqDA_FES_storeFile(localfile,"LED");
352 printf("%d physics events of %d total processed.\n",nevents_physics,nevents_total);
353 printf("%d histograms has >10 entries in maximum, max. is %d entries ",nGood,nMax);
354 printf("(module,iX,iZ)=(%d,%d,%d)",iModMax,iXmax,iZmax);