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
25 //int amore::da::Updated(char const*) {}
28 #include <TPluginManager.h>
32 #include <TPaveText.h>
35 #include <TGeoGlobalMagField.h>
39 #include "AliRawReaderDate.h"
40 #include "AliCDBManager.h"
41 #include "AliITSMeanVertexer.h"
43 int main(int argc, char **argv) {
45 TString outputFileName("SPDVertexDiamondDA.root");
46 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
54 printf("Wrong number of arguments\n");
57 // get mean vertex quality cuts
58 status = daqDA_DB_getFile("ITSSPD_VertexQualityTuning_DA.config","./ITSSPD_VertexQualityTuning_DA.config");
60 printf("Failed to get config file (ITSSPD_VertexQualityTuning_DA.config) from DAQ DB, status=%d\n", status);
63 /* open the config file and retrieve running parameters */
66 UInt_t minClInner = 999 ;
67 UInt_t maxClInner = 999 ;
68 Int_t nEvFirstLoop = 0;
69 Int_t nEvAUTOSAVE = 0;
72 FILE *fpConfig = fopen("ITSSPD_VertexQualityTuning_DA.config","r");
73 fscanf(fpConfig,"%s %f\n %s %f\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);
76 printf("\n\n Mean Vertex quality cuts : \n- errX = %f\n- r = %f\n- minSPD0 = %d maxSPD0 = %d\n- nEventsFirstLoop = %d nEventsAUTOSAVE = %d \n\n\n",errX,r,minClInner,maxClInner,nEvFirstLoop,nEvAUTOSAVE);
78 /* define data source : this is argument 1 */
79 status=monitorSetDataSource( argv[1] );
81 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
85 /* declare monitoring program */
86 status=monitorDeclareMp( __FILE__ );
88 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
92 /* define wait event timeout - 1s max */
94 monitorSetNoWaitNetworkTimeout(1000);
96 /* log start of process */
97 printf("Vertex-Diamond SPD DA started\n");
99 /* init some counters */
100 int nevents_with_vertex = 0;
101 int nevents_physics=0;
104 struct eventHeaderStruct *event;
105 eventTypeType eventT;
108 if (getenv("DATE_RUN_NUMBER")==0) {
109 printf("DATE_RUN_NUMBER not properly set.\n");
112 int runNr = atoi(getenv("DATE_RUN_NUMBER"));
114 // Get the necessary OCDB files from the DAQ detector DB
115 if (gSystem->AccessPathName("localOCDB/GRP/Geometry/Data",kFileExists)) {
116 if (gSystem->mkdir("localOCDB/GRP/Geometry/Data",kTRUE) != 0) {
117 printf("Failed to create directory: localOCDB/GRP/Geometry/Data");
121 status = daqDA_DB_getFile("GRP/Geometry/Data","localOCDB/GRP/Geometry/Data/Run0_999999999_v0_s0.root");
123 printf("Failed to get geometry file (GRP/Geometry/Data) from DAQdetDB, status=%d\n", status);
127 if (gSystem->AccessPathName("localOCDB/ITS/Align/Data",kFileExists)) {
128 if (gSystem->mkdir("localOCDB/ITS/Align/Data",kTRUE) != 0) {
129 printf("Failed to create directory: localOCDB/ITS/Align/Data");
133 status = daqDA_DB_getFile("ITS/Align/Data","localOCDB/ITS/Align/Data/Run0_999999999_v0_s0.root");
135 printf("Failed to get its-alignment file (ITS/Align/Data) from DAQdetDB, status=%d\n", status);
139 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDNoisy",kFileExists)) {
140 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDNoisy",kTRUE) != 0) {
141 printf("Failed to create directory: localOCDB/ITS/Calib/SPDNoisy");
145 status = daqDA_DB_getFile("spd_noisy_ocdb","localOCDB/ITS/Calib/SPDNoisy/Run0_999999999_v0_s0.root");
147 printf("Failed to get spd file (spd_noisy_ocdb) from DAQdetDB, status=%d\n", status);
151 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDDead",kFileExists)) {
152 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDDead",kTRUE) != 0) {
153 printf("Failed to create directory: localOCDB/ITS/Calib/SPDDead");
157 status = daqDA_DB_getFile("spd_dead_ocdb","localOCDB/ITS/Calib/SPDDead/Run0_999999999_v0_s0.root");
159 printf("Failed to get spd file (spd_dead_ocdb) from DAQdetDB, status=%d\n", status);
163 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDSparseDead",kFileExists)) {
164 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDSparseDead",kTRUE) != 0) {
165 printf("Failed to create directory: localOCDB/ITS/Calib/SPDSparseDead");
170 status = daqDA_DB_getFile("spd_sparsedead_ocdb","localOCDB/ITS/Calib/SPDSparseDead/Run0_999999999_v0_s0.root");
172 printf("Failed to get spd file (spd_sparsedead_ocdb) from DAQdetDB, status=%d\n", status);
176 if (gSystem->AccessPathName("localOCDB/TRIGGER/SPD/PITConditions",kFileExists)) {
177 if (gSystem->mkdir("localOCDB/TRIGGER/SPD/PITConditions",kTRUE) != 0) {
178 printf("Failed to create directory: localOCDB/TRIGGER/SPD/PITConditions");
182 status = daqDA_DB_getFile("TRIGGER/SPD/PITConditions","localOCDB/TRIGGER/SPD/PITConditions/Run0_999999999_v0_s0.root");
184 printf("Failed to get spd trigger file (TRIGGER/SPD/PITConditions) from DAQdetDB, status=%d\n", status);
188 status = daqDA_DB_getFile("mfchebKGI_sym.root","localOCDB/mfchebKGI_sym.root");
190 printf("Failed to get spd file (mfchebKGI_sym.root) from DAQdetDB, status=%d\n", status);
194 // Global initializations
196 // The B filed is required in AliITSClusterFinderV2SPD
197 // for the Lorentz angle correction. B set to 0.
198 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 0., 0., AliMagF::k5kGUniform,AliMagF::kBeamTypeAA,-1,2,15,"localOCDB/mfchebKGI_sym.root"));
199 AliLog::SetGlobalLogLevel(AliLog::kError);
200 AliCDBManager *man = AliCDBManager::Instance();
201 man->SetDefaultStorage("local://localOCDB");
204 // Init mean vertexer
205 AliITSMeanVertexer *mv = new AliITSMeanVertexer();
207 printf("Initialization of mean vertexer object failed ! Check the log for details");
211 mv->SetCutOnErrX(errX);
213 mv->SetCutOnCls(minClInner,maxClInner);
215 // Initialization of AMORE sender
217 amore::da::AmoreDA vtxAmore(amore::da::AmoreDA::kSender);
219 Int_t amore_status = 0;
220 /* main loop (infinite) */
223 /* check shutdown condition */
224 if (daqDA_checkShutdown()) {break;}
226 /* get next event (blocking call until timeout) */
227 status=monitorGetEventDynamic((void **)&event);
228 if (status==MON_ERR_EOF) {
229 printf ("End of File detected\n");
230 break; /* end of monitoring file has been reached */
234 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
238 /* retry if got no event */
244 eventT=event->eventType;
245 switch (event->eventType){
250 /* END START OF RUN */
258 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
260 // Run mean-vertexer reco
261 if (mv->Reconstruct(rawReader)) nevents_with_vertex++;
262 if(nevents_physics < nEvFirstLoop) continue;
264 if ((nevents_physics%nEvAUTOSAVE) == 0) {
265 TH2F *histo = ((TH2F*)mv->GetVertexXY());
266 histo->SetStats(kFALSE);
268 histo->GetListOfFunctions()->SetOwner(kTRUE);
269 if(histo->GetListOfFunctions()->GetEntries()<1) histo->GetListOfFunctions()->Add(new TPaveText(-5,4.5,5.,6.2,"br"));
270 for(Int_t i=0; i<histo->GetListOfFunctions()->GetEntries(); i++){
271 TString funcName = histo->GetListOfFunctions()->At(i)->ClassName();
272 if(funcName.Contains("TPaveText")){
273 TPaveText *p = (TPaveText*)histo->GetListOfFunctions()->At(i);
275 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));
276 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));
279 mv->WriteVertices(outputFileName.Data());
281 // send the histos to AMORE pool
282 amore_status=vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY());
283 if(amore_status) printf("AMORE XY send status: %d\n",amore_status);
284 TH1D *hProj = mv->GetVertexXY()->ProjectionX();
285 amore_status=vtxAmore.Send(Form("%s_ProjX",mv->GetVertexXY()->GetName()),hProj);
286 if(amore_status) printf("AMORE X send status: %d\n",amore_status);
287 if(hProj) delete hProj;
288 hProj = mv->GetVertexXY()->ProjectionY();
289 amore_status=vtxAmore.Send(Form("%s_ProjY",mv->GetVertexXY()->GetName()),hProj);
290 if(amore_status) printf("AMORE Y send status: %d\n",amore_status);
291 if(hProj) hProj->Delete();
292 amore_status=vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ());
293 if(amore_status) printf("AMORE Z send status: %d\n",amore_status);
303 /* exit when last event received, no need to wait for TERM signal */
304 if (eventT==END_OF_RUN) {
305 printf("EOR event detected\n");
310 TH2F *histo = ((TH2F*)mv->GetVertexXY());
311 histo->SetStats(kFALSE);
313 histo->GetListOfFunctions()->SetOwner(kTRUE);
314 if(histo->GetListOfFunctions()->GetEntries()<1) histo->GetListOfFunctions()->Add(new TPaveText(-5,4.5,5.,6.2,"br"));
315 for(Int_t i=0; i<histo->GetListOfFunctions()->GetEntries(); i++){
316 TString funcName = histo->GetListOfFunctions()->At(i)->ClassName();
317 if(funcName.Contains("TPaveText")){
318 TPaveText *p = (TPaveText*)histo->GetListOfFunctions()->At(i);
320 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));
321 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));
324 mv->WriteVertices(OUTPUT_FILE);
327 // send the histos to AMORE pool
328 amore_status=vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY());
329 if(amore_status) printf("AMORE XY send status: %d\n",amore_status);
330 TH1D *hProj = mv->GetVertexXY()->ProjectionX();
331 amore_status=vtxAmore.Send(Form("%s_ProjX",mv->GetVertexXY()->GetName()),hProj);
332 if(amore_status) printf("AMORE X send status: %d\n",amore_status);
333 if(hProj) delete hProj;
334 hProj = mv->GetVertexXY()->ProjectionY();
335 amore_status=vtxAmore.Send(Form("%s_ProjY",mv->GetVertexXY()->GetName()),hProj);
336 if(amore_status) printf("AMORE Y send status: %d\n",amore_status);
337 if(hProj) hProj->Delete();
338 amore_status=vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ());
339 if(amore_status) printf("AMORE Z send status: %d\n",amore_status);
345 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);
349 /* export file to FXS */
350 if (daqDA_FES_storeFile(OUTPUT_FILE, "VertexDiamond")) {