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"
24 //int amore::da::Updated(char const*) {}
27 #include <TPluginManager.h>
31 #include <TPaveText.h>
33 #include <TGeoGlobalMagField.h>
37 #include "AliRawReaderDate.h"
38 #include "AliCDBManager.h"
39 #include "AliITSMeanVertexer.h"
41 int main(int argc, char **argv) {
43 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
51 printf("Wrong number of arguments\n");
54 // get mean vertex quality cuts
55 status = daqDA_DB_getFile("ITSSPD_VertexQualityTuning_DA.config","./ITSSPD_VertexQualityTuning_DA.config");
57 printf("Failed to get config file (ITSSPD_VertexQualityTuning_DA.config) from DAQ DB, status=%d\n", status);
60 /* open the config file and retrieve running parameters */
63 UInt_t minClInner = 999 ;
64 UInt_t maxClInner = 999 ;
65 Int_t nEvFirstLoop = 0;
66 Int_t nEvAUTOSAVE = 0;
69 FILE *fpConfig = fopen("ITSSPD_VertexQualityTuning_DA.config","r");
70 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);
73 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);
75 /* define data source : this is argument 1 */
76 status=monitorSetDataSource( argv[1] );
78 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
82 /* declare monitoring program */
83 status=monitorDeclareMp( __FILE__ );
85 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
89 /* define wait event timeout - 1s max */
91 monitorSetNoWaitNetworkTimeout(1000);
93 /* log start of process */
94 printf("Vertex-Diamond SPD DA started\n");
96 /* init some counters */
97 int nevents_with_vertex = 0;
98 int nevents_physics=0;
101 struct eventHeaderStruct *event;
102 eventTypeType eventT;
105 if (getenv("DATE_RUN_NUMBER")==0) {
106 printf("DATE_RUN_NUMBER not properly set.\n");
109 int runNr = atoi(getenv("DATE_RUN_NUMBER"));
111 // Get the necessary OCDB files from the DAQ detector DB
112 if (gSystem->AccessPathName("localOCDB/GRP/Geometry/Data",kFileExists)) {
113 if (gSystem->mkdir("localOCDB/GRP/Geometry/Data",kTRUE) != 0) {
114 printf("Failed to create directory: localOCDB/GRP/Geometry/Data");
118 status = daqDA_DB_getFile("GRP/Geometry/Data","localOCDB/GRP/Geometry/Data/Run0_999999999_v0_s0.root");
120 printf("Failed to get geometry file (GRP/Geometry/Data) from DAQdetDB, status=%d\n", status);
124 if (gSystem->AccessPathName("localOCDB/ITS/Align/Data",kFileExists)) {
125 if (gSystem->mkdir("localOCDB/ITS/Align/Data",kTRUE) != 0) {
126 printf("Failed to create directory: localOCDB/ITS/Align/Data");
130 status = daqDA_DB_getFile("ITS/Align/Data","localOCDB/ITS/Align/Data/Run0_999999999_v0_s0.root");
132 printf("Failed to get its-alignment file (ITS/Align/Data) from DAQdetDB, status=%d\n", status);
136 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDNoisy",kFileExists)) {
137 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDNoisy",kTRUE) != 0) {
138 printf("Failed to create directory: localOCDB/ITS/Calib/SPDNoisy");
142 status = daqDA_DB_getFile("spd_noisy_ocdb","localOCDB/ITS/Calib/SPDNoisy/Run0_999999999_v0_s0.root");
144 printf("Failed to get spd file (spd_noisy_ocdb) from DAQdetDB, status=%d\n", status);
148 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDDead",kFileExists)) {
149 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDDead",kTRUE) != 0) {
150 printf("Failed to create directory: localOCDB/ITS/Calib/SPDDead");
154 status = daqDA_DB_getFile("spd_dead_ocdb","localOCDB/ITS/Calib/SPDDead/Run0_999999999_v0_s0.root");
156 printf("Failed to get spd file (spd_dead_ocdb) from DAQdetDB, status=%d\n", status);
160 if (gSystem->AccessPathName("localOCDB/ITS/Calib/SPDSparseDead",kFileExists)) {
161 if (gSystem->mkdir("localOCDB/ITS/Calib/SPDSparseDead",kTRUE) != 0) {
162 printf("Failed to create directory: localOCDB/ITS/Calib/SPDSparseDead");
167 status = daqDA_DB_getFile("spd_sparsedead_ocdb","localOCDB/ITS/Calib/SPDSparseDead/Run0_999999999_v0_s0.root");
169 printf("Failed to get spd file (spd_sparsedead_ocdb) from DAQdetDB, status=%d\n", status);
173 if (gSystem->AccessPathName("localOCDB/TRIGGER/SPD/PITConditions",kFileExists)) {
174 if (gSystem->mkdir("localOCDB/TRIGGER/SPD/PITConditions",kTRUE) != 0) {
175 printf("Failed to create directory: localOCDB/TRIGGER/SPD/PITConditions");
179 status = daqDA_DB_getFile("TRIGGER/SPD/PITConditions","localOCDB/TRIGGER/SPD/PITConditions/Run0_999999999_v0_s0.root");
181 printf("Failed to get spd trigger file (TRIGGER/SPD/PITConditions) from DAQdetDB, status=%d\n", status);
185 status = daqDA_DB_getFile("mfchebKGI_sym.root","localOCDB/mfchebKGI_sym.root");
187 printf("Failed to get spd file (mfchebKGI_sym.root) from DAQdetDB, status=%d\n", status);
191 // Global initializations
193 // The B filed is required in AliITSClusterFinderV2SPD
194 // for the Lorentz angle correction. B set to 0.
195 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 0., 0., AliMagF::k5kGUniform,AliMagF::kBeamTypeAA,-1,2,15,"localOCDB/mfchebKGI_sym.root"));
196 AliLog::SetGlobalLogLevel(AliLog::kError);
197 AliCDBManager *man = AliCDBManager::Instance();
198 man->SetDefaultStorage("local://localOCDB");
201 // Init mean vertexer
202 AliITSMeanVertexer *mv = new AliITSMeanVertexer();
204 printf("Initialization of mean vertexer object failed ! Check the log for details");
208 mv->SetCutOnErrX(errX);
210 mv->SetCutOnCls(minClInner,maxClInner);
212 // Initialization of AMORE sender
214 amore::da::AmoreDA vtxAmore(amore::da::AmoreDA::kSender);
216 /* main loop (infinite) */
219 /* check shutdown condition */
220 if (daqDA_checkShutdown()) {break;}
222 /* get next event (blocking call until timeout) */
223 status=monitorGetEventDynamic((void **)&event);
224 if (status==MON_ERR_EOF) {
225 printf ("End of File detected\n");
226 break; /* end of monitoring file has been reached */
230 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
234 /* retry if got no event */
240 eventT=event->eventType;
241 switch (event->eventType){
246 /* END START OF RUN */
254 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
256 // Run mean-vertexer reco
257 if (mv->Reconstruct(rawReader)) nevents_with_vertex++;
258 if(nevents_physics < nEvFirstLoop) continue;
260 if ((nevents_physics%nEvAUTOSAVE) == 0) {
261 TH2F *histo = ((TH2F*)mv->GetVertexXY());
262 histo->SetStats(kFALSE);
264 histo->GetListOfFunctions()->SetOwner(kTRUE);
265 if(histo->GetListOfFunctions()->GetEntries()<1) histo->GetListOfFunctions()->Add(new TPaveText(-5,4.5,5.,6.2,"br"));
266 for(Int_t i=0; i<histo->GetListOfFunctions()->GetEntries(); i++){
267 TString funcName = histo->GetListOfFunctions()->At(i)->ClassName();
268 if(funcName.Contains("TPaveText")){
269 TPaveText *p = (TPaveText*)histo->GetListOfFunctions()->At(i);
271 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));
272 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));
275 mv->WriteVertices(OUTPUT_FILE);
278 // send the histos to AMORE pool
279 printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY()));
280 printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ()));
290 /* exit when last event received, no need to wait for TERM signal */
291 if (eventT==END_OF_RUN) {
292 printf("EOR event detected\n");
297 TH2F *histo = ((TH2F*)mv->GetVertexXY());
298 histo->SetStats(kFALSE);
300 histo->GetListOfFunctions()->SetOwner(kTRUE);
301 if(histo->GetListOfFunctions()->GetEntries()<1) histo->GetListOfFunctions()->Add(new TPaveText(-5,4.5,5.,6.2,"br"));
302 for(Int_t i=0; i<histo->GetListOfFunctions()->GetEntries(); i++){
303 TString funcName = histo->GetListOfFunctions()->At(i)->ClassName();
304 if(funcName.Contains("TPaveText")){
305 TPaveText *p = (TPaveText*)histo->GetListOfFunctions()->At(i);
307 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));
308 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));
311 mv->WriteVertices(OUTPUT_FILE);
314 // send the histos to AMORE pool
315 printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexXY()->GetName(),mv->GetVertexXY()));
316 printf("AMORE send status: %d\n",vtxAmore.Send(mv->GetVertexZ()->GetName(),mv->GetVertexZ()));
322 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);
326 /* export file to FXS */
327 if (daqDA_FES_storeFile(OUTPUT_FILE, "VertexDiamond")) {