#include "AliHBTReaderInternal.h"
+//_________________________________________________________________________
+///////////////////////////////////////////////////////////////////////////
+// //
+// class AliHBTReaderInternal //
+// //
+// Multi file reader for Internal Data Format //
+// //
+// This reader reads data created by itself //
+// (method AliHBTReaderInternal::Write) //
+// Data are stored in form of tree of TClonesArray of AliHBTParticle's //
+// //
+// Piotr.Skowronski@cern.ch //
+// more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html //
+// //
+///////////////////////////////////////////////////////////////////////////
#include <TTree.h>
#include <TFile.h>
fPartBranch(0x0),
fTrackBranch(0x0),
fTree(0x0),
- fFile(0x0)
+ fFile(0x0),
+ fPartBuffer(0x0),
+ fTrackBuffer(0x0)
{
//Defalut constructor
}
fPartBranch(0x0),
fTrackBranch(0x0),
fTree(0x0),
- fFile(0x0)
+ fFile(0x0),
+ fPartBuffer(0x0),
+ fTrackBuffer(0x0)
{
//constructor
//filename - name of file to open
fPartBranch(0x0),
fTrackBranch(0x0),
fTree(0x0),
- fFile(0x0)
+ fFile(0x0),
+ fPartBuffer(0x0),
+ fTrackBuffer(0x0)
{
//ctor
//dirs contains strings with directories to look data in
counter = 0;
if (fPartBranch && fTrackBranch)
- {
+ {
+ Info("ReadNext","Found %d tracks in total.",fTrackBuffer->GetEntries());
+ Info("ReadNext","Found %d particles in total.",fPartBuffer->GetEntries());
for(i = 0; i < fPartBuffer->GetEntries(); i++)
{
tpart = dynamic_cast<AliHBTParticle*>(fPartBuffer->At(i));
ttrack = dynamic_cast<AliHBTParticle*>(fTrackBuffer->At(i));
if( tpart == 0x0 ) continue; //if returned pointer is NULL
-
+ if( ttrack == 0x0 ) continue; //if returned pointer is NULL
+
+ if (AliHBTParticle::GetDebug() > 9)
+ {
+ Info("ReadNext","Particle:");
+ tpart->Print();
+ Info("ReadNext","Track:");
+ ttrack->Print();
+ }
if (ttrack->GetUID() != tpart->GetUID())
{
Error("ReadNext","Sth. is wrong: Track and Particle has different UID.");
Error("ReadNext","They probobly do not correspond to each other.");
}
-
- for (Int_t s = 0; s < tpart->GetNumberOfPids(); s++)
+
+ for (Int_t s = 0; s < ttrack->GetNumberOfPids(); s++)
{
- if( pdgdb->GetParticle(tpart->GetNthPid(s)) == 0x0 ) continue; //if particle has crazy PDG code (not known to our database)
- if( Pass(tpart->GetNthPid(s)) ) continue; //check if we are intersted with particles of this type
- //if not take next partilce
- AliHBTParticle* part = new AliHBTParticle(*tpart);
- part->SetPdgCode(tpart->GetNthPid(s),tpart->GetNthPidProb(s));
- if( Pass(part) )
+ //check if we are intersted with particles of this type
+ //if not take next partilce
+ if( Pass(ttrack->GetNthPid(s)) )
+ {
+ if (AliHBTParticle::GetDebug() > 9)
+ Info("ReadNext","Track Incarnation %d did not pass PID cut.",ttrack->GetNthPid(s));
+ continue;
+ }
+ TParticlePDG* pdgp = pdgdb->GetParticle(ttrack->GetNthPid(s));
+ if (pdgp == 0x0)//PDG part corresponding to new incarnation
+ {
+ Error("ReadNext","Particle code unknown to PDG DB.");
+ continue;
+ }
+
+ AliHBTParticle* track = new AliHBTParticle(*ttrack);
+
+ //apart of setting PDG code of an incarnation
+ //it is necessary tu recalculate energy on the basis of
+ //new PDG code (mass) hypothesis
+ Double_t mass = pdgp->Mass();//mass of new incarnation
+ Double_t tEtot = TMath::Sqrt( ttrack->Px()*ttrack->Px() +
+ ttrack->Py()*ttrack->Py() +
+ ttrack->Pz()*ttrack->Pz() +
+ mass*mass);//total energy of the new incarnation
+ //update Energy and Calc Mass
+ track->SetMomentum(ttrack->Px(),ttrack->Py(),ttrack->Pz(),tEtot);
+ track->SetCalcMass(mass);
+ track->SetPdgCode(ttrack->GetNthPid(s),ttrack->GetNthPidProb(s));
+
+ if( Pass(track) )
{
- delete part;
+ if (AliHBTParticle::GetDebug() > 9)
+ Info("ReadNext","Track Incarnation %d did not pass cut.",ttrack->GetNthPid(s));
+ delete track;
continue;
}
- AliHBTParticle* track = new AliHBTParticle(*ttrack);
+ AliHBTParticle* part = new AliHBTParticle(*tpart);//particle has only 1 incarnation (real)
fParticlesEvent->AddParticle(part);
fTracksEvent->AddParticle(track);
{
if( pdgdb->GetParticle(tpart->GetNthPid(s)) == 0x0 ) continue; //if particle has crazy PDG code (not known to our database)
if( Pass(tpart->GetNthPid(s)) ) continue; //check if we are intersted with particles of this type
-
AliHBTParticle* part = new AliHBTParticle(*tpart);
part->SetPdgCode(tpart->GetNthPid(s),tpart->GetNthPidProb(s));
if( Pass(part) )
if (fTrackBranch)
{
+ Info("ReadNext","Found %d tracks in total.",fTrackBuffer->GetEntries());
for(i = 0; i < fTrackBuffer->GetEntries(); i++)
{
- tpart = dynamic_cast<AliHBTParticle*>(fTrackBuffer->At(i));
- if(tpart == 0x0) continue; //if returned pointer is NULL
- for (Int_t s = 0; s < tpart->GetNumberOfPids(); s++)
- {
- if( pdgdb->GetParticle(tpart->GetNthPid(s)) == 0x0 ) continue; //if particle has crazy PDG code (not known to our database)
- if( Pass(tpart->GetNthPid(s)) ) continue; //check if we are intersted with particles of this type
+ ttrack = dynamic_cast<AliHBTParticle*>(fTrackBuffer->At(i));
+ if( ttrack == 0x0 ) continue; //if returned pointer is NULL
- AliHBTParticle* part = new AliHBTParticle(*tpart);
- part->SetPdgCode(tpart->GetNthPid(s),tpart->GetNthPidProb(s));
- if( Pass(part) )
+ for (Int_t s = 0; s < ttrack->GetNumberOfPids(); s++)
+ {
+ if( Pass(ttrack->GetNthPid(s)) ) continue; //check if we are intersted with particles of this type
+ //if not take next partilce
+ TParticlePDG* pdgp = pdgdb->GetParticle(ttrack->GetNthPid(s));
+ if (pdgp == 0x0)//PDG part corresponding to new incarnation
+ {
+ Error("ReadNext","Particle code unknown to PDG DB.");
+ continue;
+ }
+ AliHBTParticle* track = new AliHBTParticle(*ttrack);
+
+ //apart of setting PDG code of an incarnation
+ //it is necessary tu recalculate energy on the basis of
+ //new PDG code (mass) hypothesis
+ Double_t mass = pdgp->Mass();//mass of new incarnation
+ Double_t tEtot = TMath::Sqrt( ttrack->Px()*ttrack->Px() +
+ ttrack->Py()*ttrack->Py() +
+ ttrack->Pz()*ttrack->Pz() +
+ mass*mass);//total energy of the new incarnation
+ //update Energy and Calc Mass
+ track->SetMomentum(ttrack->Px(),ttrack->Py(),ttrack->Pz(),tEtot);
+ track->SetCalcMass(mass);
+ track->SetPdgCode(ttrack->GetNthPid(s),ttrack->GetNthPidProb(s));
+
+ if( Pass(track) )
{
- delete part;
+ delete track;
continue;
}
- fTracksEvent->AddParticle(part);
+ fTracksEvent->AddParticle(track);
+
counter++;
}
}
}
else Info("ReadNext"," Read: 0 tracks.");
}
- fPartBuffer->Delete();
- fTrackBuffer->Delete();
+
+ if (fPartBuffer) fPartBuffer->Delete();
+ if (fTrackBuffer) fTrackBuffer->Delete();
fCurrentEvent++;
fNEventsRead++;
Info("OpenNextFile","________________________________________________________");
Info("OpenNextFile","Found %d event(s) in directory %s",
- (Int_t)fTree->GetEntries(),GetDirName(fCurrentEvent).Data());
+ (Int_t)fTree->GetEntries(),GetDirName(fCurrentDir).Data());
fCurrentEvent = 0;