]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrackHitPattern.cxx
Removing class AliMUONTrackK
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackHitPattern.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 ///
21 /// \class AliMUONTrackHitPattern
22 ///
23 /// This class propagates tracks to trigger chambers 
24 /// searching for fired strips.
25 ///
26 /// To each track, a hit pattern for trigger chambers is set.
27 /// The hit pattern is a UShort_t with 8 bits used:
28 ///
29 ///            1  1  0  1    1  1  0  1
30 ///           |           |            |
31 ///            ----------- ------------
32 /// chamber:  11 12 13 14 | 11 12 13 14
33 /// cathode:    bending   | non-bending
34 ///
35 /// The main method is:
36 /// * GetHitPattern
37 ///
38 ///  \author Diego Stocco
39 ///
40 ////////////////////////////////////
41
42
43 #include "AliMUONTrackHitPattern.h"
44
45 #include "AliMUONConstants.h"
46 #include "AliMUONVDigit.h"
47 #include "AliMUONDigitMaker.h"
48 #include "AliMUONDigitStoreV1.h"
49 #include "AliMUONGeometryTransformer.h"
50 #include "AliMUONLocalTrigger.h"
51 #include "AliMUONLocalTriggerBoard.h"
52 #include "AliMUONTrack.h"
53 #include "AliMUONTrackExtrap.h"
54 #include "AliMUONTrackParam.h"
55 #include "AliMUONVTrackStore.h"
56 #include "AliMUONVTriggerStore.h"
57 #include "AliMpPad.h"
58 #include "AliMpSegmentation.h"
59 #include "AliMpVSegmentation.h"
60
61 #include "AliMagF.h"
62 #include "AliLog.h"
63 #include "AliTracker.h"
64
65 #include <Riostream.h>
66 #include <TArrayS.h>
67 #include <TClonesArray.h>
68 #include <TMath.h>
69 #include <TMatrixD.h>
70
71 /// \cond CLASSIMP
72 ClassImp(AliMUONTrackHitPattern) // Class implementation in ROOT context
73 /// \endcond
74
75
76 //______________________________________________________________________________
77 AliMUONTrackHitPattern::AliMUONTrackHitPattern(const AliMUONGeometryTransformer& transformer,
78                                                const AliMUONDigitMaker& digitMaker)
79     : TObject(),
80       fTransformer(transformer),
81       fDigitMaker(digitMaker)
82 {
83     /// Default constructor
84
85     // Set magnetic field
86     const AliMagF* kField = AliTracker::GetFieldMap();
87     if (!kField) AliFatal("No field available");
88     AliMUONTrackExtrap::SetField(kField);
89 }
90
91
92 //______________________________________________________________________________
93 AliMUONTrackHitPattern::~AliMUONTrackHitPattern(void)
94 {
95   /// Destructor
96 }
97
98
99 //______________________________________________________________________________
100 void AliMUONTrackHitPattern::GetHitPattern(AliMUONVTrackStore& trackStore,
101                                            const AliMUONVTriggerStore& triggerStore) const
102 {
103     //
104     /// Main method:
105     /// Loops on reco tracks, extrapolates them to trigger chambers
106     /// and searches for matching digits
107     //
108     
109     const Int_t kMask[2][4]= {{0x80, 0x40, 0x20, 0x10},
110                               {0x08, 0x04, 0x02, 0x01}};
111     Bool_t isMatch[2];
112
113     UShort_t pattern=0;
114     
115     AliMUONDigitStoreV1 digitStore;
116     
117     TriggerDigits(triggerStore,digitStore);
118     
119     AliMUONTrack* muonTrack;
120     TIter next(trackStore.CreateIterator());
121     
122     while ( ( muonTrack = static_cast<AliMUONTrack*>(next()) ) )
123     {
124       pattern = 0;
125       AliMUONTrackParam *trackParam = static_cast<AliMUONTrackParam*> 
126         (muonTrack->GetTrackParamAtHit()->Last());
127       
128       for(Int_t ch=0; ch<4; ++ch)
129       {
130         AliMUONTrackExtrap::ExtrapToZCov(trackParam, AliMUONConstants::DefaultChamberZ(10+ch));
131         FindPadMatchingTrack(digitStore,*trackParam, isMatch, ch);
132         for(Int_t cath=0; cath<2; ++cath)
133         {
134           if(isMatch[cath]) pattern |= kMask[cath][ch];
135             }
136       }
137       muonTrack->SetHitsPatternInTrigCh(pattern);
138     }
139 }
140
141
142 //______________________________________________________________________________
143 void 
144 AliMUONTrackHitPattern::FindPadMatchingTrack(AliMUONVDigitStore& digitStore,
145                                              const AliMUONTrackParam& trackParam,
146                                              Bool_t isMatch[2], Int_t /*iChamber*/) const
147 {
148     //
149     /// Given track position, searches for matching digits.
150     //
151
152     Float_t minMatchDist[2];
153
154     for(Int_t cath=0; cath<2; ++cath)
155     {
156       isMatch[cath]=kFALSE;
157       minMatchDist[cath]=9999.;
158     }
159
160     TIter next(digitStore.CreateIterator());
161     AliMUONVDigit* mDigit;
162     
163     while ( ( mDigit = static_cast<AliMUONVDigit*>(next()) ) )
164     {
165       Int_t currDetElemId = mDigit->DetElemId();
166       Int_t cathode = mDigit->Cathode();
167       Int_t ix = mDigit->PadX();
168       Int_t iy = mDigit->PadY();
169       Float_t xpad, ypad, zpad;
170       const AliMpVSegmentation* seg = AliMpSegmentation::Instance()
171         ->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(cathode));
172       
173       AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
174       Float_t xlocal1 = pad.Position().X();
175       Float_t ylocal1 = pad.Position().Y();
176       Float_t dpx = pad.Dimensions().X();
177       Float_t dpy = pad.Dimensions().Y();
178       fTransformer.Local2Global(currDetElemId, xlocal1, ylocal1, 0, xpad, ypad, zpad);
179       Float_t matchDist = MinDistanceFromPad(xpad, ypad, zpad, dpx, dpy, trackParam);
180       if(matchDist>minMatchDist[cathode])continue;
181       isMatch[cathode] = kTRUE;
182       minMatchDist[cathode] = matchDist;
183     }
184 }
185
186
187 //______________________________________________________________________________
188 Float_t 
189 AliMUONTrackHitPattern::MinDistanceFromPad(Float_t xPad, Float_t yPad, Float_t zPad,
190                                            Float_t dpx, Float_t dpy, 
191                                            const AliMUONTrackParam& trackParam) const
192 {
193     //
194     /// Decides if the digit belongs to the track.
195     //
196     Float_t xTrackAtPad = trackParam.GetNonBendingCoor();
197     Float_t yTrackAtPad = trackParam.GetBendingCoor();
198
199     Float_t sigmaX, sigmaY, sigmaMS;
200     GetPosUncertainty(trackParam, zPad, sigmaX, sigmaY, sigmaMS);
201
202     Float_t maxDistX = 3.*(sigmaX + sigmaMS); // in cm
203     Float_t maxDistY = 3.*(sigmaY + sigmaMS); // in cm
204
205     Float_t deltaX = TMath::Abs(xPad-xTrackAtPad)-dpx;
206     Float_t deltaY = TMath::Abs(yPad-yTrackAtPad)-dpy;
207
208     Float_t matchDist = 99999.;
209     if(deltaX<=maxDistX && deltaY<=maxDistY) matchDist = TMath::Max(deltaX, deltaY);
210     return matchDist;
211 }
212
213
214 //______________________________________________________________________________
215 void 
216 AliMUONTrackHitPattern::GetPosUncertainty(const AliMUONTrackParam& trackParam,
217                                           Float_t zChamber, 
218                                           Float_t &sigmaX, Float_t &sigmaY, 
219                                           Float_t &sigmaMS) const
220 {
221     //
222     /// Returns uncertainties on extrapolated position.
223     /// Takes into account Branson plane corrections in the iron wall.
224     //
225
226     const Float_t kAlpha = 0.1123; // GeV/c
227     
228     // Find a better way to get such parameters ???
229     const Float_t kZFilterIn = 1471.; // From STRUCT/SHILConst2.h
230     const Float_t kZFilterOut = kZFilterIn + 120.; // From STRUCT/SHILConst2.h
231     
232     const Float_t kZBranson = - (kZFilterIn + (kZFilterOut - kZFilterIn)*2./3. ); // - sign because distance are positive
233     Float_t zDistFromWall = TMath::Abs(zChamber - kZBranson);
234     Float_t zDistFromLastTrackCh = TMath::Abs(zChamber - AliMUONConstants::DefaultChamberZ(9));
235
236     const TMatrixD& kCovParam = trackParam.GetCovariances();
237     
238     sigmaX = kCovParam(0,0);
239     sigmaY = kCovParam(2,2);
240
241     // If covariance matrix is not extrapolated, use "reasonable" errors
242     // (To be removed as soon as covariance matrix is correctly propagated).
243     if (sigmaX==0.)sigmaX = 0.003 * zDistFromLastTrackCh;
244     if (sigmaY==0.)sigmaY = 0.004 * zDistFromLastTrackCh;
245
246     Float_t p = trackParam.P();
247     Float_t thetaMS = kAlpha/p;
248     sigmaMS = zDistFromWall * TMath::Tan(thetaMS);
249 }
250
251
252 //______________________________________________________________________________
253 Bool_t 
254 AliMUONTrackHitPattern::TriggerDigits(const AliMUONVTriggerStore& triggerStore,
255                                       AliMUONVDigitStore& digitStore) const
256 {
257   //
258   /// make (S)Digit for trigger
259   //
260   
261   digitStore.Clear();
262   
263   AliMUONLocalTrigger* locTrg;
264   TIter next(triggerStore.CreateLocalIterator());
265   
266   while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) ) 
267   {
268     if (locTrg->IsNull()) continue;
269    
270     TArrayS xyPattern[2];
271     locTrg->GetXPattern(xyPattern[0]);
272     locTrg->GetYPattern(xyPattern[1]);
273
274     // do we need this ? (Ch.F.)
275 //     for(Int_t cath=0; cath<2; ++cath)
276 //     {
277 //       for(Int_t ch=0; ch<4; ++ch)
278 //       {
279 //         if(xyPattern[cath][ch]==0) continue;
280 //       }
281 //     }
282     
283     Int_t nBoard = locTrg->LoCircuit();
284     fDigitMaker.TriggerDigits(nBoard, xyPattern, digitStore);
285   }
286   return kTRUE;
287 }