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: RCU0.data RCU1.data RCU2.data RCU3.data zs.txt
9 Output files: PHOS_ModuleN_Calib.root, where N is the module number (0-5).
10 Trigger types used: PHYSICS
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",
47 AliLog::SetGlobalDebugLevel(0) ;
48 AliLog::SetGlobalLogLevel(AliLog::kFatal);
53 printf("Wrong number of arguments\n");
57 /* Retrieve ZS parameters from DAQ DB */
58 const char* zsfile = "zs.txt";
59 int failZS = daqDA_DB_getFile(zsfile, zsfile);
61 Int_t offset,threshold;
64 FILE *f = fopen(zsfile,"r");
65 int scan = fscanf(f,"%d %d",&offset,&threshold);
68 /* Retrieve mapping files from DAQ DB */
69 const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
71 for(Int_t iFile=0; iFile<4; iFile++) {
72 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
74 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
79 /* Open mapping files */
80 AliAltroMapping *mapping[4];
84 for(Int_t i = 0; i < 4; i++) {
88 mapping[i] = new AliCaloAltroMapping(path2.Data());
91 /* define data source : this is argument 1 */
92 status=monitorSetDataSource( argv[1] );
94 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
99 /* declare monitoring program */
100 status=monitorDeclareMp( __FILE__ );
102 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
107 /* define wait event timeout - 1s max */
109 monitorSetNoWaitNetworkTimeout(1000);
111 /* init some counters */
112 int nevents_physics=0;
115 AliRawReader *rawReader = NULL;
116 AliPHOSRcuDA1* dAs[5];
118 for(Int_t iMod=0; iMod<5; iMod++) {
122 Float_t e[64][56][2];
123 Float_t t[64][56][2];
125 for(Int_t iX=0; iX<64; iX++) {
126 for(Int_t iZ=0; iZ<56; iZ++) {
127 for(Int_t iGain=0; iGain<2; iGain++) {
128 e[iX][iZ][iGain] = 0.;
129 t[iX][iZ][iGain] = 0.;
137 Int_t sigStart, sigLength;
140 /* main loop (infinite) */
142 struct eventHeaderStruct *event;
143 eventTypeType eventT;
145 /* check shutdown condition */
146 if (daqDA_checkShutdown()) {break;}
148 /* get next event (blocking call until timeout) */
149 status=monitorGetEventDynamic((void **)&event);
150 if (status==MON_ERR_EOF) {
151 printf ("End of File detected\n");
152 break; /* end of monitoring file has been reached */
156 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
160 /* retry if got no event */
166 /* use event - here, just write event id to result file */
167 eventT=event->eventType;
169 if (eventT==PHYSICS_EVENT) {
171 rawReader = new AliRawReaderDate((void*)event);
172 AliCaloRawStreamV3 stream(rawReader,"PHOS",mapping);
173 AliPHOSRawFitterv0 fitter;
174 fitter.SubtractPedestals(kTRUE); // assume that data is non-ZS
177 fitter.SubtractPedestals(kFALSE);
178 fitter.SetAmpOffset(offset);
179 fitter.SetAmpThreshold(threshold);
182 while (stream.NextDDL()) {
183 while (stream.NextChannel()) {
185 cellX = stream.GetCellX();
186 cellZ = stream.GetCellZ();
187 caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
189 if(caloFlag!=0 && caloFlag!=1) continue; //TRU data!
191 // In case of oscillating signals with ZS,
192 //a channel can have several bunches.
195 while (stream.NextBunch()) {
197 if (nBunches > 1) continue;
198 sigStart = stream.GetStartTimeBin();
199 sigLength = stream.GetBunchLength();
200 fitter.SetChannelGeo(stream.GetModule(),cellX,cellZ,caloFlag);
201 fitter.Eval(stream.GetSignals(),sigStart,sigLength);
202 } // End of NextBunch()
204 if (nBunches>1) continue;
206 e[cellX][cellZ][caloFlag] = fitter.GetEnergy();
207 t[cellX][cellZ][caloFlag] = fitter.GetTime();
210 if(stream.GetModule()<0 || stream.GetModule()>4) continue;
212 if(dAs[stream.GetModule()])
213 dAs[stream.GetModule()]->FillHistograms(e,t);
215 dAs[stream.GetModule()] = new AliPHOSRcuDA1(stream.GetModule(),-1);
216 dAs[stream.GetModule()]->FillHistograms(e,t);
219 for(Int_t iX=0; iX<64; iX++) {
220 for(Int_t iZ=0; iZ<56; iZ++) {
221 for(Int_t iGain=0; iGain<2; iGain++) {
222 e[iX][iZ][iGain] = 0.;
223 t[iX][iZ][iGain] = 0.;
230 // da1.FillHistograms(e,t);
231 // //da1.UpdateHistoFile();
242 /* exit when last event received, no need to wait for TERM signal */
243 if (eventT==END_OF_RUN) {
244 printf("EOR event detected\n");
249 for(Int_t i = 0; i < 4; i++) delete mapping[i];
251 /* Be sure that all histograms are saved */
255 for(Int_t iMod=0; iMod<5; iMod++) {
256 if(!dAs[iMod]) continue;
258 dAs[iMod]->UpdateHistoFile();
259 dAs[iMod]->SetWriteToFile(kFALSE);
261 /* Store output files to the File Exchange Server */
262 sprintf(localfile,"PHOS_Module%d_Calib.root",iMod);
263 daqDA_FES_storeFile(localfile,"AMPLITUDES");