Bug fixed in AliMUONCDB::WriteTracker (Laurent)
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 4 Sep 2007 13:33:28 +0000 (13:33 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 4 Sep 2007 13:33:28 +0000 (13:33 +0000)
MUON/AliMUONCDB.cxx
MUON/AliMUONCDB.h

index 5e964969c9cd0b39abbfb226fc0c9d2616676de7..33dff82ed5234c3c1349c58c358fb1a85618b8bf 100644 (file)
@@ -47,6 +47,7 @@
 #include "AliMUONVStore.h"
 #include "AliMUONVCalibParam.h"
 #include "AliMUONVCalibParam.h"
+#include "AliMpCDB.h"
 #include "AliMpConstants.h"
 #include "AliMpDDLStore.h"
 #include "AliMpDEIterator.h"
@@ -170,6 +171,9 @@ AliMUONCDB::ManuList()
   if (!fManuList) 
   {
     AliInfo("Generating ManuList...");
+    AliCDBManager::Instance()->SetDefaultStorage(fCDBPath);
+    AliMpCDB::LoadMpSegmentation();
+    AliMpCDB::LoadDDLStore();
     fManuList = AliMpManuList::ManuList();
     AliInfo("Manu List generated.");
   }
@@ -450,6 +454,56 @@ AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues
   
 }
 
+//_____________________________________________________________________________
+Int_t
+AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file)
+{
+  ifstream in(gSystem->ExpandPathName(file));
+  if (in.bad()) return 0;
+  
+  Int_t ngenerated(0);
+  
+  char line[1024];
+  Int_t serialNumber(-1);
+  AliMUONVCalibParam* param(0x0);
+  
+  while ( in.getline(line,1024,'\n') )
+  {
+    if ( isdigit(line[0]) ) 
+    {
+      serialNumber = atoi(line);
+      param = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber));
+      if (param)
+      {
+        AliError(Form("serialNumber %d appears several times !",serialNumber));
+        capaStore.Clear();
+        break;
+      }
+      param = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
+      Bool_t ok = capaStore.Add(param);
+      if (!ok)
+      {
+        AliError(Form("Could not set serialNumber=%d",serialNumber));
+        continue;
+      }      
+      continue;
+    }
+    Int_t channel;
+    Float_t capaValue;
+    Float_t injectionGain;
+    sscanf(line,"%d %f %f",&channel,&capaValue,&injectionGain);
+    AliDebug(1,Form("SerialNumber %10d Channel %3d Capa %f injectionGain %f",
+                    serialNumber,channel,capaValue,injectionGain));
+    param->SetValueAsFloat(channel,0,capaValue);
+    param->SetValueAsFloat(channel,1,injectionGain);
+    ++ngenerated;
+  }
+  
+  in.close();
+  
+  return ngenerated;
+}
+
 //_____________________________________________________________________________
 Int_t 
 AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
@@ -466,8 +520,10 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
   Int_t nmanus(0);
   Int_t nmanusOK(0); // manus for which we got the serial number
     
-  const Float_t kCapaMean(1.0);
-  const Float_t kCapaSigma(0.5);
+  const Float_t kCapaMean(0.3);
+  const Float_t kCapaSigma(0.1);
+  const Float_t kInjectionGainMean(3);
+  const Float_t kInjectionGainSigma(1);
   
   while ( ( p = (AliMpIntPair*)next() ) )
   {
@@ -490,7 +546,7 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
     
     if (!capa)
     {
-      capa = new AliMUONCalibParamNF(1,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
+      capa = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
       Bool_t ok = capaStore.Add(capa);
       if (!ok)
       {
@@ -506,16 +562,20 @@ AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
       ++nchannels;
       
       Float_t capaValue;
+      Float_t injectionGain;
       
       if ( defaultValues ) 
       {
         capaValue = 1.0;
+        injectionGain = 1.0;
       }
       else
       {
         capaValue = GetRandom(kCapaMean,kCapaSigma,kTRUE);
+        injectionGain = GetRandom(kInjectionGainMean,kInjectionGainSigma,kTRUE);
       }
       capa->SetValueAsFloat(manuChannel,0,capaValue);
+      capa->SetValueAsFloat(manuChannel,1,injectionGain);
     }
   }
   
@@ -697,6 +757,24 @@ AliMUONCDB::MakeTriggerEfficiency(const char* file) const
   return new AliMUONTriggerEfficiencyCells(file);
 }
 
+//_____________________________________________________________________________
+void 
+AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object, 
+                       Int_t startRun, Int_t endRun, 
+                       const char* filename)
+{
+  /// Write a given object to OCDB
+  
+  AliCDBId id(calibpath,startRun,endRun);
+  AliCDBMetaData md;
+  md.SetAliRootVersion(gROOT->GetVersion());
+  md.SetComment(gSystem->ExpandPathName(filename));
+  md.SetResponsible("Uploaded using AliMUONCDB class");
+  AliCDBManager* man = AliCDBManager::Instance();
+  man->SetDefaultStorage(fCDBPath);
+  man->Put(object,id,&md);
+}
+
 //_____________________________________________________________________________
 void 
 AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object, 
@@ -958,6 +1036,25 @@ AliMUONCDB::WriteGains(Bool_t defaultValues,
   delete gainStore;
 }
 
+//_____________________________________________________________________________
+void 
+AliMUONCDB::WriteCapacitances(const char* filename,
+                              Int_t startRun, Int_t endRun)
+{
+  /// read manu capacitance and injection gain values from file 
+  /// and store them into CDB located at cdbpath, with a validity period
+  /// ranging from startRun to endRun
+  
+  AliMUONVStore* capaStore = new AliMUON1DMap(16828);
+  Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename);
+  AliInfo(Form("Ngenerated = %d",ngenerated));
+  if ( ngenerated > 0 ) 
+  {
+    WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename);
+  }
+  delete capaStore;
+}
+
 //_____________________________________________________________________________
 void 
 AliMUONCDB::WriteCapacitances(Bool_t defaultValues,
index 1e560449274855a51b1f6632ba7ae9bb5d802cce..3ce7aab7a89d8f4ddc50a43afca91e216e601085 100644 (file)
@@ -39,6 +39,7 @@ public:
   Int_t MakeHVStore(TMap& aliasMap, Bool_t defaultValues);
   Int_t MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues);
   Int_t MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues);
+  Int_t MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file);
   Int_t MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues);
   
   Int_t MakeLocalTriggerMaskStore(AliMUONVStore& ltm) const;
@@ -55,6 +56,8 @@ public:
 
   void WriteToCDB(const char* calibpath, TObject* object, 
                   Int_t startRun, Int_t endRun, Bool_t defaultValues);
+  void WriteToCDB(const char* calibpath, TObject* object, 
+                  Int_t startRun, Int_t endRun, const char* filename);
 
   void WriteTrigger(Int_t startRun=0,Int_t endRun=ALIMUONCDBINFINITY);
   void WriteTracker(Bool_t defaultValues=kTRUE, Int_t startRun=0,Int_t endRun=ALIMUONCDBINFINITY);
@@ -64,6 +67,7 @@ public:
   void WritePedestals(Bool_t defaultValues, Int_t startRun, Int_t endRun=ALIMUONCDBINFINITY);
   void WriteGains(Bool_t defaultValues, Int_t startRun, Int_t endRun=ALIMUONCDBINFINITY);
   void WriteCapacitances(Bool_t defaultValues, Int_t startRun=0, Int_t endRun=ALIMUONCDBINFINITY);
+  void WriteCapacitances(const char* file, Int_t startRun=0, Int_t endRun=ALIMUONCDBINFINITY);
   
   void WriteLocalTriggerMasks(Int_t startRun=0, Int_t endRun=ALIMUONCDBINFINITY);
   void WriteRegionalTriggerMasks(Int_t startRun=0, Int_t endRun=ALIMUONCDBINFINITY);