]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONESDInterface.cxx
Access to the file analyzed available now in analysis classes through the reader...
[u/mrichter/AliRoot.git] / MUON / AliMUONESDInterface.cxx
index 3c1299552d5f699b48b9ef303e1e893615b7e90d..3a674b00380713e7fa11a44b3a43a8b259c77ff9 100644 (file)
@@ -23,6 +23,7 @@
 #include "AliMUONVDigit.h"
 #include "AliMUONVDigitStore.h"
 #include "AliMUONLocalTrigger.h"
+#include "AliMUONTriggerTrack.h"
 #include "AliMUONVTriggerStore.h"
 #include "AliMUON2DMapIterator.h"
 #include "AliMUONTrackParam.h"
@@ -35,7 +36,6 @@
 #include "AliMpExMapIterator.h"
 #include "AliMpVSegmentation.h"
 #include "AliMpSegmentation.h"
-#include "AliMpIntPair.h"
 #include "AliMpPad.h"
 
 #include "AliESDEvent.h"
@@ -61,6 +61,9 @@
 /// 2) loading a whole ESDEvent and using the finders and/or the iterators
 ///    to access the corresponding MUON objects
 ///
+/// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
+///       By default we use Kalman filter + Smoother
+///
 /// \author Philippe Pillot
 //-----------------------------------------------------------------------------
 
@@ -68,6 +71,7 @@
 ClassImp(AliMUONESDInterface)
 /// \endcond
 
+AliMUONRecoParam* AliMUONESDInterface::fgRecoParam = 0x0;
 AliMUONVTrackReconstructor* AliMUONESDInterface::fgTracker = 0x0;
 
 TString AliMUONESDInterface::fgTrackStoreName = "AliMUONTrackStoreV1";
@@ -76,9 +80,8 @@ TString AliMUONESDInterface::fgDigitStoreName = "AliMUONDigitStoreV2R";
 TString AliMUONESDInterface::fgTriggerStoreName = "AliMUONTriggerStoreV1";
 
 //_____________________________________________________________________________
-AliMUONESDInterface::AliMUONESDInterface(AliMUONRecoParam* recoParam)
+AliMUONESDInterface::AliMUONESDInterface()
 : TObject(),
-fRecoParam(recoParam),
 fTracks(0x0),
 fDigits(0x0),
 fTriggers(0x0),
@@ -159,7 +162,7 @@ void AliMUONESDInterface::LoadEvent(AliESDEvent& esdEvent)
     if (!esdTrack->ContainTrackerData()) continue;
     
     // add it to track store
-    AliMUONTrack* track = Add(GetRecoParam(),*esdTrack, *fTracks);
+    AliMUONTrack* track = Add(*esdTrack, *fTracks);
     
     // prepare cluster map
     AliMpExMap* cMap = new AliMpExMap;
@@ -431,6 +434,32 @@ AliMUONVCluster* AliMUONESDInterface::FindClusterInTrack(const AliMUONTrack& tra
 //                                static methods                               //
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
 
+//_____________________________________________________________________________
+void AliMUONESDInterface::ResetTracker(const AliMUONRecoParam* recoParam)
+{
+  /// Reset the MUON tracker using "recoParam" if provided.
+  /// If not provided, will use Kalman filter + Smoother
+  
+  delete fgTracker;
+  delete fgRecoParam;
+  
+  if (recoParam) {
+    
+    fgRecoParam = new AliMUONRecoParam(*recoParam);
+    
+  } else {
+    
+    fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
+    fgRecoParam->SetTrackingMode("KALMAN");
+    fgRecoParam->UseSmoother(kTRUE);
+    fgRecoParam->SetBendingVertexDispersion(10.);
+    
+  }
+  
+  fgTracker = AliMUONTracker::CreateTrackReconstructor(fgRecoParam,0x0);
+  
+}
+
 //_____________________________________________________________________________
 AliMUONVTrackStore* AliMUONESDInterface::NewTrackStore()
 {
@@ -609,9 +638,13 @@ void AliMUONESDInterface::SetParamCov(const AliMUONTrackParam& trackParam, AliES
 }
 
 //_____________________________________________________________________________
-void AliMUONESDInterface::ESDToMUON(const AliMUONRecoParam* recoParam, const AliESDMuonTrack& esdTrack, AliMUONTrack& track)
+void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track)
 {
-  /// Transfert data from ESDMuon track to MUON track
+  /// Transfert data from ESDMuon track to MUON track.
+  /// The track parameters at each cluster are obtained by refitting the track
+  /// or by extrapolating the parameters at the first one if the refit failed.
+  /// note: You can set the recoParam used to refit the MUON track with ResetTracker(...);
+  ///       By default we use Kalman filter + Smoother
   
   // if the ESDMuon track is a ghost then return an empty MUON track
   if (!esdTrack.ContainTrackerData()) {
@@ -632,7 +665,6 @@ void AliMUONESDInterface::ESDToMUON(const AliMUONRecoParam* recoParam, const Ali
   track.SetMatchTrigger(esdTrack.GetMatchTrigger());
   track.SetLoTrgNum(-1);
   track.SetChi2MatchTrigger(esdTrack.GetChi2MatchTrigger());
-  track.SetTrackID(0);
   track.SetHitsPatternInTrigCh(esdTrack.GetHitsPatternInTrigCh());
   track.SetLocalTrigger(esdTrack.LoCircuit(), esdTrack.LoStripX(), esdTrack.LoStripY(),
                        esdTrack.LoDev(), esdTrack.LoLpt(), esdTrack.LoHpt());
@@ -679,15 +711,14 @@ void AliMUONESDInterface::ESDToMUON(const AliMUONRecoParam* recoParam, const Ali
     AliMUONTrackExtrap::ExtrapToZCov(firstTrackParam,firstTrackParam->GetClusterPtr()->GetZ());
     
     // refit the track to get better parameters and covariances at each cluster (temporary disable track improvement)
-    if (!fgTracker) fgTracker = AliMUONTracker::CreateTrackReconstructor(recoParam,0x0);
+    if (!fgTracker) ResetTracker();
     if (!fgTracker->RefitTrack(track, kFALSE)) track.UpdateCovTrackParamAtCluster();
     
   } else {
     
-    // get number of the first hit chamber (according to the MUONClusterMap if not empty)
+    // get number of the first hit chamber according to the MUONClusterMap
     Int_t firstCh = 0;
-    if (esdTrack.GetMuonClusterMap() != 0) while (!esdTrack.IsInMuonClusterMap(firstCh)) firstCh++;
-    else firstCh = AliMUONConstants::ChamberNumber(param.GetZ());
+    while (firstCh < 10 && !esdTrack.IsInMuonClusterMap(firstCh)) firstCh++;
     
     // produce fake cluster at this chamber
     cluster->SetUniqueID(AliMUONVCluster::BuildUniqueID(firstCh, 0, 0));
@@ -699,6 +730,9 @@ void AliMUONESDInterface::ESDToMUON(const AliMUONRecoParam* recoParam, const Ali
     
   }
   
+  // set the MC label from ESD track
+  track.SetMCLabel(esdTrack.GetLabel());
+  
   delete cluster;
   delete cStore;
   
@@ -719,10 +753,9 @@ void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONLoca
   locTrg.SetLoCircuit(esdTrack.LoCircuit());
   locTrg.SetLoStripX(esdTrack.LoStripX());
   locTrg.SetLoStripY(esdTrack.LoStripY());
-  locTrg.SetLoDev(esdTrack.LoDev());
+  locTrg.SetDeviation(esdTrack.LoDev());
   locTrg.SetLoLpt(esdTrack.LoLpt());
   locTrg.SetLoHpt(esdTrack.LoHpt());
-  locTrg.SetLoSdev(1);
   locTrg.SetLoTrigY(1);
   locTrg.SetX1Pattern(esdTrack.GetTriggerX1Pattern());
   locTrg.SetX2Pattern(esdTrack.GetTriggerX2Pattern());
@@ -747,6 +780,7 @@ void AliMUONESDInterface::ESDToMUON(const AliESDMuonCluster& esdCluster, AliMUON
   cluster.SetErrXY(esdCluster.GetErrX(),esdCluster.GetErrY());
   cluster.SetCharge(esdCluster.GetCharge());
   cluster.SetChi2(esdCluster.GetChi2());
+  cluster.SetMCLabel(esdCluster.GetLabel());
   
   if (esdCluster.PadsStored()) {
     Int_t nPads = esdCluster.GetNPads();
@@ -762,7 +796,7 @@ void AliMUONESDInterface::ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit&
   /// Transfert data from ESDMuon pad to MUON digit
   
   const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(esdPad.GetDetElemId(), esdPad.GetManuId());  
-  AliMpPad pad = seg->PadByLocation(AliMpIntPair(esdPad.GetManuId(), esdPad.GetManuChannel()), kFALSE);
+  AliMpPad pad = seg->PadByLocation(esdPad.GetManuId(), esdPad.GetManuChannel(), kFALSE);
   
   digit.Saturated(esdPad.IsSaturated());
   digit.Used(kFALSE);
@@ -770,7 +804,7 @@ void AliMUONESDInterface::ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit&
   digit.SetUniqueID(esdPad.GetUniqueID());
   digit.SetCharge(esdPad.GetCharge());
   digit.SetADC(esdPad.GetADC());
-  digit.SetPadXY(pad.GetIndices().GetFirst(), pad.GetIndices().GetSecond());
+  digit.SetPadXY(pad.GetIx(), pad.GetIy());
   
 }
 
@@ -799,6 +833,7 @@ void AliMUONESDInterface::MUONToESD(const AliMUONTrack& track, AliESDMuonTrack&
   esdTrack.SetUniqueID(track.GetUniqueID());
   esdTrack.SetChi2(track.GetGlobalChi2());
   esdTrack.SetNHit(track.GetNClusters());
+  esdTrack.SetLabel(track.GetMCLabel());
   
   // set param at first cluster
   AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track.GetTrackParamAtCluster())->First());
@@ -852,7 +887,8 @@ void AliMUONESDInterface::MUONToESD(const AliMUONTrack& track, AliESDMuonTrack&
 }
 
 //_____________________________________________________________________________
-void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuonTrack& esdTrack, UInt_t trackId)
+void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuonTrack& esdTrack,
+                                   UInt_t trackId, const AliMUONTriggerTrack* triggerTrack)
 {
   /// Build ghost ESDMuon track containing only informations about trigger track
   
@@ -864,12 +900,11 @@ void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuo
   muonTrack.SetLocalTrigger(locTrg.LoCircuit(),
                            locTrg.LoStripX(),
                            locTrg.LoStripY(),
-                           locTrg.LoDev(),
+                           locTrg.GetDeviation(),
                            locTrg.LoLpt(),
                            locTrg.LoHpt());
   esdTrack.SetLocalTrigger(muonTrack.GetLocalTrigger());
   esdTrack.SetChi2MatchTrigger(0.);
-  esdTrack.SetHitsPatternInTrigCh(0);
   esdTrack.SetTriggerX1Pattern(locTrg.GetX1Pattern());
   esdTrack.SetTriggerY1Pattern(locTrg.GetY1Pattern());
   esdTrack.SetTriggerX2Pattern(locTrg.GetX2Pattern());
@@ -878,7 +913,15 @@ void AliMUONESDInterface::MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuo
   esdTrack.SetTriggerY3Pattern(locTrg.GetY3Pattern());
   esdTrack.SetTriggerX4Pattern(locTrg.GetX4Pattern());
   esdTrack.SetTriggerY4Pattern(locTrg.GetY4Pattern());
-  
+  UShort_t hitPattern = 0;
+  if(triggerTrack){
+    hitPattern = triggerTrack->GetHitsPatternInTrigCh();
+    esdTrack.SetHitsPatternInTrigCh(hitPattern);
+    esdTrack.SetThetaXUncorrected(triggerTrack->GetThetax());
+    esdTrack.SetThetaYUncorrected(triggerTrack->GetThetay());
+    esdTrack.SetNonBendingCoorUncorrected(triggerTrack->GetX11());
+    esdTrack.SetBendingCoorUncorrected(triggerTrack->GetY11());
+  }
 }
 
 //_____________________________________________________________________________
@@ -894,6 +937,7 @@ void AliMUONESDInterface::MUONToESD(const AliMUONVCluster& cluster, AliESDMuonCl
   esdCluster.SetErrXY(cluster.GetErrX(), cluster.GetErrY());
   esdCluster.SetCharge(cluster.GetCharge());
   esdCluster.SetChi2(cluster.GetChi2());
+  esdCluster.SetLabel(cluster.GetMCLabel());
   
   if (digits) { // transfert all data if required
     
@@ -924,14 +968,13 @@ void AliMUONESDInterface::MUONToESD(const AliMUONVDigit& digit, AliESDMuonPad& e
 }
 
 //___________________________________________________________________________
-AliMUONTrack* 
-AliMUONESDInterface::Add(const AliMUONRecoParam* recoParam, const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore)
+AliMUONTrack* AliMUONESDInterface::Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore)
 {
   /// Create MUON track from ESDMuon track and add it to the store
   /// return a pointer to the track into the store (0x0 if the track already exist)
   if(trackStore.FindObject(esdTrack.GetUniqueID())) return 0x0;
   AliMUONTrack* track = trackStore.Add(AliMUONTrack());
-  ESDToMUON(recoParam,esdTrack, *track);
+  ESDToMUON(esdTrack, *track);
   return track;
 }