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