]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDGainda.cxx
Fixes for DAs after introduction of 3 LDCs (rather than 1):
[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   for (int i = 2; i < argc; i++) { 
44     TString arg(argv[i]);
45     if      (arg.Contains("--diagnostics=true")) diagnostics = kTRUE;
46     else if (arg.Contains("--help")) { 
47       std::cout << "Usage: " << argv[0] << " FILENAME [OPTIONS]\n\n"
48                 << "Options:\n" 
49                 << "    --diagnostics=BOOL Make diagnostics ROOT file\n"
50                 << std::endl;
51       return 0;
52     }
53     else { 
54       std::cerr << "Unknown option: " << arg << "\n"
55                 << "Try '" << argv[0] << " --help" << std::endl;
56       return 1;
57     }
58   }
59   Bool_t old = kTRUE;
60     
61   AliFMDParameters::Instance()->Init(kFALSE,0);
62
63   //This will only work for FDR 1 data. When newer data becomes available the ! must be removed!
64   AliFMDParameters::Instance()->UseCompleteHeader(old);
65   
66   AliLog::EnableDebug(kFALSE);
67   
68   AliRawReader *reader = 0;
69   TString fileNam(fileName);
70   if (fileNam.EndsWith(".root")) 
71     reader = new AliRawReaderRoot(fileName);
72   else reader = new AliRawReaderDate(fileName);
73   if (!reader) { 
74     std::cerr << "Don't know how to make reader for " << fileNam 
75               << std::endl;
76     return -2;
77   }
78
79   
80   TStopwatch timer;
81   timer.Start();
82   AliFMDGainDA gainDA;
83   gainDA.SetSaveDiagnostics(diagnostics);
84   gainDA.Run(reader);
85   
86   timer.Stop();
87   timer.Print();
88   
89   Int_t  retvalConditions = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
90   Int_t  retvalGain = daqDA_FES_storeFile("gains.csv", AliFMDParameters::Instance()->GetGainShuttleID());
91
92   if(retvalConditions!=0 || retvalGain!=0)
93     std::cerr << "Pedestal DA failed" << std::endl;
94   
95   if(retvalGain != 0) return retvalGain;
96   else return retvalConditions;
97   
98   
99   
100   
101 }