2 contact: Boris.Polishchuk@cern.ch
3 link: http://aliceinfo.cern.ch/static/phpBB3/viewtopic.php?f=4&t=17
4 reference run: /castor/cern.ch/alice/phos/2007/10/02/13/07000008232001.10.root
7 number of events needed: 1000
8 input files: RCU0.data RCU1.data RCU2.data RCU3.data
9 Output files: PHOS_Module2_BCM.root
10 Trigger types used: CALIBRATION_EVENT or PHYSICS
25 #include <TPluginManager.h>
27 #include "AliRawReader.h"
28 #include "AliRawReaderDate.h"
29 #include "AliPHOSDA2.h"
30 #include "AliPHOSRawFitterv1.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");
55 /* Retrieve mapping files from DAQ DB */
56 const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
58 for(Int_t iFile=0; iFile<4; iFile++) {
59 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
61 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
66 /* Open mapping files */
67 AliAltroMapping *mapping[4];
71 for(Int_t i = 0; i < 4; i++) {
75 mapping[i] = new AliCaloAltroMapping(path2.Data());
79 /* define data source : this is argument 1 */
80 status=monitorSetDataSource( argv[1] );
82 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
87 /* declare monitoring program */
88 status=monitorDeclareMp( __FILE__ );
90 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
95 /* define wait event timeout - 1s max */
97 monitorSetNoWaitNetworkTimeout(1000);
100 /* log start of process */
101 printf("DA2 (bad channels search) started.\n");
104 /* init some counters */
105 int nevents_physics=0;
108 AliRawReader *rawReader = NULL;
110 AliPHOSDA2* da2 = new AliPHOSDA2(2); // DA2 ("Checking for bad channels") for module2
112 Float_t q[64][56][2];
119 Int_t sigStart, sigLength;
121 /* main loop (infinite) */
123 struct eventHeaderStruct *event;
124 eventTypeType eventT;
126 /* check shutdown condition */
127 if (daqDA_checkShutdown()) {break;}
129 /* get next event (blocking call until timeout) */
130 status=monitorGetEventDynamic((void **)&event);
131 if (status==MON_ERR_EOF) {
132 printf ("End of File detected\n");
133 break; /* end of monitoring file has been reached */
137 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
141 /* retry if got no event */
147 /* use event - here, just write event id to result file */
148 eventT=event->eventType;
150 if (eventT==PHYSICS_EVENT || eventT==CALIBRATION_EVENT) {
152 for(Int_t iX=0; iX<64; iX++) {
153 for(Int_t iZ=0; iZ<56; iZ++) {
154 for(Int_t iGain=0; iGain<2; iGain++) {
155 q[iX][iZ][iGain] = 0.;
162 rawReader = new AliRawReaderDate((void*)event);
163 AliCaloRawStreamV3 stream(rawReader,"PHOS",mapping);
164 AliPHOSRawFitterv0 fitter();
165 fitter.SubtractPedestals(kTRUE); // assume that data is non-ZS
167 while (stream.NextDDL()) {
168 while (stream.NextChannel()) {
170 cellX = stream.GetCellX();
171 cellZ = stream.GetCellZ();
172 caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
174 // In case of oscillating signals with ZS, a channel can have several bunches
176 while (stream.NextBunch()) {
178 if (nBunches > 1) continue;
179 sigStart = fRawStream.GetStartTimeBin();
180 sigLength = fRawStream.GetBunchLength();
181 fitter.SetSamples(fRawStream->GetSignals(),sigStart,sigLength);
182 } // End of NextBunch()
184 fitter.SetNBunches(nBunches);
185 fitter.SetChannelGeo(module,cellX,cellZ,caloFlag);
188 if (nBunches>1 || caloFlag!=0 || caloFlag!=1 || fitter.GetSignalQuality()>1) continue;
190 q[cellX][cellZ][caloFlag] = fitter.GetSignalQuality();
192 if(gain && dc.GetEnergy()>40)
197 da2->FillQualityHistograms(q);
198 da2->FillFiredCellsHistogram(nFired);
199 //da1.UpdateHistoFile();
210 /* exit when last event received, no need to wait for TERM signal */
211 if (eventT==END_OF_RUN) {
212 printf("EOR event detected\n");
217 for(Int_t i = 0; i < 4; i++) delete mapping[i];
219 /* Be sure that all histograms are saved */
222 /* Store output files to the File Exchange Server */
223 daqDA_FES_storeFile("PHOS_Module2_BCM.root","BAD_CHANNELS");