Figure 1.: Use Case for reconstruction. Only PHOS is implemented. Other detectors are ignored. Click on image for full scale
Int_t ievent;
Int_t nevents = 10;
AliPHOSAnalyze reconstruction("galice.root");
for(ievent=0; i nevents; ievent++) {
reconstruction.AnalyzeOneEvent(ievent);
}
{
// Opening root file with reconstructed events
TFile * in = new TFile("galice.root");
// Getting gAlice
gAlice = (AliRun*) in->Get("gAlice");
// Getting PHOS Detector, Geometry and Indexig
AliPHOSv1 * fPHOS = (AliPHOSv1 *)gAlice->GetDetector("PHOS") ;
AliPHOSGeometry * fGeom = AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() );
AliPHOSIndexToObject * fObjGetter = AliPHOSIndexToObject::GetInstance(fPHOS) ;
// Clones Array of tracksegments and particles
TObjArray * EmcRPList = new TObjArray(1000);
TObjArray * PpsdRPList = new TObjArray(1000);
TClonesArray * ParticleList = new TClonesArray("AliPHOSRecParticle", 1000) ;
TClonesArray * TrackSegmentList = new TClonesArray("AliPHOSTrackSegment", 1000) ;
TClonesArray * ArrayOfParticles = gAlice->Particles();
// Getting Event
Int_t ievent = 8;
Int_t nprimaryparticles = gAlice->GetEvent(ievent); // Getting the physics event
cout << "FinalAnalysis >>> Event #" << ievent << " with " << nprimaryparticles << " primary particles." << endl;
// Getting Reconstrcuted Tree and Brach with TrackSegments and Reconstructed Particles
TTree * Rec = gAlice->TreeR();
TTree * TK = gAlice->TreeK();
TTree * TD = gAlice->TreeD();
TBranch * RecBranch = Rec->GetBranch("PHOSRP");
TBranch * TraBranch = Rec->GetBranch("PHOSTS");
TBranch * EmcBranch = Rec->GetBranch("PHOSEmcRP");
TBranch * PpsdBranch = Rec->GetBranch("PHOSPpsdRP");
EmcBranch-> SetAddress(&EmcRPList);
PpsdBranch->SetAddress(&PpsdRPList);
TraBranch-> SetAddress(&TrackSegmentList);
RecBranch-> SetAddress(&ParticleList);
TD->GetEvent(0); //This tree only contains one tree-event with the List of Digits of the physicis event.
TK->GetEvent(0); // This tree only contains one tree-event with the List of TParticles of the physicis event.
Int_t nbits = Rec->GetEvent(0); // This tree only contains one tree-event with the List of Reconstructed Objects (AliPHOSEmcRecPoint, AliPHOSPpsdRecPoint, AliPHOSTrackSegment and AliPHOSParticle)
cout << "FinalAnalysis >>> " << nbits << " bits in reconstructed tree envent 0." << endl;
Int_t nparticles = ParticleList.GetEntries();
Int_t iparticle;
cout << "FinalAnalysis>>> Reconstructed particle list entries is " << nparticles <At(iparticle);
AliPHOSTrackSegment * ts = TrackSegmentList->At(rp->GetPHOSTrackSegmentIndex()); // TrackSegmentList->At(iparticle);
AliPHOSEmcRecPoint * emc = EmcRPList->At(ts->GetEmcRecPointIndex());
TVector3 locpos;
emc->GetLocalPosition(locpos) ;
Int_t * primaries;
Int_t nprimaries;
Text_t particle[11];
primaries = (emc->GetPrimaries(nprimaries));
switch(rp->GetType())
{
case 0:
strcpy( particle, "NEUTRAL_EM");
break;
case 1:
strcpy(particle, "NEUTRAL_HA");
break;
case 2:
strcpy(particle, "GAMMA");
break ;
case 3:
strcpy(particle, "GAMMA_H");
break ;
case 4:
strcpy(particle, "ABSURD_EM") ;
break ;
case 5:
strcpy(particle, "ABSURD_HA") ;
break ;
case 6:
strcpy(particle, "ELECTRON") ;
break ;
case 7:
strcpy(particle, "CHARGED_HA") ;
break ;
}
cout << "FinalAnalysis>>> Partilce is " << particle << " and energy is " << rp->Energy() << " GeV" << endl ;
cout << "FinalAnalysis>>> Index in list is " << rp->GetIndexInList() << " " << endl ;
cout << "FinalAnalysis>>> Position is: X="<>> Primaries are : " << primaries[0] << " " << primaries[1] << " " << primaries[2] << " " << primaries[3] << " " << endl;
Int_t nprimaryparticle = ArrayOfParticles->GetEntriesFast();
printf("FinalAnalysis >>> nprimaryparticle is %d \n",nprimaryparticle);
Particle = (TParticle*)ArrayOfParticles->UncheckedAt(primaries[0]);
Int_t iPDGCode = Particle->GetPdgCode();
cout << "FinalAnalysis >>> PDGCode of primary is " << iPDGCode << endl;
}
}
AliPHOSAnalyze reconstruction("galice.root");
reconstruction.AnalyzeResolution(nevent);
AliPHOSAnalyze reconstruction("galice.root");
reconstruction.ReadAndPrintCPV(eventLast,eventFirst);
AliPHOSAnalyze reconstruction("galice.root");
reconstruction.AnalyzeCPV(nevent);
The reconstructed points are contained in two TObjArray (mandatory because the size of a reconstructed point depends on the number of digits used to build it) which are stored in TreeR, branch PHOSEmcRP for EMCA and branch PHOSPpsdRP for PPSD.
The track segments are contained in a TClonesArray which are stored in TreeR, branch PHOSTS.
| NEUTRAL_EM: | a reconstructed point in EMCA, none in the two layers of the PPSD, and narrow lateral development; |
| NEUTRAL_HA : | a reconstructed point in EMCA, none in the two layers of the PPSD, and wide lateral development; |
| GAMMA : | a reconstructed point in EMCA, none in the first layer CPV, one in the second layer PC, narrow lateral development; |
| GAMMA_H: | a reconstructed point in EMCA, none in the first layer CPV, one in the second layer PC, wide lateral development; |
| ABSURD_EM: | a reconstructed point in EMCA, one in the first layer CPV, none in the second layer PC, narrow lateral development; |
| ABSURD_HA: | a reconstructed point in EMCA, one in the first layer CPV, none in the second layer PC, wide lateral development; |
| ELECTRON: | a reconstructed point in EMCA, one in both layers of the PPSD, and narrow lateral development; |
| CHARGED_HA : | a reconstructed point in EMCA, one in both layers of the PPSD, and wide lateral development; |
root [2] TFile myfile("junk.root")
root [3] TTree * reconstructedtree = (TTree *)myfile.Get("TreeR0")
root [5] reconstructedtree.Print()
******************************************************************************
*Tree :TreeR0 : Reconstruction *
*Entries : 1 : Total Size = 10882 bytes File Size = 4024 *
* : : Tree compression factor = 5.65 *
******************************************************************************
*Branch :PHOSEmcRP : PHOSEmcRP *
*Entries : 1 : Total Size = 0 bytes File Size = 0 *
*Baskets : 0 : Basket Size = 16000 bytes Compression= 1.00 *
*............................................................................*
*Branch :PHOSPpsdRP : PHOSPpsdRP *
*Entries : 1 : Total Size = 8334 bytes File Size = 1476 *
*Baskets : 1 : Basket Size = 16000 bytes Compression= 5.65 *
*............................................................................*
*Branch :PHOSTS : PHOSTS *
*Entries : 1 : Total Size = 0 bytes File Size = 0 *
*Baskets : 0 : Basket Size = 16000 bytes Compression= 1.00 *
*............................................................................*
*Branch :PHOSRP : PHOSRP *
*Entries : 1 : Total Size = 0 bytes File Size = 0 *
*Entries : 1 : Total Size = 0 bytes File Size = 0 *
*Baskets : 0 : Basket Size = 16000 bytes Compression= 1.00 *
*............................................................................*
root [6]
Figure 2: Branches in TreeR generated by the PHOS reconstruction. PHOSEmc(Ppsd)RP contains EMCA(PPSD) reconstructed points in TObjArray; PHOSTS contains track segments in a TClonesArray; PHOSRP contains reconstructed particles in a TClonesArray.
AliPHOS * phos = (AliPHOSv1 *)gAlice->GetDetector("PHOS") ;
AliPHOSIndexToObject::GetInstance(phos) ;
It can then be used as follow, for example for retrieving a particle from the kine tree (TreeK):
AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
Int_t index = 123 ;
TParticle * primaryparticle = please->GimePrimaryParticle(index) ;
We shall now detail how the various reconstruction objects are linked together.
// initialization
// open root file
TFile rootfile("junk.root") ;
// get AliRun object
gAlice = (AliRun *)rootfile.Get("gAlice") ;
// get detector object
AliPHOSv1 * phos = (AliPHOSv1 *)gAlice->GetDetector("PHOS") ;
// get the geometry associated with the detector
AliPHOSGeometry::GetInstance( phos->GetGeometry()->GetName(), phos->GetGeometry()->GetTitle() ) ;
// initializes the index to object converter
AliPHOSIndexToObject::GetInstance(phos) ;
// get the list of digits
TClonesArray * digitslist = phos->Digits() ;
// loop over the list of digits
TIter nextdigit(digitslist) ;
AliPHOSDigit * digit ;
TParticle * primaryparticle[3] ;
// get the pointer of the index to object converter
AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
while ( digit = (AliPHOSDigit * )nextdigit() ) {
for ( Int_t i = 0 ; i < digit->GetNprimary() ; i++ )
primary[i] = please->GimePrimaryParticle(digit->GetPrimary(i) ) ;
}
// initialization
// open root file
TFile rootfile("junk.root") ;
// get AliRun object
gAlice = (AliRun *)rootfile.Get("gAlice") ;
// get detector object
AliPHOSv1 * phos = (AliPHOSv1 *)gAlice->GetDetector("PHOS") ;
// get the geometry associated with the detector
AliPHOSGeometry::GetInstance( phos->GetGeometry()->GetName(), phos->GetGeometry()->GetTitle() ) ;
// initializes the index to object converter
AliPHOSIndexToObject::GetInstance(phos) ;
// get the reconstructed points list
Int_t evt = 123 ;
TObjArray * recpointslist = phos->EmcRecPoints(evt) ;
// loop over reconstructed points
TIter nextrecpoint(recpointslist) ;
// get the pointer of the index to object converter
AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
AliPHOSEmcRecPoint * recpoint ;
while ( recpoint = (AliPHOSEmcRecPoint * )nextrecpoint() ) {
// get the associated digits list
Int_t * digitsindexeslist = recpoint->GetDigitsList() ;
// loop over the list of digits
for ( Int_t i = 0 ; i < recpoint->GetDigitsMultiplicity() ; i++ ) {
AliPHOSDigit * digit = please->GimeDigit(digitsindexeslist[i] ) ;
// get the primary particle associated with that digit
Int_t numberofprimaries = 0 ;
Int_t * prim = digit->GetPrimaries(numberofprimaries) ;
for (Int_t i = 0 ; i < numberofprimaries ; i++ )
// and print them
please->GimePrimaryParticle( prim[i] )->Print() ;
}
}
// or get the primaries directly from the reconstructed point
Int_t numberofprimaries = 0 ;
Int_t * prim = recpoint->GetPrimaries(numberofprimaries) ;
}
// initialization
// open root file
TFile rootfile("junk.root") ;
// get AliRun object
gAlice = (AliRun *)rootfile.Get("gAlice") ;
// get detector object
AliPHOSv1 * phos = (AliPHOSv1 *)gAlice->GetDetector("PHOS") ;
// get the geometry associated with the detector
AliPHOSGeometry::GetInstance( phos->GetGeometry()->GetName(), phos->GetGeometry()->GetTitle() ) ;
// initializes the index to object converter
AliPHOSIndexToObject::GetInstance(phos) ;
// get the track segments list
Int_t evt = 123 ;
TClonesArray * tracksegmentslist = phos->TrackSegments(evt) ;
// loop over track segments
TIter nexttracksegment(tracksegmentslist) ;
AliPHOSTrackSegment * tracksegment ;
// get the pointer of the index to object converter
AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
while ( tracksegment = (AliPHOSTrackSegment * )nexttracksegment() ) {
// get the associated reconstructed points
AliPHOSEmcRecPoint * emcrecpoint = please->GimeRecPoint(tracksegment->GetEmcRecPoint(), "emc" ) ;
AliPHOSPpsdRecPoint * ppsduprecpoint = please->GimeRecPoint(tracksegment->GetPpsdUpRecPoint(), "ppsd" ) ;
AliPHOSPpsdRecPoint * ppsdlowrecpoint = please->GimeRecPoint(tracksegment->GetPpsdLowRecPoint(),"ppsd" ) ;
// get the primaries particles
Int_t numberofprimariestoemc = 0 ;
Int_t * primemc = tracksegment->GetPrimariesEmc(numberofprimariestoemc) ;
Int_t numberofprimariestoppsdup = 0 ;
Int_t * primppsdup = tracksegment->GetPrimariesPpsdUp(numberofprimariestoppsdup) ;
Int_t numberofprimariestoppsdlow = 0 ;
Int_t * primppsdlow = tracksegment->GetPrimariesPpsdLow(numberofprimariestoppsdlow) ;
// print one as example
please->GimePrimaryParticle( primppsdlow[0] )->Print() ;
}
rootfile.Close() ;
gAlice = 0 ;
phos = 0 ;
recparticleslist = 0 ;
// initialization
// open root file
TFile rootfile("junk.root") ;
// get AliRun object
gAlice = (AliRun *)rootfile.Get("gAlice") ;
// get detector object
AliPHOSv1 * phos = (AliPHOSv1 *)gAlice->GetDetector("PHOS") ;
// get the geometry associated with the detector
AliPHOSGeometry::GetInstance( phos->GetGeometry()->GetName(), phos->GetGeometry()->GetTitle() ) ;
// initializes the index to object converter
AliPHOSIndexToObject::GetInstance(phos) ;
// get the reconstructed particles list
Int_t evt = 123 ;
TClonesArray * recparticleslist = phos->RecParticles(evt) ;
// loop over reconstructed particles
TIter nextrecparticle(recparticleslist) ;
AliPHOSRecParticle * recparticle ;
// get the pointer of the index to object converter
AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
while ( recparticle = (AliPHOSRecParticle * )nextrecparticle() ) {
// get the track segment ...
AliPHOSTrackSegment * tracksegment = recparticle->GetPHOSTrackSegment() ;
// and print it
tracksegment->Print() ;
// get the list of primaries ...
Int_t numberofprimaries = 0 ;
Int_t * prim = recparticle->GetPrimaries(numberofprimaries) ;
for (Int_t i = 0 ; i < numberofprimaries ; i++ )
// and print them
please->GimePrimaryParticle( prim[i] )->Print() ;
}
rootfile.Close() ;
gAlice = 0 ;
phos = 0 ;
recparticleslist = 0 ;
A short cut allows to access the primaries at the origin of the reconstructed particle:
Int_t numberofprimaries = 0 ;
Int_t * prim = recparticle->GetPrimariesPpsdLow(numberofprimaries) ;