]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDGainda.cxx
name change Int/Diff RP/POI
[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:                 LDC
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 <AliLog.h>
23 #include "daqDA.h"
24 #include "TROOT.h"
25 #include "TPluginManager.h"
26
27
28
29 int main(int argc, char **argv) 
30 {
31
32   gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
33                                         "*",
34                                         "TStreamerInfo",
35                                         "RIO",
36                                         "TStreamerInfo()");
37   
38   
39   Bool_t diagnostics = kFALSE;
40   Char_t* fileName = argv[1];
41   TString secondArgument(argv[2]);
42   
43   if(secondArgument.Contains("--diagnostics=true"))
44     diagnostics = kTRUE;
45   if(secondArgument.Contains("--help")) {
46     std::cout<<"Usage: filename --diagnostics=true/false . --help this help"<<std::endl;
47     return 0;
48   }
49   if(!secondArgument.IsWhitespace()&& !secondArgument.Contains("--help") 
50      && !secondArgument.Contains("--diagnostics=true")) {
51     std::cout<<"Second argument wrong. Use --help"<<std::endl;
52     return -1;
53   }
54     
55     Bool_t old = kTRUE;
56     
57   AliFMDParameters::Instance()->Init(kFALSE,0);
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   AliLog::EnableDebug(kFALSE);
63   
64   AliRawReader *reader = 0;
65   TString fileNam(fileName);
66   if (fileNam.EndsWith(".root")) 
67     reader = new AliRawReaderRoot(fileName);
68   else reader = new AliRawReaderDate(fileName);
69   if (!reader) { 
70     std::cerr << "Don't know how to make reader for " << fileNam 
71               << std::endl;
72     return -2;
73   }
74
75   
76   TStopwatch timer;
77   timer.Start();
78   AliFMDGainDA gainDA;
79   gainDA.SetSaveDiagnostics(diagnostics);
80   gainDA.Run(reader);
81   
82   timer.Stop();
83   timer.Print();
84   
85   Int_t  retvalConditions = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
86   Int_t  retvalGain = daqDA_FES_storeFile("gains.csv", AliFMDParameters::Instance()->GetGainShuttleID());
87
88   if(retvalConditions!=0 || retvalGain!=0)
89     std::cerr << "Pedestal DA failed" << std::endl;
90   
91   if(retvalGain != 0) return retvalGain;
92   else return retvalConditions;
93   
94   
95   
96   
97 }