]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDGainda.cxx
Some cleanup, corrections to the log messages and removal of possible leaks
[u/mrichter/AliRoot.git] / FMD / FMDGainda.cxx
1 /*
2
3   FMD DA for online calibration of conditions
4
5   Contact:                 canute@nbi.dk
6   Link:                    fmd.nbi.dk/fmd/offline
7   Run Type:                GAIN
8   DA Type:                 GAIN
9   Number of events needed: usually 102400
10   Input Files:             raw data 
11   Output Files:            gains.csv
12   Trigger types used:      GAIN
13 */
14 #include <TSystem.h>
15 #include <TString.h>
16 #include <AliFMDParameters.h>
17 #include <AliRawReader.h>
18 #include <TStopwatch.h>
19 #include <AliFMDGainDA.h>
20 #include <AliRawReaderDate.h>
21 #include <AliRawReaderRoot.h>
22 #include "daqDA.h"
23 #include "TROOT.h"
24 #include "TPluginManager.h"
25
26
27
28 int main(int argc, char **argv) 
29 {
30
31   gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
32                                         "*",
33                                         "TStreamerInfo",
34                                         "RIO",
35                                         "TStreamerInfo()");
36   
37   
38   Bool_t diagnostics = kFALSE;
39   Char_t* fileName = argv[1];
40   TString secondArgument(argv[2]);
41   
42   if(secondArgument.Contains("--diagnostics=true"))
43     diagnostics = kTRUE;
44   if(secondArgument.Contains("--help")) {
45     std::cout<<"Usage: filename --diagnostics=true/false . --help this help"<<std::endl;
46     return 0;
47   }
48   if(!secondArgument.IsWhitespace()&& !secondArgument.Contains("--help") 
49      && !secondArgument.Contains("--diagnostics=true")) {
50     std::cout<<"Second argument wrong. Use --help"<<std::endl;
51     return -1;
52   }
53     
54     Bool_t old = kTRUE;
55     
56   AliFMDParameters::Instance()->Init(kFALSE,0);
57   AliFMDParameters::Instance()->UseRcuTrailer(!old);
58
59   //This will only work for FDR 1 data. When newer data becomes available the ! must be removed!
60   AliFMDParameters::Instance()->UseCompleteHeader(!old);
61   
62   
63   AliRawReader *reader = 0;
64   TString fileNam(fileName);
65   if (fileNam.EndsWith(".root")) reader = new AliRawReaderRoot(fileName);
66   else if (fileNam.EndsWith(".raw")) reader = new AliRawReaderDate(fileName);
67   if (!reader) { 
68     std::cerr << "Don't know how to make reader for " << fileNam 
69               << std::endl;
70     return -2;
71   }
72   
73   
74   TStopwatch timer;
75   timer.Start();
76   AliFMDGainDA gainDA;
77   gainDA.SetSaveDiagnostics(diagnostics);
78   gainDA.Run(reader);
79   
80   timer.Stop();
81   timer.Print();
82   
83   Int_t  retvalConditions = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
84   Int_t  retvalGain = daqDA_FES_storeFile("gains.csv", AliFMDParameters::Instance()->GetGainShuttleID());
85
86   if(retvalConditions!=0 || retvalGain!=0)
87     std::cerr << "Pedestal DA failed" << std::endl;
88   
89   if(retvalGain != 0) return retvalGain;
90   else return retvalConditions;
91   
92   
93   
94   
95 }