]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/PHOSGAINda.cxx
adding phi, etaphi plots
[u/mrichter/AliRoot.git] / PHOS / PHOSGAINda.cxx
CommitLineData
62adef6c 1/*
2contact: Boris.Polishchuk@cern.ch
3link: see comments in the $ALICE_ROOT/PHOS/AliPHOSRcuDA1.cxx
4reference run: /castor/cern.ch/alice/phos/2007/10/04/18/07000008249001.1000.root
5run type: PHYSICS, STANDALONE
6DA type: MON
7number of events needed: 1000
8input files: RCU0.data RCU1.data RCU2.data RCU3.data
9Output files: PHOS_Module2_Calib.root
10trigger types used: L0
11*/
12
13
14#include "event.h"
15#include "monitor.h"
16extern "C" {
17#include "daqDA.h"
18}
19
20#include <stdio.h>
21#include <stdlib.h>
22
23#include <TSystem.h>
c59c9912 24#include <TROOT.h>
25#include <TPluginManager.h>
62adef6c 26
27#include "AliRawReader.h"
28#include "AliRawReaderDate.h"
29#include "AliPHOSRcuDA1.h"
30#include "AliPHOSRawDecoder.h"
31#include "AliCaloAltroMapping.h"
32
33
34/* Main routine
35 Arguments:
36 1- monitoring data source
37*/
38int main(int argc, char **argv) {
39
c59c9912 40 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
41 "*",
42 "TStreamerInfo",
43 "RIO",
44 "TStreamerInfo()");
45
62adef6c 46 int status;
47
48 if (argc!=2) {
49 printf("Wrong number of arguments\n");
50 return -1;
51 }
c59c9912 52
53 /* Retrieve mapping files from DAQ DB */
54 const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
55
56 for(Int_t iFile=0; iFile<4; iFile++) {
57 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
58 if(failed) {
59 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
60 return -1;
61 }
62 }
62adef6c 63
64 /* Open mapping files */
65 AliAltroMapping *mapping[4];
66 TString path = "./";
67 path += "RCU";
68 TString path2;
69 for(Int_t i = 0; i < 4; i++) {
70 path2 = path;
71 path2 += i;
72 path2 += ".data";
73 mapping[i] = new AliCaloAltroMapping(path2.Data());
74 }
75
76
77 /* define data source : this is argument 1 */
78 status=monitorSetDataSource( argv[1] );
79 if (status!=0) {
80 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
81 return -1;
82 }
83
84
85 /* declare monitoring program */
86 status=monitorDeclareMp( __FILE__ );
87 if (status!=0) {
88 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
89 return -1;
90 }
91
92
93 /* define wait event timeout - 1s max */
94 monitorSetNowait();
95 monitorSetNoWaitNetworkTimeout(1000);
96
97 /* init some counters */
98 int nevents_physics=0;
99 int nevents_total=0;
100
101 AliRawReader *rawReader = NULL;
102
103 AliPHOSRcuDA1 da1(2,-1); // DA1 (Calibration DA) for module2
104
105 Float_t e[64][56][2];
106 Float_t t[64][56][2];
107
108 Int_t gain = -1;
109 Int_t X = -1;
110 Int_t Z = -1;
111
112 /* main loop (infinite) */
113 for(;;) {
114 struct eventHeaderStruct *event;
115 eventTypeType eventT;
116
117 /* check shutdown condition */
118 if (daqDA_checkShutdown()) {break;}
119
120 /* get next event (blocking call until timeout) */
121 status=monitorGetEventDynamic((void **)&event);
122 if (status==MON_ERR_EOF) {
123 printf ("End of File detected\n");
124 break; /* end of monitoring file has been reached */
125 }
126
127 if (status!=0) {
128 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
129 break;
130 }
131
132 /* retry if got no event */
133 if (event==NULL) {
134 continue;
135 }
136
137
138 /* use event - here, just write event id to result file */
139 eventT=event->eventType;
140
141 if (eventT==PHYSICS_EVENT) {
142
143 for(Int_t iX=0; iX<64; iX++) {
144 for(Int_t iZ=0; iZ<56; iZ++) {
145 for(Int_t iGain=0; iGain<2; iGain++) {
146 e[iX][iZ][iGain] = 0.;
147 t[iX][iZ][iGain] = 0.;
148 }
149 }
150 }
151
152 rawReader = new AliRawReaderDate((void*)event);
153// AliPHOSRawDecoderv1 dc(rawReader,mapping);
154 AliPHOSRawDecoder dc(rawReader,mapping);
155 dc.SubtractPedestals(kTRUE);
156
157 while(dc.NextDigit()) {
158
159 X = dc.GetRow() - 1;
160 Z = dc.GetColumn() - 1;
161
162 if(dc.IsLowGain()) gain = 0;
163 else
164 gain = 1;
165
166 e[X][Z][gain] = dc.GetEnergy();
167 t[X][Z][gain] = dc.GetTime();
168
169 }
170
171 da1.FillHistograms(e,t);
172 //da1.UpdateHistoFile();
173
174 delete rawReader;
175 nevents_physics++;
176 }
177
178 nevents_total++;
179
180 /* free resources */
181 free(event);
182
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");
186 break;
187 }
188 }
189
190 for(Int_t i = 0; i < 4; i++) delete mapping[i];
191
c59c9912 192 /* Be sure that all histograms are saved */
193
194 da1.UpdateHistoFile();
195 da1.SetWriteToFile(kFALSE);
196
197 /* Store output files to the File Exchange Server */
198 char localfile[128];
f827931e 199 char fesfileid[128];
c59c9912 200
201 for(Int_t iMod=0; iMod<5; iMod++) {
202 sprintf(localfile,"PHOS_Module%d_Calib.root",iMod);
f827931e 203 sprintf(fesfileid,"PHOS_Module%d_AMPLITUDES",iMod);
204 daqDA_FES_storeFile(localfile,fesfileid);
c59c9912 205 }
206
62adef6c 207 return status;
208}