Adding calibration object for the sharing efficiency
[u/mrichter/AliRoot.git] / FMD / FMDPedestalda.cxx
CommitLineData
4a243071 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
8bd95799 8 DA Type: LDC
4a243071 9 Number of events needed: 1000
10 Input Files: raw data
11 Output Files: peds.csv
12 Trigger types used: PEDESTAL
13*/
24954a29 14#include <iostream>
4a243071 15#include <TSystem.h>
5dd86feb 16#include <TString.h>
4a243071 17#include <AliFMDParameters.h>
18#include <AliRawReader.h>
19#include <TStopwatch.h>
20#include <AliFMDPedestalDA.h>
21#include <AliRawReaderDate.h>
5dd86feb 22#include <AliRawReaderRoot.h>
23#include "daqDA.h"
4a243071 24#include "TROOT.h"
25#include "TPluginManager.h"
24954a29 26#include <AliLog.h>
4a243071 27
28
29int main(int argc, char **argv)
30{
4a243071 31 /* magic line from Rene - for future reference! */
32 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
24954a29 33 "*",
4a243071 34 "TStreamerInfo",
35 "RIO",
36 "TStreamerInfo()");
276b1261 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
24954a29 67
4a243071 68
5dd86feb 69 Bool_t diagnostics = kFALSE;
276b1261 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
408bf2b4 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 }
5dd86feb 98 }
4a243071 99 Bool_t old = kTRUE;
100
1f12303f 101 AliLog::EnableDebug(kFALSE);
4a243071 102 AliFMDParameters::Instance()->Init(kFALSE,0);
4a243071 103 AliFMDParameters::Instance()->UseCompleteHeader(old);
104
5dd86feb 105 AliRawReader *reader = 0;
276b1261 106 if (fileName.EndsWith(".root"))
107 reader = new AliRawReaderRoot(fileName.Data());
108 else
109 reader = new AliRawReaderDate(fileName.Data());
5dd86feb 110 if (!reader) {
276b1261 111 std::cerr << "Don't know how to make reader for " << fileName
5dd86feb 112 << std::endl;
113 return -2;
114 }
4a243071 115 TStopwatch timer;
116 timer.Start();
117 AliFMDPedestalDA pedDA;
5dd86feb 118 pedDA.SetSaveDiagnostics(diagnostics);
4a243071 119 pedDA.Run(reader);
120
121 timer.Stop();
122 timer.Print();
5dd86feb 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());
4a243071 126
5dd86feb 127 if(retvalConditions!=0 || retvalPeds!=0)
128 std::cerr << "Pedestal DA failed" << std::endl;
4a243071 129
5dd86feb 130 if(retvalPeds != 0) return retvalPeds;
131 else return retvalConditions;
4a243071 132
133}