]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALReconstructor.cxx
correct the way the clusterizer is initialized, depending on event type
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALReconstructor.cxx
index eb24a9615769df9dd08cb82b274d7aac813101d9..526a5680eaa46310f8ac80133408c635946e2215 100644 (file)
@@ -119,9 +119,7 @@ AliEMCALReconstructor::AliEMCALReconstructor()
   
   if(!fPedestalData)
     AliFatal("Dead map not found in CDB!");
-  
-  InitClusterizer();
-       
+       
   if(!fGeom) AliFatal(Form("Could not get geometry!"));
 
   AliEMCALTriggerDCSConfigDB* dcsConfigDB = AliEMCALTriggerDCSConfigDB::Instance();
@@ -174,32 +172,50 @@ AliEMCALReconstructor::~AliEMCALReconstructor()
 //    fList = AliEMCALHistoUtilities::GetTriggersListOfHists(kTRUE);
 // }
 
-//____________________________________________________________________________
-void AliEMCALReconstructor::InitClusterizer() 
+//____________________________________________________________________________                                  
+void AliEMCALReconstructor::InitClusterizer() const
 {
-  //Init the clusterizer with geometry and calibration pointers, avoid doing it twice.
-  
-  AliEMCALRecParam *recParam = NULL;
-  AliCDBEntry *entry = (AliCDBEntry*) 
-  AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
-  //Get The reco param for the default event specie
-  if (entry) 
-    recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0);
-  
-  if(!recParam){  
-    AliFatal("RecoParam not found in CDB!");
+  //Init the clusterizer with geometry and calibration pointers, avoid doing it twice.                          
+  Int_t clusterizerType = -1;
+  Int_t eventType = -1;
+  if(GetRecParam()) {
+    clusterizerType = GetRecParam()->GetClusterizerFlag();
+    eventType       = GetRecParam()->GetEventSpecie();
   }
   else{
-    if (recParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
-    {
-      fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); 
-    }
-    else
-    {
-      fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData); 
+    AliCDBEntry *entry = (AliCDBEntry*)
+    AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
+    //Get The reco param for the default event specie                                                           
+    if (entry) {
+      AliEMCALRecParam *recParam  = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0);
+      if(recParam) clusterizerType = recParam->GetClusterizerFlag(); 
     }
   }
   
+  //Check if clusterizer previously set corresponds to what is needed for this event type                       
+  if(fgClusterizer){
+    if(eventType!=AliRecoParam::kCalib){
+      //printf("ReCreate clusterizer? Clusterizer set <%d>, Clusterizer in use <%s>\n",
+        //     clusterizerType, fgClusterizer->Version());
+      
+      if     (clusterizerType == AliEMCALRecParam::kClusterizerv1 && !strcmp(fgClusterizer->Version(),"clu-v1")) return;
+      
+      else if(clusterizerType == AliEMCALRecParam::kClusterizerNxN && !strcmp(fgClusterizer->Version(),"clu-NxN")) return;
+      
+      //Need to create new clusterizer, the one set previously is not the correct one     
+      delete fgClusterizer;
+    }
+    else return;
+  }
+
+  if (clusterizerType  == AliEMCALRecParam::kClusterizerv1)
+  {
+    fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData);
+  }
+  else
+  {
+    fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData);
+  }
 }
 
 //____________________________________________________________________________
@@ -215,12 +231,14 @@ void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree)
 
   ReadDigitsArrayFromTree(digitsTree);
 
+  InitClusterizer();
+  
   fgClusterizer->InitParameters();
   fgClusterizer->SetOutput(clustersTree);
-       
+  
   //Skip clusterization of LED events
   if (GetRecParam()->GetEventSpecie()!=AliRecoParam::kCalib){
-
+       
                if(fgDigitsArr && fgDigitsArr->GetEntries()) {
 
                  fgClusterizer->SetInput(digitsTree);
@@ -311,8 +329,8 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
    {
          for (Int_t i = 0; i < 32; i++)
          {
-                 v0M[0] += esdV0->GetAdcV0C(i);
-                 v0M[1] += esdV0->GetAdcV0A(i);
+                 v0M[0] += (Int_t)esdV0->GetAdcV0C(i);
+                 v0M[1] += (Int_t)esdV0->GetAdcV0A(i);
          }
    }
    else
@@ -373,7 +391,7 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
                          while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)NextPatch())
                          {
                                  TVector2 pos; p->Position(pos);
-                                 trgESD->SetTriggerBits(pos.X(), pos.Y(), i, j);
+                                 trgESD->SetTriggerBits((Int_t) pos.X(), (Int_t) pos.Y(), i, j);
                          }
                  }
          }