CMake: Deleting wrong CMakeLists
[u/mrichter/AliRoot.git] / PHOS / DA / PHOSCPVPEDda.cxx
CommitLineData
0916ba78 1/*
2CPV PED DA for processing pedestal runs and producing pedestal tables for loading to CPV FEE.
3
4Contact: Sergey Evdokimov <sevdokim@cern.ch>
5Link: https://twiki.cern.ch/twiki/bin/view/ALICE/CPVda
6Reference run: 211758 (/afs/cern.ch/user/s/sevdokim/public/CPV_run211758_pedestal.raw)
7Run Type: PHYSICS
8DA Type: PED
9Number of events needed: 2000 events
10Input files: raw data file
11Output files: thr?_??.dat CpvPeds.root
12Trigger types used: PHYSICS_EVENT
13*/
bdffcb75 14//daqDA
0916ba78 15#include "event.h"
16#include "monitor.h"
17#include "daqDA.h"
bdffcb75 18//system
0916ba78 19#include <Riostream.h>
20#include <stdlib.h>
21#include <fstream>
22#include <string>
23
24//AliRoot
25#include "AliPHOSCpvRawStream.h"
26#include "AliPHOSCpvPedProducer.h"
27#include "AliPHOSCpvParam.h"
28#include "AliRawReaderDate.h"
29#include "AliBitPacking.h"
0916ba78 30
31//ROOT
32#include "TROOT.h"
33#include "TPluginManager.h"
34#include "TSAXParser.h"
35#include "TTree.h"
bdffcb75 36#include "TMath.h"
0916ba78 37#include "TString.h"
38#include "TFile.h"
39#include "TSystem.h"
40#include "TKey.h"
41#include "TH2S.h"
42#include "TH2F.h"
43#include "TObject.h"
44#include "TBenchmark.h"
45#include "TMath.h"
46#include "TRandom.h"
47
48
49int main( int argc, char **argv )
50{
51 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
52 "*",
53 "TStreamerInfo",
54 "RIO",
55 "TStreamerInfo()");
56 Int_t status,print;
57 Int_t sigcut=3;
58 Bool_t turbo = kTRUE;
59
60 if (argc!=2) {
61 printf("Wrong number of arguments\n");
62 return -1;
63 }
64
65 // log start of process
bdffcb75 66 printf("Cpv pedestal DA program started\n");
0916ba78 67
68 /* report progress */
69 daqDA_progressReport(0);
70
71 status=monitorSetDataSource( argv[1] );
72 if (status!=0) {
73 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
74 return -1;
75 }
76
77 /* declare monitoring program */
78 status=monitorDeclareMp( __FILE__ );
79 if (status!=0) {
80 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
81 return -1;
82 }
83
84 /* define wait event timeout - 1s max */
85 monitorSetNowait();
86 monitorSetNoWaitNetworkTimeout(1000);
87
88 /* report progress */
89 daqDA_progressReport(5);
90
91
92 // init event counter
93 Int_t iPhysEvnt=0;
94 Int_t iTotEvnt =0;
95
96 AliPHOSCpvPedProducer * pedProducer = new AliPHOSCpvPedProducer(sigcut);
97
98 // Reader
99 AliRawReader * reader;
100
101 /* report progress */
102 daqDA_progressReport(10);
103
104 /* main loop (infinite) */
105 for(;;) { // infinite loop
106 struct eventHeaderStruct *event;
107 eventTypeType eventT;
108
109 /* check shutdown condition */
110 if (daqDA_checkShutdown()) {break;}
111
112 // get next event
113 status=monitorGetEventDynamic((void **)&event);
114 if (status==MON_ERR_EOF) { // end of monitoring file has been reached
115 printf("End of monitoring file has been reached! \n");
116 break;
117 }
118
119 if (status!=0) {
120 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
121 break;
122 }
123
124 // retry if got no event
125 if (event==NULL) continue;
126
127 // use event - here, just write event id to result file
128 eventT=event->eventType;
129 if (eventT==PHYSICS_EVENT) { //we use PHYSICS_EVENT for pedestal not CALIBRATION_EVENT???
130 iTotEvnt++;
131 reader = new AliRawReaderDate((void*)event);
132 pedProducer->LoadNewEvent(reader);
133 if(pedProducer->FillPedestal()) iPhysEvnt++;
134 delete reader;
135 } // if PHYSICS_EVENT
136
137 free(event);
138
139 /* exit when last event received, no need to wait for TERM signal */
140 if (eventT==END_OF_RUN) {
141 printf("EOR event detected\n");
142 break;
143 }
144 }
145
146 Printf(" Received %d events, %d good events",iTotEvnt,iPhysEvnt);
147 /* report progress */
bdffcb75 148 daqDA_progressReport(95);
0916ba78 149
bdffcb75 150 for(int iDDL = 0; iDDL<2*AliPHOSCpvParam::kNDDL; iDDL++){
0916ba78 151 if(pedProducer -> CalcPedestal(iDDL)){
152 pedProducer -> WritePedFiles(iDDL);
bdffcb75 153 for (int iCC = 0; iCC<AliPHOSCpvParam::kNRows; iCC++){
154 status=daqDA_DB_storeFile(Form("thr%d_%02d.dat", iDDL, iCC),Form("thr%d_%02d.dat", iDDL, iCC));
155 if(status) printf("Failed to store thr%d_%02d.dat in DAQ DB!\n",iDDL, iCC);
156 //status=daqDA_FES_storeFile(Form("thr%d_%02d.dat", iDDL, iCC));
157 //if(status) printf("Failed to export thr%d_%02d.dat to DAQ FES!\n",iDDL, iCC);
158 }
0916ba78 159 }
160 }
161
162 pedProducer->WriteAllHistsToFile("CpvPeds.root");
163 status = daqDA_DB_storeFile("CpvPeds.root","CpvPeds.root");
164 if(status) printf("Failed to store CpvPeds.root in DAQ DB!\n");
bdffcb75 165 status = daqDA_FES_storeFile("CpvPeds.root","CpvPeds.root");
166 if(status) printf("Failed to store CpvPeds.root in DAQ FXS!\n");
0916ba78 167
168 /* report progress */
bdffcb75 169 daqDA_progressReport(100);
0916ba78 170
171
172 return status;
173}