]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALReconstructor.cxx
SOD enum updated to include logical combination of signals
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALReconstructor.cxx
index eab5af81de27f7309ab98c8468f948a5cea04d31..07ae64864bd9c0d3941cbd04d35697a3a7cea92b 100644 (file)
@@ -28,6 +28,8 @@
 #include <TList.h>
 #include <TClonesArray.h>
 #include <TH2.h>
+#include "TGeoManager.h"
+#include "TGeoMatrix.h"
 
 // --- Standard library ---
 
 #include "AliRawReader.h"
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
-#include "AliEMCALRecParam.h"
 #include "AliEMCALGeometry.h"
 #include "AliEMCAL.h"
 #include "AliEMCALHistoUtilities.h"
 #include "AliESDVZERO.h"
-
+#include "AliCDBManager.h"
 #include "AliRunLoader.h"
 #include "AliRun.h"
 
@@ -66,17 +67,15 @@ AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0;   // EMCAL cluste
 TClonesArray*     AliEMCALReconstructor::fgDigitsArr = 0;  // shoud read just once at event
 //____________________________________________________________________________
 AliEMCALReconstructor::AliEMCALReconstructor() 
-  : fDebug(kFALSE), fList(0), fGeom(0) 
+  : fDebug(kFALSE), fList(0), fGeom(0),fCalibData(0),fPedestalData(0) 
 {
   // ctor
-  InitRecParam();
 
   fgRawUtils = new AliEMCALRawUtils;
-  fgClusterizer = new AliEMCALClusterizerv1;
 
   //To make sure we match with the geometry in a simulation file,
   //let's try to get it first.  If not, take the default geometry
-  AliRunLoader *rl = AliRunLoader::GetRunLoader();
+  AliRunLoader *rl = AliRunLoader::Instance();
   if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")) {
     fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
   } else {
@@ -84,20 +83,36 @@ AliEMCALReconstructor::AliEMCALReconstructor()
     fGeom =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
   }
 
+  //Get calibration parameters 
+  if(!fCalibData)
+    {
+               AliCDBEntry *entry = (AliCDBEntry*) 
+               AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
+               if (entry) fCalibData =  (AliEMCALCalibData*) entry->GetObject();
+    }
+       
+  if(!fCalibData)
+               AliFatal("Calibration parameters not found in CDB!");
+       
+  //Get calibration parameters 
+  if(!fPedestalData)
+    {
+               AliCDBEntry *entry = (AliCDBEntry*) 
+               AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
+               if (entry) fPedestalData =  (AliCaloCalibPedestal*) entry->GetObject();
+    }
+       
+       if(!fPedestalData)
+               AliFatal("Dead map not found in CDB!");
+       
+       
+  //Init the clusterizer with geometry and calibration pointers, avoid doing it twice.
+  fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); 
+       
   if(!fGeom) AliFatal(Form("Could not get geometry!"));
 
 } 
 
-//____________________________________________________________________________
-AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec)
-  : AliReconstructor(rec),
-    fDebug(rec.fDebug),
-    fList(rec.fList),
-    fGeom(rec.fGeom)
-{
-  //copy ctor
-}
-
 //____________________________________________________________________________
 AliEMCALReconstructor::~AliEMCALReconstructor()
 {
@@ -113,23 +128,6 @@ void AliEMCALReconstructor::Init()
   fList = AliEMCALHistoUtilities::GetTriggersListOfHists(kTRUE);
 }
 
-//____________________________________________________________________________
-void AliEMCALReconstructor::InitRecParam() const
-{
-  // Check if the instance of AliEMCALRecParam exists, 
-  // if not, get it from OCDB if available, otherwise create a default one
-
-  if(!fgkRecParam) {
-    fgkRecParam = dynamic_cast<const AliEMCALRecParam*>(AliReconstructor::GetRecoParam(6));
-  }
-  
-  if(!fgkRecParam){
-    AliWarning("The Reconstruction parameters for EMCAL nonitialized - Used default one");
-    fgkRecParam = new AliEMCALRecParam();
-  }
-
-}
-
 //____________________________________________________________________________
 void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
 {
@@ -139,12 +137,12 @@ void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree)
   // the global tracking.
   // Works on the current event.
 
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
 
   ReadDigitsArrayFromTree(digitsTree);
-
+  fgClusterizer->InitParameters();
   fgClusterizer->SetOutput(clustersTree);
-
+       
   if(fgDigitsArr && fgDigitsArr->GetEntries()) {
 
     fgClusterizer->SetInput(digitsTree);
@@ -177,11 +175,11 @@ void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
   //must be done here because, in constructor, option is not yet known
   fgRawUtils->SetOption(GetOption());
 
-  fgRawUtils->SetRawFormatHighLowGainFactor(fgkRecParam->GetHighLowGainFactor());
-  fgRawUtils->SetRawFormatOrder(fgkRecParam->GetOrderParameter());
-  fgRawUtils->SetRawFormatTau(fgkRecParam->GetTau());
-  fgRawUtils->SetNoiseThreshold(fgkRecParam->GetNoiseThreshold());
-  fgRawUtils->SetNPedSamples(fgkRecParam->GetNPedSamples());
+  fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor());
+  fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter());
+  fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau());
+  fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold());
+  fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples());
 
   fgRawUtils->Raw2Digits(rawReader,digitsArr);
 
@@ -292,7 +290,7 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000);
   TBranch *branchdig = digitsTree->GetBranch("EMCAL");
   if (!branchdig) { 
-    AliError("can't get the branch with the PHOS digits !");
+    AliError("can't get the branch with the EMCAL digits !");
     return;
   }
   branchdig->SetAddress(&digits);
@@ -303,11 +301,15 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   AliESDCaloCells &emcCells = *(esd->GetEMCALCells());
   emcCells.CreateContainer(nDigits);
   emcCells.SetType(AliESDCaloCells::kEMCALCell);
+  Float_t energy = 0;
   for (Int_t idig = 0 ; idig < nDigits ; idig++) {
     const AliEMCALDigit * dig = (const AliEMCALDigit*)digits->At(idig);
     if(dig->GetAmp() > 0 ){
-      emcCells.SetCell(idignew,dig->GetId(),dig->GetAmp(), dig->GetTime());   
-      idignew++;
+         energy = (static_cast<AliEMCALClusterizerv1*> (fgClusterizer))->Calibrate(dig->GetAmp(),dig->GetId());
+         if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them  
+                 emcCells.SetCell(idignew,dig->GetId(),energy, dig->GetTime());   
+                 idignew++;
+         }
     }
   }
   emcCells.SetNumberOfCells(idignew);
@@ -395,6 +397,10 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
       ec->SetClusterType(AliESDCaloCluster::kEMCALClusterv1);
       ec->SetPosition(xyz);
       ec->SetE(clust->GetEnergy());
+               
+         //Distance to the nearest bad crystal
+         ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower()); 
+
       ec->SetNCells(newCellMult);
       //Change type of list from short to ushort
       UShort_t *newAbsIdList  = new UShort_t[newCellMult];
@@ -443,8 +449,47 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   delete clusters;
   
   // printf(" ## AliEMCALReconstructor::FillESD() is ended : ncl %i -> %i ### \n ",nClusters, nClustersNew); 
+
+  //Store EMCAL misalignment matrixes
+  FillMisalMatrixes(esd) ;
+
+}
+
+//==================================================================================
+void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{
+       //Store EMCAL matrixes in ESD Header
+       
+       //Check, if matrixes was already stored
+       for(Int_t sm = 0 ; sm < 12; sm++){
+               if(esd->GetEMCALMatrix(sm)!=0)
+                       return ;
+       }
+       
+       //Create and store matrixes
+       if(!gGeoManager){
+               AliError("Can not store misal. matrixes: no gGeoManager! \n") ;
+               return ;
+       }
+       //Note, that owner of copied marixes will be header
+       char path[255] ;
+       TGeoHMatrix * m ;
+       for(Int_t sm = 0; sm < 12; sm++){
+               sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5
+               if(sm >= 10) sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ;
+               
+               if (gGeoManager->cd(path)){
+                       m = gGeoManager->GetCurrentMatrix() ;
+                       esd->SetEMCALMatrix(new TGeoHMatrix(*m),sm) ;
+               }
+               else{
+                       esd->SetEMCALMatrix(NULL,sm) ;
+               }
+       }
+       
 }
 
+
+
 //__________________________________________________________________________
 void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const
 {