]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSReconstructor.cxx
Updated IFC material distribution
[u/mrichter/AliRoot.git] / PHOS / AliPHOSReconstructor.cxx
index f7b9a972cbbbf60c777fe42918307a9ed2a050ba..32120efb00c57acd58c9c0dd46b479b2821e83c0 100644 (file)
@@ -51,6 +51,7 @@
 #include "AliPHOSRawFitterv0.h"
 #include "AliPHOSRawFitterv1.h"
 #include "AliPHOSRawFitterv2.h"
+#include "AliPHOSRawFitterv3.h"
 #include "AliPHOSRawDigiProducer.h"
 #include "AliPHOSPulseGenerator.h"
 
@@ -75,6 +76,9 @@ AliPHOSReconstructor::AliPHOSReconstructor() :
   fgEMCRecPoints= new TObjArray(100) ;
   if (!fgCalibData)
     fgCalibData = new AliPHOSCalibData(-1); //use AliCDBManager's run number
+
+  AliInfo(Form("PHOS bad channel map contains %d bad channel(s).\n",
+               fgCalibData->GetNumOfEmcBadChannels()));
  
 }
 
@@ -136,9 +140,6 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   TClonesArray *recParticles  = fPID->GetRecParticles();
   Int_t nOfRecParticles = recParticles->GetEntriesFast();
   
-  esd->SetNumberOfPHOSClusters(nOfRecParticles) ; 
-  esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ;
-  
   AliDebug(2,Form("%d rec. particles, option %s",nOfRecParticles,GetOption()));
   
   // Read digits array
@@ -235,7 +236,8 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
     const AliPHOSDigit * dig = (const AliPHOSDigit*)fgDigitsArray->At(idig);
     if(dig->GetId() <= knEMC && 
        Calibrate(dig->GetEnergy(),dig->GetId()) > GetRecoParam()->GetEMCMinE() ){
-      phsCells.SetCell(idignew,dig->GetId(), Calibrate(dig->GetEnergy(),dig->GetId()), dig->GetTime());   
+      phsCells.SetCell(idignew,dig->GetId(), Calibrate(dig->GetEnergy(),dig->GetId()),
+                                             CalibrateT(dig->GetTime(),dig->GetId()));   
       idignew++;
     }
   }
@@ -300,8 +302,9 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
     ec->SetM20(emcRP->GetM2z()) ;               //second moment M2z
     ec->SetNExMax(emcRP->GetNExMax());          //number of local maxima
     ec->SetEmcCpvDistance(ts->GetCpvDistance("r")); //Only radius, what about separate x,z????
+    ec->SetTrackDistance(ts->GetCpvDistance("x"),ts->GetCpvDistance("z")); 
     ec->SetClusterChi2(-1);                     //not yet implemented
-    ec->SetTOF(emcRP->GetTime()); //Time of flight
+    ec->SetTOF(emcRP->GetTime());               //Time of flight - already calibrated in EMCRecPoint
 
     //Cells contributing to clusters
     ec->SetNCells(cellMult);
@@ -320,7 +323,21 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
     arrayTrackMatched[0]= ts->GetTrackIndex();
     ec->AddTracksMatched(arrayTrackMatched);
     
-    esd->AddCaloCluster(ec);
+    Int_t index = esd->AddCaloCluster(ec);
+
+    //Set pointer to this cluster in ESD track
+    Int_t nt=esd->GetNumberOfTracks();
+    for (Int_t itr=0; itr<nt; itr++) {
+      AliESDtrack *esdTrack=esd->GetTrack(itr);
+      if(!esdTrack->IsPHOS())
+        continue ;
+      if(esdTrack->GetPHOScluster()==-recpart){ //we store negative cluster number
+        esdTrack->SetPHOScluster(index) ;
+//no garatie that only one track matched this cluster
+//      break ;
+      }
+    }
     delete ec;   
     delete [] fracList;
     delete [] absIdList;
@@ -354,8 +371,8 @@ void  AliPHOSReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
   const TObjArray* maps = AliPHOSRecoParam::GetMappings();
   if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!");
 
-  AliAltroMapping *mapping[4];
-  for(Int_t i = 0; i < 4; i++) {
+  AliAltroMapping *mapping[20];
+  for(Int_t i = 0; i < 20; i++) {
     mapping[i] = (AliAltroMapping*)maps->At(i);
   }
 
@@ -363,6 +380,8 @@ void  AliPHOSReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
     fitter=new AliPHOSRawFitterv1();
   else if (strcmp(GetRecoParam()->EMCFitterVersion(),"v2")==0) 
     fitter=new AliPHOSRawFitterv2();
+  else if (strcmp(GetRecoParam()->EMCFitterVersion(),"v3")==0) 
+    fitter=new AliPHOSRawFitterv3();
   else
     fitter=new AliPHOSRawFitterv0();
 
@@ -433,6 +452,26 @@ Float_t AliPHOSReconstructor::Calibrate(Float_t amp, Int_t absId)const{
   }
 }
 //==================================================================================
+Float_t AliPHOSReconstructor::CalibrateT(Float_t time, Int_t absId)const{
+  // Calibrate EMC digit, i.e. multiply its Amp by a factor read from CDB
+
+  const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
+
+  //Determine rel.position of the cell absolute ID
+  Int_t relId[4];
+  geom->AbsToRelNumbering(absId,relId);
+  Int_t module=relId[0];
+  Int_t row   =relId[2];
+  Int_t column=relId[3];
+  if(relId[1]){ //CPV
+    return 0. ;
+  }
+  else{ //EMC
+    time += fgCalibData->GetTimeShiftEmc(module,column,row);
+    return time ;
+  }
+}
+//==================================================================================
 void AliPHOSReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{
   //Store PHOS matrixes in ESD Header