#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"
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 {
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()
{
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
{
// 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);
//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);
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);
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);
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];
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
{