4 TPCda.cxx - calibration algorithm to be run on GDC
7 AliTPCCalibPulser - pulser signal calibration
8 AliTPCCalibPedestal - pedestal and noise calibration
9 AliTPCCalibCE - CE time and amplitude calibration
12 contact: marian.ivanov@cern.ch
15 This program connects to the DAQ data source passed as argument
16 and populates local "./result.txt" file with the ids of events received
19 The program exits when being asked to shut down (daqDA_checkshutdown)
22 Messages on stdout are exported to DAQ log system.
24 contact: alice-datesupport@cern.ch
41 #include <TObjArray.h>
53 #include <TDirectory.h>
59 #include "AliRawReader.h"
60 #include "AliRawReaderDate.h"
61 #include "AliTPCRawStream.h"
62 #include "AliTPCROC.h"
63 #include "AliTPCCalROC.h"
64 #include "AliTPCCalPad.h"
65 #include "AliMathBase.h"
66 #include "TTreeStream.h"
68 // TPC calibration algorithm includes
70 #include "AliTPCCalibPedestal.h"
71 #include "AliTPCCalibPulser.h"
78 1- monitoring data source
80 int main(int argc, char **argv) {
83 AliTPCCalibPulser calibSignal; // pulser calibration
84 AliTPCCalibPedestal calibPedestal; // pedestal and nosie calibration
87 printf("Wrong number of arguments\n");
92 /* open result file */
94 fp=fopen("./result.txt","a");
96 printf("Failed to open file\n");
101 /* define data source : this is argument 1 */
102 status=monitorSetDataSource( argv[1] );
104 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
109 /* declare monitoring program */
110 status=monitorDeclareMp( __FILE__ );
112 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
117 /* define wait event timeout - 1s max */
119 monitorSetNoWaitNetworkTimeout(1000);
122 /* log start of process */
123 printf("DA example case2 monitoring program started\n");
126 /* init some counters */
127 int nevents_physics=0;
131 /* main loop (infinite) */
133 struct eventHeaderStruct *event;
134 eventTypeType eventT;
136 /* check shutdown condition */
137 if (daqDA_checkShutdown()) {break;}
139 /* get next event (blocking call until timeout) */
140 status=monitorGetEventDynamic((void **)&event);
141 if (status==MON_ERR_EOF) {
142 printf ("End of File detected\n");
143 break; /* end of monitoring file has been reached */
147 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
151 /* retry if got no event */
157 /* use event - here, just write event id to result file */
158 eventT=event->eventType;
160 // PULSER calibration
162 // if (eventT==PULSER_EVENT){ // i don't know the ID
164 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
165 calibSignal.ProcessEvent(rawReader);
170 // Pedestal calibration calibration
172 // if (eventT==BLACK_EVENT){ // i don't know the ID
174 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
175 calibPedestal.ProcessEvent(rawReader);
181 if (eventT==PHYSICS_EVENT) {
182 fprintf(fp,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n",
183 (unsigned long)event->eventRunNb,
184 (unsigned long)event->eventSize,
185 EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
186 EVENT_ID_GET_ORBIT(event->eventId),
187 EVENT_ID_GET_PERIOD(event->eventId)
197 /* exit when last event received, no need to wait for TERM signal */
198 if (eventT==END_OF_RUN) {
199 printf("EOR event detected\n");
200 calibPedestal.Analyse();
201 calibSignal.Analyse();
206 TFile * fileTPC = new TFile ("tpcCalibration.root","recreate");
207 calibPedestal.Write("calibPedestal");
208 calibSignal.Write("calibSignal");
213 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
215 /* close result file */