/**************************************************************************
+
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+
* *
+
* Author: The ALICE Off-line Project. *
+
* Contributors are mentioned in the code where appropriate. *
+
* *
+
* Permission to use, copy, modify and distribute this software and its *
+
* documentation strictly for non-commercial purposes is hereby granted *
+
* without fee, provided that the above copyright notice appears in all *
+
* copies and that both the copyright notice and this permission notice *
+
* appear in the supporting documentation. The authors make no claims *
+
* about the suitability of this software for any purpose. It is *
+
* provided "as is" without express or implied warranty. *
+
**************************************************************************/
+
/* $Id$ */
+
+
/* $Log:
+
1 October 2000. Yuri Kharlov:
+
AreNeighbours()
+
PPSD upper layer is considered if number of layers>1
+
+
18 October 2000. Yuri Kharlov:
+
AliEMCALClusterizerv1()
+
CPV clusterizing parameters added
+
+
MakeClusters()
+
After first PPSD digit remove EMC digits only once
+
*/
+
//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (SUBATECH & Kurchatov Institute)
+
// August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
+
// of new IO (à la PHOS)
+
//////////////////////////////////////////////////////////////////////////////
+
// Clusterization class. Performs clusterization (collects neighbouring active cells) and
+
// unfolds the clusters having several local maxima.
+
// Results are stored in TreeR#, branches EMCALTowerRP (EMC recPoints),
+
// EMCALPreShoRP (CPV RecPoints) and AliEMCALClusterizer (Clusterizer with all
+
// parameters including input digits branch title, thresholds etc.)
+
// This TTask is normally called from Reconstructioner, but can as well be used in
+
// standalone mode.
+
// Use Case:
+
// root [0] AliEMCALClusterizerv1 * cl = new AliEMCALClusterizerv1("galice.root")
+
// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
+
// //reads gAlice from header file "..."
+
// root [1] cl->ExecuteTask()
+
// //finds RecPoints in all events stored in galice.root
+
// root [2] cl->SetDigitsBranch("digits2")
+
// //sets another title for Digitis (input) branch
+
// root [3] cl->SetRecPointsBranch("recp2")
+
// //sets another title four output branches
+
// root [4] cl->SetTowerLocalMaxCut(0.03)
+
// //set clusterization parameters
+
// root [5] cl->ExecuteTask("deb all time")
+
// //once more finds RecPoints options are
+
// // deb - print number of found rec points
+
// // deb all - print number of found RecPoints and some their characteristics
+
// // time - print benchmarking results
+
+
// --- ROOT system ---
+
+
#include "TROOT.h"
+
#include "TFile.h"
+
#include "TFolder.h"
+
#include "TMath.h"
+
#include "TMinuit.h"
+
#include "TTree.h"
+
#include "TSystem.h"
+
#include "TBenchmark.h"
+
+
// --- Standard library ---
+
+
#include <iostream.h>
+
#include <iomanip.h>
+
+
// --- AliRoot header files ---
+
+
#include "AliEMCALClusterizerv1.h"
+
#include "AliEMCALDigit.h"
+
#include "AliEMCALDigitizer.h"
+
#include "AliEMCALTowerRecPoint.h"
+
#include "AliEMCAL.h"
+
#include "AliEMCALGetter.h"
+
#include "AliEMCALGeometry.h"
+
#include "AliRun.h"
+
+
ClassImp(AliEMCALClusterizerv1)
+
+
//____________________________________________________________________________
+
AliEMCALClusterizerv1::AliEMCALClusterizerv1() : AliEMCALClusterizer()
+
{
+
// default ctor (to be used mainly by Streamer)
+
+
InitParameters() ;
+
fDefaultInit = kTRUE ;
+
}
+
+
//____________________________________________________________________________
+
AliEMCALClusterizerv1::AliEMCALClusterizerv1(const char* headerFile, const char* name, const Bool_t toSplit)
+
:AliEMCALClusterizer(headerFile, name, toSplit)
+
{
+
// ctor with the indication of the file where header Tree and digits Tree are stored
+
+
InitParameters() ;
+
Init() ;
+
fDefaultInit = kFALSE ;
+
+
}
+
+
//____________________________________________________________________________
+
AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
+
{
+
// dtor
+
fSplitFile = 0 ;
+
+
}
+
+
//____________________________________________________________________________
+
const TString AliEMCALClusterizerv1::BranchName() const
+
{
+
TString branchName(GetName() ) ;
+
branchName.Remove(branchName.Index(Version())-1) ;
+
return branchName ;
+
}
+
+
//____________________________________________________________________________
+
Float_t AliEMCALClusterizerv1::Calibrate(Int_t amp, Bool_t inpresho) const
+
{//To be replased later by the method, reading individual parameters from the database
+
+
if ( inpresho ) // calibrate as pre shower
+
return -fADCpedestalPreSho + amp * fADCchannelPreSho ;
+
+
else //calibrate as tower
+
return -fADCpedestalTower + amp * fADCchannelTower ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::Exec(Option_t * option)
+
{
+
// Steering method
+
+
if( strcmp(GetName(), "")== 0 )
+
Init() ;
+
+
if(strstr(option,"tim"))
+
gBenchmark->Start("EMCALClusterizer");
+
+
if(strstr(option,"print"))
+
Print("") ;
+
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
if(gime->BranchExists("RecPoints"))
+
return ;
+
Int_t nevents = gime->MaxEvent() ;
+
Int_t ievent ;
+
+
for(ievent = 0; ievent < nevents; ievent++){
+
+
gime->Event(ievent,"D") ;
+
+
if(ievent == 0)
+
GetCalibrationParameters() ;
+
+
fNumberOfTowerClusters = fNumberOfPreShoClusters = 0 ;
+
+
MakeClusters() ;
+
+
if(fToUnfold)
+
MakeUnfolding() ;
+
+
WriteRecPoints(ievent) ;
+
+
if(strstr(option,"deb"))
+
PrintRecPoints(option) ;
+
+
//increment the total number of digits per run
+
fRecPointsInRun += gime->TowerRecPoints()->GetEntriesFast() ;
+
fRecPointsInRun += gime->PreShowerRecPoints()->GetEntriesFast() ;
+
}
+
+
if(strstr(option,"tim")){
+
gBenchmark->Stop("EMCALClusterizer");
+
cout << "AliEMCALClusterizer:" << endl ;
+
cout << " took " << gBenchmark->GetCpuTime("EMCALClusterizer") << " seconds for Clusterizing "
+
<< gBenchmark->GetCpuTime("EMCALClusterizer")/nevents << " seconds per event " << endl ;
+
cout << endl ;
+
}
+
+
}
+
+
//____________________________________________________________________________
+
Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALTowerRecPoint * emcRP, AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
+
Int_t nPar, Float_t * fitparameters) const
+
{
+
// Calls TMinuit to fit the energy distribution of a cluster with several maxima
+
// The initial values for fitting procedure are set equal to the positions of local maxima.
+
// Cluster will be fitted as a superposition of nPar/3 electromagnetic showers
+
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
TClonesArray * digits = gime->Digits() ;
+
+
+
gMinuit->mncler(); // Reset Minuit's list of paramters
+
gMinuit->SetPrintLevel(-1) ; // No Printout
+
gMinuit->SetFCN(AliEMCALClusterizerv1::UnfoldingChiSquare) ;
+
// To set the address of the minimization function
+
+
TList * toMinuit = new TList();
+
toMinuit->AddAt(emcRP,0) ;
+
toMinuit->AddAt(digits,1) ;
+
+
gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare
+
+
// filling initial values for fit parameters
+
AliEMCALDigit * digit ;
+
+
Int_t ierflg = 0;
+
Int_t index = 0 ;
+
Int_t nDigits = (Int_t) nPar / 3 ;
+
+
Int_t iDigit ;
+
+
AliEMCALGeometry * geom = gime->EMCALGeometry() ;
+
+
for(iDigit = 0; iDigit < nDigits; iDigit++){
+
digit = maxAt[iDigit];
+
+
Int_t relid[4] ;
+
Float_t x = 0.;
+
Float_t z = 0.;
+
geom->AbsToRelNumbering(digit->GetId(), relid) ;
+
geom->PosInAlice(relid, x, z) ;
+
+
Float_t energy = maxAtEnergy[iDigit] ;
+
+
gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
+
index++ ;
+
if(ierflg != 0){
+
cout << "EMCAL Unfolding> Unable to set initial value for fit procedure : x = " << x << endl ;
+
return kFALSE;
+
}
+
gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
+
index++ ;
+
if(ierflg != 0){
+
cout << "EMCAL Unfolding> Unable to set initial value for fit procedure : z = " << z << endl ;
+
return kFALSE;
+
}
+
gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
+
index++ ;
+
if(ierflg != 0){
+
cout << "EMCAL Unfolding> Unable to set initial value for fit procedure : energy = " << energy << endl ;
+
return kFALSE;
+
}
+
}
+
+
Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
+
// depends on it.
+
Double_t p1 = 1.0 ;
+
Double_t p2 = 0.0 ;
+
+
gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
+
gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
+
gMinuit->SetMaxIterations(5);
+
gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
+
+
gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
+
+
if(ierflg == 4){ // Minimum not found
+
cout << "EMCAL Unfolding> Fit not converged, cluster abandoned "<< endl ;
+
return kFALSE ;
+
}
+
for(index = 0; index < nPar; index++){
+
Double_t err ;
+
Double_t val ;
+
gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
+
fitparameters[index] = val ;
+
}
+
+
delete toMinuit ;
+
return kTRUE;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::GetCalibrationParameters()
+
{
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
const AliEMCALDigitizer * dig = gime->Digitizer(BranchName()) ;
+
+
fADCchannelTower = dig->GetTowerchannel() ;
+
fADCpedestalTower = dig->GetTowerpedestal();
+
+
fADCchannelPreSho = dig->GetPreShochannel() ;
+
fADCpedestalPreSho = dig->GetPreShopedestal() ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::Init()
+
{
+
// Make all memory allocations which can not be done in default constructor.
+
// Attach the Clusterizer task to the list of EMCAL tasks
+
+
if ( strcmp(GetTitle(), "") == 0 )
+
SetTitle("galice.root") ;
+
+
TString branchname = GetName() ;
+
branchname.Remove(branchname.Index(Version())-1) ;
+
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance(GetTitle(), branchname.Data(), fToSplit ) ;
+
if ( gime == 0 ) {
+
cerr << "ERROR: AliEMCALClusterizerv1::Init -> Could not obtain the Getter object !" << endl ;
+
return ;
+
}
+
+
fSplitFile = 0 ;
+
if(fToSplit){
+
// construct the name of the file as /path/EMCAL.SDigits.root
+
//First - extract full path if necessary
+
TString fileName(GetTitle()) ;
+
Ssiz_t islash = fileName.Last('/') ;
+
if(islash<fileName.Length())
+
fileName.Remove(islash+1,fileName.Length()) ;
+
else
+
fileName="" ;
+
// Next - append the file name
+
fileName+="EMCAL.RecData." ;
+
if((strcmp(branchname.Data(),"Default")!=0)&&(strcmp(branchname.Data(),"")!=0)){
+
fileName+=branchname ;
+
fileName+="." ;
+
}
+
fileName+="root" ;
+
// Finally - check if the file already opened or open the file
+
fSplitFile = static_cast<TFile*>(gROOT->GetFile(fileName.Data()));
+
if(!fSplitFile)
+
fSplitFile = TFile::Open(fileName.Data(),"update") ;
+
}
+
+
+
const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
+
fNTowers = geom->GetNZ() * geom->GetNPhi() ;
+
+
if(!gMinuit)
+
gMinuit = new TMinuit(100) ;
+
+
gime->PostClusterizer(this) ;
+
gime->PostRecPoints(branchname ) ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::InitParameters()
+
{
+
fNumberOfPreShoClusters = fNumberOfTowerClusters = 0 ;
+
+
+
+
fPreShoClusteringThreshold = 0.0001;
+
fTowerClusteringThreshold = 0.2;
+
+
fTowerLocMaxCut = 0.03 ;
+
fPreShoLocMaxCut = 0.03 ;
+
+
fW0 = 4.5 ;
+
fW0CPV = 4.0 ;
+
+
fTimeGate = 1.e-8 ;
+
+
fToUnfold = kFALSE ;
+
+
TString clusterizerName( GetName()) ;
+
if (clusterizerName.IsNull() )
+
clusterizerName = "Default" ;
+
clusterizerName.Append(":") ;
+
clusterizerName.Append(Version()) ;
+
SetName(clusterizerName) ;
+
fRecPointsInRun = 0 ;
+
+
}
+
+
//____________________________________________________________________________
+
Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2)const
+
{
+
// Gives the neighbourness of two digits = 0 are not neighbour but continue searching
+
// = 1 are neighbour
+
// = 2 are not neighbour but do not continue searching
+
// neighbours are defined as digits having at least a common vertex
+
// The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
+
// which is compared to a digit (d2) not yet in a cluster
+
+
AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ;
+
+
Int_t rv = 0 ;
+
+
Int_t relid1[4] ;
+
geom->AbsToRelNumbering(d1->GetId(), relid1) ;
+
+
Int_t relid2[4] ;
+
geom->AbsToRelNumbering(d2->GetId(), relid2) ;
+
+
if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same EMCAL Arm
+
Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
+
Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
+
+
if (( coldiff <= 1 ) && ( rowdiff <= 1 )){
+
if((relid1[1] != 0) || (TMath::Abs(d1->GetTime() - d2->GetTime() ) < fTimeGate))
+
rv = 1 ;
+
}
+
else {
+
if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1))
+
rv = 2; // Difference in row numbers is too large to look further
+
}
+
+
}
+
else {
+
+
if( (relid1[0] < relid2[0]) || (relid1[1] != relid2[1]) )
+
rv=2 ;
+
+
}
+
+
return rv ;
+
}
+
+
+
//____________________________________________________________________________
+
Bool_t AliEMCALClusterizerv1::IsInTower(AliEMCALDigit * digit) const
+
{
+
// Tells if (true) or not (false) the digit is in a EMCAL-Tower
+
+
Bool_t rv = kFALSE ;
+
if (!digit->IsInPreShower())
+
rv = kTRUE;
+
return rv ;
+
}
+
+
//____________________________________________________________________________
+
Bool_t AliEMCALClusterizerv1::IsInPreShower(AliEMCALDigit * digit) const
+
{
+
// Tells if (true) or not (false) the digit is in a EMCAL-PreShower
+
+
Bool_t rv = kFALSE ;
+
if (digit->IsInPreShower())
+
rv = kTRUE;
+
return rv ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::WriteRecPoints(Int_t event)
+
{
+
+
// Creates new branches with given title
+
// fills and writes into TreeR.
+
+
AliEMCALGetter *gime = AliEMCALGetter::GetInstance() ;
+
TObjArray * towerRecPoints = gime->TowerRecPoints() ;
+
TObjArray * preshoRecPoints = gime->PreShowerRecPoints() ;
+
TClonesArray * digits = gime->Digits() ;
+
TTree * treeR ;
+
+
if(fToSplit){
+
if(!fSplitFile)
+
return ;
+
fSplitFile->cd() ;
+
TString name("TreeR") ;
+
name += event ;
+
treeR = dynamic_cast<TTree*>(fSplitFile->Get(name));
+
}
+
else{
+
treeR = gAlice->TreeR();
+
}
+
+
if(!treeR){
+
gAlice->MakeTree("R", fSplitFile);
+
treeR = gAlice->TreeR() ;
+
}
+
+
Int_t index ;
+
//Evaluate position, dispersion and other RecPoint properties...
+
for(index = 0; index < towerRecPoints->GetEntries(); index++)
+
(dynamic_cast<AliEMCALTowerRecPoint *>(towerRecPoints->At(index)))->EvalAll(fW0,digits) ;
+
+
towerRecPoints->Sort() ;
+
+
for(index = 0; index < towerRecPoints->GetEntries(); index++)
+
(dynamic_cast<AliEMCALTowerRecPoint *>(towerRecPoints->At(index)))->SetIndexInList(index) ;
+
+
towerRecPoints->Expand(towerRecPoints->GetEntriesFast()) ;
+
+
//Now the same for pre shower
+
for(index = 0; index < preshoRecPoints->GetEntries(); index++)
+
(dynamic_cast<AliEMCALRecPoint *>(preshoRecPoints->At(index)))->EvalAll(fW0CPV,digits) ;
+
+
preshoRecPoints->Sort() ;
+
+
for(index = 0; index < preshoRecPoints->GetEntries(); index++)
+
(dynamic_cast<AliEMCALRecPoint *>(preshoRecPoints->At(index)))->SetIndexInList(index) ;
+
+
preshoRecPoints->Expand(preshoRecPoints->GetEntriesFast()) ;
+
+
Int_t bufferSize = 32000 ;
+
Int_t splitlevel = 0 ;
+
+
//First Tower branch
+
TBranch * towerBranch = treeR->Branch("EMCALTowerRP","TObjArray",&towerRecPoints,bufferSize,splitlevel);
+
towerBranch->SetTitle(BranchName());
+
+
//Now Pre Shower branch
+
TBranch * preshoBranch = treeR->Branch("EMCALPreShoRP","TObjArray",&preshoRecPoints,bufferSize,splitlevel);
+
preshoBranch->SetTitle(BranchName());
+
+
//And Finally clusterizer branch
+
AliEMCALClusterizerv1 * cl = (AliEMCALClusterizerv1*)gime->Clusterizer(BranchName()) ;
+
TBranch * clusterizerBranch = treeR->Branch("AliEMCALClusterizer","AliEMCALClusterizerv1",
+
&cl,bufferSize,splitlevel);
+
clusterizerBranch->SetTitle(BranchName());
+
+
towerBranch ->Fill() ;
+
preshoBranch ->Fill() ;
+
clusterizerBranch->Fill() ;
+
+
treeR->AutoSave() ; //Write(0,kOverwrite) ;
+
if(gAlice->TreeR()!=treeR)
+
treeR->Delete();
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::MakeClusters()
+
{
+
// Steering method to construct the clusters stored in a list of Reconstructed Points
+
// A cluster is defined as a list of neighbour digits
+
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
+
TObjArray * towerRecPoints = gime->TowerRecPoints(BranchName()) ;
+
TObjArray * preshoRecPoints = gime->PreShowerRecPoints(BranchName()) ;
+
towerRecPoints->Delete() ;
+
preshoRecPoints->Delete() ;
+
+
TClonesArray * digits = gime->Digits() ;
+
if ( !digits ) {
+
cerr << "ERROR: AliEMCALClusterizerv1::MakeClusters -> Digits with name "
+
<< GetName() << " not found ! " << endl ;
+
abort() ;
+
}
+
TClonesArray * digitsC = dynamic_cast<TClonesArray*>(digits->Clone()) ;
+
+
+
// Clusterization starts
+
+
TIter nextdigit(digitsC) ;
+
AliEMCALDigit * digit ;
+
Bool_t notremoved = kTRUE ;
+
+
while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigit())) ) { // scan over the list of digitsC
+
AliEMCALRecPoint * clu = 0 ;
+
+
TArrayI clusterdigitslist(1500) ;
+
Int_t index ;
+
+
if (( IsInTower (digit) && Calibrate(digit->GetAmp(),digit->IsInPreShower()) > fTowerClusteringThreshold ) ||
+
( IsInPreShower (digit) && Calibrate(digit->GetAmp(),digit->IsInPreShower()) > fPreShoClusteringThreshold ) ) {
+
+
Int_t iDigitInCluster = 0 ;
+
+
if ( IsInTower(digit) ) {
+
// start a new Tower RecPoint
+
if(fNumberOfTowerClusters >= towerRecPoints->GetSize())
+
towerRecPoints->Expand(2*fNumberOfTowerClusters+1) ;
+
+
towerRecPoints->AddAt(new AliEMCALTowerRecPoint(""), fNumberOfTowerClusters) ;
+
clu = dynamic_cast<AliEMCALTowerRecPoint *>(towerRecPoints->At(fNumberOfTowerClusters)) ;
+
fNumberOfTowerClusters++ ;
+
clu->AddDigit(*digit, Calibrate(digit->GetAmp(),digit->IsInPreShower())) ;
+
clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ;
+
iDigitInCluster++ ;
+
digitsC->Remove(digit) ;
+
+
} else {
+
+
// start a new Pre Shower cluster
+
if(fNumberOfPreShoClusters >= preshoRecPoints->GetSize())
+
preshoRecPoints->Expand(2*fNumberOfPreShoClusters+1);
+
+
preshoRecPoints->AddAt(new AliEMCALTowerRecPoint(""), fNumberOfPreShoClusters) ;
+
+
clu = dynamic_cast<AliEMCALTowerRecPoint *>(preshoRecPoints->At(fNumberOfPreShoClusters)) ;
+
fNumberOfPreShoClusters++ ;
+
clu->AddDigit(*digit, Calibrate(digit->GetAmp(),digit->IsInPreShower() ) );
+
clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ;
+
iDigitInCluster++ ;
+
digitsC->Remove(digit) ;
+
nextdigit.Reset() ;
+
+
// Here we remove remaining Tower digits, which cannot make a cluster
+
+
if( notremoved ) {
+
while( ( digit = dynamic_cast<AliEMCALDigit *>(nextdigit()) ) ) {
+
if( IsInTower(digit) )
+
digitsC->Remove(digit) ;
+
else
+
break ;
+
}
+
notremoved = kFALSE ;
+
}
+
+
} // else
+
+
nextdigit.Reset() ;
+
+
AliEMCALDigit * digitN ;
+
index = 0 ;
+
while (index < iDigitInCluster){ // scan over digits already in cluster
+
digit = (AliEMCALDigit*)digits->At(clusterdigitslist[index]) ;
+
index++ ;
+
while ( (digitN = (AliEMCALDigit *)nextdigit()) ) { // scan over the reduced list of digits
+
Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!!
+
switch (ineb ) {
+
case 0 : // not a neighbour
+
break ;
+
case 1 : // are neighbours
+
clu->AddDigit(*digitN, Calibrate( digitN->GetAmp(), digitN->IsInPreShower() ) ) ;
+
clusterdigitslist[iDigitInCluster] = digitN->GetIndexInList() ;
+
iDigitInCluster++ ;
+
digitsC->Remove(digitN) ;
+
break ;
+
case 2 : // too far from each other
+
goto endofloop;
+
} // switch
+
+
} // while digitN
+
+
endofloop: ;
+
nextdigit.Reset() ;
+
+
} // loop over cluster
+
+
} // energy theshold
+
+
+
} // while digit
+
+
delete digitsC ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::MakeUnfolding()
+
{
+
Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
+
+
// // Unfolds clusters using the shape of an ElectroMagnetic shower
+
// // Performs unfolding of all EMC/CPV clusters
+
+
// AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
+
// const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
+
// TObjArray * emcRecPoints = gime->TowerRecPoints() ;
+
// TObjArray * cpvRecPoints = gime->PreShoRecPoints() ;
+
// TClonesArray * digits = gime->Digits() ;
+
+
// // Unfold first EMC clusters
+
// if(fNumberOfTowerClusters > 0){
+
+
// Int_t nModulesToUnfold = geom->GetNModules() ;
+
+
// Int_t numberofNotUnfolded = fNumberOfTowerClusters ;
+
// Int_t index ;
+
// for(index = 0 ; index < numberofNotUnfolded ; index++){
+
+
// AliEMCALTowerRecPoint * emcRecPoint = (AliEMCALTowerRecPoint *) emcRecPoints->At(index) ;
+
// if(emcRecPoint->GetEMCALMod()> nModulesToUnfold)
+
// break ;
+
+
// Int_t nMultipl = emcRecPoint->GetMultiplicity() ;
+
// Int_t * maxAt = new Int_t[nMultipl] ;
+
// Float_t * maxAtEnergy = new Float_t[nMultipl] ;
+
// Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fTowerLocMaxCut,digits) ;
+
+
// if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0
+
// UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ;
+
// emcRecPoints->Remove(emcRecPoint);
+
// emcRecPoints->Compress() ;
+
// index-- ;
+
// fNumberOfTowerClusters -- ;
+
// numberofNotUnfolded-- ;
+
// }
+
+
// delete[] maxAt ;
+
// delete[] maxAtEnergy ;
+
// }
+
// }
+
// // Unfolding of EMC clusters finished
+
+
+
// // Unfold now CPV clusters
+
// if(fNumberOfPreShoClusters > 0){
+
+
// Int_t nModulesToUnfold = geom->GetNModules() ;
+
+
// Int_t numberofPreShoNotUnfolded = fNumberOfPreShoClusters ;
+
// Int_t index ;
+
// for(index = 0 ; index < numberofPreShoNotUnfolded ; index++){
+
+
// AliEMCALRecPoint * recPoint = (AliEMCALRecPoint *) cpvRecPoints->At(index) ;
+
+
// if(recPoint->GetEMCALMod()> nModulesToUnfold)
+
// break ;
+
+
// AliEMCALTowerRecPoint * emcRecPoint = (AliEMCALTowerRecPoint*) recPoint ;
+
+
// Int_t nMultipl = emcRecPoint->GetMultiplicity() ;
+
// Int_t * maxAt = new Int_t[nMultipl] ;
+
// Float_t * maxAtEnergy = new Float_t[nMultipl] ;
+
// Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fPreShoLocMaxCut,digits) ;
+
+
// if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0
+
// UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ;
+
// cpvRecPoints->Remove(emcRecPoint);
+
// cpvRecPoints->Compress() ;
+
// index-- ;
+
// numberofPreShoNotUnfolded-- ;
+
// fNumberOfPreShoClusters-- ;
+
// }
+
+
// delete[] maxAt ;
+
// delete[] maxAtEnergy ;
+
// }
+
// }
+
// //Unfolding of PreSho clusters finished
+
+
}
+
+
//____________________________________________________________________________
+
Double_t AliEMCALClusterizerv1::ShowerShape(Double_t r)
+
{
+
// Shape of the shower (see EMCAL TDR)
+
// If you change this function, change also the gradient evaluation in ChiSquare()
+
+
Double_t r4 = r*r*r*r ;
+
Double_t r295 = TMath::Power(r, 2.95) ;
+
Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
+
return shape ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALTowerRecPoint * iniTower,
+
Int_t nMax,
+
AliEMCALDigit ** maxAt,
+
Float_t * maxAtEnergy)
+
{
+
// Performs the unfolding of a cluster with nMax overlapping showers
+
+
Fatal("AliEMCALClusterizerv1::UnfoldCluster", "--> Unfolding not implemented") ;
+
+
// AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
// const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
+
// const TClonesArray * digits = gime->Digits() ;
+
// TObjArray * emcRecPoints = gime->TowerRecPoints() ;
+
// TObjArray * cpvRecPoints = gime->PreShoRecPoints() ;
+
+
// Int_t nPar = 3 * nMax ;
+
// Float_t * fitparameters = new Float_t[nPar] ;
+
+
// Bool_t rv = FindFit(iniTower, maxAt, maxAtEnergy, nPar, fitparameters) ;
+
// if( !rv ) {
+
// // Fit failed, return and remove cluster
+
// delete[] fitparameters ;
+
// return ;
+
// }
+
+
// // create ufolded rec points and fill them with new energy lists
+
// // First calculate energy deposited in each sell in accordance with fit (without fluctuations): efit[]
+
// // and later correct this number in acordance with actual energy deposition
+
+
// Int_t nDigits = iniTower->GetMultiplicity() ;
+
// Float_t * efit = new Float_t[nDigits] ;
+
// Float_t xDigit=0.,zDigit=0.,distance=0. ;
+
// Float_t xpar=0.,zpar=0.,epar=0. ;
+
// Int_t relid[4] ;
+
// AliEMCALDigit * digit = 0 ;
+
// Int_t * emcDigits = iniTower->GetDigitsList() ;
+
+
// Int_t iparam ;
+
// Int_t iDigit ;
+
// for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
+
// digit = (AliEMCALDigit*) digits->At(emcDigits[iDigit] ) ;
+
// geom->AbsToRelNumbering(digit->GetId(), relid) ;
+
// geom->RelPosInModule(relid, xDigit, zDigit) ;
+
// efit[iDigit] = 0;
+
+
// iparam = 0 ;
+
// while(iparam < nPar ){
+
// xpar = fitparameters[iparam] ;
+
// zpar = fitparameters[iparam+1] ;
+
// epar = fitparameters[iparam+2] ;
+
// iparam += 3 ;
+
// distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
+
// distance = TMath::Sqrt(distance) ;
+
// efit[iDigit] += epar * ShowerShape(distance) ;
+
// }
+
// }
+
+
+
// // Now create new RecPoints and fill energy lists with efit corrected to fluctuations
+
// // so that energy deposited in each cell is distributed betwin new clusters proportionally
+
// // to its contribution to efit
+
+
// Float_t * emcEnergies = iniTower->GetEnergiesList() ;
+
// Float_t ratio ;
+
+
// iparam = 0 ;
+
// while(iparam < nPar ){
+
// xpar = fitparameters[iparam] ;
+
// zpar = fitparameters[iparam+1] ;
+
// epar = fitparameters[iparam+2] ;
+
// iparam += 3 ;
+
+
// AliEMCALTowerRecPoint * emcRP = 0 ;
+
+
// if(iniTower->IsTower()){ //create new entries in fTowerRecPoints...
+
+
// if(fNumberOfTowerClusters >= emcRecPoints->GetSize())
+
// emcRecPoints->Expand(2*fNumberOfTowerClusters) ;
+
+
// (*emcRecPoints)[fNumberOfTowerClusters] = new AliEMCALTowerRecPoint("") ;
+
// emcRP = (AliEMCALTowerRecPoint *) emcRecPoints->At(fNumberOfTowerClusters);
+
// fNumberOfTowerClusters++ ;
+
// }
+
// else{//create new entries in fPreShoRecPoints
+
// if(fNumberOfPreShoClusters >= cpvRecPoints->GetSize())
+
// cpvRecPoints->Expand(2*fNumberOfPreShoClusters) ;
+
+
// (*cpvRecPoints)[fNumberOfPreShoClusters] = new AliEMCALPreShoRecPoint("") ;
+
// emcRP = (AliEMCALTowerRecPoint *) cpvRecPoints->At(fNumberOfPreShoClusters);
+
// fNumberOfPreShoClusters++ ;
+
// }
+
+
// Float_t eDigit ;
+
// for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
+
// digit = (AliEMCALDigit*) digits->At( emcDigits[iDigit] ) ;
+
// geom->AbsToRelNumbering(digit->GetId(), relid) ;
+
// geom->RelPosInModule(relid, xDigit, zDigit) ;
+
// distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
+
// distance = TMath::Sqrt(distance) ;
+
// ratio = epar * ShowerShape(distance) / efit[iDigit] ;
+
// eDigit = emcEnergies[iDigit] * ratio ;
+
// emcRP->AddDigit( *digit, eDigit ) ;
+
// }
+
// }
+
+
// delete[] fitparameters ;
+
// delete[] efit ;
+
+
}
+
+
//_____________________________________________________________________________
+
void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag)
+
{
+
// Calculates the Chi square for the cluster unfolding minimization
+
// Number of parameters, Gradient, Chi squared, parameters, what to do
+
+
abort() ;
+
// Fatal("AliEMCALClusterizerv1::UnfoldingChiSquare","-->Unfolding not implemented") ;
+
+
// TList * toMinuit = (TList*) gMinuit->GetObjectFit() ;
+
+
// AliEMCALTowerRecPoint * emcRP = (AliEMCALTowerRecPoint*) toMinuit->At(0) ;
+
// TClonesArray * digits = (TClonesArray*)toMinuit->At(1) ;
+
+
+
+
// // AliEMCALTowerRecPoint * emcRP = (AliEMCALTowerRecPoint *) gMinuit->GetObjectFit() ; // TowerRecPoint to fit
+
+
// Int_t * emcDigits = emcRP->GetDigitsList() ;
+
+
// Int_t nOdigits = emcRP->GetDigitsMultiplicity() ;
+
+
// Float_t * emcEnergies = emcRP->GetEnergiesList() ;
+
+
// const AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ;
+
// fret = 0. ;
+
// Int_t iparam ;
+
+
// if(iflag == 2)
+
// for(iparam = 0 ; iparam < nPar ; iparam++)
+
// Grad[iparam] = 0 ; // Will evaluate gradient
+
+
// Double_t efit ;
+
+
// AliEMCALDigit * digit ;
+
// Int_t iDigit ;
+
+
// for( iDigit = 0 ; iDigit < nOdigits ; iDigit++) {
+
+
// digit = (AliEMCALDigit*) digits->At( emcDigits[iDigit] ) ;
+
+
// Int_t relid[4] ;
+
// Float_t xDigit ;
+
// Float_t zDigit ;
+
+
// geom->AbsToRelNumbering(digit->GetId(), relid) ;
+
+
// geom->RelPosInModule(relid, xDigit, zDigit) ;
+
+
// if(iflag == 2){ // calculate gradient
+
// Int_t iParam = 0 ;
+
// efit = 0 ;
+
// while(iParam < nPar ){
+
// Double_t distance = (xDigit - x[iParam]) * (xDigit - x[iParam]) ;
+
// iParam++ ;
+
// distance += (zDigit - x[iParam]) * (zDigit - x[iParam]) ;
+
// distance = TMath::Sqrt( distance ) ;
+
// iParam++ ;
+
// efit += x[iParam] * ShowerShape(distance) ;
+
// iParam++ ;
+
// }
+
// Double_t sum = 2. * (efit - emcEnergies[iDigit]) / emcEnergies[iDigit] ; // Here we assume, that sigma = sqrt(E)
+
// iParam = 0 ;
+
// while(iParam < nPar ){
+
// Double_t xpar = x[iParam] ;
+
// Double_t zpar = x[iParam+1] ;
+
// Double_t epar = x[iParam+2] ;
+
// Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) );
+
// Double_t shape = sum * ShowerShape(dr) ;
+
// Double_t r4 = dr*dr*dr*dr ;
+
// Double_t r295 = TMath::Power(dr,2.95) ;
+
// Double_t deriv =-4. * dr*dr * ( 2.32 / ( (2.32 + 0.26 * r4) * (2.32 + 0.26 * r4) ) +
+
// 0.0316 * (1. + 0.0171 * r295) / ( ( 1. + 0.0652 * r295) * (1. + 0.0652 * r295) ) ) ;
+
+
// Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ; // Derivative over x
+
// iParam++ ;
+
// Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ; // Derivative over z
+
// iParam++ ;
+
// Grad[iParam] += shape ; // Derivative over energy
+
// iParam++ ;
+
// }
+
// }
+
// efit = 0;
+
// iparam = 0 ;
+
+
// while(iparam < nPar ){
+
// Double_t xpar = x[iparam] ;
+
// Double_t zpar = x[iparam+1] ;
+
// Double_t epar = x[iparam+2] ;
+
// iparam += 3 ;
+
// Double_t distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
+
// distance = TMath::Sqrt(distance) ;
+
// efit += epar * ShowerShape(distance) ;
+
// }
+
+
// fret += (efit-emcEnergies[iDigit])*(efit-emcEnergies[iDigit])/emcEnergies[iDigit] ;
+
// // Here we assume, that sigma = sqrt(E)
+
// }
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::Print(Option_t * option)const
+
{
+
// Print clusterizer parameters
+
+
if( strcmp(GetName(), "") !=0 ){
+
+
// Print parameters
+
+
TString taskName(GetName()) ;
+
taskName.ReplaceAll(Version(), "") ;
+
+
cout << "---------------"<< taskName.Data() << " " << GetTitle()<< "-----------" << endl
+
<< "Clusterizing digits from the file: " << taskName.Data() << endl
+
<< " Branch: " << GetName() << endl
+
<< endl
+
<< " EMC Clustering threshold = " << fTowerClusteringThreshold << endl
+
<< " EMC Local Maximum cut = " << fTowerLocMaxCut << endl
+
<< " EMC Logarothmic weight = " << fW0 << endl
+
<< endl
+
<< " CPV Clustering threshold = " << fPreShoClusteringThreshold << endl
+
<< " CPV Local Maximum cut = " << fPreShoLocMaxCut << endl
+
<< " CPV Logarothmic weight = " << fW0CPV << endl
+
<< endl ;
+
if(fToUnfold)
+
cout << " Unfolding on " << endl ;
+
else
+
cout << " Unfolding off " << endl ;
+
+
cout << "------------------------------------------------------------------" <<endl ;
+
}
+
else
+
cout << " AliEMCALClusterizerv1 not initialized " << endl ;
+
}
+
//____________________________________________________________________________
+
void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
+
{
+
// Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
+
+
TObjArray * towerRecPoints = AliEMCALGetter::GetInstance()->TowerRecPoints() ;
+
TObjArray * preshoRecPoints = AliEMCALGetter::GetInstance()->PreShowerRecPoints() ;
+
+
cout << "AliEMCALClusterizerv1: : event "<<gAlice->GetEvNumber() << endl ;
+
cout << " Found "<< towerRecPoints->GetEntriesFast() << " TOWER Rec Points and "
+
<< preshoRecPoints->GetEntriesFast() << " PRE SHOWER RecPoints" << endl ;
+
+
fRecPointsInRun += towerRecPoints->GetEntriesFast() ;
+
fRecPointsInRun += preshoRecPoints->GetEntriesFast() ;
+
+
if(strstr(option,"all")) {
+
+
cout << "Tower clusters " << endl ;
+
cout << " Index Ene(MeV) Multi Module phi r theta Lambda 1 Lambda 2 # of prim Primaries list " << endl;
+
+
Int_t index ;
+
for (index = 0 ; index < towerRecPoints->GetEntries() ; index++) {
+
AliEMCALTowerRecPoint * rp = dynamic_cast<AliEMCALTowerRecPoint * >(towerRecPoints->At(index)) ;
+
TVector3 globalpos;
+
rp->GetGlobalPosition(globalpos);
+
Float_t lambda[2];
+
rp->GetElipsAxis(lambda);
+
Int_t * primaries;
+
Int_t nprimaries;
+
primaries = rp->GetPrimaries(nprimaries);
+
+
cout << setw(4) << rp->GetIndexInList() << " "
+
<< setw(7) << setprecision(3) << rp->GetEnergy() << " "
+
<< setw(3) << rp->GetMultiplicity() << " "
+
<< setw(1) << rp->GetEMCALArm() << " "
+
<< setw(5) << setprecision(4) << globalpos.X() << " "
+
<< setw(5) << setprecision(4) << globalpos.Y() << " "
+
<< setw(5) << setprecision(4) << globalpos.Z() << " "
+
<< setw(4) << setprecision(2) << lambda[0] << " "
+
<< setw(4) << setprecision(2) << lambda[1] << " "
+
<< setw(2) << nprimaries << " " ;
+
+
for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
+
cout << setw(4) << primaries[iprimary] << " " ;
+
cout << endl ;
+
}
+
+
//Now plot Pre shower recPoints
+
+
cout << "-----------------------------------------------------------------------"<<endl ;
+
+
cout << "PreShower clusters " << endl ;
+
cout << " Index Ene(MeV) Multi Module phi r theta Lambda 1 Lambda 2 # of prim Primaries list " << endl;
+
+
for (index = 0 ; index < preshoRecPoints->GetEntries() ; index++) {
+
AliEMCALTowerRecPoint * rp = dynamic_cast<AliEMCALTowerRecPoint *>(preshoRecPoints->At(index)) ;
+
TVector3 globalpos;
+
rp->GetGlobalPosition(globalpos);
+
Float_t lambda[2];
+
rp->GetElipsAxis(lambda);
+
Int_t * primaries;
+
Int_t nprimaries;
+
primaries = rp->GetPrimaries(nprimaries);
+
+
cout << setw(4) << rp->GetIndexInList() << " "
+
<< setw(7) << setprecision(3) << rp->GetEnergy() << " "
+
<< setw(3) << rp->GetMultiplicity() << " "
+
<< setw(1) << rp->GetEMCALArm() << " "
+
<< setw(5) << setprecision(4) << globalpos.X() << " "
+
<< setw(5) << setprecision(4) << globalpos.Y() << " "
+
<< setw(5) << setprecision(4) << globalpos.Z() << " "
+
<< setw(4) << setprecision(2) << lambda[0] << " "
+
<< setw(4) << setprecision(2) << lambda[1] << " "
+
<< setw(2) << nprimaries << " " ;
+
+
for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
+
cout << setw(4) << primaries[iprimary] << " " ;
+
cout << endl ;
+
}
+
+
cout << "-----------------------------------------------------------------------"<<endl ;
+
}
+
}
+
+
/**************************************************************************
+
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+
* *
+
* Author: The ALICE Off-line Project. *
+
* Contributors are mentioned in the code where appropriate. *
+
* *
+
* Permission to use, copy, modify and distribute this software and its *
+
* documentation strictly for non-commercial purposes is hereby granted *
+
* without fee, provided that the above copyright notice appears in all *
+
* copies and that both the copyright notice and this permission notice *
+
* appear in the supporting documentation. The authors make no claims *
+
* about the suitability of this software for any purpose. It is *
+
* provided "as is" without express or implied warranty. *
+
**************************************************************************/
+
+
/* $Id$*/
+
+
//_________________________________________________________________________
+
// Geometry class for EMCAL : singleton
+
// EMCAL consists of layers of scintillator and lead
+
// Places the the Barrel Geometry of The EMCAL at Midrapidity
+
// between 0 and 120 degrees of Phi and
+
// -0.7 to 0.7 in eta
+
// Number of Modules and Layers may be controlled by
+
// the name of the instance defined
+
// EMCALArch2x has more modules along both phi and eta
+
// EMCALArchxa has less Layers in the Radial Direction
+
//*-- Author: Sahal Yacoob (LBL / UCT)
+
// and : Yves Schutz (SUBATECH)
+
// and : Jennifer Klay (LBL)
+
+
// --- ROOT system ---
+
+
// --- Standard library ---
+
+
#include <iostream.h>
+
+
// --- AliRoot header files ---
+
#include <TMath.h>
+
// -- ALICE Headers.
+
#include "AliConst.h"
+
// --- EMCAL headers
+
#include "AliEMCALGeometry.h"
+
+
ClassImp(AliEMCALGeometry);
+
+
AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
+
Bool_t AliEMCALGeometry::fgInit = kFALSE;
+
+
//______________________________________________________________________
+
AliEMCALGeometry::~AliEMCALGeometry(void){
+
// dtor
+
}
+
//______________________________________________________________________
+
void AliEMCALGeometry::Init(void){
+
// Initializes the EMCAL parameters
+
+
fgInit = kFALSE; // Assume failer untill proven otherwise.
+
+
TString name(GetName()) ;
+
+
if( name != "EMCALArch1a" &&
+
name != "EMCALArch1b" &&
+
name != "EMCALArch2a" &&
+
name != "EMCALArch2b" ){
+
cerr << "ERROR: " << ClassName() << "::Init -> " << name.Data()
+
<< " is not a known geometry (choose among EMCALArch1a, EMCALArch1b, EMCALArch2a and EMCALArch2b)"
+
<< endl ;
+
abort() ;
+
} // end if
+
//
+
if ( name == "EMCALArch1a" ||
+
name == "EMCALArch1b" ) {
+
fNZ = 96;
+
fNPhi = 144;
+
} // end if
+
if ( name == "EMCALArch2a" ||
+
name, "EMCALArch2b" ) {
+
fNZ = 112;
+
fNPhi = 168;
+
} // end if
+
if ( name == "EMCALArch1a" ||
+
name == "EMCALArch2a" ) {
+
fNLayers = 21;
+
} // end if
+
if ( name == "EMCALArch1b" ||
+
name == "EMCALArch2b" ) {
+
fNLayers = 25;
+
} // end if
+
+
// geometry
+
fAirGap = 5.0; // cm, air gap between EMCAL mother volume and
+
// active material.
+
fAlFrontThick = 3.18; // cm, Thickness of front Al layer
+
fPbRadThickness = 0.5; // cm, Thickness of theh Pb radiators.
+
fPreShowerSintThick = 0.6; // cm, Thickness of the sintilator for the
+
// preshower part of the calorimeter
+
fFullShowerSintThick = 0.5; // cm, Thickness of the sintilator for the
+
// full shower part of the calorimeter
+
fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position
+
fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position
+
fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
+
fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
+
fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL
+
fShellThickness = GetAlFrontThickness() + 2.*GetPreSintThick() +
+
(fNLayers-2)*GetFullSintThick()+(fNLayers-1)*GetPbRadThick();
+
//below; cm, Z lenght of the EMCAL.
+
fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax);
+
fEnvelop[0] = fIPDistance; // mother volume inner radius
+
fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
+
fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
+
fGap2Active = 1.0; // cm, Gap between
+
fgInit = kTRUE;
+
}
+
//______________________________________________________________________
+
AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
+
// Returns the pointer of the unique instance
+
+
return static_cast<AliEMCALGeometry *>( fgGeom ) ;
+
}
+
//______________________________________________________________________
+
AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
+
const Text_t* title){
+
// Returns the pointer of the unique instance
+
+
AliEMCALGeometry * rv = 0;
+
if ( fgGeom == 0 ) {
+
if ( strcmp(name,"") == 0 ) rv = 0;
+
else {
+
fgGeom = new AliEMCALGeometry(name, title);
+
if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
+
else {
+
rv = 0;
+
delete fgGeom;
+
fgGeom = 0;
+
} // end if fgInit
+
} // end if strcmp(name,"")
+
}else{
+
if ( strcmp(fgGeom->GetName(), name) != 0 ) {
+
cout << "AliEMCALGeometry <E> : current geometry is "
+
<< fgGeom->GetName() << endl
+
<< " you cannot call " << name
+
<< endl;
+
}else{
+
rv = (AliEMCALGeometry *) fgGeom;
+
} // end if
+
} // end if fgGeom
+
return rv;
+
}
+
//______________________________________________________________________
+
Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi,Int_t ipre) const {
+
// Returns the tower index number from the based on the Z and Phi
+
// index numbers. There are 2 times the number of towers to separate
+
// out the full towsers from the pre-towsers.
+
// Inputs:
+
// Int_t ieta // index allong z axis [1-fNZ]
+
// Int_t iphi // index allong phi axis [1-fNPhi]
+
// Int_t ipre // 0 = Full tower, 1 = Pre-shower tower only. [0,1]
+
// Outputs:
+
// none.
+
// Returned
+
// Int_t the absoulute tower index. [1-2*fNZ*fNPhi]
+
Int_t index;
+
+
if((ieta<=0 || ieta>GetNEta()) || (iphi<=0 || iphi>GetNPhi()) ||
+
(ipre<0 || ipre>1) ){
+
cout << "inputs out of range ieta=" << ieta << " [1-" << GetNEta();
+
cout << "] iphi=" << iphi << " [1-" << GetNPhi() << "] ipre=";
+
cout << ipre << "[0,1]. returning -1" << endl;
+
return -1;
+
} // end if
+
index = iphi + GetNPhi()*(ieta-1) + ipre*(GetNPhi()*GetNEta());
+
return index;
+
}
+
//______________________________________________________________________
+
void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi,
+
Int_t &ipre) const {
+
// given the tower index number it returns the based on the Z and Phi
+
// index numbers and if it is for the full tower or the pre-tower number.
+
// There are 2 times the number of towers to separate
+
// out the full towsers from the pre-towsers.
+
// Inputs:
+
// Int_t index // Tower index number [1-2*fNZ*fNPhi]
+
// Outputs:
+
// Int_t ieta // index allong z axis [1-fNZ]
+
// Int_t iphi // index allong phi axis [1-fNPhi]
+
// Int_t ipre // 0 = Full tower, 1 = Pre-shower tower only. [0,1]
+
// Returned
+
// none.
+
Int_t itowers;
+
+
itowers = GetNEta()*GetNPhi();
+
if(index<1 || index>2*itowers){
+
cout << "index=" << index <<" is out of range [1-";
+
cout << 2*itowers << "], returning -1 for all." << endl;
+
ieta = -1; iphi = -1; ipre = -1;
+
return ;
+
} // end if
+
ipre = 0;
+
if(index>itowers){ // pre shower indexs
+
ipre = 1;
+
index = index - itowers;
+
} // end if
+
ieta = 1+ (Int_t)((index-1)/GetNPhi());
+
iphi = index - GetNPhi()*(ieta-1);
+
return;
+
}
+
//______________________________________________________________________
+
void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const {
+
// given the tower index number it returns the based on the eta and phi
+
// of the tower.
+
// Inputs:
+
// Int_t index // Tower index number [1-2*fNZ*fNPhi]
+
// Outputs:
+
// Float_t eta // eta of center of tower in pseudorapidity
+
// Float_t phi // phi of center of tower in degrees
+
// Returned
+
// none.
+
Int_t ieta,iphi,ipre;
+
Double_t deta,dphi,phid;
+
+
TowerIndexes(index,ieta,iphi,ipre);
+
deta = (GetArm1EtaMax()-GetArm1EtaMin())/((Float_t)GetNEta());
+
eta = GetArm1EtaMin() + (((Float_t)ieta)-0.5)*deta;
+
dphi = (GetArm1PhiMax() - GetArm1PhiMin())/((Float_t)GetNPhi()); // in degrees.
+
phid = GetArm1PhiMin() + dphi*((Float_t)iphi -0.5);//iphi range [1-fNphi].
+
phi = phid;
+
}
+
//______________________________________________________________________
+
Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
+
// returns the tower index number based on the eta and phi of the tower.
+
// Inputs:
+
// Float_t eta // eta of center of tower in pseudorapidity
+
// Float_t phi // phi of center of tower in degrees
+
// Outputs:
+
// none.
+
// Returned
+
// Int_t index // Tower index number [1-fNZ*fNPhi]
+
Int_t ieta,iphi;
+
+
ieta = 1 + (Int_t)(((Float_t)GetNEta())*(eta-GetArm1EtaMin())/
+
(GetArm1EtaMax() - GetArm1EtaMin()));
+
if(ieta<=0 || ieta>GetNEta()){
+
cout << "TowerIndexFromEtaPhi:";
+
cout << "ieta = "<< ieta << " eta=" << eta << " is outside of EMCAL. etamin=";
+
cout << GetArm1EtaMin() << " to etamax=" << GetArm1EtaMax();
+
cout << " returning -1" << endl;
+
return -1;
+
} // end if
+
iphi = 1 + (Int_t)(((Float_t)GetNPhi())*(phi-GetArm1PhiMin())/
+
((Float_t)(GetArm1PhiMax() - GetArm1PhiMin())));
+
if(iphi<=0 || iphi>GetNPhi()){
+
cout << "TowerIndexFromEtaPhi:";
+
cout << "iphi=" << iphi << " phi=" << phi << " is outside of EMCAL.";
+
cout << " Phimin=" << GetArm1PhiMin() << " PhiMax=" << GetArm1PhiMax();
+
cout << " returning -1" << endl;
+
return -1;
+
} // end if
+
return TowerIndex(ieta,iphi,0);
+
}
+
//______________________________________________________________________
+
Int_t AliEMCALGeometry::PreTowerIndexFromEtaPhi(Float_t eta,Float_t phi) const {
+
// returns the pretower index number based on the eta and phi of the tower.
+
// Inputs:
+
// Float_t eta // eta of center of tower in pseudorapidity
+
// Float_t phi // phi of center of tower in degrees
+
// Outputs:
+
// none.
+
// Returned
+
// Int_t index // PreTower index number [fNZ*fNPhi-2*fNZ*fNPhi]
+
+
return GetNEta()*GetNPhi()+TowerIndexFromEtaPhi(eta,phi);
+
}
+
//______________________________________________________________________
+
Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const {
+
// Converts the absolute numbering into the following array/
+
// relid[0] = EMCAL Arm number 1:1
+
// relid[1] = 0 Not in Pre Shower layers
+
// = -1 In Pre Shower
+
// relid[2] = Row number inside EMCAL
+
// relid[3] = Column number inside EMCAL
+
// Input:
+
// Int_t AbsId // Tower index number [1-2*fNZ*fNPhi]
+
// Outputs:
+
// Int_t *relid // array of 5. Discribed above.
+
Bool_t rv = kTRUE ;
+
Int_t ieta=0,iphi=0,ipre=0,index=AbsId;
+
+
TowerIndexes(index,ieta,iphi,ipre);
+
relid[0] = 1;
+
relid[1] = 0;
+
if(ipre==1)
+
relid[1] = -1;
+
relid[2] = ieta;
+
relid[3] = iphi;
+
+
return rv;
+
}
+
//______________________________________________________________________
+
void AliEMCALGeometry::PosInAlice(const Int_t *relid,Float_t &theta,
+
Float_t &phi) const {
+
// Converts the relative numbering into the local EMCAL-module (x, z)
+
// coordinates
+
Int_t ieta = relid[2]; // offset along x axis
+
Int_t iphi = relid[3]; // offset along z axis
+
Int_t ipre = relid[1]; // indicates -1 preshower, or 0 full tower.
+
Int_t index;
+
Float_t eta;
+
+
if(ipre==-1) ipre = 1;
+
index = TowerIndex(ieta,iphi,ipre);
+
EtaPhiFromIndex(index,eta,phi);
+
theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
+
+
return;
+
}
+
+
//______________________________________________________________________
+
void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const {
+
// given the tower relative number it returns the X, Y and Z
+
// of the tower.
+
+
// Outputs:
+
// Float_t x // x of center of tower in cm
+
// Float_t y // y of center of tower in cm
+
// Float_t z // z of centre of tower in cm
+
// Returned
+
// none.
+
+
Float_t eta,theta, phi,cyl_radius,kDeg2Rad;
+
+
Int_t ieta = relid[2]; // offset along x axis
+
Int_t iphi = relid[3]; // offset along z axis
+
Int_t ipre = relid[1]; // indicates -1 preshower, or 0 full tower.
+
Int_t index;
+
+
+
if(ipre==-1) ipre = 1;
+
index = TowerIndex(ieta,iphi,ipre);
+
EtaPhiFromIndex(index,eta,phi);
+
theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi();
+
+
+
+
kDeg2Rad = TMath::Pi() / static_cast<Double_t>(180) ;
+
cyl_radius = GetIPDistance()+ GetAirGap() ;
+
x = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
+
y = cyl_radius * TMath::Cos(phi * kDeg2Rad ) ;
+
z = cyl_radius / TMath::Tan(theta * kDeg2Rad ) ;
+
+
return;
+
}
+
+
//______________________________________________________________________
+
/*
+
Boot_t AliEMCALGeometry::AreNeighbours(Int_t index1,Int_t index2) const {
+
// Returns kTRUE if the two towers are neighbours or not, including
+
// diagonals. Both indexes are required to be either towers or preshower.
+
// Inputs:
+
// Int_t index1 // index of tower 1
+
// Int_t index2 // index of tower 2
+
// Outputs:
+
// none.
+
// Returned
+
// Boot_t kTRUE if the towers are neighbours otherwise false.
+
Boot_t anb = kFALSE;
+
Int_t ieta1 = 0, ieta2 = 0, iphi1 = 0, iphi2 = 0, ipre1 = 0, ipre2 = 0;
+
+
TowerIndexes(index1,ieta1,iphi1,ipre1);
+
TowerIndexes(index2,ieta2,iphi2,ipre2);
+
if(ipre1!=ipre2) return anb;
+
if((ieta1>=ieta2-1 && ieta1<=ieta2+1) && (iphi1>=iphi2-1 &&iphi1<=iphi2+1))
+
anb = kTRUE;
+
return anb;
+
}
+
*/
+
/**************************************************************************
+
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+
* *
+
* Author: The ALICE Off-line Project. *
+
* Contributors are mentioned in the code where appropriate. *
+
* *
+
* Permission to use, copy, modify and distribute this software and its *
+
* documentation strictly for non-commercial purposes is hereby granted *
+
* without fee, provided that the above copyright notice appears in all *
+
* copies and that both the copyright notice and this permission notice *
+
* appear in the supporting documentation. The authors make no claims *
+
* about the suitability of this software for any purpose. It is *
+
* provided "as is" without express or implied warranty. *
+
**************************************************************************/
+
+
/* $Id: */
+
+
/* $Log:
+
29.05.2001 Yuri Kharlov:
+
Everywhere reading the treese TTree->GetEvent(i)
+
is replaced by reading the branches TBranch->GetEntry(0)
+
*/
+
/* $Log:
+
08.2002 Dmitri Peressounko:
+
+
*/
+
+
//_________________________________________________________________________
+
// A singleton. This class should be used in the analysis stage to get
+
// reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
+
// instead of directly reading them from galice.root file. This container
+
// ensures, that one reads Digits, made of these particular digits, RecPoints,
+
// made of these particular RecPoints, TrackSegments and RecParticles.
+
// This becomes non trivial if there are several identical branches, produced with
+
// different set of parameters.
+
//
+
// An example of how to use (see also class AliEMCALAnalyser):
+
// AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ;
+
// for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
+
// AliEMCALRecParticle * part = gime->RecParticle(1) ;
+
// ................
+
// please->GetEvent(event) ; // reads new event from galice.root
+
//
+
//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
+
//*-- Completely redesigned by Dmitri Peressounko March 2001
+
//
+
//*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
+
//*-- systematic usage of TFolders without changing the interface
+
//*-- YS August 2002 : clone PHOS as closely as possible and intoduction
+
// of new IO (à la PHOS)
+
//////////////////////////////////////////////////////////////////////////////
+
+
// --- ROOT system ---
+
#include "TFile.h"
+
#include "TTree.h"
+
#include "TROOT.h"
+
#include "TObjString.h"
+
#include "TFolder.h"
+
#include "TParticle.h"
+
+
// --- Standard library ---
+
#include <iostream.h>
+
+
// --- AliRoot header files ---
+
#include "AliRun.h"
+
#include "AliConfig.h"
+
#include "AliEMCALGetter.h"
+
#include "AliEMCAL.h"
+
#include "AliEMCALDigitizer.h"
+
#include "AliEMCALSDigitizer.h"
+
#include "AliEMCALClusterizerv1.h"
+
//#include "AliEMCALTrackSegmentMakerv1.h"
+
//#include "AliEMCALTrackSegment.h"
+
//#include "AliEMCALPIDv1.h"
+
#include "AliEMCALGeometry.h"
+
+
ClassImp(AliEMCALGetter)
+
+
AliEMCALGetter * AliEMCALGetter::fgObjGetter = 0 ;
+
TFile * AliEMCALGetter::fFile = 0 ;
+
+
//____________________________________________________________________________
+
AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle, const Bool_t toSplit)
+
{
+
// This is the ctor called by GetInstance and the only one that can be used
+
+
if ( fHeaderFile.Contains("_") ) {
+
cerr << "AliEMCALGetter::AliEMCALGetter -> Invalid file name (_ not allowed) " << fHeaderFile.Data() << endl ;
+
abort() ;
+
}
+
+
//Initialize all data
+
+
fFailed = kFALSE ;
+
fDebug = 0 ;
+
fAlice = 0 ;
+
+
fToSplit = toSplit ;
+
fHeaderFile = headerFile ;
+
+
fPrimaries = new TObjArray(1) ;
+
+
fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
+
fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
+
fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
+
fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
+
fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
+
fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
+
//fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
+
fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
+
+
//Set titles to branches and create PHOS specific folders
+
SetTitle(branchTitle) ;
+
+
if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
+
//open headers file
+
fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
+
+
if(!fFile){ //if file was not opened yet, read gAlice
+
fFile = TFile::Open(fHeaderFile.Data(), "update") ;
+
if (!fFile->IsOpen()) {
+
cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot open " << fHeaderFile.Data() << endl ;
+
fFailed = kTRUE ;
+
return ;
+
}
+
gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
+
}
+
}
+
+
if (!gAlice) {
+
cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
+
fFailed = kTRUE ;
+
return ;
+
}
+
if (!EMCAL()) {
+
if (fDebug)
+
cout << "INFO: AliEMCALGetter -> Posting EMCAL to Folders" << endl ;
+
if (gAlice->GetDetector("EMCAL")) {
+
AliConfig * conf = AliConfig::Instance() ;
+
conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("EMCAL"))) ;
+
conf->Add(static_cast<AliModule*>(gAlice->GetDetector("EMCAL"))) ;
+
}
+
else
+
cerr << "ERROR: AliEMCALGetter -> detector EMCAL not found" << endl ;
+
}
+
+
fDebug=0;
+
}
+
+
//____________________________________________________________________________
+
AliEMCALGetter::~AliEMCALGetter()
+
{
+
if (fPrimaries) {
+
fPrimaries->Delete() ;
+
delete fPrimaries ;
+
}
+
+
TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
+
TCollection * folderslist = emcalF->GetListOfFolders() ;
+
TIter next(folderslist) ;
+
TFolder * folder = 0 ;
+
while ( (folder = static_cast<TFolder*>(next())) )
+
emcalF->Remove(folder) ;
+
+
if (fFile) {
+
fFile->Close() ;
+
delete fFile ;
+
fFile = 0 ;
+
}
+
fgObjGetter = 0 ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::CloseFile()
+
{
+
delete gAlice ;
+
gAlice = 0 ;
+
delete fAlice ;
+
fAlice = 0 ;
+
}
+
+
//____________________________________________________________________________
+
const TFolder * AliEMCALGetter::Folder(const TString what) const {
+
+
// returns the EMCAL folder required by what
+
// what = hits, sdigits, digits
+
+
if ( what == "hits" )
+
return dynamic_cast<const TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
+
else if ( what == "sdigits" )
+
return dynamic_cast<const TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
+
else if ( what == "digits" )
+
return dynamic_cast<const TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
+
else {
+
cerr << "ERROR: AliEMCALGetter::GetFolder -> " << what.Data() << " illegal option (hits, sdigits, digits) " << endl ;
+
return 0 ;
+
}
+
}
+
+
//____________________________________________________________________________
+
AliEMCALGetter * AliEMCALGetter::GetInstance()
+
{
+
// Returns the pointer of the unique instance already defined
+
+
if ( fgObjGetter ) {
+
return fgObjGetter ;
+
}
+
else {
+
// cout << "AliEMCALGetter::GetInstance ERROR: not yet initialized" << endl ;
+
return 0 ;
+
}
+
}
+
+
//____________________________________________________________________________
+
AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
+
const char* branchTitle,
+
const Bool_t toSplit)
+
{
+
// Creates and returns the pointer of the unique instance
+
// Must be called only when the environment has changed
+
+
if(!fgObjGetter){
+
fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
+
if(fgObjGetter->fFailed)
+
return 0;
+
else
+
return fgObjGetter ;
+
}
+
+
//First checks, if header file already opened
+
if(!fgObjGetter->fFile){
+
fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
+
if(fgObjGetter->fFailed)
+
return 0;
+
else
+
return fgObjGetter ;
+
}
+
+
if(fgObjGetter->fHeaderFile.CompareTo(headerFile)==0){ //Opened the same header file
+
if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0)&& //Open the same branch title
+
(toSplit==fgObjGetter->fToSplit)){ //Nothing should be cleaned
+
return fgObjGetter ;
+
}
+
else{ //Clean all data and AliEMCAL...zers
+
if(fgObjGetter->fToSplit)
+
fgObjGetter->CloseSplitFiles() ;
+
fgObjGetter->CleanWhiteBoard() ;
+
fgObjGetter->fToSplit = toSplit ;
+
fgObjGetter->SetTitle(branchTitle) ;
+
return fgObjGetter ;
+
}
+
}
+
else{ //Close already opened files, clean memory and open new header file
+
if(gAlice)
+
delete gAlice ;
+
gAlice= 0;
+
if(fgObjGetter->fFile){
+
fgObjGetter->fFile->Close() ;
+
fgObjGetter->fFile=0;
+
}
+
if(fgObjGetter->fToSplit)
+
fgObjGetter->CloseSplitFiles() ;
+
fgObjGetter->CleanWhiteBoard() ;
+
fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
+
return fgObjGetter ;
+
}
+
return fgObjGetter ;
+
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::BranchExists(const TString recName) const
+
{
+
//Looks in the tree Tree"name" if branch with current name olready exists
+
+
TString filename("") ;
+
TString name, dataname, zername;
+
if(recName == "SDigits"){
+
filename=fSDigitsFileName ;
+
name = "TreeS0" ;
+
dataname = "PHOS" ;
+
zername = "AliPHOSSDigitizer" ;
+
}
+
else
+
if(recName == "Digits"){
+
filename=fDigitsFileName ;
+
name = "TreeD0" ;
+
dataname = "PHOS" ;
+
zername = "AliPHOSDigitizer" ;
+
}
+
else
+
if(recName =="RecPoints"){
+
filename=fRecPointsFileName ;
+
name = "TreeR0" ;
+
dataname = "PHOSEmcRP" ;
+
zername = "AliPHOSClusterizer" ;
+
}
+
else
+
if(recName == "TrackSegments"){
+
filename=fTrackSegmentsFileName ;
+
name = "TreeR0" ;
+
dataname = "PHOSTS" ;
+
zername = "AliPHOSTrackSegmentMaker" ;
+
}
+
else
+
if(recName == "RecParticles"){
+
filename= fRecParticlesFileName ;
+
name = "TreeR0" ;
+
dataname = "PHOSRP" ;
+
zername = "AliPHOSPID" ;
+
}
+
else
+
return kFALSE ;
+
+
TFile * file ;
+
TTree * tree ;
+
if(fToSplit){
+
file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+
if(!file)
+
file = TFile::Open(fSDigitsFileName.Data(),"update");
+
}
+
else
+
file = fFile ;
+
+
tree = (TTree *)file->Get(name.Data()) ;
+
+
if(!tree )
+
return kFALSE ;
+
+
TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ;
+
TIter next(lob) ;
+
TBranch * branch = 0 ;
+
TString titleName(fBranchTitle);
+
titleName+=":";
+
while ((branch = (static_cast<TBranch*>(next())))) {
+
TString branchName(branch->GetName() ) ;
+
TString branchTitle(branch->GetTitle() ) ;
+
if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){
+
cerr << "WARNING: AliEMCALGetter::BranchExists -> branch " << dataname.Data() << " with title " << fBranchTitle << " already exits in "
+
<< name.Data() << endl;
+
return kTRUE ;
+
}
+
if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){
+
cerr << "WARNING: AliEMCALGetter::BranchExists -> branch AliEMCAL... with title " << branch->GetTitle() << " already exits in "
+
<< name.Data() << endl;
+
return kTRUE ;
+
}
+
}
+
//We can't delete three if gAlice points to it... To be redisigned somehow???!!!
+
if(!fToSplit){
+
if(name.Contains("TreeS"))
+
if(tree!=gAlice->TreeS())
+
tree->Delete();
+
if(name.Contains("TreeD"))
+
if(tree!=gAlice->TreeD())
+
tree->Delete();
+
if(name.Contains("TreeR"))
+
if(tree!=gAlice->TreeR())
+
tree->Delete();
+
}
+
return kFALSE ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::ListBranches(Int_t event) const
+
{
+
+
TBranch * branch = 0 ;
+
if (gAlice->GetEvent(event) == -1)
+
return ;
+
+
TTree * t = gAlice->TreeH() ;
+
if(t){
+
cout << "INFO: AliEMCALGetter::ListBranches -> ****** Hits : " << endl ;
+
TObjArray * lob = t->GetListOfBranches() ;
+
TIter next(lob) ;
+
while ( (branch = static_cast<TBranch*>(next())) )
+
cout << " " << branch->GetName() << endl ;
+
} else
+
cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeH not found for event " << event << endl ;
+
+
+
t = gAlice->TreeS() ;
+
if(t){
+
cout << "INFO: AliEMCALGetter::ListBranches -> ****** SDigits : " << endl ;
+
TObjArray * lob = t->GetListOfBranches() ;
+
TIter next(lob) ;
+
while ( (branch = static_cast<TBranch*>(next())) )
+
cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
+
} else
+
cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeS not found for event " << event << endl ;
+
+
t = gAlice->TreeD() ;
+
if(t){
+
cout << "INFO: AliEMCALGetter::ListBranches -> ****** Digits : " << endl ;
+
TObjArray * lob = t->GetListOfBranches() ;
+
TIter next(lob) ;
+
while ( (branch = static_cast<TBranch*>(next())) )
+
cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
+
} else
+
cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeD not found for event " << event << endl ;
+
+
+
t = gAlice->TreeR() ;
+
if(t){
+
cout << "INFO: AliEMCALGetter::ListBranches -> ****** Recon : " << endl ;
+
TObjArray * lob = t->GetListOfBranches() ;
+
TIter next(lob) ;
+
while ( (branch = static_cast<TBranch*>(next())) )
+
cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
+
} else
+
cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeR not found for event " << event << endl ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::NewBranch(TString name, Int_t event)
+
{
+
fBranchTitle = fSDigitsTitle = fDigitsTitle = fRecPointsTitle = fTrackSegmentsTitle = fRecParticlesTitle = name ;
+
Event(event) ;
+
}
+
+
//____________________________________________________________________________
+
Bool_t AliEMCALGetter::NewFile(TString name)
+
{
+
fHeaderFile = name ;
+
fFile->Close() ;
+
fFailed = kFALSE;
+
+
fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
+
if(!fFile) { //if file was not opened yet, read gAlice
+
fFile = TFile::Open(fHeaderFile.Data(),"update") ;
+
if (!fFile->IsOpen()) {
+
cerr << "ERROR : AliEMCALGetter::NewFile -> Cannot open " << fHeaderFile.Data() << endl ;
+
fFailed = kTRUE ;
+
return fFailed ;
+
}
+
gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
+
}
+
+
if (!gAlice) {
+
cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
+
fFailed = kTRUE ;
+
return fFailed ;
+
}
+
return fFailed ;
+
}
+
+
//____________________________________________________________________________
+
const AliEMCAL * AliEMCALGetter::EMCAL()
+
{
+
// returns the EMCAL object
+
AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(fModuleFolder->FindObject("EMCAL")) ;
+
if (!emcal)
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::EMCAL -> EMCAL module not found in Folders" << endl ;
+
return emcal ;
+
}
+
+
//____________________________________________________________________________
+
AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
+
{
+
AliEMCALGeometry * rv = 0 ;
+
if (EMCAL() )
+
rv = EMCAL()->GetGeometry() ;
+
return rv ;
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostPrimaries(void) const
+
{ //------- Primaries ----------------------
+
+
// the hierarchy is //Folders/RunMC/Event/Data/Primaries
+
+
TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
+
if ( !primariesFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post Primaries -> Folder //" << fPrimariesFolder->GetName() << "/Primaries/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder->GetName() << "/Primaries/" << endl;
+
}
+
primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
+
}
+
TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
+
primaries->SetName("Primaries") ;
+
primariesFolder->Add(primaries) ;
+
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject** AliEMCALGetter::PrimariesRef(void) const
+
{ //------- Primaries ----------------------
+
+
+
// the hierarchy is //Folders/RunMC/Event/Data/Primaries
+
if ( !fPrimariesFolder ) {
+
cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
+
if ( !primariesFolder ) {
+
cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
+
abort() ;
+
}
+
+
TObject * p = primariesFolder->FindObject("Primaries") ;
+
if(!p) {
+
cerr << "ERROR: AliEMCALGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
+
abort() ;
+
}
+
else
+
return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostHits(void) const
+
{ //------- Hits ----------------------
+
+
// the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post H -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
+
}
+
emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
+
}
+
TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
+
hits->SetName("Hits") ;
+
emcalFolder->Add(hits) ;
+
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::HitsRef(void) const
+
{ //------- Hits ----------------------
+
+
+
// the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
+
if ( !fHitsFolder ) {
+
cerr << "ERROR: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
+
return 0;
+
}
+
+
TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder ) {
+
cerr << "ERROR: AliEMCALGetter::Post HRef -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
+
return 0;
+
}
+
+
TObject * h = emcalFolder->FindObject("Hits") ;
+
if(!h) {
+
cerr << "ERROR: AliEMCALGetter::HRef -> " << emcalFolder->GetName() << "/Hits not found !" << endl ;
+
return 0 ;
+
}
+
else
+
return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
+
{ //---------- SDigits -------------------------
+
+
+
// the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
+
// because you can have sdigits from several hit files for mixing
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post S -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post S -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
+
}
+
emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
+
}
+
+
TString subdir(headerFile) ;
+
subdir.ReplaceAll("/", "_") ;
+
TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
+
if ( !emcalSubFolder )
+
emcalSubFolder = emcalFolder->AddFolder(subdir, "");
+
+
+
TObject * sd = emcalSubFolder->FindObject(name);
+
if ( !sd ) {
+
TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
+
sdigits->SetName(name) ;
+
emcalSubFolder->Add(sdigits) ;
+
}
+
+
return kTRUE;
+
}
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
+
{ //------- SDigits ----------------------
+
+
// the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
+
+
if ( !fSDigitsFolder ) {
+
cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder ) {
+
cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * emcalSubFolder = 0 ;
+
if(file)
+
emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
+
else
+
emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
+
+
if(!emcalSubFolder) {
+
cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/EMCAL/" << file << "not found!" << endl;
+
abort() ;
+
}
+
+
TObject * dis = emcalSubFolder->FindObject(name) ;
+
if(!dis) {
+
cerr << "ERROR: AliEMCALGetter::DigitesSRef -> object " << name << " not found! " << endl ;
+
abort() ;
+
}
+
else
+
return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
+
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
+
{ //---------- SDigitizer -------------------------
+
+
// the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
+
+
+
TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
+
+
if ( !sd ) {
+
cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
+
return kFALSE ;
+
}
+
TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL/" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
sd->Add(emcal) ;
+
}
+
AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
+
if (emcalsd) {
+
if (fDebug)
+
cout << "INFO: AliEMCALGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
+
emcal->GetListOfTasks()->Remove(emcalsd) ;
+
}
+
emcal->Add(sdigitizer) ;
+
return kTRUE;
+
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
+
{
+
+
TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
+
if ( !sd ) {
+
cerr << "ERROR: AliEMCALGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
+
abort();
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
cerr <<"ERROR: AliEMCALGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/EMCAL not found!" << endl;
+
abort();
+
}
+
+
TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
+
+
return emcal->GetListOfTasks()->GetObjectRef(task) ;
+
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
+
{ //---------- SDigitizer -------------------------
+
+
// the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
+
+
TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
+
if ( !sd ) {
+
cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
+
return kFALSE ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
sd->Add(emcal) ;
+
}
+
+
TString sdname(name) ;
+
sdname.Append(":") ;
+
sdname.Append(file);
+
sdname.ReplaceAll("/","_") ;
+
AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
+
if (!emcalsd) {
+
emcalsd = new AliEMCALSDigitizer() ;
+
//Note, we can not call constructor with parameters: it will call Getter and screw up everething
+
emcalsd->SetName(sdname) ;
+
emcalsd->SetTitle(file) ;
+
emcal->Add(emcalsd) ;
+
}
+
return kTRUE;
+
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostDigits(const char * name) const
+
{ //---------- Digits -------------------------
+
+
// the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
+
+
if ( !emcalFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post D -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post D -> Adding Folder //" << fDigitsFolder << "/EMCAL/" << endl;
+
}
+
emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
+
}
+
+
TObject* dig = emcalFolder->FindObject( name ) ;
+
if ( !dig ) {
+
TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
+
digits->SetName(name) ;
+
emcalFolder->Add(digits) ;
+
}
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::DigitsRef(const char * name) const
+
{ //------- Digits ----------------------
+
+
// the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
+
+
if ( !fDigitsFolder ) {
+
cerr << "ERROR: AliEMCALGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder ) {
+
cerr << "ERROR: AliEMCALGetter::DRef -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
+
abort() ;
+
}
+
+
TObject * d = emcalFolder->FindObject(name) ;
+
if(!d) {
+
cerr << "ERROR: AliEMCALGetter::DigitsRef -> object " << name << " not found! " << endl ;
+
abort() ;
+
}
+
else
+
return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
+
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
+
{ //---------- Digitizer -------------------------
+
+
TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
+
+
if ( !sd ) {
+
cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
+
return kFALSE ;
+
}
+
TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
sd->Add(emcal) ;
+
}
+
+
AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
+
if (emcald) {
+
emcald->Delete() ;
+
emcal->GetListOfTasks()->Remove(emcald) ;
+
}
+
emcal->Add(digitizer) ;
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
+
{ //---------- Digitizer -------------------------
+
+
// the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
+
+
TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
+
if ( !d ) {
+
cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
+
return kFALSE ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
d->Add(emcal) ;
+
}
+
+
AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
+
if (!emcald) {
+
emcald = new AliEMCALDigitizer() ;
+
emcald->SetName(fDigitsTitle) ;
+
emcald->SetTitle(fHeaderFile) ;
+
emcal->Add(emcald) ;
+
}
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
+
{
+
TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
+
if ( !sd ) {
+
cerr << "ERROR: AliEMCALGetter::Post DerRef -> Task //" << fTasksFolder->GetName() << "/Digitizer not found!" << endl;
+
abort();
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
cerr <<"ERROR: AliEMCALGetter::Post DerRef -> //" << fTasksFolder->GetName() << "/Digitizer/EMCAL" << endl;
+
abort();
+
}
+
+
TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
+
+
return emcal->GetListOfTasks()->GetObjectRef(task) ;
+
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
+
{ // -------------- RecPoints -------------------------------------------
+
+
// the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
+
// the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
+
+
if ( !emcalFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
+
}
+
emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
+
}
+
+
// Tower RecPoints
+
TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
+
if ( !emcalRPoTowerFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints not found!" << endl;
+
}
+
emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
+
}
+
+
TObject * erp = emcalFolder->FindObject( name ) ;
+
if ( !erp ) {
+
TObjArray * towerrp = new TObjArray(100) ;
+
towerrp->SetName(name) ;
+
emcalRPoTowerFolder->Add(towerrp) ;
+
}
+
+
// Pre Shower RecPoints
+
TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShowerRecPoints")) ;
+
if ( !emcalRPoPreShoFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/" << endl;
+
}
+
emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShowerRecPoints", "PreSho RecPoints from EMCAL") ;
+
}
+
+
TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
+
if ( !crp ) {
+
TObjArray * preshorp = new TObjArray(100) ;
+
preshorp->SetName(name) ;
+
emcalRPoPreShoFolder->Add(preshorp) ;
+
}
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
+
{ // -------------- RecPoints -------------------------------------------
+
+
// the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
+
+
if ( !fRecoFolder ) {
+
cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
+
if ( !towerFolder ) {
+
cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
+
abort() ;
+
}
+
+
+
TObject * trp = towerFolder->FindObject(name ) ;
+
if ( !trp ) {
+
cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Object " << name << " not found!" << endl ;
+
abort() ;
+
}
+
return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
+
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::PreShowerRecPointsRef(const char * name) const
+
{ // -------------- RecPoints -------------------------------------------
+
+
// the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
+
+
if ( !fRecoFolder ) {
+
cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
+
if ( !preshoFolder ) {
+
cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/" << endl;
+
abort() ;
+
}
+
+
TObject * prp = preshoFolder->FindObject(name ) ;
+
if ( !prp ) {
+
cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Object " << name << " not found! " << endl ;
+
abort() ;
+
}
+
return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
+
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizer * clu) const
+
{ // ------------------ AliEMCALClusterizer ------------------------
+
+
// the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
+
return kFALSE ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
tasks->Add(emcal) ;
+
}
+
+
AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
+
if (emcalcl) {
+
if (fDebug)
+
cout << "INFO: AliEMCALGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
+
emcalcl->Delete() ;
+
emcal->GetListOfTasks()->Remove(emcalcl) ;
+
}
+
emcal->Add(clu) ;
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
+
{ // ------------------ AliEMCALClusterizer ------------------------
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::Post RerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
+
abort() ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
cerr <<"WARNING: AliEMCALGetter::Post RerRef -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
+
abort() ;
+
}
+
+
TList * l = emcal->GetListOfTasks() ;
+
TIter it(l) ;
+
TTask * task ;
+
TTask * clu = 0 ;
+
TString cluname(name) ;
+
cluname+=":clu-" ;
+
while((task = static_cast<TTask *>(it.Next()) )){
+
TString taskname(task->GetName()) ;
+
if(taskname.BeginsWith(cluname)){
+
clu = task ;
+
break ;
+
}
+
}
+
+
if(clu)
+
return l->GetObjectRef(clu) ;
+
else {
+
cerr << "ERROR: AliEMCALGetter::Post RerRef -> task " << task->GetName() << " not found! " << endl ;
+
abort() ;
+
}
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
+
{ // ------------------ AliEMCALClusterizer ------------------------
+
+
// the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::Post Rer -> Task//" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
+
return kFALSE ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
tasks->Add(emcal) ;
+
}
+
+
TList * l = emcal->GetListOfTasks() ;
+
TIter it(l) ;
+
TString clun(name) ;
+
clun+=":clu" ;
+
TTask * task ;
+
while((task = static_cast<TTask *>(it.Next()) )){
+
TString taskname(task->GetName()) ;
+
if(taskname.BeginsWith(clun))
+
return kTRUE ;
+
}
+
+
AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
+
clun+="-v1" ;
+
emcalcl->SetName(clun) ;
+
emcalcl->SetTitle(fHeaderFile) ;
+
emcal->Add(emcalcl) ;
+
return kTRUE;
+
+
}
+
+
//____________________________________________________________________________
+
/*const Bool_t AliEMCALGetter::PostTrackSegments(const char * name) const
+
{ // ---------------TrackSegments -----------------------------------
+
+
// the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
+
+
if ( !emcalFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post TS -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL" << endl;
+
}
+
emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
+
}
+
+
TFolder * emcalTSFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TrackSegments")) ;
+
if ( !emcalTSFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post TS -> Folder//" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL/TrackSegments/" << endl;
+
}
+
emcalTSFolder = emcalFolder->AddFolder("TrackSegments", "TrackSegments from EMCAL") ;
+
}
+
+
TObject * tss = emcalTSFolder->FindObject( name ) ;
+
if (!tss) {
+
TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ;
+
ts->SetName(name) ;
+
emcalTSFolder->Add(ts) ;
+
}
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::TrackSegmentsRef(const char * name) const
+
{ // ---------------TrackSegments -----------------------------------
+
+
// the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
+
+
if ( !fRecoFolder ) {
+
cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
+
if ( !emcalFolder ) {
+
cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
+
abort();
+
}
+
+
TObject * tss = emcalFolder->FindObject(name) ;
+
if (!tss) {
+
cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> object " << name << " not found! " << endl ;
+
abort() ;
+
}
+
return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsmaker) const
+
{ //------------Track Segment Maker ------------------------------
+
+
// the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
+
return kFALSE ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
tasks->Add(emcal) ;
+
}
+
+
AliEMCALTrackSegmentMaker * emcalts =
+
dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
+
if (emcalts) {
+
emcalts->Delete() ;
+
emcal->GetListOfTasks()->Remove(emcalts) ;
+
}
+
emcal->Add(tsmaker) ;
+
return kTRUE;
+
+
}
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostTrackSegmentMaker(const char * name) const
+
{ //------------Track Segment Maker ------------------------------
+
+
// the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
+
return kFALSE ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Ter -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Ter -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
tasks->Add(emcal) ;
+
}
+
+
TList * l = emcal->GetListOfTasks() ;
+
TIter it(l) ;
+
TString tsn(name);
+
tsn+=":tsm" ;
+
TTask * task ;
+
while((task = static_cast<TTask *>(it.Next()) )){
+
TString taskname(task->GetName()) ;
+
if(taskname.BeginsWith(tsn))
+
return kTRUE ;
+
}
+
+
AliEMCALTrackSegmentMakerv1 * emcalts = new AliEMCALTrackSegmentMakerv1() ;
+
tsn+="-v1" ;
+
emcalts->SetName(tsn) ;
+
emcalts->SetTitle(fHeaderFile) ;
+
emcal->Add(emcalts) ;
+
return kTRUE;
+
+
}
+
+
+
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::TSMakerRef(const char * name) const
+
{ //------------Track Segment Maker ------------------------------
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::TSLakerRef TerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
+
abort() ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
cerr <<"WARNING: AliEMCALGetter::TSMakerRef TerRef -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl;
+
abort() ;
+
}
+
+
TList * l = emcal->GetListOfTasks() ;
+
TIter it(l) ;
+
TTask * task ;
+
TTask * tsm = 0 ;
+
TString tsmname(name) ;
+
tsmname+=":tsm-" ;
+
while((task = static_cast<TTask *>(it.Next()) )){
+
TString taskname(task->GetName()) ;
+
if(taskname.BeginsWith(tsmname)){
+
tsm = task ;
+
break ;
+
}
+
}
+
+
if(tsm)
+
return l->GetObjectRef(tsm) ;
+
else {
+
cerr << "ERROR: AliEMCALGetter::TSLakerRef -> task " << task->GetName() << " not found! " << endl ;
+
abort() ;
+
}
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostRecParticles(const char * name) const
+
{ // -------------------- RecParticles ------------------------
+
+
// the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
+
+
if ( !emcalFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
+
}
+
emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
+
}
+
+
TFolder * emcalRPaFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("RecParticles")) ;
+
if ( !emcalRPaFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/EMCAL/RecParticles/" << endl;
+
}
+
emcalRPaFolder = emcalFolder->AddFolder("RecParticles", "RecParticles from EMCAL") ;
+
}
+
+
TObject * rps = emcalRPaFolder->FindObject( name ) ;
+
if ( !rps ) {
+
TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ;
+
rp->SetName(name) ;
+
emcalRPaFolder->Add(rp) ;
+
}
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::RecParticlesRef(const char * name) const
+
{ // ---------------RecParticles -----------------------------------
+
+
// the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
+
+
if ( !fRecoFolder ) {
+
cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
+
if ( !emcalFolder ) {
+
cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
+
abort() ;
+
}
+
+
TObject * tss = emcalFolder->FindObject(name) ;
+
if (!tss) {
+
cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> object " << name << " not found! " << endl ;
+
abort() ;
+
}
+
return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostPID(AliEMCALPID * pid) const
+
{ // ------------AliEMCAL PID -----------------------------
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
+
return kFALSE ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
tasks->Add(emcal) ;
+
}
+
+
AliEMCALPID * emcalpid = dynamic_cast<AliEMCALPID*>(emcal->GetListOfTasks()->FindObject(pid->GetName())) ;
+
if (emcalpid) {
+
if (fDebug)
+
cout << "INFO: AliEMCALGetter::Post Per -> Task " << pid->GetName()
+
<< " already exists" << endl ;
+
emcal->GetListOfTasks()->Remove(emcalpid) ;
+
}
+
+
emcal->Add(pid) ;
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostPID(const char * name) const
+
{
+
// the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
+
return kFALSE ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
if (fDebug) {
+
cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl;
+
cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
+
}
+
emcal = new TTask("EMCAL", "") ;
+
tasks->Add(emcal) ;
+
}
+
+
TList * l = emcal->GetListOfTasks() ;
+
TIter it(l) ;
+
TString pidname(name) ;
+
pidname+=":pid" ;
+
TTask * task ;
+
while((task = static_cast<TTask *>(it.Next()) )){
+
TString taskname(task->GetName()) ;
+
if(taskname.BeginsWith(pidname))
+
return kTRUE ;
+
}
+
+
AliEMCALPIDv1 * emcalpid = new AliEMCALPIDv1() ;
+
pidname+="-v1" ;
+
emcalpid->SetName(pidname) ;
+
emcalpid->SetTitle(fHeaderFile) ;
+
emcal->Add(emcalpid) ;
+
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::PIDRef(const char * name) const
+
{ //------------PID ------------------------------
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
+
if ( !tasks ) {
+
cerr << "ERROR: AliEMCALGetter::PIDRef PerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
+
abort() ;
+
}
+
+
TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if ( !emcal ) {
+
cerr <<"WARNING: AliEMCALGetter::PIDRef PerRef -> //" << fTasksFolder->GetName() << "/ReconstructionerEMCAL not found!" << endl;
+
abort() ;
+
}
+
+
TList * l = emcal->GetListOfTasks() ;
+
TIter it(l) ;
+
TTask * task ;
+
TTask * pid = 0 ;
+
TString pidname(name) ;
+
pidname+=":pid-" ;
+
while((task = static_cast<TTask *>(it.Next()) )){
+
TString taskname(task->GetName()) ;
+
if(taskname.BeginsWith(pidname)){
+
pid = task ;
+
break ;
+
}
+
}
+
+
if(pid)
+
return l->GetObjectRef(pid) ;
+
else {
+
cerr << "ERROR: AliEMCALGetter::PIDRef -> task " << task->GetName() << " not found! " << endl ;
+
abort() ;
+
}
+
+
}
+
+
//____________________________________________________________________________
+
const Bool_t AliEMCALGetter::PostQA(void) const
+
{ // ------------------ QA ---------------------------------
+
+
// the hierarchy is //Folders/Run/Conditions/QA/EMCAL/alarmsName
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder ) {
+
if (fDebug) {
+
cout << "WARNING: AliEMCALGetter::Post Q -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
+
cout << "INFO: AliEMCALGetter::Post Q -> Adding Folder //" << fQAFolder << "/EMCAL/" << endl;
+
}
+
emcalFolder = fQAFolder->AddFolder("EMCAL", "QA from EMCAL") ;
+
}
+
+
return kTRUE;
+
}
+
+
//____________________________________________________________________________
+
TObject ** AliEMCALGetter::AlarmsRef(void) const
+
{ //------- Alarms ----------------------
+
+
+
// the hierarchy is //Folders/Run/Conditions/QA/EMCAL
+
if ( !fQAFolder ) {
+
cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << " not found!" << endl;
+
abort() ;
+
}
+
+
TFolder * emcalFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder ) {
+
cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
+
abort() ;
+
}
+
+
return fQAFolder->GetListOfFolders()->GetObjectRef(emcalFolder) ;
+
}
+
*/
+
+
//____________________________________________________________________________
+
TTree * AliEMCALGetter::TreeK(TString filename)
+
{
+
+
// returns TreeK from file filename
+
// usefull in case of split file
+
+
if ( filename.IsNull() )
+
filename = fHeaderFile ;
+
+
TFile * file = 0 ;
+
file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+
if (file && (filename != fHeaderFile) ) { // file already open
+
file->Close() ;
+
delete fAlice ;
+
}
+
file = TFile::Open(filename.Data(), "read") ;
+
fAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
+
TString treeName("TreeK") ;
+
treeName += EventNumber() ;
+
TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+
if (!tree && fDebug)
+
cout << "WARNING: AliEMCALGetter::TreeK -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+
return tree ;
+
}
+
+
//____________________________________________________________________________
+
TTree * AliEMCALGetter::TreeH(TString filename)
+
{
+
+
// returns TreeH from file filename
+
// usefull in case of split file
+
+
if ( filename.IsNull() )
+
filename = fHeaderFile ;
+
+
TFile * file = 0 ;
+
file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+
if (!file) { // file not open yet
+
file = TFile::Open(filename.Data(), "read") ;
+
}
+
TString treeName("TreeH") ;
+
treeName += EventNumber() ;
+
TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+
if (!tree && fDebug)
+
cout << "WARNING: AliEMCALGetter::TreeH -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+
return tree ;
+
}
+
+
//____________________________________________________________________________
+
TTree * AliEMCALGetter::TreeS(TString filename)
+
{
+
+
// returns TreeS from file filename
+
// usefull in case of split file
+
+
if ( filename.IsNull() )
+
filename = fHeaderFile ;
+
+
TFile * file = 0 ;
+
file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+
if (!file) { // file not open yet
+
file = TFile::Open(filename.Data(), "read") ;
+
}
+
TString treeName("TreeS") ;
+
treeName += EventNumber() ;
+
TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+
if (!tree && fDebug)
+
cout << "WARNING: AliEMCALGetter::TreeS -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+
return tree ;
+
}
+
+
//____________________________________________________________________________
+
TTree * AliEMCALGetter::TreeD(TString filename)
+
{
+
+
// returns TreeD from file filename
+
// usefull in case of split file
+
+
if ( filename.IsNull() )
+
filename = fHeaderFile ;
+
+
TFile * file = 0 ;
+
file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+
if (!file) { // file not open yet
+
file = TFile::Open(filename.Data(), "read") ;
+
}
+
TString treeName("TreeD") ;
+
treeName += EventNumber() ;
+
TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+
if (!tree && fDebug)
+
cout << "WARNING: AliEMCALGetter::TreeD -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
+
+
return tree ;
+
}
+
+
//____________________________________________________________________________
+
const TParticle * AliEMCALGetter::Primary(Int_t index) const
+
{
+
// Return primary particle numbered by <index>
+
+
if(index < 0)
+
return 0 ;
+
TParticle * p = 0 ;
+
if (fAlice)
+
p = fAlice->Particle(index) ;
+
else
+
p = gAlice->Particle(index) ;
+
+
return p ;
+
+
}
+
+
//____________________________________________________________________________
+
const TParticle * AliEMCALGetter::Secondary(TParticle* p, Int_t index) const
+
{
+
// Return first (index=1) or second (index=2) secondary particle of primary particle p
+
+
if(index <= 0)
+
return 0 ;
+
if(index > 2)
+
return 0 ;
+
+
if(p) {
+
Int_t daughterIndex = p->GetDaughter(index-1) ;
+
return gAlice->Particle(daughterIndex) ;
+
}
+
else
+
return 0 ;
+
}
+
+
//____________________________________________________________________________
+
Int_t AliEMCALGetter::ReadTreeD(const Int_t event)
+
{
+
// Read the digit tree gAlice->TreeD()
+
+
TTree * treeD ;
+
if(fToSplit){
+
TFile * file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName));
+
if(!file)
+
file = TFile::Open(fDigitsFileName) ;
+
// Get Digits Tree header from file
+
TString treeName("TreeD") ;
+
treeName += event ;
+
treeD = dynamic_cast<TTree*>(file->Get(treeName.Data()));
+
if(!treeD){ // TreeD not found in header file
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find TreeD in " << fDigitsFileName.Data() << endl;
+
return 1;
+
}
+
}
+
else
+
treeD = gAlice->TreeD() ;
+
+
TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
+
TIter next(lob) ;
+
TBranch * branch = 0 ;
+
TBranch * digitsbranch = 0 ;
+
TBranch * digitizerbranch = 0 ;
+
Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
+
+
while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
+
if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
+
digitsbranch = branch ;
+
emcalfound = kTRUE ;
+
}
+
else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
+
digitizerbranch = branch ;
+
digitizerfound = kTRUE ;
+
}
+
}
+
+
if ( !emcalfound || !digitizerfound ) {
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
+
<< fDigitsTitle << endl ;
+
return 2;
+
}
+
+
//read digits
+
if(!Digits(fDigitsTitle) )
+
PostDigits(fDigitsTitle);
+
digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
+
digitsbranch->GetEntry(0) ;
+
+
+
// read the Digitizer
+
RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that
+
if(!Digitizer(fDigitsTitle))
+
PostDigitizer(fDigitsTitle) ;
+
digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
+
digitizerbranch->GetEntry(0) ;
+
+
lob ->Delete();
+
if(gAlice->TreeD()!=treeD)
+
treeD->Delete();
+
return 0 ;
+
}
+
+
//____________________________________________________________________________
+
Int_t AliEMCALGetter::ReadTreeH()
+
{
+
// Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
+
+
TTree * treeH = gAlice->TreeH() ;
+
+
if(!treeH) {// TreeH not found in header file
+
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find TreeH in " << fHeaderFile << endl ;
+
+
TString searchFileName("EMCAL.HITS") ;
+
if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
+
searchFileName+="." ;
+
searchFileName += fBranchTitle ;
+
}
+
searchFileName+=".root" ;
+
+
if ( (treeH = TreeH(searchFileName)) ) { //found TreeH in the file which contains the hits
+
if (fDebug)
+
cout << "INFO: AliEMCALGetter::ReadTreeH -> TreeH found in " << searchFileName.Data() << endl ;
+
+
} else {
+
cerr << "ERROR: AliEMCALGetter::ReadTreeH -> TreeH not found " << endl ;
+
return 1;
+
}
+
}
+
+
TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
+
if ( !hitsbranch ) {
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
+
return 2;
+
}
+
if(!Hits())
+
PostHits() ;
+
+
if (hitsbranch->GetEntries() > 1 ) {
+
(dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
+
TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
+
TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
+
hitsbranch->SetAddress(&tempo) ;
+
Int_t index = 0 ;
+
Int_t i = 0 ;
+
for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
+
hitsbranch->GetEntry(i) ;
+
Int_t j = 0 ;
+
for ( j = 0 ; j < tempo->GetEntries() ; j++) {
+
const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
+
new((*hits)[index]) AliEMCALHit( *hit ) ;
+
index++ ;
+
}
+
}
+
delete tempo ;
+
}
+
else {
+
(dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
+
hitsbranch->SetAddress(HitsRef()) ;
+
hitsbranch->GetEntry(0) ;
+
}
+
return 0 ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::Track(Int_t itrack)
+
{
+
// Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
+
+
if(gAlice->TreeH()== 0){
+
cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
+
return ;
+
}
+
+
TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
+
if ( !hitsbranch ) {
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
+
return ;
+
}
+
if(!Hits())
+
PostHits() ;
+
+
(dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
+
hitsbranch->SetAddress(HitsRef()) ;
+
hitsbranch->GetEntry(itrack) ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::ReadTreeQA()
+
{
+
if (fDebug)
+
cout << "WARNING : " << ClassName() << "::ReadTreeQA -> not implemented" << endl ;
+
// Read the digit tree gAlice->TreeQA()
+
// so far only EMCAL knows about this Tree
+
+
// if(EMCAL()->TreeQA()== 0){
+
// cerr << "ERROR: AliEMCALGetter::ReadTreeQA: can not read TreeQA " << endl ;
+
// return ;
+
// }
+
+
// TBranch * qabranch = EMCAL()->TreeQA()->GetBranch("EMCAL") ;
+
// if (!qabranch) {
+
// if (fDebug)
+
// cout << "WARNING: AliEMCALGetter::ReadTreeQA -> Cannot find QA Alarms for EMCAL" << endl ;
+
// return ;
+
// }
+
+
// if(!Alarms())
+
// PostQA() ;
+
+
// qabranch->SetAddress(AlarmsRef()) ;
+
+
// qabranch->GetEntry(0) ;
+
+
// PostQA("EMCAL") ;
+
// TFolder * alarmsF = Alarms() ;
+
// alarmsF->Clear() ;
+
// qabranch->SetAddress(&alarmsF) ;
+
// qabranch->GetEntry(0) ;
+
+
}
+
+
//____________________________________________________________________________
+
Int_t AliEMCALGetter::ReadTreeR(const Int_t event)
+
{
+
// Read the reconstrunction tree gAlice->TreeR()
+
// A particularity has been introduced here :
+
// if gime->Event(ievent,"R") is called branches with the current title are read, the current title
+
// being for example give in AliPHOSPID(fileName, title)
+
// if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
+
// This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
+
// from a given set of TrackSegments (with a given name)
+
// This is why any is NOT used to read the branch of RecParticles
+
// any migh have become obsolete : to be checked
+
// See AliEMCALPIDv1
+
+
TTree * treeR ;
+
if(fToSplit){
+
TFile * file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName));
+
if(!file)
+
file = TFile::Open(fRecPointsFileName) ;
+
// Get Digits Tree header from file
+
TString treeName("TreeR") ;
+
treeName += event ;
+
treeR = dynamic_cast<TTree*>(file->Get(treeName.Data()));
+
if(!treeR){ // TreeR not found in header file
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find TreeR in " << fRecPointsFileName.Data() << endl;
+
return 1;
+
}
+
}
+
else
+
treeR = gAlice->TreeR() ;
+
+
// RecPoints
+
TObjArray * lob = static_cast<TObjArray*>(treeR->GetListOfBranches()) ;
+
TIter next(lob) ;
+
TBranch * branch = 0 ;
+
TBranch * towerbranch = 0 ;
+
TBranch * preshowerbranch = 0 ;
+
TBranch * clusterizerbranch = 0 ;
+
Bool_t emcalTowerRPfound = kFALSE, emcalPreShoRPfound = kFALSE, clusterizerfound = kFALSE ;
+
+
+
while ( (branch = static_cast<TBranch*>(next())) && (!emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) ) {
+
if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 ) {
+
if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
+
towerbranch = branch ;
+
emcalTowerRPfound = kTRUE ;
+
}
+
else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
+
preshowerbranch = branch ;
+
emcalPreShoRPfound = kTRUE ;
+
}
+
else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
+
clusterizerbranch = branch ;
+
clusterizerfound = kTRUE ;
+
}
+
}
+
}
+
+
if ( !emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) {
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name "
+
<< fRecPointsTitle << endl ;
+
+
} else {
+
if(!TowerRecPoints(fRecPointsTitle) )
+
PostRecPoints(fRecPointsTitle) ;
+
+
towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
+
towerbranch->GetEntry(0) ;
+
+
preshowerbranch->SetAddress(PreShowerRecPointsRef(fRecPointsTitle)) ;
+
preshowerbranch->GetEntry(0) ;
+
+
if(!Clusterizer(fRecPointsTitle) )
+
PostClusterizer(fRecPointsTitle) ;
+
+
clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
+
clusterizerbranch->GetEntry(0) ;
+
}
+
+
// //------------------- TrackSegments ---------------------
+
// next.Reset() ;
+
// TBranch * tsbranch = 0 ;
+
// TBranch * tsmakerbranch = 0 ;
+
// Bool_t emcaltsfound = kFALSE, tsmakerfound = kFALSE ;
+
// while ( (branch = static_cast<TBranch*>(next())) && (!emcaltsfound || !tsmakerfound) ) {
+
// if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0 ) {
+
// if ( strcmp(branch->GetName(), "EMCALTS")==0){
+
// tsbranch = branch ;
+
// emcaltsfound = kTRUE ;
+
// }
+
// else if(strcmp(branch->GetName(), "AliEMCALTrackSegmentMaker")==0) {
+
// tsmakerbranch = branch ;
+
// tsmakerfound = kTRUE ;
+
// }
+
// }
+
// }
+
+
// if ( !emcaltsfound || !tsmakerfound ) {
+
// if (fDebug)
+
// cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
+
// << fTrackSegmentsTitle << endl ;
+
// } else {
+
// // Read and Post the TrackSegments
+
// if(!TrackSegments(fTrackSegmentsTitle))
+
// PostTrackSegments(fTrackSegmentsTitle) ;
+
// tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
+
// tsbranch->GetEntry(0) ;
+
+
// // Read and Post the TrackSegment Maker
+
// if(!TrackSegmentMaker(fTrackSegmentsTitle))
+
// PostTrackSegmentMaker(fTrackSegmentsTitle) ;
+
// tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
+
// tsmakerbranch->GetEntry(0) ;
+
// }
+
+
+
// //------------ RecParticles ----------------------------
+
// next.Reset() ;
+
// TBranch * rpabranch = 0 ;
+
// TBranch * pidbranch = 0 ;
+
// Bool_t emcalrpafound = kFALSE, pidfound = kFALSE ;
+
+
// while ( (branch = static_cast<TBranch*>(next())) && (!emcalrpafound || !pidfound) )
+
// if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
+
// if ( strcmp(branch->GetName(), "EMCALRP")==0) {
+
// rpabranch = branch ;
+
// emcalrpafound = kTRUE ;
+
// }
+
// else if (strcmp(branch->GetName(), "AliEMCALPID")==0) {
+
// pidbranch = branch ;
+
// pidfound = kTRUE ;
+
// }
+
// }
+
+
// if ( !emcalrpafound || !pidfound ) {
+
// if (fDebug)
+
// cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
+
// << fRecParticlesTitle << endl ;
+
// } else {
+
// // Read and Post the RecParticles
+
// if(!RecParticles(fRecParticlesTitle))
+
// PostRecParticles(fRecParticlesTitle) ;
+
// rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
+
// rpabranch->GetEntry(0) ;
+
// // Read and Post the PID
+
// if(!PID(fRecParticlesTitle))
+
// PostPID(fRecParticlesTitle) ;
+
// pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
+
// pidbranch->GetEntry(0) ;
+
// }
+
+
if(gAlice->TreeR()!=treeR)
+
treeR->Delete();
+
return 0 ;
+
}
+
+
//____________________________________________________________________________
+
Int_t AliEMCALGetter::ReadTreeS(Int_t event)
+
{
+
// Reads the SDigits treeS from all files
+
// Files, which should be opened are listed in emcalF
+
// So, first get list of files
+
TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
+
if (!emcalF)
+
emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
+
TCollection * folderslist = emcalF->GetListOfFolders() ;
+
+
// Now iterate over the list of files and read TreeS into Whiteboard
+
TIter next(folderslist) ;
+
TFolder * folder = 0 ;
+
TFile * file;
+
TTree * treeS = 0;
+
while ( (folder = static_cast<TFolder*>(next())) ) {
+
TString fileName("") ;
+
if(fToSplit)
+
fileName = folder->GetTitle() ;
+
else
+
fileName = folder->GetName() ;
+
fileName.ReplaceAll("_","/") ;
+
file = static_cast<TFile*>(gROOT->GetFile(fileName));
+
if(!file)
+
file = TFile::Open(fileName) ;
+
// Get SDigits Tree header from file
+
TString treeName("TreeS") ;
+
treeName += event ;
+
treeS = dynamic_cast<TTree*>(file->Get(treeName.Data()));
+
+
if(!treeS){ // TreeS not found in header file
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeS -> Cannot find TreeS in " << fileName.Data() << endl;
+
return 1;
+
}
+
+
//set address of the SDigits and SDigitizer
+
TBranch * sdigitsBranch = 0;
+
TBranch * sdigitizerBranch = 0;
+
TBranch * branch = 0 ;
+
TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
+
TIter next(lob) ;
+
Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
+
+
while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
+
if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
+
emcalfound = kTRUE ;
+
sdigitsBranch = branch ;
+
}
+
+
else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) &&
+
(strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
+
sdigitizerfound = kTRUE ;
+
sdigitizerBranch = branch ;
+
}
+
}
+
if ( !emcalfound || !sdigitizerfound ) {
+
if (fDebug)
+
cout << "WARNING: AliEMCALDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
+
<< " not found" << endl ;
+
return 2;
+
}
+
+
if ( !folder->FindObject(fSDigitsTitle) )
+
PostSDigits(fSDigitsTitle,folder->GetName()) ;
+
+
((TClonesArray*) (*SDigitsRef(fSDigitsTitle,folder->GetName())))->Clear() ;
+
sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
+
sdigitsBranch->GetEntry(0) ;
+
+
TString sdname(fSDigitsTitle) ;
+
sdname+=":" ;
+
sdname+=folder->GetName() ;
+
if(!SDigitizer(sdname) )
+
PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
+
sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
+
sdigitizerBranch->GetEntry(0) ;
+
if(gAlice->TreeS()!=treeS)
+
treeS->Delete();
+
}
+
return 0 ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
+
{ // Read the summable digits fron treeS()
+
+
+
TString filename("mergefile") ;
+
filename+= input ;
+
+
TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder ) {
+
emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
+
}
+
TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
+
//set address of the SDigits and SDigitizer
+
TBranch * sdigitsBranch = 0;
+
TBranch * sdigitizerBranch = 0;
+
TBranch * branch = 0 ;
+
TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
+
TIter next(lob) ;
+
Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
+
+
while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
+
if ( strcmp(branch->GetName(), "EMCAL")==0) {
+
emcalfound = kTRUE ;
+
sdigitsBranch = branch ;
+
}
+
+
else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
+
sdigitizerfound = kTRUE ;
+
sdigitizerBranch = branch ;
+
}
+
}
+
if ( !emcalfound || !sdigitizerfound ) {
+
if (fDebug)
+
cout << "WARNING: AliEMCALGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
+
return ;
+
}
+
+
if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
+
PostSDigits(sdigitsBranch->GetTitle(),filename) ;
+
+
sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
+
sdigitsBranch->GetEntry(0) ;
+
+
TString sdname(sdigitsBranch->GetTitle()) ;
+
sdname+=":" ;
+
sdname+=filename ;
+
+
if(!SDigitizer(sdigitsBranch->GetTitle()) )
+
PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
+
sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
+
sdigitizerBranch->GetEntry(0) ;
+
if(gAlice->TreeS()!=treeS)
+
treeS->Delete();
+
}
+
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::ReadPrimaries()
+
{
+
// Reads specific branches of primaries
+
+
TClonesArray * ar = 0 ;
+
if(! (ar = Primaries()) ) {
+
PostPrimaries() ;
+
ar = Primaries() ;
+
}
+
ar->Delete() ;
+
+
if (TreeK(fHeaderFile)) { // treeK found in header file
+
if (fDebug)
+
cout << "INFO: AliEMCALGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ;
+
fNPrimaries = gAlice->GetNtrack() ;
+
fAlice = 0 ;
+
+
} else { // treeK not found in header file
+
+
cerr << "ERROR: AliEMCALGetter::ReadPrimaries -> TreeK not found " << endl ;
+
return ;
+
+
}
+
Int_t index = 0 ;
+
for (index = 0 ; index < fNPrimaries; index++) {
+
new ((*ar)[index]) TParticle(*(Primary(index)));
+
}
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::Event(const Int_t event, const char* opt)
+
{
+
// Reads the content of all Tree's S, D and R
+
+
if (event >= gAlice->TreeE()->GetEntries() ) {
+
cerr << "ERROR: AliEMCALGetter::Event -> " << event << " not found in TreeE!" << endl ;
+
return ;
+
}
+
+
Bool_t any = kFALSE ;
+
if (strstr(opt,"A") ) // do not check the title of the branches
+
any = kTRUE;
+
+
gAlice->GetEvent(event) ;
+
+
if( strstr(opt,"R") )
+
ReadTreeR(event) ;
+
+
if( strstr(opt,"D") )
+
ReadTreeD(event) ;
+
+
if(strstr(opt,"S") )
+
ReadTreeS(event) ;
+
+
if(strstr(opt,"H") )
+
ReadTreeH() ;
+
+
if( strstr(opt,"Q") )
+
ReadTreeQA() ;
+
+
if( strstr(opt,"P") || (strcmp(opt,"")==0) )
+
ReadPrimaries() ;
+
+
}
+
+
//____________________________________________________________________________
+
TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
+
{
+
// get the object named "what" from the folder
+
// folders are named like //Folders
+
+
if ( file.IsNull() )
+
file = fHeaderFile ;
+
+
TFolder * folder = 0 ;
+
TObject * emcalO = 0 ;
+
+
if ( what.CompareTo("Primaries") == 0 ) {
+
folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
+
if (folder)
+
emcalO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
+
else
+
return 0 ;
+
}
+
else if ( what.CompareTo("Hits") == 0 ) {
+
folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
+
if (folder)
+
emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
+
}
+
else if ( what.CompareTo("SDigits") == 0 ) {
+
file.ReplaceAll("/","_") ;
+
TString path = "EMCAL/" + file ;
+
folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
+
if (folder) {
+
if (name.IsNull())
+
name = fSDigitsTitle ;
+
emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
+
}
+
}
+
else if ( what.CompareTo("Digits") == 0 ){
+
folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
+
if (folder) {
+
if (name.IsNull())
+
name = fDigitsTitle ;
+
emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
+
}
+
}
+
else if ( what.CompareTo("TowerRecPoints") == 0 ) {
+
folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
+
if (folder) {
+
if (name.IsNull())
+
name = fRecPointsTitle ;
+
emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
+
}
+
}
+
else if ( what.CompareTo("PreShowerRecPoints") == 0 ) {
+
folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
+
if (folder) {
+
if (name.IsNull())
+
name = fRecPointsTitle ;
+
emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
+
}
+
}
+
/*
+
else if ( what.CompareTo("TrackSegments") == 0 ) {
+
folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
+
if (folder) {
+
if (name.IsNull())
+
name = fTrackSegmentsTitle ;
+
emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
+
}
+
}
+
else if ( what.CompareTo("RecParticles") == 0 ) {
+
folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
+
if (folder) {
+
if (name.IsNull())
+
name = fRecParticlesTitle ;
+
emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
+
}
+
}
+
else if ( what.CompareTo("Alarms") == 0 ){
+
if (name.IsNull() )
+
emcalO = dynamic_cast<TObject *>(fQAFolder->FindObject("EMCAL")) ;
+
else {
+
folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
+
if (!folder)
+
emcalO = 0 ;
+
else
+
emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
+
}
+
}
+
*/
+
if (!emcalO) {
+
if(fDebug)
+
cout << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
+
return 0 ;
+
}
+
+
return emcalO ;
+
}
+
+
//____________________________________________________________________________
+
const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
+
{
+
// get the TTask named "what" from the folder
+
// folders are named like //Folders/Tasks/what/EMCAL/name
+
+
TString search(what) ;
+
if ( what.CompareTo("Clusterizer") == 0 )
+
search = "Reconstructioner" ;
+
else if ( what.CompareTo("TrackSegmentMaker") == 0 )
+
search = "Reconstructioner" ;
+
else if ( what.CompareTo("PID") == 0 )
+
search = "Reconstructioner" ;
+
else if ( what.CompareTo("QATasks") == 0 )
+
search = "QA" ;
+
+
TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
+
+
if (!tasks) {
+
cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << " not found!" << endl ;
+
return 0 ;
+
}
+
+
TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
+
if (!emcalT) {
+
cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << "/EMCAL not found!" << endl ;
+
return 0 ;
+
}
+
+
TList * list = emcalT->GetListOfTasks() ;
+
+
if (what.CompareTo("SDigitizer") == 0) {
+
if ( name.IsNull() )
+
name = fSDigitsTitle ;
+
} else if (what.CompareTo("Digitizer") == 0){
+
if ( name.IsNull() )
+
name = fDigitsTitle ;
+
} else if (what.CompareTo("Clusterizer") == 0){
+
if ( name.IsNull() )
+
name = fRecPointsTitle ;
+
name.Append(":clu") ;
+
}
+
// else if (what.CompareTo("TrackSegmentMaker") == 0){
+
// if ( name.IsNull() )
+
// name = fTrackSegmentsTitle ;
+
// name.Append(":tsm") ;
+
// }
+
// else if (what.CompareTo("PID") == 0){
+
// if ( name.IsNull() )
+
// name = fRecParticlesTitle ;
+
// name.Append(":pid") ;
+
// }
+
// else if (what.CompareTo("QATasks") == 0){
+
// if ( name.IsNull() )
+
// return emcalT ;
+
// }
+
+
TIter it(list) ;
+
TTask * task = 0 ;
+
while((task = static_cast<TTask *>(it.Next()) )){
+
TString taskname(task->GetName()) ;
+
if(taskname.BeginsWith(name)){
+
return task ;}
+
}
+
+
if(fDebug)
+
cout << "WARNING: AliEMCALGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;
+
return 0 ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::RemoveTask(TString opt, TString name) const
+
{
+
// remove a task from the folder
+
// path is fTasksFolder/SDigitizer/EMCAL/name
+
+
TTask * task = 0 ;
+
TTask * emcal = 0 ;
+
TList * lofTasks = 0 ;
+
+
if (opt == "S") { // SDigitizer
+
task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
+
if (!task)
+
return ;
+
}
+
else if (opt == "D") { // Digitizer
+
task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
+
if (!task)
+
return ;
+
}
+
else if (opt == "C") { // Clusterizer
+
task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
if (!task)
+
return ;
+
}
+
else {
+
cerr << "WARNING: AliEMCALGetter::RemoveTask -> Unknown option " << opt.Data() << endl ;
+
return ;
+
}
+
emcal = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
+
if (!emcal)
+
return ;
+
lofTasks = emcal->GetListOfTasks() ;
+
if (!lofTasks)
+
return ;
+
TObject * obj = lofTasks->FindObject(name) ;
+
if (obj)
+
lofTasks->Remove(obj) ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::RemoveObjects(TString opt, TString name) const
+
{
+
// remove SDigits from the folder
+
// path is fSDigitsFolder/fHeaderFileName/name
+
+
TFolder * emcal = 0 ;
+
TFolder * emcalmain = 0 ;
+
+
if (opt == "H") { // Hits
+
emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
+
if (!emcal)
+
return ;
+
name = "Hits" ;
+
}
+
+
else if ( opt == "S") { // SDigits
+
emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
+
if (!emcalmain)
+
return ;
+
emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
+
if (!emcal)
+
return ;
+
}
+
+
else if (opt == "D") { // Digits
+
emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
+
if (!emcal)
+
return ;
+
}
+
+
else if (opt == "RT") { // Tower RecPoints
+
emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
+
if (!emcal)
+
return ;
+
}
+
+
else if (opt == "RP") { // Preshower RecPoints
+
emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
+
if (!emcal)
+
return ;
+
}
+
+
else if (opt == "T") { // TrackSegments
+
emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
+
if (!emcal)
+
return ;
+
}
+
+
else if (opt == "P") { // RecParticles
+
emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
+
if (!emcal)
+
return ;
+
}
+
+
else {
+
cerr << "WARNING: AliEMCALGetter::RemoveObjects -> Unknown option " << opt.Data() << endl ;
+
return ;
+
}
+
+
TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject(name)) ;
+
if (ar) {
+
emcal->Remove(ar) ;
+
ar->Delete() ;
+
delete ar ;
+
}
+
+
if (opt == "S")
+
emcalmain->Remove(emcal) ;
+
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::RemoveSDigits() const
+
{
+
TFolder * emcal= dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
+
if (!emcal)
+
return ;
+
+
emcal->SetOwner() ;
+
emcal->Clear() ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALGetter::CleanWhiteBoard(void){
+
+
TFolder * emcalmain = 0 ;
+
TFolder * emcal ;
+
TObjArray * ar ;
+
TList * lofTasks = 0 ;
+
TTask * task = 0 ;
+
TTask * emcalt = 0 ;
+
+
// Hits
+
emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
+
if (emcal){
+
TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject("Hits")) ;
+
if (ar) {
+
emcal->Remove(ar) ;
+
ar->Delete() ;
+
delete ar ;
+
}
+
}
+
+
// SDigits
+
emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
+
if (emcalmain){
+
emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
+
if (emcal) {
+
ar = dynamic_cast<TObjArray*>(emcal->FindObject(fSDigitsTitle)) ;
+
if (ar) {
+
emcal->Remove(ar) ;
+
ar->Delete() ;
+
delete ar ;
+
}
+
}
+
emcalmain->Remove(emcal) ;
+
}
+
+
+
// Digits
+
emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
+
if (emcal){
+
ar = dynamic_cast<TObjArray*>(emcal->FindObject(fDigitsTitle)) ;
+
if (ar) {
+
emcal->Remove(ar) ;
+
ar->Delete() ;
+
delete ar ;
+
}
+
}
+
+
+
// TowerRecPoints
+
emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
+
if (emcal){
+
ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
+
if (ar) {
+
emcal->Remove(ar) ;
+
ar->Delete() ;
+
delete ar ;
+
}
+
}
+
+
+
// PreShowerRecPoints
+
emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
+
if (emcal){
+
ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
+
if (ar) {
+
emcal->Remove(ar) ;
+
ar->Delete() ;
+
delete ar ;
+
}
+
}
+
+
+
// TrackSegments
+
emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
+
if (emcal) {
+
ar = dynamic_cast<TObjArray*>(emcal->FindObject(fTrackSegmentsTitle)) ;
+
if (ar) {
+
emcal->Remove(ar) ;
+
ar->Delete() ;
+
delete ar ;
+
}
+
}
+
+
+
+
// RecParticles
+
emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
+
if (emcal){
+
ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecParticlesTitle)) ;
+
if (ar) {
+
emcal->Remove(ar) ;
+
ar->Delete() ;
+
delete ar ;
+
}
+
}
+
+
+
//---- Now Tasks -----------
+
+
TObject * obj ;
+
TString sdname(fSDigitsTitle);
+
+
// Digitizer
+
task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
+
if (task){
+
emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
+
if (emcalt){
+
lofTasks = emcalt->GetListOfTasks() ;
+
if (lofTasks){
+
obj = lofTasks->FindObject(sdname.Data()) ;
+
if (obj)
+
lofTasks->Remove(obj) ;
+
}
+
}
+
}
+
+
+
sdname.Append(":") ;
+
// Clusterizer, TrackSegmentMaker, PID
+
task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
+
if (task){
+
emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
+
if (emcalt){
+
lofTasks = emcalt->GetListOfTasks() ;
+
TIter next(lofTasks);
+
while((obj=next())){
+
TString oname(obj->GetName()) ;
+
if (oname.BeginsWith(sdname)){
+
lofTasks->Remove(obj) ;
+
}
+
}
+
}
+
}
+
+
+
// SDigitizer
+
sdname.Append(fHeaderFile) ;
+
task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
+
if (task) {
+
emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
+
if (emcalt){
+
lofTasks = emcalt->GetListOfTasks() ;
+
if (lofTasks){
+
obj = lofTasks->FindObject(sdname.Data()) ;
+
if (obj)
+
lofTasks->Remove(obj) ;
+
}
+
}
+
}
+
+
}
+
//____________________________________________________________________________
+
void AliEMCALGetter::SetTitle(const char * branchTitle )
+
{
+
fBranchTitle = branchTitle ;
+
fSDigitsTitle = branchTitle ;
+
fDigitsTitle = branchTitle ;
+
fRecPointsTitle = branchTitle ;
+
fRecParticlesTitle = branchTitle ;
+
fTrackSegmentsTitle = branchTitle ;
+
if(fToSplit){
+
//First - extract full path if necessary
+
TString sFileName(fHeaderFile) ;
+
Ssiz_t islash = sFileName.Last('/') ;
+
if(islash<sFileName.Length())
+
sFileName.Remove(islash+1,sFileName.Length()) ;
+
else
+
sFileName="" ;
+
//Now construct file names
+
fSDigitsFileName = sFileName ;
+
fDigitsFileName = sFileName ;
+
fRecPointsFileName = sFileName ;
+
fRecParticlesFileName = sFileName ;
+
fTrackSegmentsFileName = sFileName ;
+
fSDigitsFileName += "EMCAL.SDigits." ;
+
fDigitsFileName += "EMCAL.Digits." ;
+
fRecPointsFileName += "EMCAL.RecData." ;
+
fTrackSegmentsFileName+= "EMCAL.RecData." ;
+
fRecParticlesFileName += "EMCAL.RecData." ;
+
if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
+
fSDigitsFileName += fBranchTitle ;
+
fSDigitsFileName += "." ;
+
fDigitsFileName += fBranchTitle ;
+
fDigitsFileName += "." ;
+
fRecPointsFileName += fBranchTitle ;
+
fRecPointsFileName += "." ;
+
fRecParticlesFileName += fBranchTitle ;
+
fRecParticlesFileName += "." ;
+
fTrackSegmentsFileName+= fBranchTitle ;
+
fTrackSegmentsFileName+= "." ;
+
}
+
fSDigitsFileName += "root" ;
+
fDigitsFileName += "root" ;
+
fRecPointsFileName += "root" ;
+
fRecParticlesFileName += "root" ;
+
fTrackSegmentsFileName+= "root" ;
+
}else{
+
fSDigitsFileName = "" ;
+
fDigitsFileName = "" ;
+
fRecPointsFileName = "" ;
+
fRecParticlesFileName = "" ;
+
fTrackSegmentsFileName = "" ;
+
}
+
TFolder * emcalFolder ;
+
emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder )
+
emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
+
+
emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder )
+
emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
+
+
//Make folder for SDigits
+
TString subdir(fHeaderFile) ;
+
subdir.ReplaceAll("/","_") ;
+
emcalFolder->AddFolder(subdir, fSDigitsFileName.Data());
+
+
+
emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder )
+
emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
+
+
emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
+
if ( !emcalFolder )
+
emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
+
+
+
}
+
//____________________________________________________________________________
+
void AliEMCALGetter::CloseSplitFiles(void){
+
TFile * file ;
+
file = static_cast<TFile*>(gROOT->GetFile(fSDigitsFileName.Data() ) ) ;
+
if(file)
+
file->Close() ;
+
file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName.Data() ) ) ;
+
if(file)
+
file->Close() ;
+
file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName.Data() ) ) ;
+
if(file)
+
file->Close() ;
+
file = static_cast<TFile*>(gROOT->GetFile(fTrackSegmentsFileName.Data() ) ) ;
+
if(file)
+
file->Close() ;
+
file = static_cast<TFile*>(gROOT->GetFile(fRecParticlesFileName.Data() ) ) ;
+
if(file)
+
file->Close() ;
+
+
}
+
#ifndef ALIEMCALGETTER_H
+
#define ALIEMCALGETTER_H
+
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+
* See cxx source for full Copyright notice */
+
+
/* $Id$ */
+
+
//_________________________________________________________________________
+
// A singleton that returns various objects
+
// Should be used on the analysis stage to avoid confusing between different
+
// branches of reconstruction tree: e.g. reading RecPoints and TS made from
+
// another set of RecPoints.
+
//
+
// The objects are retrived from folders.
+
//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
+
//
+
+
// Modif:
+
// August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
+
// of new IO (à la PHOS)
+
+
// --- ROOT system ---
+
#include "TClonesArray.h"
+
#include "TFolder.h"
+
#include "TTree.h"
+
#include "TFile.h"
+
class TString ;
+
class TParticle ;
+
class TTask ;
+
+
// --- Standard library ---
+
#include <stdlib.h>
+
#include <iostream.h>
+
+
// --- AliRoot header files ---
+
+
#include "AliRun.h"
+
#include "AliEMCAL.h"
+
#include "AliEMCALHit.h"
+
#include "AliEMCALDigit.h"
+
#include "AliEMCALTowerRecPoint.h"
+
//class AliEMCALTrackSegment ;
+
//class AliEMCALRecParticle ;
+
class AliEMCALGeometry ;
+
#include "AliEMCALDigitizer.h"
+
#include "AliEMCALSDigitizer.h"
+
class AliEMCALClusterizer ;
+
//class AliEMCALTrackSegmentMaker ;
+
//class AliEMCALPID ;
+
+
class AliEMCALGetter : public TObject {
+
+
public:
+
+
AliEMCALGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
+
cerr << "ERROR: AliEMCALGetter is a singleton default ctor not callable" << endl ;
+
abort() ;
+
}
+
AliEMCALGetter(const AliEMCALGetter & obj) {
+
// cpy ctor requested by Coding Convention
+
// but not yet needed
+
abort() ;
+
}
+
+
AliEMCALGetter & operator = (const AliEMCALGetter & ) {
+
// assignement operator requested by coding convention, but not needed
+
abort() ;
+
return *this ;
+
}
+
virtual ~AliEMCALGetter() ;
+
+
//=========== Instantiators ================
+
static AliEMCALGetter * GetInstance(const char* headerFile,
+
const char* branchTitle = "Default",
+
const Bool_t toSplit = kFALSE ) ;
+
static AliEMCALGetter * GetInstance() ;
+
+
//=========== General information about run ==============
+
const Int_t MaxEvent() const { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
+
const Int_t EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
+
const Bool_t BranchExists(const TString recName) const ;
+
+
//========== EMCALGeometry and EMCAL =============
+
const AliEMCAL * EMCAL() ;
+
AliEMCALGeometry * EMCALGeometry() ;
+
+
//========== Methods to read something from file ==========
+
void Event(const Int_t event, const char * opt = "HSDRP") ;
+
void Track(const Int_t itrack) ;
+
void ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when
+
//digitizing is under the conytrol of AliRunDigitizer,
+
//which opens all files etc.
+
//========== Alarms ======================
+
//TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
+
//const TObjArray * Alarms(const char * name ) const { return dynamic_cast<const TObjArray*>(ReturnO("Alarms", name)) ; }
+
//const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; }
+
+
//-----------------now getter's data--------------------------------------
+
+
//=========== Primaries ============
+
TTree * TreeK(TString filename="") ;
+
TClonesArray * Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
+
const TParticle * Primary(Int_t index) const;
+
const Int_t NPrimaries()const { return fNPrimaries; }
+
const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
+
+
//=========== Hits =================
+
TTree * TreeH(TString filename="") ;
+
const TClonesArray * Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
+
const AliEMCALHit * Hit(Int_t index) { return dynamic_cast<const AliEMCALHit*>(Hits()->At(index) );}
+
+
//=========== SDigits ==============
+
TTree * TreeS(TString filename="") ;
+
TClonesArray * SDigits(const char * name = 0, const char * file=0) {
+
return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; }
+
const AliEMCALDigit * SDigit(Int_t index) { return static_cast<const AliEMCALDigit*>(SDigits()->At(index)) ;}
+
const AliEMCALSDigitizer * SDigitizer(const char * name =0) const {
+
return (const AliEMCALSDigitizer*)(ReturnT("SDigitizer", name)) ; // here static or dynamic cast does not work ! why ?
+
}
+
+
//========== Digits ================
+
TTree * TreeD(TString filename="") ;
+
TClonesArray * Digits(const char * name = 0)const {
+
return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
+
const AliEMCALDigit * Digit(Int_t index) { return static_cast<const AliEMCALDigit *>(Digits()->At(index)) ;}
+
const AliEMCALDigitizer * Digitizer(const char * name =0) const {
+
return (const AliEMCALDigitizer*)(ReturnT("Digitizer", name)) ; }
+
+
//========== RecPoints =============
+
TObjArray * TowerRecPoints(const char * name = 0) const {
+
return (dynamic_cast<TObjArray*>(ReturnO("TowerRecPoints", name))) ; }
+
const AliEMCALTowerRecPoint * TowerRecPoint(Int_t index) { return static_cast<const AliEMCALTowerRecPoint *>(TowerRecPoints()->At(index)) ;}
+
TObjArray * PreShowerRecPoints(const char * name = 0) const {
+
return (dynamic_cast<TObjArray*>(ReturnO("PreShowerRecPoints", name))) ; }
+
const AliEMCALClusterizer * Clusterizer (const char * name =0) const {
+
return (const AliEMCALClusterizer*)(ReturnT("Clusterizer", name)) ;// here static or dynamic cast does not work ! why ?
+
}
+
+
//========== TrackSegments ==========
+
//TClonesArray * TrackSegments(const char * name = 0) const {
+
// return (dynamic_cast<TClonesArray*>(ReturnO("TrackSegments", name))) ; }
+
//const AliEMCALTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const {
+
// return (const AliEMCALTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ;// here static or dynamic cast does not work ! why }
+
+
//========== RecParticles ===========
+
//TClonesArray * RecParticles(const char * name = 0) const {
+
// return (dynamic_cast<TClonesArray*>(ReturnO("RecParticles", name))) ; }
+
//const AliEMCALPID * PID(const char * name =0) const {
+
// return (const AliEMCALPID*)(ReturnT("PID", name)) ;// here static or dynamic cast does not work ! why }
+
+
//-----------------Auxiliary methods: cleaners-----------------
+
void RemoveTask(TString opt, TString name) const ;
+
void RemoveObjects(TString opt, TString name) const ;
+
void RemoveSDigits() const ;
+
+
//-----------------Auxiliary methods: miscellana-----------------
+
void CloseFile() ;
+
const TFolder * Folder(const TString what) const ;
+
const Bool_t HasFailed(void) const {return fFailed ;}
+
void ListBranches(Int_t event=0) const ;
+
void NewBranch(TString name, Int_t event = 0) ;
+
Bool_t NewFile(TString name) ;
+
TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ; }
+
void SetDebug(Int_t level) {fDebug = level;} // Set debug level
+
void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
+
+
//------------Auxiliary methods: Posters--------------------
+
const Bool_t PostPrimaries(void ) const ;
+
const Bool_t PostHits(void ) const ;
+
const Bool_t PostSDigits( const char * name, const char * file = 0) const ;
+
const Bool_t PostDigits( const char * name ) const ;
+
const Bool_t PostRecPoints( const char * name ) const ;
+
//const Bool_t PostTrackSegments(const char * name) const ;
+
//const Bool_t PostRecParticles( const char * name) const ;
+
const Bool_t PostClusterizer( const char * name) const ;
+
const Bool_t PostClusterizer(AliEMCALClusterizer * clu) const ;
+
const Bool_t PostSDigitizer (AliEMCALSDigitizer * sdigitizer) const ;
+
const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
+
const Bool_t PostDigitizer (AliEMCALDigitizer * digitizer) const ;
+
const Bool_t PostDigitizer ( const char * name) const ;
+
//const Bool_t PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsm) const ;
+
//const Bool_t PostTrackSegmentMaker(const char * name ) const ;
+
//const Bool_t PostPID (AliEMCALPID * pid) const ;
+
//const Bool_t PostPID (const char * name ) const ;
+
//const Bool_t PostQA (void) const ;
+
+
private:
+
+
AliEMCALGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ;
+
TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
+
const TTask * ReturnT(TString what,TString name=0) const ;
+
void DefineBranchTitles(char* branch, char* branchTitle) ;
+
Int_t ReadTreeD(const Int_t event) ;
+
Int_t ReadTreeH(void) ;
+
Int_t ReadTreeR(const Int_t event) ;
+
Int_t ReadTreeS(const Int_t event) ;
+
void ReadTreeQA(void) ;
+
void ReadPrimaries(void) ;
+
void CleanWhiteBoard(void) ;
+
void CloseSplitFiles(void) ;
+
void SetTitle(const char * title) ;
+
+
TObject ** PrimariesRef(void) const ;
+
TObject ** HitsRef(void) const ;
+
TObject ** SDigitsRef(const char * name, const char * file = 0 ) const;
+
TObject ** DigitsRef (const char * name) const ;
+
TObject ** TowerRecPointsRef (const char * name) const ;
+
TObject ** PreShowerRecPointsRef (const char * name) const ;
+
//TObject ** TrackSegmentsRef(const char * name) const ;
+
//TObject ** RecParticlesRef (const char * name) const ;
+
//TObject ** AlarmsRef (void) const ;
+
+
TObject ** SDigitizerRef (const char * name) const ;
+
TObject ** DigitizerRef (const char * name) const ;
+
TObject ** ClusterizerRef(const char * name) const ;
+
//TObject ** TSMakerRef (const char * name) const ;
+
//TObject ** PIDRef (const char * name) const ;
+
+
private:
+
+
static TFile * fFile ; //!
+
Bool_t fToSplit ; //! Do we work in the split mode
+
TString fHeaderFile ; //! File in which gAlice lives
+
TString fBranchTitle ; //!
+
TString fTrackSegmentsTitle ;//!
+
TString fTrackSegmentsFileName ;//!
+
TString fRecPointsTitle ; //!
+
TString fRecPointsFileName ; //!
+
TString fRecParticlesTitle ; //!
+
TString fRecParticlesFileName ; //!
+
TString fDigitsTitle ; //!TDirectory tempo(gDirectory)
+
TString fDigitsFileName ; //! TDirectory tempo(gDirectory)
+
TString fSDigitsTitle ; //!
+
TString fSDigitsFileName ; //!
+
Bool_t fFailed ; //! true if file is not opened and/or galice not found
+
Int_t fDebug ; // Debug level
+
AliRun * fAlice ; //! needed to read TreeK if in an other file than fHeaderFile
+
Int_t fNPrimaries ; //! # of primaries
+
TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
+
TFolder * fModuleFolder ; //!Folder that contains the modules
+
TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles
+
TFolder * fHitsFolder ; //!Folder that contains the Hits
+
TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
+
TFolder * fDigitsFolder ; //!Folder that contains the Digits
+
TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
+
TFolder * fQAFolder ; //!Folder that contains the QA objects
+
TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
+
+
static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton
+
+
ClassDef(AliEMCALGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
+
+
};
+
+
#endif // AliEMCALGETTER_H
+
/*************************************************************************
+
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+
* *
+
* Author: The ALICE Off-line Project. *
+
* Contributors are mentioned in the code where appropriate. *
+
* *
+
* Permission to use, copy, modify and distribute this software and its *
+
* documentation strictly for non-commercial purposes is hereby granted *
+
* without fee, provided that the above copyright notice appears in all *
+
* copies and that both the copyright notice and this permission notice *
+
* appear in the supporting documentation. The authors make no claims *
+
* about the suitability of this software for any purpose. It is *
+
* provided "as is" without express or implied warranty. *
+
**************************************************************************/
+
+
+
/* $Id$ */
+
+
//_________________________________________________________________________
+
// This is a TTask that makes SDigits out of Hits
+
// A Summable Digits is the sum of all hits originating
+
// from one in one tower of the EMCAL
+
// A threshold for assignment of the primary to SDigit is applied
+
// SDigits are written to TreeS, branch "EMCAL"
+
// AliEMCALSDigitizer with all current parameters is written
+
// to TreeS branch "AliEMCALSDigitizer".
+
// Both branches have the same title. If necessary one can produce
+
// another set of SDigits with different parameters. Two versions
+
// can be distunguished using titles of the branches.
+
// User case:
+
// root [0] AliEMCALSDigitizer * s = new AliEMCALSDigitizer("galice.root")
+
// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
+
// root [1] s->ExecuteTask()
+
// // Makes SDigitis for all events stored in galice.root
+
// root [2] s->SetPedestalParameter(0.001)
+
// // One can change parameters of digitization
+
// root [3] s->SetSDigitsBranch("Redestal 0.001")
+
// // and write them into the new branch
+
// root [4] s->ExeciteTask("deb all tim")
+
// // available parameters:
+
// deb - print # of produced SDigitis
+
// deb all - print # and list of produced SDigits
+
// tim - print benchmarking information
+
//
+
//*-- Author : Sahal Yacoob (LBL)
+
// based on : AliPHOSSDigitzer
+
// Modif:
+
// August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
+
// of new IO (à la PHOS)
+
//////////////////////////////////////////////////////////////////////////////
+
+
+
// --- ROOT system ---
+
#include "TFile.h"
+
#include "TTask.h"
+
#include "TTree.h"
+
#include "TSystem.h"
+
#include "TROOT.h"
+
#include "TFolder.h"
+
#include "TBenchmark.h"
+
#include "TGeometry.h"
+
+
// --- Standard library ---
+
#include <iomanip.h>
+
+
// --- AliRoot header files ---
+
#include "AliRun.h"
+
#include "AliHeader.h"
+
#include "AliEMCALDigit.h"
+
#include "AliEMCALGeometry.h"
+
#include "AliEMCALGetter.h"
+
#include "AliEMCALHit.h"
+
#include "AliEMCALSDigitizer.h"
+
+
ClassImp(AliEMCALSDigitizer)
+
+
+
//____________________________________________________________________________
+
AliEMCALSDigitizer::AliEMCALSDigitizer():TTask("AliEMCALSDigitizer","")
+
{
+
// ctor
+
InitParameters() ;
+
fDefaultInit = kTRUE ;
+
}
+
+
//____________________________________________________________________________
+
AliEMCALSDigitizer::AliEMCALSDigitizer(const char* headerFile, const char *sDigitsTitle, const Bool_t toSplit):
+
TTask(sDigitsTitle, headerFile)
+
{
+
// ctor
+
InitParameters() ;
+
fToSplit = toSplit ;
+
Init();
+
fDefaultInit = kFALSE ;
+
}
+
+
//____________________________________________________________________________
+
AliEMCALSDigitizer::~AliEMCALSDigitizer()
+
{
+
// dtor
+
+
fSplitFile = 0 ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALSDigitizer::Init(){
+
+
// Initialization: open root-file, allocate arrays for hits and sdigits,
+
// attach task SDigitizer to the list of EMCAL tasks
+
//
+
// Initialization can not be done in the default constructor
+
//============================================================= YS
+
// The initialisation is now done by the getter
+
+
if( strcmp(GetTitle(), "") == 0 )
+
SetTitle("galice.root") ;
+
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance(GetTitle(), GetName(), fToSplit) ;
+
if ( gime == 0 ) {
+
cerr << "ERROR: AliEMCALSDigitizer::Init -> Could not obtain the Getter object !"
+
<< endl ;
+
return ;
+
}
+
+
gime->PostSDigits( GetName(), GetTitle() ) ;
+
+
fSplitFile = 0 ;
+
if(fToSplit){
+
// construct the name of the file as /path/EMCAL.SDigits.root
+
// First - extract full path if necessary
+
TString sDigitsFileName(GetTitle()) ;
+
Ssiz_t islash = sDigitsFileName.Last('/') ;
+
if(islash<sDigitsFileName.Length())
+
sDigitsFileName.Remove(islash+1,sDigitsFileName.Length()) ;
+
else
+
sDigitsFileName="" ;
+
// Next - append the file name
+
sDigitsFileName+="EMCAL.SDigits." ;
+
if((strcmp(GetName(),"Default")!=0)&&(strcmp(GetName(),"")!=0)){
+
sDigitsFileName+=GetName() ;
+
sDigitsFileName+="." ;
+
}
+
sDigitsFileName+="root" ;
+
// Finally - check if the file already opened or open the file
+
fSplitFile = static_cast<TFile*>(gROOT->GetFile(sDigitsFileName.Data()));
+
if(!fSplitFile)
+
fSplitFile = TFile::Open(sDigitsFileName.Data(),"update") ;
+
}
+
+
TString sdname(GetName() );
+
sdname.Append(":") ;
+
sdname.Append(GetTitle() ) ;
+
SetName(sdname) ;
+
gime->PostSDigitizer(this) ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALSDigitizer::InitParameters(){
+
fA = 0;
+
fB = 10000000.;
+
fTowerPrimThreshold = 0.01 ;
+
fPreShowerPrimThreshold = 0.0001 ;
+
fPhotonElectronFactor = 5000. ; // photoelectrons per GeV
+
fSplitFile = 0 ;
+
fToSplit = kFALSE ;
+
}
+
+
//____________________________________________________________________________
+
void AliEMCALSDigitizer::Exec(Option_t *option) {
+
+
// Collects all hits in the same active volume into digit
+
+
if( strcmp(GetName(), "") == 0 )
+
Init() ;
+
+
if (strstr(option, "print") ) {
+
Print("") ;
+
return ;
+
}
+
+
if(strstr(option,"tim"))
+
gBenchmark->Start("EMCALSDigitizer");
+
+
//Check, if this branch already exits
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
if(gime->BranchExists("SDigits") )
+
return;
+
+
TString sdname(GetName()) ;
+
sdname.Remove(sdname.Index(GetTitle())-1) ;
+
+
Int_t nevents = gime->MaxEvent() ;
+
Int_t ievent ;
+
for(ievent = 0; ievent < nevents; ievent++){
+
gime->Event(ievent,"H") ;
+
const TClonesArray * hits = gime->Hits() ;
+
TClonesArray * sdigits = gime->SDigits(sdname.Data()) ;
+
sdigits->Clear();
+
Int_t nSdigits = 0 ;
+
+
//Collects all hits in the same active volume into digit
+
+
//Now make SDigits from hits, for EMCAL it is the same, so just copy
+
Int_t nPrim = static_cast<Int_t>((gAlice->TreeH())->GetEntries()) ;
+
// Attention nPrim is the number of primaries tracked by Geant
+
// and this number could be different to the number of Primaries in TreeK;
+
Int_t iprim ;
+
for ( iprim = 0 ; iprim < nPrim ; iprim++ ) {
+
//=========== Get the EMCAL branch from Hits Tree for the Primary iprim
+
gime->Track(iprim) ;
+
Int_t i;
+
for ( i = 0 ; i < hits->GetEntries() ; i++ ) {
+
AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(hits->At(i)) ;
+
AliEMCALDigit * curSDigit = 0 ;
+
AliEMCALDigit * sdigit = 0 ;
+
Bool_t newsdigit = kTRUE;
+
// Assign primary number only if deposited energy is significant
+
+
if( (!hit->IsInPreShower() && hit->GetEnergy() > fTowerPrimThreshold) ||
+
(hit->IsInPreShower() && hit->GetEnergy() > fPreShowerPrimThreshold))
+
curSDigit = new AliEMCALDigit( hit->GetPrimary(),
+
hit->GetIparent(),Layer2TowerID(hit->GetId(),hit->IsInPreShower()),
+
Digitize(hit->GetEnergy()), hit->GetTime() ) ;
+
else
+
curSDigit = new AliEMCALDigit( -1 ,
+
-1 ,
+
Layer2TowerID(hit->GetId(),hit->IsInPreShower()),
+
Digitize(hit->GetEnergy()), hit->GetTime() ) ;
+
Int_t check = 0 ;
+
for(check= 0; check < nSdigits ; check++) {
+
sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
+
if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same tower or the same preshower ?
+
*sdigit = *sdigit + *curSDigit;
+
newsdigit = kFALSE;
+
}
+
}
+
if (newsdigit) {
+
new((*sdigits)[nSdigits]) AliEMCALDigit(*curSDigit);
+
nSdigits++ ;
+
}
+
} // loop over all hits (hit = deposited energy/layer/entering particle)
+
} // loop over iprim
+
+
sdigits->Sort() ;
+
+
nSdigits = sdigits->GetEntriesFast() ;
+
fSDigitsInRun += nSdigits ;
+
sdigits->Expand(nSdigits) ;
+
+
const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
+
+
Int_t lastPreShowerIndex = nSdigits - 1 ;
+
if (!(dynamic_cast<AliEMCALDigit *>(sdigits->At(lastPreShowerIndex))->IsInPreShower()))
+
lastPreShowerIndex = -2;
+
Int_t firstPreShowerIndex = 100000 ;
+
Int_t index ;
+
AliEMCALDigit * sdigit = 0 ;
+
for ( index = 0; index < nSdigits ; index++) {
+
sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(index) ) ;
+
if (sdigit->IsInPreShower() ){
+
firstPreShowerIndex = index ;
+
break ;
+
}
+
}
+
+
AliEMCALDigit * preshower ;
+
AliEMCALDigit * tower ;
+
Int_t lastIndex = lastPreShowerIndex +1 ;
+
+
for (index = firstPreShowerIndex ; index <= lastPreShowerIndex; index++) {
+
preshower = dynamic_cast<AliEMCALDigit *>(sdigits->At(index) );
+
Bool_t towerFound = kFALSE ;
+
Int_t jndex ;
+
for (jndex = 0; jndex < firstPreShowerIndex; jndex++) {
+
tower = dynamic_cast<AliEMCALDigit *>(sdigits->At(jndex) );
+
if ( (preshower->GetId() - (geom->GetNZ() * geom->GetNPhi()) ) == tower->GetId() ) {
+
Float_t towerEnergy = static_cast<Float_t>(tower->GetAmp()) ;
+
Float_t preshoEnergy = static_cast<Float_t>(preshower->GetAmp()) ;
+
towerEnergy +=preshoEnergy ;
+
*tower = *tower + *preshower ; // and add preshower multiplied by layer ratio to tower
+
tower->SetAmp(static_cast<Int_t>(TMath::Ceil(towerEnergy))) ;
+
towerFound = kTRUE ;
+
}
+
}
+
if ( !towerFound ) {
+
+
new((*sdigits)[lastIndex]) AliEMCALDigit(*preshower);
+
AliEMCALDigit * temp = dynamic_cast<AliEMCALDigit *>(sdigits->At(lastIndex)) ;
+
temp->SetId(temp->GetId() - (geom->GetNZ() * geom->GetNPhi()) ) ;
+
lastIndex++ ;
+
}
+
}
+
+
sdigits->Sort() ;
+
Int_t NPrimarymax = -1 ;
+
Int_t i ;
+
for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) {
+
sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(i)) ;
+
sdigit->SetIndexInList(i) ;
+
}
+
+
for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) {
+
if (((dynamic_cast<AliEMCALDigit *>(sdigits->At(i)))->GetNprimary()) > NPrimarymax)
+
NPrimarymax = ((dynamic_cast<AliEMCALDigit *>(sdigits->At(i)))->GetNprimary()) ;
+
}
+
+
//Now write SDigits
+
+
if(gAlice->TreeS() == 0 || (fSplitFile)) //<--- To be checked: we should not create TreeS if it is already here
+
gAlice->MakeTree("S",fSplitFile);
+
+
if(fSplitFile)
+
fSplitFile->cd() ;
+
+
//First list of sdigits
+
Int_t bufferSize = 32000 ;
+
TBranch * sdigitsBranch = gAlice->TreeS()->Branch("EMCAL",&sdigits,bufferSize);
+
sdigitsBranch->SetTitle(sdname);
+
+
//NEXT - SDigitizer
+
Int_t splitlevel = 0 ;
+
AliEMCALSDigitizer * sd = this ;
+
TBranch * sdigitizerBranch = gAlice->TreeS()->Branch("AliEMCALSDigitizer","AliEMCALSDigitizer",
+
&sd,bufferSize,splitlevel);
+
sdigitizerBranch->SetTitle(sdname);
+
+
sdigitsBranch->Fill() ;
+
sdigitizerBranch->Fill() ;
+
gAlice->TreeS()->AutoSave() ;
+
+
if(strstr(option,"deb"))
+
PrintSDigits(option) ;
+
+
}
+
+
if(strstr(option,"tim")){
+
gBenchmark->Stop("EMCALSDigitizer");
+
cout << "AliEMCALSDigitizer:" << endl ;
+
cout << " took " << gBenchmark->GetCpuTime("EMCALSDigitizer") << " seconds for SDigitizing "
+
<< gBenchmark->GetCpuTime("EMCALSDigitizer") << " seconds per event " << endl ;
+
cout << endl ;
+
}
+
}
+
+
//__________________________________________________________________
+
void AliEMCALSDigitizer::SetSDigitsBranch(const char * title ){
+
+
// Setting title to branch SDigits
+
+
TString stitle(title) ;
+
+
// check if branch with title already exists
+
TBranch * sdigitsBranch =
+
static_cast<TBranch*>(gAlice->TreeS()->GetListOfBranches()->FindObject("EMCAL")) ;
+
TBranch * sdigitizerBranch =
+
static_cast<TBranch*>(gAlice->TreeS()->GetListOfBranches()->FindObject("AliEMCALSDigitizer")) ;
+
const char * sdigitsTitle = sdigitsBranch ->GetTitle() ;
+
const char * sdigitizerTitle = sdigitizerBranch ->GetTitle() ;
+
if ( stitle.CompareTo(sdigitsTitle)==0 || stitle.CompareTo(sdigitizerTitle)==0 ){
+
cerr << "ERROR: AliEMCALSdigitizer::SetSDigitsBranch -> Cannot overwrite existing branch with title " << title << endl ;
+
return ;
+
}
+
+
cout << "AliEMCALSdigitizer::SetSDigitsBranch -> Changing SDigits file from " << GetName() << " to " << title << endl ;
+
+
SetName(title) ;
+
+
// Post to the WhiteBoard
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
gime->PostSDigits( title, GetTitle()) ;
+
}
+
+
+
//__________________________________________________________________
+
void AliEMCALSDigitizer::Print(Option_t* option)const
+
{
+
// Prints parameters of SDigitizer
+
+
cout << "------------------- "<< GetName() << " -------------" << endl ;
+
cout << " Writing SDigitis to branch with title " << GetName() << endl ;
+
cout << " with digitization parameters A = " << fA << endl ;
+
cout << " B = " << fB << endl ;
+
cout << " Threshold for Primary assignment in Tower = " << fTowerPrimThreshold << endl ;
+
cout << " Threshold for Primary assignment in PreShower = " << fPreShowerPrimThreshold << endl ;
+
cout << "---------------------------------------------------"<<endl ;
+
+
}
+
+
//__________________________________________________________________
+
Bool_t AliEMCALSDigitizer::operator==( AliEMCALSDigitizer const &sd )const
+
{
+
// Equal operator.
+
// SDititizers are equal if their pedestal, slope and threshold are equal
+
+
if( (fA==sd.fA)&&(fB==sd.fB)&&
+
(fTowerPrimThreshold==sd.fTowerPrimThreshold) &&
+
(fPreShowerPrimThreshold==sd.fPreShowerPrimThreshold))
+
return kTRUE ;
+
else
+
return kFALSE ;
+
}
+
//__________________________________________________________________
+
void AliEMCALSDigitizer::PrintSDigits(Option_t * option){
+
//Prints list of digits produced at the current pass of AliEMCALDigitizer
+
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
TString sdname(GetName()) ;
+
sdname.Remove(sdname.Index(GetTitle())-1) ;
+
const TClonesArray * sdigits = gime->SDigits(sdname.Data()) ;
+
+
cout << "AliEMCALSDigitiser: event " << gAlice->GetEvNumber() << endl ;
+
cout << " Number of entries in SDigits list " << sdigits->GetEntriesFast() << endl ;
+
cout << endl ;
+
if(strstr(option,"all")||strstr(option,"EMC")){
+
+
//loop over digits
+
AliEMCALDigit * digit;
+
cout << "SDigit Id " << " Amplitude " << " Time " << " Index " << " Nprim " << " Primaries list " << endl;
+
Int_t index ;
+
for (index = 0 ; index < sdigits->GetEntries() ; index++) {
+
digit = dynamic_cast<AliEMCALDigit *>( sdigits->At(index) ) ;
+
cout << setw(6) << digit->GetId() << " " << setw(10) << digit->GetAmp() << " " << digit->GetTime()
+
<< setw(6) << digit->GetIndexInList() << " "
+
<< setw(5) << digit->GetNprimary() <<" ";
+
+
Int_t iprimary;
+
for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
+
cout << " " << digit->GetPrimary(iprimary+1) << " ";
+
cout << endl;
+
}
+
cout <<endl;
+
}
+
}
+
+
//________________________________________________________________________
+
const Int_t AliEMCALSDigitizer::Layer2TowerID(Int_t ihit, Bool_t preshower)
+
{
+
// Method to Transform from Hit Id to Digit Id
+
// This function should be one to one
+
AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
+
const AliEMCALGeometry * geom = gime->EMCALGeometry();
+
Int_t ieta = ((ihit-1)/geom->GetNPhi())%geom->GetNZ(); // eta Tower Index
+
Int_t iphi = (ihit-1)%(geom->GetNPhi())+1; //phi Tower Index
+
Int_t it = -10;
+
Int_t ipre = 0;
+
+
if (preshower)ipre = 1;
+
if (iphi > 0 && ieta >= 0){
+
it = iphi+ieta*geom->GetNPhi() + ipre*geom->GetNPhi()*geom->GetNZ();
+
return it;
+
}else{
+
cerr << " AliEMCALSDigitizer::Layer2TowerID() -- there is an error "<< endl << "Eta number = "
+
<< ieta << "Phi number = " << iphi << endl ;
+
return it;
+
} // end if iphi>0 && ieta>0
+
}
+
//_______________________________________________________________________________________
+
// void AliEMCALSDigitizer::TestTowerID(void)
+
// {
+
// Int_t j;
+
+
// Bool_t preshower = kFALSE;
+
// for (j = 0 ; j < 10 ; j++){ // loop over hit id
+
// Int_t i;
+
// for (i = 0 ; i <= 2 ; i++){ // loop over
+
// Int_t k = i*96*144+j*144+1;
+
// cout << " Hit Index = " << k << " " << j*10 << " TOWERID = " << Layer2TowerID(k, preshower) << endl ;
+
// }
+
// }
+
// }
+
+
//____________________________________________________________________________
+
void AliEMCALSDigitizer::UseHitsFrom(const char * filename)
+
{
+
SetTitle(filename) ;
+
Init() ;
+
}
+
#ifndef ALIEMCALSDigitizer_H
+
#define ALIEMCALSDigitizer_H
+
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+
* See cxx source for full Copyright notice */
+
+
/* $Id$ */
+
+
//_________________________________________________________________________
+
// Task Class for making SDigits in EMCAL
+
//
+
//*-- Author: Sahal Yacoob (LBL)
+
// based on : AliPHOSSDigitizer
+
//_________________________________________________________________________
+
//
+
// Modif:
+
// August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
+
// of new IO (à la PHOS)
+
+
// --- ROOT system ---
+
#include "TTask.h"
+
#include "TString.h"
+
// --- Standard library ---
+
+
// --- AliRoot header files ---
+
+
class AliEMCALSDigitizer: public TTask {
+
+
public:
+
AliEMCALSDigitizer() ; // ctor
+
AliEMCALSDigitizer(const char* headerFile,const char* hdigitsTitle = "Default", const Bool_t toSplit = kFALSE) ;
+
virtual ~AliEMCALSDigitizer() ; // dtor
+
+
Float_t Calibrate(Int_t amp)const {return (amp - fA)/fB ; }
+
Int_t Digitize(Float_t Energy)const { return (Int_t ) ( fA + Energy*fB); }
+
virtual void Exec(Option_t *option);
+
const char * GetSDigitsBranch()const{return GetName();}
+
const Int_t GetSDigitsInRun() const {return fSDigitsInRun ;}
+
const Float_t GetPedestalParameter()const {return fA;}
+
const Float_t GetCalibrationParameter()const{return fB;}
+
virtual void Print(Option_t* option) const ;
+
void SetSDigitsBranch(const char * title ) ;
+
void SetPedestalParameter(Float_t A){fA = A ;}
+
void SetSlopeParameter(Float_t B){fB = B ;}
+
void UseHitsFrom(const char * filename) ;
+
Bool_t operator == (const AliEMCALSDigitizer & sd) const ;
+
const Int_t Segment2TowerID(Int_t SegmentID){
+
return Layer2TowerID(SegmentID,kFALSE);
+
}
+
+
private:
+
void Init() ;
+
void InitParameters() ;
+
void PrintSDigits(Option_t * option) ;
+
const Int_t Layer2TowerID(Int_t,Bool_t) ;
+
+
private:
+
Float_t fA ; // Pedestal parameter
+
Float_t fB ; // Slope Digitizition parameters
+
Float_t fPhotonElectronFactor ; // number of photon electrons per GeV
+
// should be calculated independently for each layer as :
+
// LightYield*LightCollectionEfficiency*LightAttenuation*APDPhotoElectronEfficiency*APDGain
+
Float_t fTowerPrimThreshold ; // To store primary in Tower if Elos > threshold
+
Float_t fPreShowerPrimThreshold ;// To store primary if Pre Shower Elos > threshold
+
Bool_t fDefaultInit; //! Says if the task was created by defaut ctor (only parameters are initialized)
+
Int_t fSDigitsInRun ; //! Total number of sdigits in one run
+
TFile * fSplitFile ; //! file in which SDigits will eventually be stored
+
Bool_t fToSplit ; //! Says that sigits should be written into splip file
+
+
ClassDef(AliEMCALSDigitizer,2) // description
+
+
};
+
+
#endif // AliEMCALSDigitizer_H
+
/**************************************************************************
+
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+
* *
+
* Author: The ALICE Off-line Project. *
+
* Contributors are mentioned in the code where appropriate. *
+
* *
+
* Permission to use, copy, modify and distribute this software and its *
+
* documentation strictly for non-commercial purposes is hereby granted *
+
* without fee, provided that the above copyright notice appears in all *
+
* copies and that both the copyright notice and this permission notice *
+
* appear in the supporting documentation. The authors make no claims *
+
* about the suitability of this software for any purpose. It is *
+
* provided "as is" without express or implied warranty. *
+
**************************************************************************/
+
+
/* $Id$ */
+
+
//_________________________________________________________________________
+
// Implementation version v1 of EMCAL Manager class
+
// An object of this class does not produce digits
+
// It is the one to use if you do want to produce outputs in TREEH
+
//
+
//*-- Author: Sahal Yacoob (LBL /UCT)
+
//*-- : Jennifer Klay (LBL)
+
+
// This Class not stores information on all particles prior to EMCAL entry - in order to facilitate analysis.
+
// This is done by setting fIShunt =2, and flagging all parents of particles entering the EMCAL.
+
+
// 15/02/2002 .... Yves Schutz
+
// 1. fSamplingFraction and fLayerToPreshowerRatio have been removed
+
// 2. Timing signal is collected and added to hit
+
+
// --- ROOT system ---
+
#include "TPGON.h"
+
#include "TTUBS.h"
+
#include "TNode.h"
+
#include "TRandom.h"
+
#include "TTree.h"
+
#include "TGeometry.h"
+
#include "TParticle.h"
+
+
// --- Standard library ---
+
+
#include <stdio.h>
+
#include <string.h>
+
#include <stdlib.h>
+
#include <strstream.h>
+
#include <iostream.h>
+
#include <math.h>
+
// --- AliRoot header files ---
+
+
#include "AliEMCALv1.h"
+
#include "AliEMCALHit.h"
+
#include "AliEMCALGeometry.h"
+
#include "AliConst.h"
+
#include "AliRun.h"
+
#include "AliMC.h"
+
+
ClassImp(AliEMCALv1)
+
+
+
//______________________________________________________________________
+
AliEMCALv1::AliEMCALv1():AliEMCALv0(){
+
// ctor
+
fLightYieldMean = 0 ;
+
fIntrinsicAPDEfficiency = fLightFactor = fLightYieldAttenuation = fAPDFactor = fAPDGain = fRecalibrationFactor = fAPDFactor = 0. ;
+
}
+
+
//______________________________________________________________________
+
AliEMCALv1::AliEMCALv1(const char *name, const char *title):
+
AliEMCALv0(name,title){
+
// Standard Creator.
+
+
fHits= new TClonesArray("AliEMCALHit",1000);
+
gAlice->AddHitList(fHits);
+
+
fNhits = 0;
+
fIshunt = 2; // All hits are associated with particles entering the calorimeter
+
+
//Photoelectron statistics:
+
// The light yield is a poissonian distribution of the number of
+
// photons created in a plastic layer, calculated using following formula
+
// NumberOfPhotons = EnergyLost * LightYieldMean* APDEfficiency *
+
// exp (-LightYieldAttenuation * DistanceToPINdiodeFromTheHit)
+
// LightYieldMean is parameter calculated to be over 100000 photons per GeV (a guess)
+
// APDEfficiency is 0.02655
+
// fLightYieldAttenuation is 0.0045 a guess
+
// TO BE FIXED
+
//***** Need a method in geometry to retrieve the fiber length corresponding to each layer
+
//***** See the step manager for the light attenuation calculation
+
// The number of electrons created in the APD is
+
// NumberOfElectrons = APDGain * LightYield
+
// The APD Gain is 300
+
+
fLightYieldMean = 10000000.; // This is a guess
+
fIntrinsicAPDEfficiency = 0.02655 ;
+
fLightFactor = fLightYieldMean * fIntrinsicAPDEfficiency ;
+
fLightYieldAttenuation = 0.0045 ; // an other guess
+
fAPDGain = 300. ;
+
fRecalibrationFactor = 13.418/ fLightYieldMean ;
+
fAPDFactor = (fRecalibrationFactor/100.) * fAPDGain ;
+
+
}
+
+
//______________________________________________________________________
+
AliEMCALv1::~AliEMCALv1(){
+
// dtor
+
+
if ( fHits) {
+
fHits->Delete();
+
delete fHits;
+
fHits = 0;
+
}
+
}
+
//______________________________________________________________________
+
void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
+
Int_t id, Float_t * hits,Float_t * p){
+
// Add a hit to the hit list.
+
// An EMCAL hit is the sum of all hits in a single segment
+
// originating from the same enterring particle
+
Int_t hitCounter;
+
+
AliEMCALHit *newHit;
+
AliEMCALHit *curHit;
+
Bool_t deja = kFALSE;
+
+
newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
+
for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
+
curHit = (AliEMCALHit*) (*fHits)[hitCounter];
+
// We add hits with the same tracknumber, while GEANT treats
+
// primaries succesively
+
if(curHit->GetPrimary() != primary) break;
+
if( *curHit == *newHit ) {
+
*curHit = *curHit + *newHit;
+
deja = kTRUE;
+
} // end if
+
} // end for hitCounter
+
+
if ( !deja ) {
+
new((*fHits)[fNhits]) AliEMCALHit(*newHit);
+
fNhits++;
+
} // end if
+
+
delete newHit;
+
}
+
//______________________________________________________________________
+
void AliEMCALv1::StepManager(void){
+
// Accumulates hits as long as the track stays in a single
+
// crystal or PPSD gas Cell
+
+
Int_t id[2]; // (layer, phi, Eta) indices
+
Int_t absid;
+
// position wrt MRS and energy deposited
+
Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
+
Float_t pmom[4]={0.,0.,0.,0.};
+
TLorentzVector pos; // Lorentz vector of the track current position.
+
TLorentzVector mom; // Lorentz vector of the track current momentum.
+
Int_t tracknumber = gAlice->CurrentTrack();
+
Int_t primary = 0;
+
static Int_t iparent = 0;
+
static Float_t ienergy = 0;
+
Int_t copy = 0;
+
+
AliEMCALGeometry * geom = GetGeometry() ;
+
+
if(gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"XALU") == 0)){ // This Particle in enterring the Calorimeter
+
gMC->TrackPosition(pos) ;
+
xyzte[0] = pos[0] ;
+
xyzte[1] = pos[1] ;
+
xyzte[2] = pos[2] ;
+
if ( (xyzte[0]*xyzte[0] + xyzte[1]*xyzte[1])
+
< (geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 )*(geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 ) ) {
+
iparent = tracknumber;
+
gMC->TrackMomentum(mom);
+
ienergy = mom[3];
+
TParticle * part = 0 ;
+
Int_t parent = iparent ;
+
while ( parent != -1 ) { // <------------- flags this particle to be kept and
+
//all the ancestors of this particle
+
part = gAlice->Particle(parent) ;
+
part->SetBit(kKeepBit);
+
parent = part->GetFirstMother() ;
+
}
+
}
+
}
+
if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are in a Scintillator Layer
+
+
Float_t depositedEnergy ;
+
+
if( (depositedEnergy = gMC->Edep()) > 0.){// Track is inside a scintillator and deposits some energy
+
+
gMC->TrackPosition(pos);
+
xyzte[0] = pos[0];
+
xyzte[1] = pos[1];
+
xyzte[2] = pos[2];
+
xyzte[3] = gMC->TrackTime() ;
+
+
gMC->TrackMomentum(mom);
+
pmom[0] = mom[0];
+
pmom[1] = mom[1];
+
pmom[2] = mom[2];
+
pmom[3] = mom[3];
+
+
gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
+
gMC->CurrentVolID(id[1]); // get the phi number inside the layer
+
absid = (id[0]-1)*(geom->GetNPhi()) + id[1];
+
+
//Calculates the light yield, the number of photons produced in the
+
//plastic layer
+
// Here we need to know the fiber lebgth to calculate the attenuation
+
+
Float_t lengthOfFiber = 0. ;// should be retrieved from the geometry
+
+
Float_t lightYield = gRandom->Poisson(fLightFactor * depositedEnergy *
+
exp(-fLightYieldAttenuation * lengthOfFiber)) ;
+
xyzte[4] = fAPDFactor * lightYield ;
+
+
primary = gAlice->GetPrimary(tracknumber);
+
AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyzte, pmom);
+
} // there is deposited energy
+
}
+
}
+