//_________________________________________________________________________
//*--
-//*-- Author: Gines Martinez & Yves Schutz (SUBATECH)
-//*-- Compleetely redesigned by Dmitri Peressounko (SUBATECH & RRC KI) March 2001
-/////////////////////////////////////////////////////////////////////////////////////
-// Wrapping class for reconstruction. Allows to produce reconstruction from
-// different steps: from previously produced hits,sdigits, etc. Each new reconstruction
-// flow (e.g. digits, made from them RecPoints, subsequently made TrackSegments,
-// subsequently made RecParticles) are distinguished by the title of created branches. One can
-// use this title as a comment, see use case below.
-// Thanks to getters, one can set
-// parameters to reconstruction briks. The full set of parameters is saved in the
-// corresponding branch: e.g. parameters of clusterizer are stored in branch
-// TreeR::AliPHOSClusterizer with the same title as the branch containing the RecPoints. // TTree does not support overwriting, therefore one can not produce several
-// branches with the same names and titles - use different titles.
-//
-// Use case:
-//
-// root [0] AliPHOSReconstructor * r = new AliPHOSReconstructor("galice.root")
-// // Set the header file
-// root [1] r->ExecuteTask()
-// // Make full chain of reconstruction
-//
-// // One can specify the title for each branch
-// root [2] r->SetBranchFileName("RecPoints","RecPoints1") ;
-//
-// // One can change parameters of reconstruction algorithms
-// root [3] r->GetClusterizer()->SetEmcLocalMaxCut(0.02)
-//
-// // One can specify the starting point of the reconstruction and title of all
-// // branches produced in this pass
-// root [4] r->StartFrom("AliPHOSClusterizer","Local max cut 0.02")
-// // means that will use already generated Digits and produce only RecPoints,
-// // TS and RecParticles
-//
-// // And finally one can call ExecuteTask() with the following options
-// root [5] r->ExecuteTask("debug all timing")
-// // deb - prints the numbers of RecPoints, TrackSegments, RecParticles
-// // deb all - prints in addition list of RecPoints, TrackSegments, RecParticles
-// // timing - prints benchmarking results
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
+//*-- Yves Schutz (SUBATECH)
+// Reconstruction class. Redesigned from the old AliReconstructionner class and
+// derived from STEER/AliReconstructor.
+//
// --- ROOT system ---
// --- Standard library ---
// --- AliRoot header files ---
#include "AliESD.h"
-#include "AliESDCaloTrack.h"
#include "AliPHOSReconstructor.h"
#include "AliPHOSClusterizerv1.h"
#include "AliPHOSTrackSegmentMakerv1.h"
#include "AliPHOSPIDv1.h"
#include "AliPHOSGetter.h"
+#include "AliPHOSTracker.h"
+#include "AliRawReader.h"
-
+
ClassImp(AliPHOSReconstructor)
+Bool_t AliPHOSReconstructor::fgDebug = kFALSE ;
+
//____________________________________________________________________________
- AliPHOSReconstructor::AliPHOSReconstructor():TTask("AliPHOSReconstructor","")
+ AliPHOSReconstructor::AliPHOSReconstructor()
{
// ctor
- fClusterizer = 0 ;
- fTSMaker = 0 ;
- fPID = 0 ;
- fFirstEvent = 0 ;
- fLastEvent = -1 ;
- fIsInitialized = kFALSE ;
}
//____________________________________________________________________________
-AliPHOSReconstructor::AliPHOSReconstructor(const char* evFoldName,const char * branchName,const TString taskName):
-TTask("AliPHOSReconstructor",evFoldName)
+ AliPHOSReconstructor::~AliPHOSReconstructor()
{
- // Create a PHOS reconstructioner for the tasks defined by taskName
- // "C" - clusterization
- // "T" - track segment making
- // "P" - PID
-
- AliPHOSGetter::Instance(evFoldName) ;
+ // dtor
- if (taskName.Contains("C")) {
- fRecPointBranch=branchName ;
- fClusterizer = new AliPHOSClusterizerv1(evFoldName, GetTitle());
- Add(fClusterizer);
- }
-
- if (taskName.Contains("T")) {
- fTSBranch=branchName ;
- fTSMaker = new AliPHOSTrackSegmentMakerv1(evFoldName, GetTitle());
- Add(fTSMaker) ;
- }
-
- if (taskName.Contains("P")) {
- fRecPartBranch=branchName ;
- fPID = new AliPHOSPIDv1(evFoldName, GetTitle());
- Add(fPID);
- }
-
- fIsInitialized = kTRUE ;
}
+
//____________________________________________________________________________
-void AliPHOSReconstructor::Exec(Option_t *opt)
+void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader) const
{
- //check, if the names of branches, which should be made coincide with already
- //existing
- if (!opt)
- return ;
- if(!fIsInitialized)
- Init() ;
+ // method called by AliReconstruction;
+ // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
+ // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
+ // the global tracking.
+
+ TString headerFile(runLoader->GetFileName()) ;
+ TString branchName(runLoader->GetEventFolder()->GetName()) ;
+
+ AliPHOSClusterizerv1 clu(headerFile, branchName);
+ clu.SetEventRange(0, -1) ; // do all the events
+ if ( Debug() )
+ clu.ExecuteTask("deb all") ;
+ else
+ clu.ExecuteTask("") ;
+
}
+
//____________________________________________________________________________
-void AliPHOSReconstructor:: Clusters2Tracks(Int_t ievent, AliESD *event)
+void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawreader) const
{
- // Convert PHOS reconstructed particles into ESD object for event# ievent.
- // ESD object is returned as an argument event
+ // method called by AliReconstruction;
+ // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
+ // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
+ // the global tracking.
+ // Here we reconstruct from Raw Data
- if(!fIsInitialized) Init() ;
+ rawreader->Reset() ;
+ TString headerFile(runLoader->GetFileName()) ;
+ TString branchName(runLoader->GetEventFolder()->GetName()) ;
+
+ AliPHOSClusterizerv1 clu(headerFile, branchName);
+ clu.SetEventRange(0, -1) ; // do all the events
+ clu.SetRawReader(rawreader);
- fClusterizer->SetEventRange(ievent,ievent);
- fClusterizer->ExecuteTask();
+ TString option = GetOption();
+ if (option.Contains("OldRCUFormat"))
+ clu.SetOldRCUFormat(kTRUE);
- fTSMaker ->SetEventRange(ievent,ievent);
- fTSMaker ->ExecuteTask();
-
- fPID ->SetEventRange(ievent,ievent);
- fPID ->ExecuteTask();
+ if ( Debug() )
+ clu.ExecuteTask("deb all") ;
+ else
+ clu.ExecuteTask("") ;
- AliPHOSGetter *gime = AliPHOSGetter::Instance();
- TClonesArray *recParticles = gime->RecParticles();
- Int_t nOfRecParticles = recParticles->GetEntries();
- for (Int_t recpart=0; recpart<nOfRecParticles; recpart++) {
- AliESDCaloTrack *ct = new AliESDCaloTrack((AliPHOSRecParticle*)recParticles->At(recpart));
- event->AddCaloTrack(ct);
- }
-
}
+
//____________________________________________________________________________
- void AliPHOSReconstructor::Init()
+void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
{
- // initiliaze Reconstructioner if necessary: we can not do this in default constructor
+ // This function creates AliESDtracks from AliPHOSRecParticles
+ // and
+ // writes them to the ESD
- if(!fIsInitialized){
-
- fRecPointBranch="Default" ;
- fClusterizer = new AliPHOSClusterizerv1(GetTitle(),fRecPointBranch.Data());
- Add(fClusterizer) ;
+ Int_t eventNumber = runLoader->GetEventNumber() ;
+
+ AliPHOSGetter *gime = AliPHOSGetter::Instance();
+ gime->Event(eventNumber, "DRTP") ;
+ TClonesArray *recParticles = gime->RecParticles();
+ Int_t nOfRecParticles = recParticles->GetEntries();
- fTSBranch="Default" ;
- fTSMaker = new AliPHOSTrackSegmentMakerv1(GetTitle(),fTSBranch.Data());
- Add(fTSMaker) ;
+ esd->SetNumberOfPHOSClusters(nOfRecParticles) ;
+ esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ;
+
+ AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption()));
+ for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) {
+ AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart));
+ if (Debug())
+ rp->Print();
+ // Get track segment and EMC rec.point associated with this rec.particle
+ AliPHOSTrackSegment *ts = gime->TrackSegment(rp->GetPHOSTSIndex());
+ AliPHOSEmcRecPoint *emcRP = gime->EmcRecPoint(ts->GetEmcIndex());
+ AliESDCaloCluster *ec = new AliESDCaloCluster() ;
- fRecPartBranch="Default";
- fPID = new AliPHOSPIDv1(GetTitle(),fRecPartBranch.Data()) ;
- Add(fPID) ;
+ // fills the ESDCaloCluster
+ Float_t xyz[3];
+ for (Int_t ixyz=0; ixyz<3; ixyz++)
+ xyz[ixyz] = rp->GetPos()[ixyz];
- fIsInitialized = kTRUE ;
+ AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2]));
- }
-}
+ Int_t digitMult = emcRP->GetDigitsMultiplicity();
+ Int_t *digitsList = emcRP->GetDigitsList();
+ UShort_t *amplList = new UShort_t[digitMult];
+ UShort_t *timeList = new UShort_t[digitMult];
+ UShort_t *digiList = new UShort_t[digitMult];
+
+ // Convert Float_t* and Int_t* to UShort_t* to save memory
+ for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
+ AliPHOSDigit *digit = gime->Digit(digitsList[iDigit]);
+ amplList[iDigit] = (UShort_t)(digit->GetEnergy()*500); // Energy in units of GeV/500
+ timeList[iDigit] = (UShort_t)(digit->GetTime()*1e9*100); // time in units of 0.01 ns
+ digiList[iDigit] = (UShort_t)(digit->GetId());
+ }
+
+ ec->SetPHOS(kTRUE);
+ ec->SetGlobalPosition(xyz); //rec.point position in MARS
+ ec->SetClusterEnergy(rp->Energy()); //total particle energy
+ ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion
+ ec->SetPid (rp->GetPID()) ; //array of particle identification
+ ec->SetPrimaryIndex (rp->GetPrimaryIndex());//index of primary particle (for simulations)
+ ec->SetM02(emcRP->GetM2x()) ; //second moment M2x
+ ec->SetM20(emcRP->GetM2z()) ; //second moment M2z
+ ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima
+ ec->SetNumberOfDigits(digitMult); //digit multiplicity
+ ec->SetDigitAmplitude(amplList); //energies in 1/500 of GeV
+ ec->SetDigitTime(timeList); //times in 1/100 on ns
+ ec->SetDigitIndex(digiList); //abs id of the cell
+ ec->SetEmcCpvDistance(-1); //not yet implemented
+ ec->SetClusterChi2(-1); //not yet implemented
+ ec->SetM11(-1) ; //not yet implemented
+
+ // add the track to the esd object
+ esd->AddCaloCluster(ec);
+ delete ec;
+ }
+}
+
//____________________________________________________________________________
-AliPHOSReconstructor::~AliPHOSReconstructor()
+void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader,
+ AliRawReader* rawReader, AliESD* esd) const
{
- // Delete data members if any
-}
+ //This function creates AliESDtracks from AliPHOSRecParticles
+ //and writes them to the ESD in the case of raw data reconstruction.
-void AliPHOSReconstructor::Print()const {
- // Print reconstructioner data
+ Int_t eventNumber = runLoader->GetEventNumber() ;
- TString message ;
- message = "-----------------AliPHOSReconstructor---------------\n" ;
- message += " Reconstruction of the header file %s\n" ;
- message += " with the following modules:\n" ;
+ AliPHOSGetter *gime = AliPHOSGetter::Instance();
+ gime->Event(eventNumber, "DRTP") ;
- if(fClusterizer->IsActive()){
- message += " (+) %s to branch %s\n" ;
- }
+ TClonesArray *recParticles = gime->RecParticles();
+ Int_t nOfRecParticles = recParticles->GetEntries();
- if(fTSMaker->IsActive()){
- message += " (+) %s to branch %s\n" ;
- }
+ esd->SetNumberOfPHOSClusters(nOfRecParticles) ;
+ esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ;
+
+ AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption()));
- if(fPID->IsActive()){
- message += " (+) %s to branch %s\n" ;
+ for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) {
+ AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart));
+
+ if(rp) {
+ Float_t xyz[3];
+ for (Int_t ixyz=0; ixyz<3; ixyz++)
+ xyz[ixyz] = rp->GetPos()[ixyz];
+
+ AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2]));
+
+ AliPHOSTrackSegment *ts = gime->TrackSegment(rp->GetPHOSTSIndex());
+ AliPHOSEmcRecPoint *emcRP = gime->EmcRecPoint(ts->GetEmcIndex());
+ AliESDCaloCluster *ec = new AliESDCaloCluster() ;
+
+ Int_t digitMult = emcRP->GetDigitsMultiplicity();
+ Int_t *digitsList = emcRP->GetDigitsList();
+ UShort_t *amplList = new UShort_t[digitMult];
+ UShort_t *digiList = new UShort_t[digitMult];
+
+ // Convert Float_t* and Int_t* to UShort_t* to save memory
+ for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
+ AliPHOSDigit *digit = gime->Digit(digitsList[iDigit]);
+ if(!digit) {
+ AliFatal(Form("Digit not found at the expected position %d!",iDigit));
+ }
+ else {
+ amplList[iDigit] = (UShort_t)digit->GetEnergy();
+ digiList[iDigit] = (UShort_t)(digit->GetId());
+ }
+ }
+
+ ec->SetPHOS(kTRUE);
+ ec->SetGlobalPosition(xyz); //rec.point position in MARS
+ ec->SetClusterEnergy(rp->Energy()); //total particle energy
+ ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion
+ ec->SetPid (rp->GetPID()) ; //array of particle identification
+ ec->SetM02(emcRP->GetM2x()) ; //second moment M2x
+ ec->SetM20(emcRP->GetM2z()) ; //second moment M2z
+ ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima
+ ec->SetNumberOfDigits(digitMult); //digit multiplicity
+ ec->SetDigitAmplitude(amplList); //digit energies
+ ec->SetDigitIndex(digiList); //abs id of the cell
+ ec->SetEmcCpvDistance(-1); //not yet implemented
+ ec->SetClusterChi2(-1); //not yet implemented
+ ec->SetM11(-1) ; //not yet implemented
+
+ // add the track to the esd object
+ esd->AddCaloCluster(ec);
+ delete ec;
+
+ }
}
- Info("Print", message.Data(),
- GetTitle(),
- fClusterizer->GetName(), fRecPointBranch.Data(),
- fTSMaker->GetName(), fTSBranch.Data() ,
- fPID->GetName(), fRecPartBranch.Data() ) ;
+
+
}
-//____________________________________________________________________________
-void AliPHOSReconstructor::SetEventRange(Int_t first, Int_t last)
+AliTracker* AliPHOSReconstructor::CreateTracker(AliRunLoader* runLoader) const
{
- // Set the event range to process
- fFirstEvent=first;
- fLastEvent=last;
- fClusterizer->SetEventRange(fFirstEvent, fLastEvent) ;
- fTSMaker->SetEventRange(fFirstEvent, fLastEvent) ;
- fPID->SetEventRange(fFirstEvent, fLastEvent) ;
+// creates the PHOS tracker
+ if (!runLoader) return NULL;
+ return new AliPHOSTracker(runLoader);
}
+