]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/EMCALda.cxx
AnalysisTask base class for multi event analysis (mixing).
[u/mrichter/AliRoot.git] / EMCAL / EMCALda.cxx
CommitLineData
3b5beac9 1/*
2 EMCAL DA for online calibration
3
4 Contact: silvermy@ornl.gov
5 Run Type: PEDESTAL_RUN or PULSER_RUN
6 DA Type: LDC
7 Number of events needed: ~100
8 Input Files: argument list
9 Output Files: RESULT_FILE=EMCALda1.root, to be exported to the DAQ FXS
10 fileId: FILE_ID=EMCALda1
11 Trigger types used: CALIBRATION_EVENT (temporarily also PHYSICS_EVENT to start with)
12
13*/
14/*
15 This process reads RAW data from the files provided as command line arguments
16 and save results in a file (named from RESULT_FILE define - see below).
17*/
18
19#define RESULT_FILE "EMCALda.root"
20#define FILE_ID "EMCALda"
21#define AliDebugLevel() -1
22
23extern "C" {
24#include <daqDA.h>
25}
26#include "event.h"
27#include "monitor.h"
28
29#include "stdio.h"
30#include "stdlib.h"
31
32//
33//AliRoot includes
34//
35#include "AliRawReader.h"
36#include "AliRawReaderDate.h"
37#include "AliRawEventHeaderBase.h"
38#include "AliCaloRawStream.h"
39#include "AliLog.h"
40
41//
42// EMC calibration-helper algorithm includes
43//
44#include "AliCaloCalibPedestal.h"
45
46/*
47 Main routine, EMC pedestal detector algorithm to be run on EMC LDC
48 Arguments: list of DATE raw data files
49*/
50
51int main(int argc, char **argv) {
52
53 AliLog::SetClassDebugLevel("AliCaloRawStream",-5);
54 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
55 AliLog::SetModuleDebugLevel("RAW",-5);
56
57 if (argc<2) {
58 printf("Wrong number of arguments\n");
59 return -1;
60 }
61
62 int i, status;
63
64 /* log start of process */
65 printf("EMCAL DA started - %s\n",__FILE__);
66
67 /* declare monitoring program */
68 status=monitorDeclareMp( __FILE__ );
69 if (status!=0) {
70 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
71 return -1;
72 }
73
74 AliCaloCalibPedestal * calibPedestal = new
75 AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal); // pedestal and noise calibration
76
77 /* loop over RAW data files */
78 int nevents=0;
79 for ( i=1; i<argc; i++ ) {
80
81 /* define data source : this is argument i */
82 printf("Processing file %s\n", argv[i]);
83
84 AliRawReader *rawReader = new AliRawReaderDate(argv[i]);
85 AliCaloRawStream *in = new AliCaloRawStream(rawReader,"EMCAL");
3b5beac9 86 AliRawEventHeaderBase *aliHeader=NULL;
87
88 /* read until EOF */
89 while ( rawReader->NextEvent() ) {
90
91 /* check shutdown condition */
92 if (daqDA_checkShutdown()) {break;}
93
94 aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader();
95 calibPedestal->SetRunNumber( aliHeader->Get("RunNb") ); // just for fun; keep info on last run looked at
96
97 // select physics and calibration events now (only calibration in future)
98 if ( aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent ||
99 aliHeader->Get("Type") == AliRawEventHeaderBase::kCalibrationEvent ) {
100
101 nevents++;
102
103 // Pedestal calibration
104 calibPedestal->ProcessEvent(in);
105 }
106 } // loop over all events in file
107 /* cleanup the reading handles */
108 delete in;
109 delete rawReader;
110 } // loop over files
111
112 //
113 // write results/histograms to rootfile
114 //
115
116 printf ("%d physics/calibration events processed.\n",nevents);
117 calibPedestal->SaveHistograms(RESULT_FILE);
118 printf("Wrote %s.\n",RESULT_FILE);
119
120 /* store the result file on FES */
121 status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);
122
123 // see if we can delete our analysis helper also
124 delete calibPedestal;
125
126 return status;
127}