- Splitting the creation of ped, gains and deadchannels containers which used to be
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Oct 2006 16:02:48 +0000 (16:02 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Oct 2006 16:02:48 +0000 (16:02 +0000)
  in the same function.
- Added a diff function to compute the difference of calibration between 2 runs
(Laurent)

MUON/MUONCDB.C
MUON/MUONCDB.h

index 25d72d8..b7287ea 100644 (file)
 #include "AliMUONCalibParam1I.h"
 #include "AliMUONCalibParam2F.h"
 #include "AliMUONConstants.h"
+#include "AliMUONObjectPair.h"
+#include "AliMUONTriggerEfficiencyCells.h"
 #include "AliMUONTriggerLut.h"
 #include "AliMUONV2DStore.h"
 #include "AliMUONVCalibParam.h"
+#include "AliMUONVDataIterator.h"
 #include "AliMpDEIterator.h"
 #include "AliMpDEManager.h"
+#include "AliMpManuList.h"
 #include "AliMpSegFactory.h"
 #include "AliMpStationType.h"
 #include "AliMpVSegmentation.h"
-#include "AliMUONTriggerEfficiencyCells.h"
 #include "Riostream.h"
 #include "TH1F.h"
 #include "TList.h"
@@ -106,12 +109,12 @@ void countChannels()
 }
 
 //_____________________________________________________________________________
-AliMUONV2DStore* read2D(const char* calibType)
+AliMUONV2DStore* read2D(const char* calibType, Int_t runNumber)
 {
   AliCDBManager* man = AliCDBManager::Instance();
   man->SetDefaultStorage(CDBPath);
 
-  AliCDBEntry* entry = man->Get(calibType,0);
+  AliCDBEntry* entry = man->Get(calibType,runNumber);
 
   if (entry)
     {
@@ -121,12 +124,12 @@ AliMUONV2DStore* read2D(const char* calibType)
 }
 
 //_____________________________________________________________________________
-AliMUONV1DStore* read1D(const char* calibType)
+AliMUONV1DStore* read1D(const char* calibType, Int_t runNumber)
 {
   AliCDBManager* man = AliCDBManager::Instance();
   man->SetDefaultStorage(CDBPath);
   
-  AliCDBEntry* entry = man->Get(calibType,0);
+  AliCDBEntry* entry = man->Get(calibType,runNumber);
   
   if (entry)
   {
@@ -149,7 +152,8 @@ void checkCDB(const char* calibType)
   AliMUONV2DStore* store = read2D(calibType);
   if (!store) return;
   
-  TIter next(manuList());
+  TList* list = AliMpManuList::ManuList();
+  TIter next(list);
   AliMpIntPair* p;
   
   while ( ( p = (AliMpIntPair*)next() ) )
@@ -180,45 +184,160 @@ void checkCDB(const char* calibType)
     }
   }
   
+  delete list;
   delete store;
 }
 
+//_____________________________________________________________________________
+//void testDump(AliMUONV2DStore& store, int n)
+//{  
+//  AliMUONObjectPair* p;
+//  
+//  Int_t c(0);
+//  
+//  for ( Int_t i = 0; i < n; ++i )
+//  {
+//    AliMUONVDataIterator* it = store.Iterator();
+//    
+//    while ( ( p = dynamic_cast<AliMUONObjectPair*>(it->Next() ) ) )
+//    {
+//      AliMpIntPair* dm = dynamic_cast<AliMpIntPair*>(p->Key());
+//      if (dm)
+//      {
+//        Int_t a(dm->GetFirst()+dm->GetSecond());
+//        a=2;
+//        ++c;
+//        AliMUONVCalibParam* param = dynamic_cast<AliMUONVCalibParam*>(p->Value());
+//      }
+//      delete p;
+//    }
+//    delete it;
+//  }
+//    
+//  cout << c << endl;
+//}
 
 //_____________________________________________________________________________
-void plotCDB(const char* calibType)
+AliMUONV2DStore* diff(AliMUONV2DStore& store1, AliMUONV2DStore& store2, 
+                      const char* /* opt */)
 {
-  TString c(calibType);
+  // creates a store which contains store1-store2
+  // if opt="abs" the difference is absolute one,
+  // if opt="rel" then what is stored is (store1-store2)/store1
   
-  TH1* h = 0;
-  TH1* h2 = 0;
+  AliMUONV2DStore* d = static_cast<AliMUONV2DStore*>(store1.Clone());
+
+  AliMUONVDataIterator* it = d->Iterator();
+  
+  AliMUONObjectPair* p;
   
-  if ( c == "MUON/Calib/Gains" )
+  while ( ( p = dynamic_cast<AliMUONObjectPair*>(it->Next() ) ) )
   {
-    h = new TH1F("gains_mean","mean gain",100,0,1.5);
-    h2 = new TH1F("saturation","adc saturation",4096,-0.5,4095.5);
+    AliMpIntPair* dm = dynamic_cast<AliMpIntPair*>(p->Key());
+    //FIXME: this might happen (if a full manu is missing, for instance)
+    //handle it.
+    assert(dm!=0);
+    AliMUONVCalibParam* param = dynamic_cast<AliMUONVCalibParam*>(p->Value());
+    //FIXMENOT: this should *not* happen
+    assert(param!=0);
+
+    AliMUONVCalibParam* param2 = dynamic_cast<AliMUONVCalibParam*>(store2.Get(dm->GetFirst(),dm->GetSecond()));
+    //FIXME: this might happen. Handle it.
+    assert(param2!=0);
+    
+    for ( Int_t i = 0; i < param->Size(); ++i )
+    {
+      for ( Int_t j = 0; j < param->Dimension(); ++j )
+      {
+        param->SetValueAsFloat(i,j,param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j));
+      }      
+    }
   }
-  else if ( c == "MUON/Calib/Pedestals" )
+  return d;
+}
+
+//_____________________________________________________________________________
+void getBoundaries(const AliMUONV2DStore& store,
+                   Float_t& x0min, Float_t& x0max,
+                   Float_t& x1min, Float_t& x1max)
+{
+  x0min=1E30;
+  x0max=-1E30;
+  x1min=1E30;
+  x1max=-1E30;
+  
+  TList* list = AliMpManuList::ManuList();
+  TIter next(list);
+  AliMpIntPair* p;
+  
+  while ( ( p = (AliMpIntPair*)next() ) )
   {
-    h = new TH1F("pedestals_mean","pedestals_mean",4096,-0.5,4095.5);
-    h2 = new TH1F("pedestals_sigma","pedestals_sigma",100,0,20);
+    Int_t detElemId = p->GetFirst();
+    Int_t manuId = p->GetSecond();
+        
+    AliMpVSegmentation* seg = 
+      segFactory()->CreateMpSegmentationByElectronics(detElemId,manuId);
+          
+    AliMUONVCalibParam* value = 
+      dynamic_cast<AliMUONVCalibParam*>(store.Get(detElemId,manuId));
+    
+    if (!value) continue;
+
+    for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel )
+    {
+      AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
+      if (!pad.IsValid()) continue;
+
+      Float_t x0 = value->ValueAsFloat(manuChannel,0);
+      
+      x0min = TMath::Min(x0min,x0);
+      x0max = TMath::Max(x0max,x0);
+      if ( value->Dimension()>1 )
+      {
+        Float_t x1 = value->ValueAsFloat(manuChannel,1);
+        x1min = TMath::Min(x1min,x1);
+        x1max = TMath::Max(x1max,x1);
+      }
+    }
+  }  
+  delete list;
+}
+
+//_____________________________________________________________________________
+void plot(const AliMUONV2DStore& store, const char* name, Int_t nbins)
+{
+  Float_t x0min, x0max, x1min, x1max;
+  
+  getBoundaries(store,x0min,x0max,x1min,x1max);
+  
+  if ( x0min > x0max ) 
+  {
+    cerr << Form("Something is wrong with boundaries : x0(min,max)=%e,%e",
+                 x0min,x0max) << endl;
+    return;
   }
-  else if ( c == "MUON/Calib/DeadChannels" )
+
+  if ( TMath::Abs(x0min-x0max) < 1E-3 ) 
   {
-    h = new TH1F("dead_channels","dead channels per DE",1500,-0.5,1499.5);
+    x0min -= 1;
+    x0max += 1;
   }
-  else
+  
+  TH1* h0 = new TH1F(Form("%s_0",name),Form("%s_0",name),
+                    nbins,x0min,x0max);
+  
+  TH1* h1(0);
+  
+  if ( x1max > x1min )
   {
-    cerr << "Don't know how to deal with " << calibType << endl;
-    return;
+    h1 = new TH1F(Form("%s_1",name),Form("%s_1",name),
+                  nbins,x1min,x1max);
   }
   
-  AliMUONV2DStore* store = read2D(calibType);
-  if (!store) return;
-
-  TIter next(manuList());
+  TList* list = AliMpManuList::ManuList();
+  TIter next(list);
   AliMpIntPair* p;
   Int_t n(0);
-  Int_t ndead(0);
   Int_t nPerStation[7];
   
   for ( Int_t i = 0; i < 7; ++i ) nPerStation[i]=0;
@@ -229,34 +348,33 @@ void plotCDB(const char* calibType)
     Int_t manuId = p->GetSecond();
     Int_t station = AliMpDEmanager::GetChamberId(detElemId);
     
+    AliMpVSegmentation* seg = 
+      segFactory()->CreateMpSegmentationByElectronics(detElemId,manuId);
+    
     AliMUONVCalibParam* value = 
-    dynamic_cast<AliMUONVCalibParam*>(store->Get(detElemId,manuId));
+      dynamic_cast<AliMUONVCalibParam*>(store.Get(detElemId,manuId));
     
     if (value)
     {
       for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel )
       {
+        AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
+        if (!pad.IsValid()) continue;
+
         ++n;
         ++nPerStation[station];
-        if (h2)
+        Float_t x = value->ValueAsFloat(manuChannel,0);
+        h0->Fill(x);
+        if (h1)
         {
-          h->Fill(value->ValueAsFloat(manuChannel,0));
-          h2->Fill(value->ValueAsFloat(manuChannel,1));
-        }
-        else
-        {
-          if( value->ValueAsInt(manuChannel) )
-          {
-            h->Fill(detElemId);
-            ++ndead;
-          }
+          h1->Fill(value->ValueAsFloat(manuChannel,1));
         }
       }
     }
     else
     {
       cout << "Got a null value for DE=" << detElemId << " manuId="
-        << manuId << endl;
+      << manuId << endl;
     }
   }
   
@@ -266,17 +384,28 @@ void plotCDB(const char* calibType)
     cout << "Station " << (i+1) << " " << nPerStation[i] << endl;
   }
   
-  if (n && c == "MUON/Calib/DeadChannels")
-  {
-    cout << "Number of dead channels=" << ndead << endl;
-  }
+  delete list;
+}
+
+//_____________________________________________________________________________
+void plotCDB(const char* calibType, Int_t runNumber)
+{
+  AliMUONV2DStore* store = read2D(calibType,runNumber);
+  if (!store) return;
+
+  TString c(calibType);
+  c.ReplaceAll("/","_");
+  
+  plot(*store,c.Data());
+  
   delete store;
 }
 
 //_____________________________________________________________________________
 void testReadStore(const AliMUONV2DStore& store, Int_t n)
 {
-  TIter next(manuList());
+  TList* list = AliMpManuList::ManuList();
+  TIter next(list);
   AliMpIntPair* p;
   
   while ( ( p = (AliMpIntPair*)next() ) )
@@ -286,156 +415,222 @@ void testReadStore(const AliMUONV2DStore& store, Int_t n)
       store.Get(p->GetFirst(),p->GetSecond());
     }
   }
+  delete list;
 } 
 
 //_____________________________________________________________________________
-Int_t makeStores(AliMUONV2DStore& pedestalStore,
-                 AliMUONV2DStore& gainStore,
-                 AliMUONV2DStore& deadStore,
-                 Bool_t defaultValues)
-{  
-  TIter next(manuList());
+Int_t makePedestalStore(AliMUONV2DStore& pedestalStore, Bool_t defaultValues)
+{
+  TList* list = AliMpManuList::ManuList();
+  TIter next(list);
   
   AliMpIntPair* p;
   
-  Int_t ngenerated(0);
+  Int_t nchannels(0);
+  Int_t nmanus(0);
   
   Bool_t replace = kFALSE;
   
   const Int_t nChannels(64);
+  const Float_t kPedestalMeanMean(150);
+  const Float_t kPedestalMeanSigma(10);
+  const Float_t kPedestalSigmaMean(1.0);
+  const Float_t kPedestalSigmaSigma(0.2);
   
   while ( ( p = (AliMpIntPair*)next() ) )
   {
-    AliMUONVCalibParam* ped = new AliMUONCalibParam2F(nChannels);
-    AliMUONVCalibParam* gain = new AliMUONCalibParam2F(nChannels);
-    AliMUONVCalibParam* dead = new AliMUONCalibParam1I(nChannels);
-
+    ++nmanus;
+    AliMUONVCalibParam* ped = new AliMUONCalibParam2F(nChannels,AliMUONVCalibParam::InvalidFloatValue());
+    
+    Int_t detElemId = p->GetFirst();
+    
+    if ( detElemId / 100 == 1 || detElemId / 1000 == 1 ) continue;
+    
+    if ( detElemId == 501 || detElemId == 903 ) continue;
+    
+    Int_t manuId = p->GetSecond();
+    
+    if ( manuId == 4 && detElemId / 700 > 0 ) continue;
+    
+    AliMpVSegmentation* seg = 
+      segFactory()->CreateMpSegmentationByElectronics(detElemId,manuId);
+    
     for ( Int_t manuChannel = 0; manuChannel < nChannels; ++manuChannel )
     {
+      AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
+      if (!pad.IsValid()) continue;
+      
+      ++nchannels;
+      
       Float_t meanPedestal;
       Float_t sigmaPedestal;
-      Float_t meanGain;
-      Float_t saturation(3000);
-    
+      
       if ( defaultValues ) 
       {
         meanPedestal = 0.0;
         sigmaPedestal = 1.0;
-        meanGain = 1.0;
       }
       else
       {
         meanPedestal = -1;
         while ( meanPedestal < 0 )
         {
-          meanPedestal = gRandom->Gaus(150,10);
+          meanPedestal = gRandom->Gaus(kPedestalMeanMean,kPedestalMeanSigma);
         }
         sigmaPedestal = -1;
         while ( sigmaPedestal < 0 )
         {
-          sigmaPedestal = gRandom->Gaus(1,0.2);
-        }
-        meanGain = -1;
-        while ( meanGain < 0 )
-        {
-          meanGain = gRandom->Gaus(1,0.05);
+          sigmaPedestal = gRandom->Gaus(kPedestalSigmaMean,kPedestalSigmaSigma);
         }
       }
       ped->SetValueAsFloat(manuChannel,0,meanPedestal);
       ped->SetValueAsFloat(manuChannel,1,sigmaPedestal);
-      gain->SetValueAsFloat(manuChannel,0,meanGain);
-      gain->SetValueAsFloat(manuChannel,1,saturation);
       
-      if (!defaultValues)
+    }
+    Bool_t ok = pedestalStore.Set(detElemId,manuId,ped,replace);
+    if (!ok)
+    {
+      cout << "Could not set DetElemId=" << detElemId << " manuId="
+      << manuId << endl;
+    }
+  }
+  
+  delete list;
+  cout << nmanus << " Manus and " << nchannels << " channels." << endl;
+  return nchannels;
+  
+}
+
+//_____________________________________________________________________________
+Int_t makeGainStore(AliMUONV2DStore& gainStore, Bool_t defaultValues)
+{  
+  TList* list = AliMpManuList::ManuList();
+  TIter next(list);
+  
+  AliMpIntPair* p;
+  
+  Int_t nchannels(0);
+  Int_t nmanus(0);
+  
+  Bool_t replace = kFALSE;
+  
+  const Int_t nChannels(64);
+  const Double_t kSaturation(3000);
+  const Double_t kGainMean(1.0);
+  const Double_t kGainSigma(0.05);
+  
+  while ( ( p = (AliMpIntPair*)next() ) )
+  {
+    ++nmanus;
+    AliMUONVCalibParam* gain = new AliMUONCalibParam2F(nChannels,AliMUONVCalibParam::InvalidFloatValue());
+
+    Int_t detElemId = p->GetFirst();
+    Int_t manuId = p->GetSecond();
+
+    AliMpVSegmentation* seg = 
+      segFactory()->CreateMpSegmentationByElectronics(detElemId,manuId);
+
+    for ( Int_t manuChannel = 0; manuChannel < nChannels; ++manuChannel )
+    {
+      AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
+      if (!pad.IsValid()) continue;
+      
+      ++nchannels;
+      
+      Float_t meanGain;
+      Float_t saturation(kSaturation);
+    
+      if ( defaultValues ) 
       {
-        // probability that this channel is dead ~ 1%
-        if ( gRandom->Uniform(100.0) < 1.0 ) 
+        meanGain = 1.0;
+      }
+      else
+      {
+        meanGain = -1;
+        while ( meanGain < 0 )
         {
-          Int_t reason = 5; // that value could be used to distinguish
-          // why the channel is dead or how it was flagged bad (online,
-          // offline, by chance...). 5 is of course a fake number.
-          dead->SetValueAsInt(manuChannel,0,reason);
+          meanGain = gRandom->Gaus(kGainMean,kGainSigma);
         }
       }
+      gain->SetValueAsFloat(manuChannel,0,meanGain);
+      gain->SetValueAsFloat(manuChannel,1,saturation);
+      
     }
-    Int_t detElemId = p->GetFirst();
-    Int_t manuId = p->GetSecond();
-    Bool_t ok1 = pedestalStore.Set(detElemId,manuId,ped,replace);
-    Bool_t ok2 = gainStore.Set(detElemId,manuId,gain,replace);
-    Bool_t ok3 = deadStore.Set(detElemId,manuId,dead,replace);
-    if (!ok1 || !ok2 || !ok3)
+    Bool_t ok = gainStore.Set(detElemId,manuId,gain,replace);
+    if (!ok)
     {
       cout << "Could not set DetElemId=" << detElemId << " manuId="
         << manuId << endl;
     }
-    else
-    {
-      ++ngenerated;
-    }
   }
   
-  return ngenerated;
+  delete list;
+  cout << nmanus << " Manus and " << nchannels << " channels." << endl;
+  return nchannels;
 }
 
 //_____________________________________________________________________________
-TList* manuList(Bool_t reset)
-{
-  static TList* fgmanuList = new TList;
-  
-  if (reset) 
-  {
-    fgmanuList->Delete();
-    return fgmanuList;
-  }
-  
-  if (!fgmanuList->IsEmpty()) return fgmanuList;
-  
-  TStopwatch timer;
-  
-  cout << "Generating manu list. Please wait" << endl;
+Int_t makeDeadStore(AliMUONV2DStore& deadStore, Bool_t defaultValues)
+{  
+  TList* list = AliMpManuList::ManuList();
+  TIter next(list);
   
-  fgmanuList->SetOwner(kTRUE);
+  AliMpIntPair* p;
   
-  timer.Start();
+  Int_t nchannels(0);
+  Int_t nmanus(0);
   
-  AliMpDEIterator it;
+  Bool_t replace = kFALSE;
   
-  it.First();
+  const Int_t nChannels(64);
+  const Double_t deadProba = 1.0; // 1%
   
-  while ( !it.IsDone() )
+  while ( ( p = (AliMpIntPair*)next() ) )
   {
-    Int_t detElemId = it.CurrentDE();
-    AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
-    if ( stationType != kStationTrigger ) 
+    ++nmanus;
+    AliMUONVCalibParam* dead = new AliMUONCalibParam1I(nChannels,-9999);
+    
+    Int_t detElemId = p->GetFirst();
+    Int_t manuId = p->GetSecond();
+    
+    AliMpVSegmentation* seg = 
+      segFactory()->CreateMpSegmentationByElectronics(detElemId,manuId);
+    
+    for ( Int_t manuChannel = 0; manuChannel < nChannels; ++manuChannel )
     {
-      for ( Int_t cath = 0; cath <=1 ; ++cath )
+      AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,manuChannel),kFALSE);
+      if (!pad.IsValid()) continue;
+      
+      ++nchannels;
+            
+      if (!defaultValues)
       {
-        AliMpVSegmentation* seg = segFactory()->CreateMpSegmentation(detElemId,cath);
-        
-        TArrayI manus;
-        
-        seg->GetAllElectronicCardIDs(manus);
-        
-        for ( Int_t im = 0; im < manus.GetSize(); ++im )
+        // probability that this channel is dead ~ 1%
+        if ( gRandom->Uniform(100.0) < deadProba ) 
         {
-          fgmanuList->Add(new AliMpIntPair(detElemId,manus[im]));
-        }        
+          Int_t reason = 5; // that value could be used to distinguish
+                            // why the channel is dead or how it was flagged bad (online,
+                            // offline, by chance...). 5 is of course a fake number.
+          dead->SetValueAsInt(manuChannel,0,reason);
+        }
       }
     }
-    it.Next();
+    Bool_t ok = deadStore.Set(detElemId,manuId,dead,replace);
+    if (!ok)
+    {
+      cout << "Could not set DetElemId=" << detElemId << " manuId="
+      << manuId << endl;
+    }
   }
   
-  cout << "Time to make the manu list = ";
-  timer.Print();
-  
-  return fgmanuList;
+  delete list;
+  cout << nmanus << " Manus and " << nchannels << " channels." << endl;
+  return nchannels;
 }
 
 //_____________________________________________________________________________
 void testMakeStores(Int_t readLoop)
 {
-  manuList();
-  
   AliMUONV2DStore* pedestalStore = new AliMUON2DMap;
   AliMUONV2DStore* gainStore = new AliMUON2DMap;
   AliMUONV2DStore* deadStore = new AliMUON2DMap;
@@ -444,8 +639,12 @@ void testMakeStores(Int_t readLoop)
   
   cout << "Creating" << endl;
   
+  Bool_t defaultValues = kTRUE;
+  
   timer.Start(kTRUE);
-  makeStores(*pedestalStore,*gainStore,*deadStore,true);
+  makePedestalStore(*pedestalStore,defaultValues);
+  makeGainStore(*gainStore,defaultValues);
+  makeDeadStore(*deadStore,defaultValues);
   timer.Print();
   
   cout << "Reading..." << endl;
@@ -556,22 +755,12 @@ void generateTrigger(const char* cdbpath)
   delete globalBoardMasks;
 }
 
+
 //_____________________________________________________________________________
-void generateCalibrations(const char* cdbpath, Bool_t defaultValues)
+void writeToCDB(const char* cdbpath, const char* calibpath, TObject* object, 
+                Int_t startRun, Int_t endRun, Bool_t defaultValues)
 {
-  //
-  //
-  //
-
-  AliMUONV2DStore* pedestalStore = new AliMUON2DMap;
-  AliMUONV2DStore* gainStore = new AliMUON2DMap;
-  AliMUONV2DStore* deadStore = new AliMUON2DMap; 
-  
-  makeStores(*pedestalStore,*gainStore,*deadStore,defaultValues);
-  
-  Int_t ever = 99999999;
-  
-  AliCDBId id("MUON/Calib/Pedestals",0,ever);
+  AliCDBId id(calibpath,startRun,endRun);
   AliCDBMetaData md;
   md.SetBeamPeriod(1);
   md.SetAliRootVersion(gROOT->GetVersion());
@@ -587,19 +776,40 @@ void generateCalibrations(const char* cdbpath, Bool_t defaultValues)
   
   AliCDBManager* man = AliCDBManager::Instance();
   man->SetDefaultStorage(cdbpath);
-  man->Put(pedestalStore,id,&md);
-  
-  id.SetPath("MUON/Calib/Gains");
-  
-  man->Put(gainStore,id,(AliCDBMetaData*)md.Clone());
+  man->Put(object,id,&md);
+}
+
+//_____________________________________________________________________________
+void writePedestals(const char* cdbpath, Bool_t defaultValues,
+                    Int_t startRun, Int_t endRun)
+{
+  AliMUONV2DStore* pedestalStore = new AliMUON2DMap;
+  Int_t ngenerated = makePedestalStore(*pedestalStore,defaultValues);
+  cout << "Ngenerated = " << ngenerated << endl;
   
-  id.SetPath("MUON/Calib/DeadChannels");
+  writeToCDB(cdbpath,"MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues);
+}
+
+//_____________________________________________________________________________
+void writeGains(const char* cdbpath, Bool_t defaultValues,
+                    Int_t startRun, Int_t endRun)
+{
+  AliMUONV2DStore* gainStore = new AliMUON2DMap;
+  Int_t ngenerated = makeGainStore(*gainStore,defaultValues);
+  cout << "Ngenerated = " << ngenerated << endl;
   
-  man->Put(deadStore,id,(AliCDBMetaData*)md.Clone());
+  writeToCDB(cdbpath,"MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues);
+}
+
+//_____________________________________________________________________________
+void writeDeadChannels(const char* cdbpath, Bool_t defaultValues,
+                       Int_t startRun, Int_t endRun)
+{
+  AliMUONV2DStore* deadStore = new AliMUON2DMap;
+  Int_t ngenerated = makeDeadStore(*deadStore,defaultValues);
+  cout << "Ngenerated = " << ngenerated << endl;
   
-  delete deadStore;
-  delete pedestalStore;
-  delete gainStore;
+  writeToCDB(cdbpath,"MUON/Calib/DeadChannels",deadStore,startRun,endRun,defaultValues);
 }
 
 
index 8092212..4d13a66 100644 (file)
@@ -12,19 +12,36 @@ class TList;
 class AliMUONV1DStore;
 class AliMUONV2DStore;
 
-static const char* CDBPath = "local://$ALICE_ROOT/";
+static const char* CDBPath = "local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB";
 
 void generateTrigger(const char* cdbpath=CDBPath);
 
-void generateCalibrations(const char* cdbpath=CDBPath, Bool_t defaultValues = kTRUE);
+void getBoundaries(const AliMUONV2DStore& store,
+                   Float_t& x0min, Float_t& x0max,
+                   Float_t& x1min, Float_t& x1max);
 
-TList* manuList(Bool_t reset=kFALSE);
+void plot(const AliMUONV2DStore& store, const char* name, Int_t nbins=512);
 
-void plotCDB(const char* calibType="MUON/Calib/Pedestals");
+void plotCDB(const char* calibType="MUON/Calib/Pedestals", Int_t runNumber=0);
 
-AliMUONV2DStore* read2D(const char* calibType="MUON/Calib/Pedestals");
-AliMUONV1DStore* read1D(const char* calibType="MUON/Calib/LocalBoardMasks");
+AliMUONV2DStore* diff(AliMUONV2DStore& store1, AliMUONV2DStore& store2, const char* opt="abs");
+
+AliMUONV2DStore* read2D(const char* calibType="MUON/Calib/Pedestals", Int_t runNumber=0);
+
+AliMUONV1DStore* read1D(const char* calibType="MUON/Calib/LocalBoardMasks", Int_t runNumber=0);
 
 void testMakeStores(Int_t readLoop=10);
 
+void writeToCDB(const char* cdbpath, const char* calibpath, TObject* object, 
+                Int_t startRun, Int_t endRun, Bool_t defaultValues);
+
+void writePedestals(const char* cdbpath, Bool_t defaultValues,
+                    Int_t startRun, Int_t endRun);
+
+void writeGains(const char* cdbpath, Bool_t defaultValues,
+                Int_t startRun, Int_t endRun);
+
+void writeDeadChannels(const char* cdbpath, Bool_t defaultValues,
+                       Int_t startRun, Int_t endRun);
+
 #endif