]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/FMDGainda.cxx
Script to do per-strip spectra
[u/mrichter/AliRoot.git] / FMD / FMDGainda.cxx
CommitLineData
0e9547f1 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
8bd95799 8 DA Type: LDC
0e9547f1 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>
5fee0a18 15#include <TString.h>
0e9547f1 16#include <AliFMDParameters.h>
17#include <AliRawReader.h>
18#include <TStopwatch.h>
19#include <AliFMDGainDA.h>
20#include <AliRawReaderDate.h>
5fee0a18 21#include <AliRawReaderRoot.h>
40036ce9 22#include <AliLog.h>
5fee0a18 23#include "daqDA.h"
0e9547f1 24#include "TROOT.h"
25#include "TPluginManager.h"
2a082c96 26#ifdef ALI_AMORE
27# include <AmoreDA.h>
28# include <TH2.h>
29#endif
0e9547f1 30
31
32
33int main(int argc, char **argv)
34{
35
0e9547f1 36 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
37 "*",
38 "TStreamerInfo",
39 "RIO",
40 "TStreamerInfo()");
276b1261 41 gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", "Minuit",
42 "TMinuitMinimizer",
43 "Minuit",
44 "TMinuitMinimizer(const char *)");
45 gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
46 "GSLMultiMin",
47 "ROOT::Math::GSLMinimizer",
48 "MathMore",
49 "GSLMinimizer(const char *)");
50 gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
51 "GSLMultiFit",
52 "ROOT::Math::GSLNLSMinimizer",
53 "MathMore", "GSLNLSMinimizer(int)");
54 gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
55 "GSLSimAn",
56 "ROOT::Math::GSLSimAnMinimizer",
57 "MathMore",
58 "GSLSimAnMinimizer(int)");
59 gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
60 "Linear",
61 "TLinearMinimizer",
62 "Minuit",
63 "TLinearMinimizer(const char *)");
64 gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
65 "Fumili",
66 "TFumiliMinimizer",
67 "Fumili",
68 "TFumiliMinimizer(int)");
0e9547f1 69
70
5fee0a18 71 Bool_t diagnostics = kFALSE;
0e9547f1 72 Char_t* fileName = argv[1];
5fee0a18 73 TString secondArgument(argv[2]);
0e9547f1 74
408bf2b4 75 for (int i = 2; i < argc; i++) {
76 TString arg(argv[i]);
77 if (arg.Contains("--diagnostics=true")) diagnostics = kTRUE;
78 else if (arg.Contains("--help")) {
79 std::cout << "Usage: " << argv[0] << " FILENAME [OPTIONS]\n\n"
80 << "Options:\n"
81 << " --diagnostics=BOOL Make diagnostics ROOT file\n"
82 << std::endl;
83 return 0;
84 }
85 else {
86 std::cerr << "Unknown option: " << arg << "\n"
87 << "Try '" << argv[0] << " --help" << std::endl;
88 return 1;
89 }
5fee0a18 90 }
408bf2b4 91 Bool_t old = kTRUE;
0e9547f1 92
93 AliFMDParameters::Instance()->Init(kFALSE,0);
0e9547f1 94
95 //This will only work for FDR 1 data. When newer data becomes available the ! must be removed!
40036ce9 96 AliFMDParameters::Instance()->UseCompleteHeader(old);
0e9547f1 97
1f12303f 98 AliLog::EnableDebug(kFALSE);
0e9547f1 99
5fee0a18 100 AliRawReader *reader = 0;
101 TString fileNam(fileName);
40036ce9 102 if (fileNam.EndsWith(".root"))
103 reader = new AliRawReaderRoot(fileName);
6d237bb1 104 else reader = new AliRawReaderDate(fileName);
5fee0a18 105 if (!reader) {
106 std::cerr << "Don't know how to make reader for " << fileNam
107 << std::endl;
108 return -2;
109 }
40036ce9 110
0e9547f1 111
0e9547f1 112 TStopwatch timer;
113 timer.Start();
114 AliFMDGainDA gainDA;
5fee0a18 115 gainDA.SetSaveDiagnostics(diagnostics);
2a082c96 116#ifdef ALI_AMORE
117 gainDA.SetMakeSummaries(kTRUE);
118#endif
0e9547f1 119 gainDA.Run(reader);
120
121 timer.Stop();
122 timer.Print();
5fee0a18 123
2a082c96 124 Int_t retvalConditions =
125 daqDA_FES_storeFile("conditions.csv",
126 AliFMDParameters::Instance()->GetConditionsShuttleID());
127 Int_t retvalGain =
128 daqDA_FES_storeFile("gains.csv",
129 AliFMDParameters::Instance()->GetGainShuttleID());
0e9547f1 130
5fee0a18 131 if(retvalConditions!=0 || retvalGain!=0)
132 std::cerr << "Pedestal DA failed" << std::endl;
133
2a082c96 134#ifdef ALI_AMORE
135 try {
136 amore::da::AmoreDA myAmore(amore::da::AmoreDA::kSender);
137
138 UShort_t det = 0;
139 for (det = 1; det <= 3; det++)
140 if (gainDA.HasSeenDetector(det)) break;
141 if (det >= 1 && det <= 3) {
142 TObject* runNo = new TObject;
143 runNo->SetUniqueID(reader->GetRunNumber());
144 myAmore.Send(Form("gainRunNoFMD%d", det), runNo);
145 }
146
147 TIter next(&gainDA.GetSummaries());
148 TObject* obj = 0;
149 while ((obj = next()))
150 myAmore.Send(obj->GetName(), obj);
151
152 }
153 catch (std::exception& e) {
154 std::cerr << "Failed to make AMORE instance: " << e.what() << std::endl;
155 }
156
157#endif
158
5fee0a18 159 if(retvalGain != 0) return retvalGain;
2a082c96 160 return retvalConditions;
161
0e9547f1 162}
2a082c96 163//
164// EOF
165//
166