]>
Commit | Line | Data |
---|---|---|
a9e2aefa | 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 | ||
cc87ebcd | 16 | /* $Id$ */ |
17 | ||
3831f268 | 18 | //////////////////////////////////// |
a9e2aefa | 19 | // |
29f1b13a | 20 | // MUON track reconstructor in ALICE (class renamed from AliMUONEventReconstructor) |
a9e2aefa | 21 | // |
22 | // This class contains as data: | |
29f1b13a | 23 | // * the parameters for the track reconstruction |
a9e2aefa | 24 | // * a pointer to the array of hits to be reconstructed (the event) |
25 | // * a pointer to the array of segments made with these hits inside each station | |
26 | // * a pointer to the array of reconstructed tracks | |
27 | // | |
28 | // It contains as methods, among others: | |
29 | // * MakeEventToBeReconstructed to build the array of hits to be reconstructed | |
30 | // * MakeSegments to build the segments | |
31 | // * MakeTracks to build the tracks | |
3831f268 | 32 | // |
33 | //////////////////////////////////// | |
a9e2aefa | 34 | |
ae17f568 | 35 | #include <stdlib.h> |
30178c30 | 36 | #include <Riostream.h> |
37 | #include <TDirectory.h> | |
38 | #include <TFile.h> | |
cc87ebcd | 39 | #include <TMatrixD.h> |
a9e2aefa | 40 | |
29f1b13a | 41 | #include "AliMUONTrackReconstructor.h" |
30178c30 | 42 | #include "AliMUON.h" |
29fc2c86 | 43 | #include "AliMUONConstants.h" |
a9e2aefa | 44 | #include "AliMUONHitForRec.h" |
276c44b7 | 45 | #include "AliMUONTriggerTrack.h" |
276c44b7 | 46 | #include "AliMUONTriggerCircuit.h" |
bc4a7ff4 | 47 | #include "AliMUONTriggerCircuitNew.h" |
a9e2aefa | 48 | #include "AliMUONRawCluster.h" |
276c44b7 | 49 | #include "AliMUONLocalTrigger.h" |
52c9bc11 | 50 | #include "AliMUONGlobalTrigger.h" |
3831f268 | 51 | #include "AliMUONSegment.h" |
a9e2aefa | 52 | #include "AliMUONTrack.h" |
a9e2aefa | 53 | #include "AliMUONTrackHit.h" |
94de3818 | 54 | #include "AliMagF.h" |
3831f268 | 55 | #include "AliRun.h" // for gAlice |
88cb7938 | 56 | #include "AliRunLoader.h" |
57 | #include "AliLoader.h" | |
cc87ebcd | 58 | #include "AliMUONTrackK.h" |
5d12ce38 | 59 | #include "AliMC.h" |
8c343c7c | 60 | #include "AliLog.h" |
29fc2c86 | 61 | #include "AliTrackReference.h" |
a9e2aefa | 62 | |
a9e2aefa | 63 | //************* Defaults parameters for reconstruction |
29f1b13a | 64 | const Double_t AliMUONTrackReconstructor::fgkDefaultMinBendingMomentum = 3.0; |
7b96283c | 65 | const Double_t AliMUONTrackReconstructor::fgkDefaultMaxBendingMomentum = 3000.0; |
29f1b13a | 66 | const Double_t AliMUONTrackReconstructor::fgkDefaultMaxChi2 = 100.0; |
67 | const Double_t AliMUONTrackReconstructor::fgkDefaultMaxSigma2Distance = 16.0; | |
68 | const Double_t AliMUONTrackReconstructor::fgkDefaultBendingResolution = 0.01; | |
69 | const Double_t AliMUONTrackReconstructor::fgkDefaultNonBendingResolution = 0.144; | |
70 | const Double_t AliMUONTrackReconstructor::fgkDefaultChamberThicknessInX0 = 0.03; | |
a9e2aefa | 71 | // Simple magnetic field: |
72 | // Value taken from macro MUONtracking.C: 0.7 T, hence 7 kG | |
73 | // Length and Position from reco_muon.F, with opposite sign: | |
74 | // Length = ZMAGEND-ZCOIL | |
75 | // Position = (ZMAGEND+ZCOIL)/2 | |
76 | // to be ajusted differently from real magnetic field ???? | |
29f1b13a | 77 | const Double_t AliMUONTrackReconstructor::fgkDefaultSimpleBValue = 7.0; |
78 | const Double_t AliMUONTrackReconstructor::fgkDefaultSimpleBLength = 428.0; | |
79 | const Double_t AliMUONTrackReconstructor::fgkDefaultSimpleBPosition = 1019.0; | |
80 | const Int_t AliMUONTrackReconstructor::fgkDefaultRecTrackRefHits = 0; | |
81 | const Double_t AliMUONTrackReconstructor::fgkDefaultEfficiency = 0.95; | |
a9e2aefa | 82 | |
29f1b13a | 83 | ClassImp(AliMUONTrackReconstructor) // Class implementation in ROOT context |
a9e2aefa | 84 | |
3bc8b580 | 85 | //__________________________________________________________________________ |
86 | AliMUONTrackReconstructor::AliMUONTrackReconstructor(AliLoader* loader, AliMUONData* data) | |
30178c30 | 87 | : TObject() |
a9e2aefa | 88 | { |
29f1b13a | 89 | // Constructor for class AliMUONTrackReconstructor |
a9e2aefa | 90 | SetReconstructionParametersToDefaults(); |
83dbc640 | 91 | fTrackMethod = 1; //AZ - tracking method (1-default, 2-Kalman) |
a9e2aefa | 92 | // Memory allocation for the TClonesArray of hits for reconstruction |
93 | // Is 10000 the right size ???? | |
94 | fHitsForRecPtr = new TClonesArray("AliMUONHitForRec", 10000); | |
95 | fNHitsForRec = 0; // really needed or GetEntriesFast sufficient ???? | |
96 | // Memory allocation for the TClonesArray's of segments in stations | |
97 | // Is 2000 the right size ???? | |
190f97ea | 98 | for (Int_t st = 0; st < AliMUONConstants::NTrackingCh()/2; st++) { |
a9e2aefa | 99 | fSegmentsPtr[st] = new TClonesArray("AliMUONSegment", 2000); |
100 | fNSegments[st] = 0; // really needed or GetEntriesFast sufficient ???? | |
101 | } | |
102 | // Memory allocation for the TClonesArray of reconstructed tracks | |
103 | // Is 10 the right size ???? | |
104 | fRecTracksPtr = new TClonesArray("AliMUONTrack", 10); | |
105 | fNRecTracks = 0; // really needed or GetEntriesFast sufficient ???? | |
8429a5e4 | 106 | // Memory allocation for the TClonesArray of hits on reconstructed tracks |
107 | // Is 100 the right size ???? | |
b035a148 | 108 | fRecTrackHitsPtr = new TClonesArray("AliMUONTrackHit", 100); |
8429a5e4 | 109 | fNRecTrackHits = 0; // really needed or GetEntriesFast sufficient ???? |
a9e2aefa | 110 | |
5b64e914 | 111 | // Sign of fSimpleBValue according to sign of Bx value at (50,50,-950). |
a6f03ddb | 112 | Float_t b[3], x[3]; |
5b64e914 | 113 | x[0] = 50.; x[1] = 50.; x[2] = -950.; |
a6f03ddb | 114 | gAlice->Field()->Field(x, b); |
065bd0e1 | 115 | fSimpleBValue = TMath::Sign(fSimpleBValue,(Double_t) b[0]); |
5b64e914 | 116 | fSimpleBPosition = TMath::Sign(fSimpleBPosition,(Double_t) x[2]); |
a6f03ddb | 117 | // See how to get fSimple(BValue, BLength, BPosition) |
118 | // automatically calculated from the actual magnetic field ???? | |
a9e2aefa | 119 | |
29f1b13a | 120 | AliDebug(1,"AliMUONTrackReconstructor constructed with defaults"); |
b840996b | 121 | if ( AliLog::GetGlobalDebugLevel()>0) Dump(); |
122 | AliDebug(1,"Magnetic field from root file:"); | |
123 | if ( AliLog::GetGlobalDebugLevel()>0) gAlice->Field()->Dump(); | |
124 | ||
c7ba256d | 125 | |
29fc2c86 | 126 | // Initializions for track ref. background events |
127 | fBkgTrackRefFile = 0; | |
128 | fBkgTrackRefTK = 0; | |
129 | fBkgTrackRefParticles = 0; | |
130 | fBkgTrackRefTTR = 0; | |
131 | fBkgTrackRefEventNumber = -1; | |
34f1bfa0 | 132 | |
52c9bc11 | 133 | // initialize loader's |
134 | fLoader = loader; | |
135 | ||
136 | // initialize container | |
3bc8b580 | 137 | // fMUONData = new AliMUONData(fLoader,"MUON","MUON"); |
138 | fMUONData = data; | |
52c9bc11 | 139 | |
a9e2aefa | 140 | return; |
141 | } | |
52c9bc11 | 142 | //__________________________________________________________________________ |
29f1b13a | 143 | AliMUONTrackReconstructor::AliMUONTrackReconstructor (const AliMUONTrackReconstructor& rhs) |
30178c30 | 144 | : TObject(rhs) |
9cbdf048 | 145 | { |
30178c30 | 146 | // Protected copy constructor |
147 | ||
8c343c7c | 148 | AliFatal("Not implemented."); |
9cbdf048 | 149 | } |
150 | ||
29f1b13a | 151 | AliMUONTrackReconstructor & |
152 | AliMUONTrackReconstructor::operator=(const AliMUONTrackReconstructor& rhs) | |
9cbdf048 | 153 | { |
30178c30 | 154 | // Protected assignement operator |
155 | ||
156 | if (this == &rhs) return *this; | |
157 | ||
8c343c7c | 158 | AliFatal("Not implemented."); |
30178c30 | 159 | |
160 | return *this; | |
9cbdf048 | 161 | } |
162 | ||
a9e2aefa | 163 | //__________________________________________________________________________ |
29f1b13a | 164 | AliMUONTrackReconstructor::~AliMUONTrackReconstructor(void) |
a9e2aefa | 165 | { |
29f1b13a | 166 | // Destructor for class AliMUONTrackReconstructor |
a9e2aefa | 167 | delete fHitsForRecPtr; // Correct destruction of everything ???? or delete [] ???? |
190f97ea | 168 | for (Int_t st = 0; st < AliMUONConstants::NTrackingCh()/2; st++) |
a9e2aefa | 169 | delete fSegmentsPtr[st]; // Correct destruction of everything ???? |
170 | return; | |
171 | } | |
172 | ||
173 | //__________________________________________________________________________ | |
29f1b13a | 174 | void AliMUONTrackReconstructor::SetReconstructionParametersToDefaults(void) |
a9e2aefa | 175 | { |
176 | // Set reconstruction parameters to default values | |
177 | // Would be much more convenient with a structure (or class) ???? | |
343146bf | 178 | fMinBendingMomentum = fgkDefaultMinBendingMomentum; |
179 | fMaxBendingMomentum = fgkDefaultMaxBendingMomentum; | |
180 | fMaxChi2 = fgkDefaultMaxChi2; | |
181 | fMaxSigma2Distance = fgkDefaultMaxSigma2Distance; | |
a9e2aefa | 182 | |
a9e2aefa | 183 | // ******** Parameters for making HitsForRec |
184 | // minimum radius, | |
185 | // like in TRACKF_STAT: | |
186 | // 2 degrees for stations 1 and 2, or ch(0...) from 0 to 3; | |
187 | // 30 cm for stations 3 to 5, or ch(0...) from 4 to 9 | |
190f97ea | 188 | for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) { |
06c11448 | 189 | if (ch < 4) fRMin[ch] = TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)) * |
a9e2aefa | 190 | 2.0 * TMath::Pi() / 180.0; |
191 | else fRMin[ch] = 30.0; | |
d0bfce8d | 192 | // maximum radius at 10 degrees and Z of chamber |
06c11448 | 193 | fRMax[ch] = TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)) * |
d0bfce8d | 194 | 10.0 * TMath::Pi() / 180.0; |
a9e2aefa | 195 | } |
a9e2aefa | 196 | |
197 | // ******** Parameters for making segments | |
198 | // should be parametrized ???? | |
199 | // according to interval between chambers in a station ???? | |
200 | // Maximum distance in non bending plane | |
201 | // 5 * 0.22 just to remember the way it was made in TRACKF_STAT | |
202 | // SIGCUT*DYMAX(IZ) | |
190f97ea | 203 | for (Int_t st = 0; st < AliMUONConstants::NTrackingCh()/2; st++) |
a9e2aefa | 204 | fSegmentMaxDistNonBending[st] = 5. * 0.22; |
860cef81 | 205 | // Maximum distance in bending plane: |
206 | // values from TRACKF_STAT, corresponding to (J psi 20cm), | |
207 | // scaled to the real distance between chambers in a station | |
ef21c79e | 208 | fSegmentMaxDistBending[0] = TMath::Abs( 1.5 * |
06c11448 | 209 | (AliMUONConstants::DefaultChamberZ(1) - AliMUONConstants::DefaultChamberZ(0)) / 20.0); |
e516b01d | 210 | fSegmentMaxDistBending[1] = TMath::Abs( 1.5 * |
06c11448 | 211 | (AliMUONConstants::DefaultChamberZ(3) - AliMUONConstants::DefaultChamberZ(2)) / 20.0); |
e516b01d | 212 | fSegmentMaxDistBending[2] = TMath::Abs( 3.0 * |
06c11448 | 213 | (AliMUONConstants::DefaultChamberZ(5) - AliMUONConstants::DefaultChamberZ(4)) / 20.0); |
e516b01d | 214 | fSegmentMaxDistBending[3] = TMath::Abs( 6.0 * |
06c11448 | 215 | (AliMUONConstants::DefaultChamberZ(7) - AliMUONConstants::DefaultChamberZ(6)) / 20.0); |
e516b01d | 216 | fSegmentMaxDistBending[4] = TMath::Abs( 6.0 * |
06c11448 | 217 | (AliMUONConstants::DefaultChamberZ(9) - AliMUONConstants::DefaultChamberZ(8)) / 20.0); |
218 | ||
a9e2aefa | 219 | |
343146bf | 220 | fBendingResolution = fgkDefaultBendingResolution; |
221 | fNonBendingResolution = fgkDefaultNonBendingResolution; | |
222 | fChamberThicknessInX0 = fgkDefaultChamberThicknessInX0; | |
223 | fSimpleBValue = fgkDefaultSimpleBValue; | |
224 | fSimpleBLength = fgkDefaultSimpleBLength; | |
225 | fSimpleBPosition = fgkDefaultSimpleBPosition; | |
29fc2c86 | 226 | fRecTrackRefHits = fgkDefaultRecTrackRefHits; |
343146bf | 227 | fEfficiency = fgkDefaultEfficiency; |
a9e2aefa | 228 | return; |
229 | } | |
230 | ||
231 | //__________________________________________________________________________ | |
29f1b13a | 232 | Double_t AliMUONTrackReconstructor::GetImpactParamFromBendingMomentum(Double_t BendingMomentum) const |
a9e2aefa | 233 | { |
234 | // Returns impact parameter at vertex in bending plane (cm), | |
235 | // from the signed bending momentum "BendingMomentum" in bending plane (GeV/c), | |
236 | // using simple values for dipole magnetic field. | |
065bd0e1 | 237 | // The sign of "BendingMomentum" is the sign of the charge. |
a9e2aefa | 238 | return (-0.0003 * fSimpleBValue * fSimpleBLength * fSimpleBPosition / |
239 | BendingMomentum); | |
240 | } | |
241 | ||
242 | //__________________________________________________________________________ | |
29f1b13a | 243 | Double_t AliMUONTrackReconstructor::GetBendingMomentumFromImpactParam(Double_t ImpactParam) const |
a9e2aefa | 244 | { |
245 | // Returns signed bending momentum in bending plane (GeV/c), | |
065bd0e1 | 246 | // the sign being the sign of the charge for particles moving forward in Z, |
a9e2aefa | 247 | // from the impact parameter "ImpactParam" at vertex in bending plane (cm), |
248 | // using simple values for dipole magnetic field. | |
a9e2aefa | 249 | return (-0.0003 * fSimpleBValue * fSimpleBLength * fSimpleBPosition / |
250 | ImpactParam); | |
251 | } | |
252 | ||
253 | //__________________________________________________________________________ | |
29f1b13a | 254 | void AliMUONTrackReconstructor::SetBkgTrackRefFile(Text_t *BkgTrackRefFileName) |
a9e2aefa | 255 | { |
29fc2c86 | 256 | // Set background file ... for track ref. hits |
a9e2aefa | 257 | // Must be called after having loaded the firts signal event |
b840996b | 258 | AliDebug(1,Form("Enter SetBkgTrackRefFile with BkgTrackRefFileName %s",BkgTrackRefFileName)); |
259 | ||
29fc2c86 | 260 | if (strlen(BkgTrackRefFileName)) { |
261 | // BkgTrackRefFileName not empty: try to open the file | |
b840996b | 262 | |
263 | if(AliLog::GetGlobalDebugLevel()>1) { | |
264 | cout << "Before File(Bkg)" << endl; gDirectory->Dump(); | |
265 | } | |
29fc2c86 | 266 | fBkgTrackRefFile = new TFile(BkgTrackRefFileName); |
b840996b | 267 | if(AliLog::GetGlobalDebugLevel()>1) { |
268 | cout << "After File(Bkg)" << endl; gDirectory->Dump(); | |
269 | } | |
29fc2c86 | 270 | if (fBkgTrackRefFile-> IsOpen()) { |
b840996b | 271 | if(AliLog::GetGlobalDebugLevel()>0) { |
29fc2c86 | 272 | cout << "Background for Track ref. hits in file: ``" << BkgTrackRefFileName |
a9e2aefa | 273 | << "'' successfully opened" << endl;} |
274 | } | |
275 | else { | |
29fc2c86 | 276 | cout << "Background for Track Ref. hits in file: " << BkgTrackRefFileName << endl; |
a9e2aefa | 277 | cout << "NOT FOUND: EXIT" << endl; |
278 | exit(0); // right instruction for exit ???? | |
279 | } | |
280 | // Arrays for "particles" and "hits" | |
29fc2c86 | 281 | fBkgTrackRefParticles = new TClonesArray("TParticle", 200); |
a9e2aefa | 282 | // Event number to -1 for initialization |
29fc2c86 | 283 | fBkgTrackRefEventNumber = -1; |
a9e2aefa | 284 | // Back to the signal file: |
285 | // first signal event must have been loaded previously, | |
286 | // otherwise, Segmentation violation at the next instruction | |
287 | // How is it possible to do smething better ???? | |
288 | ((gAlice->TreeK())->GetCurrentFile())->cd(); | |
b840996b | 289 | if(AliLog::GetGlobalDebugLevel()>1) cout << "After cd(gAlice)" << endl; gDirectory->Dump(); |
a9e2aefa | 290 | } |
291 | return; | |
292 | } | |
293 | ||
294 | //__________________________________________________________________________ | |
29f1b13a | 295 | void AliMUONTrackReconstructor::NextBkgTrackRefEvent(void) |
a9e2aefa | 296 | { |
29fc2c86 | 297 | // Get next event in background file for track ref. hits |
a9e2aefa | 298 | // Goes back to event number 0 when end of file is reached |
299 | char treeName[20]; | |
b840996b | 300 | |
301 | AliDebug(1,"Enter NextBkgTrackRefEvent"); | |
a9e2aefa | 302 | // Clean previous event |
29fc2c86 | 303 | if(fBkgTrackRefTK) delete fBkgTrackRefTK; |
304 | fBkgTrackRefTK = NULL; | |
305 | if(fBkgTrackRefParticles) fBkgTrackRefParticles->Clear(); | |
306 | if(fBkgTrackRefTTR) delete fBkgTrackRefTTR; | |
307 | fBkgTrackRefTTR = NULL; | |
a9e2aefa | 308 | // Increment event number |
29fc2c86 | 309 | fBkgTrackRefEventNumber++; |
a9e2aefa | 310 | // Get access to Particles and Hits for event from background file |
b840996b | 311 | if (AliLog::GetGlobalDebugLevel()>1) cout << "Before cd(Bkg)" << endl; gDirectory->Dump(); |
29fc2c86 | 312 | fBkgTrackRefFile->cd(); |
b840996b | 313 | if (AliLog::GetGlobalDebugLevel()>1) cout << "After cd(Bkg)" << endl; gDirectory->Dump(); |
a9e2aefa | 314 | // Particles: TreeK for event and branch "Particles" |
29fc2c86 | 315 | sprintf(treeName, "TreeK%d", fBkgTrackRefEventNumber); |
316 | fBkgTrackRefTK = (TTree*)gDirectory->Get(treeName); | |
317 | if (!fBkgTrackRefTK) { | |
b840996b | 318 | |
319 | AliDebug(1,Form("Cannot find Kine Tree for background event: %d",fBkgTrackRefEventNumber)); | |
320 | AliDebug(1,"Goes back to event 0"); | |
321 | ||
29fc2c86 | 322 | fBkgTrackRefEventNumber = 0; |
323 | sprintf(treeName, "TreeK%d", fBkgTrackRefEventNumber); | |
324 | fBkgTrackRefTK = (TTree*)gDirectory->Get(treeName); | |
325 | if (!fBkgTrackRefTK) { | |
326 | AliError(Form("cannot find Kine Tree for background event: %d",fBkgTrackRefEventNumber)); | |
8c343c7c | 327 | exit(0); |
a9e2aefa | 328 | } |
329 | } | |
29fc2c86 | 330 | if (fBkgTrackRefTK) |
331 | fBkgTrackRefTK->SetBranchAddress("Particles", &fBkgTrackRefParticles); | |
332 | fBkgTrackRefTK->GetEvent(0); // why event 0 ???? necessary ???? | |
a9e2aefa | 333 | // Hits: TreeH for event and branch "MUON" |
29fc2c86 | 334 | sprintf(treeName, "TreeTR%d", fBkgTrackRefEventNumber); |
335 | fBkgTrackRefTTR = (TTree*)gDirectory->Get(treeName); | |
336 | if (!fBkgTrackRefTTR) { | |
337 | AliError(Form("cannot find Hits Tree for background event: %d",fBkgTrackRefEventNumber)); | |
a9e2aefa | 338 | exit(0); |
339 | } | |
29fc2c86 | 340 | fBkgTrackRefTTR->GetEntries(); // necessary ???? |
a9e2aefa | 341 | // Back to the signal file |
342 | ((gAlice->TreeK())->GetCurrentFile())->cd(); | |
b840996b | 343 | if (AliLog::GetGlobalDebugLevel()>1) |
344 | cout << "After cd(gAlice)" << endl; gDirectory->Dump(); | |
a9e2aefa | 345 | return; |
346 | } | |
347 | ||
348 | //__________________________________________________________________________ | |
29f1b13a | 349 | void AliMUONTrackReconstructor::EventReconstruct(void) |
a9e2aefa | 350 | { |
351 | // To reconstruct one event | |
b840996b | 352 | AliDebug(1,"Enter EventReconstruct"); |
fff097e0 | 353 | ResetTracks(); //AZ |
354 | ResetTrackHits(); //AZ | |
355 | ResetSegments(); //AZ | |
356 | ResetHitsForRec(); //AZ | |
a9e2aefa | 357 | MakeEventToBeReconstructed(); |
358 | MakeSegments(); | |
359 | MakeTracks(); | |
d837040f | 360 | if (fMUONData->IsTriggerTrackBranchesInTree()) |
361 | ValidateTracksWithTrigger(); | |
362 | ||
363 | // Add tracks to MUON data container | |
364 | for(Int_t i=0; i<GetNRecTracks(); i++) { | |
365 | AliMUONTrack * track = (AliMUONTrack*) GetRecTracksPtr()->At(i); | |
366 | fMUONData->AddRecTrack(*track); | |
367 | } | |
368 | ||
a9e2aefa | 369 | return; |
370 | } | |
371 | ||
276c44b7 | 372 | //__________________________________________________________________________ |
29f1b13a | 373 | void AliMUONTrackReconstructor::EventReconstructTrigger(void) |
276c44b7 | 374 | { |
375 | // To reconstruct one event | |
b840996b | 376 | AliDebug(1,"Enter EventReconstructTrigger"); |
276c44b7 | 377 | MakeTriggerTracks(); |
378 | return; | |
379 | } | |
380 | ||
a9e2aefa | 381 | //__________________________________________________________________________ |
29f1b13a | 382 | void AliMUONTrackReconstructor::ResetHitsForRec(void) |
a9e2aefa | 383 | { |
384 | // To reset the array and the number of HitsForRec, | |
385 | // and also the number of HitsForRec | |
386 | // and the index of the first HitForRec per chamber | |
0ce28091 | 387 | if (fHitsForRecPtr) fHitsForRecPtr->Delete(); |
a9e2aefa | 388 | fNHitsForRec = 0; |
190f97ea | 389 | for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) |
a9e2aefa | 390 | fNHitsForRecPerChamber[ch] = fIndexOfFirstHitForRecPerChamber[ch] = 0; |
391 | return; | |
392 | } | |
393 | ||
394 | //__________________________________________________________________________ | |
29f1b13a | 395 | void AliMUONTrackReconstructor::ResetSegments(void) |
a9e2aefa | 396 | { |
397 | // To reset the TClonesArray of segments and the number of Segments | |
398 | // for all stations | |
190f97ea | 399 | for (Int_t st = 0; st < AliMUONConstants::NTrackingCh()/2; st++) { |
a9e2aefa | 400 | if (fSegmentsPtr[st]) fSegmentsPtr[st]->Clear(); |
401 | fNSegments[st] = 0; | |
402 | } | |
403 | return; | |
404 | } | |
405 | ||
406 | //__________________________________________________________________________ | |
29f1b13a | 407 | void AliMUONTrackReconstructor::ResetTracks(void) |
a9e2aefa | 408 | { |
409 | // To reset the TClonesArray of reconstructed tracks | |
8429a5e4 | 410 | if (fRecTracksPtr) fRecTracksPtr->Delete(); |
411 | // Delete in order that the Track destructors are called, | |
412 | // hence the space for the TClonesArray of pointers to TrackHit's is freed | |
a9e2aefa | 413 | fNRecTracks = 0; |
414 | return; | |
415 | } | |
416 | ||
276c44b7 | 417 | |
8429a5e4 | 418 | //__________________________________________________________________________ |
29f1b13a | 419 | void AliMUONTrackReconstructor::ResetTrackHits(void) |
8429a5e4 | 420 | { |
421 | // To reset the TClonesArray of hits on reconstructed tracks | |
422 | if (fRecTrackHitsPtr) fRecTrackHitsPtr->Clear(); | |
423 | fNRecTrackHits = 0; | |
424 | return; | |
425 | } | |
426 | ||
a9e2aefa | 427 | //__________________________________________________________________________ |
29f1b13a | 428 | void AliMUONTrackReconstructor::MakeEventToBeReconstructed(void) |
a9e2aefa | 429 | { |
430 | // To make the list of hits to be reconstructed, | |
29fc2c86 | 431 | // either from the track ref. hits or from the raw clusters |
a9e2aefa | 432 | // according to the parameter set for the reconstructor |
e191bb57 | 433 | // TString evfoldname = AliConfig::GetDefaultEventFolderName();//to be interfaced properly |
88cb7938 | 434 | |
52c9bc11 | 435 | // AliRunLoader* rl = AliRunLoader::GetRunLoader(evfoldname); |
436 | // if (rl == 0x0) | |
437 | // { | |
438 | // Error("MakeEventToBeReconstructed", | |
439 | // "Can not find Run Loader in Event Folder named %s.", | |
440 | // evfoldname.Data()); | |
441 | // return; | |
442 | // } | |
443 | // AliLoader* gime = rl->GetLoader("MUONLoader"); | |
444 | // if (gime == 0x0) | |
445 | // { | |
446 | // Error("MakeEventToBeReconstructed","Can not get MUON Loader from Run Loader."); | |
447 | // return; | |
448 | // } | |
29fc2c86 | 449 | AliRunLoader *runLoader = fLoader->GetRunLoader(); |
450 | ||
b840996b | 451 | AliDebug(1,"Enter MakeEventToBeReconstructed"); |
fff097e0 | 452 | //AZ ResetHitsForRec(); |
29fc2c86 | 453 | if (fRecTrackRefHits == 1) { |
454 | // Reconstruction from track ref. hits | |
a9e2aefa | 455 | // Back to the signal file |
29fc2c86 | 456 | TTree* treeTR = runLoader->TreeTR(); |
457 | if (treeTR == 0x0) | |
458 | { | |
459 | Int_t retval = runLoader->LoadTrackRefs("READ"); | |
460 | if ( retval) | |
88cb7938 | 461 | { |
8c343c7c | 462 | AliError("Error occured while loading hits."); |
88cb7938 | 463 | return; |
464 | } | |
29fc2c86 | 465 | treeTR = runLoader->TreeTR(); |
466 | if (treeTR == 0x0) | |
88cb7938 | 467 | { |
29fc2c86 | 468 | AliError("Can not get TreeTR"); |
469 | return; | |
88cb7938 | 470 | } |
29fc2c86 | 471 | } |
472 | ||
473 | AddHitsForRecFromTrackRef(treeTR,1); | |
88cb7938 | 474 | |
a9e2aefa | 475 | // Background hits |
29fc2c86 | 476 | AddHitsForRecFromTrackRef(fBkgTrackRefTTR,0); |
a9e2aefa | 477 | // Sort HitsForRec in increasing order with respect to chamber number |
478 | SortHitsForRecWithIncreasingChamber(); | |
479 | } | |
480 | else { | |
481 | // Reconstruction from raw clusters | |
482 | // AliMUON *MUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ???? | |
483 | // Security on MUON ???? | |
484 | // TreeR assumed to be be "prepared" in calling function | |
485 | // by "MUON->GetTreeR(nev)" ???? | |
52c9bc11 | 486 | TTree *treeR = fLoader->TreeR(); |
cc87ebcd | 487 | //AZ? fMUONData->SetTreeAddress("RC"); |
9cbdf048 | 488 | AddHitsForRecFromRawClusters(treeR); |
a9e2aefa | 489 | // No sorting: it is done automatically in the previous function |
490 | } | |
b840996b | 491 | |
492 | AliDebug(1,"End of MakeEventToBeReconstructed"); | |
493 | if (AliLog::GetGlobalDebugLevel() > 0) { | |
494 | AliDebug(1, Form("NHitsForRec: %d",fNHitsForRec)); | |
190f97ea | 495 | for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) { |
b840996b | 496 | AliDebug(1, Form("Chamber(0...): %d",ch)); |
497 | AliDebug(1, Form("NHitsForRec: %d", fNHitsForRecPerChamber[ch])); | |
498 | AliDebug(1, Form("Index(first HitForRec): %d", fIndexOfFirstHitForRecPerChamber[ch])); | |
499 | for (Int_t hit = fIndexOfFirstHitForRecPerChamber[ch]; | |
500 | hit < fIndexOfFirstHitForRecPerChamber[ch] + fNHitsForRecPerChamber[ch]; | |
501 | hit++) { | |
502 | AliDebug(1, Form("HitForRec index(0...): %d",hit)); | |
503 | ((*fHitsForRecPtr)[hit])->Dump(); | |
a9e2aefa | 504 | } |
505 | } | |
506 | } | |
507 | return; | |
508 | } | |
509 | ||
510 | //__________________________________________________________________________ | |
29f1b13a | 511 | void AliMUONTrackReconstructor::AddHitsForRecFromTrackRef(TTree *TTR, Int_t signal) |
a9e2aefa | 512 | { |
513 | // To add to the list of hits for reconstruction | |
29fc2c86 | 514 | // the signal hits from a track reference tree TreeTR. |
515 | TClonesArray *listOfTrackRefs = NULL; | |
516 | AliTrackReference *trackRef; | |
517 | ||
518 | Int_t track = 0; | |
b840996b | 519 | AliDebug(2,Form("Enter AddHitsForRecFromTrackRef with TTR: %d", TTR)); |
29fc2c86 | 520 | if (TTR == NULL) return; |
521 | ||
522 | listOfTrackRefs = CleanTrackRefs(TTR); | |
1391e633 | 523 | |
29fc2c86 | 524 | Int_t ntracks = listOfTrackRefs->GetEntriesFast(); |
a9e2aefa | 525 | |
b840996b | 526 | AliDebug(2,Form("ntracks: %d", ntracks)); |
29fc2c86 | 527 | |
528 | for (Int_t index = 0; index < ntracks; index++) { | |
529 | trackRef = (AliTrackReference*) listOfTrackRefs->At(index); | |
530 | track = trackRef->GetTrack(); | |
531 | ||
532 | NewHitForRecFromTrackRef(trackRef,track,signal); | |
533 | } // end of track ref. | |
534 | ||
535 | listOfTrackRefs->Delete(); | |
536 | delete listOfTrackRefs; | |
a9e2aefa | 537 | return; |
538 | } | |
539 | ||
29fc2c86 | 540 | |
a9e2aefa | 541 | //__________________________________________________________________________ |
29f1b13a | 542 | AliMUONHitForRec* AliMUONTrackReconstructor::NewHitForRecFromTrackRef(AliTrackReference* Hit, Int_t TrackNumber, Int_t Signal) |
a9e2aefa | 543 | { |
29fc2c86 | 544 | // To make a new hit for reconstruction from a track ref. hit pointed to by "Hit", |
545 | // with the track numbered "TrackNumber", | |
a9e2aefa | 546 | // either from signal ("Signal" = 1) or background ("Signal" = 0) event. |
547 | // Selects hits in tracking (not trigger) chambers. | |
548 | // Takes into account the efficiency (fEfficiency) | |
549 | // and the smearing from resolution (fBendingResolution and fNonBendingResolution). | |
550 | // Adds a condition on the radius between RMin and RMax | |
551 | // to better simulate the real chambers. | |
552 | // Returns the pointer to the new hit for reconstruction, | |
553 | // or NULL in case of inefficiency or non tracking chamber or bad radius. | |
554 | // No condition on at most 20 cm from a muon from a resonance | |
555 | // like in Fortran TRACKF_STAT. | |
556 | AliMUONHitForRec* hitForRec; | |
557 | Double_t bendCoor, nonBendCoor, radius; | |
30d3ea8a | 558 | Int_t detElemId = Hit->UserId(), chamber = 0; |
559 | if (detElemId) chamber = detElemId / 100 - 1; | |
560 | else chamber = AliMUONConstants::ChamberNumber(Hit->Z()); // chamber(0...) | |
29fc2c86 | 561 | if (chamber < 0) return NULL; |
a9e2aefa | 562 | // only in tracking chambers (fChamber starts at 1) |
190f97ea | 563 | if (chamber >= AliMUONConstants::NTrackingCh()) return NULL; |
a9e2aefa | 564 | // only if hit is efficient (keep track for checking ????) |
565 | if (gRandom->Rndm() > fEfficiency) return NULL; | |
566 | // only if radius between RMin and RMax | |
94de3818 | 567 | bendCoor = Hit->Y(); |
568 | nonBendCoor = Hit->X(); | |
a9e2aefa | 569 | radius = TMath::Sqrt((bendCoor * bendCoor) + (nonBendCoor * nonBendCoor)); |
d0bfce8d | 570 | // This cut is not needed with a realistic chamber geometry !!!! |
571 | // if ((radius < fRMin[chamber]) || (radius > fRMax[chamber])) return NULL; | |
29fc2c86 | 572 | // new AliMUONHitForRec from track ref. hit and increment number of AliMUONHitForRec's |
a9e2aefa | 573 | hitForRec = new ((*fHitsForRecPtr)[fNHitsForRec]) AliMUONHitForRec(Hit); |
574 | fNHitsForRec++; | |
575 | // add smearing from resolution | |
576 | hitForRec->SetBendingCoor(bendCoor + gRandom->Gaus(0., fBendingResolution)); | |
577 | hitForRec->SetNonBendingCoor(nonBendCoor | |
578 | + gRandom->Gaus(0., fNonBendingResolution)); | |
d0bfce8d | 579 | // // !!!! without smearing |
580 | // hitForRec->SetBendingCoor(bendCoor); | |
581 | // hitForRec->SetNonBendingCoor(nonBendCoor); | |
a9e2aefa | 582 | // more information into HitForRec |
583 | // resolution: angular effect to be added here ???? | |
584 | hitForRec->SetBendingReso2(fBendingResolution * fBendingResolution); | |
585 | hitForRec->SetNonBendingReso2(fNonBendingResolution * fNonBendingResolution); | |
29fc2c86 | 586 | // track ref. info |
587 | hitForRec->SetTTRTrack(TrackNumber); | |
588 | hitForRec->SetTrackRefSignal(Signal); | |
b840996b | 589 | if (AliLog::GetGlobalDebugLevel()> 1) { |
590 | AliDebug(2,Form("Track: %d", TrackNumber)); | |
a9e2aefa | 591 | Hit->Dump(); |
592 | cout << "AliMUONHitForRec number (1...): " << fNHitsForRec << endl; | |
b840996b | 593 | hitForRec->Dump(); |
594 | } | |
a9e2aefa | 595 | return hitForRec; |
596 | } | |
29fc2c86 | 597 | //__________________________________________________________________________ |
29f1b13a | 598 | TClonesArray* AliMUONTrackReconstructor::CleanTrackRefs(TTree *treeTR) |
29fc2c86 | 599 | { |
600 | // Make hits from track ref.. | |
601 | // Re-calculate hits parameters because two AliTrackReferences are recorded for | |
602 | // each chamber (one when particle is entering + one when particle is leaving | |
603 | // the sensitive volume) | |
604 | ||
605 | AliTrackReference *trackReference; | |
606 | Float_t x1, y1, z1, pX1, pY1, pZ1; | |
607 | Float_t x2, y2, z2, pX2, pY2, pZ2; | |
608 | Int_t track1, track2; | |
609 | Int_t nRec = 0; | |
610 | Float_t maxGasGap = 1.; // cm | |
611 | Int_t iHit1 = 0; | |
612 | Int_t iHitMin = 0; | |
613 | ||
614 | AliTrackReference *trackReferenceNew = new AliTrackReference(); | |
615 | ||
616 | TClonesArray* trackRefs = new TClonesArray("AliTrackReference", 10); | |
617 | TClonesArray* cleanTrackRefs = new TClonesArray("AliTrackReference", 10); | |
618 | ||
619 | if (treeTR == NULL) return NULL; | |
620 | TBranch* branch = treeTR->GetBranch("MUON"); | |
621 | if (branch == NULL) return NULL; | |
622 | branch->SetAddress(&trackRefs); | |
623 | ||
624 | Int_t nTrack = (Int_t)treeTR->GetEntries(); | |
625 | for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { | |
626 | treeTR->GetEntry(iTrack); | |
627 | iHitMin = 0; | |
628 | iHit1 = 0; | |
629 | while (iHit1 < trackRefs->GetEntries()) { | |
630 | trackReference = (AliTrackReference*)trackRefs->At(iHit1); | |
631 | x1 = trackReference->X(); | |
632 | y1 = trackReference->Y(); | |
633 | z1 = trackReference->Z(); | |
634 | pX1 = trackReference->Px(); | |
635 | pY1 = trackReference->Py(); | |
636 | pZ1 = trackReference->Pz(); | |
637 | track1 = trackReference->GetTrack(); | |
638 | nRec = 1; | |
639 | iHitMin = iHit1+1; | |
640 | for (Int_t iHit2 = iHit1+1; iHit2 < trackRefs->GetEntries(); iHit2++) { | |
641 | trackReference = (AliTrackReference*)trackRefs->At(iHit2); | |
642 | x2 = trackReference->X(); | |
643 | y2 = trackReference->Y(); | |
644 | z2 = trackReference->Z(); | |
645 | pX2 = trackReference->Px(); | |
646 | pY2 = trackReference->Py(); | |
647 | pZ2 = trackReference->Pz(); | |
648 | track2 = trackReference->GetTrack(); | |
649 | if (track2 == track1 && TMath::Abs(z2-z1) < maxGasGap ) { | |
650 | nRec++; | |
651 | x1 += x2; | |
652 | y1 += y2; | |
653 | z1 += z2; | |
654 | pX1 += pX2; | |
655 | pY1 += pY2; | |
656 | pZ1 += pZ2; | |
657 | iHitMin = iHit2+1; | |
658 | } | |
659 | ||
660 | } // for iHit2 | |
661 | x1 /= (Float_t)nRec; | |
662 | y1 /= (Float_t)nRec; | |
663 | z1 /= (Float_t)nRec; | |
664 | pX1 /= (Float_t)nRec; | |
665 | pY1 /= (Float_t)nRec; | |
666 | pZ1 /= (Float_t)nRec; | |
667 | trackReferenceNew->SetPosition(x1,y1,z1); | |
668 | trackReferenceNew->SetMomentum(pX1,pY1,pZ1); | |
669 | trackReferenceNew->SetTrack(track1); | |
670 | {new ((*cleanTrackRefs)[cleanTrackRefs->GetEntriesFast()]) AliTrackReference(*trackReferenceNew);} | |
671 | iHit1 = iHitMin; | |
672 | } // while iHit1 | |
673 | } // for track | |
674 | ||
675 | trackRefs->Delete(); | |
676 | delete trackRefs; | |
677 | delete trackReferenceNew; | |
678 | return cleanTrackRefs; | |
679 | ||
680 | } | |
a9e2aefa | 681 | //__________________________________________________________________________ |
29f1b13a | 682 | void AliMUONTrackReconstructor::SortHitsForRecWithIncreasingChamber() |
a9e2aefa | 683 | { |
684 | // Sort HitsForRec's in increasing order with respect to chamber number. | |
685 | // Uses the function "Compare". | |
686 | // Update the information for HitsForRec per chamber too. | |
687 | Int_t ch, nhits, prevch; | |
688 | fHitsForRecPtr->Sort(); | |
190f97ea | 689 | for (ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) { |
a9e2aefa | 690 | fNHitsForRecPerChamber[ch] = 0; |
691 | fIndexOfFirstHitForRecPerChamber[ch] = 0; | |
692 | } | |
693 | prevch = 0; // previous chamber | |
694 | nhits = 0; // number of hits in current chamber | |
695 | // Loop over HitsForRec | |
696 | for (Int_t hit = 0; hit < fNHitsForRec; hit++) { | |
697 | // chamber number (0...) | |
698 | ch = ((AliMUONHitForRec*) ((*fHitsForRecPtr)[hit]))->GetChamberNumber(); | |
699 | // increment number of hits in current chamber | |
700 | (fNHitsForRecPerChamber[ch])++; | |
701 | // update index of first HitForRec in current chamber | |
702 | // if chamber number different from previous one | |
703 | if (ch != prevch) { | |
704 | fIndexOfFirstHitForRecPerChamber[ch] = hit; | |
705 | prevch = ch; | |
706 | } | |
707 | } | |
708 | return; | |
709 | } | |
710 | ||
a9e2aefa | 711 | //__________________________________________________________________________ |
29f1b13a | 712 | void AliMUONTrackReconstructor::AddHitsForRecFromRawClusters(TTree* TR) |
a9e2aefa | 713 | { |
714 | // To add to the list of hits for reconstruction all the raw clusters | |
715 | // No condition added, like in Fortran TRACKF_STAT, | |
716 | // on the radius between RMin and RMax. | |
717 | AliMUONHitForRec *hitForRec; | |
718 | AliMUONRawCluster *clus; | |
f69d51b5 | 719 | Int_t iclus, nclus, nTRentries; |
a9e2aefa | 720 | TClonesArray *rawclusters; |
b840996b | 721 | AliDebug(1,"Enter AddHitsForRecFromRawClusters"); |
88cb7938 | 722 | |
cc87ebcd | 723 | if (fTrackMethod != 3) { //AZ |
724 | fMUONData->SetTreeAddress("RC"); //AZ | |
725 | nTRentries = Int_t(TR->GetEntries()); | |
726 | if (nTRentries != 1) { | |
727 | AliError(Form("nTRentries = %d not equal to 1 ",nTRentries)); | |
728 | exit(0); | |
729 | } | |
730 | fLoader->TreeR()->GetEvent(0); // only one entry | |
f69d51b5 | 731 | } |
52c9bc11 | 732 | |
a9e2aefa | 733 | // Loop over tracking chambers |
190f97ea | 734 | for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) { |
a9e2aefa | 735 | // number of HitsForRec to 0 for the chamber |
736 | fNHitsForRecPerChamber[ch] = 0; | |
737 | // index of first HitForRec for the chamber | |
738 | if (ch == 0) fIndexOfFirstHitForRecPerChamber[ch] = 0; | |
739 | else fIndexOfFirstHitForRecPerChamber[ch] = fNHitsForRec; | |
52c9bc11 | 740 | rawclusters =fMUONData->RawClusters(ch); |
f69d51b5 | 741 | // pMUON->ResetRawClusters(); |
742 | // TR->GetEvent((Int_t) (TR->GetEntries()) - 1); // to be checked ???? | |
a9e2aefa | 743 | nclus = (Int_t) (rawclusters->GetEntries()); |
744 | // Loop over (cathode correlated) raw clusters | |
745 | for (iclus = 0; iclus < nclus; iclus++) { | |
746 | clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(iclus); | |
747 | // new AliMUONHitForRec from raw cluster | |
748 | // and increment number of AliMUONHitForRec's (total and in chamber) | |
749 | hitForRec = new ((*fHitsForRecPtr)[fNHitsForRec]) AliMUONHitForRec(clus); | |
750 | fNHitsForRec++; | |
751 | (fNHitsForRecPerChamber[ch])++; | |
752 | // more information into HitForRec | |
753 | // resolution: info should be already in raw cluster and taken from it ???? | |
fff097e0 | 754 | //hitForRec->SetBendingReso2(fBendingResolution * fBendingResolution); |
755 | //hitForRec->SetNonBendingReso2(fNonBendingResolution * fNonBendingResolution); | |
756 | hitForRec->SetBendingReso2(clus->GetErrY() * clus->GetErrY()); | |
757 | hitForRec->SetNonBendingReso2(clus->GetErrX() * clus->GetErrX()); | |
a9e2aefa | 758 | // original raw cluster |
759 | hitForRec->SetChamberNumber(ch); | |
760 | hitForRec->SetHitNumber(iclus); | |
ba5b68db | 761 | // Z coordinate of the raw cluster (cm) |
ba12c242 | 762 | hitForRec->SetZ(clus->GetZ(0)); |
b840996b | 763 | if (AliLog::GetGlobalDebugLevel() > 1) { |
a9e2aefa | 764 | cout << "chamber (0...): " << ch << |
765 | " raw cluster (0...): " << iclus << endl; | |
766 | clus->Dump(); | |
767 | cout << "AliMUONHitForRec number (1...): " << fNHitsForRec << endl; | |
768 | hitForRec->Dump();} | |
769 | } // end of cluster loop | |
770 | } // end of chamber loop | |
cc87ebcd | 771 | SortHitsForRecWithIncreasingChamber(); |
a9e2aefa | 772 | return; |
773 | } | |
774 | ||
775 | //__________________________________________________________________________ | |
29f1b13a | 776 | void AliMUONTrackReconstructor::MakeSegments(void) |
a9e2aefa | 777 | { |
778 | // To make the list of segments in all stations, | |
779 | // from the list of hits to be reconstructed | |
b840996b | 780 | AliDebug(1,"Enter MakeSegments"); |
fff097e0 | 781 | //AZ ResetSegments(); |
a9e2aefa | 782 | // Loop over stations |
cc87ebcd | 783 | Int_t nb = (fTrackMethod != 1) ? 3 : 0; //AZ |
784 | for (Int_t st = nb; st < AliMUONConstants::NTrackingCh()/2; st++) | |
a9e2aefa | 785 | MakeSegmentsPerStation(st); |
b840996b | 786 | if (AliLog::GetGlobalDebugLevel() > 1) { |
a9e2aefa | 787 | cout << "end of MakeSegments" << endl; |
190f97ea | 788 | for (Int_t st = 0; st < AliMUONConstants::NTrackingCh()/2; st++) { |
a9e2aefa | 789 | cout << "station(0...): " << st |
790 | << " Segments: " << fNSegments[st] | |
791 | << endl; | |
792 | for (Int_t seg = 0; | |
793 | seg < fNSegments[st]; | |
794 | seg++) { | |
795 | cout << "Segment index(0...): " << seg << endl; | |
796 | ((*fSegmentsPtr[st])[seg])->Dump(); | |
797 | } | |
798 | } | |
799 | } | |
800 | return; | |
801 | } | |
802 | ||
803 | //__________________________________________________________________________ | |
29f1b13a | 804 | void AliMUONTrackReconstructor::MakeSegmentsPerStation(Int_t Station) |
a9e2aefa | 805 | { |
806 | // To make the list of segments in station number "Station" (0...) | |
807 | // from the list of hits to be reconstructed. | |
808 | // Updates "fNSegments"[Station]. | |
809 | // Segments in stations 4 and 5 are sorted | |
810 | // according to increasing absolute value of "impact parameter" | |
811 | AliMUONHitForRec *hit1Ptr, *hit2Ptr; | |
812 | AliMUONSegment *segment; | |
813 | Bool_t last2st; | |
814 | Double_t bendingSlope, distBend, distNonBend, extBendCoor, extNonBendCoor, | |
d0bfce8d | 815 | impactParam = 0., maxImpactParam = 0., minImpactParam = 0.; // =0 to avoid compilation warnings. |
b840996b | 816 | AliDebug(1,Form("Enter MakeSegmentsPerStation (0...) %d",Station)); |
a9e2aefa | 817 | // first and second chambers (0...) in the station |
818 | Int_t ch1 = 2 * Station; | |
819 | Int_t ch2 = ch1 + 1; | |
820 | // variable true for stations downstream of the dipole: | |
821 | // Station(0..4) equal to 3 or 4 | |
822 | if ((Station == 3) || (Station == 4)) { | |
823 | last2st = kTRUE; | |
824 | // maximum impact parameter (cm) according to fMinBendingMomentum... | |
825 | maxImpactParam = | |
826 | TMath::Abs(GetImpactParamFromBendingMomentum(fMinBendingMomentum)); | |
d0bfce8d | 827 | // minimum impact parameter (cm) according to fMaxBendingMomentum... |
828 | minImpactParam = | |
829 | TMath::Abs(GetImpactParamFromBendingMomentum(fMaxBendingMomentum)); | |
a9e2aefa | 830 | } |
831 | else last2st = kFALSE; | |
832 | // extrapolation factor from Z of first chamber to Z of second chamber | |
833 | // dZ to be changed to take into account fine structure of chambers ???? | |
e516b01d | 834 | Double_t extrapFact; |
a9e2aefa | 835 | // index for current segment |
836 | Int_t segmentIndex = 0; | |
837 | // Loop over HitsForRec in the first chamber of the station | |
838 | for (Int_t hit1 = fIndexOfFirstHitForRecPerChamber[ch1]; | |
839 | hit1 < fIndexOfFirstHitForRecPerChamber[ch1] + fNHitsForRecPerChamber[ch1]; | |
840 | hit1++) { | |
841 | // pointer to the HitForRec | |
842 | hit1Ptr = (AliMUONHitForRec*) ((*fHitsForRecPtr)[hit1]); | |
843 | // extrapolation, | |
844 | // on the straight line joining the HitForRec to the vertex (0,0,0), | |
845 | // to the Z of the second chamber of the station | |
a9e2aefa | 846 | // Loop over HitsForRec in the second chamber of the station |
847 | for (Int_t hit2 = fIndexOfFirstHitForRecPerChamber[ch2]; | |
848 | hit2 < fIndexOfFirstHitForRecPerChamber[ch2] + fNHitsForRecPerChamber[ch2]; | |
849 | hit2++) { | |
850 | // pointer to the HitForRec | |
851 | hit2Ptr = (AliMUONHitForRec*) ((*fHitsForRecPtr)[hit2]); | |
852 | // absolute values of distances, in bending and non bending planes, | |
853 | // between the HitForRec in the second chamber | |
854 | // and the previous extrapolation | |
e516b01d | 855 | extrapFact = hit2Ptr->GetZ()/ hit1Ptr->GetZ(); |
856 | extBendCoor = extrapFact * hit1Ptr->GetBendingCoor(); | |
857 | extNonBendCoor = extrapFact * hit1Ptr->GetNonBendingCoor(); | |
a9e2aefa | 858 | distBend = TMath::Abs(hit2Ptr->GetBendingCoor() - extBendCoor); |
859 | distNonBend = TMath::Abs(hit2Ptr->GetNonBendingCoor() - extNonBendCoor); | |
860 | if (last2st) { | |
861 | // bending slope | |
8999d47d | 862 | if ( hit1Ptr->GetZ() - hit2Ptr->GetZ() != 0.0 ) { |
863 | bendingSlope = (hit1Ptr->GetBendingCoor() - hit2Ptr->GetBendingCoor()) / | |
864 | (hit1Ptr->GetZ() - hit2Ptr->GetZ()); | |
865 | // absolute value of impact parameter | |
866 | impactParam = | |
867 | TMath::Abs(hit1Ptr->GetBendingCoor() - hit1Ptr->GetZ() * bendingSlope); | |
868 | } | |
869 | else { | |
870 | AliWarning("hit1Ptr->GetZ() = hit2Ptr->GetZ(): impactParam set to maxImpactParam"); | |
871 | impactParam = maxImpactParam; | |
872 | } | |
a9e2aefa | 873 | } |
874 | // check for distances not too large, | |
875 | // and impact parameter not too big if stations downstream of the dipole. | |
876 | // Conditions "distBend" and "impactParam" correlated for these stations ???? | |
877 | if ((distBend < fSegmentMaxDistBending[Station]) && | |
878 | (distNonBend < fSegmentMaxDistNonBending[Station]) && | |
d0bfce8d | 879 | (!last2st || (impactParam < maxImpactParam)) && |
880 | (!last2st || (impactParam > minImpactParam))) { | |
a9e2aefa | 881 | // make new segment |
882 | segment = new ((*fSegmentsPtr[Station])[segmentIndex]) | |
883 | AliMUONSegment(hit1Ptr, hit2Ptr); | |
884 | // update "link" to this segment from the hit in the first chamber | |
885 | if (hit1Ptr->GetNSegments() == 0) | |
886 | hit1Ptr->SetIndexOfFirstSegment(segmentIndex); | |
887 | hit1Ptr->SetNSegments(hit1Ptr->GetNSegments() + 1); | |
b840996b | 888 | if (AliLog::GetGlobalDebugLevel() > 1) { |
a9e2aefa | 889 | cout << "segmentIndex(0...): " << segmentIndex |
890 | << " distBend: " << distBend | |
891 | << " distNonBend: " << distNonBend | |
892 | << endl; | |
893 | segment->Dump(); | |
894 | cout << "HitForRec in first chamber" << endl; | |
895 | hit1Ptr->Dump(); | |
896 | cout << "HitForRec in second chamber" << endl; | |
897 | hit2Ptr->Dump(); | |
898 | }; | |
899 | // increment index for current segment | |
900 | segmentIndex++; | |
901 | } | |
902 | } //for (Int_t hit2 | |
903 | } // for (Int_t hit1... | |
904 | fNSegments[Station] = segmentIndex; | |
905 | // Sorting according to "impact parameter" if station(1..5) 4 or 5, | |
906 | // i.e. Station(0..4) 3 or 4, using the function "Compare". | |
907 | // After this sorting, it is impossible to use | |
908 | // the "fNSegments" and "fIndexOfFirstSegment" | |
909 | // of the HitForRec in the first chamber to explore all segments formed with it. | |
910 | // Is this sorting really needed ???? | |
911 | if ((Station == 3) || (Station == 4)) (fSegmentsPtr[Station])->Sort(); | |
b840996b | 912 | AliDebug(1,Form("Station: %d NSegments: %d ", Station, fNSegments[Station])); |
a9e2aefa | 913 | return; |
914 | } | |
915 | ||
916 | //__________________________________________________________________________ | |
29f1b13a | 917 | void AliMUONTrackReconstructor::MakeTracks(void) |
a9e2aefa | 918 | { |
919 | // To make the tracks, | |
920 | // from the list of segments and points in all stations | |
b840996b | 921 | AliDebug(1,"Enter MakeTracks"); |
8429a5e4 | 922 | // The order may be important for the following Reset's |
fff097e0 | 923 | //AZ ResetTracks(); |
924 | //AZ ResetTrackHits(); | |
cc87ebcd | 925 | if (fTrackMethod != 1) { //AZ - Kalman filter |
83dbc640 | 926 | MakeTrackCandidatesK(); |
b035a148 | 927 | if (fRecTracksPtr->GetEntriesFast() == 0) return; |
83dbc640 | 928 | // Follow tracks in stations(1..) 3, 2 and 1 |
929 | FollowTracksK(); | |
930 | // Remove double tracks | |
931 | RemoveDoubleTracksK(); | |
932 | // Propagate tracks to the vertex thru absorber | |
933 | GoToVertex(); | |
b035a148 | 934 | // Fill AliMUONTrack data members |
935 | FillMUONTrack(); | |
d837040f | 936 | } else { |
83dbc640 | 937 | // Look for candidates from at least 3 aligned points in stations(1..) 4 and 5 |
938 | MakeTrackCandidates(); | |
939 | // Follow tracks in stations(1..) 3, 2 and 1 | |
940 | FollowTracks(); | |
941 | // Remove double tracks | |
942 | RemoveDoubleTracks(); | |
d837040f | 943 | UpdateTrackParamAtHit(); |
b8dc484b | 944 | UpdateHitForRecAtHit(); |
52c9bc11 | 945 | } |
a9e2aefa | 946 | return; |
947 | } | |
948 | ||
276c44b7 | 949 | //__________________________________________________________________________ |
29f1b13a | 950 | void AliMUONTrackReconstructor::ValidateTracksWithTrigger(void) |
d837040f | 951 | { |
7e6d7e07 | 952 | // Try to match track from tracking system with trigger track |
d837040f | 953 | AliMUONTrack *track; |
24ab3324 | 954 | TClonesArray *recTriggerTracks; |
955 | ||
24ab3324 | 956 | fMUONData->SetTreeAddress("RL"); |
957 | fMUONData->GetRecTriggerTracks(); | |
958 | recTriggerTracks = fMUONData->RecTriggerTracks(); | |
e8765288 | 959 | |
d837040f | 960 | track = (AliMUONTrack*) fRecTracksPtr->First(); |
961 | while (track) { | |
962 | track->MatchTriggerTrack(recTriggerTracks); | |
963 | track = (AliMUONTrack*) fRecTracksPtr->After(track); | |
e8765288 | 964 | } |
24ab3324 | 965 | |
d837040f | 966 | } |
967 | ||
968 | //__________________________________________________________________________ | |
29f1b13a | 969 | Bool_t AliMUONTrackReconstructor::MakeTriggerTracks(void) |
276c44b7 | 970 | { |
971 | // To make the trigger tracks from Local Trigger | |
b840996b | 972 | AliDebug(1, "Enter MakeTriggerTracks"); |
276c44b7 | 973 | |
974 | Int_t nTRentries; | |
52c9bc11 | 975 | Long_t gloTrigPat; |
276c44b7 | 976 | TClonesArray *localTrigger; |
9131b4fe | 977 | TClonesArray *globalTrigger; |
276c44b7 | 978 | AliMUONLocalTrigger *locTrg; |
9131b4fe | 979 | AliMUONGlobalTrigger *gloTrg; |
bc4a7ff4 | 980 | |
52c9bc11 | 981 | AliMUONTriggerTrack *recTriggerTrack = 0; |
d837040f | 982 | |
30178c30 | 983 | TTree* treeR = fLoader->TreeR(); |
276c44b7 | 984 | |
276c44b7 | 985 | // Loading MUON subsystem |
986 | AliMUON * pMUON = (AliMUON *) gAlice->GetDetector("MUON"); | |
bc4a7ff4 | 987 | // Not really clean, but for the moment we must check whether the |
988 | // trigger uses new or old TriggerCircuit | |
989 | Bool_t newTrigger=kFALSE; | |
990 | if ( pMUON->DigitizerType().Contains("NewTrigger") ) newTrigger = kTRUE; | |
991 | ||
30178c30 | 992 | nTRentries = Int_t(treeR->GetEntries()); |
d837040f | 993 | |
30178c30 | 994 | treeR->GetEvent(0); // only one entry |
d837040f | 995 | |
996 | if (!(fMUONData->IsTriggerBranchesInTree())) { | |
8c343c7c | 997 | AliWarning(Form("Trigger information is not avalaible, nTRentries = %d not equal to 1",nTRentries)); |
d837040f | 998 | return kFALSE; |
276c44b7 | 999 | } |
276c44b7 | 1000 | |
ce3e25a8 | 1001 | fMUONData->SetTreeAddress("TC"); |
52c9bc11 | 1002 | fMUONData->GetTrigger(); |
9131b4fe | 1003 | |
52c9bc11 | 1004 | // global trigger for trigger pattern |
9131b4fe | 1005 | gloTrigPat = 0; |
52c9bc11 | 1006 | globalTrigger = fMUONData->GlobalTrigger(); |
9131b4fe | 1007 | gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0); |
8efb0686 | 1008 | if (gloTrg) { |
1009 | if (gloTrg->SinglePlusLpt()) gloTrigPat|= 0x1; | |
1010 | if (gloTrg->SinglePlusHpt()) gloTrigPat|= 0x2; | |
1011 | if (gloTrg->SinglePlusApt()) gloTrigPat|= 0x4; | |
1012 | ||
1013 | if (gloTrg->SingleMinusLpt()) gloTrigPat|= 0x8; | |
1014 | if (gloTrg->SingleMinusHpt()) gloTrigPat|= 0x10; | |
1015 | if (gloTrg->SingleMinusApt()) gloTrigPat|= 0x20; | |
1016 | ||
1017 | if (gloTrg->SingleUndefLpt()) gloTrigPat|= 0x40; | |
1018 | if (gloTrg->SingleUndefHpt()) gloTrigPat|= 0x80; | |
1019 | if (gloTrg->SingleUndefApt()) gloTrigPat|= 0x100; | |
1020 | ||
1021 | if (gloTrg->PairUnlikeLpt()) gloTrigPat|= 0x200; | |
1022 | if (gloTrg->PairUnlikeHpt()) gloTrigPat|= 0x400; | |
1023 | if (gloTrg->PairUnlikeApt()) gloTrigPat|= 0x800; | |
1024 | ||
1025 | if (gloTrg->PairLikeLpt()) gloTrigPat|= 0x1000; | |
1026 | if (gloTrg->PairLikeHpt()) gloTrigPat|= 0x2000; | |
1027 | if (gloTrg->PairLikeApt()) gloTrigPat|= 0x4000; | |
1028 | } | |
9131b4fe | 1029 | |
52c9bc11 | 1030 | // local trigger for tracking |
1031 | localTrigger = fMUONData->LocalTrigger(); | |
276c44b7 | 1032 | Int_t nlocals = (Int_t) (localTrigger->GetEntries()); |
06c11448 | 1033 | |
1034 | Float_t z11 = AliMUONConstants::DefaultChamberZ(10); | |
1035 | Float_t z21 = AliMUONConstants::DefaultChamberZ(12); | |
276c44b7 | 1036 | |
bc4a7ff4 | 1037 | Float_t y11 = 0.; |
1038 | Int_t stripX21 = 0; | |
1039 | Float_t y21 = 0.; | |
1040 | Float_t x11 = 0.; | |
1041 | ||
276c44b7 | 1042 | for (Int_t i=0; i<nlocals; i++) { // loop on Local Trigger |
52c9bc11 | 1043 | locTrg = (AliMUONLocalTrigger*)localTrigger->UncheckedAt(i); |
bc4a7ff4 | 1044 | |
1045 | if (!newTrigger) { // old trigger | |
1046 | // printf("AliMUONTrackReconstructor::MakeTriggerTrack using OLD trigger \n"); | |
1047 | AliMUONTriggerCircuit * circuit = &(pMUON->TriggerCircuit(locTrg->LoCircuit())); | |
1048 | y11 = circuit->GetY11Pos(locTrg->LoStripX()); | |
1049 | stripX21 = locTrg->LoStripX()+locTrg->LoDev()+1; | |
1050 | y21 = circuit->GetY21Pos(stripX21); | |
1051 | x11 = circuit->GetX11Pos(locTrg->LoStripY()); | |
1052 | } else { // new trigger | |
1053 | // printf("AliMUONTrackReconstructor::MakeTriggerTrack using NEW trigger \n"); | |
1054 | AliMUONTriggerCircuitNew * circuit = | |
1055 | &(pMUON->TriggerCircuitNew(locTrg->LoCircuit()-1)); // -1 !!! | |
1056 | y11 = circuit->GetY11Pos(locTrg->LoStripX()); | |
1057 | stripX21 = locTrg->LoStripX()+locTrg->LoDev()+1; | |
1058 | y21 = circuit->GetY21Pos(stripX21); | |
1059 | x11 = circuit->GetX11Pos(locTrg->LoStripY()); | |
1060 | } | |
1061 | // printf(" MakeTriggerTrack %d %d %d %d %d %f %f %f \n",i,locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoStripX()+locTrg->LoDev()+1,locTrg->LoStripY(),y11, y21, x11); | |
1062 | ||
52c9bc11 | 1063 | Float_t thetax = TMath::ATan2( x11 , z11 ); |
1064 | Float_t thetay = TMath::ATan2( (y21-y11) , (z21-z11) ); | |
bc4a7ff4 | 1065 | |
7fe0032c | 1066 | recTriggerTrack = new AliMUONTriggerTrack(x11,y11,thetax,thetay,gloTrigPat); |
34f1bfa0 | 1067 | |
52c9bc11 | 1068 | // since static statement does not work, set gloTrigPat for each track |
bc4a7ff4 | 1069 | |
52c9bc11 | 1070 | fMUONData->AddRecTriggerTrack(*recTriggerTrack); |
34f1bfa0 | 1071 | delete recTriggerTrack; |
276c44b7 | 1072 | } // end of loop on Local Trigger |
d837040f | 1073 | return kTRUE; |
276c44b7 | 1074 | } |
1075 | ||
a9e2aefa | 1076 | //__________________________________________________________________________ |
29f1b13a | 1077 | Int_t AliMUONTrackReconstructor::MakeTrackCandidatesWithTwoSegments(AliMUONSegment *BegSegment) |
a9e2aefa | 1078 | { |
1079 | // To make track candidates with two segments in stations(1..) 4 and 5, | |
1080 | // the first segment being pointed to by "BegSegment". | |
1081 | // Returns the number of such track candidates. | |
1082 | Int_t endStation, iEndSegment, nbCan2Seg; | |
e516b01d | 1083 | AliMUONSegment *endSegment; |
1084 | AliMUONSegment *extrapSegment = NULL; | |
a9e2aefa | 1085 | AliMUONTrack *recTrack; |
1086 | Double_t mcsFactor; | |
b840996b | 1087 | AliDebug(1,"Enter MakeTrackCandidatesWithTwoSegments"); |
a9e2aefa | 1088 | // Station for the end segment |
1089 | endStation = 7 - (BegSegment->GetHitForRec1())->GetChamberNumber() / 2; | |
1090 | // multiple scattering factor corresponding to one chamber | |
1091 | mcsFactor = 0.0136 / | |
1092 | GetBendingMomentumFromImpactParam(BegSegment->GetBendingImpact()); | |
1093 | mcsFactor = fChamberThicknessInX0 * mcsFactor * mcsFactor; | |
1094 | // linear extrapolation to end station | |
a9e2aefa | 1095 | // number of candidates with 2 segments to 0 |
1096 | nbCan2Seg = 0; | |
1097 | // Loop over segments in the end station | |
1098 | for (iEndSegment = 0; iEndSegment < fNSegments[endStation]; iEndSegment++) { | |
1099 | // pointer to segment | |
1100 | endSegment = (AliMUONSegment*) ((*fSegmentsPtr[endStation])[iEndSegment]); | |
1101 | // test compatibility between current segment and "extrapSegment" | |
04b5ea16 | 1102 | // 4 because 4 quantities in chi2 |
e516b01d | 1103 | extrapSegment = |
1104 | BegSegment->CreateSegmentFromLinearExtrapToStation(endSegment->GetZ(), mcsFactor); | |
a9e2aefa | 1105 | if ((endSegment-> |
1106 | NormalizedChi2WithSegment(extrapSegment, | |
1107 | fMaxSigma2Distance)) <= 4.0) { | |
1108 | // both segments compatible: | |
1109 | // make track candidate from "begSegment" and "endSegment" | |
b840996b | 1110 | AliDebug(2,Form("TrackCandidate with Segment %d in Station(0..) %d", iEndSegment, endStation)); |
a9e2aefa | 1111 | // flag for both segments in one track: |
1112 | // to be done in track constructor ???? | |
1113 | BegSegment->SetInTrack(kTRUE); | |
1114 | endSegment->SetInTrack(kTRUE); | |
1115 | recTrack = new ((*fRecTracksPtr)[fNRecTracks]) | |
1116 | AliMUONTrack(BegSegment, endSegment, this); | |
1117 | fNRecTracks++; | |
b840996b | 1118 | if (AliLog::GetGlobalDebugLevel() > 1) recTrack->RecursiveDump(); |
a9e2aefa | 1119 | // increment number of track candidates with 2 segments |
1120 | nbCan2Seg++; | |
1121 | } | |
ddf8948c | 1122 | delete extrapSegment; // should not delete HitForRec's it points to !!!! |
a9e2aefa | 1123 | } // for (iEndSegment = 0;... |
a9e2aefa | 1124 | return nbCan2Seg; |
1125 | } | |
1126 | ||
1127 | //__________________________________________________________________________ | |
29f1b13a | 1128 | Int_t AliMUONTrackReconstructor::MakeTrackCandidatesWithOneSegmentAndOnePoint(AliMUONSegment *BegSegment) |
a9e2aefa | 1129 | { |
1130 | // To make track candidates with one segment and one point | |
1131 | // in stations(1..) 4 and 5, | |
1132 | // the segment being pointed to by "BegSegment". | |
1133 | Int_t ch, ch1, ch2, endStation, iHit, iHitMax, iHitMin, nbCan1Seg1Hit; | |
e516b01d | 1134 | AliMUONHitForRec *extrapHitForRec= NULL; |
1135 | AliMUONHitForRec *hit; | |
a9e2aefa | 1136 | AliMUONTrack *recTrack; |
1137 | Double_t mcsFactor; | |
b840996b | 1138 | AliDebug(1,"Enter MakeTrackCandidatesWithOneSegmentAndOnePoint"); |
a9e2aefa | 1139 | // station for the end point |
1140 | endStation = 7 - (BegSegment->GetHitForRec1())->GetChamberNumber() / 2; | |
1141 | // multiple scattering factor corresponding to one chamber | |
1142 | mcsFactor = 0.0136 / | |
1143 | GetBendingMomentumFromImpactParam(BegSegment->GetBendingImpact()); | |
1144 | mcsFactor = fChamberThicknessInX0 * mcsFactor * mcsFactor; | |
1145 | // first and second chambers(0..) in the end station | |
1146 | ch1 = 2 * endStation; | |
1147 | ch2 = ch1 + 1; | |
1148 | // number of candidates to 0 | |
1149 | nbCan1Seg1Hit = 0; | |
1150 | // Loop over chambers of the end station | |
1151 | for (ch = ch2; ch >= ch1; ch--) { | |
a9e2aefa | 1152 | // limits for the hit index in the loop |
1153 | iHitMin = fIndexOfFirstHitForRecPerChamber[ch]; | |
1154 | iHitMax = iHitMin + fNHitsForRecPerChamber[ch]; | |
1155 | // Loop over HitForRec's in the chamber | |
1156 | for (iHit = iHitMin; iHit < iHitMax; iHit++) { | |
1157 | // pointer to HitForRec | |
1158 | hit = (AliMUONHitForRec*) ((*fHitsForRecPtr)[iHit]); | |
1159 | // test compatibility between current HitForRec and "extrapHitForRec" | |
04b5ea16 | 1160 | // 2 because 2 quantities in chi2 |
e516b01d | 1161 | // linear extrapolation to chamber |
1162 | extrapHitForRec = | |
1163 | BegSegment->CreateHitForRecFromLinearExtrapToChamber( hit->GetZ(), mcsFactor); | |
a9e2aefa | 1164 | if ((hit-> |
1165 | NormalizedChi2WithHitForRec(extrapHitForRec, | |
1166 | fMaxSigma2Distance)) <= 2.0) { | |
1167 | // both HitForRec's compatible: | |
1168 | // make track candidate from begSegment and current HitForRec | |
b840996b | 1169 | AliDebug(2, Form("TrackCandidate with HitForRec %d in Chamber(0..) %d", iHit, ch)); |
a9e2aefa | 1170 | // flag for beginning segments in one track: |
1171 | // to be done in track constructor ???? | |
1172 | BegSegment->SetInTrack(kTRUE); | |
1173 | recTrack = new ((*fRecTracksPtr)[fNRecTracks]) | |
1174 | AliMUONTrack(BegSegment, hit, this); | |
1175 | // the right place to eliminate "double counting" ???? how ???? | |
1176 | fNRecTracks++; | |
b840996b | 1177 | if (AliLog::GetGlobalDebugLevel() > 1) recTrack->RecursiveDump(); |
a9e2aefa | 1178 | // increment number of track candidates |
1179 | nbCan1Seg1Hit++; | |
1180 | } | |
ddf8948c | 1181 | delete extrapHitForRec; |
a9e2aefa | 1182 | } // for (iHit = iHitMin;... |
a9e2aefa | 1183 | } // for (ch = ch2;... |
1184 | return nbCan1Seg1Hit; | |
1185 | } | |
1186 | ||
1187 | //__________________________________________________________________________ | |
29f1b13a | 1188 | void AliMUONTrackReconstructor::MakeTrackCandidates(void) |
a9e2aefa | 1189 | { |
1190 | // To make track candidates | |
1191 | // with at least 3 aligned points in stations(1..) 4 and 5 | |
1192 | // (two Segment's or one Segment and one HitForRec) | |
1193 | Int_t begStation, iBegSegment, nbCan1Seg1Hit, nbCan2Seg; | |
1194 | AliMUONSegment *begSegment; | |
b840996b | 1195 | AliDebug(1,"Enter MakeTrackCandidates"); |
a9e2aefa | 1196 | // Loop over stations(1..) 5 and 4 for the beginning segment |
1197 | for (begStation = 4; begStation > 2; begStation--) { | |
1198 | // Loop over segments in the beginning station | |
1199 | for (iBegSegment = 0; iBegSegment < fNSegments[begStation]; iBegSegment++) { | |
1200 | // pointer to segment | |
1201 | begSegment = (AliMUONSegment*) ((*fSegmentsPtr[begStation])[iBegSegment]); | |
b840996b | 1202 | AliDebug(2,Form("Look for TrackCandidate's with Segment %d in Station(0..) %d", iBegSegment, begStation)); |
a9e2aefa | 1203 | // Look for track candidates with two segments, |
1204 | // "begSegment" and all compatible segments in other station. | |
1205 | // Only for beginning station(1..) 5 | |
1206 | // because candidates with 2 segments have to looked for only once. | |
1207 | if (begStation == 4) | |
1208 | nbCan2Seg = MakeTrackCandidatesWithTwoSegments(begSegment); | |
956019b6 | 1209 | // Look for track candidates with one segment and one point, |
a9e2aefa | 1210 | // "begSegment" and all compatible HitForRec's in other station. |
1211 | // Only if "begSegment" does not belong already to a track candidate. | |
1212 | // Is that a too strong condition ???? | |
1213 | if (!(begSegment->GetInTrack())) | |
1214 | nbCan1Seg1Hit = MakeTrackCandidatesWithOneSegmentAndOnePoint(begSegment); | |
1215 | } // for (iBegSegment = 0;... | |
1216 | } // for (begStation = 4;... | |
1217 | return; | |
1218 | } | |
1219 | ||
1220 | //__________________________________________________________________________ | |
29f1b13a | 1221 | void AliMUONTrackReconstructor::FollowTracks(void) |
a9e2aefa | 1222 | { |
1223 | // Follow tracks in stations(1..) 3, 2 and 1 | |
04b5ea16 | 1224 | // too long: should be made more modular !!!! |
e516b01d | 1225 | AliMUONHitForRec *bestHit, *extrapHit, *hit; |
1226 | AliMUONSegment *bestSegment, *extrapSegment, *segment; | |
04b5ea16 | 1227 | AliMUONTrack *track, *nextTrack; |
1228 | AliMUONTrackParam *trackParam1, trackParam[2], trackParamVertex; | |
ecfa008b | 1229 | // -1 to avoid compilation warnings |
1230 | Int_t ch = -1, chInStation, chBestHit = -1, iHit, iSegment, station, trackIndex; | |
04b5ea16 | 1231 | Double_t bestChi2, chi2, dZ1, dZ2, dZ3, maxSigma2Distance, mcsFactor; |
d0bfce8d | 1232 | Double_t bendingMomentum, chi2Norm = 0.; |
cc87ebcd | 1233 | |
04b5ea16 | 1234 | // local maxSigma2Distance, for easy increase in testing |
1235 | maxSigma2Distance = fMaxSigma2Distance; | |
b840996b | 1236 | AliDebug(2,"Enter FollowTracks"); |
a9e2aefa | 1237 | // Loop over track candidates |
04b5ea16 | 1238 | track = (AliMUONTrack*) fRecTracksPtr->First(); |
1239 | trackIndex = -1; | |
1240 | while (track) { | |
1241 | // Follow function for each track candidate ???? | |
1242 | trackIndex++; | |
1243 | nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track); // prepare next track | |
b840996b | 1244 | AliDebug(2,Form("FollowTracks: track candidate(0..): %d", trackIndex)); |
956019b6 | 1245 | // Fit track candidate |
1246 | track->SetFitMCS(0); // without multiple Coulomb scattering | |
1247 | track->SetFitNParam(3); // with 3 parameters (X = Y = 0) | |
1248 | track->SetFitStart(0); // from parameters at vertex | |
1249 | track->Fit(); | |
b840996b | 1250 | if (AliLog::GetGlobalDebugLevel()> 2) { |
a9e2aefa | 1251 | cout << "FollowTracks: track candidate(0..): " << trackIndex |
956019b6 | 1252 | << " after fit in stations(0..) 3 and 4" << endl; |
a9e2aefa | 1253 | track->RecursiveDump(); |
1254 | } | |
1255 | // Loop over stations(1..) 3, 2 and 1 | |
04b5ea16 | 1256 | // something SPECIAL for stations 2 and 1 for majority 3 coincidence ???? |
1257 | // otherwise: majority coincidence 2 !!!! | |
a9e2aefa | 1258 | for (station = 2; station >= 0; station--) { |
1259 | // Track parameters at first track hit (smallest Z) | |
1260 | trackParam1 = ((AliMUONTrackHit*) | |
1261 | (track->GetTrackHitsPtr()->First()))->GetTrackParam(); | |
1262 | // extrapolation to station | |
1263 | trackParam1->ExtrapToStation(station, trackParam); | |
79e1e601 | 1264 | extrapSegment = new AliMUONSegment(); // empty segment |
a9e2aefa | 1265 | // multiple scattering factor corresponding to one chamber |
1266 | // and momentum in bending plane (not total) | |
1267 | mcsFactor = 0.0136 * trackParam1->GetInverseBendingMomentum(); | |
1268 | mcsFactor = fChamberThicknessInX0 * mcsFactor * mcsFactor; | |
1269 | // Z difference from previous station | |
f93b9bd8 | 1270 | dZ1 = AliMUONConstants::DefaultChamberZ(2 * station) - |
1271 | AliMUONConstants::DefaultChamberZ(2 * station + 2); | |
a9e2aefa | 1272 | // Z difference between the two previous stations |
f93b9bd8 | 1273 | dZ2 = AliMUONConstants::DefaultChamberZ(2 * station + 2) - |
1274 | AliMUONConstants::DefaultChamberZ(2 * station + 4); | |
04b5ea16 | 1275 | // Z difference between the two chambers in the previous station |
f93b9bd8 | 1276 | dZ3 = AliMUONConstants::DefaultChamberZ(2 * station) - |
1277 | AliMUONConstants::DefaultChamberZ(2 * station + 1); | |
04b5ea16 | 1278 | extrapSegment->SetBendingCoorReso2(fBendingResolution * fBendingResolution); |
1279 | extrapSegment-> | |
1280 | SetNonBendingCoorReso2(fNonBendingResolution * fNonBendingResolution); | |
1281 | extrapSegment->UpdateFromStationTrackParam | |
1282 | (trackParam, mcsFactor, dZ1, dZ2, dZ3, station, | |
1283 | trackParam1->GetInverseBendingMomentum()); | |
a9e2aefa | 1284 | bestChi2 = 5.0; |
1285 | bestSegment = NULL; | |
b840996b | 1286 | if (AliLog::GetGlobalDebugLevel() > 2) { |
a9e2aefa | 1287 | cout << "FollowTracks: track candidate(0..): " << trackIndex |
1288 | << " Look for segment in station(0..): " << station << endl; | |
1289 | } | |
1290 | // Loop over segments in station | |
1291 | for (iSegment = 0; iSegment < fNSegments[station]; iSegment++) { | |
1292 | // Look for best compatible Segment in station | |
1293 | // should consider all possibilities ???? | |
1294 | // multiple scattering ???? | |
1295 | // separation in 2 functions: Segment and HitForRec ???? | |
1296 | segment = (AliMUONSegment*) ((*fSegmentsPtr[station])[iSegment]); | |
d0bfce8d | 1297 | // correction of corrected segment (fBendingCoor and fNonBendingCoor) |
1298 | // according to real Z value of "segment" and slopes of "extrapSegment" | |
e516b01d | 1299 | (&(trackParam[0]))->ExtrapToZ(segment->GetZ()); |
1300 | (&(trackParam[1]))->ExtrapToZ(segment->GetZ()); | |
1301 | extrapSegment->SetBendingCoor((&(trackParam[0]))->GetBendingCoor()); | |
1302 | extrapSegment->SetNonBendingCoor((&(trackParam[0]))->GetNonBendingCoor()); | |
1303 | extrapSegment->SetBendingSlope((&(trackParam[0]))->GetBendingSlope()); | |
1304 | extrapSegment->SetNonBendingSlope((&(trackParam[0]))->GetNonBendingSlope()); | |
d0bfce8d | 1305 | chi2 = segment-> |
e516b01d | 1306 | NormalizedChi2WithSegment(extrapSegment, maxSigma2Distance); |
a9e2aefa | 1307 | if (chi2 < bestChi2) { |
1308 | // update best Chi2 and Segment if better found | |
1309 | bestSegment = segment; | |
1310 | bestChi2 = chi2; | |
1311 | } | |
1312 | } | |
1313 | if (bestSegment) { | |
1314 | // best segment found: add it to track candidate | |
e516b01d | 1315 | (&(trackParam[0]))->ExtrapToZ(bestSegment->GetZ()); |
1316 | (&(trackParam[1]))->ExtrapToZ(bestSegment->GetZ()); | |
a9e2aefa | 1317 | track->AddSegment(bestSegment); |
1318 | // set track parameters at these two TrakHit's | |
1319 | track->SetTrackParamAtHit(track->GetNTrackHits() - 2, &(trackParam[0])); | |
1320 | track->SetTrackParamAtHit(track->GetNTrackHits() - 1, &(trackParam[1])); | |
b840996b | 1321 | AliDebug(3, Form("FollowTracks: track candidate(0..): %d Added segment in station(0..): %d", trackIndex, station)); |
1322 | if (AliLog::GetGlobalDebugLevel()>2) track->RecursiveDump(); | |
a9e2aefa | 1323 | } |
1324 | else { | |
1325 | // No best segment found: | |
1326 | // Look for best compatible HitForRec in station: | |
1327 | // should consider all possibilities ???? | |
1328 | // multiple scattering ???? do about like for extrapSegment !!!! | |
79e1e601 | 1329 | extrapHit = new AliMUONHitForRec(); // empty hit |
a9e2aefa | 1330 | bestChi2 = 3.0; |
1331 | bestHit = NULL; | |
b840996b | 1332 | AliDebug(3, Form("FollowTracks: track candidate(0..): %d Segment not found, look for hit in station(0..): %d ", |
1333 | trackIndex, station)); | |
1334 | ||
a9e2aefa | 1335 | // Loop over chambers of the station |
d82671a0 | 1336 | for (chInStation = 0; chInStation < 2; chInStation++) { |
956019b6 | 1337 | ch = 2 * station + chInStation; |
a9e2aefa | 1338 | for (iHit = fIndexOfFirstHitForRecPerChamber[ch]; |
1339 | iHit < fIndexOfFirstHitForRecPerChamber[ch] + | |
1340 | fNHitsForRecPerChamber[ch]; | |
1341 | iHit++) { | |
1342 | hit = (AliMUONHitForRec*) ((*fHitsForRecPtr)[iHit]); | |
e516b01d | 1343 | // coordinates of extrapolated hit |
1344 | (&(trackParam[chInStation]))->ExtrapToZ(hit->GetZ()); | |
1345 | extrapHit-> | |
1346 | SetBendingCoor((&(trackParam[chInStation]))->GetBendingCoor()); | |
1347 | extrapHit-> | |
1348 | SetNonBendingCoor((&(trackParam[chInStation]))->GetNonBendingCoor()); | |
1349 | // resolutions from "extrapSegment" | |
1350 | extrapHit->SetBendingReso2(extrapSegment->GetBendingCoorReso2()); | |
1351 | extrapHit->SetNonBendingReso2(extrapSegment->GetNonBendingCoorReso2()); | |
1352 | // Loop over hits in the chamber | |
a9e2aefa | 1353 | // condition for hit not already in segment ???? |
1354 | chi2 = hit->NormalizedChi2WithHitForRec(extrapHit, maxSigma2Distance); | |
1355 | if (chi2 < bestChi2) { | |
1356 | // update best Chi2 and HitForRec if better found | |
1357 | bestHit = hit; | |
1358 | bestChi2 = chi2; | |
d82671a0 | 1359 | chBestHit = chInStation; |
a9e2aefa | 1360 | } |
1361 | } | |
1362 | } | |
1363 | if (bestHit) { | |
1364 | // best hit found: add it to track candidate | |
e516b01d | 1365 | (&(trackParam[chBestHit]))->ExtrapToZ(bestHit->GetZ()); |
a9e2aefa | 1366 | track->AddHitForRec(bestHit); |
956019b6 | 1367 | // set track parameters at this TrackHit |
a9e2aefa | 1368 | track->SetTrackParamAtHit(track->GetNTrackHits() - 1, |
1369 | &(trackParam[chBestHit])); | |
b840996b | 1370 | if (AliLog::GetGlobalDebugLevel() > 2) { |
a9e2aefa | 1371 | cout << "FollowTracks: track candidate(0..): " << trackIndex |
1372 | << " Added hit in station(0..): " << station << endl; | |
1373 | track->RecursiveDump(); | |
1374 | } | |
1375 | } | |
1376 | else { | |
8429a5e4 | 1377 | // Remove current track candidate |
1378 | // and corresponding TrackHit's, ... | |
1379 | track->Remove(); | |
04b5ea16 | 1380 | delete extrapSegment; |
d0bfce8d | 1381 | delete extrapHit; |
a9e2aefa | 1382 | break; // stop the search for this candidate: |
1383 | // exit from the loop over station | |
1384 | } | |
d0bfce8d | 1385 | delete extrapHit; |
a9e2aefa | 1386 | } |
04b5ea16 | 1387 | delete extrapSegment; |
a9e2aefa | 1388 | // Sort track hits according to increasing Z |
1389 | track->GetTrackHitsPtr()->Sort(); | |
1390 | // Update track parameters at first track hit (smallest Z) | |
1391 | trackParam1 = ((AliMUONTrackHit*) | |
1392 | (track->GetTrackHitsPtr()->First()))->GetTrackParam(); | |
d0bfce8d | 1393 | bendingMomentum = 0.; |
1394 | if (TMath::Abs(trackParam1->GetInverseBendingMomentum()) > 0.) | |
1395 | bendingMomentum = TMath::Abs(1/(trackParam1->GetInverseBendingMomentum())); | |
1396 | // Track removed if bendingMomentum not in window [min, max] | |
1397 | if ((bendingMomentum < fMinBendingMomentum) || (bendingMomentum > fMaxBendingMomentum)) { | |
1398 | track->Remove(); | |
1399 | break; // stop the search for this candidate: | |
1400 | // exit from the loop over station | |
1401 | } | |
956019b6 | 1402 | // Track fit |
04b5ea16 | 1403 | // with multiple Coulomb scattering if all stations |
1404 | if (station == 0) track->SetFitMCS(1); | |
956019b6 | 1405 | // without multiple Coulomb scattering if not all stations |
04b5ea16 | 1406 | else track->SetFitMCS(0); |
956019b6 | 1407 | track->SetFitNParam(5); // with 5 parameters (momentum and position) |
1408 | track->SetFitStart(1); // from parameters at first hit | |
1409 | track->Fit(); | |
d0bfce8d | 1410 | Double_t numberOfDegFree = (2.0 * track->GetNTrackHits() - 5); |
1411 | if (numberOfDegFree > 0) { | |
1412 | chi2Norm = track->GetFitFMin() / numberOfDegFree; | |
1413 | } else { | |
1414 | chi2Norm = 1.e10; | |
1415 | } | |
1416 | // Track removed if normalized chi2 too high | |
1417 | if (chi2Norm > fMaxChi2) { | |
1418 | track->Remove(); | |
1419 | break; // stop the search for this candidate: | |
1420 | // exit from the loop over station | |
1421 | } | |
b840996b | 1422 | if (AliLog::GetGlobalDebugLevel() > 2) { |
a9e2aefa | 1423 | cout << "FollowTracks: track candidate(0..): " << trackIndex |
1424 | << " after fit from station(0..): " << station << " to 4" << endl; | |
1425 | track->RecursiveDump(); | |
1426 | } | |
04b5ea16 | 1427 | // Track extrapolation to the vertex through the absorber (Branson) |
956019b6 | 1428 | // after going through the first station |
04b5ea16 | 1429 | if (station == 0) { |
1430 | trackParamVertex = *trackParam1; | |
889a0215 | 1431 | (&trackParamVertex)->ExtrapToVertex(0.,0.,0.); |
04b5ea16 | 1432 | track->SetTrackParamAtVertex(&trackParamVertex); |
b840996b | 1433 | if (AliLog::GetGlobalDebugLevel() > 0) { |
6ae236ee | 1434 | cout << "FollowTracks: track candidate(0..): " << trackIndex |
1435 | << " after extrapolation to vertex" << endl; | |
1436 | track->RecursiveDump(); | |
1437 | } | |
04b5ea16 | 1438 | } |
a9e2aefa | 1439 | } // for (station = 2;... |
04b5ea16 | 1440 | // go really to next track |
1441 | track = nextTrack; | |
1442 | } // while (track) | |
1443 | // Compression of track array (necessary after Remove ????) | |
1444 | fRecTracksPtr->Compress(); | |
1445 | return; | |
1446 | } | |
1447 | ||
1448 | //__________________________________________________________________________ | |
29f1b13a | 1449 | void AliMUONTrackReconstructor::RemoveDoubleTracks(void) |
8429a5e4 | 1450 | { |
1451 | // To remove double tracks. | |
1452 | // Tracks are considered identical | |
1453 | // if they have at least half of their hits in common. | |
1454 | // Among two identical tracks, one keeps the track with the larger number of hits | |
1455 | // or, if these numbers are equal, the track with the minimum Chi2. | |
1456 | AliMUONTrack *track1, *track2, *trackToRemove; | |
1457 | Bool_t identicalTracks; | |
1458 | Int_t hitsInCommon, nHits1, nHits2; | |
1459 | identicalTracks = kTRUE; | |
1460 | while (identicalTracks) { | |
1461 | identicalTracks = kFALSE; | |
1462 | // Loop over first track of the pair | |
1463 | track1 = (AliMUONTrack*) fRecTracksPtr->First(); | |
1464 | while (track1 && (!identicalTracks)) { | |
1465 | nHits1 = track1->GetNTrackHits(); | |
1466 | // Loop over second track of the pair | |
1467 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
1468 | while (track2 && (!identicalTracks)) { | |
1469 | nHits2 = track2->GetNTrackHits(); | |
1470 | // number of hits in common between two tracks | |
1471 | hitsInCommon = track1->HitsInCommon(track2); | |
1472 | // check for identical tracks | |
1473 | if ((4 * hitsInCommon) >= (nHits1 + nHits2)) { | |
1474 | identicalTracks = kTRUE; | |
1475 | // decide which track to remove | |
1476 | if (nHits1 > nHits2) trackToRemove = track2; | |
1477 | else if (nHits1 < nHits2) trackToRemove = track1; | |
1478 | else if ((track1->GetFitFMin()) < (track2->GetFitFMin())) | |
1479 | trackToRemove = track2; | |
1480 | else trackToRemove = track1; | |
1481 | // remove it | |
1482 | trackToRemove->Remove(); | |
1483 | } | |
1484 | track2 = (AliMUONTrack*) fRecTracksPtr->After(track2); | |
1485 | } // track2 | |
1486 | track1 = (AliMUONTrack*) fRecTracksPtr->After(track1); | |
1487 | } // track1 | |
1488 | } | |
1489 | return; | |
1490 | } | |
1491 | ||
d837040f | 1492 | //__________________________________________________________________________ |
29f1b13a | 1493 | void AliMUONTrackReconstructor::UpdateTrackParamAtHit() |
d837040f | 1494 | { |
1495 | // Set track parameters after track fitting. Fill fTrackParamAtHit of AliMUONTrack's | |
1496 | AliMUONTrack *track; | |
1497 | AliMUONTrackHit *trackHit; | |
1498 | AliMUONTrackParam *trackParam; | |
1499 | track = (AliMUONTrack*) fRecTracksPtr->First(); | |
1500 | while (track) { | |
1501 | trackHit = (AliMUONTrackHit*) (track->GetTrackHitsPtr())->First(); | |
1502 | while (trackHit) { | |
1503 | trackParam = trackHit->GetTrackParam(); | |
1504 | track->AddTrackParamAtHit(trackParam); | |
1505 | trackHit = (AliMUONTrackHit*) (track->GetTrackHitsPtr())->After(trackHit); | |
1506 | } // trackHit | |
1507 | track = (AliMUONTrack*) fRecTracksPtr->After(track); | |
1508 | } // track | |
1509 | return; | |
1510 | } | |
1511 | ||
b8dc484b | 1512 | //__________________________________________________________________________ |
29f1b13a | 1513 | void AliMUONTrackReconstructor::UpdateHitForRecAtHit() |
b8dc484b | 1514 | { |
1515 | // Set cluster parameterss after track fitting. Fill fHitForRecAtHit of AliMUONTrack's | |
1516 | AliMUONTrack *track; | |
1517 | AliMUONTrackHit *trackHit; | |
1518 | AliMUONHitForRec *hitForRec; | |
1519 | track = (AliMUONTrack*) fRecTracksPtr->First(); | |
1520 | while (track) { | |
1521 | trackHit = (AliMUONTrackHit*) (track->GetTrackHitsPtr())->First(); | |
1522 | while (trackHit) { | |
1523 | hitForRec = trackHit->GetHitForRecPtr(); | |
1524 | track->AddHitForRecAtHit(hitForRec); | |
1525 | trackHit = (AliMUONTrackHit*) (track->GetTrackHitsPtr())->After(trackHit); | |
1526 | } // trackHit | |
1527 | track = (AliMUONTrack*) fRecTracksPtr->After(track); | |
1528 | } // track | |
1529 | return; | |
1530 | } | |
1531 | ||
b035a148 | 1532 | //__________________________________________________________________________ |
29f1b13a | 1533 | void AliMUONTrackReconstructor::FillMUONTrack() |
b035a148 | 1534 | { |
1535 | // Set track parameters at hits for Kalman track. Fill fTrackParamAtHit of AliMUONTrack's | |
1536 | AliMUONTrackK *track; | |
1537 | track = (AliMUONTrackK*) fRecTracksPtr->First(); | |
1538 | while (track) { | |
1539 | track->FillMUONTrack(); | |
1540 | track = (AliMUONTrackK*) fRecTracksPtr->After(track); | |
1541 | } | |
1542 | return; | |
1543 | } | |
1544 | ||
8429a5e4 | 1545 | //__________________________________________________________________________ |
29f1b13a | 1546 | void AliMUONTrackReconstructor::EventDump(void) |
04b5ea16 | 1547 | { |
1548 | // Dump reconstructed event (track parameters at vertex and at first hit), | |
1549 | // and the particle parameters | |
1550 | ||
1551 | AliMUONTrack *track; | |
1552 | AliMUONTrackParam *trackParam, *trackParam1; | |
04b5ea16 | 1553 | Double_t bendingSlope, nonBendingSlope, pYZ; |
1554 | Double_t pX, pY, pZ, x, y, z, c; | |
1555 | Int_t np, trackIndex, nTrackHits; | |
1556 | ||
b840996b | 1557 | AliDebug(1,"****** enter EventDump ******"); |
1558 | AliDebug(1, Form("Number of Reconstructed tracks : %d", fNRecTracks)); | |
1559 | ||
04b5ea16 | 1560 | fRecTracksPtr->Compress(); // for simple loop without "Next" since no hole |
1561 | // Loop over reconstructed tracks | |
1562 | for (trackIndex = 0; trackIndex < fNRecTracks; trackIndex++) { | |
83dbc640 | 1563 | if (fTrackMethod != 1) continue; //AZ - skip the rest for now |
b840996b | 1564 | AliDebug(1, Form("track number: %d", trackIndex)); |
04b5ea16 | 1565 | // function for each track for modularity ???? |
1566 | track = (AliMUONTrack*) ((*fRecTracksPtr)[trackIndex]); | |
1567 | nTrackHits = track->GetNTrackHits(); | |
b840996b | 1568 | AliDebug(1, Form("Number of track hits: %d ", nTrackHits)); |
04b5ea16 | 1569 | // track parameters at Vertex |
1570 | trackParam = track->GetTrackParamAtVertex(); | |
1571 | x = trackParam->GetNonBendingCoor(); | |
1572 | y = trackParam->GetBendingCoor(); | |
1573 | z = trackParam->GetZ(); | |
1574 | bendingSlope = trackParam->GetBendingSlope(); | |
1575 | nonBendingSlope = trackParam->GetNonBendingSlope(); | |
1576 | pYZ = 1/TMath::Abs(trackParam->GetInverseBendingMomentum()); | |
1577 | pZ = pYZ/TMath::Sqrt(1+bendingSlope*bendingSlope); | |
1578 | pX = pZ * nonBendingSlope; | |
1579 | pY = pZ * bendingSlope; | |
1580 | c = TMath::Sign(1.0, trackParam->GetInverseBendingMomentum()); | |
b840996b | 1581 | AliDebug(1, Form("Track parameters at Vertex z= %f: X= %f Y= %f pX= %f pY= %f pZ= %f c= %f\n", |
1582 | z, x, y, pX, pY, pZ, c)); | |
04b5ea16 | 1583 | |
1584 | // track parameters at first hit | |
1585 | trackParam1 = ((AliMUONTrackHit*) | |
1586 | (track->GetTrackHitsPtr()->First()))->GetTrackParam(); | |
1587 | x = trackParam1->GetNonBendingCoor(); | |
1588 | y = trackParam1->GetBendingCoor(); | |
1589 | z = trackParam1->GetZ(); | |
1590 | bendingSlope = trackParam1->GetBendingSlope(); | |
1591 | nonBendingSlope = trackParam1->GetNonBendingSlope(); | |
1592 | pYZ = 1/TMath::Abs(trackParam1->GetInverseBendingMomentum()); | |
1593 | pZ = pYZ/TMath::Sqrt(1.0 + bendingSlope * bendingSlope); | |
1594 | pX = pZ * nonBendingSlope; | |
1595 | pY = pZ * bendingSlope; | |
1596 | c = TMath::Sign(1.0, trackParam1->GetInverseBendingMomentum()); | |
b840996b | 1597 | AliDebug(1, Form("track parameters at z= %f: X= %f Y= %f pX= %f pY= %f pZ= %f c= %f\n", |
1598 | z, x, y, pX, pY, pZ, c)); | |
04b5ea16 | 1599 | } |
1600 | // informations about generated particles | |
5d12ce38 | 1601 | np = gAlice->GetMCApp()->GetNtrack(); |
04b5ea16 | 1602 | printf(" **** number of generated particles: %d \n", np); |
1603 | ||
88cb7938 | 1604 | // for (Int_t iPart = 0; iPart < np; iPart++) { |
1605 | // p = gAlice->Particle(iPart); | |
1606 | // printf(" particle %d: type= %d px= %f py= %f pz= %f pdg= %d\n", | |
1607 | // iPart, p->GetPdgCode(), p->Px(), p->Py(), p->Pz(), p->GetPdgCode()); | |
1608 | // } | |
a9e2aefa | 1609 | return; |
1610 | } | |
1611 | ||
276c44b7 | 1612 | |
1613 | //__________________________________________________________________________ | |
29f1b13a | 1614 | void AliMUONTrackReconstructor::EventDumpTrigger(void) |
276c44b7 | 1615 | { |
1616 | // Dump reconstructed trigger event | |
1617 | // and the particle parameters | |
1618 | ||
52c9bc11 | 1619 | AliMUONTriggerTrack *triggertrack ; |
1620 | Int_t nTriggerTracks = fMUONData->RecTriggerTracks()->GetEntriesFast(); | |
276c44b7 | 1621 | |
b840996b | 1622 | AliDebug(1, "****** enter EventDumpTrigger ******"); |
1623 | AliDebug(1, Form("Number of Reconstructed tracks : %d ", nTriggerTracks)); | |
1624 | ||
276c44b7 | 1625 | // Loop over reconstructed tracks |
52c9bc11 | 1626 | for (Int_t trackIndex = 0; trackIndex < nTriggerTracks; trackIndex++) { |
1627 | triggertrack = (AliMUONTriggerTrack*)fMUONData->RecTriggerTracks()->At(trackIndex); | |
276c44b7 | 1628 | printf(" trigger track number %i x11=%f y11=%f thetax=%f thetay=%f \n", |
1629 | trackIndex, | |
1630 | triggertrack->GetX11(),triggertrack->GetY11(), | |
1631 | triggertrack->GetThetax(),triggertrack->GetThetay()); | |
1632 | } | |
1633 | } | |
1634 | ||
83dbc640 | 1635 | //__________________________________________________________________________ |
29f1b13a | 1636 | void AliMUONTrackReconstructor::MakeTrackCandidatesK(void) |
83dbc640 | 1637 | { |
1638 | // To make initial tracks for Kalman filter from the list of segments | |
1639 | Int_t istat, iseg; | |
1640 | AliMUONSegment *segment; | |
1641 | AliMUONTrackK *trackK; | |
1642 | ||
b840996b | 1643 | AliDebug(1,"Enter MakeTrackCandidatesK"); |
83dbc640 | 1644 | |
fff097e0 | 1645 | AliMUONTrackK a(this, fHitsForRecPtr); |
83dbc640 | 1646 | // Loop over stations(1...) 5 and 4 |
1647 | for (istat=4; istat>=3; istat--) { | |
1648 | // Loop over segments in the station | |
1649 | for (iseg=0; iseg<fNSegments[istat]; iseg++) { | |
1650 | // Transform segments to tracks and evaluate covariance matrix | |
1651 | segment = (AliMUONSegment*) ((*fSegmentsPtr[istat])[iseg]); | |
cc87ebcd | 1652 | trackK = new ((*fRecTracksPtr)[fNRecTracks++]) AliMUONTrackK(segment); |
83dbc640 | 1653 | } // for (iseg=0;...) |
1654 | } // for (istat=4;...) | |
1655 | return; | |
1656 | } | |
1657 | ||
1658 | //__________________________________________________________________________ | |
29f1b13a | 1659 | void AliMUONTrackReconstructor::FollowTracksK(void) |
83dbc640 | 1660 | { |
1661 | // Follow tracks using Kalman filter | |
30178c30 | 1662 | Bool_t ok; |
b035a148 | 1663 | Int_t icand, ichamBeg = 0, ichamEnd, chamBits; |
83dbc640 | 1664 | Double_t zDipole1, zDipole2; |
1665 | AliMUONTrackK *trackK; | |
1666 | AliMUONHitForRec *hit; | |
1667 | AliMUONRawCluster *clus; | |
1668 | TClonesArray *rawclusters; | |
83dbc640 | 1669 | clus = 0; rawclusters = 0; |
1670 | ||
b035a148 | 1671 | zDipole1 = GetSimpleBPosition() + GetSimpleBLength()/2; |
1672 | zDipole2 = zDipole1 - GetSimpleBLength(); | |
83dbc640 | 1673 | |
1674 | // Print hits | |
b035a148 | 1675 | trackK = (AliMUONTrackK*) ((*fRecTracksPtr)[0]); |
1676 | if (trackK->DebugLevel() > 0) { | |
1677 | for (Int_t i1=0; i1<fNHitsForRec; i1++) { | |
1678 | hit = (AliMUONHitForRec*) ((*fHitsForRecPtr)[i1]); | |
29fc2c86 | 1679 | //if (hit->GetTTRTrack() > 1 || hit->GetTrackRefSignal() == 0) continue; |
b035a148 | 1680 | printf(" Hit # %d %10.4f %10.4f %10.4f", |
1681 | hit->GetChamberNumber(), hit->GetBendingCoor(), | |
1682 | hit->GetNonBendingCoor(), hit->GetZ()); | |
29fc2c86 | 1683 | if (fRecTrackRefHits) { |
1684 | // from track ref hits | |
1685 | printf(" %3d %3d \n", hit->GetTrackRefSignal(), hit->GetTTRTrack()); | |
b035a148 | 1686 | } else { |
1687 | // from raw clusters | |
1688 | rawclusters = fMUONData->RawClusters(hit->GetChamberNumber()); | |
1689 | clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(hit-> | |
1690 | GetHitNumber()); | |
cc87ebcd | 1691 | printf(" %d", clus->GetTrack(1)); |
1692 | if (clus->GetTrack(2) != -1) printf(" %d \n", clus->GetTrack(2)); | |
b035a148 | 1693 | else printf("\n"); |
29fc2c86 | 1694 | } // if (fRecTrackRefHits) |
83dbc640 | 1695 | } |
b035a148 | 1696 | } // if (trackK->DebugLevel() > 0) |
83dbc640 | 1697 | |
1698 | icand = -1; | |
b035a148 | 1699 | Int_t nSeeds; |
1700 | nSeeds = fNRecTracks; // starting number of seeds | |
83dbc640 | 1701 | // Loop over track candidates |
1702 | while (icand < fNRecTracks-1) { | |
1703 | icand ++; | |
b035a148 | 1704 | if (trackK->DebugLevel()>0) cout << " *** Kalman track candidate No. " << icand << endl; |
83dbc640 | 1705 | trackK = (AliMUONTrackK*) ((*fRecTracksPtr)[icand]); |
b035a148 | 1706 | if (trackK->GetRecover() < 0) continue; // failed track |
83dbc640 | 1707 | |
1708 | // Discard candidate which will produce the double track | |
b035a148 | 1709 | /* |
83dbc640 | 1710 | if (icand > 0) { |
30178c30 | 1711 | ok = CheckCandidateK(icand,nSeeds); |
1712 | if (!ok) { | |
b035a148 | 1713 | trackK->SetRecover(-1); // mark candidate to be removed |
1714 | continue; | |
83dbc640 | 1715 | } |
1716 | } | |
b035a148 | 1717 | */ |
83dbc640 | 1718 | |
30178c30 | 1719 | ok = kTRUE; |
83dbc640 | 1720 | if (trackK->GetRecover() == 0) hit = (AliMUONHitForRec*) |
fff097e0 | 1721 | trackK->GetTrackHits()->Last(); // last hit |
b035a148 | 1722 | else hit = trackK->GetHitLastOk(); // hit where track stopped |
1723 | if (hit) ichamBeg = hit->GetChamberNumber(); | |
83dbc640 | 1724 | ichamEnd = 0; |
1725 | // Check propagation direction | |
cc87ebcd | 1726 | if (!hit) { ichamBeg = ichamEnd; AliFatal(" ??? "); } |
b035a148 | 1727 | else if (trackK->GetTrackDir() < 0) { |
83dbc640 | 1728 | ichamEnd = 9; // forward propagation |
30178c30 | 1729 | ok = trackK->KalmanFilter(ichamBeg,ichamEnd,kFALSE,zDipole1,zDipole2); |
1730 | if (ok) { | |
83dbc640 | 1731 | ichamBeg = ichamEnd; |
1732 | ichamEnd = 6; // backward propagation | |
1733 | // Change weight matrix and zero fChi2 for backpropagation | |
1734 | trackK->StartBack(); | |
b035a148 | 1735 | trackK->SetTrackDir(1); |
30178c30 | 1736 | ok = trackK->KalmanFilter(ichamBeg,ichamEnd,kTRUE,zDipole1,zDipole2); |
83dbc640 | 1737 | ichamBeg = ichamEnd; |
1738 | ichamEnd = 0; | |
1739 | } | |
1740 | } else { | |
1741 | if (trackK->GetBPFlag()) { | |
1742 | // backpropagation | |
1743 | ichamEnd = 6; // backward propagation | |
1744 | // Change weight matrix and zero fChi2 for backpropagation | |
1745 | trackK->StartBack(); | |
30178c30 | 1746 | ok = trackK->KalmanFilter(ichamBeg,ichamEnd,kTRUE,zDipole1,zDipole2); |
83dbc640 | 1747 | ichamBeg = ichamEnd; |
1748 | ichamEnd = 0; | |
1749 | } | |
1750 | } | |
1751 | ||
30178c30 | 1752 | if (ok) { |
b035a148 | 1753 | trackK->SetTrackDir(1); |
83dbc640 | 1754 | trackK->SetBPFlag(kFALSE); |
30178c30 | 1755 | ok = trackK->KalmanFilter(ichamBeg,ichamEnd,kFALSE,zDipole1,zDipole2); |
83dbc640 | 1756 | } |
b035a148 | 1757 | if (!ok) { trackK->SetRecover(-1); continue; } // mark candidate to be removed |
1758 | ||
1759 | // Apply smoother | |
1760 | if (trackK->GetRecover() >= 0) { | |
1761 | ok = trackK->Smooth(); | |
1762 | if (!ok) trackK->SetRecover(-1); // mark candidate to be removed | |
1763 | } | |
83dbc640 | 1764 | |
1765 | // Majority 3 of 4 in first 2 stations | |
b035a148 | 1766 | if (!ok) continue; |
83dbc640 | 1767 | chamBits = 0; |
f29ba3e1 | 1768 | Double_t chi2max = 0; |
83dbc640 | 1769 | for (Int_t i=0; i<trackK->GetNTrackHits(); i++) { |
fff097e0 | 1770 | hit = (AliMUONHitForRec*) (*trackK->GetTrackHits())[i]; |
b035a148 | 1771 | chamBits |= BIT(hit->GetChamberNumber()); |
f29ba3e1 | 1772 | if (trackK->GetChi2PerPoint(i) > chi2max) chi2max = trackK->GetChi2PerPoint(i); |
83dbc640 | 1773 | } |
f29ba3e1 | 1774 | if (!((chamBits&3)==3 || (chamBits>>2&3)==3) && chi2max > 25) { |
b035a148 | 1775 | //trackK->Recover(); |
1776 | trackK->SetRecover(-1); //mark candidate to be removed | |
1777 | continue; | |
1778 | } | |
1779 | if (ok) trackK->SetTrackQuality(0); // compute "track quality" | |
83dbc640 | 1780 | } // while |
1781 | ||
1782 | for (Int_t i=0; i<fNRecTracks; i++) { | |
1783 | trackK = (AliMUONTrackK*) ((*fRecTracksPtr)[i]); | |
1784 | if (trackK->GetRecover() < 0) fRecTracksPtr->RemoveAt(i); | |
1785 | } | |
1786 | ||
1787 | // Compress TClonesArray | |
1788 | fRecTracksPtr->Compress(); | |
1789 | fNRecTracks = fRecTracksPtr->GetEntriesFast(); | |
1790 | return; | |
1791 | } | |
1792 | ||
1793 | //__________________________________________________________________________ | |
29f1b13a | 1794 | Bool_t AliMUONTrackReconstructor::CheckCandidateK(Int_t icand, Int_t nSeeds) const |
83dbc640 | 1795 | { |
1796 | // Discards track candidate if it will produce the double track (having | |
1797 | // the same seed segment hits as hits of a good track found before) | |
1798 | AliMUONTrackK *track1, *track2; | |
1799 | AliMUONHitForRec *hit1, *hit2, *hit; | |
1800 | ||
1801 | track1 = (AliMUONTrackK*) ((*fRecTracksPtr)[icand]); | |
fff097e0 | 1802 | hit1 = (AliMUONHitForRec*) (*track1->GetTrackHits())[0]; // 1'st hit |
1803 | hit2 = (AliMUONHitForRec*) (*track1->GetTrackHits())[1]; // 2'nd hit | |
83dbc640 | 1804 | |
1805 | for (Int_t i=0; i<icand; i++) { | |
1806 | track2 = (AliMUONTrackK*) ((*fRecTracksPtr)[i]); | |
1807 | //if (track2->GetRecover() < 0) continue; | |
1808 | if (track2->GetRecover() < 0 && icand >= nSeeds) continue; | |
1809 | ||
1810 | if (track1->GetStartSegment() == track2->GetStartSegment()) { | |
1811 | return kFALSE; | |
1812 | } else { | |
1813 | Int_t nSame = 0; | |
1814 | for (Int_t j=0; j<track2->GetNTrackHits(); j++) { | |
fff097e0 | 1815 | hit = (AliMUONHitForRec*) (*track2->GetTrackHits())[j]; |
83dbc640 | 1816 | if (hit == hit1 || hit == hit2) { |
1817 | nSame++; | |
1818 | if (nSame == 2) return kFALSE; | |
1819 | } | |
1820 | } // for (Int_t j=0; | |
1821 | } | |
1822 | } // for (Int_t i=0; | |
1823 | return kTRUE; | |
1824 | } | |
1825 | ||
1826 | //__________________________________________________________________________ | |
29f1b13a | 1827 | void AliMUONTrackReconstructor::RemoveDoubleTracksK(void) |
83dbc640 | 1828 | { |
1829 | // Removes double tracks (sharing more than half of their hits). Keeps | |
1830 | // the track with higher quality | |
1831 | AliMUONTrackK *track1, *track2, *trackToKill; | |
1832 | ||
1833 | // Sort tracks according to their quality | |
1834 | fRecTracksPtr->Sort(); | |
1835 | ||
1836 | // Loop over first track of the pair | |
1837 | track1 = (AliMUONTrackK*) fRecTracksPtr->First(); | |
b035a148 | 1838 | Int_t debug = track1->DebugLevel(); |
83dbc640 | 1839 | while (track1) { |
1840 | // Loop over second track of the pair | |
1841 | track2 = (AliMUONTrackK*) fRecTracksPtr->After(track1); | |
1842 | while (track2) { | |
1843 | // Check whether or not to keep track2 | |
1844 | if (!track2->KeepTrack(track1)) { | |
b035a148 | 1845 | if (debug >= 0) cout << " Killed track: " << 1/(*track2->GetTrackParameters())(4,0) << |
83dbc640 | 1846 | " " << track2->GetTrackQuality() << endl; |
1847 | trackToKill = track2; | |
1848 | track2 = (AliMUONTrackK*) fRecTracksPtr->After(track2); | |
1849 | trackToKill->Kill(); | |
1850 | fRecTracksPtr->Compress(); | |
1851 | } else track2 = (AliMUONTrackK*) fRecTracksPtr->After(track2); | |
1852 | } // track2 | |
1853 | track1 = (AliMUONTrackK*) fRecTracksPtr->After(track1); | |
1854 | } // track1 | |
1855 | ||
1856 | fNRecTracks = fRecTracksPtr->GetEntriesFast(); | |
b035a148 | 1857 | if (debug >= 0) cout << " Number of Kalman tracks: " << fNRecTracks << endl; |
83dbc640 | 1858 | } |
1859 | ||
1860 | //__________________________________________________________________________ | |
29f1b13a | 1861 | void AliMUONTrackReconstructor::GoToVertex(void) |
83dbc640 | 1862 | { |
1863 | // Propagates track to the vertex thru absorber | |
1864 | // (using Branson correction for now) | |
1865 | ||
1866 | Double_t zVertex; | |
1867 | zVertex = 0; | |
1868 | for (Int_t i=0; i<fNRecTracks; i++) { | |
1869 | //((AliMUONTrackK*)(*fRecTracksPtr)[i])->Branson(); | |
83dbc640 | 1870 | ((AliMUONTrackK*)(*fRecTracksPtr)[i])->SetTrackQuality(1); // compute Chi2 |
b035a148 | 1871 | //((AliMUONTrackK*)(*fRecTracksPtr)[i])->GoToZ(zVertex); // w/out absorber |
1872 | ((AliMUONTrackK*)(*fRecTracksPtr)[i])->GoToVertex(1); // with absorber | |
83dbc640 | 1873 | } |
1874 | } | |
b035a148 | 1875 | |
1876 | //__________________________________________________________________________ | |
29f1b13a | 1877 | void AliMUONTrackReconstructor::SetTrackMethod(Int_t iTrackMethod) |
b035a148 | 1878 | { |
1879 | // Set track method and recreate track container if necessary | |
1880 | ||
cc87ebcd | 1881 | fTrackMethod = TMath::Min (iTrackMethod, 3); |
1882 | fTrackMethod = TMath::Max (fTrackMethod, 1); | |
1883 | if (fTrackMethod != 1) { | |
b035a148 | 1884 | if (fRecTracksPtr) delete fRecTracksPtr; |
1885 | fRecTracksPtr = new TClonesArray("AliMUONTrackK", 10); | |
cc87ebcd | 1886 | if (fTrackMethod == 2) cout << " *** Tracking with the Kalman filter *** " << endl; |
1887 | else cout << " *** Combined cluster / track finder ***" << endl; | |
fff097e0 | 1888 | } else cout << " *** Original tracking *** " << endl; |
b035a148 | 1889 | |
1890 | } |