fix finding of pad neighbours; remove methods to write them in OCDB
[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"
933daf4c 39#include "AliMUONTrackParam.h"
9bf6860b 40#include "AliMpArea.h"
41#include "AliMpDEManager.h"
42#include <TMath.h>
43
44///\cond CLASSIMP
45ClassImp(AliMUONTriggerTrackToTrackerClusters)
46///\endcond
47
48//_____________________________________________________________________________
49AliMUONTriggerTrackToTrackerClusters::AliMUONTriggerTrackToTrackerClusters(const AliMUONGeometryTransformer& transformer,
50 AliMUONVTriggerTrackStore* trackStore)
72dae9ff 51: TObject(), fkTransformer(transformer), fTriggerTrackStore(trackStore)
9bf6860b 52{
53 /// ctor. We do not take ownership of the trigger track store.
54}
55
56//_____________________________________________________________________________
57AliMUONTriggerTrackToTrackerClusters::~AliMUONTriggerTrackToTrackerClusters()
58{
59 /// dtor
60}
61
62//_____________________________________________________________________________
63Int_t
64AliMUONTriggerTrackToTrackerClusters::DetElemId(Int_t chamber, Double_t x, Double_t y,
65 Double_t ex, Double_t ey,
66 Double_t& z) const
67{
68 /// Find in which detection element (x,y) (global) position is.
69
70 AliMpDEIterator it;
71
6e97fbb8 72 AliMpArea a(x, y, ex, ey);
9bf6860b 73
74 it.First(chamber);
75
76 while ( !it.IsDone() )
77 {
78 Int_t detElemId = it.CurrentDEId();
79
72dae9ff 80 AliMpArea* area = fkTransformer.GetDEArea(detElemId);
9bf6860b 81
82 if ( area->Overlap(a) )
83 {
84 // get z of the center of that DE.
85 Double_t dummyx, dummyy;
72dae9ff 86 fkTransformer.Local2Global(detElemId,0,0,0,dummyx,dummyy,z);
9bf6860b 87 return detElemId;
88 }
89 it.Next();
90 }
91
92 return -1;
93}
94
95//_____________________________________________________________________________
96Int_t
97AliMUONTriggerTrackToTrackerClusters::GenerateClusters(Int_t iChamber,
98 AliMUONVClusterStore& clusterStore) const
99{
100 /// Generate clusters in given chamber
101 /// Return the number of clusters added to the clusterStore
102
99c136e1 103 AliCodeTimerAuto(Form("Chamber %d",iChamber),0);
9bf6860b 104
105 TIter next(fTriggerTrackStore->CreateIterator());
106
107 AliMUONTriggerTrack* track;
108 Int_t nadded(0);
109
110 while ( ( track = static_cast<AliMUONTriggerTrack*>(next()) ) )
111 {
112 nadded += GenerateClusters(iChamber,*track,clusterStore);
113 }
114 return nadded;
115}
116
117//_____________________________________________________________________________
118Int_t
119AliMUONTriggerTrackToTrackerClusters::GenerateClusters(Int_t iChamber,
120 const AliMUONTriggerTrack& track,
121 AliMUONVClusterStore& clusterStore) const
122{
123 /// From a trigger track, generate 1 cluster in given chamber
124
125 /// Get a (rough) guestimate of the track momentum
126
127 Int_t nadded(0);
128
129 Double_t z = AliMUONConstants::DefaultChamberZ(10);
130
131 Double_t bendingCoord = track.GetY11();
132 Double_t bendingSlope = TMath::Tan(track.GetThetay());
133
134 Double_t bendingImpact = bendingCoord - z * bendingSlope;
135
136 AliDebug(1,Form("TriggerTrack impact parameter=%e",bendingImpact));
137
138 // StdoutToAliDebug(1,track.Print());
139
140 Double_t inverseBendingMomentum = 1. / AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(bendingImpact);
141
142 // Construct an AliMUONTrackParam from the trigger track, in order to be able to extrapolate it
143 // to chambers 6..9 planes.
144
145 AliMUONTrackParam trackParam;
146
147 trackParam.SetZ(z);
148 trackParam.SetNonBendingCoor(track.GetX11());
149 trackParam.SetNonBendingSlope(TMath::Tan(track.GetThetax()));
150 trackParam.SetBendingCoor(bendingCoord);
151 trackParam.SetBendingSlope(bendingSlope);
152 trackParam.SetInverseBendingMomentum(inverseBendingMomentum);
153
37a615ac 154 Double_t dZ = AliMUONConstants::DefaultChamberZ(10) - AliMUONConstants::DefaultChamberZ(12);
9bf6860b 155
156 Double_t sigmaX = AliMUONConstants::TriggerNonBendingReso();
157
158 Double_t sigmaY = AliMUONConstants::TriggerBendingReso();
159
160 // Compute and set track parameters covariances
161 TMatrixD paramCov(5,5);
162 paramCov.Zero();
163
164 // Non bending plane
165 paramCov(0,0) = sigmaX*sigmaX;
37a615ac 166 paramCov(0,1) = paramCov(0,0)/dZ;
9bf6860b 167 paramCov(1,0) = paramCov(0,1);
37a615ac 168 paramCov(1,1) = 2.0*paramCov(0,0)/dZ/dZ;
9bf6860b 169
170 // Bending plane
171 paramCov(2,2) = sigmaY*sigmaY;
37a615ac 172 paramCov(2,3) = paramCov(2,2)/dZ;
9bf6860b 173 paramCov(3,2) = paramCov(2,3);
37a615ac 174 paramCov(3,3) = 2.0*paramCov(2,2)/dZ/dZ;
9bf6860b 175
176 // Inverse bending momentum (50% error)
177 paramCov(4,4) = 0.5*inverseBendingMomentum * 0.5*inverseBendingMomentum;
178
179 // Set covariances
180 trackParam.SetCovariances(paramCov);
181
37a615ac 182 // add MCS effect in the iron wall
183 const Float_t kFilterThickness = AliMUONConstants::MuonFilterZEnd()-AliMUONConstants::MuonFilterZBeg(); // cm
184 AliMUONTrackExtrap::ExtrapToZCov(&trackParam, AliMUONConstants::MuonFilterZEnd()); // Extrap to iChamber
185 AliMUONTrackExtrap::AddMCSEffect(&trackParam, kFilterThickness, AliMUONConstants::MuonFilterX0()); // Add MCS effects
9bf6860b 186
37a615ac 187 // Now we extrapolate this trackParam to chambers 6 -> 9
9bf6860b 188 Int_t nclusters = clusterStore.GetSize();
189
190 AliMUONTrackParam tp(trackParam);
191
192 Double_t zg = AliMUONConstants::DefaultChamberZ(iChamber);
193 AliMUONTrackExtrap::ExtrapToZCov(&tp, zg); // Extrap to iChamber
194
9bf6860b 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 {
1130977f 225 AliWarning(Form("No DE found at xg=%e yg=%e",x,y));
9bf6860b 226 }
227
228 return nadded;
229}