Fixed a few issues in this code
[u/mrichter/AliRoot.git] / MUON / AliMUONESDInterface.cxx
CommitLineData
103e6575 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 "AliMUONESDInterface.h"
19#include "AliMUONTrack.h"
20#include "AliMUONVTrackStore.h"
21#include "AliMUONVCluster.h"
22#include "AliMUONVClusterStore.h"
23#include "AliMUONVDigit.h"
24#include "AliMUONVDigitStore.h"
b1fea02e 25#include "AliMUONLocalTrigger.h"
67c201be 26#include "AliMUONTriggerTrack.h"
b1fea02e 27#include "AliMUONVTriggerStore.h"
9f164762 28#include "AliMUONVTriggerTrackStore.h"
103e6575 29#include "AliMUON2DMapIterator.h"
30#include "AliMUONTrackParam.h"
31#include "AliMUONTrackExtrap.h"
32#include "AliMUONConstants.h"
b1fea02e 33#include "AliMUONTracker.h"
34#include "AliMUONRecoParam.h"
35#include "AliMUONVTrackReconstructor.h"
103e6575 36
630711ed 37#include "AliMpExMapIterator.h"
103e6575 38#include "AliMpVSegmentation.h"
39#include "AliMpSegmentation.h"
103e6575 40#include "AliMpPad.h"
41
42#include "AliESDEvent.h"
43#include "AliESDMuonTrack.h"
44#include "AliESDMuonCluster.h"
45#include "AliESDMuonPad.h"
46#include "AliLog.h"
47
48#include <TClass.h>
49#include <TIterator.h>
50#include <TMath.h>
51#include <TMatrixD.h>
52#include <Riostream.h>
a99c3449 53#include <TGeoGlobalMagField.h>
54#include <TVirtualMagField.h>
103e6575 55
56//-----------------------------------------------------------------------------
57/// \class AliMUONESDInterface
58///
59/// There are 2 way of using thid converter between MUON track/cluster/digit
60/// and ESDMuon track/cluster/pad:
61///
62/// 1) using the static methods converting the objects one by one
63///
b1fea02e 64/// 2) loading a whole ESDEvent and using the finders and/or the iterators
103e6575 65/// to access the corresponding MUON objects
66///
ad3c6eda 67/// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
68/// By default we use Kalman filter + Smoother
69///
103e6575 70/// \author Philippe Pillot
71//-----------------------------------------------------------------------------
72
73/// \cond CLASSIMP
74ClassImp(AliMUONESDInterface)
75/// \endcond
76
ad3c6eda 77AliMUONRecoParam* AliMUONESDInterface::fgRecoParam = 0x0;
b1fea02e 78AliMUONVTrackReconstructor* AliMUONESDInterface::fgTracker = 0x0;
79
103e6575 80TString AliMUONESDInterface::fgTrackStoreName = "AliMUONTrackStoreV1";
81TString AliMUONESDInterface::fgClusterStoreName = "AliMUONClusterStoreV2";
82TString AliMUONESDInterface::fgDigitStoreName = "AliMUONDigitStoreV2R";
b1fea02e 83TString AliMUONESDInterface::fgTriggerStoreName = "AliMUONTriggerStoreV1";
9f164762 84TString AliMUONESDInterface::fgTriggerTrackStoreName = "AliMUONTriggerTrackStoreV1";
103e6575 85
86//_____________________________________________________________________________
ad3c6eda 87AliMUONESDInterface::AliMUONESDInterface()
103e6575 88: TObject(),
a0dc65b4 89fTracks(0x0),
90fDigits(0x0),
91fTriggers(0x0),
92fClusterMap(0x0),
93fDigitMap(0x0)
103e6575 94{
95 /// Default constructor
96}
97
98//_____________________________________________________________________________
99AliMUONESDInterface::~AliMUONESDInterface()
100{
101 /// Destructor
102 delete fTracks;
103 delete fDigits;
b1fea02e 104 delete fTriggers;
103e6575 105 delete fClusterMap;
106 delete fDigitMap;
107}
108
109//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
110// methods to play with internal objects //
111//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
112
113//_____________________________________________________________________________
114void AliMUONESDInterface::Clear(Option_t*)
115{
116 /// clear memory
117 delete fTracks; fTracks = 0x0;
118 delete fDigits; fDigits = 0x0;
b1fea02e 119 delete fTriggers; fTriggers = 0x0;
103e6575 120 delete fClusterMap; fClusterMap = 0x0;
121 delete fDigitMap; fDigitMap = 0x0;
122}
123
124//_____________________________________________________________________________
125void AliMUONESDInterface::Reset()
126{
127 /// reset stores and maps
128
129 if (fTracks) fTracks->Clear("C");
130 else fTracks = NewTrackStore();
131
132 if (fDigits) fDigits->Clear("C");
133 else fDigits = NewDigitStore();
134
b1fea02e 135 if (fTriggers) fTriggers->Clear("C");
136 else fTriggers = NewTriggerStore();
137
103e6575 138 if (fClusterMap) fClusterMap->Clear();
630711ed 139 else fClusterMap = new AliMpExMap;
103e6575 140 fClusterMap->SetOwner(kTRUE);
141
630711ed 142 if (fDigitMap) fDigitMap->Clear();
143 else fDigitMap = new AliMpExMap;
144 fDigitMap->SetOwner(kTRUE);
103e6575 145}
146
147//_____________________________________________________________________________
a99c3449 148void AliMUONESDInterface::LoadEvent(AliESDEvent& esdEvent, Bool_t refit)
103e6575 149{
150 /// Extract MUON data from the given ESD event
151
152 // reset data members
153 Reset();
154
155 // loop over ESD tracks and fill the stores
156 Int_t nTracks = (Int_t) esdEvent.GetNumberOfMuonTracks();
157 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
158
159 // get ESD track
160 AliESDMuonTrack* esdTrack = esdEvent.GetMuonTrack(iTrack);
161
b1fea02e 162 // fill trigger store if related info are availables
163 if (esdTrack->ContainTriggerData()) Add(*esdTrack, *fTriggers);
164
165 // fill tracker data if availables
166 if (!esdTrack->ContainTrackerData()) continue;
167
103e6575 168 // add it to track store
a99c3449 169 AliMUONTrack* track = Add(*esdTrack, *fTracks, refit);
103e6575 170
103e6575 171 // prepare cluster map
630711ed 172 AliMpExMap* cMap = new AliMpExMap;
103e6575 173 cMap->SetOwner(kFALSE);
630711ed 174 fClusterMap->Add(esdTrack->GetUniqueID(), cMap);
103e6575 175
176 // prepare digit maps
630711ed 177 AliMpExMap* dMaps = new AliMpExMap;
103e6575 178 dMaps->SetOwner(kTRUE);
630711ed 179 fDigitMap->Add(esdTrack->GetUniqueID(), dMaps);
103e6575 180
181 // loop over ESD clusters
182 Int_t nClusters = esdTrack->GetNClusters();
183 for (Int_t iCluster = 0; iCluster < nClusters; iCluster++) {
184
185 // get ESD cluster
186 AliESDMuonCluster *esdCluster = (AliESDMuonCluster*) esdTrack->GetClusters().UncheckedAt(iCluster);
187
188 // get the corresponding MUON cluster
189 AliMUONVCluster* cluster = FindClusterInTrack(*track, esdCluster->GetUniqueID());
190
191 // fill cluster map
192 cMap->Add(cluster->GetUniqueID(), cluster);
193
194 // prepare digit map
630711ed 195 AliMpExMap* dMap =new AliMpExMap;
103e6575 196 dMap->SetOwner(kFALSE);
630711ed 197 dMaps->Add(esdCluster->GetUniqueID(), dMap);
103e6575 198
199 // loop over ESD pads
200 Int_t nPads = esdCluster->GetNPads();
b1fea02e 201 for (Int_t iPad = 0; iPad < nPads; iPad++) {
103e6575 202
203 // get ESD pad
204 AliESDMuonPad *esdPad = (AliESDMuonPad*) esdCluster->GetPads().UncheckedAt(iPad);
205
206 // add it to digit store
207 AliMUONVDigit* digit = Add(*esdPad, *fDigits);
208
209 // fill digit map
210 if (digit) dMap->Add(esdPad->GetUniqueID(), digit);
211 else dMap->Add(esdPad->GetUniqueID(), fDigits->FindObject(esdPad->GetUniqueID()));
212
213 } // end of loop over pads
214
215 } // end of loop over clusters
216
217 } // end of loop over tracks
218
219}
220
221//___________________________________________________________________________
222Int_t AliMUONESDInterface::GetNTracks() const
223{
224 /// return the number of tracks
630711ed 225 return fTracks ? fTracks->GetSize() : 0;
103e6575 226}
227
228//___________________________________________________________________________
229Int_t AliMUONESDInterface::GetNClusters() const
230{
231 /// return the number of clusters
232 Int_t nClusters = 0;
630711ed 233 AliMUONTrack *track;
234 TIter next(CreateTrackIterator());
235 while ((track = static_cast<AliMUONTrack*>(next()))) nClusters += track->GetNClusters();
103e6575 236 return nClusters;
237}
238
239//___________________________________________________________________________
630711ed 240Int_t AliMUONESDInterface::GetNClusters(UInt_t trackId) const
103e6575 241{
630711ed 242 /// return the number of clusters in track "trackId"
243 AliMUONTrack* track = FindTrack(trackId);
103e6575 244 return track ? track->GetNClusters() : 0;
245}
246
247//___________________________________________________________________________
248Int_t AliMUONESDInterface::GetNDigits() const
249{
250 /// return the number of digits
251 return fDigits ? fDigits->GetSize() : 0;
252}
253
254//___________________________________________________________________________
630711ed 255Int_t AliMUONESDInterface::GetNDigits(UInt_t trackId) const
103e6575 256{
630711ed 257 /// return the number of digits in all clusters of track "trackId"
103e6575 258 Int_t nDigits = 0;
630711ed 259 AliMUONVCluster *cluster;
260 TIter next(CreateClusterIterator(trackId));
261 while ((cluster = static_cast<AliMUONVCluster*>(next()))) nDigits += cluster->GetNDigits();
103e6575 262 return nDigits;
263}
264
265//___________________________________________________________________________
630711ed 266Int_t AliMUONESDInterface::GetNDigits(UInt_t trackId, UInt_t clusterId) const
103e6575 267{
268 /// return the number of digits in cluster numbered "iCluster" of track "iTrack"
630711ed 269 AliMUONVCluster* cluster = FindCluster(trackId, clusterId);
103e6575 270 return cluster ? cluster->GetNDigits() : 0;
271}
272
273//___________________________________________________________________________
274Int_t AliMUONESDInterface::GetNDigitsInCluster(UInt_t clusterId) const
275{
276 /// return the number of digits in cluster "clusterId"
277 AliMUONVCluster* cluster = FindCluster(clusterId);
278 return cluster ? cluster->GetNDigits() : 0;
279}
280
281//___________________________________________________________________________
b1fea02e 282Int_t AliMUONESDInterface::GetNTriggers() const
283{
284 /// return the number of triggers
285 return fTriggers ? fTriggers->GetSize() : 0;
286}
287
288//___________________________________________________________________________
630711ed 289AliMUONTrack* AliMUONESDInterface::FindTrack(UInt_t trackId) const
103e6575 290{
630711ed 291 /// return track "trackId" (0x0 if not found)
292 AliMUONTrack *track = fTracks ? static_cast<AliMUONTrack*>(fTracks->FindObject(trackId)) : 0x0;
293 if (!track) AliWarning(Form("track %d does not exist",trackId));
103e6575 294 return track;
295}
296
297//___________________________________________________________________________
103e6575 298AliMUONVCluster* AliMUONESDInterface::FindCluster(UInt_t clusterId) const
299{
630711ed 300 /// loop over tracks and return the first cluster "clusterId" found (0x0 if not found)
301 AliMpExMap *cMap;
103e6575 302 AliMUONVCluster* cluster = 0x0;
303
630711ed 304 if (fClusterMap) {
103e6575 305
630711ed 306 TIter next(fClusterMap->CreateIterator());
307 while ((cMap = static_cast<AliMpExMap*>(next()))) {
308
309 cluster = static_cast<AliMUONVCluster*>(cMap->GetValue(clusterId));
310 if (cluster) return cluster;
311
312 }
103e6575 313
314 }
315
316 if (!cluster) AliWarning(Form("cluster %d does not exist",clusterId));
630711ed 317 return 0x0;
318}
319
320//___________________________________________________________________________
321AliMUONVCluster* AliMUONESDInterface::FindCluster(UInt_t trackId, UInt_t clusterId) const
322{
323 /// return cluster "clusterId" in track "trackId" (0x0 if not found)
324 AliMpExMap *cMap = fClusterMap ? static_cast<AliMpExMap*>(fClusterMap->GetValue(trackId)) : 0x0;
325 AliMUONVCluster* cluster = cMap ? static_cast<AliMUONVCluster*>(cMap->GetValue(clusterId)) : 0x0;
326 if (!cluster) AliWarning(Form("cluster %d does not exist in track %d", clusterId, trackId));
103e6575 327 return cluster;
328}
329
330//___________________________________________________________________________
331AliMUONVDigit* AliMUONESDInterface::FindDigit(UInt_t digitId) const
332{
333 /// return digit "digitId" (0x0 if not found)
334 AliMUONVDigit *digit = fDigits ? fDigits->FindObject(digitId) : 0x0;
335 if (!digit) AliWarning(Form("digit %d does not exist",digitId));
336 return digit;
337}
338
339//___________________________________________________________________________
b1fea02e 340AliMUONLocalTrigger* AliMUONESDInterface::FindLocalTrigger(Int_t boardNumber) const
341{
342 /// return MUON local trigger "boardNumber"
343 return (fTriggers) ? fTriggers->FindLocal(boardNumber) : 0x0;
344}
345
346//___________________________________________________________________________
103e6575 347TIterator* AliMUONESDInterface::CreateTrackIterator() const
348{
349 /// return iterator over all tracks
350 return fTracks ? fTracks->CreateIterator() : 0x0;
351}
352
353//___________________________________________________________________________
354TIterator* AliMUONESDInterface::CreateClusterIterator() const
355{
356 /// return iterator over all clusters
357 return fClusterMap ? new AliMUON2DMapIterator(*fClusterMap) : 0x0;
358}
359
360//___________________________________________________________________________
630711ed 361TIterator* AliMUONESDInterface::CreateClusterIterator(UInt_t trackId) const
103e6575 362{
630711ed 363 /// return iterator over clusters of track "trackId"
364 AliMpExMap *cMap = fClusterMap ? static_cast<AliMpExMap*>(fClusterMap->GetValue(trackId)) : 0x0;
365 return cMap ? cMap->CreateIterator() : 0x0;
103e6575 366}
367
368//___________________________________________________________________________
369TIterator* AliMUONESDInterface::CreateDigitIterator() const
370{
371 /// return iterator over all digits
372 return fDigits ? fDigits->CreateIterator() : 0x0;
373}
374
375//___________________________________________________________________________
630711ed 376TIterator* AliMUONESDInterface::CreateDigitIterator(UInt_t trackId) const
103e6575 377{
630711ed 378 /// return iterator over all digits of track "trackId"
379 AliMpExMap* dMaps = fDigitMap ? static_cast<AliMpExMap*>(fDigitMap->GetValue(trackId)) : 0x0;
103e6575 380 return dMaps ? new AliMUON2DMapIterator(*dMaps) : 0x0;
381}
382
383//___________________________________________________________________________
630711ed 384TIterator* AliMUONESDInterface::CreateDigitIterator(UInt_t trackId, UInt_t clusterId) const
103e6575 385{
630711ed 386 /// return iterator over digits of cluster "clusterId" in track "trackId"
387 AliMpExMap* dMaps = fDigitMap ? static_cast<AliMpExMap*>(fDigitMap->GetValue(trackId)) : 0x0;
388 AliMpExMap* dMap = dMaps ? static_cast<AliMpExMap*>(dMaps->GetValue(clusterId)) : 0x0;
389 return dMap ? dMap->CreateIterator() : 0x0;
103e6575 390}
391
392//___________________________________________________________________________
393TIterator* AliMUONESDInterface::CreateDigitIteratorInCluster(UInt_t clusterId) const
394{
630711ed 395 /// return iterator over digits of the first cluster "clusterId" found by looping over all tracks
396 AliMpExMap *dMaps;
103e6575 397 AliMpExMap* dMap = 0x0;
398
630711ed 399 if (fDigitMap) {
103e6575 400
630711ed 401 TIter next(fDigitMap->CreateIterator());
402 while ((dMaps = static_cast<AliMpExMap*>(next()))) {
403
404 dMap = static_cast<AliMpExMap*>(dMaps->GetValue(clusterId));
405 if (dMap) return dMap->CreateIterator();
406
407 }
103e6575 408
409 }
410
630711ed 411 return 0x0;
103e6575 412}
413
414//___________________________________________________________________________
b1fea02e 415TIterator* AliMUONESDInterface::CreateLocalTriggerIterator() const
416{
417 /// return iterator over all local trigger
418 return fTriggers ? fTriggers->CreateLocalIterator() : 0x0;
419}
420
421//___________________________________________________________________________
103e6575 422AliMUONVCluster* AliMUONESDInterface::FindClusterInTrack(const AliMUONTrack& track, UInt_t clusterId) const
423{
424 /// find the cluster with the given Id into the track
425
426 Int_t nClusters = track.GetNClusters();
427 for (Int_t iCluster = 0; iCluster < nClusters; iCluster++) {
428
429 AliMUONVCluster* cluster = ((AliMUONTrackParam*) track.GetTrackParamAtCluster()->UncheckedAt(iCluster))->GetClusterPtr();
430 if (cluster->GetUniqueID() == clusterId) return cluster;
431
432 }
433
434 return 0x0;
435}
436
437//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
438// static methods //
439//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
440
441//_____________________________________________________________________________
a99c3449 442void AliMUONESDInterface::ResetTracker(const AliMUONRecoParam* recoParam, Bool_t info)
ad3c6eda 443{
444 /// Reset the MUON tracker using "recoParam" if provided.
445 /// If not provided, will use Kalman filter + Smoother
446
447 delete fgTracker;
448 delete fgRecoParam;
449
450 if (recoParam) {
451
452 fgRecoParam = new AliMUONRecoParam(*recoParam);
453
a99c3449 454 if (info) cout<<"I-AliMUONESDInterface::ResetTracker: will refit tracks with provided RecoParam:"<<endl;
455
5a240757 456 } else {
ad3c6eda 457
458 fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
4ea3f013 459
460 cout<<"W-AliMUONESDInterface::ResetTracker: RecoParam not provided. Will use default LowFlux parametrization:"<<endl;
a99c3449 461
462 }
463
464 // print useful parameters for refitting
465 if (info) {
4ea3f013 466 cout<<" --> Tracking mode = "<<fgRecoParam->GetTrackingMode()<<endl;
467 if (fgRecoParam->UseSmoother()) cout<<" --> Use Smoother"<<endl;
468 else cout<<" --> Do not use smoother"<<endl;
469 cout<<" --> Vertex dispersion in bending direction = "
a99c3449 470 <<fgRecoParam->GetBendingVertexDispersion()<<" cm"<<endl;
ad3c6eda 471 }
472
a99c3449 473 if (!TGeoGlobalMagField::Instance()->GetField())
474 cout<<"W-AliMUONESDInterface::ResetTracker: Magnetic field has not been set --> assume field is OFF"<<endl;
475
ad3c6eda 476 fgTracker = AliMUONTracker::CreateTrackReconstructor(fgRecoParam,0x0);
477
478}
479
480//_____________________________________________________________________________
103e6575 481AliMUONVTrackStore* AliMUONESDInterface::NewTrackStore()
482{
483 /// Create an empty track store of type fgTrackStoreName
484 TClass* classPtr = TClass::GetClass(fgTrackStoreName);
485 if (!classPtr || !classPtr->InheritsFrom("AliMUONVTrackStore")) {
486 cout<<"E-AliMUONESDInterface::NewTrackStore: Unable to create store of type "<<fgTrackStoreName.Data()<<endl;
487 return 0x0;
488 }
489 return reinterpret_cast<AliMUONVTrackStore*>(classPtr->New());
490}
491
492//_____________________________________________________________________________
493AliMUONVClusterStore* AliMUONESDInterface::NewClusterStore()
494{
495 /// Create an empty cluster store of type fgClusterStoreName
496 TClass* classPtr = TClass::GetClass(fgClusterStoreName);
497 if (!classPtr || !classPtr->InheritsFrom("AliMUONVClusterStore")) {
498 cout<<"E-AliMUONESDInterface::NewClusterStore: Unable to create store of type "<<fgClusterStoreName.Data()<<endl;
499 return 0x0;
500 }
501 return reinterpret_cast<AliMUONVClusterStore*>(classPtr->New());
502}
503
504//_____________________________________________________________________________
505AliMUONVDigitStore* AliMUONESDInterface::NewDigitStore()
506{
507 /// Create an empty digit store of type fgDigitStoreName
508 TClass* classPtr = TClass::GetClass(fgDigitStoreName);
509 if (!classPtr || !classPtr->InheritsFrom("AliMUONVDigitStore")) {
510 cout<<"E-AliMUONESDInterface::NewDigitStore: Unable to create store of type "<<fgDigitStoreName.Data()<<endl;
511 return 0x0;
512 }
513 return reinterpret_cast<AliMUONVDigitStore*>(classPtr->New());
514}
515
b1fea02e 516//_____________________________________________________________________________
517AliMUONVTriggerStore* AliMUONESDInterface::NewTriggerStore()
518{
519 /// Create an empty trigger store of type fgTriggerStoreName
520 TClass* classPtr = TClass::GetClass(fgTriggerStoreName);
521 if (!classPtr || !classPtr->InheritsFrom("AliMUONVTriggerStore")) {
522 cout<<"E-AliMUONESDInterface::NewTriggerStore: Unable to create store of type "<<fgTriggerStoreName.Data()<<endl;
523 return 0x0;
524 }
525 return reinterpret_cast<AliMUONVTriggerStore*>(classPtr->New());
526}
527
9f164762 528//_____________________________________________________________________________
529AliMUONVTriggerTrackStore* AliMUONESDInterface::NewTriggerTrackStore()
530{
531 /// Create an empty trigger track store of type fgTriggerTrackStoreName
532 TClass* classPtr = TClass::GetClass(fgTriggerTrackStoreName);
533 if (!classPtr || !classPtr->InheritsFrom("AliMUONVTriggerTrackStore")) {
534 cout<<"E-AliMUONESDInterface::NewTriggerTrackStore: Unable to create store of type "<<fgTriggerTrackStoreName.Data()<<endl;
535 return 0x0;
536 }
537 return reinterpret_cast<AliMUONVTriggerTrackStore*>(classPtr->New());
538}
539
103e6575 540//_________________________________________________________________________
541void AliMUONESDInterface::GetParamAtVertex(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam)
542{
543 /// Get parameters at vertex from ESDMuon track
544 trackParam.SetZ(esdTrack.GetZ());
545 trackParam.SetNonBendingCoor(esdTrack.GetNonBendingCoor());
546 trackParam.SetNonBendingSlope(TMath::Tan(esdTrack.GetThetaX()));
547 trackParam.SetBendingCoor(esdTrack.GetBendingCoor());
548 trackParam.SetBendingSlope(TMath::Tan(esdTrack.GetThetaY()));
549 trackParam.SetInverseBendingMomentum(esdTrack.GetInverseBendingMomentum());
550}
551
552//_________________________________________________________________________
553void AliMUONESDInterface::GetParamAtDCA(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam)
554{
555 /// Get parameters at DCA from ESDMuon track
556 trackParam.SetZ(esdTrack.GetZ());
557 trackParam.SetNonBendingCoor(esdTrack.GetNonBendingCoorAtDCA());
558 trackParam.SetNonBendingSlope(TMath::Tan(esdTrack.GetThetaXAtDCA()));
559 trackParam.SetBendingCoor(esdTrack.GetBendingCoorAtDCA());
560 trackParam.SetBendingSlope(TMath::Tan(esdTrack.GetThetaYAtDCA()));
561 trackParam.SetInverseBendingMomentum(esdTrack.GetInverseBendingMomentumAtDCA());
562}
563
564//_________________________________________________________________________
565void AliMUONESDInterface::GetParamAtFirstCluster(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam)
566{
567 /// Get parameters at first cluster from ESDMuon track
568 trackParam.SetZ(esdTrack.GetZUncorrected());
569 trackParam.SetNonBendingCoor(esdTrack.GetNonBendingCoorUncorrected());
570 trackParam.SetNonBendingSlope(TMath::Tan(esdTrack.GetThetaXUncorrected()));
571 trackParam.SetBendingCoor(esdTrack.GetBendingCoorUncorrected());
572 trackParam.SetBendingSlope(TMath::Tan(esdTrack.GetThetaYUncorrected()));
573 trackParam.SetInverseBendingMomentum(esdTrack.GetInverseBendingMomentumUncorrected());
574}
575
576//_________________________________________________________________________
577void AliMUONESDInterface::GetParamCov(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam)
578{
579 /// Get parameters covariances from ESD track
580
581 // get ESD covariance matrix
582 TMatrixD covariances(5,5);
583 esdTrack.GetCovariances(covariances);
584
585 // compute Jacobian to change the coordinate system
586 // from (X,thetaX,Y,thetaY,c/pYZ) to (X,slopeX,Y,slopeY,c/pYZ)
587 Double_t cosThetaX = TMath::Cos(esdTrack.GetThetaXUncorrected());
588 Double_t cosThetaY = TMath::Cos(esdTrack.GetThetaYUncorrected());
589 TMatrixD jacob(5,5);
590 jacob.Zero();
591 jacob(0,0) = 1.;
592 jacob(1,1) = 1. / cosThetaX / cosThetaX;
593 jacob(2,2) = 1.;
594 jacob(3,3) = 1. / cosThetaY / cosThetaY;
595 jacob(4,4) = 1.;
596
597 // compute covariance matrix in ESD coordinate system
598 TMatrixD tmp(covariances,TMatrixD::kMultTranspose,jacob);
599 trackParam.SetCovariances(TMatrixD(jacob,TMatrixD::kMult,tmp));
600
601}
602
603//_________________________________________________________________________
604void AliMUONESDInterface::SetParamAtVertex(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack)
605{
606 /// Set parameters in ESD track
607 esdTrack.SetZ(trackParam.GetZ());
608 esdTrack.SetNonBendingCoor(trackParam.GetNonBendingCoor());
609 esdTrack.SetThetaX(TMath::ATan(trackParam.GetNonBendingSlope()));
610 esdTrack.SetBendingCoor(trackParam.GetBendingCoor());
611 esdTrack.SetThetaY(TMath::ATan(trackParam.GetBendingSlope()));
612 esdTrack.SetInverseBendingMomentum(trackParam.GetInverseBendingMomentum());
613}
614
615//_________________________________________________________________________
616void AliMUONESDInterface::SetParamAtDCA(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack)
617{
618 /// Set parameters in ESD track
619 esdTrack.SetNonBendingCoorAtDCA(trackParam.GetNonBendingCoor());
620 esdTrack.SetThetaXAtDCA(TMath::ATan(trackParam.GetNonBendingSlope()));
621 esdTrack.SetBendingCoorAtDCA(trackParam.GetBendingCoor());
622 esdTrack.SetThetaYAtDCA(TMath::ATan(trackParam.GetBendingSlope()));
623 esdTrack.SetInverseBendingMomentumAtDCA(trackParam.GetInverseBendingMomentum());
624}
625
626//_________________________________________________________________________
627void AliMUONESDInterface::SetParamAtFirstCluster(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack)
628{
629 /// Set parameters in ESD track
630 esdTrack.SetZUncorrected(trackParam.GetZ());
631 esdTrack.SetNonBendingCoorUncorrected(trackParam.GetNonBendingCoor());
632 esdTrack.SetThetaXUncorrected(TMath::ATan(trackParam.GetNonBendingSlope()));
633 esdTrack.SetBendingCoorUncorrected(trackParam.GetBendingCoor());
634 esdTrack.SetThetaYUncorrected(TMath::ATan(trackParam.GetBendingSlope()));
635 esdTrack.SetInverseBendingMomentumUncorrected(trackParam.GetInverseBendingMomentum());
636}
637
638//_________________________________________________________________________
639void AliMUONESDInterface::SetParamCov(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack)
640{
641 /// Set parameters covariances in ESD track
642
643 // set null matrix if covariances does not exist
644 if (!trackParam.CovariancesExist()) {
645 TMatrixD tmp(5,5);
646 tmp.Zero();
647 esdTrack.SetCovariances(tmp);
648 return;
649 }
650
651 // compute Jacobian to change the coordinate system
652 // from (X,slopeX,Y,slopeY,c/pYZ) to (X,thetaX,Y,thetaY,c/pYZ)
653 Double_t cosThetaX = TMath::Cos(TMath::ATan(trackParam.GetNonBendingSlope()));
654 Double_t cosThetaY = TMath::Cos(TMath::ATan(trackParam.GetBendingSlope()));
655 TMatrixD jacob(5,5);
656 jacob.Zero();
657 jacob(0,0) = 1.;
658 jacob(1,1) = cosThetaX * cosThetaX;
659 jacob(2,2) = 1.;
660 jacob(3,3) = cosThetaY * cosThetaY;
661 jacob(4,4) = 1.;
662
663 // compute covariance matrix in ESD coordinate system
664 TMatrixD tmp(trackParam.GetCovariances(),TMatrixD::kMultTranspose,jacob);
665 esdTrack.SetCovariances(TMatrixD(jacob,TMatrixD::kMult,tmp));
666
667}
668
669//_____________________________________________________________________________
a99c3449 670void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track, Bool_t refit)
103e6575 671{
c59f70b9 672 /// Transfert data from ESDMuon track to MUON track.
a99c3449 673 /// If refit = kTRUE, the track parameters at each cluster are obtained by refitting the track
c59f70b9 674 /// or by extrapolating the parameters at the first one if the refit failed.
a99c3449 675 /// If refit = kFALSE, only the track parameters at first cluster are valid.
c59f70b9 676 /// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
677 /// By default we use Kalman filter + Smoother
103e6575 678
b1fea02e 679 // if the ESDMuon track is a ghost then return an empty MUON track
680 if (!esdTrack.ContainTrackerData()) {
681 track.Reset();
682 track.SetUniqueID(esdTrack.GetUniqueID());
683 return;
684 }
685
103e6575 686 track.Clear("C");
687
688 // global info
689 track.SetUniqueID(esdTrack.GetUniqueID());
690 track.FitWithVertex(kFALSE);
691 track.FitWithMCS(kFALSE);
692 track.SetImproved(kFALSE);
693 track.SetVertexErrXY2(0.,0.);
694 track.SetGlobalChi2(esdTrack.GetChi2());
695 track.SetMatchTrigger(esdTrack.GetMatchTrigger());
103e6575 696 track.SetChi2MatchTrigger(esdTrack.GetChi2MatchTrigger());
103e6575 697 track.SetHitsPatternInTrigCh(esdTrack.GetHitsPatternInTrigCh());
698 track.SetLocalTrigger(esdTrack.LoCircuit(), esdTrack.LoStripX(), esdTrack.LoStripY(),
00d46f24 699 esdTrack.LoDev(), esdTrack.LoLpt(), esdTrack.LoHpt(),
700 esdTrack.GetTriggerWithoutChamber());
5c15a68b 701 track.Connected(esdTrack.IsConnected());
103e6575 702
703 // track parameters at vertex
704 AliMUONTrackParam paramAtVertex;
705 GetParamAtVertex(esdTrack, paramAtVertex);
706 track.SetTrackParamAtVertex(&paramAtVertex);
707
708 // track parameters at first cluster
709 AliMUONTrackParam param;
710 GetParamAtFirstCluster(esdTrack, param);
711 GetParamCov(esdTrack, param);
712
713 // create empty cluster
714 AliMUONVClusterStore* cStore = NewClusterStore();
715 if (!cStore) return;
716 AliMUONVCluster* cluster = cStore->CreateCluster(0,0,0);
717
718 // fill TrackParamAtCluster with track parameters at each cluster if available
719 // or with only track parameters at first (fake) cluster if not
720 if(esdTrack.ClustersStored()) {
721
722 // loop over ESD clusters
723 AliESDMuonCluster *esdCluster = (AliESDMuonCluster*) esdTrack.GetClusters().First();
724 while (esdCluster) {
725
726 // copy cluster information
727 ESDToMUON(*esdCluster, *cluster);
728
729 // only set the Z parameter to avoid error in the AddTrackParamAtCluster(...) method
730 param.SetZ(cluster->GetZ());
731
732 // add common track parameters at current cluster
733 track.AddTrackParamAtCluster(param, *cluster, kTRUE);
734
735 esdCluster = (AliESDMuonCluster*) esdTrack.GetClusters().After(esdCluster);
736 }
737
b1fea02e 738 // refit the track to get better parameters and covariances at each cluster (temporary disable track improvement)
a99c3449 739 if (refit) {
740
741 AliMUONTrackParam *firstTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First();
742 AliMUONTrackParam paramSave(*firstTrackParam);
743
744 if (!fgTracker) ResetTracker();
745
746 if (!fgTracker->RefitTrack(track, kFALSE) && track.GetGlobalChi2() < AliMUONTrack::MaxChi2()) {
747 *firstTrackParam = paramSave;
748 track.UpdateCovTrackParamAtCluster();
749 }
750
751 }
103e6575 752
753 } else {
754
c59f70b9 755 // get number of the first hit chamber according to the MUONClusterMap
103e6575 756 Int_t firstCh = 0;
c59f70b9 757 while (firstCh < 10 && !esdTrack.IsInMuonClusterMap(firstCh)) firstCh++;
103e6575 758
759 // produce fake cluster at this chamber
760 cluster->SetUniqueID(AliMUONVCluster::BuildUniqueID(firstCh, 0, 0));
761 cluster->SetXYZ(param.GetNonBendingCoor(), param.GetBendingCoor(), param.GetZ());
762 cluster->SetErrXY(0., 0.);
763
764 // add track parameters at first (fake) cluster
765 track.AddTrackParamAtCluster(param, *cluster, kTRUE);
766
767 }
768
2e2d0c44 769 // set the MC label from ESD track
770 track.SetMCLabel(esdTrack.GetLabel());
771
103e6575 772 delete cluster;
773 delete cStore;
774
775}
776
777//_____________________________________________________________________________
b1fea02e 778void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONLocalTrigger& locTrg)
779{
780 /// Transfert trigger data from ESDMuon track to the MUONLocalTtrigger object
781
782 // if the ESDMuon track is a ghost then return an empty MUON track
783 if (!esdTrack.ContainTriggerData()) {
784 AliMUONLocalTrigger emptyLocTrg;
785 locTrg = emptyLocTrg;
786 return;
787 }
788
8f16115a 789 locTrg.SetUniqueID(esdTrack.GetUniqueID());
b1fea02e 790 locTrg.SetLoCircuit(esdTrack.LoCircuit());
791 locTrg.SetLoStripX(esdTrack.LoStripX());
792 locTrg.SetLoStripY(esdTrack.LoStripY());
5a240757 793 locTrg.SetDeviation(esdTrack.LoDev());
b1fea02e 794 locTrg.SetLoLpt(esdTrack.LoLpt());
795 locTrg.SetLoHpt(esdTrack.LoHpt());
00d46f24 796 locTrg.SetTriggerWithoutChamber(esdTrack.GetTriggerWithoutChamber());
b1fea02e 797 locTrg.SetLoTrigY(1);
798 locTrg.SetX1Pattern(esdTrack.GetTriggerX1Pattern());
799 locTrg.SetX2Pattern(esdTrack.GetTriggerX2Pattern());
800 locTrg.SetX3Pattern(esdTrack.GetTriggerX3Pattern());
801 locTrg.SetX4Pattern(esdTrack.GetTriggerX4Pattern());
802 locTrg.SetY1Pattern(esdTrack.GetTriggerY1Pattern());
803 locTrg.SetY2Pattern(esdTrack.GetTriggerY2Pattern());
804 locTrg.SetY3Pattern(esdTrack.GetTriggerY3Pattern());
805 locTrg.SetY4Pattern(esdTrack.GetTriggerY4Pattern());
806
807}
808
809//_____________________________________________________________________________
103e6575 810void AliMUONESDInterface::ESDToMUON(const AliESDMuonCluster& esdCluster, AliMUONVCluster& cluster)
811{
812 /// Transfert data from ESDMuon cluster to MUON cluster
813
814 cluster.Clear("C");
815
816 cluster.SetUniqueID(esdCluster.GetUniqueID());
817 cluster.SetXYZ(esdCluster.GetX(), esdCluster.GetY(), esdCluster.GetZ());
818 cluster.SetErrXY(esdCluster.GetErrX(),esdCluster.GetErrY());
819 cluster.SetCharge(esdCluster.GetCharge());
820 cluster.SetChi2(esdCluster.GetChi2());
2e2d0c44 821 cluster.SetMCLabel(esdCluster.GetLabel());
103e6575 822
823 if (esdCluster.PadsStored()) {
824 Int_t nPads = esdCluster.GetNPads();
825 for (Int_t iPad = 0; iPad < nPads; iPad++)
826 cluster.AddDigitId(((AliESDMuonPad*)esdCluster.GetPads().UncheckedAt(iPad))->GetUniqueID());
827 }
828
829}
830
831//___________________________________________________________________________
832void AliMUONESDInterface::ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit& digit)
833{
834 /// Transfert data from ESDMuon pad to MUON digit
835
a99c3449 836 if (!AliMpSegmentation::Instance(kFALSE)) {
837 cout<<"E-AliMUONESDInterface::ESDToMUON: need mapping segmentation to convert ESD pad to MUON digit"<<endl;
838 return;
839 }
840
103e6575 841 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(esdPad.GetDetElemId(), esdPad.GetManuId());
168e9c4d 842 AliMpPad pad = seg->PadByLocation(esdPad.GetManuId(), esdPad.GetManuChannel(), kFALSE);
103e6575 843
b1fea02e 844 digit.Saturated(esdPad.IsSaturated());
103e6575 845 digit.Used(kFALSE);
b1fea02e 846 digit.Calibrated(esdPad.IsCalibrated());
103e6575 847 digit.SetUniqueID(esdPad.GetUniqueID());
848 digit.SetCharge(esdPad.GetCharge());
849 digit.SetADC(esdPad.GetADC());
168e9c4d 850 digit.SetPadXY(pad.GetIx(), pad.GetIy());
103e6575 851
852}
853
854//_____________________________________________________________________________
b1fea02e 855void AliMUONESDInterface::MUONToESD(const AliMUONTrack& track, AliESDMuonTrack& esdTrack, const Double_t vertex[3],
856 const AliMUONVDigitStore* digits, const AliMUONLocalTrigger* locTrg)
103e6575 857{
858 /// Transfert data from MUON track to ESDMuon track
859 /// Incorporate the ESDPads if the digits are provided
b1fea02e 860 /// Add trigger info if the MUON track is matched with a trigger track
861
862 // empty MUON track -> produce a ghost ESDMuon track if trigger info are available otherwise produce an empty track
863 if (track.GetNClusters() == 0) {
67c201be 864 if (locTrg) MUONToESD(*locTrg, esdTrack, track.GetUniqueID());
b1fea02e 865 else {
866 cout<<"W-AliMUONESDInterface::MUONToESD: will produce an empty ESDMuon track"<<endl;
867 esdTrack.Reset();
868 esdTrack.SetUniqueID(0xFFFFFFFF);
869 }
870 return;
871 }
103e6575 872
873 esdTrack.Clear("C");
874
b1fea02e 875 // set global info
876 esdTrack.SetUniqueID(track.GetUniqueID());
877 esdTrack.SetChi2(track.GetGlobalChi2());
878 esdTrack.SetNHit(track.GetNClusters());
2e2d0c44 879 esdTrack.SetLabel(track.GetMCLabel());
b1fea02e 880
103e6575 881 // set param at first cluster
882 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track.GetTrackParamAtCluster())->First());
883 SetParamAtFirstCluster(*trackParam, esdTrack);
884 SetParamCov(*trackParam, esdTrack);
885
f43586f0 886 // set transverse position at the end of the absorber
887 AliMUONTrackParam trackParamAtAbsEnd(*trackParam);
888 AliMUONTrackExtrap::ExtrapToZ(&trackParamAtAbsEnd, AliMUONConstants::AbsZEnd());
889 Double_t xAbs = trackParamAtAbsEnd.GetNonBendingCoor();
890 Double_t yAbs = trackParamAtAbsEnd.GetBendingCoor();
891 esdTrack.SetRAtAbsorberEnd(TMath::Sqrt(xAbs*xAbs + yAbs*yAbs));
892
103e6575 893 // set param at vertex
894 AliMUONTrackParam trackParamAtVtx(*trackParam);
895 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0], vertex[1], vertex[2], 0., 0.);
896 SetParamAtVertex(trackParamAtVtx, esdTrack);
897
898 // set param at Distance of Closest Approach
899 AliMUONTrackParam trackParamAtDCA(*trackParam);
900 AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&trackParamAtDCA, vertex[2]);
901 SetParamAtDCA(trackParamAtDCA, esdTrack);
902
103e6575 903 // set muon cluster info
904 AliESDMuonCluster esdCluster;
905 esdTrack.SetMuonClusterMap(0);
906 while (trackParam) {
907 MUONToESD(*(trackParam->GetClusterPtr()), esdCluster, digits);
908 esdTrack.AddCluster(esdCluster);
909 esdTrack.AddInMuonClusterMap(esdCluster.GetChamberId());
910 trackParam = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->After(trackParam));
911 }
912
5c15a68b 913 // set connected flag
914 esdTrack.Connected(track.IsConnected());
915
b1fea02e 916 // set trigger info
917 esdTrack.SetLocalTrigger(track.GetLocalTrigger());
918 esdTrack.SetChi2MatchTrigger(track.GetChi2MatchTrigger());
919 esdTrack.SetHitsPatternInTrigCh(track.GetHitsPatternInTrigCh());
920 if (locTrg) {
921 esdTrack.SetTriggerX1Pattern(locTrg->GetX1Pattern());
922 esdTrack.SetTriggerY1Pattern(locTrg->GetY1Pattern());
923 esdTrack.SetTriggerX2Pattern(locTrg->GetX2Pattern());
924 esdTrack.SetTriggerY2Pattern(locTrg->GetY2Pattern());
925 esdTrack.SetTriggerX3Pattern(locTrg->GetX3Pattern());
926 esdTrack.SetTriggerY3Pattern(locTrg->GetY3Pattern());
927 esdTrack.SetTriggerX4Pattern(locTrg->GetX4Pattern());
928 esdTrack.SetTriggerY4Pattern(locTrg->GetY4Pattern());
929 } else {
930 esdTrack.SetTriggerX1Pattern(0);
931 esdTrack.SetTriggerY1Pattern(0);
932 esdTrack.SetTriggerX2Pattern(0);
933 esdTrack.SetTriggerY2Pattern(0);
934 esdTrack.SetTriggerX3Pattern(0);
935 esdTrack.SetTriggerY3Pattern(0);
936 esdTrack.SetTriggerX4Pattern(0);
937 esdTrack.SetTriggerY4Pattern(0);
938 }
939
940}
941
942//_____________________________________________________________________________
67c201be 943void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuonTrack& esdTrack,
944 UInt_t trackId, const AliMUONTriggerTrack* triggerTrack)
b1fea02e 945{
946 /// Build ghost ESDMuon track containing only informations about trigger track
947
948 esdTrack.Reset();
949 esdTrack.SetUniqueID(trackId);
950
951 // set trigger info
952 AliMUONTrack muonTrack;
953 muonTrack.SetLocalTrigger(locTrg.LoCircuit(),
954 locTrg.LoStripX(),
955 locTrg.LoStripY(),
98606cfc 956 locTrg.GetDeviation(),
b1fea02e 957 locTrg.LoLpt(),
00d46f24 958 locTrg.LoHpt(),
959 locTrg.GetTriggerWithoutChamber());
b1fea02e 960 esdTrack.SetLocalTrigger(muonTrack.GetLocalTrigger());
961 esdTrack.SetChi2MatchTrigger(0.);
b1fea02e 962 esdTrack.SetTriggerX1Pattern(locTrg.GetX1Pattern());
963 esdTrack.SetTriggerY1Pattern(locTrg.GetY1Pattern());
964 esdTrack.SetTriggerX2Pattern(locTrg.GetX2Pattern());
965 esdTrack.SetTriggerY2Pattern(locTrg.GetY2Pattern());
966 esdTrack.SetTriggerX3Pattern(locTrg.GetX3Pattern());
967 esdTrack.SetTriggerY3Pattern(locTrg.GetY3Pattern());
968 esdTrack.SetTriggerX4Pattern(locTrg.GetX4Pattern());
969 esdTrack.SetTriggerY4Pattern(locTrg.GetY4Pattern());
67c201be 970 UShort_t hitPattern = 0;
971 if(triggerTrack){
972 hitPattern = triggerTrack->GetHitsPatternInTrigCh();
973 esdTrack.SetHitsPatternInTrigCh(hitPattern);
974 esdTrack.SetThetaXUncorrected(triggerTrack->GetThetax());
975 esdTrack.SetThetaYUncorrected(triggerTrack->GetThetay());
976 esdTrack.SetNonBendingCoorUncorrected(triggerTrack->GetX11());
977 esdTrack.SetBendingCoorUncorrected(triggerTrack->GetY11());
bdfb6eef 978 esdTrack.SetZUncorrected(triggerTrack->GetZ11());
67c201be 979 }
103e6575 980}
981
982//_____________________________________________________________________________
983void AliMUONESDInterface::MUONToESD(const AliMUONVCluster& cluster, AliESDMuonCluster& esdCluster, const AliMUONVDigitStore* digits)
984{
985 /// Transfert data from MUON cluster to ESDMuon cluster
986 /// Incorporate the ESDPads if the digits are provided
987
988 esdCluster.Clear("C");
989
990 esdCluster.SetUniqueID(cluster.GetUniqueID());
991 esdCluster.SetXYZ(cluster.GetX(), cluster.GetY(), cluster.GetZ());
992 esdCluster.SetErrXY(cluster.GetErrX(), cluster.GetErrY());
630711ed 993 esdCluster.SetCharge(cluster.GetCharge());
994 esdCluster.SetChi2(cluster.GetChi2());
2e2d0c44 995 esdCluster.SetLabel(cluster.GetMCLabel());
103e6575 996
630711ed 997 if (digits) { // transfert all data if required
103e6575 998
103e6575 999 AliESDMuonPad esdPad;
1000 for (Int_t i=0; i<cluster.GetNDigits(); i++) {
1001 AliMUONVDigit* digit = digits->FindObject(cluster.GetDigitId(i));
1002 if (!digit) {
1003 cout<<"E-AliMUONESDInterface::MUONToESD: digit "<<cluster.GetDigitId(i)<<" not found"<<endl;
1004 continue;
1005 }
1006 MUONToESD(*digit, esdPad);
1007 esdCluster.AddPad(esdPad);
1008 }
1009
103e6575 1010 }
1011
1012}
1013
1014//_____________________________________________________________________________
1015void AliMUONESDInterface::MUONToESD(const AliMUONVDigit& digit, AliESDMuonPad& esdPad)
1016{
1017 /// Transfert data from MUON digit to ESDMuon pad
1018 esdPad.SetUniqueID(digit.GetUniqueID());
1019 esdPad.SetADC(digit.ADC());
1020 esdPad.SetCharge(digit.Charge());
b1fea02e 1021 esdPad.SetCalibrated(digit.IsCalibrated());
1022 esdPad.SetSaturated(digit.IsSaturated());
103e6575 1023}
1024
1025//___________________________________________________________________________
a99c3449 1026AliMUONTrack* AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore, Bool_t refit)
103e6575 1027{
1028 /// Create MUON track from ESDMuon track and add it to the store
a99c3449 1029 /// Track parameters at each clusters are recomputed or not depending on the flag "refit"
b1fea02e 1030 /// return a pointer to the track into the store (0x0 if the track already exist)
1031 if(trackStore.FindObject(esdTrack.GetUniqueID())) return 0x0;
103e6575 1032 AliMUONTrack* track = trackStore.Add(AliMUONTrack());
a99c3449 1033 ESDToMUON(esdTrack, *track, refit);
103e6575 1034 return track;
1035}
1036
1037//___________________________________________________________________________
b1fea02e 1038void AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTriggerStore& triggerStore)
1039{
1040 /// Create MUON local trigger from ESDMuon track and add it to the store if not already there
81d71c13 1041 if (!triggerStore.FindLocal(esdTrack.LoCircuit())->IsNull()) return;
b1fea02e 1042 AliMUONLocalTrigger locTrg;
1043 ESDToMUON(esdTrack, locTrg);
1044 triggerStore.Add(locTrg);
1045}
1046
1047//___________________________________________________________________________
103e6575 1048AliMUONVCluster* AliMUONESDInterface::Add(const AliESDMuonCluster& esdCluster, AliMUONVClusterStore& clusterStore)
1049{
1050 /// Create MUON cluster from ESDMuon cluster and add it to the store
1051 /// return a pointer to the cluster into the store (0x0 if the cluster already exist)
1052 AliMUONVCluster* cluster = clusterStore.Add(esdCluster.GetChamberId(), esdCluster.GetDetElemId(), esdCluster.GetClusterIndex());
1053 if (cluster) ESDToMUON(esdCluster, *cluster);
1054 return cluster;
1055}
1056
1057//___________________________________________________________________________
1058AliMUONVDigit* AliMUONESDInterface::Add(const AliESDMuonPad& esdPad, AliMUONVDigitStore& digitStore)
1059{
1060 /// Create MUON digit from ESDMuon digit and add it to the store
1061 /// return a pointer to the digit into the store (0x0 if the digit already exist)
1062 AliMUONVDigit* digit = digitStore.Add(esdPad.GetDetElemId(), esdPad.GetManuId(), esdPad.GetManuChannel(), esdPad.GetCathode(), AliMUONVDigitStore::kDeny);
1063 if (digit) ESDToMUON(esdPad, *digit);
1064 return digit;
1065}
1066