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_Calib.root
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",
50 printf("Wrong number of arguments\n");
54 /* Retrieve ZS parameters from DAQ DB */
55 const char* zsfile = "zs.txt";
56 int failZS = daqDA_DB_getFile(zsfile, zsfile);
58 Int_t offset,threshold;
61 FILE *f = fopen(zsfile,"r");
62 int scan = fscanf(f,"%d %d",&offset,&threshold);
65 /* Retrieve mapping files from DAQ DB */
66 const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
68 for(Int_t iFile=0; iFile<4; iFile++) {
69 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
71 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
76 /* Open mapping files */
77 AliAltroMapping *mapping[4];
81 for(Int_t i = 0; i < 4; i++) {
85 mapping[i] = new AliCaloAltroMapping(path2.Data());
88 /* define data source : this is argument 1 */
89 status=monitorSetDataSource( argv[1] );
91 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
96 /* declare monitoring program */
97 status=monitorDeclareMp( __FILE__ );
99 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
104 /* define wait event timeout - 1s max */
106 monitorSetNoWaitNetworkTimeout(1000);
108 /* init some counters */
109 int nevents_physics=0;
112 AliRawReader *rawReader = NULL;
113 AliPHOSRcuDA1* dAs[5];
115 for(Int_t iMod=0; iMod<5; iMod++) {
119 Float_t e[64][56][2];
120 Float_t t[64][56][2];
122 for(Int_t iX=0; iX<64; iX++) {
123 for(Int_t iZ=0; iZ<56; iZ++) {
124 for(Int_t iGain=0; iGain<2; iGain++) {
125 e[iX][iZ][iGain] = 0.;
126 t[iX][iZ][iGain] = 0.;
134 Int_t sigStart, sigLength;
137 /* main loop (infinite) */
139 struct eventHeaderStruct *event;
140 eventTypeType eventT;
142 /* check shutdown condition */
143 if (daqDA_checkShutdown()) {break;}
145 /* get next event (blocking call until timeout) */
146 status=monitorGetEventDynamic((void **)&event);
147 if (status==MON_ERR_EOF) {
148 printf ("End of File detected\n");
149 break; /* end of monitoring file has been reached */
153 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
157 /* retry if got no event */
163 /* use event - here, just write event id to result file */
164 eventT=event->eventType;
166 if (eventT==PHYSICS_EVENT) {
168 rawReader = new AliRawReaderDate((void*)event);
169 AliCaloRawStreamV3 stream(rawReader,"PHOS",mapping);
170 AliPHOSRawFitterv0 fitter;
171 fitter.SubtractPedestals(kTRUE); // assume that data is non-ZS
174 fitter.SubtractPedestals(kFALSE);
175 fitter.SetAmpOffset(offset);
176 fitter.SetAmpThreshold(threshold);
179 while (stream.NextDDL()) {
180 while (stream.NextChannel()) {
182 cellX = stream.GetCellX();
183 cellZ = stream.GetCellZ();
184 caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
186 if(caloFlag!=0 && caloFlag!=1) continue; //TRU data!
188 // In case of oscillating signals with ZS,
189 //a channel can have several bunches.
192 while (stream.NextBunch()) {
194 if (nBunches > 1) continue;
195 sigStart = stream.GetStartTimeBin();
196 sigLength = stream.GetBunchLength();
197 fitter.SetChannelGeo(stream.GetModule(),cellX,cellZ,caloFlag);
198 fitter.Eval(stream.GetSignals(),sigStart,sigLength);
199 } // End of NextBunch()
201 if (nBunches>1) continue;
203 e[cellX][cellZ][caloFlag] = fitter.GetEnergy();
204 t[cellX][cellZ][caloFlag] = fitter.GetTime();
207 if(stream.GetModule()<0 || stream.GetModule()>4) continue;
209 if(dAs[stream.GetModule()])
210 dAs[stream.GetModule()]->FillHistograms(e,t);
212 dAs[stream.GetModule()] = new AliPHOSRcuDA1(stream.GetModule(),-1);
213 dAs[stream.GetModule()]->FillHistograms(e,t);
216 for(Int_t iX=0; iX<64; iX++) {
217 for(Int_t iZ=0; iZ<56; iZ++) {
218 for(Int_t iGain=0; iGain<2; iGain++) {
219 e[iX][iZ][iGain] = 0.;
220 t[iX][iZ][iGain] = 0.;
227 // da1.FillHistograms(e,t);
228 // //da1.UpdateHistoFile();
239 /* exit when last event received, no need to wait for TERM signal */
240 if (eventT==END_OF_RUN) {
241 printf("EOR event detected\n");
246 for(Int_t i = 0; i < 4; i++) delete mapping[i];
248 /* Be sure that all histograms are saved */
252 for(Int_t iMod=0; iMod<5; iMod++) {
253 if(!dAs[iMod]) continue;
255 dAs[iMod]->UpdateHistoFile();
256 dAs[iMod]->SetWriteToFile(kFALSE);
258 /* Store output files to the File Exchange Server */
259 sprintf(localfile,"PHOS_Module%d_Calib.root",iMod);
260 daqDA_FES_storeFile(localfile,"AMPLITUDES");