/* History of cvs commits:
*
* $Log$
+ * Revision 1.5 2007/12/14 10:54:15 gustavo
+ * Protection against cluster labels larger than kinematics entries
+ *
+ * Revision 1.4 2007/10/29 13:48:42 gustavo
+ * Corrected coding violations
+ *
+ * Revision 1.2 2007/08/17 12:40:04 schutz
+ * New analysis classes by Gustavo Conesa
+ *
* Revision 1.1.2.1 2007/07/26 10:32:09 schutz
* new analysis classes in the the new analysis framework
*
// --- ROOT system ---
-#include "Riostream.h"
+#include <TFormula.h>
#include <TParticle.h>
-
+
//---- ANALYSIS system ----
#include "AliGammaMCDataReader.h"
-#include "AliLog.h"
#include "AliESDEvent.h"
#include "AliESDVertex.h"
#include "AliESDCaloCluster.h"
#include "AliStack.h"
+#include "AliLog.h"
ClassImp(AliGammaMCDataReader)
//____________________________________________________________________________
AliGammaMCDataReader::AliGammaMCDataReader() :
- AliGammaReader(),
- fEMCALPID(0),fPHOSPID(0),
- fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.), fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.)
+ AliGammaReader()
{
//Default Ctor
//Initialize parameters
fDataType=kMCData;
- InitParameters();
}
//____________________________________________________________________________
AliGammaMCDataReader::AliGammaMCDataReader(const AliGammaMCDataReader & g) :
- AliGammaReader(g),
- fEMCALPID(g.fEMCALPID),
- fPHOSPID(g.fPHOSPID),
- fEMCALPhotonWeight(g.fEMCALPhotonWeight),
- fEMCALPi0Weight(g.fEMCALPi0Weight),
- fPHOSPhotonWeight(g.fPHOSPhotonWeight),
- fPHOSPi0Weight(g.fPHOSPi0Weight)
+ AliGammaReader(g)
{
// cpy ctor
}
if(&source == this) return *this;
- fEMCALPID = source.fEMCALPID ;
- fPHOSPID = source.fPHOSPID ;
- fEMCALPhotonWeight = source. fEMCALPhotonWeight ;
- fEMCALPi0Weight = source.fEMCALPi0Weight ;
- fPHOSPhotonWeight = source.fPHOSPhotonWeight ;
- fPHOSPi0Weight = source.fPHOSPi0Weight ;
-
+
return *this;
}
void AliGammaMCDataReader::CreateParticleList(TObject * data, TObject * kine,
TClonesArray * plCTS,
TClonesArray * plEMCAL,
- TClonesArray * plPHOS, TClonesArray *){
+ TClonesArray * plPHOS,
+ TClonesArray * plPrimCTS,
+ TClonesArray * plPrimEMCAL,
+ TClonesArray * plPrimPHOS){
//Create a list of particles from the ESD. These particles have been measured
- //by the Central Tracking system (TPC+ITS), PHOS and EMCAL
+ //by the Central Tracking system (TPC+ITS+...), PHOS and EMCAL
+ //Also create particle list with mothers.
AliESDEvent* esd = (AliESDEvent*) data;
AliStack* stack = (AliStack*) kine;
Int_t npar = 0 ;
- Float_t *pid = new Float_t[AliPID::kSPECIESN];
+ Double_t *pid = new Double_t[AliPID::kSPECIESN];
AliDebug(3,"Fill particle lists");
//Get vertex for momentum calculation
Double_t v[3] ; //vertex ;
esd->GetVertex()->GetXYZ(v) ;
- //########### PHOS ##############
-
- Int_t begphos = esd->GetFirstPHOSCluster();
- Int_t endphos = esd->GetFirstPHOSCluster() +
- esd->GetNumberOfPHOSClusters() ;
+ //########### CALORIMETERS ##############
+ Int_t nCaloCluster = esd->GetNumberOfCaloClusters() ;
Int_t indexPH = plPHOS->GetEntries() ;
- AliDebug(3,Form("First PHOS particle %d, last particle %d", begphos,endphos));
+ Int_t indexEM = plEMCAL->GetEntries() ;
- for (npar = begphos; npar < endphos; npar++) {//////////////PHOS track loop
- AliESDCaloCluster * clus = esd->GetCaloCluster(npar) ; // retrieve track from esd
- if(clus->GetTrackMatched()==-1 ){
- //Create a TParticle to fill the particle list
- TLorentzVector momentum ;
- clus->GetMomentum(momentum, v);
- pid=clus->GetPid();
- Int_t pdg = 22;
-
- if(fPHOSPID){
- if( pid[AliPID::kPhoton] > fPHOSPhotonWeight) pdg=22;
- if( pid[AliPID::kPi0] > fPHOSPi0Weight) pdg=111;
- else pdg = 0 ;
- }
+ for (npar = 0; npar < nCaloCluster; npar++) {//////////////CaloCluster loop
+ AliESDCaloCluster * clus = esd->GetCaloCluster(npar) ; // retrieve cluster from esd
+ Int_t type = clus->GetClusterType();
+
+ //########### PHOS ##############
+ if(fSwitchOnPHOS && type == AliESDCaloCluster::kPHOSCluster){
+ AliDebug(4,Form("PHOS clusters: E %f, match %d", clus->E(),clus->GetTrackMatched()));
- TParticle * particle = new TParticle(pdg, 1, -1, -1, -1, -1,
- momentum.Px(), momentum.Py(), momentum.Pz(), momentum.E(), v[0], v[1], v[2], 0);
+ if(clus->GetTrackMatched()==-1){
+ TLorentzVector momentum ;
+ clus->GetMomentum(momentum, v);
+ Double_t phi = momentum.Phi();
+ if(phi<0) phi+=TMath::TwoPi() ;
+ if(momentum.Pt() > fNeutralPtCut && TMath::Abs(momentum.Eta()) < fPHOSEtaCut &&
+ phi > fPhiPHOSCut[0] && phi < fPhiPHOSCut[1] ) {
+
+ pid=clus->GetPid();
+ Int_t pdg = 22;
+
+ if(IsPHOSPIDOn()){
+ AliDebug(5,Form("E %1.2f; PID: ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f,pi %0.2f, k %0.2f, p %0.2f, k0 %0.2f, n %0.2f, mu %0.2f ",
+ momentum.E(),pid[AliPID::kPhoton],pid[AliPID::kPi0],pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
+ pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],pid[AliPID::kNeutron], pid[AliPID::kMuon]));
+
+ Float_t wPhoton = fPHOSPhotonWeight;
+ Float_t wPi0 = fPHOSPi0Weight;
+
+ if(fPHOSWeightFormula){
+ wPhoton = fPHOSPhotonWeightFormula->Eval(momentum.E()) ;
+ wPi0 = fPHOSPi0WeightFormula->Eval(momentum.E());
+ }
+
+ if(pid[AliPID::kPhoton] > wPhoton)
+ pdg = kPhoton ;
+ else if(pid[AliPID::kPi0] > wPi0)
+ pdg = kPi0 ;
+ else if(pid[AliPID::kElectron] > fPHOSElectronWeight)
+ pdg = kElectron ;
+ else if(pid[AliPID::kEleCon] > fPHOSElectronWeight)
+ pdg = kEleCon ;
+ else if(pid[AliPID::kPion]+pid[AliPID::kKaon]+pid[AliPID::kProton] > fPHOSChargeWeight)
+ pdg = kChargedHadron ;
+ else if(pid[AliPID::kKaon0]+pid[AliPID::kNeutron] > fPHOSNeutralWeight)
+ pdg = kNeutralHadron ;
+
+ else if(pid[AliPID::kElectron]+pid[AliPID::kEleCon]+pid[AliPID::kPion]+pid[AliPID::kKaon]+pid[AliPID::kProton] >
+ pid[AliPID::kPhoton] + pid[AliPID::kPi0]+pid[AliPID::kKaon0]+pid[AliPID::kNeutron])
+ pdg = kChargedUnknown ;
+ else
+ pdg = kNeutralUnknown ;
+ //neutral cluster, unidentifed.
+ }
+
+ if(pdg != kElectron && pdg != kEleCon && pdg !=kChargedHadron && pdg !=kChargedUnknown ){//keep only neutral particles in the array
- AliDebug(4,Form("PHOS clusters: pt %f, phi %f, eta %f", particle->Pt(),particle->Phi(),particle->Eta()));
-
- //Look if parent is prompt photon
- Int_t label = clus->GetLabel();
- if(label>=0){
- TParticle * pmother = stack->Particle(label);
- Int_t imother = pmother->GetFirstMother();
- if(imother == 6 || imother == 7)
- pmother->SetFirstMother(22);
- }
+ TParticle * particle = new TParticle(pdg, 1, -1, -1, -1, -1, momentum.Px(), momentum.Py(), momentum.Pz(), momentum.E(), v[0], v[1], v[2], 0);
+ new((*plPHOS)[indexPH]) TParticle(*particle) ;
+ AliDebug(4,Form("PHOS added: pdg %d, pt %f, phi %f, eta %f", pdg, particle->Pt(),particle->Phi(),particle->Eta()));
+
+ //###############
+ //Check kinematics
+ //###############
+ TParticle * pmother = new TParticle();
+ Int_t label = clus->GetLabel();
+ if(label < stack->GetNtrack())
+ pmother = GetMotherParticle(label,stack, "PHOS",momentum);
+ else
+ AliInfo(Form("PHOS: Bad label %d, too large, NPrimaries %d",label,stack->GetNtrack()));
+ new((*plPrimPHOS)[indexPH]) TParticle(*pmother) ;
+
+ indexPH++;
+ }
+ else AliDebug(4,Form("PHOS charged cluster NOT added: pdg %d, pt %f, phi %f, eta %f\n",
+ pdg, momentum.Pt(),momentum.Phi(),momentum.Eta()));
+
+ }//pt, eta, phi cut
+ else AliDebug(4,"Particle not added");
+ }//track-match?
+ }//PHOS cluster
+
+ //################ EMCAL ##############
+ else if(fSwitchOnEMCAL && type == AliESDCaloCluster::kEMCALClusterv1){
+ AliDebug(4,Form("EMCAL clusters: E %f, match %d", clus->E(),clus->GetTrackMatched()));
- new((*plPHOS)[indexPH++]) TParticle(*particle) ;
-
- }//not charged
+ if(clus->GetTrackMatched()==-1 ){
+ TLorentzVector momentum ;
+ clus->GetMomentum(momentum, v);
+ Double_t phi = momentum.Phi();
+ if(phi<0) phi+=TMath::TwoPi() ;
+ if(momentum.Pt() > fNeutralPtCut && TMath::Abs(momentum.Eta()) < fEMCALEtaCut &&
+ phi > fPhiEMCALCut[0] && phi < fPhiEMCALCut[1] ) {
+
+ pid=clus->GetPid();
+ Int_t pdg = 22;
+
+ if(IsEMCALPIDOn()){
+ AliDebug(5,Form("E %1.2f; PID: ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f,pi %0.2f, k %0.2f, p %0.2f, k0 %0.2f, n %0.2f, mu %0.2f ",
+ momentum.E(),pid[AliPID::kPhoton],pid[AliPID::kPi0],pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
+ pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],pid[AliPID::kNeutron], pid[AliPID::kMuon]));
+
+ if(pid[AliPID::kPhoton] > fEMCALPhotonWeight)
+ pdg = kPhoton ;
+ else if(pid[AliPID::kPi0] > fEMCALPi0Weight)
+ pdg = kPi0 ;
+ else if(pid[AliPID::kElectron] > fEMCALElectronWeight)
+ pdg = kElectron ;
+ else if(pid[AliPID::kEleCon] > fEMCALElectronWeight)
+ pdg = kEleCon ;
+ else if(pid[AliPID::kPion]+pid[AliPID::kKaon]+pid[AliPID::kProton] > fEMCALChargeWeight)
+ pdg = kChargedHadron ;
+ else if(pid[AliPID::kKaon0]+pid[AliPID::kNeutron] > fEMCALNeutralWeight)
+ pdg = kNeutralHadron ;
+ else if(pid[AliPID::kElectron]+pid[AliPID::kEleCon]+pid[AliPID::kPion]+pid[AliPID::kKaon]+pid[AliPID::kProton] >
+ pid[AliPID::kPhoton] + pid[AliPID::kPi0]+pid[AliPID::kKaon0]+pid[AliPID::kNeutron])
+ pdg = kChargedUnknown ;
+ else
+ pdg = kNeutralUnknown ;
+ }
+
+ if(pdg != kElectron && pdg != kEleCon && pdg !=kChargedHadron && pdg !=kChargedUnknown){//keep only neutral particles in the array
+
+ TParticle * particle = new TParticle(pdg, 1, -1, -1, -1, -1, momentum.Px(), momentum.Py(), momentum.Pz(), momentum.E(), v[0], v[1], v[2], 0);
+ new((*plEMCAL)[indexEM]) TParticle(*particle) ;
+ AliDebug(4,Form("EMCAL cluster added: pdg %f, pt %f, phi %f, eta %f", pdg, particle->Pt(),particle->Phi(),particle->Eta()));
+
+ //###############
+ //Check kinematics
+ //###############
+ TParticle * pmother = new TParticle();
+ Int_t label = clus->GetLabel();
+ if(label < stack->GetNtrack())
+ pmother = GetMotherParticle(label,stack, "EMCAL",momentum);
+ else
+ AliInfo(Form("EMCAL: Bad label %d, too large, NPrimaries %d",label,stack->GetNtrack()));
+ new((*plPrimEMCAL)[indexEM]) TParticle(*pmother) ;
+
+ indexEM++;
+ }
+ else AliDebug(4,Form("EMCAL charged cluster NOT added: pdg %d, pt %f, phi %f, eta %f",
+ pdg, momentum.Pt(),momentum.Phi(),momentum.Eta()));
+
+ }//pt, phi, eta cut
+ else AliDebug(4,"Particle not added");
+ }//track-matched
+ }//EMCAL cluster
+
}//cluster loop
+
+
//########### CTS (TPC+ITS) #####################
- Int_t begtpc = 0 ;
- Int_t endtpc = esd->GetNumberOfTracks() ;
+ Int_t nTracks = esd->GetNumberOfTracks() ;
Int_t indexCh = plCTS->GetEntries() ;
- AliDebug(3,Form("First CTS particle %d, last particle %d", begtpc,endtpc));
-
- for (npar = begtpc; npar < endtpc; npar++) {////////////// track loop
- AliESDtrack * track = esd->GetTrack(npar) ; // retrieve track from esd
-
- //We want tracks fitted in the detectors:
- ULong_t status=AliESDtrack::kTPCrefit;
- status|=AliESDtrack::kITSrefit;
-
- //We want tracks whose PID bit is set:
- // ULong_t status =AliESDtrack::kITSpid;
- // status|=AliESDtrack::kTPCpid;
-
- if ( (track->GetStatus() & status) == status) {//Check if the bits we want are set
- // Do something with the tracks which were successfully
- // re-fitted
- Double_t en = 0; //track ->GetTPCsignal() ;
- Double_t mom[3];
- track->GetPxPyPz(mom) ;
- Double_t px = mom[0];
- Double_t py = mom[1];
- Double_t pz = mom[2]; //Check with TPC people if this is correct.
- Int_t pdg = 11; //Give any charged PDG code, in this case electron.
- //I just want to tag the particle as charged
- TParticle * particle = new TParticle(pdg, 1, -1, -1, -1, -1,
- px, py, pz, en, v[0], v[1], v[2], 0);
-
- //TParticle * particle = new TParticle() ;
- //particle->SetMomentum(px,py,pz,en) ;
-
- new((*plCTS)[indexCh++]) TParticle(*particle) ;
- }
- }
-
- //################ EMCAL ##############
-
- Int_t indexEM = plEMCAL->GetEntries() ;
- Int_t begem = esd->GetFirstEMCALCluster();
- Int_t endem = esd->GetFirstEMCALCluster() +
- esd->GetNumberOfEMCALClusters() ;
-
- AliDebug(3,Form("First EMCAL particle %d, last particle %d",begem,endem));
+
+ if(fSwitchOnCTS){
+ AliDebug(3,Form("Number of tracks %d",nTracks));
- for (npar = begem; npar < endem; npar++) {//////////////EMCAL track loop
- AliESDCaloCluster * clus = esd->GetCaloCluster(npar) ; // retrieve track from esd
- Int_t clustertype= clus->GetClusterType();
- if(clustertype == AliESDCaloCluster::kClusterv1 && clus->GetTrackMatched()==-1 ){
+ for (npar = 0; npar < nTracks; npar++) {////////////// track loop
+ AliESDtrack * track = esd->GetTrack(npar) ; // retrieve track from esd
- TLorentzVector momentum ;
- clus->GetMomentum(momentum, v);
- pid=clus->GetPid();
- Int_t pdg = 22;
-
- if(fEMCALPID){
- if( pid[AliPID::kPhoton] > fEMCALPhotonWeight) pdg=22;
- else if( pid[AliPID::kPi0] > fEMCALPi0Weight) pdg=111;
- else pdg = 0;
- }
-
- TParticle * particle = new TParticle(pdg, 1, -1, -1, -1, -1,
- momentum.Px(), momentum.Py(), momentum.Pz(), momentum.E(), v[0], v[1], v[2], 0);
- AliDebug(4,Form("EMCAL clusters: pt %f, phi %f, eta %f", particle->Pt(),particle->Phi(),particle->Eta()));
-
- //Look if parent is prompt photon
- Int_t label = clus->GetLabel();
- if(label>=0){
- TParticle * pmother = stack->Particle(label);
- Int_t imother = pmother->GetFirstMother();
- if(imother == 6 || imother == 7)
- pmother->SetFirstMother(22);
- }
-
- new((*plEMCAL)[indexEM++]) TParticle(*particle) ;
+ //We want tracks fitted in the detectors:
+ ULong_t status=AliESDtrack::kTPCrefit;
+ status|=AliESDtrack::kITSrefit;
+
+ //We want tracks whose PID bit is set:
+ // ULong_t status =AliESDtrack::kITSpid;
+ // status|=AliESDtrack::kTPCpid;
- }//not charged, not pseudocluster
- }//Cluster loop
-
- AliDebug(3,"Particle lists filled");
-
+ if ( (track->GetStatus() & status) == status) {//Check if the bits we want are set
+ // Do something with the tracks which were successfully
+ // re-fitted
+ Double_t en = 0; //track ->GetTPCsignal() ;
+ Double_t mom[3];
+ track->GetPxPyPz(mom) ;
+ Double_t px = mom[0];
+ Double_t py = mom[1];
+ Double_t pz = mom[2]; //Check with TPC people if this is correct.
+ Int_t pdg = 11; //Give any charged PDG code, in this case electron.
+ //I just want to tag the particle as charged
+
+ //Check kinematics
+ Int_t label = TMath::Abs(track->GetLabel());
+ TParticle * pmother = new TParticle();
+ pmother = stack->Particle(label);
+
+ TParticle * particle = new TParticle(pdg, 1, -1, -1, -1, -1,
+ px, py, pz, en, v[0], v[1], v[2], 0);
+
+ if(particle->Pt() > fChargedPtCut && TMath::Abs(particle->Eta())<fCTSEtaCut){
+ new((*plCTS)[indexCh]) TParticle(*particle) ;
+ new((*plPrimCTS)[indexCh]) TParticle(*pmother) ;
+ indexCh++;
+
+ }//kinematic selection
+ }//select track from refit
+ }//track loop
+ }//CTS
+
+ AliDebug(3,Form("Particle lists filled, tracks %d , clusters: EMCAL %d, PHOS %d", indexCh,indexEM,indexPH));
+
}
- //____________________________________________________________________________
-void AliGammaMCDataReader::InitParameters()
+TParticle * AliGammaMCDataReader:: GetMotherParticle(Int_t label, AliStack *stack, TString calo, TLorentzVector momentum)
{
-
- //Initialize the parameters of the analysis.
+ //Gets the primary particle and do some checks:
+ //Check if primary is inside calorimeter and look the mother outsie
+ //Check if mother is a decay photon, in which case check if decay was overlapped
+
+ Float_t minangle = 0;
+ Float_t ipdist = 0;
+ TParticle * pmother = new TParticle();
- //Fill particle lists when PID is ok
- fEMCALPID = kFALSE;
- fPHOSPID = kFALSE;
- fEMCALPhotonWeight = 0.5 ;
- fEMCALPi0Weight = 0.5 ;
- fPHOSPhotonWeight = 0.8 ;
- fPHOSPi0Weight = 0.5 ;
+ if(calo == "PHOS"){
+ ipdist= fPHOSIPDistance;
+ minangle = fPHOSMinAngle;
+ }
+ else if (calo == "EMCAL"){
+ ipdist = fEMCALIPDistance;
+ minangle = fEMCALMinAngle;
+ }
-}
+ if(label>=0){
+ pmother = stack->Particle(label);
+ Int_t mostatus = pmother->GetStatusCode();
+ Int_t mopdg = TMath::Abs(pmother->GetPdgCode());
+
+ //Check if mother is a conversion inside the calorimeter
+ //In such case, return the mother before the calorimeter.
+ //First approximation.
+ Float_t vy = TMath::Abs(pmother->Vy()) ;
-void AliGammaMCDataReader::Print(const Option_t * opt) const
-{
+ if( mostatus == 0 && vy >= ipdist){
- //Print some relevant parameters set for the analysis
- if(! opt)
- return;
-
- Info("Print", "%s %s", GetName(), GetTitle() ) ;
- printf("PHOS PID on? = %d\n", fPHOSPID) ;
- printf("EMCAL PID on? = %d\n", fEMCALPID) ;
- printf("PHOS PID weight , photon %f, pi0 %f\n\n", fPHOSPhotonWeight, fPHOSPi0Weight) ;
- printf("EMCAL PID weight, photon %f, pi0 %f\n", fEMCALPhotonWeight, fEMCALPi0Weight) ;
+ //cout<<"Calo: "<<calo<<" vy "<<vy<<" E clus "<<momentum.E()<<" Emother "<<pmother->Energy()<<" "
+ // <<pmother->GetName()<<endl;
+
+ while( vy >= ipdist){//inside calorimeter
+ AliDebug(4,Form("Conversion inside calorimeter, mother vertex %0.2f, IP distance %0.2f", vy, ipdist));
+ pmother = stack->Particle(pmother->GetMother(0));
+ vy = TMath::Abs(pmother->Vy()) ;
+ //cout<<" label "<<label<<" Mother: "<<pmother->GetName()<<" E "<<pmother->Energy()<<" Status "<<pmother->GetStatusCode()<<" and vertex "<<vy<<endl;
+ mostatus = pmother->GetStatusCode();
+ mopdg = TMath::Abs(pmother->GetPdgCode());
+ }//while vertex is inside calorimeter
+ //cout<<"Calo: "<<calo<<" final vy "<<vy<<" E clus "<<momentum.E()<<" Emother "<<pmother->Energy()<<" "
+ // <<pmother->GetName()<<endl;
+ }//check status and vertex
+
+ AliDebug(4,Form("%s, ESD E %2.2f, PID %d, mother: E %2.2f, label %d, status %d, vertex %3.2f, mother 2 %d, grandmother %d \n",
+ calo.Data(),momentum.E(),pmother->Energy(), label, pmother->GetPdgCode(),
+ pmother->GetStatusCode(), vy, pmother->GetMother(0), stack->GetPrimary(label)));
+
+ //Check Decay photons
+ if(mopdg == 22){
+
+ //his mother was a pi0?
+ TParticle * pmotherpi0 = stack->Particle(pmother->GetMother(0));
+ if( pmotherpi0->GetPdgCode() == 111){
+
+ AliDebug(4,Form(" %s: E cluster %2.2f, E gamma %2.2f, Mother Pi0, E %0.2f, status %d, daughters %d\n",
+ calo.Data(), momentum.E(),pmother->Energy(),pmotherpi0->Energy(),
+ pmotherpi0->GetStatusCode(), pmotherpi0->GetNDaughters()));
+
+ if(pmotherpi0->GetNDaughters() == 1) mostatus = 2 ; //signal that this photon can only be decay, not overlapped.
+ else if(pmotherpi0->GetNDaughters() == 2){
+
+ TParticle * pd1 = stack->Particle(pmotherpi0->GetDaughter(0));
+ TParticle * pd2 = stack->Particle(pmotherpi0->GetDaughter(1));
+ //if(pmotherpi0->Energy()> 10 ){
+// cout<<"Two "<<calo<<" daugthers, pi0 label "<<pmother->GetMother(0)<<" E :"<<pmotherpi0->Energy()<<endl;
+// cout<<" 1) label "<<pmotherpi0->GetDaughter(0)<<" pdg "<<pd1->GetPdgCode()<<" E "<<pd1->Energy()
+// <<" phi "<<pd1->Phi()*TMath::RadToDeg()<<" eta "<<pd1->Eta()
+// <<" mother label "<<pd1->GetMother(0)<<" n daug "<<pd1->GetNDaughters() <<endl;
+// cout<<" 2) label "<<pmotherpi0->GetDaughter(1)<<" pdg "<<pd2->GetPdgCode()<<" E "<<pd2->Energy()
+// <<" phi "<<pd2->Phi()*TMath::RadToDeg()<<" eta "<<pd2->Eta()<<" mother label "
+// <<pd2->GetMother(0)<<" n daug "<<pd2->GetNDaughters() <<endl;
+ //}
+ if(pd1->GetPdgCode() == 22 && pd2->GetPdgCode() == 22){
+ TLorentzVector lv1 , lv2 ;
+ pd1->Momentum(lv1);
+ pd2->Momentum(lv2);
+ Double_t angle = lv1.Angle(lv2.Vect());
+// if(pmotherpi0->Energy()> 10 )
+// cout<<"angle*ipdist "<<angle*ipdist<<" mindist "<< minangle <<endl;
+ if (angle < minangle){
+ //There is overlapping, pass the pi0 as mother
+
+ AliDebug(4,Form(">>>> %s cluster with E %2.2f is a overlapped pi0, E %2.2f, angle %2.4f < anglemin %2.4f\n",
+ calo.Data(), momentum.E(), pmotherpi0->Energy(), angle, minangle));
+
+ pmother = pmotherpi0 ;
+
+ }
+ else mostatus = 2 ; // gamma decay not overlapped
+ }// daughters are photons
+ else mostatus = 2; // daughters are e-gamma or e-e, no overlapped, or charged cluster
+ }//2 daughters
+ else AliDebug(4,Form("pi0 has %d daughters",pmotherpi0->GetNDaughters()));
+ }//pi0 decay photon?
+ }//photon
+
+ pmother->SetStatusCode(mostatus); // if status = 2, decay photon.
+
+ }//label >=0
+ else AliInfo(Form("Negative Kinematic label of PHOS cluster: %d",label));
+
+ return pmother ;
}