remoe duplicate QA initialisation and do ESD QA for same detectors as RecPoint QA
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerTrackToTrackerClusters.cxx
CommitLineData
9bf6860b 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#include "AliMUONTriggerTrackToTrackerClusters.h"
19
20///\class AliMUONTriggerTrackToTrackerClusters
21///
22/// Class to convert trigger tracks into "fake" clusters in stations 4 and 5
23///
24/// Only intent is to be able to reconstruct data where stations 4 and 5 were
25/// not functionning, typically early cosmic runs
26///
27///\author Laurent Aphecetche, Subatech
28
29#include "AliCodeTimer.h"
30#include "AliLog.h"
31#include "AliMUONConstants.h"
32#include "AliMUONGeometryTransformer.h"
33#include "AliMUONTrack.h"
34#include "AliMUONTrackExtrap.h"
35#include "AliMUONTriggerTrack.h"
36#include "AliMUONVCluster.h"
37#include "AliMUONVClusterStore.h"
38#include "AliMUONVTriggerTrackStore.h"
39#include "AliMpArea.h"
40#include "AliMpDEManager.h"
41#include <TMath.h>
42
43///\cond CLASSIMP
44ClassImp(AliMUONTriggerTrackToTrackerClusters)
45///\endcond
46
47//_____________________________________________________________________________
48AliMUONTriggerTrackToTrackerClusters::AliMUONTriggerTrackToTrackerClusters(const AliMUONGeometryTransformer& transformer,
49 AliMUONVTriggerTrackStore* trackStore)
50: TObject(), fTransformer(transformer), fTriggerTrackStore(trackStore)
51{
52 /// ctor. We do not take ownership of the trigger track store.
53}
54
55//_____________________________________________________________________________
56AliMUONTriggerTrackToTrackerClusters::~AliMUONTriggerTrackToTrackerClusters()
57{
58 /// dtor
59}
60
61//_____________________________________________________________________________
62Int_t
63AliMUONTriggerTrackToTrackerClusters::DetElemId(Int_t chamber, Double_t x, Double_t y,
64 Double_t ex, Double_t ey,
65 Double_t& z) const
66{
67 /// Find in which detection element (x,y) (global) position is.
68
69 AliMpDEIterator it;
70
71 AliMpArea a( TVector2(x,y), TVector2(ex,ey) );
72
73 it.First(chamber);
74
75 while ( !it.IsDone() )
76 {
77 Int_t detElemId = it.CurrentDEId();
78
79 AliMpArea* area = fTransformer.GetDEArea(detElemId);
80
81 if ( area->Overlap(a) )
82 {
83 // get z of the center of that DE.
84 Double_t dummyx, dummyy;
85 fTransformer.Local2Global(detElemId,0,0,0,dummyx,dummyy,z);
86 return detElemId;
87 }
88 it.Next();
89 }
90
91 return -1;
92}
93
94//_____________________________________________________________________________
95Int_t
96AliMUONTriggerTrackToTrackerClusters::GenerateClusters(Int_t iChamber,
97 AliMUONVClusterStore& clusterStore) const
98{
99 /// Generate clusters in given chamber
100 /// Return the number of clusters added to the clusterStore
101
102 AliCodeTimerAuto(Form("Chamber %d",iChamber));
103
104 TIter next(fTriggerTrackStore->CreateIterator());
105
106 AliMUONTriggerTrack* track;
107 Int_t nadded(0);
108
109 while ( ( track = static_cast<AliMUONTriggerTrack*>(next()) ) )
110 {
111 nadded += GenerateClusters(iChamber,*track,clusterStore);
112 }
113 return nadded;
114}
115
116//_____________________________________________________________________________
117Int_t
118AliMUONTriggerTrackToTrackerClusters::GenerateClusters(Int_t iChamber,
119 const AliMUONTriggerTrack& track,
120 AliMUONVClusterStore& clusterStore) const
121{
122 /// From a trigger track, generate 1 cluster in given chamber
123
124 /// Get a (rough) guestimate of the track momentum
125
126 Int_t nadded(0);
127
128 Double_t z = AliMUONConstants::DefaultChamberZ(10);
129
130 Double_t bendingCoord = track.GetY11();
131 Double_t bendingSlope = TMath::Tan(track.GetThetay());
132
133 Double_t bendingImpact = bendingCoord - z * bendingSlope;
134
135 AliDebug(1,Form("TriggerTrack impact parameter=%e",bendingImpact));
136
137 // StdoutToAliDebug(1,track.Print());
138
139 Double_t inverseBendingMomentum = 1. / AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(bendingImpact);
140
141 // Construct an AliMUONTrackParam from the trigger track, in order to be able to extrapolate it
142 // to chambers 6..9 planes.
143
144 AliMUONTrackParam trackParam;
145
146 trackParam.SetZ(z);
147 trackParam.SetNonBendingCoor(track.GetX11());
148 trackParam.SetNonBendingSlope(TMath::Tan(track.GetThetax()));
149 trackParam.SetBendingCoor(bendingCoord);
150 trackParam.SetBendingSlope(bendingSlope);
151 trackParam.SetInverseBendingMomentum(inverseBendingMomentum);
152
153 Double_t dZ = TMath::Abs(AliMUONConstants::DefaultChamberZ(12) - AliMUONConstants::DefaultChamberZ(10));
154
155 Double_t sigmaX = AliMUONConstants::TriggerNonBendingReso();
156
157 Double_t sigmaY = AliMUONConstants::TriggerBendingReso();
158
159 // Compute and set track parameters covariances
160 TMatrixD paramCov(5,5);
161 paramCov.Zero();
162
163 // Non bending plane
164 paramCov(0,0) = sigmaX*sigmaX;
165 paramCov(0,1) = -sigmaX/dZ;
166 paramCov(1,0) = paramCov(0,1);
167
168 paramCov(1,1) = 2.0*sigmaX/dZ/dZ;
169
170 // Bending plane
171 paramCov(2,2) = sigmaY*sigmaY;
172 paramCov(2,3) = -sigmaY/dZ;
173 paramCov(3,2) = paramCov(2,3);
174
175 paramCov(3,3) = 2.0*sigmaY/dZ/dZ;
176
177 // Inverse bending momentum (50% error)
178 paramCov(4,4) = 0.5*inverseBendingMomentum * 0.5*inverseBendingMomentum;
179
180 // Set covariances
181 trackParam.SetCovariances(paramCov);
182
183 // Now we extrapolate this trackParam to chambers 6 -> 9
184
185 const Float_t kFilterThickness = TMath::Abs(AliMUONConstants::MuonFilterZEnd()-AliMUONConstants::MuonFilterZBeg()); // cm
186
187 Int_t nclusters = clusterStore.GetSize();
188
189 AliMUONTrackParam tp(trackParam);
190
191 Double_t zg = AliMUONConstants::DefaultChamberZ(iChamber);
192 AliMUONTrackExtrap::ExtrapToZCov(&tp, zg); // Extrap to iChamber
193
194 AliMUONTrackExtrap::AddMCSEffect(&tp, kFilterThickness, AliMUONConstants::MuonFilterX0()); // Add MCS effects
195
196 AliDebug(1,Form("iChamber=%d",iChamber));
197
198 StdoutToAliDebug(1,tp.Print("FULLCOV"););
199
200 Double_t x = tp.GetNonBendingCoor();
201 Double_t y = tp.GetBendingCoor();
202 const TMatrixD& cov = tp.GetCovariances();
203 Double_t ex = TMath::Sqrt(cov(0,0));
204 Double_t ey = TMath::Sqrt(cov(2,2));
205
206 Double_t zde;
207
208 Int_t detElemId = DetElemId(iChamber,x,y,ex,ey,zde);
209
210 AliDebug(1,Form("zg = %e zde = %e",zg,zde));
211
212 if ( AliMpDEManager::IsValidDetElemId(detElemId) )
213 {
214 AliMUONVCluster* rawCluster = clusterStore.Add(AliMpDEManager::GetChamberId(detElemId), detElemId, nclusters);
215
216 ++nclusters;
217 ++nadded;
218
219 rawCluster->SetCharge(100.0);
220 rawCluster->SetXYZ(x, y, zg);
221 rawCluster->SetErrXY(ex,ey);
222 }
223 else
224 {
225 AliWarning(Form("No DE found at xg=%e yg=%e",detElemId,x,y));
226 }
227
228 return nadded;
229}