]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDGainda.cxx
Changing fabs into TMath::Abs
[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 "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
58   //This will only work for FDR 1 data. When newer data becomes available the ! must be removed!
59   AliFMDParameters::Instance()->UseCompleteHeader(!old);
60   
61   
62   AliRawReader *reader = 0;
63   TString fileNam(fileName);
64   if (fileNam.EndsWith(".root")) reader = new AliRawReaderRoot(fileName);
65   else if (fileNam.EndsWith(".raw")) reader = new AliRawReaderDate(fileName);
66   if (!reader) { 
67     std::cerr << "Don't know how to make reader for " << fileNam 
68               << std::endl;
69     return -2;
70   }
71   
72   
73   TStopwatch timer;
74   timer.Start();
75   AliFMDGainDA gainDA;
76   gainDA.SetSaveDiagnostics(diagnostics);
77   gainDA.Run(reader);
78   
79   timer.Stop();
80   timer.Print();
81   
82   Int_t  retvalConditions = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
83   Int_t  retvalGain = daqDA_FES_storeFile("gains.csv", AliFMDParameters::Instance()->GetGainShuttleID());
84
85   if(retvalConditions!=0 || retvalGain!=0)
86     std::cerr << "Pedestal DA failed" << std::endl;
87   
88   if(retvalGain != 0) return retvalGain;
89   else return retvalConditions;
90   
91   
92   
93   
94 }