]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONVTrackReconstructor.cxx
- Added back the old constructor that takes care of loading/unloading Kinematics,
[u/mrichter/AliRoot.git] / MUON / AliMUONVTrackReconstructor.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ////////////////////////////////////
19 //
20 // Virtual MUON track reconstructor in ALICE (class renamed from AliMUONEventReconstructor)
21 //
22 // This class contains as data:
23 // * a pointer to the array of hits to be reconstructed (the event)
24 // * a pointer to the array of segments made with these hits inside each station
25 // * a pointer to the array of reconstructed tracks
26 //
27 // It contains as methods, among others:
28 // * EventReconstruct to build the muon tracks
29 // * EventReconstructTrigger to build the trigger tracks
30 //
31 ////////////////////////////////////
32
33 #include <stdlib.h>
34 #include <Riostream.h>
35 #include <TTree.h>
36
37 #include "AliMUONVTrackReconstructor.h"
38 #include "AliMUONData.h"
39 #include "AliMUONConstants.h"
40 #include "AliMUONHitForRec.h"
41 #include "AliMUONTriggerTrack.h"
42 #include "AliMUONTriggerCircuit.h"
43 #include "AliMUONLocalTrigger.h"
44 #include "AliMUONGlobalTrigger.h"
45 #include "AliMUONSegment.h"
46 #include "AliMUONTrack.h"
47 #include "AliMUONTrackParam.h"
48 #include "AliMUONTrackExtrap.h"
49 #include "AliMagF.h"
50 #include "AliLog.h"
51 #include "AliTracker.h"
52
53 ClassImp(AliMUONVTrackReconstructor) // Class implementation in ROOT context
54
55 //************* Defaults parameters for reconstruction
56 const Double_t AliMUONVTrackReconstructor::fgkDefaultMinBendingMomentum = 3.0;
57 const Double_t AliMUONVTrackReconstructor::fgkDefaultMaxBendingMomentum = 3000.0;
58 const Double_t AliMUONVTrackReconstructor::fgkDefaultBendingResolution = 0.01;
59 const Double_t AliMUONVTrackReconstructor::fgkDefaultNonBendingResolution = 0.144;
60 const Double_t AliMUONVTrackReconstructor::fgkDefaultMaxSigma2Distance = 16.0;
61 // Simple magnetic field:
62 // Value taken from macro MUONtracking.C: 0.7 T, hence 7 kG
63 // Length and Position from reco_muon.F, with opposite sign:
64 // Length = ZMAGEND-ZCOIL
65 // Position = (ZMAGEND+ZCOIL)/2
66 // to be ajusted differently from real magnetic field ????
67 const Double_t AliMUONVTrackReconstructor::fgkDefaultSimpleBValue = 7.0;
68 const Double_t AliMUONVTrackReconstructor::fgkDefaultSimpleBLength = 428.0;
69 const Double_t AliMUONVTrackReconstructor::fgkDefaultSimpleBPosition = 1019.0;
70
71 //__________________________________________________________________________
72 AliMUONVTrackReconstructor::AliMUONVTrackReconstructor(AliMUONData* data)
73   : TObject(),
74     fMinBendingMomentum(fgkDefaultMinBendingMomentum),
75     fMaxBendingMomentum(fgkDefaultMaxBendingMomentum),
76     fBendingResolution(fgkDefaultBendingResolution),
77     fNonBendingResolution(fgkDefaultNonBendingResolution),
78     fMaxSigma2Distance(fgkDefaultMaxSigma2Distance),
79     fChamberThicknessInX0(AliMUONConstants::DefaultChamberThicknessInX0()),
80     fSimpleBValue(fgkDefaultSimpleBValue),
81     fSimpleBLength(fgkDefaultSimpleBLength),
82     fSimpleBPosition(fgkDefaultSimpleBPosition),
83     fSegmentMaxDistBending(0x0),
84     fSegmentMaxDistNonBending(0x0),
85     fHitsForRecPtr(0x0),
86     fNHitsForRec(0),
87     fNHitsForRecPerChamber(0x0),
88     fIndexOfFirstHitForRecPerChamber(0x0),
89     fSegmentsPtr(0x0),
90     fNSegments(0x0),
91     fRecTracksPtr(0x0),
92     fNRecTracks(0),
93     fMUONData(data),
94     fTriggerTrack(new AliMUONTriggerTrack()),
95     fTriggerCircuit(0x0)
96 {
97   /// Constructor for class AliMUONVTrackReconstructor
98   fSegmentMaxDistBending = new Double_t[AliMUONConstants::NTrackingSt()];
99   fSegmentMaxDistNonBending = new Double_t[AliMUONConstants::NTrackingSt()];
100   fNHitsForRecPerChamber = new Int_t[AliMUONConstants::NTrackingCh()];
101   fIndexOfFirstHitForRecPerChamber = new Int_t[AliMUONConstants::NTrackingCh()];
102
103   SetReconstructionParametersToDefaults();
104   
105   // Memory allocation for the TClonesArray of hits for reconstruction
106   // Is 10000 the right size ????
107   fHitsForRecPtr = new TClonesArray("AliMUONHitForRec", 10000);
108
109   // Memory allocation for the TClonesArray's of segments in stations
110   // Is 2000 the right size ????
111   fSegmentsPtr = new TClonesArray*[AliMUONConstants::NTrackingSt()];
112   fNSegments = new Int_t[AliMUONConstants::NTrackingSt()];
113   for (Int_t st = 0; st < AliMUONConstants::NTrackingSt(); st++) {
114     fSegmentsPtr[st] = new TClonesArray("AliMUONSegment", 2000);
115     fNSegments[st] = 0; // really needed or GetEntriesFast sufficient ????
116   }
117
118   const AliMagF* kField = AliTracker::GetFieldMap();
119   if (!kField) AliFatal("No field available");
120  // Sign of fSimpleBValue according to sign of Bx value at (50,50,-950).
121   Float_t b[3], x[3];
122   x[0] = 50.; x[1] = 50.; x[2] = -950.;
123   kField->Field(x,b);
124
125   fSimpleBValue    = TMath::Sign(fSimpleBValue,(Double_t) b[0]);
126   fSimpleBPosition = TMath::Sign(fSimpleBPosition,(Double_t) x[2]);
127   // See how to get fSimple(BValue, BLength, BPosition)
128   // automatically calculated from the actual magnetic field ????
129   
130   // set the magnetic field for track extrapolations
131   AliMUONTrackExtrap::SetField(kField);
132 }
133
134   //__________________________________________________________________________
135 AliMUONVTrackReconstructor::~AliMUONVTrackReconstructor(void)
136 {
137   /// Destructor for class AliMUONVTrackReconstructor
138   delete [] fSegmentMaxDistBending;
139   delete [] fSegmentMaxDistNonBending;
140   delete [] fNHitsForRecPerChamber;
141   delete [] fIndexOfFirstHitForRecPerChamber;
142   delete fTriggerTrack;
143   delete fHitsForRecPtr;
144   // Correct destruction of everything ????
145   for (Int_t st = 0; st < AliMUONConstants::NTrackingSt(); st++) delete fSegmentsPtr[st];
146   delete [] fSegmentsPtr;
147   delete [] fNSegments;
148 }
149
150   //__________________________________________________________________________
151 void AliMUONVTrackReconstructor::SetReconstructionParametersToDefaults(void)
152 {
153   /// Set reconstruction parameters for making segments to default values
154   // Would be much more convenient with a structure (or class) ????
155
156   // ******** Parameters for making segments
157   // should be parametrized ????
158   // according to interval between chambers in a station ????
159   // Maximum distance in non bending plane
160   // 5 * 0.22 just to remember the way it was made in TRACKF_STAT
161   // SIGCUT*DYMAX(IZ)
162   for (Int_t st = 0; st < AliMUONConstants::NTrackingCh()/2; st++)
163     fSegmentMaxDistNonBending[st] = 5. * 0.22;
164   // Maximum distance in bending plane:
165   // values from TRACKF_STAT, corresponding to (J psi 20cm),
166   // scaled to the real distance between chambers in a station
167   fSegmentMaxDistBending[0] = TMath::Abs( 1.5 *
168                                           (AliMUONConstants::DefaultChamberZ(1) - AliMUONConstants::DefaultChamberZ(0)) / 20.0);
169   fSegmentMaxDistBending[1] = TMath::Abs( 1.5 *
170                                           (AliMUONConstants::DefaultChamberZ(3) - AliMUONConstants::DefaultChamberZ(2)) / 20.0);
171   fSegmentMaxDistBending[2] = TMath::Abs( 3.0 *
172                                           (AliMUONConstants::DefaultChamberZ(5) - AliMUONConstants::DefaultChamberZ(4)) / 20.0);
173   fSegmentMaxDistBending[3] = TMath::Abs( 6.0 *
174                                           (AliMUONConstants::DefaultChamberZ(7) - AliMUONConstants::DefaultChamberZ(6)) / 20.0);
175   fSegmentMaxDistBending[4] = TMath::Abs( 6.0 *
176                                           (AliMUONConstants::DefaultChamberZ(9) - AliMUONConstants::DefaultChamberZ(8)) / 20.0);
177
178   return;
179 }
180
181   //__________________________________________________________________________
182 void AliMUONVTrackReconstructor::EventReconstruct(void)
183 {
184   // To reconstruct one event
185   AliDebug(1,"Enter EventReconstruct");
186   ResetTracks(); //AZ
187   ResetSegments(); //AZ
188   ResetHitsForRec(); //AZ
189   AddHitsForRecFromRawClusters();
190   MakeSegments();
191   MakeTracks();
192   if (fMUONData->IsTriggerTrackBranchesInTree()) 
193     ValidateTracksWithTrigger(); 
194   
195   // Add tracks to MUON data container 
196   for(Int_t i=0; i<fNRecTracks; i++) {
197     AliMUONTrack * track = (AliMUONTrack*) fRecTracksPtr->At(i);
198     fMUONData->AddRecTrack(*track);
199   }
200 }
201
202   //__________________________________________________________________________
203 void AliMUONVTrackReconstructor::ResetTracks(void)
204 {
205   /// To reset the TClonesArray of reconstructed tracks
206   if (fRecTracksPtr) fRecTracksPtr->Delete();
207   // Delete in order that the Track destructors are called,
208   // hence the space for the TClonesArray of pointers to TrackHit's is freed
209   fNRecTracks = 0;
210   return;
211 }
212
213   //__________________________________________________________________________
214 void AliMUONVTrackReconstructor::ResetSegments(void)
215 {
216   /// To reset the TClonesArray of segments and the number of Segments for all stations
217   for (Int_t st = 0; st < AliMUONConstants::NTrackingCh()/2; st++) {
218     if (fSegmentsPtr[st]) fSegmentsPtr[st]->Clear();
219     fNSegments[st] = 0;
220   }
221   return;
222 }
223
224   //__________________________________________________________________________
225 void AliMUONVTrackReconstructor::ResetHitsForRec(void)
226 {
227   /// To reset the array and the number of HitsForRec,
228   /// and also the number of HitsForRec
229   /// and the index of the first HitForRec per chamber
230   if (fHitsForRecPtr) fHitsForRecPtr->Delete();
231   fNHitsForRec = 0;
232   for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++)
233     fNHitsForRecPerChamber[ch] = fIndexOfFirstHitForRecPerChamber[ch] = 0;
234   return;
235 }
236
237   //__________________________________________________________________________
238 void AliMUONVTrackReconstructor::SortHitsForRecWithIncreasingChamber()
239 {
240   /// Sort HitsForRec's in increasing order with respect to chamber number.
241   /// Uses the function "Compare".
242   /// Update the information for HitsForRec per chamber too.
243   Int_t ch, nhits, prevch;
244   fHitsForRecPtr->Sort();
245   for (ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) {
246     fNHitsForRecPerChamber[ch] = 0;
247     fIndexOfFirstHitForRecPerChamber[ch] = 0;
248   }
249   prevch = 0; // previous chamber
250   nhits = 0; // number of hits in current chamber
251   // Loop over HitsForRec
252   for (Int_t hit = 0; hit < fNHitsForRec; hit++) {
253     // chamber number (0...)
254     ch = ((AliMUONHitForRec*)  ((*fHitsForRecPtr)[hit]))->GetChamberNumber();
255     // increment number of hits in current chamber
256     (fNHitsForRecPerChamber[ch])++;
257     // update index of first HitForRec in current chamber
258     // if chamber number different from previous one
259     if (ch != prevch) {
260       fIndexOfFirstHitForRecPerChamber[ch] = hit;
261       prevch = ch;
262     }
263   }
264   return;
265 }
266
267   //__________________________________________________________________________
268 void AliMUONVTrackReconstructor::MakeSegmentsPerStation(Int_t Station)
269 {
270   /// To make the list of segments in station number "Station" (0...)
271   /// from the list of hits to be reconstructed.
272   /// Updates "fNSegments"[Station].
273   /// Segments in stations 4 and 5 are sorted
274   /// according to increasing absolute value of "impact parameter"
275   AliMUONHitForRec *hit1Ptr, *hit2Ptr;
276   AliMUONSegment *segment;
277   Bool_t last2st;
278   Double_t bendingSlope, distBend, distNonBend, extBendCoor, extNonBendCoor,
279       impactParam = 0., maxImpactParam = 0., minImpactParam = 0.; // =0 to avoid compilation warnings.
280   AliDebug(1,Form("Enter MakeSegmentsPerStation (0...) %d",Station));
281   // first and second chambers (0...) in the station
282   Int_t ch1 = 2 * Station;
283   Int_t ch2 = ch1 + 1;
284   // variable true for stations downstream of the dipole:
285   // Station(0..4) equal to 3 or 4
286   if ((Station == 3) || (Station == 4)) {
287     last2st = kTRUE;
288     // maximum impact parameter (cm) according to fMinBendingMomentum...
289     maxImpactParam =
290       TMath::Abs(GetImpactParamFromBendingMomentum(fMinBendingMomentum));
291     // minimum impact parameter (cm) according to fMaxBendingMomentum...
292     minImpactParam =
293       TMath::Abs(GetImpactParamFromBendingMomentum(fMaxBendingMomentum));
294   }
295   else last2st = kFALSE;
296   // extrapolation factor from Z of first chamber to Z of second chamber
297   // dZ to be changed to take into account fine structure of chambers ????
298   Double_t extrapFact;
299   // index for current segment
300   Int_t segmentIndex = 0;
301   // Loop over HitsForRec in the first chamber of the station
302   for (Int_t hit1 = fIndexOfFirstHitForRecPerChamber[ch1];
303        hit1 < fIndexOfFirstHitForRecPerChamber[ch1] + fNHitsForRecPerChamber[ch1];
304        hit1++) {
305     // pointer to the HitForRec
306     hit1Ptr = (AliMUONHitForRec*) ((*fHitsForRecPtr)[hit1]);
307     // extrapolation,
308     // on the straight line joining the HitForRec to the vertex (0,0,0),
309     // to the Z of the second chamber of the station
310     // Loop over HitsForRec in the second chamber of the station
311     for (Int_t hit2 = fIndexOfFirstHitForRecPerChamber[ch2];
312          hit2 < fIndexOfFirstHitForRecPerChamber[ch2] + fNHitsForRecPerChamber[ch2];
313          hit2++) {
314       // pointer to the HitForRec
315       hit2Ptr = (AliMUONHitForRec*) ((*fHitsForRecPtr)[hit2]);
316       // absolute values of distances, in bending and non bending planes,
317       // between the HitForRec in the second chamber
318       // and the previous extrapolation
319       extrapFact = hit2Ptr->GetZ()/ hit1Ptr->GetZ();
320       extBendCoor = extrapFact * hit1Ptr->GetBendingCoor();
321       extNonBendCoor = extrapFact * hit1Ptr->GetNonBendingCoor();
322       distBend = TMath::Abs(hit2Ptr->GetBendingCoor() - extBendCoor);
323       distNonBend = TMath::Abs(hit2Ptr->GetNonBendingCoor() - extNonBendCoor);
324       if (last2st) {
325         // bending slope
326         if ( hit1Ptr->GetZ() - hit2Ptr->GetZ() != 0.0 ) {
327           bendingSlope = (hit1Ptr->GetBendingCoor() - hit2Ptr->GetBendingCoor()) /
328             (hit1Ptr->GetZ() - hit2Ptr->GetZ());
329           // absolute value of impact parameter
330           impactParam =
331             TMath::Abs(hit1Ptr->GetBendingCoor() - hit1Ptr->GetZ() * bendingSlope);
332          } 
333          else {
334            AliWarning("hit1Ptr->GetZ() = hit2Ptr->GetZ(): impactParam set to maxImpactParam");
335            impactParam = maxImpactParam;   
336          }   
337       }
338       // check for distances not too large,
339       // and impact parameter not too big if stations downstream of the dipole.
340       // Conditions "distBend" and "impactParam" correlated for these stations ????
341       if ((distBend < fSegmentMaxDistBending[Station]) &&
342           (distNonBend < fSegmentMaxDistNonBending[Station]) &&
343           (!last2st || (impactParam < maxImpactParam)) &&
344           (!last2st || (impactParam > minImpactParam))) {
345         // make new segment
346         segment = new ((*fSegmentsPtr[Station])[segmentIndex])
347           AliMUONSegment(hit1Ptr, hit2Ptr);
348         // update "link" to this segment from the hit in the first chamber
349         if (hit1Ptr->GetNSegments() == 0)
350           hit1Ptr->SetIndexOfFirstSegment(segmentIndex);
351         hit1Ptr->SetNSegments(hit1Ptr->GetNSegments() + 1);
352         if (AliLog::GetGlobalDebugLevel() > 1) {
353           cout << "segmentIndex(0...): " << segmentIndex
354                << "  distBend: " << distBend
355                << "  distNonBend: " << distNonBend
356                << endl;
357           segment->Dump();
358           cout << "HitForRec in first chamber" << endl;
359           hit1Ptr->Dump();
360           cout << "HitForRec in second chamber" << endl;
361           hit2Ptr->Dump();
362         };
363         // increment index for current segment
364         segmentIndex++;
365       }
366     } //for (Int_t hit2
367   } // for (Int_t hit1...
368   fNSegments[Station] = segmentIndex;
369   // Sorting according to "impact parameter" if station(1..5) 4 or 5,
370   // i.e. Station(0..4) 3 or 4, using the function "Compare".
371   // After this sorting, it is impossible to use
372   // the "fNSegments" and "fIndexOfFirstSegment"
373   // of the HitForRec in the first chamber to explore all segments formed with it.
374   // Is this sorting really needed ????
375   if ((Station == 3) || (Station == 4)) (fSegmentsPtr[Station])->Sort();
376   AliDebug(1,Form("Station: %d  NSegments:  %d ", Station, fNSegments[Station]));
377   return;
378 }
379
380   //__________________________________________________________________________
381 Double_t AliMUONVTrackReconstructor::GetImpactParamFromBendingMomentum(Double_t BendingMomentum) const
382 {
383   /// Returns impact parameter at vertex in bending plane (cm),
384   /// from the signed bending momentum "BendingMomentum" in bending plane (GeV/c),
385   /// using simple values for dipole magnetic field.
386   /// The sign of "BendingMomentum" is the sign of the charge.
387   return (-0.0003 * fSimpleBValue * fSimpleBLength * fSimpleBPosition /
388           BendingMomentum);
389 }
390
391   //__________________________________________________________________________
392 Double_t AliMUONVTrackReconstructor::GetBendingMomentumFromImpactParam(Double_t ImpactParam) const
393 {
394   /// Returns signed bending momentum in bending plane (GeV/c),
395   /// the sign being the sign of the charge for particles moving forward in Z,
396   /// from the impact parameter "ImpactParam" at vertex in bending plane (cm),
397   /// using simple values for dipole magnetic field.
398   return (-0.0003 * fSimpleBValue * fSimpleBLength * fSimpleBPosition /
399           ImpactParam);
400 }
401
402   //__________________________________________________________________________
403 void AliMUONVTrackReconstructor::ValidateTracksWithTrigger(void)
404 {
405   /// Try to match track from tracking system with trigger track
406   AliMUONTrack *track;
407   AliMUONTrackParam trackParam; 
408   AliMUONTriggerTrack *triggerTrack;
409   
410   fMUONData->SetTreeAddress("RL");
411   fMUONData->GetRecTriggerTracks();
412   TClonesArray *recTriggerTracks = fMUONData->RecTriggerTracks();
413   
414   Bool_t matchTrigger;
415   Double_t distSigma[3]={1,1,0.02}; // sigma of distributions (trigger-track) X,Y,slopeY
416   Double_t distTriggerTrack[3];
417   Double_t chi2MatchTrigger, xTrack, yTrack, ySlopeTrack, dTrigTrackMin2, dTrigTrack2 = 0.;
418   
419   track = (AliMUONTrack*) fRecTracksPtr->First();
420   while (track) {
421     matchTrigger = kFALSE;
422     chi2MatchTrigger = 0.;
423     
424     trackParam = *((AliMUONTrackParam*) (track->GetTrackParamAtHit()->Last()));
425     AliMUONTrackExtrap::ExtrapToZ(&trackParam, AliMUONConstants::DefaultChamberZ(10)); // extrap to 1st trigger chamber
426     
427     xTrack = trackParam.GetNonBendingCoor();
428     yTrack = trackParam.GetBendingCoor();
429     ySlopeTrack = trackParam.GetBendingSlope();
430     dTrigTrackMin2 = 999.;
431   
432     triggerTrack = (AliMUONTriggerTrack*) recTriggerTracks->First();
433     while(triggerTrack){
434       distTriggerTrack[0] = (triggerTrack->GetX11()-xTrack)/distSigma[0];
435       distTriggerTrack[1] = (triggerTrack->GetY11()-yTrack)/distSigma[1];
436       distTriggerTrack[2] = (TMath::Tan(triggerTrack->GetThetay())-ySlopeTrack)/distSigma[2];
437       dTrigTrack2 = 0.;
438       for (Int_t iVar = 0; iVar < 3; iVar++) dTrigTrack2 += distTriggerTrack[iVar]*distTriggerTrack[iVar];
439       if (dTrigTrack2 < dTrigTrackMin2 && dTrigTrack2 < fMaxSigma2Distance) {
440         dTrigTrackMin2 = dTrigTrack2;
441         matchTrigger = kTRUE;
442         chi2MatchTrigger =  dTrigTrack2/3.; // Normalized Chi2, 3 variables (X,Y,slopeY)
443       }
444       triggerTrack = (AliMUONTriggerTrack*) recTriggerTracks->After(triggerTrack);
445     }
446     
447     track->SetMatchTrigger(matchTrigger);
448     track->SetChi2MatchTrigger(chi2MatchTrigger);
449     
450     track = (AliMUONTrack*) fRecTracksPtr->After(track);
451   }
452
453   return;
454 }
455
456 //__________________________________________________________________________
457 void AliMUONVTrackReconstructor::EventReconstructTrigger(void)
458 {
459   /// To reconstruct trigger for one event
460   AliDebug(1,"Enter EventReconstructTrigger");
461   MakeTriggerTracks();  
462   return;
463 }
464
465   //__________________________________________________________________________
466 Bool_t AliMUONVTrackReconstructor::MakeTriggerTracks(void)
467 {
468     // To make the trigger tracks from Local Trigger
469   AliDebug(1, "Enter MakeTriggerTracks");
470   
471   TTree* treeR;
472   Int_t nTRentries;
473   UChar_t gloTrigPat;
474   TClonesArray *localTrigger;
475   TClonesArray *globalTrigger;
476   AliMUONLocalTrigger *locTrg;
477   AliMUONGlobalTrigger *gloTrg;
478
479   treeR = fMUONData->TreeR();
480   if (!treeR) {
481     AliWarning("TreeR is not loaded");
482     return kFALSE;
483   }
484   
485   nTRentries = Int_t(treeR->GetEntries());
486    
487   treeR->GetEvent(0); // only one entry  
488
489   if (!(fMUONData->IsTriggerBranchesInTree())) {
490     AliWarning(Form("Trigger information is not avalaible, nTRentries = %d not equal to 1",nTRentries));
491     return kFALSE;
492   }
493
494   fMUONData->SetTreeAddress("TC");
495   fMUONData->GetTrigger();
496
497   // global trigger for trigger pattern
498   gloTrigPat = 0;
499   globalTrigger = fMUONData->GlobalTrigger(); 
500   gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0);
501  
502   if (gloTrg)
503     gloTrigPat = gloTrg->GetGlobalResponse();
504  
505
506   // local trigger for tracking 
507   localTrigger = fMUONData->LocalTrigger();    
508   Int_t nlocals = (Int_t) (localTrigger->GetEntries());
509
510   Float_t z11 = AliMUONConstants::DefaultChamberZ(10);
511   Float_t z21 = AliMUONConstants::DefaultChamberZ(12);
512
513   Float_t y11 = 0.;
514   Int_t stripX21 = 0;
515   Float_t y21 = 0.;
516   Float_t x11 = 0.;
517
518   for (Int_t i=0; i<nlocals; i++) { // loop on Local Trigger
519     locTrg = (AliMUONLocalTrigger*)localTrigger->UncheckedAt(i);      
520
521     AliDebug(1, "AliMUONTrackReconstructor::MakeTriggerTrack using NEW trigger \n");
522     AliMUONTriggerCircuit* circuit = 
523       (AliMUONTriggerCircuit*)fTriggerCircuit->At(locTrg->LoCircuit()-1); // -1 !!!
524
525     y11 = circuit->GetY11Pos(locTrg->LoStripX()); 
526     stripX21 = locTrg->LoStripX()+locTrg->LoDev()+1;
527     y21 = circuit->GetY21Pos(stripX21);       
528     x11 = circuit->GetX11Pos(locTrg->LoStripY());
529     
530     AliDebug(1, Form(" MakeTriggerTrack %d %d %d %d %d %f %f %f \n",i,locTrg->LoCircuit(),
531                      locTrg->LoStripX(),locTrg->LoStripX()+locTrg->LoDev()+1,locTrg->LoStripY(),y11, y21, x11));
532     
533     Float_t thetax = TMath::ATan2( x11 , z11 );
534     Float_t thetay = TMath::ATan2( (y21-y11) , (z21-z11) );
535     
536     fTriggerTrack->SetX11(x11);
537     fTriggerTrack->SetY11(y11);
538     fTriggerTrack->SetThetax(thetax);
539     fTriggerTrack->SetThetay(thetay);
540     fTriggerTrack->SetGTPattern(gloTrigPat);
541           
542     fMUONData->AddRecTriggerTrack(*fTriggerTrack);
543   } // end of loop on Local Trigger
544   
545   return kTRUE;    
546 }
547
548 //__________________________________________________________________________
549 void AliMUONVTrackReconstructor::EventDumpTrigger(void)
550 {
551   /// Dump reconstructed trigger event 
552   /// and the particle parameters
553   AliMUONTriggerTrack *triggertrack ;
554   Int_t nTriggerTracks = fMUONData->RecTriggerTracks()->GetEntriesFast();
555  
556   AliDebug(1, "****** enter EventDumpTrigger ******");
557   AliDebug(1, Form("Number of Reconstructed tracks : %d ",  nTriggerTracks));
558   
559   // Loop over reconstructed tracks
560   for (Int_t trackIndex = 0; trackIndex < nTriggerTracks; trackIndex++) {
561     triggertrack = (AliMUONTriggerTrack*)fMUONData->RecTriggerTracks()->At(trackIndex);
562       printf(" trigger track number %i x11=%f y11=%f thetax=%f thetay=%f \n",
563              trackIndex,
564              triggertrack->GetX11(),triggertrack->GetY11(),
565              triggertrack->GetThetax(),triggertrack->GetThetay());      
566   } 
567 }
568