]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/scripts/dqm/PatternCalib.C
Coverity fixes
[u/mrichter/AliRoot.git] / FMD / scripts / dqm / PatternCalib.C
1 //____________________________________________________________________
2 //
3 // $Id: PatternDigits.C 28055 2008-08-18 00:33:20Z cholm $
4 //
5 // Draw hits in the specialised FMD event display 
6 //
7 /** Display hits 
8     @ingroup FMD_script
9  */
10 Bool_t
11 CheckFile(const char* prefix, const char* path, int number, TString& f)
12 {
13   f = (Form("%s%d.csv", prefix, number));
14   std::cout << "Checking if " << f << " exists in " << path << " ... " 
15             << std::flush;
16   f = gSystem->Which(path, f.Data());
17   std::cout << '"' << f << '"' << std::endl;
18   return !f.IsNull();
19 }
20 void
21 PatternCalib(const char* file="raw.root", const char* calib="$(HOME)/calib/", 
22              Int_t runno=0)
23 {
24   // AliLog::SetModuleDebugLevel("FMD", 1);
25   gSystem->Load("libFMDutil.so");
26
27   AliCDBManager* cdb = AliCDBManager::Instance();
28   const char* cdbUri = gSystem->Getenv("AMORE_CDB_URI");
29   cdb->SetDefaultStorage(cdbUri);
30   cdb->SetRun(runno);
31
32   AliFMDCalibStripRange* range = new AliFMDCalibStripRange;
33   AliFMDCalibSampleRate* rate  = new AliFMDCalibSampleRate;
34   AliFMDCalibPedestal*   peds  = new AliFMDCalibPedestal;
35   AliFMDCalibGain*       gains = new AliFMDCalibGain;
36   Bool_t gotConds = kFALSE;
37   Bool_t gotPeds  = kFALSE;
38   Bool_t gotGains = kFALSE;
39   for (Int_t i = 1; i <= 3; i++) { 
40     TString f;
41     if (CheckFile("conditions", calib, i, f)) {
42       gotConds = kTRUE;
43       std::cout << "Reading conditions for FMD" <<i<< " from " <<f<< std::endl;
44       std::ifstream in(f.Data());
45       range->ReadFromFile(in);
46       rate->ReadFromFile(in);
47     }
48     if (CheckFile("peds", calib, i, f)) {
49       gotPeds = kTRUE;
50       std::cout << "Reading pedestals for FMD" <<i<< " from " <<f<< std::endl;
51       std::ifstream in(f.Data());
52       peds->ReadFromFile(in);
53     }
54     if (CheckFile("gains", calib, i, f)) {
55       gotGains = kTRUE;
56       std::cout << "Reading gains for FMD" <<i<< " from " <<f<< std::endl;
57       std::ifstream in(f.Data());
58       gains->ReadFromFile(in);
59     }
60   }
61
62   Int_t mask = (AliFMDParameters::kDeadMap|
63                 AliFMDParameters::kZeroSuppression|
64                 AliFMDParameters::kAltroMap);
65
66
67   if (!gotConds) mask |= AliFMDParameters::kStripRange;
68   if (!gotConds) mask |= AliFMDParameters::kSampleRate;
69   if (!gotPeds)  mask |= AliFMDParameters::kPedestal;
70   if (!gotGains) mask |= AliFMDParameters::kPulseGain;
71
72   AliFMDParameters* pars = AliFMDParameters::Instance();
73   pars->Init(kFALSE, mask);
74
75   if (gotConds) pars->SetStripRange(range);
76   if (gotConds) pars->SetSampleRate(rate);
77   if (gotPeds)  pars->SetPedestal(peds);
78   if (gotGains) pars->SetGain(gains);
79   
80   // pars->Print("pedestal");
81
82   AliFMDPattern* d = new AliFMDPattern;
83   d->AddLoad(AliFMDInput::kRawCalib);
84   d->SetRawFile(file);
85   d->SetName("rawCalib");
86   d->SetTitle("Calibrated Raw");
87   d->SetFactor(5);
88   d->SetCut(0.02, 1);
89   d->Run();
90 }
91
92 //____________________________________________________________________
93 //
94 // EOF
95 //