]>
Commit | Line | Data |
---|---|---|
fa6e7866 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
e54bf126 | 18 | /// \ingroup macros |
19 | /// \file DecodeRecoCocktail.C | |
20 | /// \brief add brief description | |
21 | /// | |
22 | /// \author A. De Falco, H. Woehri, INFN Cagliari, July 2006 | |
23 | /// | |
24 | /// This macro reads the generation/reconstruction files in the | |
25 | /// input directories (recodir and simdir), | |
26 | /// builds a tree that contains, for each event, an array of muons and dimuons | |
27 | /// (TClonesArrays of AliMUONTrackLight and AliMUONPairLight objects) | |
28 | /// and writes the tree in an output file (outFileName) | |
29 | /// Note that if the path for the output file is not explicitly specified, | |
30 | /// it will be written in the directory containing the generation/reconstruction | |
31 | /// 27-Nov-2006: modified by in order to loop on files | |
32 | /// | |
33 | /// 13 Nov 2007: | |
34 | /// Updated this macro to work with new version of AliMUONRecoCheck. Also, we are | |
35 | /// now fetching reconstructed track data from ESD and not the track tree, because | |
36 | /// the AliMUONTrack objects for reconstructed tracks are no longer stored on disk. | |
37 | /// - Artur Szostak <artursz@iafrica.com> | |
9bdda5f6 | 38 | |
4d309390 | 39 | #if !defined(__CINT__) || defined(__MAKECINT__) |
40 | #include <Riostream.h> | |
fa6e7866 | 41 | #include <TClonesArray.h> |
42 | #include <TFile.h> | |
43 | #include <TTree.h> | |
44 | #include <TMath.h> | |
45 | #include <TLorentzVector.h> | |
46 | #include <TParticle.h> | |
47 | #include <TSystem.h> | |
59830a87 | 48 | #include <TGeoManager.h> |
d9b1d5a4 | 49 | #include <TGeoGlobalMagField.h> |
4d309390 | 50 | #include "AliMUONRecoCheck.h" |
51 | #include "AliMUONTrack.h" | |
52 | #include "AliMUONTrackParam.h" | |
fa6e7866 | 53 | #include "AliMUONTrackLight.h" |
54 | #include "AliMUONPairLight.h" | |
9bdda5f6 | 55 | #include "AliMUONVTrackStore.h" |
22ccc301 | 56 | #include "AliMUONTrackExtrap.h" |
9bdda5f6 | 57 | #include "AliESDEvent.h" |
58 | #include "AliESDVertex.h" | |
59 | #include "AliMCEventHandler.h" | |
60 | #include "AliMCEvent.h" | |
f7a1cc68 | 61 | #include "AliMagF.h" |
d9b1d5a4 | 62 | #include "AliGRPManager.h" |
9bdda5f6 | 63 | /*TODO: need to update this with changes made to ITS |
4d309390 | 64 | #include "AliITSVertexerPPZ.h" |
65 | #include "AliITSLoader.h" | |
9bdda5f6 | 66 | */ |
59830a87 | 67 | #include "AliTracker.h" |
4d309390 | 68 | #endif |
fa6e7866 | 69 | |
4d309390 | 70 | |
9bdda5f6 | 71 | void DecodeRecoCocktail( |
72 | char* recodir=".", // The directory containing galice.root for reconstructed data. | |
73 | char* simdir="generated/", // The directory containing galice.root for simulated data. | |
74 | char* outFileName = "MuonLight.root", // The output filename containing AliMUONTrackLight and AliMUONPairLight objects. | |
61fed964 | 75 | char* geoFilename = "geometry.root" // The filename containing the geometry. |
9bdda5f6 | 76 | ) |
77 | { | |
e54bf126 | 78 | /// \param recodir The directory containing galice.root for reconstructed data. |
79 | /// \param simdir The directory containing galice.root for simulated data. | |
80 | /// \param outFileName The output filename containing AliMUONTrackLight and AliMUONPairLight objects. | |
81 | /// \param geoFilename The filename containing the geometry. | |
82 | ||
4d309390 | 83 | char startingDir[200]; |
84 | sprintf (startingDir,"%s",gSystem->pwd()); | |
9bdda5f6 | 85 | gSystem->cd(recodir); |
4d309390 | 86 | |
87 | TClonesArray *muonArray = new TClonesArray("AliMUONTrackLight",10); | |
88 | TClonesArray *dimuonArray = new TClonesArray("AliMUONPairLight",10); | |
89 | TTree *treeOut = new TTree("tree","tree"); | |
90 | ||
fa6e7866 | 91 | TFile *fout = new TFile(outFileName,"recreate"); |
4d309390 | 92 | fout->cd(); |
fa6e7866 | 93 | |
4d309390 | 94 | treeOut->Branch("muons",&muonArray); |
95 | treeOut->Branch("dimuons",&dimuonArray); | |
96 | ||
59830a87 | 97 | // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex) |
98 | if (!gGeoManager) { | |
99 | TGeoManager::Import(geoFilename); | |
100 | if (!gGeoManager) { | |
101 | Error("MUONmass_ESD", "getting geometry from file %s failed", geoFilename); | |
102 | return; | |
103 | } | |
104 | } | |
105 | ||
106 | // set mag field | |
107 | // waiting for mag field in CDB | |
d9b1d5a4 | 108 | if (!TGeoGlobalMagField::Instance()->GetField()) { |
f7a1cc68 | 109 | printf("Loading field map...\n"); |
d9b1d5a4 | 110 | AliGRPManager *grpMan = new AliGRPManager(); |
111 | grpMan->ReadGRPEntry(); | |
112 | grpMan->SetMagField(); | |
113 | delete grpMan; | |
f7a1cc68 | 114 | } |
59830a87 | 115 | // set the magnetic field for track extrapolations |
f7a1cc68 | 116 | AliMUONTrackExtrap::SetField(); |
59830a87 | 117 | |
61fed964 | 118 | AliMUONRecoCheck *rc = new AliMUONRecoCheck("AliESDs.root", simdir); |
9bdda5f6 | 119 | Int_t nev = rc->NumberOfEvents(); |
fa6e7866 | 120 | |
9bdda5f6 | 121 | /*TODO: need to update this with changes made to ITS |
a4ee7ab9 | 122 | AliITSLoader* ITSloader = (AliITSLoader*) runLoaderSim->GetLoader("ITSLoader"); |
4d309390 | 123 | AliITSVertexerPPZ *dovert = 0; |
124 | if (ITSloader) { | |
125 | dovert = new AliITSVertexerPPZ("default",0,0); | |
21939432 | 126 | // dovert->SetDebug(0); |
4d309390 | 127 | dovert->SetDiffPhiMax(0.05); |
128 | dovert->SetWindow(3.); | |
129 | } | |
130 | AliESDVertex *vert = 0; | |
9bdda5f6 | 131 | */ |
fa6e7866 | 132 | |
133 | TLorentzVector v; | |
9bdda5f6 | 134 | |
fa6e7866 | 135 | for(Int_t ievent = 0; ievent < nev; ievent++){ // loop over events |
9bdda5f6 | 136 | |
137 | /*TODO: need to update this with changes made to ITS | |
a4ee7ab9 | 138 | runLoaderSim->GetHeader(); |
4d309390 | 139 | if (ITSloader) { |
140 | vert = dovert->FindVertexForCurrentEvent(ievent); | |
141 | } | |
9bdda5f6 | 142 | */ |
143 | ||
a4ee7ab9 | 144 | //printf ("Event %d of %d\n",ievent,nev); |
fa6e7866 | 145 | muonArray->Clear(); // clean muon and dimuon arrays |
146 | dimuonArray->Clear(); | |
fa6e7866 | 147 | |
61fed964 | 148 | AliMUONVTrackStore* recoTracks = rc->ReconstructedTracks(ievent); // Use tracks from actual reconstruction, but this does not work anymore. |
9bdda5f6 | 149 | //AliMUONVTrackStore* trackRefs = rc->ReconstructibleTracks(ievent); // Only use reconstructible reference tracks. |
150 | AliMUONVTrackStore* trackRefs = rc->TrackRefs(ievent); | |
61fed964 | 151 | AliStack* pstack = (const_cast<AliMCEventHandler*>(rc->GetMCEventHandler()))->MCEvent()->Stack(); |
9bdda5f6 | 152 | |
153 | TIter next(recoTracks->CreateIterator()); | |
154 | AliMUONTrack* trackReco = NULL; | |
155 | ||
156 | Int_t nTrackReco = recoTracks->GetSize(); | |
61fed964 | 157 | Int_t nTracksESD = rc->GetESDEvent()->GetNumberOfMuonTracks(); |
9bdda5f6 | 158 | if (nTrackReco != nTracksESD) printf ("Tracks in recoTracks (%d) and in ESD (%d) do not match!\n", nTrackReco, nTracksESD); |
159 | Int_t nreftracks = 0; | |
160 | Int_t itrRec = 0; | |
161 | while ( (trackReco = static_cast<AliMUONTrack*>(next())) != NULL ) | |
162 | { | |
fa6e7866 | 163 | // assign parameters concerning the reconstructed tracks |
4d309390 | 164 | AliMUONTrackLight muLight; |
a4ee7ab9 | 165 | |
61fed964 | 166 | muLight.FillFromESD(rc->GetESDEvent()->GetMuonTrack(itrRec)); |
9bdda5f6 | 167 | // muLight.FillFromAliMUONTrack(trackReco); |
4d309390 | 168 | |
169 | // find the reference track and store further information | |
61fed964 | 170 | TParticle *part = muLight.FindRefTrack(trackReco, trackRefs, pstack); |
fa6e7866 | 171 | if (part) { |
172 | v.SetPxPyPzE(part->Px(), part->Py(), part->Pz(), part->Energy()); | |
82724a77 | 173 | muLight.SetPGen(v); |
9bdda5f6 | 174 | muLight.FillMuonHistory(pstack, part); |
4d309390 | 175 | // muLight.PrintInfo("A"); |
fa6e7866 | 176 | //store the referenced track in the muonArray: |
177 | TClonesArray &muons = *muonArray; | |
82724a77 | 178 | new (muons[nreftracks++]) AliMUONTrackLight(muLight); |
4d309390 | 179 | } |
9bdda5f6 | 180 | |
181 | itrRec++; | |
4d309390 | 182 | } // end reco track |
fa6e7866 | 183 | |
184 | // now loop over muon pairs to build dimuons | |
185 | Int_t nmuons = muonArray->GetEntriesFast(); | |
186 | Int_t ndimuons = 0; | |
187 | for(Int_t itrRec1 = 0; itrRec1 < nmuons-1; itrRec1++) { | |
188 | AliMUONTrackLight* mu1 = (AliMUONTrackLight*) muonArray->At(itrRec1); | |
189 | for(Int_t itrRec2 = itrRec1+1; itrRec2 < nmuons; itrRec2++){ | |
190 | AliMUONTrackLight* mu2 = (AliMUONTrackLight*) muonArray->At(itrRec2); | |
4d309390 | 191 | AliMUONPairLight dimuLight; |
82724a77 | 192 | dimuLight.SetMuons(*mu1, *mu2); |
fa6e7866 | 193 | TClonesArray &dimuons = *dimuonArray; |
82724a77 | 194 | new (dimuons[ndimuons++]) AliMUONPairLight(dimuLight); |
fa6e7866 | 195 | } |
196 | } | |
9bdda5f6 | 197 | |
fa6e7866 | 198 | treeOut->Fill(); |
4d309390 | 199 | } |
200 | ||
fa6e7866 | 201 | fout->cd(); |
202 | treeOut->Write(); | |
203 | gSystem->cd(startingDir); | |
82724a77 | 204 | fout->Close(); |
82724a77 | 205 | delete muonArray; |
206 | delete dimuonArray; | |
4d309390 | 207 | delete treeOut; |
208 | delete fout; | |
209 | delete rc; | |
fa6e7866 | 210 | } |
4d309390 | 211 |