]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONESDInterface.cxx
Do not update AMORE pool with an empty object
[u/mrichter/AliRoot.git] / MUON / AliMUONESDInterface.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 #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"
25 #include "AliMUONLocalTrigger.h"
26 #include "AliMUONTriggerTrack.h"
27 #include "AliMUONVTriggerStore.h"
28 #include "AliMUONVTriggerTrackStore.h"
29 #include "AliMUON2DMapIterator.h"
30 #include "AliMUONTrackParam.h"
31 #include "AliMUONTrackExtrap.h"
32 #include "AliMUONConstants.h"
33 #include "AliMUONTracker.h"
34 #include "AliMUONRecoParam.h"
35 #include "AliMUONVTrackReconstructor.h"
36
37 #include "AliMpExMapIterator.h"
38 #include "AliMpVSegmentation.h"
39 #include "AliMpSegmentation.h"
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>
53 #include <TGeoGlobalMagField.h>
54 #include <TVirtualMagField.h>
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 ///
64 /// 2) loading a whole ESDEvent and using the finders and/or the iterators
65 ///    to access the corresponding MUON objects
66 ///
67 /// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
68 ///       By default we use Kalman filter + Smoother
69 ///
70 /// \author Philippe Pillot
71 //-----------------------------------------------------------------------------
72
73 /// \cond CLASSIMP
74 ClassImp(AliMUONESDInterface)
75 /// \endcond
76
77 AliMUONRecoParam* AliMUONESDInterface::fgRecoParam = 0x0;
78 AliMUONVTrackReconstructor* AliMUONESDInterface::fgTracker = 0x0;
79
80 TString AliMUONESDInterface::fgTrackStoreName = "AliMUONTrackStoreV1";
81 TString AliMUONESDInterface::fgClusterStoreName = "AliMUONClusterStoreV2";
82 TString AliMUONESDInterface::fgDigitStoreName = "AliMUONDigitStoreV2R";
83 TString AliMUONESDInterface::fgTriggerStoreName = "AliMUONTriggerStoreV1";
84 TString AliMUONESDInterface::fgTriggerTrackStoreName = "AliMUONTriggerTrackStoreV1";
85
86 //_____________________________________________________________________________
87 AliMUONESDInterface::AliMUONESDInterface()
88 : TObject(),
89 fTracks(0x0),
90 fDigits(0x0),
91 fTriggers(0x0),
92 fClusterMap(0x0),
93 fDigitMap(0x0)
94 {
95   /// Default constructor
96 }
97
98 //_____________________________________________________________________________
99 AliMUONESDInterface::~AliMUONESDInterface()
100 {
101   /// Destructor
102   delete fTracks;
103   delete fDigits;
104   delete fTriggers;
105   delete fClusterMap;
106   delete fDigitMap;
107 }
108
109 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
110 //                    methods to play with internal objects                    //
111 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
112
113 //_____________________________________________________________________________
114 void AliMUONESDInterface::Clear(Option_t*)
115 {
116   /// clear memory
117   delete fTracks; fTracks = 0x0;
118   delete fDigits; fDigits = 0x0;
119   delete fTriggers; fTriggers = 0x0;
120   delete fClusterMap; fClusterMap = 0x0;
121   delete fDigitMap; fDigitMap = 0x0;
122 }
123
124 //_____________________________________________________________________________
125 void 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   
135   if (fTriggers) fTriggers->Clear("C");
136   else fTriggers = NewTriggerStore();
137   
138   if (fClusterMap) fClusterMap->Clear();
139   else fClusterMap = new AliMpExMap;
140   fClusterMap->SetOwner(kTRUE);
141   
142   if (fDigitMap) fDigitMap->Clear();
143   else fDigitMap = new AliMpExMap;
144   fDigitMap->SetOwner(kTRUE);
145 }
146
147 //_____________________________________________________________________________
148 void AliMUONESDInterface::LoadEvent(AliESDEvent& esdEvent, Bool_t refit)
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     
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     
168     // add it to track store
169     AliMUONTrack* track = Add(*esdTrack, *fTracks, refit);
170     
171     // prepare cluster map
172     AliMpExMap* cMap = new AliMpExMap;
173     cMap->SetOwner(kFALSE);
174     fClusterMap->Add(esdTrack->GetUniqueID(), cMap);
175     
176     // prepare digit maps
177     AliMpExMap* dMaps = new AliMpExMap;
178     dMaps->SetOwner(kTRUE);
179     fDigitMap->Add(esdTrack->GetUniqueID(), dMaps);
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
195       AliMpExMap* dMap =new AliMpExMap;
196       dMap->SetOwner(kFALSE);
197       dMaps->Add(esdCluster->GetUniqueID(), dMap);
198       
199       // loop over ESD pads
200       Int_t nPads = esdCluster->GetNPads();
201       for (Int_t iPad = 0; iPad < nPads; iPad++) {
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 //___________________________________________________________________________
222 Int_t AliMUONESDInterface::GetNTracks() const
223 {
224   /// return the number of tracks
225   return fTracks ? fTracks->GetSize() : 0;
226 }
227
228 //___________________________________________________________________________
229 Int_t AliMUONESDInterface::GetNClusters() const
230 {
231   /// return the number of clusters
232   Int_t nClusters = 0;
233   AliMUONTrack *track;
234   TIter next(CreateTrackIterator());
235   while ((track = static_cast<AliMUONTrack*>(next()))) nClusters += track->GetNClusters();
236   return nClusters;
237 }
238
239 //___________________________________________________________________________
240 Int_t AliMUONESDInterface::GetNClusters(UInt_t trackId) const
241 {
242   /// return the number of clusters in track "trackId"
243   AliMUONTrack* track = FindTrack(trackId);
244   return track ? track->GetNClusters() : 0;
245 }
246
247 //___________________________________________________________________________
248 Int_t AliMUONESDInterface::GetNDigits() const
249 {
250   /// return the number of digits
251   return fDigits ? fDigits->GetSize() : 0;
252 }
253
254 //___________________________________________________________________________
255 Int_t AliMUONESDInterface::GetNDigits(UInt_t trackId) const
256 {
257   /// return the number of digits in all clusters of track "trackId"
258   Int_t nDigits = 0;
259   AliMUONVCluster *cluster;
260   TIter next(CreateClusterIterator(trackId));
261   while ((cluster = static_cast<AliMUONVCluster*>(next()))) nDigits += cluster->GetNDigits();
262   return nDigits;
263 }
264
265 //___________________________________________________________________________
266 Int_t AliMUONESDInterface::GetNDigits(UInt_t trackId, UInt_t clusterId) const
267 {
268   /// return the number of digits in cluster numbered "iCluster" of track "iTrack"
269   AliMUONVCluster* cluster = FindCluster(trackId, clusterId);
270   return cluster ? cluster->GetNDigits() : 0;
271 }
272
273 //___________________________________________________________________________
274 Int_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 //___________________________________________________________________________
282 Int_t AliMUONESDInterface::GetNTriggers() const
283 {
284   /// return the number of triggers
285   return fTriggers ? fTriggers->GetSize() : 0;
286 }
287
288 //___________________________________________________________________________
289 AliMUONTrack* AliMUONESDInterface::FindTrack(UInt_t trackId) const
290 {
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));
294   return track;
295 }
296
297 //___________________________________________________________________________
298 AliMUONVCluster* AliMUONESDInterface::FindCluster(UInt_t clusterId) const
299 {
300   /// loop over tracks and return the first cluster "clusterId" found (0x0 if not found)
301   AliMpExMap *cMap;
302   AliMUONVCluster* cluster = 0x0;
303   
304   if (fClusterMap) {
305     
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     }
313     
314   }
315   
316   if (!cluster) AliWarning(Form("cluster %d does not exist",clusterId));
317   return 0x0;
318 }
319
320 //___________________________________________________________________________
321 AliMUONVCluster* 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));
327   return cluster;
328 }
329
330 //___________________________________________________________________________
331 AliMUONVDigit* 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 //___________________________________________________________________________
340 AliMUONLocalTrigger* AliMUONESDInterface::FindLocalTrigger(Int_t boardNumber) const
341 {
342   /// return MUON local trigger "boardNumber"
343   return (fTriggers) ? fTriggers->FindLocal(boardNumber) : 0x0;
344 }
345
346 //___________________________________________________________________________
347 TIterator* AliMUONESDInterface::CreateTrackIterator() const
348 {
349   /// return iterator over all tracks
350   return fTracks ? fTracks->CreateIterator() : 0x0;
351 }
352
353 //___________________________________________________________________________
354 TIterator* AliMUONESDInterface::CreateClusterIterator() const
355 {
356   /// return iterator over all clusters
357   return fClusterMap ? new AliMUON2DMapIterator(*fClusterMap) : 0x0;
358 }
359
360 //___________________________________________________________________________
361 TIterator* AliMUONESDInterface::CreateClusterIterator(UInt_t trackId) const
362 {
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;
366 }
367
368 //___________________________________________________________________________
369 TIterator* AliMUONESDInterface::CreateDigitIterator() const
370 {
371   /// return iterator over all digits
372   return fDigits ? fDigits->CreateIterator() : 0x0;
373 }
374
375 //___________________________________________________________________________
376 TIterator* AliMUONESDInterface::CreateDigitIterator(UInt_t trackId) const
377 {
378   /// return iterator over all digits of track "trackId"
379   AliMpExMap* dMaps = fDigitMap ? static_cast<AliMpExMap*>(fDigitMap->GetValue(trackId)) : 0x0;
380   return dMaps ? new AliMUON2DMapIterator(*dMaps) : 0x0;
381 }
382
383 //___________________________________________________________________________
384 TIterator* AliMUONESDInterface::CreateDigitIterator(UInt_t trackId, UInt_t clusterId) const
385 {
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;
390 }
391
392 //___________________________________________________________________________
393 TIterator* AliMUONESDInterface::CreateDigitIteratorInCluster(UInt_t clusterId) const
394 {
395   /// return iterator over digits of the first cluster "clusterId" found by looping over all tracks
396   AliMpExMap *dMaps;
397   AliMpExMap* dMap = 0x0;
398   
399   if (fDigitMap) {
400     
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     }
408     
409   }
410   
411   return 0x0;
412 }
413
414 //___________________________________________________________________________
415 TIterator* AliMUONESDInterface::CreateLocalTriggerIterator() const
416 {
417   /// return iterator over all local trigger
418   return fTriggers ? fTriggers->CreateLocalIterator() : 0x0;
419 }
420
421 //___________________________________________________________________________
422 AliMUONVCluster* 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 //_____________________________________________________________________________
442 void AliMUONESDInterface::ResetTracker(const AliMUONRecoParam* recoParam, Bool_t info)
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     
454     if (info) cout<<"I-AliMUONESDInterface::ResetTracker: will refit tracks with provided RecoParam:"<<endl;
455     
456   } else {
457     
458     fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
459     
460     cout<<"W-AliMUONESDInterface::ResetTracker: RecoParam not provided. Will use default LowFlux parametrization:"<<endl;
461     
462   }
463   
464   // print useful parameters for refitting
465   if (info) {
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 = "
470     <<fgRecoParam->GetBendingVertexDispersion()<<" cm"<<endl;
471   }
472   
473   if (!TGeoGlobalMagField::Instance()->GetField())
474     cout<<"W-AliMUONESDInterface::ResetTracker: Magnetic field has not been set --> assume field is OFF"<<endl;
475   
476   fgTracker = AliMUONTracker::CreateTrackReconstructor(fgRecoParam,0x0);
477   
478 }
479
480 //_____________________________________________________________________________
481 AliMUONVTrackStore* 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 //_____________________________________________________________________________
493 AliMUONVClusterStore* 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 //_____________________________________________________________________________
505 AliMUONVDigitStore* 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
516 //_____________________________________________________________________________
517 AliMUONVTriggerStore* 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
528 //_____________________________________________________________________________
529 AliMUONVTriggerTrackStore* 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
540 //_________________________________________________________________________
541 void 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 //_________________________________________________________________________
553 void 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 //_________________________________________________________________________
565 void 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 //_________________________________________________________________________
577 void 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 //_________________________________________________________________________
604 void 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 //_________________________________________________________________________
616 void 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 //_________________________________________________________________________
627 void 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 //_________________________________________________________________________
639 void 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 //_____________________________________________________________________________
670 void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track, Bool_t refit)
671 {
672   /// Transfert data from ESDMuon track to MUON track.
673   /// If refit = kTRUE, the track parameters at each cluster are obtained by refitting the track
674   /// or by extrapolating the parameters at the first one if the refit failed.
675   /// If refit = kFALSE, only the track parameters at first cluster are valid.
676   /// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
677   ///       By default we use Kalman filter + Smoother
678   
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   
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());
696   track.SetChi2MatchTrigger(esdTrack.GetChi2MatchTrigger());
697   track.SetHitsPatternInTrigCh(esdTrack.GetHitsPatternInTrigCh());
698   track.SetLocalTrigger(esdTrack.LoCircuit(), esdTrack.LoStripX(), esdTrack.LoStripY(),
699                         esdTrack.LoDev(), esdTrack.LoLpt(), esdTrack.LoHpt(),
700                         esdTrack.GetTriggerWithoutChamber());
701   track.Connected(esdTrack.IsConnected());
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     
738     // refit the track to get better parameters and covariances at each cluster (temporary disable track improvement)
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     }
752     
753   } else {
754     
755     // get number of the first hit chamber according to the MUONClusterMap
756     Int_t firstCh = 0;
757     while (firstCh < 10 && !esdTrack.IsInMuonClusterMap(firstCh)) firstCh++;
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   
769   // set the MC label from ESD track
770   track.SetMCLabel(esdTrack.GetLabel());
771   
772   delete cluster;
773   delete cStore;
774   
775 }
776
777 //_____________________________________________________________________________
778 void 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   
789   locTrg.SetUniqueID(locTrg.GetUniqueID());
790   locTrg.SetLoCircuit(esdTrack.LoCircuit());
791   locTrg.SetLoStripX(esdTrack.LoStripX());
792   locTrg.SetLoStripY(esdTrack.LoStripY());
793   locTrg.SetDeviation(esdTrack.LoDev());
794   locTrg.SetLoLpt(esdTrack.LoLpt());
795   locTrg.SetLoHpt(esdTrack.LoHpt());
796   locTrg.SetTriggerWithoutChamber(esdTrack.GetTriggerWithoutChamber());
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 //_____________________________________________________________________________
810 void 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());
821   cluster.SetMCLabel(esdCluster.GetLabel());
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 //___________________________________________________________________________
832 void AliMUONESDInterface::ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit& digit)
833 {
834   /// Transfert data from ESDMuon pad to MUON digit
835   
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   
841   const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(esdPad.GetDetElemId(), esdPad.GetManuId());  
842   AliMpPad pad = seg->PadByLocation(esdPad.GetManuId(), esdPad.GetManuChannel(), kFALSE);
843   
844   digit.Saturated(esdPad.IsSaturated());
845   digit.Used(kFALSE);
846   digit.Calibrated(esdPad.IsCalibrated());
847   digit.SetUniqueID(esdPad.GetUniqueID());
848   digit.SetCharge(esdPad.GetCharge());
849   digit.SetADC(esdPad.GetADC());
850   digit.SetPadXY(pad.GetIx(), pad.GetIy());
851   
852 }
853
854 //_____________________________________________________________________________
855 void AliMUONESDInterface::MUONToESD(const AliMUONTrack& track, AliESDMuonTrack& esdTrack, const Double_t vertex[3],
856                                     const AliMUONVDigitStore* digits, const AliMUONLocalTrigger* locTrg)
857 {
858   /// Transfert data from MUON track to ESDMuon track
859   /// Incorporate the ESDPads if the digits are provided
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) {
864     if (locTrg) MUONToESD(*locTrg, esdTrack, track.GetUniqueID());
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   }
872   
873   esdTrack.Clear("C");
874   
875   // set global info
876   esdTrack.SetUniqueID(track.GetUniqueID());
877   esdTrack.SetChi2(track.GetGlobalChi2());
878   esdTrack.SetNHit(track.GetNClusters());
879   esdTrack.SetLabel(track.GetMCLabel());
880   
881   // set param at first cluster
882   AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track.GetTrackParamAtCluster())->First());
883   SetParamAtFirstCluster(*trackParam, esdTrack);
884   SetParamCov(*trackParam, esdTrack);
885   
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   
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   
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   
913   // set connected flag
914   esdTrack.Connected(track.IsConnected());
915   
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 //_____________________________________________________________________________
943 void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuonTrack& esdTrack,
944                                     UInt_t trackId, const AliMUONTriggerTrack* triggerTrack)
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(),
956                             locTrg.GetDeviation(),
957                             locTrg.LoLpt(),
958                             locTrg.LoHpt(),
959                             locTrg.GetTriggerWithoutChamber());
960   esdTrack.SetLocalTrigger(muonTrack.GetLocalTrigger());
961   esdTrack.SetChi2MatchTrigger(0.);
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());
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());
978     esdTrack.SetZUncorrected(triggerTrack->GetZ11());
979   }
980 }
981
982 //_____________________________________________________________________________
983 void 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());
993   esdCluster.SetCharge(cluster.GetCharge());
994   esdCluster.SetChi2(cluster.GetChi2());
995   esdCluster.SetLabel(cluster.GetMCLabel());
996   
997   if (digits) { // transfert all data if required
998     
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     
1010   }
1011   
1012 }
1013
1014 //_____________________________________________________________________________
1015 void 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());
1021   esdPad.SetCalibrated(digit.IsCalibrated());
1022   esdPad.SetSaturated(digit.IsSaturated());
1023 }
1024
1025 //___________________________________________________________________________
1026 AliMUONTrack* AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore, Bool_t refit)
1027 {
1028   /// Create MUON track from ESDMuon track and add it to the store
1029   /// Track parameters at each clusters are recomputed or not depending on the flag "refit"
1030   /// return a pointer to the track into the store (0x0 if the track already exist)
1031   if(trackStore.FindObject(esdTrack.GetUniqueID())) return 0x0;
1032   AliMUONTrack* track = trackStore.Add(AliMUONTrack());
1033   ESDToMUON(esdTrack, *track, refit);
1034   return track;
1035 }
1036
1037 //___________________________________________________________________________
1038 void 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
1041   if (!triggerStore.FindLocal(esdTrack.LoCircuit())->IsNull()) return;
1042   AliMUONLocalTrigger locTrg;
1043   ESDToMUON(esdTrack, locTrg);
1044   triggerStore.Add(locTrg);
1045 }
1046
1047 //___________________________________________________________________________
1048 AliMUONVCluster* 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 //___________________________________________________________________________
1058 AliMUONVDigit* 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