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 "AliPHOSRawDecoder.h"
31 #include "AliCaloAltroMapping.h"
36 1- monitoring data source
38 int main(int argc, char **argv) {
40 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
49 printf("Wrong number of arguments\n");
53 /* Retrieve mapping files from DAQ DB */
54 const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
56 for(Int_t iFile=0; iFile<4; iFile++) {
57 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
59 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
64 /* Open mapping files */
65 AliAltroMapping *mapping[4];
69 for(Int_t i = 0; i < 4; i++) {
73 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 Int_t fMod = 2; // module 2!
102 AliRawReader *rawReader = NULL;
104 AliPHOSRcuDA1 da1(fMod,-1,0); // DA1 for module2, no input/output file
106 Float_t e[64][56][2];
107 Float_t t[64][56][2];
113 /* main loop (infinite) */
115 struct eventHeaderStruct *event;
116 eventTypeType eventT;
118 /* check shutdown condition */
119 if (daqDA_checkShutdown()) {break;}
121 /* get next event (blocking call until timeout) */
122 status=monitorGetEventDynamic((void **)&event);
123 if (status==MON_ERR_EOF) {
124 printf ("End of File detected\n");
125 break; /* end of monitoring file has been reached */
129 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
133 /* retry if got no event */
139 /* use event - here, just write event id to result file */
140 eventT=event->eventType;
142 if (eventT==PHYSICS_EVENT) {
144 for(Int_t iX=0; iX<64; iX++) {
145 for(Int_t iZ=0; iZ<56; iZ++) {
146 for(Int_t iGain=0; iGain<2; iGain++) {
147 e[iX][iZ][iGain] = 0.;
148 t[iX][iZ][iGain] = 0.;
153 rawReader = new AliRawReaderDate((void*)event);
154 // AliPHOSRawDecoderv1 dc(rawReader,mapping);
155 AliPHOSRawDecoder dc(rawReader,mapping);
156 dc.SubtractPedestals(kTRUE);
158 while(dc.NextDigit()) {
161 Z = dc.GetColumn() - 1;
163 if(dc.IsLowGain()) gain = 0;
167 e[X][Z][gain] = dc.GetEnergy();
168 t[X][Z][gain] = dc.GetTime();
172 da1.FillHistograms(e,t);
183 /* exit when last event received, no need to wait for TERM signal */
184 if (eventT==END_OF_RUN) {
185 printf("EOR event detected\n");
190 for(Int_t i = 0; i < 4; i++) delete mapping[i];
192 /* Be sure that all histograms are saved */
195 sprintf(localfile,"PHOS_Module%d_LED.root",fMod);
196 TFile* f = new TFile(localfile,"recreate");
201 Int_t nGood=0; // >10 entries in peak
202 Int_t nMax=-111; // max. number of entries in peak
206 for(Int_t iX=0; iX<64; iX++) {
207 for(Int_t iZ=0; iZ<56; iZ++) {
209 h1 = da1.GetHgLgRatioHistogram(iX,iZ); // High Gain/Low Gain ratio
211 if(h1->GetMaximum()>10.) nGood++;
212 if(h1->GetMaximum()>nMax) {nMax = (Int_t)h1->GetMaximum(); iXmax=iX; iZmax=iZ;}
216 for(Int_t iGain=0; iGain<2; iGain++) {
217 h2 = da1.GetTimeEnergyHistogram(iX,iZ,iGain); // Time vs Energy
226 /* Store output files to the File Exchange Server */
229 for(Int_t iMod=0; iMod<5; iMod++) {
230 sprintf(localfile,"PHOS_Module%d_LED.root",iMod);
231 sprintf(fesfileid,"PHOS_Module%d_LED",iMod);
232 daqDA_FES_storeFile(localfile,fesfileid);
235 printf("%d physics events of %d total processed.\n",nevents_physics,nevents_total);
236 printf("%d histograms has >10 entries in maximum, max. is %d entries ",nGood,nMax);
237 printf("(module,iX,iZ)=(%d,%d,%d)",fMod,iXmax,iZmax);