]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDPedestalda.cxx
Fixes for DAs after introduction of 3 LDCs (rather than 1):
[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   for (int i = 2; i < argc; i++) { 
42     TString arg(argv[i]);
43     if      (arg.Contains("--diagnostics=true")) diagnostics = kTRUE;
44     else if (arg.Contains("--help")) { 
45       std::cout << "Usage: " << argv[0] << " FILENAME [OPTIONS]\n\n"
46                 << "Options:\n" 
47                 << "    --diagnostics=BOOL Make diagnostics ROOT file\n"
48                 << std::endl;
49       return 0;
50     }
51     else { 
52       std::cerr << "Unknown option: " << arg << "\n"
53                 << "Try '" << argv[0] << " --help" << std::endl;
54       return 1;
55     }
56   }
57   Bool_t old = kTRUE;
58
59   AliLog::EnableDebug(kFALSE);
60   AliFMDParameters::Instance()->Init(kFALSE,0);
61   AliFMDParameters::Instance()->UseCompleteHeader(old);
62
63   AliRawReader *reader = 0;
64   TString fileNam(fileName);
65   if (fileNam.EndsWith(".root")) reader = new AliRawReaderRoot(fileName);
66   else 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   }
72   TStopwatch timer;
73   timer.Start();
74   AliFMDPedestalDA pedDA;
75   pedDA.SetSaveDiagnostics(diagnostics);
76   pedDA.Run(reader);
77   
78   timer.Stop();
79   timer.Print();
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());
83
84   if(retvalConditions!=0 || retvalPeds!=0)
85     std::cerr << "Pedestal DA failed" << std::endl;
86   
87   if(retvalPeds != 0) return retvalPeds;
88   else return retvalConditions;
89   
90 }