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