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 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());
77 /* define data source : this is argument 1 */
78 status=monitorSetDataSource( argv[1] );
80 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
85 /* declare monitoring program */
86 status=monitorDeclareMp( __FILE__ );
88 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
93 /* define wait event timeout - 1s max */
95 monitorSetNoWaitNetworkTimeout(1000);
97 /* init some counters */
98 int nevents_physics=0;
101 AliRawReader *rawReader = NULL;
103 AliPHOSRcuDA1 da1(2,-1); // DA1 (Calibration DA) for module2
105 Float_t e[64][56][2];
106 Float_t t[64][56][2];
112 Int_t sigStart, sigLength;
114 /* main loop (infinite) */
116 struct eventHeaderStruct *event;
117 eventTypeType eventT;
119 /* check shutdown condition */
120 if (daqDA_checkShutdown()) {break;}
122 /* get next event (blocking call until timeout) */
123 status=monitorGetEventDynamic((void **)&event);
124 if (status==MON_ERR_EOF) {
125 printf ("End of File detected\n");
126 break; /* end of monitoring file has been reached */
130 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
134 /* retry if got no event */
140 /* use event - here, just write event id to result file */
141 eventT=event->eventType;
143 if (eventT==PHYSICS_EVENT) {
145 for(Int_t iX=0; iX<64; iX++) {
146 for(Int_t iZ=0; iZ<56; iZ++) {
147 for(Int_t iGain=0; iGain<2; iGain++) {
148 e[iX][iZ][iGain] = 0.;
149 t[iX][iZ][iGain] = 0.;
154 rawReader = new AliRawReaderDate((void*)event);
155 AliCaloRawStreamV3 stream(rawReader,"PHOS",mapping);
156 AliPHOSRawFitterv0 fitter();
157 fitter.SubtractPedestals(kTRUE); // assume that data is non-ZS
159 while (stream.NextDDL()) {
160 while (stream.NextChannel()) {
162 cellX = stream.GetCellX();
163 cellZ = stream.GetCellZ();
164 caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
166 // In case of oscillating signals with ZS, a channel can have several bunches
168 while (stream.NextBunch()) {
170 if (nBunches > 1) continue;
171 sigStart = fRawStream.GetStartTimeBin();
172 sigLength = fRawStream.GetBunchLength();
173 fitter.SetSamples(fRawStream->GetSignals(),sigStart,sigLength);
174 } // End of NextBunch()
176 fitter.SetNBunches(nBunches);
177 fitter.SetChannelGeo(module,cellX,cellZ,caloFlag);
180 if (nBunches>1 || caloFlag!=0 || caloFlag!=1 || fitter.GetSignalQuality()>1) continue;
182 e[cellX][cellZ][caloFlag] = fitter.GetEnergy();
183 t[cellX][cellZ][caloFlag] = fitter.GetTime();
187 da1.FillHistograms(e,t);
188 //da1.UpdateHistoFile();
199 /* exit when last event received, no need to wait for TERM signal */
200 if (eventT==END_OF_RUN) {
201 printf("EOR event detected\n");
206 for(Int_t i = 0; i < 4; i++) delete mapping[i];
208 /* Be sure that all histograms are saved */
210 da1.UpdateHistoFile();
211 da1.SetWriteToFile(kFALSE);
213 /* Store output files to the File Exchange Server */
216 for(Int_t iMod=0; iMod<5; iMod++) {
217 sprintf(localfile,"PHOS_Module%d_Calib.root",iMod);
218 daqDA_FES_storeFile(localfile,"AMPLITUDES");