Stuff from aldaqdqm09
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Jul 2009 09:44:43 +0000 (09:44 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Jul 2009 09:44:43 +0000 (09:44 +0000)
FMD/scripts/dqm/SpectraRaw.C

index bce7376..9648758 100644 (file)
@@ -7,13 +7,18 @@
 /** Display hits 
     @ingroup FMD_script
  */
+Bool_t
+CheckFile(const char* prefix, int number, TString& f)
+{
+  f = (Form("%s%d.csv", prefix, number));
+  std::cout << "Checking if " << f << " exists ... " << std::flush;
+  f = gSystem->Which("$(HOME)/calib/", f.Data());
+  std::cout << '"' << f << '"' << std::endl;
+  return !f.IsNull();
+}
 void
 SpectraRaw(const char* file="raw.root", Int_t runno=0)
 {
-  gSystem->Load("libANALYSIS.so");
-  gSystem->Load("libANALYSISalice.so");
-  // gSystem->Load("libFMDanalysis.so");
-  gSystem->Load("$(HOME)/scripts/foo.so");
   gSystem->Load("libFMDutil.so");
 
   AliCDBManager* cdb = AliCDBManager::Instance();
@@ -21,14 +26,53 @@ SpectraRaw(const char* file="raw.root", Int_t runno=0)
   cdb->SetDefaultStorage(cdbUri);
   cdb->SetRun(runno);
 
-  AliFMDParameters::Instance()->Init(kFALSE,
-                                    AliFMDParameters::kPulseGain|
-                                    AliFMDParameters::kPedestal|
-                                    AliFMDParameters::kDeadMap|
-                                    AliFMDParameters::kZeroSuppression|
-                                    AliFMDParameters::kAltroMap|
-                                    AliFMDParameters::kStripRange);
-  AliFMDParameters::Instance()->SetSampleRate(2);
+  AliFMDCalibStripRange* range = new AliFMDCalibStripRange;
+  AliFMDCalibSampleRate* rate  = new AliFMDCalibSampleRate;
+  AliFMDCalibPedestal*   peds  = new AliFMDCalibPedestal;
+  AliFMDCalibGain*       gains = new AliFMDCalibGain;
+  Bool_t gotConds = kFALSE;
+  Bool_t gotPeds  = kFALSE;
+  Bool_t gotGains = kFALSE;
+  for (Int_t i = 1; i <= 3; i++) { 
+    TString f;
+    if (CheckFile("conditions", i, f)) {
+      gotConds = kTRUE;
+      std::cout << "Reading conditions for FMD" <<i<< " from " <<f<< std::endl;
+      std::ifstream in(f.Data());
+      range->ReadFromFile(in);
+      rate->ReadFromFile(in);
+    }
+    if (CheckFile("peds", i, f)) {
+      gotPeds = kTRUE;
+      std::cout << "Reading pedestals for FMD" <<i<< " from " <<f<< std::endl;
+      std::ifstream in(f.Data());
+      peds->ReadFromFile(in);
+    }
+    if (CheckFile("gains", i, f)) {
+      gotGains = kTRUE;
+      std::cout << "Reading gains for FMD" <<i<< " from " <<f<< std::endl;
+      std::ifstream in(f.Data());
+      gains->ReadFromFile(in);
+    }
+  }
+
+  Int_t mask = (AliFMDParameters::kDeadMap|
+               AliFMDParameters::kZeroSuppression|
+               AliFMDParameters::kAltroMap);
+
+
+  if (!gotConds) mask |= AliFMDParameters::kStripRange;
+  if (!gotConds) mask |= AliFMDParameters::kSampleRate;
+  if (!gotPeds)  mask |= AliFMDParameters::kPedestal;
+  if (!gotGains) mask |= AliFMDParameters::kPulseGain;
+
+  AliFMDParameters* pars = AliFMDParameters::Instance();
+  pars->Init(kFALSE, mask);
+
+  if (gotConds) pars->SetStripRange(range);
+  if (gotConds) pars->SetSampleRate(rate);
+  if (gotPeds)  pars->SetPedestal(peds);
+  if (gotGains) pars->SetGain(gains);
   
   AliFMDSpectraDisplay* d = new AliFMDSpectraDisplay;
   d->AddLoad(AliFMDInput::kRaw);