2 Contact: cvetan.cheshkov@cern.ch
3 Link: http://alisoft.cern.ch/viewvc/trunk/ITS/ITSSPDVertexDiamondda.cxx?root=AliRoot&view=log , /afs/cern.ch/user/c/cheshkov/public/ITS/VD_da_test.date , /afs/cern.ch/user/c/cheshkov/public/08000058338016.30.root.date.gz
7 Number of events needed: 100
8 Input Files: GRP/Geometry/Data , ITS/Align/Data , spd_noisy_ocdb , spd_dead_ocdb , TRIGGER/SPD/PITConditions (all the files are taken from SPD daqDetDB)
9 Output Files: SPDVertexDiamondDA.root
10 Trigger types used: PHYSICS, SPD-F0
13 #define OUTPUT_FILE "SPDVertexDiamondDA.root"
26 //int amore::da::Updated(char const*) {}
29 #include <TPluginManager.h>
33 #include <TPaveText.h>
35 #include <TGeoGlobalMagField.h>
36 #include <TTimeStamp.h>
40 #include "AliRawReaderDate.h"
41 #include "AliCDBManager.h"
42 #include "AliITSMeanVertexer.h"
45 int main(int argc, char **argv) {
47 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
55 printf("Wrong number of arguments\n");
58 // get mean vertex quality cuts
59 status = daqDA_DB_getFile("ITSSPD_VertexQualityTuning_DA.config","./ITSSPD_VertexQualityTuning_DA.config");
61 printf("Failed to get config file (ITSSPD_VertexQualityTuning_DA.config) from DAQ DB, status=%d\n", status);
64 /* open the config file and retrieve running parameters */
67 UInt_t minClInner = 999 ;
68 UInt_t maxClInner = 999 ;
69 Int_t nEvFirstLoop = 0;
70 Int_t nEvAUTOSAVE = 0;
71 Int_t zFiducialRegion=0;
72 Int_t timeWindowExport=0;
73 Int_t timeErrWindowExport=0;
78 FILE *fpConfig = fopen("ITSSPD_VertexQualityTuning_DA.config","r");
79 fscanf(fpConfig,"%s %f\n %s %f\n %s %d\n %s %d \n %s %d \n %s %d \n %s %d \n %s %d \n %s %d",&name[0], &errX, &name[1], &r, &name[2], &minClInner,&name[3], &maxClInner, &name[4],&nEvFirstLoop,&name[5],&nEvAUTOSAVE,&name[6],&zFiducialRegion, &name[7], &timeWindowExport, &name[8], &timeErrWindowExport);
83 printf("\n\n Mean Vertex quality cuts : \n- errX = %f\n- r = %f\n- minSPD0 = %d maxSPD0 = %d\n- nEventsFirstLoop = %d nEventsAUTOSAVE = %d \n- zFiducialRegion = %d\n- timeWindowExport = %d \n- timeErrWindowExport = %d \n\n\n",errX,r,minClInner,maxClInner,nEvFirstLoop,nEvAUTOSAVE,zFiducialRegion, timeWindowExport, timeErrWindowExport);
85 /* define data source : this is argument 1 */
86 status=monitorSetDataSource( argv[1] );
88 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
92 /* declare monitoring program */
93 status=monitorDeclareMp( __FILE__ );
95 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
99 /* define wait event timeout - 1s max */
101 monitorSetNoWaitNetworkTimeout(1000);
103 /* log start of process */
104 printf("Vertex-Diamond SPD DA started\n");
106 /* init some counters */
107 int nevents_with_vertex = 0;
108 int nevents_physics=0;
111 struct eventHeaderStruct *event;
112 eventTypeType eventT;
115 if (getenv("DATE_RUN_NUMBER")==0) {
116 printf("DATE_RUN_NUMBER not properly set.\n");
119 int runNr = atoi(getenv("DATE_RUN_NUMBER"));
121 // Get the necessary OCDB files from the DAQ detector DB
122 if (gSystem->AccessPathName("localOCDB/GRP/Geometry/Data",kFileExists)) {
123 if (gSystem->mkdir("localOCDB/GRP/Geometry/Data",kTRUE) != 0) {
124 printf("Failed to create directory: localOCDB/GRP/Geometry/Data");
128 status = daqDA_DB_getFile("GRP/Geometry/Data","localOCDB/GRP/Geometry/Data/Run0_999999999_v0_s0.root");
130 printf("Failed to get geometry file (GRP/Geometry/Data) from DAQdetDB, status=%d\n", status);
134 if (gSystem->AccessPathName("localOCDB/ITS/Align/Data",kFileExists)) {
135 if (gSystem->mkdir("localOCDB/ITS/Align/Data",kTRUE) != 0) {
136 printf("Failed to create directory: localOCDB/ITS/Align/Data");
140 status = daqDA_DB_getFile("ITS/Align/Data","localOCDB/ITS/Align/Data/Run0_999999999_v0_s0.root");
142 printf("Failed to get its-alignment file (ITS/Align/Data) from DAQdetDB, status=%d\n", status);
146 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDNoisy",kFileExists)) {
147 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDNoisy",kTRUE) != 0) {
148 printf("Failed to create directory: localOCDB/ITS/Calib/SPDNoisy");
152 status = daqDA_DB_getFile("spd_noisy_ocdb","localOCDB/ITS/Calib/SPDNoisy/Run0_999999999_v0_s0.root");
154 printf("Failed to get spd file (spd_noisy_ocdb) from DAQdetDB, status=%d\n", status);
158 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDDead",kFileExists)) {
159 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDDead",kTRUE) != 0) {
160 printf("Failed to create directory: localOCDB/ITS/Calib/SPDDead");
164 status = daqDA_DB_getFile("spd_dead_ocdb","localOCDB/ITS/Calib/SPDDead/Run0_999999999_v0_s0.root");
166 printf("Failed to get spd file (spd_dead_ocdb) from DAQdetDB, status=%d\n", status);
170 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDSparseDead",kFileExists)) {
171 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDSparseDead",kTRUE) != 0) {
172 printf("Failed to create directory: localOCDB/ITS/Calib/SPDSparseDead");
177 status = daqDA_DB_getFile("spd_sparsedead_ocdb","localOCDB/ITS/Calib/SPDSparseDead/Run0_999999999_v0_s0.root");
179 printf("Failed to get spd file (spd_sparsedead_ocdb) from DAQdetDB, status=%d\n", status);
183 if (gSystem->AccessPathName("localOCDB/TRIGGER/SPD/PITConditions",kFileExists)) {
184 if (gSystem->mkdir("localOCDB/TRIGGER/SPD/PITConditions",kTRUE) != 0) {
185 printf("Failed to create directory: localOCDB/TRIGGER/SPD/PITConditions");
189 status = daqDA_DB_getFile("TRIGGER/SPD/PITConditions","localOCDB/TRIGGER/SPD/PITConditions/Run0_999999999_v0_s0.root");
191 printf("Failed to get spd trigger file (TRIGGER/SPD/PITConditions) from DAQdetDB, status=%d\n", status);
195 status = daqDA_DB_getFile("mfchebKGI_sym.root","localOCDB/mfchebKGI_sym.root");
197 printf("Failed to get spd file (mfchebKGI_sym.root) from DAQdetDB, status=%d\n", status);
201 // Global initializations
203 // The B filed is required in AliITSClusterFinderV2SPD
204 // for the Lorentz angle correction. B set to 0.
205 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 0., 0., AliMagF::k5kGUniform,AliMagF::kBeamTypeAA,-1,2,15,"localOCDB/mfchebKGI_sym.root"));
206 AliLog::SetGlobalLogLevel(AliLog::kError);
207 AliCDBManager *man = AliCDBManager::Instance();
208 man->SetDefaultStorage("local://localOCDB");
211 // Init mean vertexer
212 AliITSMeanVertexer *mv = new AliITSMeanVertexer();
214 // Optionally change the Z fiducial region here (default +/- 40 cm
215 mv->SetZFiducialRegion(zFiducialRegion);
218 printf("Initialization of mean vertexer object failed ! Check the log for details");
222 mv->SetCutOnErrX(errX);
224 mv->SetCutOnCls(minClInner,maxClInner);
226 gSystem->Exec(Form("rm %s",OUTPUT_FILE));
228 TTimeStamp *timeStamp;
230 Int_t t1 = timeStamp->GetSec();
233 // Initialization of AMORE sender
235 amore::da::AmoreDA vtxAmore(amore::da::AmoreDA::kSender);
237 Int_t amore_status = 0;
238 /* main loop (infinite) */
241 /* check shutdown condition */
242 if (daqDA_checkShutdown()) {break;}
244 /* get next event (blocking call until timeout) */
245 status=monitorGetEventDynamic((void **)&event);
246 if (status==MON_ERR_EOF) {
247 printf ("End of File detected\n");
248 break; /* end of monitoring file has been reached */
252 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
256 /* retry if got no event */
262 eventT=event->eventType;
263 switch (event->eventType){
268 /* END START OF RUN */
276 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
278 // Run mean-vertexer reco
279 if (mv->Reconstruct(rawReader)) nevents_with_vertex++;
280 if(nevents_physics < nEvFirstLoop) continue;
282 if ((nevents_physics%nEvAUTOSAVE) == 0) {
283 TH2F *histo = ((TH2F*)mv->GetVertexXY());
284 histo->SetStats(kFALSE);
286 histo->GetListOfFunctions()->SetOwner(kTRUE);
287 if(histo->GetListOfFunctions()->GetEntries()<1) histo->GetListOfFunctions()->Add(new TPaveText(-5,4.5,5.,6.2,"br"));
288 for(Int_t i=0; i<histo->GetListOfFunctions()->GetEntries(); i++){
289 TString funcName = histo->GetListOfFunctions()->At(i)->ClassName();
290 if(funcName.Contains("TPaveText")){
291 TPaveText *p = (TPaveText*)histo->GetListOfFunctions()->At(i);
293 p->AddText(Form("%f events with vertex (%i out of %i processed events)",((Double_t)nevents_with_vertex)/((Double_t)nevents_physics),nevents_with_vertex,nevents_physics));
294 p->AddText(Form("%f events with good vertex (%i out of %i events with vertex)",histo->GetEntries()/((Double_t)nevents_with_vertex),(Int_t)histo->GetEntries(),nevents_with_vertex));
297 mv->WriteVertices(OUTPUT_FILE);
300 t2 = timeStamp->GetSec();
306 if (TMath::Abs((t2-t1)-timeWindowExport) < timeErrWindowExport){
308 // send the histos to AMORE pool
309 amore_status=vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY());
310 if(amore_status) printf("AMORE XY send status: %d\n",amore_status);
311 TH1D *hProj = mv->GetVertexXY()->ProjectionX();
312 amore_status=vtxAmore.Send(Form("%s_ProjX",mv->GetVertexXY()->GetName()),hProj);
313 if(amore_status) printf("AMORE X send status: %d\n",amore_status);
314 if(hProj) delete hProj;
315 hProj = mv->GetVertexXY()->ProjectionY();
316 amore_status=vtxAmore.Send(Form("%s_ProjY",mv->GetVertexXY()->GetName()),hProj);
317 if(amore_status) printf("AMORE Y send status: %d\n",amore_status);
318 if(hProj) hProj->Delete();
319 amore_status=vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ());
320 if(amore_status) printf("AMORE Z send status: %d\n",amore_status);
322 if (TMath::Abs(t2-t1)> timeWindowExport) t1=t2;
333 /* exit when last event received, no need to wait for TERM signal */
334 if (eventT==END_OF_RUN) {
335 printf("EOR event detected\n");
340 TH2F *histo = ((TH2F*)mv->GetVertexXY());
341 histo->SetStats(kFALSE);
343 histo->GetListOfFunctions()->SetOwner(kTRUE);
344 if(histo->GetListOfFunctions()->GetEntries()<1) histo->GetListOfFunctions()->Add(new TPaveText(-5,4.5,5.,6.2,"br"));
345 for(Int_t i=0; i<histo->GetListOfFunctions()->GetEntries(); i++){
346 TString funcName = histo->GetListOfFunctions()->At(i)->ClassName();
347 if(funcName.Contains("TPaveText")){
348 TPaveText *p = (TPaveText*)histo->GetListOfFunctions()->At(i);
350 p->AddText(Form("%f events with vertex (%i out of %i processed events)",((Double_t)nevents_with_vertex)/((Double_t)nevents_physics),nevents_with_vertex,nevents_physics));
351 p->AddText(Form("%f events with good vertex (%i out of %i events with vertex)",histo->GetEntries()/((Double_t)nevents_with_vertex),(Int_t)histo->GetEntries(),nevents_with_vertex));
354 mv->WriteVertices(OUTPUT_FILE);
357 if (TMath::Abs((t2-t1)-timeWindowExport) < timeErrWindowExport){
359 // send the histos to AMORE pool
360 amore_status=vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY());
361 if(amore_status) printf("AMORE XY send status: %d\n",amore_status);
362 TH1D *hProj = mv->GetVertexXY()->ProjectionX();
363 amore_status=vtxAmore.Send(Form("%s_ProjX",mv->GetVertexXY()->GetName()),hProj);
364 if(amore_status) printf("AMORE X send status: %d\n",amore_status);
365 if(hProj) delete hProj;
366 hProj = mv->GetVertexXY()->ProjectionY();
367 amore_status=vtxAmore.Send(Form("%s_ProjY",mv->GetVertexXY()->GetName()),hProj);
368 if(amore_status) printf("AMORE Y send status: %d\n",amore_status);
369 if(hProj) hProj->Delete();
370 amore_status=vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ());
371 if(amore_status) printf("AMORE Z send status: %d\n",amore_status);
373 if (TMath::Abs(t2-t1)> timeWindowExport) t1=t2;
380 printf("Run #%s, received %d events with vertex, out of %d physics and out of %d total events\n",getenv("DATE_RUN_NUMBER"),nevents_with_vertex,nevents_physics,nevents_total);
384 /* export file to FXS */
385 if (daqDA_FES_storeFile(OUTPUT_FILE, "VertexDiamond")) {