]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/EMCALda.cxx
a new line
[u/mrichter/AliRoot.git] / EMCAL / EMCALda.cxx
1 /*
2   EMCAL DA for online calibration
3   
4   Contact: silvermy@ornl.gov
5   Run Type: PEDESTAL or PHYSICS or STANDALONE
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 (class itself) 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 #define ClassName "emcCalibPedestal"
23
24 extern "C" {
25 #include <daqDA.h>
26 }
27 #include "event.h"
28 #include "monitor.h"
29
30 #include "stdio.h"
31 #include "stdlib.h"
32
33 //
34 //AliRoot includes
35 //
36 #include "AliRawReader.h"
37 #include "AliRawReaderDate.h"
38 #include "AliRawEventHeaderBase.h"
39 #include "AliCaloRawStream.h"
40 #include "AliLog.h"
41
42 //
43 // EMC calibration-helper algorithm includes
44 //
45 #include "AliCaloCalibPedestal.h"
46
47 /*
48   Main routine, EMC pedestal detector algorithm to be run on EMC LDC
49   Arguments: list of DATE raw data files
50 */
51
52 int main(int argc, char **argv) {
53
54   AliLog::SetClassDebugLevel("AliCaloRawStream",-5);
55   AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
56   AliLog::SetModuleDebugLevel("RAW",-5);
57
58   if (argc<2) {
59     printf("Wrong number of arguments\n");
60     return -1;
61   }
62
63   int i, status;
64
65   /* log start of process */
66   printf("EMCAL DA started - %s\n",__FILE__);
67
68   /* declare monitoring program */
69   status=monitorDeclareMp( __FILE__ );
70   if (status!=0) {
71     printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
72     return -1;
73   }
74
75   AliCaloCalibPedestal * calibPedestal = new 
76     AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal); // pedestal and noise calibration
77
78   /* loop over RAW data files */
79   int nevents=0;
80   for ( i=1; i<argc; i++ ) {
81
82     /* define data source : this is argument i */
83     printf("Processing file %s\n", argv[i]);
84
85     AliRawReader *rawReader = new AliRawReaderDate(argv[i]);
86     AliCaloRawStream *in = new AliCaloRawStream(rawReader,"EMCAL");
87     AliRawEventHeaderBase *aliHeader=NULL;
88
89     /* read until EOF */
90     while ( rawReader->NextEvent() ) {
91
92       /* check shutdown condition */
93       if (daqDA_checkShutdown()) {break;}
94
95       aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader();
96       calibPedestal->SetRunNumber( aliHeader->Get("RunNb") ); // just for fun; keep info on last run looked at
97
98       // select physics and calibration events now (only calibration in future)
99       if ( aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent || 
100            aliHeader->Get("Type") == AliRawEventHeaderBase::kCalibrationEvent  ) {
101
102         nevents++;
103
104         //  Pedestal calibration
105         calibPedestal->ProcessEvent(in);
106       }
107     } // loop over all events in file
108     /* cleanup the reading handles */
109     delete in;
110     delete rawReader;    
111   } // loop over files
112
113   //
114   // write class to rootfile
115   //
116
117   printf ("%d physics/calibration events processed.\n",nevents);
118
119   TFile f(RESULT_FILE, "recreate");
120   if (!f.IsZombie()) { 
121     f.cd();
122     calibPedestal->Write(ClassName);
123     f.Close();
124     printf("Object saved to file \"%s\" as \"%s\".\n", RESULT_FILE, ClassName); 
125   } 
126   else {
127     printf("Could not save the object to file \"%s\".\n", RESULT_FILE);
128   }
129
130   /* store the result file on FES */
131   status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);
132
133   // see if we can delete our analysis helper also
134   delete calibPedestal;
135
136   return status;
137 }