Fixed a bug in the arguments to the program
[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
8 DA Type: Pedestal
9 Number of events needed: 1000
10 Input Files: raw data
11 Output Files: peds.csv
12 Trigger types used: PEDESTAL
13*/
14#include <TSystem.h>
5dd86feb 15#include <TString.h>
4a243071 16#include <AliFMDParameters.h>
17#include <AliRawReader.h>
18#include <TStopwatch.h>
19#include <AliFMDPedestalDA.h>
20#include <AliRawReaderDate.h>
5dd86feb 21#include <AliRawReaderRoot.h>
22#include "daqDA.h"
4a243071 23#include "TROOT.h"
24#include "TPluginManager.h"
25
26
27
28int main(int argc, char **argv)
29{
30
31 //#if 0
32 /* magic line from Rene - for future reference! */
33 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
34 "*",
35 "TStreamerInfo",
36 "RIO",
37 "TStreamerInfo()");
38 //#endif
39
5dd86feb 40 Bool_t diagnostics = kFALSE;
4a243071 41 Char_t* fileName = argv[1];
5dd86feb 42 TString secondArgument(argv[2]);
43
44 if(secondArgument.Contains("--diagnostics=true"))
45 diagnostics = kTRUE;
46 if(secondArgument.Contains("--help")) {
47 std::cout<<"Usage: filename --diagnostics=true/false . --help this help"<<std::endl;
48 return 0;
49 }
4a243071 50
bbafbf2e 51 if(!secondArgument.IsWhitespace() && !secondArgument.Contains("--help")
52 && !secondArgument.Contains("--diagnostics=true")) {
5dd86feb 53 std::cout<<"Second argument wrong. Use --help"<<std::endl;
54 return -1;
55 }
4a243071 56 Bool_t old = kTRUE;
57
58
59 AliFMDParameters::Instance()->Init(kFALSE,0);
4a243071 60 AliFMDParameters::Instance()->UseRcuTrailer(!old);
61 AliFMDParameters::Instance()->UseCompleteHeader(old);
62
5dd86feb 63 AliRawReader *reader = 0;
64 TString fileNam(fileName);
65 if (fileNam.EndsWith(".root")) reader = new AliRawReaderRoot(fileName);
66 else if (fileNam.EndsWith(".raw")) reader = new AliRawReaderDate(fileName);
67 if (!reader) {
68 std::cerr << "Don't know how to make reader for " << fileNam
69 << std::endl;
70 return -2;
71 }
4a243071 72 TStopwatch timer;
73 timer.Start();
74 AliFMDPedestalDA pedDA;
5dd86feb 75 pedDA.SetSaveDiagnostics(diagnostics);
4a243071 76 pedDA.Run(reader);
77
78 timer.Stop();
79 timer.Print();
5dd86feb 80
81 Int_t retvalConditions = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
82 Int_t retvalPeds = daqDA_FES_storeFile("peds.csv", AliFMDParameters::Instance()->GetPedestalShuttleID());
4a243071 83
5dd86feb 84 if(retvalConditions!=0 || retvalPeds!=0)
85 std::cerr << "Pedestal DA failed" << std::endl;
4a243071 86
5dd86feb 87 if(retvalPeds != 0) return retvalPeds;
88 else return retvalConditions;
4a243071 89
90}