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