]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/TRDVDRIFTda.cxx
Fix for memory leaks in digits TClonesArrays (Matevz)
[u/mrichter/AliRoot.git] / TRD / TRDVDRIFTda.cxx
CommitLineData
170c35f1 1/*
2
c5348551 3Contact: r.bailhache@gsi.de
27b46d95 4Link:
5Reference run: 25909
25781e34 6Run Type: PHYSICS STANDALONE
c5348551 7DA Type: MON
27b46d95 8Number of events needed: many
9Input Files: TRD raw files
10Output Files: trdCalibrationv.root
11Trigger types used: PHYSICS_EVENT
170c35f1 12
13*/
14
5f518e55 15#define RESULT_FILE "trdVdrift.root"
16#define FILE_ID "VDRIFT"
6ace5fe2 17
18
170c35f1 19extern "C" {
20#include <daqDA.h>
21}
22
23#include "event.h"
24#include "monitor.h"
25#include <stdio.h>
26#include <stdlib.h>
27
28
29//
30//Root includes
31//
32#include <TObjArray.h>
33#include <TString.h>
34#include <TVectorF.h>
170c35f1 35#include <TDirectory.h>
36#include <TSystem.h>
37#include <TFile.h>
25781e34 38#include "TROOT.h"
39#include "TPluginManager.h"
170c35f1 40//
41//AliRoot includes
42//
43#include "AliRawReader.h"
44#include "AliRawReaderDate.h"
987ba9a3 45#include "AliTRDrawStream.h"
5ac2a9f9 46#include "AliTRDrawStreamBase.h"
27b46d95 47
170c35f1 48
49//
50// TRD calibration algorithm includes
51//
170c35f1 52#include "AliTRDCalibraFillHisto.h"
53
54
55
56
57/* Main routine
58 Arguments:
59 1- monitoring data source
60*/
61int main(int argc, char **argv) {
62
25781e34 63 /* magic line from Rene */
64 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
65 "*",
66 "TStreamerInfo",
67 "RIO",
68 "TStreamerInfo()");
170c35f1 69 int status;
70
71 if (argc!=2) {
72 printf("Wrong number of arguments\n");
73 return -1;
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
98 /* log start of process */
6ace5fe2 99 printf("TRD DA VDRIFT started\n");
170c35f1 100
101
102 /* init some counters */
6bbdc11a 103 int neventsphysics=0;
104 int neventstotal=0;
170c35f1 105
f3667dfd 106 //Instance of AliCDBManager: needed by AliTRDrawStream
27b46d95 107 //AliCDBManager *man = AliCDBManager::Instance();
162637e4 108 //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
27b46d95 109 //man->SetRun(0);
170c35f1 110 //Instance of AliTRDCalibraFillHisto
111 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
170c35f1 112 // everythings are okey for vdrift
3a0f6479 113 Bool_t passvdrift = kTRUE; // if timebin okey
114 Int_t nbvdrift = 0; // number of events with entries for vdrift
170c35f1 115
162a3e73 116 // setting
987ba9a3 117 // AliTRDrawStream::SetNoDebug();
0ca1720e 118 AliTRDrawStream::DisableSkipData();
987ba9a3 119 AliTRDrawStream::SetNoErrorWarning();
0ca1720e 120 //AliTRDrawStream::SetSubtractBaseline(0);
987ba9a3 121 //AliTRDrawStream::SetForceCleanDataOnly();
0ca1720e 122 //AliTRDrawStream::AllowCorruptedData();
123 //AliTRDrawStream::DisableStackNumberChecker();
124 //AliTRDrawStream::DisableStackLinkNumberChecker();
987ba9a3 125 //AliTRDrawStream::SetSkipCDH();
126 //AliTRDrawStream::SetExtraWordsFix();
127 //AliTRDrawStream::EnableDebugStream();
128 //AliTRDrawStream::SetDumpHead(320);
129 //AliTRDrawStream::SetDumpHead(80);
f222df8d 130
170c35f1 131
132 /* main loop (infinite) */
133 for(;;) {
134 //for(Int_t k = 0; k < 20; k++) {
135 struct eventHeaderStruct *event;
136 eventTypeType eventT;
6ace5fe2 137
170c35f1 138 /* check shutdown condition */
139 if (daqDA_checkShutdown()) {break;}
140
141 /* get next event (blocking call until timeout) */
142 status=monitorGetEventDynamic((void **)&event);
143 if (status==MON_ERR_EOF) {
144 printf ("End of File detected\n");
145 break; /* end of monitoring file has been reached */
146 }
147
148 if (status!=0) {
149 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
150 break;
151 }
152
153 /* retry if got no event */
154 if (event==NULL) {
155 continue;
156 }
157
6bbdc11a 158 if( ((Int_t)neventstotal)%1000 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) neventstotal,(Int_t) neventsphysics);
170c35f1 159
160
161 /* use event - here, just write event id to result file */
162 eventT=event->eventType;
6ace5fe2 163
170c35f1 164 //
165 // vdrift calibration: run only for physics events
166 //
6ace5fe2 167 if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
170c35f1 168 //if (eventT==PHYSICS_EVENT) {
170c35f1 169 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
5ac2a9f9 170 rawReader->Select("TRD");
987ba9a3 171 AliTRDrawStream *trdRawStream = new AliTRDrawStream((AliRawReader *) rawReader);
8799e123 172 Int_t result = calibra->ProcessEventDAQ((AliTRDrawStreamBase *) trdRawStream,(Bool_t)nbvdrift);
3a0f6479 173 if(!result) passvdrift = kFALSE;
174 else nbvdrift += (Int_t) result/2;
5750af0a 175
170c35f1 176 delete trdRawStream;
177 delete rawReader;
5ac2a9f9 178
170c35f1 179 }
180
5750af0a 181 if(eventT==PHYSICS_EVENT){
182
6bbdc11a 183 neventsphysics++;
5750af0a 184
185 }
170c35f1 186
6bbdc11a 187 neventstotal++;
170c35f1 188
189
190 /* free resources */
191 free(event);
192
193 /* exit when last event received, no need to wait for TERM signal */
194 if (eventT==END_OF_RUN) {
195 printf("EOR event detected\n");
196 break;
197 }
198 }
199
6ace5fe2 200
201 /* report progress */
6bbdc11a 202 printf("%d events processed and %d used\n",neventstotal,nbvdrift);
6ace5fe2 203
170c35f1 204 //
205 // Write a local file and put it on the FX
206 //
6ace5fe2 207 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
208
3a0f6479 209 if((nbvdrift > 0) && passvdrift){
6ace5fe2 210 //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
211 //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
212 // write the histogram in any case to see if problems
213 calibra->GetPH2d()->Write();
214 //}
170c35f1 215 }
216 fileTRD->Close();
217 status=0;
6ace5fe2 218 // Export the file in any case to see if problems
5f518e55 219 if(daqDA_FES_storeFile(RESULT_FILE,FILE_ID)) status = -2;
6ace5fe2 220
170c35f1 221 delete fileTRD;
222
223 return status;
1ac4bb35 224}
0ca1720e 225