]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/PMDPEDESTALda.cxx
AliTPCclustererKr.h -
[u/mrichter/AliRoot.git] / PMD / PMDPEDESTALda.cxx
CommitLineData
e43e472f 1/*
2PMD DA for online calibration
3
4contact: basanta@phy.iitb.ac.in
5Link:/afs/cern.ch/user/a/alicepmd/public/pedestaldata/run31270.raw
6Run Type: STANDALONE
7DA Type: MON
8Number of events needed: 1000
9Input Files: data raw
10Output Files: pmd_ped.root, to be exported to the DAQ FXS
11Trigger types used: PULSER
12
13*/
14extern "C" {
15#include <daqDA.h>
16}
17
18#include "event.h"
19#include "monitor.h"
20//#include "daqDA.h"
21
22#include <Riostream.h>
23#include <stdio.h>
24#include <stdlib.h>
25
26//AliRoot
27#include "AliRawReaderDate.h"
28#include "AliPMDCalibPedestal.h"
29
30//ROOT
31#include "TFile.h"
32#include "TH1F.h"
33#include "TBenchmark.h"
34#include "TTree.h"
35#include "TROOT.h"
36#include "TPluginManager.h"
37
38
39
40/* Main routine
41 Arguments:
42 1- monitoring data source
43*/
44int main(int argc, char **argv) {
45
46 /* magic line from Rene */
47 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
48 "*",
49 "TStreamerInfo",
50 "RIO",
51 "TStreamerInfo()");
52
53
54 AliPMDCalibPedestal calibped;
55
56 TTree *ped = new TTree("ped","PMD Pedestal tree");
57
58 TH1F::AddDirectory(0);
59
60
61 // decoding the events
62
63 int status;
64
65 if (argc!=2) {
66 printf("Wrong number of arguments\n");
67 return -1;
68 }
69
70
71
72 /* define data source : this is argument 1 */
73 status=monitorSetDataSource( argv[1] );
74 if (status!=0) {
75 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
76 return -1;
77 }
78
79 /* declare monitoring program */
80 status=monitorDeclareMp( __FILE__ );
81 if (status!=0) {
82 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
83 return -1;
84 }
85
86 /* define wait event timeout - 1s max */
87 monitorSetNowait();
88 monitorSetNoWaitNetworkTimeout(1000);
89
90 /* log start of process */
91 printf("DA example case2 monitoring program started\n");
92
93 /* init some counters */
94 int nevents_physics=0;
95 int nevents_total=0;
96
97 struct eventHeaderStruct *event;
98 eventTypeType eventT;
99 Int_t iev=0;
100
101 /* main loop (infinite) */
102 for(;;) {
103
104 /* check shutdown condition */
105 if (daqDA_checkShutdown()) {break;}
106
107 /* get next event (blocking call until timeout) */
108 status=monitorGetEventDynamic((void **)&event);
109 if (status==MON_ERR_EOF) {
110 printf ("End of File detected\n");
111 break; /* end of monitoring file has been reached */
112 }
113
114 if (status!=0) {
115 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
116 break;
117 }
118
119 /* retry if got no event */
120 if (event==NULL) {
121 continue;
122 }
123
124 iev++;
125
126 /* use event - here, just write event id to result file */
127 eventT=event->eventType;
128 switch (event->eventType){
129
130 /* START OF RUN */
131 case START_OF_RUN:
132 break;
133 /* END START OF RUN */
134
135 /* END OF RUN */
136 case END_OF_RUN:
137 break;
138
139 case PULSER:
140 printf(" event number = %i \n",iev);
141 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
142 calibped.ProcessEvent(rawReader);
143
144 delete rawReader;
145 rawReader = 0x0;
146 }
147
148 /* free resources */
149 free(event);
150
151 /* exit when last event received, no need to wait for TERM signal */
152 if (eventT==END_OF_RUN) {
153 printf("EOR event detected\n");
154 calibped.Analyse(ped);
155 break;
156 }
157 }
158
159
160 TFile * pedRun = new TFile ("pmd_ped.root","RECREATE");
161 ped->Write();
162 pedRun->Close();
163
164
165 /* close result file */
166 fclose(fp);
167
168
169 return status;
170}