]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/ITSSSDPEDda.cxx
Updated version of SSD Detector Algorithms (S. Borysov)
[u/mrichter/AliRoot.git] / ITS / ITSSSDPEDda.cxx
1 /**************************************************************************
2 - Contact: Oleksandr_Borysov aborysov@ts.infnf.it
3 - Link: /afs/infn.it/ts/user/efragiac/public/testCosm3125.001
4 - Run Type: 
5 - DA Type: LDC
6 - Number of events needed: >=500
7 - Input Files: ssdpeddaconfig, raw_data_file_on_LDC
8 - Output Files: $DA_TEST_DIR/ssddaldc_<LDCID>_<RunID>.root, FXS_name=ITSSSDda_<LDCID>_<RunID>.root 
9                 local files are persistent over runs: data source
10 - Trigger types used:
11  **************************************************************************/
12
13
14 #include <iostream>
15 #include "TString.h"
16 #include "TFile.h"
17 #include "daqDA.h"
18 #include "AliITSHandleDaSSD.h" 
19
20 using namespace std;
21
22
23 int main( int argc, char** argv )
24 {
25   AliITSHandleDaSSD  *ssddaldc;
26   TString             feefname, cmddbsave;
27   Int_t               status;
28   Char_t             *dafname = NULL, *dadaqdir = NULL;
29
30   /* check that we got some arguments = list of files */
31   if (argc<2) {
32     fprintf(stderr, "Wrong number of arguments\n");
33     return -1;
34   }
35
36   char *datafilename = argv[1];
37
38   ssddaldc = new AliITSHandleDaSSD(datafilename);
39   if (ssddaldc->IsZombie()) return -1;
40   if (!ssddaldc->ProcessRawData())
41   {
42      cerr << "Error !ssddaldc->ProcessRawData()" << endl;
43      delete ssddaldc;
44      return -1;
45   }  
46   daqDA_progressReport(90);
47
48   if (!system(NULL)) {
49     cerr << "Error: the call system(NULL) in main() returned NULL!" << endl;
50     return -1;
51   }
52   dadaqdir = getenv ("DA_TEST_DIR");
53   if (!dadaqdir) {
54     cerr << "Error: DA_TEST_DIR is not defined, DA data are not saved!" << endl;
55     delete ssddaldc;
56     daqDA_progressReport(100);
57     return 1;
58   }
59   dafname = dadaqdir;
60   if (ssddaldc->SaveCalibrationSSDLDC(dafname)) {
61     cout << "SSDDA data are saved in " << dafname << endl;
62     status = daqDA_FES_storeFile(dafname, "DASSD_DB_results");
63     if (status) fprintf(stderr, "Failed to export file : %d\n", status);
64   } else cerr << "Error saving DA data to the file! Probably $DA_TEST_DIR defined incorrectly!" << endl;
65
66   feefname.Form("%s/ssddaldc_%i_%i.root", dadaqdir, ssddaldc->GetLdcId(), ssddaldc->GetRunId());
67   cout << "Saving feessdda data in " << feefname << endl;
68   TFile *fileRun = new TFile (feefname.Data(),"RECREATE");
69   if (fileRun->IsZombie()) {
70     cerr << "Error open file " << feefname << endl;
71     delete ssddaldc;
72     delete fileRun;
73     return 2;
74   }  
75   ssddaldc->Write();
76   fileRun->Close();
77   delete fileRun;
78
79   if (getenv("DATE_DB_DIR")) {
80     cmddbsave.Form("$DATE_DB_DIR/daqDetDB_store ssddaldc_%i.root %s", ssddaldc->GetLdcId(), feefname.Data());
81     status = system(cmddbsave.Data());
82     if (status) fprintf(stderr, "Failed to export file to the detector db: %d, %s \n",status, cmddbsave.Data());
83     cmddbsave.Form("$DATE_DB_DIR/daqDetDB_store ssddaldc_%i_%i.root %s", 
84                                  ssddaldc->GetLdcId(), ssddaldc->GetRunId(), feefname.Data());
85     status = system(cmddbsave.Data());
86     if (status) fprintf(stderr, "Failed to export file to the detector db: %d, %s \n",status, cmddbsave.Data());
87   } else cerr << "Error main(): $DATE_DB_DIR is not defined!" << endl;
88
89   delete ssddaldc;
90   daqDA_progressReport(100);
91   return 0;
92 }