2 contact: Boris.Polishchuk@cern.ch
3 reference run: /alice/data/2010/LHC10a_PHOS/000112189/raw/10000112189003.10.root
6 number of events needed: 200
7 input files: Mod0RCU0.data Mod0RCU1.data Mod0RCU2.data Mod0RCU3.data Mod1RCU0.data Mod1RCU1.data Mod1RCU2.data Mod1RCU3.data Mod2RCU0.data Mod2RCU1.data Mod2RCU2.data Mod2RCU3.data Mod3RCU0.data Mod3RCU1.data Mod3RCU2.data Mod3RCU3.data Mod4RCU0.data Mod4RCU1.data Mod4RCU2.data Mod4RCU3.data
8 Output files: PHOS_PED.root
24 #include <TPluginManager.h>
31 #include "AliRawReader.h"
32 #include "AliRawReaderDate.h"
33 #include "AliCaloAltroMapping.h"
34 #include "AliCaloRawStreamV3.h"
37 int main(int argc, char **argv)
39 // Read raw data, decode it to samples,
40 // calculate pedestals from presamples,
41 // evaluate the signal amplitude as a maximum sample,
42 // and fill histograms with pedestals and amplitudes
44 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
50 AliLog::SetGlobalDebugLevel(0) ;
51 AliLog::SetGlobalLogLevel(AliLog::kFatal);
56 printf("Wrong number of arguments\n");
60 /* Retrieve mapping files from DAQ DB */
61 const char* mapFiles[20] = {
84 for(Int_t iFile=0; iFile<20; iFile++) {
85 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
87 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
92 /* Open mapping files */
93 AliAltroMapping *mapping[20];
101 for(Int_t iMod = 0; iMod < 5; iMod++) {
106 for(Int_t iRCU=0; iRCU<4; iRCU++) {
110 mapping[iMap] = new AliCaloAltroMapping(path3.Data());
115 /* define data source : this is argument 1 */
116 status=monitorSetDataSource( argv[1] );
118 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
122 /* declare monitoring program */
123 status=monitorDeclareMp( __FILE__ );
125 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
129 /* define wait event timeout - 1s max */
131 monitorSetNoWaitNetworkTimeout(1000);
133 /* init some counters */
134 int nevents_physics=0;
137 AliRawReader * reader = NULL;
138 AliCaloRawStreamV3* stream = NULL;
140 TString baseNamePed ="hPed";
141 TString baseTitlePed="Ped in cell (";
142 const char* sgain[3]={"LG","HG", "TRU"};
144 const Int_t caloFlagMax=3,modMax=5,cellXMax=64,cellZMax=56;
145 TH1F *hPed[5][3][64][56] = {};
147 TH1F *hPedHiMean1m2 = new TH1F("hPedHiMean1m2","Mean pedestals in module 2, high gain" ,100,0.,100.);
148 TH1F *hPedHiRMS1m2 = new TH1F("hPedHiRMS1m2" ,"RMS pedestals in module 2, high gain" ,100,0.,50.);
149 TH1F *hPedLoMean1m2 = new TH1F("hPedLoMean1m2","Mean pedestals in module 2, low gain" ,100,0.,100.);
150 TH1F *hPedLoRMS1m2 = new TH1F("hPedLoRMS1m2" ,"RMS pedestals in module 2, low gain" ,100,0.,50.);
151 TH1F *hPedTRUMean1m2 = new TH1F("hPedTRUMean1m2","Mean pedestals in module 2, TRU" ,1000,0.,1000.);
152 TH1F *hPedTRURMS1m2 = new TH1F("hPedTRURMS1m2" ,"RMS pedestals in module 2, TRU" ,100,0.,50.);
154 TH1F *hPedHiMean1m3 = new TH1F("hPedHiMean1m3","Mean pedestals in module 3, high gain" ,100,0.,100.);
155 TH1F *hPedHiRMS1m3 = new TH1F("hPedHiRMS1m3" ,"RMS pedestals in module 3, high gain" ,100,0.,50.);
156 TH1F *hPedLoMean1m3 = new TH1F("hPedLoMean1m3","Mean pedestals in module 3, low gain" ,100,0.,100.);
157 TH1F *hPedLoRMS1m3 = new TH1F("hPedLoRMS1m3" ,"RMS pedestals in module 3, low gain" ,100,0.,50.);
158 TH1F *hPedTRUMean1m3 = new TH1F("hPedTRUMean1m3","Mean pedestals in module 3, TRU" ,1000,0.,1000.);
159 TH1F *hPedTRURMS1m3 = new TH1F("hPedTRURMS1m3" ,"RMS pedestals in module 3, TRU" ,100,0.,50.);
161 TH1F *hPedHiMean1m4 = new TH1F("hPedHiMean1m4","Mean pedestals in module 4, high gain" ,100,0.,100.);
162 TH1F *hPedHiRMS1m4 = new TH1F("hPedHiRMS1m4" ,"RMS pedestals in module 4, high gain" ,100,0.,50.);
163 TH1F *hPedLoMean1m4 = new TH1F("hPedLoMean1m4","Mean pedestals in module 4, low gain" ,100,0.,100.);
164 TH1F *hPedLoRMS1m4 = new TH1F("hPedLoRMS1m4" ,"RMS pedestals in module 4, low gain" ,100,0.,50.);
165 TH1F *hPedTRUMean1m4 = new TH1F("hPedTRUMean1m4","Mean pedestals in module 4, TRU" ,1000,0.,1000.);
166 TH1F *hPedTRURMS1m4 = new TH1F("hPedTRURMS1m4" ,"RMS pedestals in module 4, TRU" ,100,0.,50.);
168 hPedHiMean1m2->Sumw2();
169 hPedHiRMS1m2 ->Sumw2();
170 hPedLoMean1m2->Sumw2();
171 hPedLoRMS1m2 ->Sumw2();
172 hPedTRUMean1m2->Sumw2();
173 hPedTRURMS1m2 ->Sumw2();
174 hPedHiMean1m3->Sumw2();
175 hPedHiRMS1m3 ->Sumw2();
176 hPedLoMean1m3->Sumw2();
177 hPedLoRMS1m3 ->Sumw2();
178 hPedTRUMean1m3->Sumw2();
179 hPedTRURMS1m3 ->Sumw2();
180 hPedHiMean1m4->Sumw2();
181 hPedHiRMS1m4 ->Sumw2();
182 hPedLoMean1m4->Sumw2();
183 hPedLoRMS1m4 ->Sumw2();
184 hPedTRUMean1m4->Sumw2();
185 hPedTRURMS1m4 ->Sumw2();
187 TH2F *hPedHiMeanm2 = new TH2F("hPedHiMeanm2","Mean pedestals in module 2, high gain",
188 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
189 TH2F *hPedHiRMSm2 = new TH2F("hPedHiRMSm2" ,"R.M.S. of pedestals in module 2, high gain",
190 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
191 TH2F *hPedHiNumm2 = new TH2F("hPedHiNumm2" ,"Number of pedestals in module 2, high gain",
192 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
193 TH2F *hPedLoMeanm2 = new TH2F("hPedLoMeanm2","Mean pedestals in module 2, low gain",
194 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
195 TH2F *hPedLoRMSm2 = new TH2F("hPedLoRMSm2" ,"R.M.S. of pedestals in module 2, low gain",
196 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
197 TH2F *hPedLoNumm2 = new TH2F("hPedLoNumm2" ,"Number of pedestals in module 2, low gain",
198 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
200 TH2F *hPedHiMeanm3 = new TH2F("hPedHiMeanm3","Mean pedestals in module 3, high gain",
201 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
202 TH2F *hPedHiRMSm3 = new TH2F("hPedHiRMSm3" ,"R.M.S. of pedestals in module 3, high gain",
203 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
204 TH2F *hPedHiNumm3 = new TH2F("hPedHiNumm3" ,"Number of pedestals in module 3, high gain",
205 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
206 TH2F *hPedLoMeanm3 = new TH2F("hPedLoMeanm3","Mean pedestals in module 3, low gain",
207 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
208 TH2F *hPedLoRMSm3 = new TH2F("hPedLoRMSm3" ,"R.M.S. of pedestals in module 3, low gain",
209 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
210 TH2F *hPedLoNumm3 = new TH2F("hPedLoNumm3" ,"Number of pedestals in module 3, low gain",
211 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
213 TH2F *hPedHiMeanm4 = new TH2F("hPedHiMeanm4","Mean pedestals in module 4, high gain",
214 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
215 TH2F *hPedHiRMSm4 = new TH2F("hPedHiRMSm4" ,"R.M.S. of pedestals in module 4, high gain",
216 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
217 TH2F *hPedHiNumm4 = new TH2F("hPedHiNumm4" ,"Number of pedestals in module 4, high gain",
218 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
219 TH2F *hPedLoMeanm4 = new TH2F("hPedLoMeanm4","Mean pedestals in module 4, low gain",
220 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
221 TH2F *hPedLoRMSm4 = new TH2F("hPedLoRMSm4" ,"R.M.S. of pedestals in module 4, low gain",
222 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
223 TH2F *hPedLoNumm4 = new TH2F("hPedLoNumm4" ,"Number of pedestals in module 4, low gain",
224 cellXMax,0.,cellXMax, cellZMax,0.,cellZMax);
226 TH1I *hNBunches = new TH1I("hNBunches","Number of bunches",10,0,10);
227 TH2I *hHWaddr = new TH2I("hHWaddr","DDL is vs HW addr",216,0,216,4096,0,4096);
228 TH1I *hModule = new TH1I("hModule" ,"Module number", 5,0.,5);
231 Int_t module,cellX,cellZ,caloFlag;
233 /* main loop (infinite) */
235 struct eventHeaderStruct *event;
236 eventTypeType eventT;
238 /* check shutdown condition */
239 if (daqDA_checkShutdown()) {break;}
241 /* get next event (blocking call until timeout) */
242 status=monitorGetEventDynamic((void **)&event);
243 if (status==MON_ERR_EOF) {
244 printf ("End of File detected\n");
245 break; /* end of monitoring file has been reached */
249 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
253 /* retry if got no event */
258 /* use event - here, just write event id to result file */
259 eventT=event->eventType;
261 if (eventT==PHYSICS_EVENT) {
263 reader = new AliRawReaderDate((void*)event);
264 stream = new AliCaloRawStreamV3(reader,"PHOS",mapping);
266 runNum = reader->GetRunNumber();
267 while (stream->NextDDL()) {
268 while (stream->NextChannel()) {
269 module = stream->GetModule();
270 cellX = stream->GetCellX();
271 cellZ = stream->GetCellZ();
272 caloFlag = stream->GetCaloFlag();
273 if (caloFlag!=0 && caloFlag!=1) continue;
275 hHWaddr->Fill(stream->GetDDLNumber(),stream->GetHWAddress());
276 hModule->Fill(module);
277 if (!hPed[module][caloFlag][cellX][cellZ]) {
278 TString name = baseNamePed;
279 TString title = baseTitlePed;
280 name +="_g"; name +=caloFlag;
281 name +="_m"; name +=module;
282 name +="_x"; name +=cellX;
283 name +="_z"; name +=cellZ;
285 title +=module; title +=",";
286 title +=cellX; title +=",";
287 title +=cellZ; title +="), ";
288 title +=sgain[caloFlag];
290 hPed[module][caloFlag][cellX][cellZ] = new TH1F(name,title,100,0.,100.);
291 hPed[module][caloFlag][cellX][cellZ]->Sumw2();
292 hPed[module][caloFlag][cellX][cellZ]->SetMarkerStyle(20);
293 hPed[module][caloFlag][cellX][cellZ]->SetOption("eph");
297 while (stream->NextBunch()) {
299 const UShort_t *sig = stream->GetSignals();
300 Int_t sigLength = stream->GetBunchLength();
301 for (Int_t i = 0; i < sigLength; i++) {
302 hPed[module][caloFlag][cellX][cellZ]->Fill(sig[i]);
305 hNBunches->Fill(nBunches);
306 } // end of NextChannel()
307 } // end of NextDDL()
312 } // end of if(eventT==PHYSICS_EVENT)
319 /* exit when last event received, no need to wait for TERM signal */
320 if (eventT==END_OF_RUN) {
321 printf("EOR event detected\n");
325 } // end of inf. loop over events
327 for(Int_t i = 0; i < 20; i++) delete mapping[i];
329 // Fill 2-dim histograms for mean, rms and n pedestals
331 for (Int_t mod=2; mod<=4; mod++) {
332 for (Int_t caloFlag=0; caloFlag<2; caloFlag++) {
333 for (Int_t cellX=0; cellX<cellXMax; cellX++) {
334 for (Int_t cellZ=0; cellZ<cellZMax; cellZ++) {
335 if (hPed[mod][caloFlag][cellX][cellZ] != 0) {
338 hPedLoMean1m2->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
339 hPedLoRMS1m2 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
340 hPedLoMeanm2 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetMean());
341 hPedLoRMSm2 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
342 hPedLoNumm2 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetEntries());
345 hPedLoMean1m3->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
346 hPedLoRMS1m3 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
347 hPedLoMeanm3 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetMean());
348 hPedLoRMSm3 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
349 hPedLoNumm3 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetEntries());
352 hPedLoMean1m4->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
353 hPedLoRMS1m4 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
354 hPedLoMeanm4 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetMean());
355 hPedLoRMSm4 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
356 hPedLoNumm4 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetEntries());
359 else if (caloFlag == 1) {
361 hPedHiMean1m2->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
362 hPedHiRMS1m2 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS() );
363 hPedHiMeanm2 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetMean());
364 hPedHiRMSm2 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
365 hPedHiNumm2 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetEntries());
368 hPedHiMean1m3->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
369 hPedHiRMS1m3 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS() );
370 hPedHiMeanm3 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetMean());
371 hPedHiRMSm3 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
372 hPedHiNumm3 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetEntries());
375 hPedHiMean1m4->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
376 hPedHiRMS1m4 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
377 hPedHiMeanm4 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetMean());
378 hPedHiRMSm4 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetRMS());
379 hPedHiNumm4 ->Fill( cellX, cellZ, hPed[mod][caloFlag][cellX][cellZ]->GetEntries());
382 else if (caloFlag == 2) {
384 hPedTRUMean1m2->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
385 hPedTRURMS1m2 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS() );
388 hPedTRUMean1m3->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
389 hPedTRURMS1m3 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS() );
392 hPedTRUMean1m4->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetMean());
393 hPedTRURMS1m4 ->Fill( hPed[mod][caloFlag][cellX][cellZ]->GetRMS() );
402 // Write existing histograms to a root file
404 TString fileName = "PHOS_PED.root";
405 TFile *file = new TFile(fileName,"RECREATE");
407 for (Int_t mod=2; mod<=3; mod++) {
408 for (Int_t caloFlag=0; caloFlag<caloFlagMax; caloFlag++) {
409 for (Int_t mod=0; mod<modMax; mod++) {
410 for (Int_t cellX=0; cellX<cellXMax; cellX++) {
411 for (Int_t cellZ=0; cellZ<cellZMax; cellZ++) {
412 if (hPed[mod][caloFlag][cellX][cellZ] != 0)
413 hPed[mod][caloFlag][cellX][cellZ]->Write();
420 hPedHiMean1m2->Write();
421 hPedHiRMS1m2 ->Write();
422 hPedLoMean1m2->Write();
423 hPedLoRMS1m2 ->Write();
424 hPedHiMeanm2 ->Write();
425 hPedHiRMSm2 ->Write();
426 hPedHiNumm2 ->Write();
427 hPedLoMeanm2 ->Write();
428 hPedLoRMSm2 ->Write();
429 hPedLoNumm2 ->Write();
430 hPedTRUMean1m2->Write();
431 hPedTRURMS1m2 ->Write();
433 hPedHiMean1m3->Write();
434 hPedHiRMS1m3 ->Write();
435 hPedLoMean1m3->Write();
436 hPedLoRMS1m3 ->Write();
437 hPedHiMeanm3 ->Write();
438 hPedHiRMSm3 ->Write();
439 hPedHiNumm3 ->Write();
440 hPedLoMeanm3 ->Write();
441 hPedLoRMSm3 ->Write();
442 hPedLoNumm3 ->Write();
443 hPedTRUMean1m3->Write();
444 hPedTRURMS1m3 ->Write();
446 hPedHiMean1m4->Write();
447 hPedHiRMS1m4 ->Write();
448 hPedLoMean1m4->Write();
449 hPedLoRMS1m4 ->Write();
450 hPedHiMeanm4 ->Write();
451 hPedHiRMSm4 ->Write();
452 hPedHiNumm4 ->Write();
453 hPedLoMeanm4 ->Write();
454 hPedLoRMSm4 ->Write();
455 hPedLoNumm4 ->Write();
456 hPedTRUMean1m4->Write();
457 hPedTRURMS1m4 ->Write();
465 /* Store output files to the File Exchange Server */
466 daqDA_FES_storeFile(fileName.Data(),"PED");
468 printf("%d physics events of %d total processed.\n",nevents_physics,nevents_total);