Moving the FMD offline trigger to its own class, AliFMDOfflineTrigger
[u/mrichter/AliRoot.git] / FMD / FMDPedestalda.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:                PEDESTAL
8   DA Type:                 LDC
9   Number of events needed: 1000
10   Input Files:             raw data 
11   Output Files:            peds.csv
12   Trigger types used:      PEDESTAL
13 */
14 #include <iostream>
15 #include <TSystem.h>
16 #include <TString.h>
17 #include <AliFMDParameters.h>
18 #include <AliRawReader.h>
19 #include <TStopwatch.h>
20 #include <AliFMDPedestalDA.h>
21 #include <AliRawReaderDate.h>
22 #include <AliRawReaderRoot.h>
23 #include "daqDA.h"
24 #include "TROOT.h"
25 #include "TPluginManager.h"
26 #include <AliLog.h>
27
28
29 int main(int argc, char **argv) 
30 {
31   /* magic line from Rene - for future reference! */
32   gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
33                                         "*",
34                                         "TStreamerInfo",
35                                         "RIO",
36                                         "TStreamerInfo()");
37   gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", "Minuit", 
38                                         "TMinuitMinimizer",
39                                         "Minuit", 
40                                         "TMinuitMinimizer(const char *)");
41   gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
42                                         "GSLMultiMin", 
43                                         "ROOT::Math::GSLMinimizer",
44                                         "MathMore", 
45                                         "GSLMinimizer(const char *)");
46   gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
47                                         "GSLMultiFit", 
48                                         "ROOT::Math::GSLNLSMinimizer",
49                                         "MathMore", "GSLNLSMinimizer(int)");
50   gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
51                                         "GSLSimAn", 
52                                         "ROOT::Math::GSLSimAnMinimizer",
53                                         "MathMore", 
54                                         "GSLSimAnMinimizer(int)");
55   gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
56                                         "Linear", 
57                                         "TLinearMinimizer",
58                                         "Minuit", 
59                                         "TLinearMinimizer(const char *)");
60   gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
61                                         "Fumili", 
62                                         "TFumiliMinimizer",
63                                         "Fumili", 
64                                         "TFumiliMinimizer(int)");
65
66
67   
68   
69   Bool_t diagnostics = kFALSE;
70   if (argc < 2) { 
71     std::cerr << "No input file given" << std::endl;
72     return 1;
73   }
74   TString fileName(argv[1]);
75   if (fileName.Contains("--help")) { 
76     std::cout << "Usage: " << argv[0] << " FILENAME [OPTIONS]\n\n"
77               << "Options:\n" 
78               << "    --diagnostics=BOOL Make diagnostics ROOT file\n"
79               << std::endl;
80     return 0;
81   }
82       
83   for (int i = 2; i < argc; i++) { 
84     TString arg(argv[i]);
85     if      (arg.Contains("--diagnostics=true")) diagnostics = kTRUE;
86     else if (arg.Contains("--help")) { 
87       std::cout << "Usage: " << argv[0] << " FILENAME [OPTIONS]\n\n"
88                 << "Options:\n" 
89                 << "    --diagnostics=BOOL Make diagnostics ROOT file\n"
90                 << std::endl;
91       return 0;
92     }
93     else { 
94       std::cerr << "Unknown option: " << arg << "\n"
95                 << "Try '" << argv[0] << " --help" << std::endl;
96       return 1;
97     }
98   }
99   Bool_t old = kTRUE;
100
101   AliLog::EnableDebug(kFALSE);
102   AliFMDParameters::Instance()->Init(kFALSE,0);
103   AliFMDParameters::Instance()->UseCompleteHeader(old);
104
105   AliRawReader *reader = 0;
106   if (fileName.EndsWith(".root")) 
107     reader = new AliRawReaderRoot(fileName.Data());
108   else 
109     reader = new AliRawReaderDate(fileName.Data());
110   if (!reader) { 
111     std::cerr << "Don't know how to make reader for " << fileName
112               << std::endl;
113     return -2;
114   }
115   TStopwatch timer;
116   timer.Start();
117   AliFMDPedestalDA pedDA;
118   pedDA.SetSaveDiagnostics(diagnostics);
119   pedDA.Run(reader);
120   
121   timer.Stop();
122   timer.Print();
123  
124   Int_t  retvalConditions = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
125   Int_t  retvalPeds = daqDA_FES_storeFile("peds.csv", AliFMDParameters::Instance()->GetPedestalShuttleID());
126
127   if(retvalConditions!=0 || retvalPeds!=0)
128     std::cerr << "Pedestal DA failed" << std::endl;
129   
130   if(retvalPeds != 0) return retvalPeds;
131   else return retvalConditions;
132   
133 }