/* $Id$ */
-// A. De Falco, H. Woehri, INFN Cagliari, July 2006
-// This macro reads the generation/reconstruction files in the
-// input directories (recodir and simdir),
-// builds a tree that contains, for each event, an array of muons and dimuons
-// (TClonesArrays of AliMUONTrackLight and AliMUONPairLight objects)
-// and writes the tree in an output file (outFileName)
-// Note that if the path for the output file is not explicitly specified,
-// it will be written in the directory containing the generation/reconstruction
-// 27-Nov-2006: modified by in order to loop on files
-
-// 13 Nov 2007:
-// Updated this macro to work with new version of AliMUONRecoCheck. Also, we are
-// now fetching reconstructed track data from ESD and not the track tree, because
-// the AliMUONTrack objects for reconstructed tracks are no longer stored on disk.
-// - Artur Szostak <artursz@iafrica.com>
+/// \ingroup macros
+/// \file DecodeRecoCocktail.C
+/// \brief add brief description
+///
+/// \author A. De Falco, H. Woehri, INFN Cagliari, July 2006
+///
+/// This macro reads the generation/reconstruction files in the
+/// input directories (recodir and simdir),
+/// builds a tree that contains, for each event, an array of muons and dimuons
+/// (TClonesArrays of AliMUONTrackLight and AliMUONPairLight objects)
+/// and writes the tree in an output file (outFileName)
+/// Note that if the path for the output file is not explicitly specified,
+/// it will be written in the directory containing the generation/reconstruction
+/// 27-Nov-2006: modified by in order to loop on files
+///
+/// 13 Nov 2007:
+/// Updated this macro to work with new version of AliMUONRecoCheck. Also, we are
+/// now fetching reconstructed track data from ESD and not the track tree, because
+/// the AliMUONTrack objects for reconstructed tracks are no longer stored on disk.
+/// - Artur Szostak <artursz@iafrica.com>
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <Riostream.h>
#include <TLorentzVector.h>
#include <TParticle.h>
#include <TSystem.h>
-#include <TGeoManager.h>
#include "AliMUONRecoCheck.h"
#include "AliMUONTrack.h"
-#include "AliMUONTrackParam.h"
#include "AliMUONTrackLight.h"
#include "AliMUONPairLight.h"
#include "AliMUONVTrackStore.h"
-#include "AliMUONTrackExtrap.h"
#include "AliESDEvent.h"
#include "AliESDVertex.h"
+#include "AliESDMuonTrack.h"
#include "AliMCEventHandler.h"
#include "AliMCEvent.h"
+#include "AliStack.h"
/*TODO: need to update this with changes made to ITS
#include "AliITSVertexerPPZ.h"
#include "AliITSLoader.h"
*/
-#include "AliTracker.h"
-#include "AliMagFMaps.h"
#endif
void DecodeRecoCocktail(
char* recodir=".", // The directory containing galice.root for reconstructed data.
char* simdir="generated/", // The directory containing galice.root for simulated data.
- char* outFileName = "MuonLight.root", // The output filename containing AliMUONTrackLight and AliMUONPairLight objects.
- char* geoFilename = "generated/geometry.root" // The filename containing the geometry.
+ char* outFileName = "MuonLight.root" // The output filename containing AliMUONTrackLight and AliMUONPairLight objects.
)
{
+/// \param recodir The directory containing galice.root for reconstructed data.
+/// \param simdir The directory containing galice.root for simulated data.
+/// \param outFileName The output filename containing AliMUONTrackLight and AliMUONPairLight objects.
+/// \param geoFilename The filename containing the geometry.
+
char startingDir[200];
sprintf (startingDir,"%s",gSystem->pwd());
gSystem->cd(recodir);
treeOut->Branch("muons",&muonArray);
treeOut->Branch("dimuons",&dimuonArray);
- TFile* esdFile = TFile::Open("AliESDs.root");
- if (!esdFile || !esdFile->IsOpen()) {
- Error("DecodeRecoCocktailNew", "opening ESD file AliESDs.root failed");
- return;
- }
-
- AliESDEvent* esd = new AliESDEvent();
- TTree* treeESD = (TTree*) esdFile->Get("esdTree");
- if (!treeESD) {
- Error("CheckESD", "no ESD tree found");
- return;
- }
- esd->ReadFromTree(treeESD);
-
- // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex)
- if (!gGeoManager) {
- TGeoManager::Import(geoFilename);
- if (!gGeoManager) {
- Error("MUONmass_ESD", "getting geometry from file %s failed", geoFilename);
- return;
- }
- }
-
- // set mag field
- // waiting for mag field in CDB
- printf("Loading field map...\n");
- AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG);
- AliTracker::SetFieldMap(field, kFALSE);
- // set the magnetic field for track extrapolations
- AliMUONTrackExtrap::SetField(AliTracker::GetFieldMap());
-
- AliMUONRecoCheck *rc = new AliMUONRecoCheck("galice.root", simdir);
- Int_t nev = rc->NumberOfEvents();
+ AliMUONRecoCheck *rc = new AliMUONRecoCheck("AliESDs.root", simdir);
/*TODO: need to update this with changes made to ITS
AliITSLoader* ITSloader = (AliITSLoader*) runLoaderSim->GetLoader("ITSLoader");
TLorentzVector v;
+ Int_t nev = rc->NumberOfEvents();
for(Int_t ievent = 0; ievent < nev; ievent++){ // loop over events
- treeESD->GetEvent(ievent);
- rc->GetMCEventHandler()->GetEvent(ievent);
- AliStack* pstack = rc->GetMCEventHandler()->MCEvent()->Stack();
/*TODO: need to update this with changes made to ITS
runLoaderSim->GetHeader();
muonArray->Clear(); // clean muon and dimuon arrays
dimuonArray->Clear();
- //AliMUONVTrackStore* recoTracks = rc->ReconstructedTracks(ievent); // Use tracks from actual reconstruction, but this does not work anymore.
- AliMUONVTrackStore* recoTracks = rc->ReconstructedTracks(esd);
+ AliMUONVTrackStore* recoTracks = rc->ReconstructedTracks(ievent, kFALSE); // Use tracks from actual reconstruction.
//AliMUONVTrackStore* trackRefs = rc->ReconstructibleTracks(ievent); // Only use reconstructible reference tracks.
AliMUONVTrackStore* trackRefs = rc->TrackRefs(ievent);
+ AliStack* pstack = (const_cast<AliMCEventHandler*>(rc->GetMCEventHandler()))->MCEvent()->Stack();
- TIter next(recoTracks->CreateIterator());
- AliMUONTrack* trackReco = NULL;
-
- Int_t nTrackReco = recoTracks->GetSize();
- Int_t nTracksESD = (Int_t)esd->GetNumberOfMuonTracks();
- if (nTrackReco != nTracksESD) printf ("Tracks in recoTracks (%d) and in ESD (%d) do not match!\n", nTrackReco, nTracksESD);
+ // loop over ESD tracks
Int_t nreftracks = 0;
- Int_t itrRec = 0;
- while ( (trackReco = static_cast<AliMUONTrack*>(next())) != NULL )
- {
- // assign parameters concerning the reconstructed tracks
- AliMUONTrackLight muLight;
+ const AliESDEvent* esd = rc->GetESDEvent();
+ Int_t nTracks = (Int_t)esd->GetNumberOfMuonTracks() ;
+ for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
+
+ AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
- muLight.FillFromESD(esd->GetMuonTrack(itrRec));
- // muLight.FillFromAliMUONTrack(trackReco);
+ // skip ghosts
+ if (!esdTrack->ContainTrackerData()) continue;
- // find the reference track and store further information
- TParticle *part = muLight.FindRefTrack(trackReco, trackRefs, pstack, kTRUE);
- if (part) {
+ // find the corresponding MUON track
+ AliMUONTrack* trackReco = (AliMUONTrack*) recoTracks->FindObject(esdTrack->GetUniqueID());
+
+ // try to match the reconstructed track with a simulated one
+ Int_t nMatchClusters = 0;
+ AliMUONTrack* matchedTrackRef = rc->FindCompatibleTrack(*trackReco, *trackRefs, nMatchClusters, kFALSE, 10.);
+
+ if (matchedTrackRef) {
+
+ //store new referenced track in the muonArray
+ AliMUONTrackLight* muLight = new ((*muonArray)[nreftracks++]) AliMUONTrackLight();
+
+ // assign parameters concerning the reconstructed tracks
+ muLight->FillFromESD(esdTrack);
+ // muLight->FillFromAliMUONTrack(trackReco);
+
+ // store further information related to the simulated track
+ muLight->SetTrackPythiaLine(matchedTrackRef->GetUniqueID());
+ TParticle *part = pstack->Particle(matchedTrackRef->GetUniqueID());
+ muLight->SetTrackPDGCode(part->GetPdgCode());
v.SetPxPyPzE(part->Px(), part->Py(), part->Pz(), part->Energy());
- muLight.SetPGen(v);
- muLight.FillMuonHistory(pstack, part);
+ muLight->SetPGen(v);
+ muLight->FillMuonHistory(pstack, part);
// muLight.PrintInfo("A");
- //store the referenced track in the muonArray:
- TClonesArray &muons = *muonArray;
- new (muons[nreftracks++]) AliMUONTrackLight(muLight);
- }
+
+ }
- itrRec++;
- } // end reco track
+ } // end esd track
// now loop over muon pairs to build dimuons
Int_t nmuons = muonArray->GetEntriesFast();
}
treeOut->Fill();
-
- delete recoTracks;
}
fout->cd();
delete treeOut;
delete fout;
delete rc;
- delete esd;
}