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