]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDPedestalda.cxx
New version which dumps into a list instead of a TObjArray
[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   
38   
39   Bool_t diagnostics = kFALSE;
40   Char_t* fileName = argv[1];
41   TString secondArgument(argv[2]);
42   
43   if(secondArgument.Contains("--diagnostics=true"))
44     diagnostics = kTRUE;
45   if(secondArgument.Contains("--help")) {
46     std::cout<<"Usage: filename --diagnostics=true/false . --help this help"<<std::endl;
47     return 0;
48   }
49   
50   if(!secondArgument.IsWhitespace() && !secondArgument.Contains("--help") 
51      && !secondArgument.Contains("--diagnostics=true")) {
52     std::cout<<"Second argument wrong. Use --help"<<std::endl;
53     return -1;
54   }
55   Bool_t old = kTRUE;
56
57   AliLog::EnableDebug(kFALSE);
58   AliFMDParameters::Instance()->Init(kFALSE,0);
59   AliFMDParameters::Instance()->UseCompleteHeader(old);
60
61   AliRawReader *reader = 0;
62   TString fileNam(fileName);
63   if (fileNam.EndsWith(".root")) reader = new AliRawReaderRoot(fileName);
64   else reader = new AliRawReaderDate(fileName);
65   if (!reader) { 
66     std::cerr << "Don't know how to make reader for " << fileNam 
67               << std::endl;
68     return -2;
69   }
70   TStopwatch timer;
71   timer.Start();
72   AliFMDPedestalDA pedDA;
73   pedDA.SetSaveDiagnostics(diagnostics);
74   pedDA.Run(reader);
75   
76   timer.Stop();
77   timer.Print();
78  
79   Int_t  retvalConditions = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
80   Int_t  retvalPeds = daqDA_FES_storeFile("peds.csv", AliFMDParameters::Instance()->GetPedestalShuttleID());
81
82   if(retvalConditions!=0 || retvalPeds!=0)
83     std::cerr << "Pedestal DA failed" << std::endl;
84   
85   if(retvalPeds != 0) return retvalPeds;
86   else return retvalConditions;
87   
88 }