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