]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Implemented first version of merging for TrackerData-related objects
authorlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 8 Jul 2008 15:32:37 +0000 (15:32 +0000)
committerlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 8 Jul 2008 15:32:37 +0000 (15:32 +0000)
MUON/AliMUONPainterDataSourceItem.cxx
MUON/AliMUONSparseHisto.cxx
MUON/AliMUONSparseHisto.h
MUON/AliMUONTrackerData.cxx
MUON/AliMUONTrackerData.h
MUON/AliMUONTrackerDataWrapper.cxx
MUON/AliMUONTrackerOCDBDataMaker.cxx
MUON/AliMUONTrackerRawDataMaker.cxx
MUON/AliMUONTrackerRawDataMaker.h
MUON/AliMUONVTrackerData.h
MUON/MUONcalibLinkDef.h

index 7c7036f06976cb258b250809a2c9e593a5d5f10d..41610c8056d35275e613973fd6ccf279df183394 100644 (file)
@@ -349,7 +349,7 @@ AliMUONPainterDataSourceItem::Update()
 {
   /// Update ourselves
   
-  fNumberOfEvents->SetText(Form("%10d",fDataMaker->Data()->NumberOfEvents()));
+  fNumberOfEvents->SetText(Form("%10d",fDataMaker->Data()->NumberOfEvents(-1)));
 }
 
 //_____________________________________________________________________________
index 9a81a0ac15ab6f2569afbc51a8f2ca572e38d67c..da67adf01bbcc0bdb39023193ac6a99787c5cc8a 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "AliMUONSparseHisto.h"
 
+#include "AliLog.h"
 #include <Riostream.h>
 #include <TH1.h>
 #include <TMath.h>
@@ -81,6 +82,26 @@ AliMUONSparseHisto::~AliMUONSparseHisto()
   delete[] fArray;
 }
 
+//______________________________________________________________________________
+Bool_t 
+AliMUONSparseHisto::Add(const AliMUONSparseHisto& h)
+{
+  /// Add h to this
+
+  if ( fXmin != h.Xmin() || fXmax != h.Xmax() ) 
+  {
+    AliError("Cannot add sparse histograms with different limits !");
+    return kFALSE;
+  }
+  
+  for ( Int_t i = 0; i < h.GetNbins(); ++i ) 
+  {
+    Fill(h.GetBinContent(i));
+  }  
+  
+  return kTRUE;
+}
+
 //______________________________________________________________________________
 void 
 AliMUONSparseHisto::Clear(Option_t*)
index 2b3ea204c76edccd9d92e32c1e6905b3b4f0dc9c..817ad754f9ddee77b46b9b17929b7ee7afe1b408 100644 (file)
@@ -32,6 +32,8 @@ public:
   
   virtual ~AliMUONSparseHisto();
   
+  Bool_t Add(const AliMUONSparseHisto& h);
+  
   /// Whether this histogram has underflow values 
   /// (no way to know the number of underflow, though)
   Bool_t HasUnderflow() const { return TestBit(kUnderflow); }
index 9d26be3629bd29452a71d7088d0e680a2cd8d110..f58b8035a1cc71a2b6428d93f89fce7c9e46095c 100644 (file)
@@ -18,6 +18,7 @@
 #include "AliMUONTrackerData.h"
 
 #include "AliCodeTimer.h"
+#include "AliDAQ.h"
 #include "AliLog.h"
 #include "AliMUON1DArray.h"
 #include "AliMUON1DMap.h"
@@ -34,6 +35,7 @@
 #include "AliMpHVNamer.h"
 #include "AliMpManuIterator.h"
 #include <Riostream.h>
+#include <TClass.h>
 #include <TMath.h>
 #include <TObjArray.h>
 #include <TObjString.h>
@@ -67,7 +69,7 @@ fDEValues(0x0),
 fChamberValues(0x0),
 fPCBValues(0x0),
 fDimension(External2Internal(dimension)+fgkExtraDimension),
-fNevents(0x0),
+fNevents(0),
 fDimensionNames(new TObjArray(fDimension+fgkVirtualExtraDimension)),
 fExternalDimensionNames(new TObjArray(dimension)),
 fExternalDimension(dimension),
@@ -76,7 +78,9 @@ fHistos(0x0),
 fXmin(0.0),
 fXmax(0.0),
 fIsChannelLevelEnabled(kTRUE),
-fIsManuLevelEnabled(kTRUE)
+fIsManuLevelEnabled(kTRUE),
+fNofDDLs(0),
+fNofEventsPerDDL(0x0)
 {  
   /// ctor
   memset(fHistogramming,0,sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
@@ -102,14 +106,213 @@ AliMUONTrackerData::~AliMUONTrackerData()
   delete fExternalDimensionNames;
   delete[] fHistogramming;
   delete fHistos;
+  delete[] fNofEventsPerDDL;
 }
 
 //_____________________________________________________________________________
 Bool_t
-AliMUONTrackerData::Add(const AliMUONVStore& store)
+AliMUONTrackerData::Add(const AliMUONVStore& store, TArrayI* nevents)
 {
   /// Add the given external store to our internal store
-  return InternalAdd(store,kFALSE);
+  return InternalAdd(store,nevents,kFALSE);
+}
+
+//_____________________________________________________________________________
+Bool_t 
+AliMUONTrackerData::Add(const AliMUONTrackerData& data)
+{
+  /// Add data to *this
+  // We do this by looping on all VCalibParam stored in the various containers,
+  // and simply adding the values there.
+  // Same thing for the number of events per DDL.
+  // Same thing for sparsehistograms, if we have some.
+
+  // First cross check we have compatible objects.
+  
+  if ( fIsChannelLevelEnabled != data.fIsChannelLevelEnabled ) 
+  {
+    AliError("Incompatible IsChannelLevelEnabled status");
+    return kFALSE;
+  }
+  
+  if ( fIsManuLevelEnabled != data.fIsManuLevelEnabled ) 
+  {
+    AliError("Incompatible IsManuLevelEnabled status");
+    return kFALSE;
+  }
+  
+  if ( fIsSingleEvent != data.fIsSingleEvent ) 
+  {
+    AliError("Incompatible IsSingleEvent status");
+    return kFALSE;
+  }
+  
+  if ( fDimension != data.fDimension || fExternalDimension != data.fExternalDimension ) 
+  {
+    AliError("Incompatible dimensions");
+    return kFALSE;
+  }
+
+  if ( fNofDDLs != data.fNofDDLs ) 
+  {
+    AliError("Incompatible number of Ddls");
+    return kFALSE;
+  }
+  
+  if ( ( !fHistogramming && data.fHistogramming ) || ( fHistogramming && !data.fHistogramming ) 
+      || fXmin != data.fXmin || fXmax != data.fXmax ) 
+  {
+    AliError(Form("Incompatible histogramming (%x vs %x) (xmax = %e vs %e ; xmin = %e vs %e)",
+             fHistogramming,data.fHistogramming,fXmax,data.fXmax,fXmin,data.fXmin));
+    return kFALSE;
+  }
+
+  if ( fHistogramming )
+  {
+    for ( Int_t i = 0; i < fExternalDimension; ++i ) 
+    {
+      if ( fHistogramming[i] != data.fHistogramming[i] )
+      {
+        AliError(Form("Incompatible histogramming for external dimension %d",i));
+        return kFALSE;
+      }
+    }
+  }
+  
+  // OK. Seems we have compatible objects, so we can proceed with the actual
+  // merging...
+  
+  if ( data.fChannelValues ) 
+  {
+    Add2D(*(data.fChannelValues),*fChannelValues);
+  }
+  
+  if ( data.fManuValues ) 
+  {
+    Add2D(*(data.fManuValues),*fManuValues);
+  }
+  
+  if ( data.fPCBValues ) 
+  {
+    Add2D(*(data.fPCBValues),*fPCBValues);
+  }
+  
+  if ( data.fBusPatchValues ) 
+  {
+    Add1D(*(data.fBusPatchValues),*fBusPatchValues);
+  }
+  
+  if ( data.fDEValues ) 
+  {
+    Add1D(*(data.fDEValues),*fDEValues);
+  }
+  
+  if ( data.fChamberValues ) 
+  {
+    Add1D(*(data.fChamberValues),*fChamberValues);
+  }
+
+  for ( Int_t i = 0; i < fNofDDLs; ++i ) 
+  {
+    fNofEventsPerDDL[i] += data.fNofEventsPerDDL[i];
+  }
+  
+  if ( data.fHistos ) 
+  {
+    TIter nexthisto(data.fHistos->CreateIterator());
+    AliMUONVStore* store;
+    while ( ( store = static_cast<AliMUONVStore*>(nexthisto()) ) )
+    {
+      TIter ns(store->CreateIterator());
+      AliMUONSparseHisto* h;
+      while ( ( h = static_cast<AliMUONSparseHisto*>(ns()) ) )
+      {
+        AliMUONVStore* thisStore = static_cast<AliMUONVStore*>(fHistos->FindObject(store->GetUniqueID()));
+        
+        if (!thisStore)
+        {
+          thisStore = store->Create();
+          thisStore->SetUniqueID(store->GetUniqueID());
+          fHistos->Add(thisStore);
+        }
+        
+        AliMUONSparseHisto* mine = static_cast<AliMUONSparseHisto*>(thisStore->FindObject(h->GetUniqueID()));
+        
+        if (!mine) 
+        {
+          thisStore->Add(h);
+        }
+        else
+        {
+          mine->Add(*h);
+        }
+      }
+    }
+  }
+  
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+void 
+AliMUONTrackerData::Add2D(const AliMUONVStore& src, AliMUONVStore& dest) const
+{
+  /// Add one 2d store to another
+  
+  TIter next(src.CreateIterator());
+  AliMUONVCalibParam* p;
+  
+  while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
+  {
+    AliMUONVCalibParam* a = static_cast<AliMUONVCalibParam*>(dest.FindObject(p->ID0(),p->ID1()));
+    
+    if (!a)
+    {
+      dest.Add(static_cast<AliMUONVCalibParam*>(p->Clone()));
+    }
+    else
+    {
+      AddCalibParams(*p,*a);
+    }
+  }
+}
+
+//_____________________________________________________________________________
+void 
+AliMUONTrackerData::Add1D(const AliMUONVStore& src, AliMUONVStore& dest) const
+{
+  /// Add one 1d store to another
+  
+  TIter next(src.CreateIterator());
+  AliMUONVCalibParam* p;
+  
+  while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
+  {
+    AliMUONVCalibParam* a = static_cast<AliMUONVCalibParam*>(dest.FindObject(p->GetUniqueID()));
+    
+    if (!a)
+    {
+      dest.Add(static_cast<AliMUONVCalibParam*>(p->Clone()));
+    }
+    else
+    {
+      AddCalibParams(*p,*a);
+    }
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTrackerData::AddCalibParams(const AliMUONVCalibParam& src, AliMUONVCalibParam& dest) const
+{
+  /// Add src to dest
+  for ( Int_t i = 0; i < src.Size(); ++i ) 
+  {
+    for ( Int_t j = 0; j < src.Dimension(); ++j )
+    {
+      dest.SetValueAsFloat(i,j,src.ValueAsFloat(i,j));
+    }
+  }
 }
 
 //_____________________________________________________________________________
@@ -117,14 +320,14 @@ Bool_t
 AliMUONTrackerData::Replace(const AliMUONVStore& store)
 {
   /// Replace our values by values from the given external store
-  Bool_t rv = InternalAdd(store,kTRUE);
+  Bool_t rv = InternalAdd(store,0x0,kTRUE);
   AliMUONVTrackerData::Replace(store);
   return rv;
 }
 
 //_____________________________________________________________________________
 Bool_t
-AliMUONTrackerData::InternalAdd(const AliMUONVStore& store, Bool_t replace)
+AliMUONTrackerData::InternalAdd(const AliMUONVStore& store, TArrayI* nevents, Bool_t replace)
 {
   /// Add the given external store to our internal store
   
@@ -132,14 +335,47 @@ AliMUONTrackerData::InternalAdd(const AliMUONVStore& store, Bool_t replace)
     
   if ( !replace)
   {
-    if ( IsSingleEvent() && fNevents == 1 ) 
+    if ( IsSingleEvent() && NumberOfEvents(-1) == 1 ) 
     {
       AliError(Form("%s is supposed to be single event only",GetName()));
       return kFALSE;
     }  
-    ++fNevents;  
     NumberOfEventsChanged();
   }
+
+  if (!fNofDDLs)
+  {
+    fNofDDLs = AliDAQ::NumberOfDdls("MUONTRK");
+    fNofEventsPerDDL = new Int_t[fNofDDLs];
+    for ( Int_t i = 0; i < fNofDDLs; ++i ) 
+    {
+      fNofEventsPerDDL[i] = 0;
+    }
+  }
+    
+  if (nevents)
+  {
+    if (nevents->GetSize() != fNofDDLs ) 
+    {
+      AliError(Form("nof of ddl per event array size is incorrect : got %d, expecting %d",
+                    nevents->GetSize(),fNofDDLs));
+      return kFALSE;
+    }
+    
+    for ( Int_t i = 0 ; i < fNofDDLs; ++i ) 
+    {
+      fNofEventsPerDDL[i] += nevents->At(i);
+      fNevents = TMath::Max(fNevents,fNofEventsPerDDL[i]);
+    }
+  }
+  else
+  {
+    for ( Int_t i = 0 ; i < fNofDDLs; ++i ) 
+    {
+      ++fNofEventsPerDDL[i];
+      fNevents = TMath::Max(fNevents,fNofEventsPerDDL[i]);
+    }
+  }
   
   if (!fChamberValues)
   {
@@ -301,7 +537,7 @@ AliMUONTrackerData::BusPatch(Int_t busPatchId, Int_t dim) const
   /// Return the value of a given buspatch for a given dimension
   /// or 0 if not existing
   AliMUONVCalibParam* param = BusPatchParam(busPatchId);
-  return param ? Value(*param,0,dim) : 0.0;
+  return param ? Value(*param,0,dim,DdlIdFromBusPatchId(busPatchId)) : 0.0;
 }
 
 //_____________________________________________________________________________
@@ -365,8 +601,13 @@ AliMUONTrackerData::Chamber(Int_t chamberId, Int_t dim) const
 {
   /// Return the value fo a given chamber for a given dimension,
   /// or zero if not existing
+  
+  // FIXME: is the Value() correct wrt to number of events in the case of
+  // chamber ? Or should we do something custom at the chamber level 
+  // (as it spans several ddls) ?
+  
   AliMUONVCalibParam* param = ChamberParam(chamberId);
-  return param ? Value(*param,0,dim) : 0.0;
+  return param ? Value(*param,0,dim,DdlIdFromChamberId(chamberId)) : 0.0;
 }
 
 //_____________________________________________________________________________
@@ -437,7 +678,7 @@ AliMUONTrackerData::Channel(Int_t detElemId, Int_t manuId,
   
   AliMUONVCalibParam* param = ChannelParam(detElemId,manuId);
   
-  return param ? Value(*param,manuChannel,dim) : 0.0;
+  return param ? Value(*param,manuChannel,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
 }
 
 //_____________________________________________________________________________
@@ -471,7 +712,10 @@ AliMUONTrackerData::Clear(Option_t*)
   if ( fDEValues) fDEValues->Clear();
   if ( fChamberValues ) fChamberValues->Clear();
   if ( fHistos ) fHistos->Clear();
-  fNevents = 0;
+  for ( Int_t i = 0; i < fNofDDLs; ++i ) 
+  {
+    fNofEventsPerDDL[i] = 0;
+  }
   NumberOfEventsChanged();
 }
 
@@ -520,7 +764,7 @@ AliMUONTrackerData::DetectionElement(Int_t detElemId, Int_t dim) const
 {
   /// Return the value for a given detection element for a given dimension
   AliMUONVCalibParam* param = DetectionElementParam(detElemId);
-  return param ? Value(*param,0,dim) : 0.0;
+  return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
 
 }
 
@@ -572,6 +816,61 @@ AliMUONTrackerData::CreateDetectionElementParam(Int_t detElemId) const
   return de;
 }
 
+//_____________________________________________________________________________
+Int_t 
+AliMUONTrackerData::DdlIdFromBusPatchId(Int_t buspatchid) const
+{
+  /// Get the "local" ddlid (0..19) of a given buspatch
+  AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(buspatchid);
+  if (bp)
+  {
+    return bp->GetDdlId();
+  }
+  return -1;
+}
+
+//_____________________________________________________________________________
+Int_t 
+AliMUONTrackerData::DdlIdFromDetElemId(Int_t detelemid) const
+{
+  /// Get the "local" ddlid (0..19) of a given detection element
+  AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detelemid);
+  if (de)
+  {
+    return de->GetDdlId();
+  }
+  return -1;
+}
+
+//_____________________________________________________________________________
+Int_t 
+AliMUONTrackerData::DdlIdFromChamberId(Int_t chamberid) const
+{
+  /// Get the "local" ddlid (0..19) of a given chamber
+  /// This has no real meaning (as there are several ddls per chamber),
+  /// so we take the ddlid where we got the max number of events
+  
+  AliMpDEIterator it;
+  
+  it.First(chamberid);
+  Int_t n(0);
+  Int_t d(-1);
+  
+  while (!it.IsDone())
+  {
+    Int_t detElemId = it.CurrentDEId();
+    Int_t ddlId = DdlIdFromDetElemId(detElemId);
+    if ( NumberOfEvents(ddlId) > n ) 
+    {
+      n = NumberOfEvents(ddlId);
+      d = ddlId;
+    }
+    it.Next();
+  }
+  
+  return d;
+}
+
 //_____________________________________________________________________________
 TString 
 AliMUONTrackerData::DimensionName(Int_t dim) const
@@ -759,6 +1058,35 @@ AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
   return h;
 }
 
+//_____________________________________________________________________________
+void
+AliMUONTrackerData::GetDEManu(const AliMUONVCalibParam& param,
+                              Int_t& detElemId, Int_t& manuId) const
+{
+  /// Tries to get (detElemId,manuId) of param
+  
+  if ( param.ID1() <= 0 ) 
+  {
+    // we (probably) get a manu serial number
+    Int_t serial = param.ID0();
+    AliMpIntPair pair = AliMpDDLStore::Instance()->GetDetElemIdManu(serial);
+    detElemId = pair.GetFirst();
+    manuId = pair.GetSecond();
+    if ( !detElemId ) 
+    {
+      AliError(Form("DE %d manuId %d from serial %d is not correct !",
+                    detElemId,manuId,serial));
+    }
+  }
+  else
+  {
+    // we get a (de,manu) pair
+    detElemId = param.ID0();
+    manuId = param.ID1();
+  }
+}
+
+
 //_____________________________________________________________________________
 Int_t
 AliMUONTrackerData::GetParts(AliMUONVCalibParam* external,
@@ -777,27 +1105,8 @@ AliMUONTrackerData::GetParts(AliMUONVCalibParam* external,
   Int_t detElemId;
   Int_t manuId;
   
-  if ( external->ID1() <= 0 ) 
-  {
-    // we get a manu serial number
-    Int_t serial = external->ID0();
-    AliMpIntPair pair = ddlStore->GetDetElemIdManu(serial);
-    detElemId = pair.GetFirst();
-    manuId = pair.GetSecond();
-    if ( !detElemId ) 
-    {
-      AliError(Form("DE %d manuId %d from serial %d is not correct !",
-                    detElemId,manuId,serial));
-      return -1;
-    }
-  }
-  else
-  {
-    // we get a (de,manu) pair
-    detElemId = external->ID0();
-    manuId = external->ID1();
-  }
-
+  GetDEManu(*external,detElemId,manuId);
+  
   mpde = ddlStore->GetDetElement(detElemId);
 
   Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
@@ -881,7 +1190,7 @@ AliMUONTrackerData::Manu(Int_t detElemId, Int_t manuId, Int_t dim) const
   /// Return the value for a given manu and a given dimension
   
   AliMUONVCalibParam* param = ManuParam(detElemId,manuId);
-  return param ? Value(*param,0,dim) : 0.0;
+  return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
 }
 
 //_____________________________________________________________________________
@@ -923,13 +1232,36 @@ AliMUONTrackerData::CreateManuParam(Int_t detElemId, Int_t manuId) const
 
 //_____________________________________________________________________________
 Long64_t
-AliMUONTrackerData::Merge(TCollection*)
+AliMUONTrackerData::Merge(TCollection* list)
 {
-  /// Merge all tracker data objects from li into a single one.
+  /// Merge this with a list of AliMUONVTrackerData
+
+  if (!list) return 0;
   
-  AliError("Not implemented yet");
+  if ( list->IsEmpty() ) return NumberOfEvents(-1);
+  
+  TIter next(list);
+  const TObject* o(0x0);
+  
+  while ( ( o = next() ) )
+  {
+    const AliMUONTrackerData* data = dynamic_cast<const AliMUONTrackerData*>(o);
+    if (!o)
+    {
+      AliError(Form("Object named %s is not an AliMUONTrackerData ! Skipping it",
+                    o->GetName()));
+    }
+    else
+    {
+      Bool_t ok = Add(*data);
+      if (!ok)
+      {
+        AliError("Got incompatible objects");
+      }
+    }
+  }
   
-  return 0;
+  return NumberOfEvents(-1);
 }
 
 //_____________________________________________________________________________
@@ -941,6 +1273,28 @@ AliMUONTrackerData::NumberOfDimensions() const
   return fDimension + fgkVirtualExtraDimension; 
 }
 
+//_____________________________________________________________________________
+Int_t
+AliMUONTrackerData::NumberOfEvents(Int_t ddlNumber) const
+{
+  /// Get the number of events we've seen for a given DDL, or the max
+  /// in case ddlNumber<0
+
+  Int_t n(0);
+  
+  if ( fNofEventsPerDDL && ddlNumber >= 0 && ddlNumber < fNofDDLs )
+  {
+    n = fNofEventsPerDDL[ddlNumber];
+  }
+  else
+  {
+    // get the max number of events
+    return fNevents;
+  }
+  
+  return n;
+}
+
 //_____________________________________________________________________________
 Double_t 
 AliMUONTrackerData::PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim) const
@@ -949,7 +1303,7 @@ AliMUONTrackerData::PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim) const
 
   AliMUONVCalibParam* param = PCBParam(detElemId,pcbIndex);
   
-  return param ? Value(*param,0,dim) : 0.0;
+  return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
 }
 
 //_____________________________________________________________________________
@@ -998,7 +1352,10 @@ AliMUONTrackerData::Print(Option_t* wildcard, Option_t* opt) const
   
   if ( !fIsSingleEvent ) 
   {
-    cout << " Nevents=" << fNevents << endl;
+    for ( Int_t i = 0; i < fNofDDLs; ++i ) 
+    {
+      cout << Form("DDL %04d Nevents=%10d",AliDAQ::DdlID("MUONTRK",i),fNofEventsPerDDL[i]) << endl;
+    }
   }
 
        if ( !fIsChannelLevelEnabled ) 
@@ -1163,7 +1520,8 @@ AliMUONTrackerData::SetExternalDimensionName(Int_t index, const char* value)
 
 //_____________________________________________________________________________
 Double_t 
-AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) const
+AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, 
+                          Int_t dim, Int_t ddlId) const
 {
   /// Compute the value for a given dim, using the internal information we have
   /// Basically we're converting sum of weights and sum of squares of weights
@@ -1180,7 +1538,11 @@ AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) c
     return occ;
   }
   
-  if ( dim == IndexOfOccupancyDimension() ) return occ/n/NumberOfEvents();
+  if ( dim == IndexOfOccupancyDimension() ) 
+  {
+    if ( ddlId < 0 ) AliError("Got a negative ddl id !");
+    return occ/n/NumberOfEvents(ddlId);
+  }
   
   Double_t value = param.ValueAsDouble(i,dim);
   
@@ -1212,3 +1574,31 @@ AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) c
   return 0.0;
 }
 
+//_____________________________________________________________________________
+void 
+AliMUONTrackerData::Streamer(TBuffer &R__b)
+{
+  /// Customized streamer                                                    
+  
+  if (R__b.IsReading()) {
+    AliMUONTrackerData::Class()->ReadBuffer(R__b, this);
+    if ( !fNofDDLs )
+    {
+      // backward compatible mode : we set number of events
+      // per DDL to the total number of events (the only information
+      // we had before version 7 of that class)
+      delete[] fNofEventsPerDDL;
+      fNofDDLs=20;
+      fNofEventsPerDDL = new Int_t[fNofDDLs];
+      for ( Int_t i = 0; i < fNofDDLs; ++i ) 
+      {
+        fNofEventsPerDDL[i] = fNevents;
+      }
+    }
+  } 
+  else {
+    AliMUONTrackerData::Class()->WriteBuffer(R__b, this);
+  }
+}
+
+
index 2b39b1fcb5b228936e363c356070a78520fb1fbf..df44f6cd6e65aae83bd36a3217ce6cdef2a6a790 100644 (file)
@@ -29,7 +29,9 @@ public:
                      Bool_t issingleevent=kFALSE);
   virtual ~AliMUONTrackerData();
 
-  virtual Bool_t Add(const AliMUONVStore& channelValues);
+  Bool_t Add(const AliMUONTrackerData& data);
+  
+  virtual Bool_t Add(const AliMUONVStore& channelValues, TArrayI* nofEventsPerDDL=0x0);
 
   virtual Bool_t Replace(const AliMUONVStore& channelValues);
 
@@ -75,7 +77,7 @@ public:
   virtual Int_t InternalToExternal(Int_t dim) const { return dim/2; }
 
   /// Returns the number of events we have seen so far
-  virtual Int_t NumberOfEvents() const { return fNevents; }
+  virtual Int_t NumberOfEvents(Int_t ddlNumber) const;
   
   virtual Double_t PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim=0) const;
 
@@ -156,7 +158,10 @@ private:
   /// To allow merging of different objects
   virtual Long64_t Merge(TCollection* list);
 
-private:
+  Int_t DdlIdFromBusPatchId(Int_t buspatchid) const;
+  Int_t DdlIdFromDetElemId(Int_t detelemid) const;
+  Int_t DdlIdFromChamberId(Int_t chamberid) const;
+  
   /// Not implemented
   AliMUONTrackerData(const AliMUONTrackerData& rhs);
   /// Not implemented
@@ -180,14 +185,23 @@ private:
 
   void SetExternalDimensionName(Int_t index, const char* value);  
 
-  Double_t Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) const;
+  Double_t Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim, Int_t ddlId) const;
   
   /// The number of values we actually *store* for each item
   Int_t Dimension() const { return fDimension; }
     
+  Bool_t InternalAdd(const AliMUONVStore& store, TArrayI* nevents, Bool_t replace);
+
+  void GetDEManu(const AliMUONVCalibParam& param,
+                  Int_t& detElemId, Int_t& manuId) const;
+  
+  void AddCalibParams(const AliMUONVCalibParam& src, AliMUONVCalibParam& dest) const;
+
+  void Add2D(const AliMUONVStore& src, AliMUONVStore& dest) const;
+  
+  void Add1D(const AliMUONVStore& src, AliMUONVStore& dest) const;
+  
 private:
-    
-    Bool_t InternalAdd(const AliMUONVStore& store, Bool_t replace);
   
   Bool_t fIsSingleEvent; ///< whether we can deal with more than one event
   AliMUONVStore* fChannelValues; ///< the channel store
@@ -210,8 +224,10 @@ private:
   static const Int_t fgkVirtualExtraDimension; ///< to give access to information not stored, but computed on the fly
   Bool_t fIsChannelLevelEnabled; ///< whether we allow storing of channel (fChannelValues) values
   Bool_t fIsManuLevelEnabled; ///< whether we allow storing of manu (fManuValues) values
-       
-  ClassDef(AliMUONTrackerData,6) // Implementation of AliMUONVTrackerData
+  Int_t fNofDDLs; ///< nof of DDLs we're dealing with
+  Int_t* fNofEventsPerDDL; //[fNofDDLs] the number of events treated (per DDL)
+
+  ClassDef(AliMUONTrackerData,7) // Implementation of AliMUONVTrackerData
 };
 
 #endif
index 47829fe9f5fb9541d6fdd42fa5049517b02f0d8d..7c002e7ba7fbc4e0f0114f1f84662a08f1abd1ee 100644 (file)
@@ -66,7 +66,7 @@ AliMUONTrackerDataWrapper::NumberOfEvents() const
   /// Get the number of events the data has seen
   if ( Data() ) 
   {
-    return Data()->NumberOfEvents();
+    return Data()->NumberOfEvents(-1);
   }
   return 0;
 }
index 0daf22414b38c56436910fc0f0aa05f40b2fedf0..6d9b7b7a10fe323ffbaebe9945eddba3107f281d 100644 (file)
@@ -29,6 +29,7 @@
 #include "AliMpConstants.h"
 #include "AliMpDDLStore.h"
 #include "AliMpDetElement.h"
+#include "AliMpDEManager.h"
 #include "AliMpHVNamer.h"
 #include <TClass.h>
 #include <TMap.h>
@@ -174,6 +175,13 @@ AliMUONTrackerOCDBDataMaker::CreateHVStore(TMap& m)
 
     Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data());
     
+    if ( !AliMpDEManager::IsValidDetElemId(detElemId) )
+    {
+      AliErrorClass(Form("Got an invalid DE = %d from alias = %s",
+                         detElemId,name.Data()));
+      continue;
+    }
+    
     Int_t nindex = 1;
     Int_t hvIndex = hvNamer.HVIndexFromDCSAlias(name.Data());
     
index cb6d73ffb9ecf3469bdac8abe186e36a41df5d89..c320f0e252453df12649aae8074bea9511a4a32c 100644 (file)
@@ -149,12 +149,13 @@ AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker()
 }
 
 //_____________________________________________________________________________
-Long64_t
-AliMUONTrackerRawDataMaker::Merge(TCollection*)
+Bool_t
+AliMUONTrackerRawDataMaker::Add(const AliMUONTrackerRawDataMaker& other) 
 {
-  /// Merge objects in collection
+  /// Adds other to this
   
-//  AliRawReader* fRawReader; //!< reader of the data (owner)
+//  AliRawReader* fRawReader; //!< reader of the data (owner or not)
+//  Bool_t fIsOwnerOfRawReader; //!< whether we must delete rawReader or not
 //  AliMUONVTrackerData* fAccumulatedData; ///< data (owner)
 //  AliMUONVStore* fOneEventData; ///< data for one event (owner)
 //  TString fSource; ///< where the data comes from
@@ -162,10 +163,64 @@ AliMUONTrackerRawDataMaker::Merge(TCollection*)
 //  Int_t fNumberOfEvents; ///< number of events seen
 //  Int_t fRunNumber; ///< run number of the data
 //  Bool_t fIsEventByEvent; ///< we only keep one event's data (no accumulation)
-//  Bool_t fUseHPDecoder; ///< whether to use high performance decoder or not (false by default)
+//  Bool_t fUseHPDecoder; ///< whether to use high performance decoder or not
+//  static Int_t fgkCounter; ///< to count the number of instances
+  
+  if (!fAccumulatedData) return kFALSE;
+  
+  if ( fIsEventByEvent )
+  {
+    AliError("Cannot add event by event objects !");
+    return kFALSE;
+  }
+  
+  if ( fRunNumber != other.fRunNumber ) fRunNumber = -1;
+  
+  fSource += "\n";
+  fSource += other.fSource;
+  
+  fNumberOfEvents += other.fNumberOfEvents;
+  
+  TList list;
+  list.Add(other.fAccumulatedData);
+  
+  fAccumulatedData->Merge(&list);
+  
+  return kTRUE;
+}
 
-  AliError("Not implemented yet");
-  return 0;
+//_____________________________________________________________________________
+Long64_t
+AliMUONTrackerRawDataMaker::Merge(TCollection* list)
+{
+  /// Merge objects in collection
+  
+  if (!list) return 0;
+  
+  if ( list->IsEmpty() ) return NumberOfEvents();
+  
+  TIter next(list);
+  const TObject* o(0x0);
+  
+  while ( ( o = next() ) )
+  {
+    const AliMUONTrackerRawDataMaker* data = dynamic_cast<const AliMUONTrackerRawDataMaker*>(o);
+    if (!o)
+    {
+      AliError(Form("Object named %s is not an AliMUONTrackerRawDataMaker ! Skipping it",
+                    o->GetName()));
+    }
+    else
+    {
+      Bool_t ok = Add(*data);
+      if (!ok)
+      {
+        AliError("Got incompatible objects");
+      }
+    }
+  }
+  
+  return NumberOfEvents();
 }
 
 //_____________________________________________________________________________
index 4aa83786b1ad6795fb19504e17828386287ae8cf..950be4cdad5bf3ee86071bbdb2fdc19a27c25fe6 100644 (file)
@@ -39,6 +39,8 @@ public:
   
   virtual ~AliMUONTrackerRawDataMaker();
   
+  Bool_t Add(const AliMUONTrackerRawDataMaker& other);
+  
   /// Whether we have a valid raw reader
   Bool_t IsValid() const { return fRawReader != 0x0; }
   
index 19d4e3526ebbb99642ee9dd189d49ae90f7652d5..8ef7db2aab7f9489b5c9512b6c369c198926c8ed 100644 (file)
@@ -26,6 +26,7 @@
 class AliMUONSparseHisto;
 class AliMUONVStore;
 class TCollection;
+class TArrayI;
 
 class AliMUONVTrackerData : public TNamed, public TQObject
 {
@@ -36,7 +37,7 @@ public:
   virtual ~AliMUONVTrackerData();
   
   /// Add values for one event from one full store
-  virtual Bool_t Add(const AliMUONVStore& store) = 0;
+  virtual Bool_t Add(const AliMUONVStore& store, TArrayI* arrayOfNofEventsPerDDL=0x0) = 0;
 
   /// Replace values
   virtual Bool_t Replace(const AliMUONVStore& store) = 0;
@@ -99,8 +100,10 @@ public:
   /// The number of dimensions we are inputting
   virtual Int_t ExternalDimension() const = 0;
 
-  /// The number of events we've seen so far
-  virtual Int_t NumberOfEvents() const = 0;
+  /** The number of events we've seen so far in a given DDL (or any DDL if param<0)
+   ddlNumber is 0..19
+   */
+  virtual Int_t NumberOfEvents(Int_t ddlNumber) const = 0;
 
   /// Signal to indicate that the number of events changed
   virtual void NumberOfEventsChanged(); // *SIGNAL*
index 59f846e2e612d57ad62fa432aefcf78bd4a3353d..82bbbb39ce2ac9703271dd0c847d71c68dea3c47 100644 (file)
@@ -29,7 +29,7 @@
 #pragma link C++ class AliMUONTrackerIO+;
 #pragma link C++ class AliMUONVTrackerData+;
 #pragma link C++ class AliMUONSparseHisto+;
-#pragma link C++ class AliMUONTrackerData+;
+#pragma link C++ class AliMUONTrackerData-;
 
 #endif