]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/ITSSSDPEDda.cxx
updated SSD pedestal DA
[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: ./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 #include "TROOT.h"
20 #include "TPluginManager.h"
21
22 using namespace std;
23
24
25 int main( int argc, char** argv )
26 {
27   AliITSHandleDaSSD  *ssddaldc;
28   TString             feefname, cmddbsave;
29   Int_t               status;
30   Char_t             *dafname = NULL;
31
32
33    gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
34                                         "*",
35                                         "TStreamerInfo",
36                                         "RIO",
37                                         "TStreamerInfo()");
38
39
40
41   /* check that we got some arguments = list of files */
42   if (argc<2) {
43     fprintf(stderr, "Wrong number of arguments\n");
44     return -1;
45   }
46
47   char *datafilename = argv[1];
48
49   ssddaldc = new AliITSHandleDaSSD(datafilename);
50   if (ssddaldc->IsZombie()) return -1;
51   if (!ssddaldc->ProcessRawData())
52   {
53      cerr << "Error !ssddaldc->ProcessRawData()" << endl;
54      delete ssddaldc;
55      return -1;
56   }  
57   daqDA_progressReport(90);
58
59   if (!system(NULL)) {
60     cerr << "Error: the call system(NULL) in main() returned NULL!" << endl;
61     return -1;
62   }
63   dafname = ".";
64   if (ssddaldc->SaveCalibrationSSDLDC(dafname)) {
65     cout << "SSDDA data are saved in " << dafname << endl;
66     status = daqDA_FES_storeFile(dafname, "DASSD_DB_results");
67     if (status) fprintf(stderr, "Failed to export file : %d\n", status);
68   } else cerr << "Error saving DA data to the file! Probably $DA_TEST_DIR defined incorrectly!" << endl;
69   feefname.Form("%s/ssddaldc_%i_%i.root", ".", ssddaldc->GetLdcId(), ssddaldc->GetRunId());
70   cout << "Saving feessdda data in " << feefname << endl;
71   TFile *fileRun = new TFile (feefname.Data(),"RECREATE");
72   if (fileRun->IsZombie()) {
73     cerr << "Error open file " << feefname << endl;
74     delete ssddaldc;
75     delete fileRun;
76     return 2;
77   }  
78   ssddaldc->Write();
79   fileRun->Close();
80   delete fileRun;
81
82   if (getenv("DATE_DB_DIR")) {
83     cmddbsave.Form("$DATE_DB_DIR/daqDetDB_store ssddaldc_%i.root %s", ssddaldc->GetLdcId(), feefname.Data());
84     status = system(cmddbsave.Data());
85     if (status) fprintf(stderr, "Failed to export file to the detector db: %d, %s \n",status, cmddbsave.Data());
86     cmddbsave.Form("$DATE_DB_DIR/daqDetDB_store ssddaldc_%i_%i.root %s", 
87                                  ssddaldc->GetLdcId(), ssddaldc->GetRunId(), feefname.Data());
88     status = system(cmddbsave.Data());
89     if (status) fprintf(stderr, "Failed to export file to the detector db: %d, %s \n",status, cmddbsave.Data());
90   } else cerr << "Error main(): $DATE_DB_DIR is not defined!" << endl;
91
92   delete ssddaldc;
93   daqDA_progressReport(100);
94   return 0;
95 }