Rewritten using VStores, and now filling ESD, instead of AliMUONReconstruction (Laurent)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 17 Jun 2007 21:05:31 +0000 (21:05 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 17 Jun 2007 21:05:31 +0000 (21:05 +0000)
MUON/AliMUONTracker.cxx
MUON/AliMUONTracker.h

index 99eaf84..5a8d3cb 100644 (file)
  **************************************************************************/
 
 /// \class AliMUONTracker
-/// Interface class for use of global tracking framework;
+///
+/// Steering class for use in global tracking framework;
 /// reconstruct tracks from recpoints
 ///
-/// \author Christian Finck, SUBATECH Nantes
+/// Actual tracking is performed by some AliMUONVTrackReconstructor children
+///
+/// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
 
 #include "AliMUONTracker.h"
-#include "AliMUONTrackReconstructorK.h"
+
+#include "AliESD.h"
+#include "AliESDMuonTrack.h"
+#include "AliESDVertex.h"
+#include "AliLoader.h"
+#include "AliMUONTrack.h"
+#include "AliMUONTrackExtrap.h"
+#include "AliMUONTrackHitPattern.h"
+#include "AliMUONTrackParam.h"
 #include "AliMUONTrackReconstructor.h"
-#include "AliMUONRecData.h"
+#include "AliMUONTrackReconstructorK.h"
+#include "AliMUONTrackStoreV1.h"
+#include "AliMUONTriggerTrackStoreV1.h"
+#include "AliMUONVClusterStore.h"
+#include "AliMUONVTriggerStore.h"
+#include <Riostream.h>
+#include <TTree.h>
 #include "AliLog.h"
 
 //_____________________________________________________________________________
-AliMUONTracker::AliMUONTracker()
-  : AliTracker(),
-    fTriggerCircuit(0x0),
-    fMUONData(0x0),
-    fTrackReco(0x0)
+AliMUONTracker::AliMUONTracker(AliLoader* loader,
+                               const AliMUONDigitMaker* digitMaker,
+                               const AliMUONGeometryTransformer* transformer,
+                               const TClonesArray* triggerCircuit)
+: AliTracker(),
+  fLoader(loader),
+  fDigitMaker(digitMaker), // not owner
+  fTransformer(transformer), // not owner
+  fTriggerCircuit(triggerCircuit), // not owner
+  fTrackHitPatternMaker(0x0),
+  fTrackReco(0x0),
+  fClusterStore(0x0),
+  fTriggerStore(0x0)
 {
   /// constructor
-
+  if (fTransformer && fDigitMaker)
+  {
+    fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
+  }
 }
+
 //_____________________________________________________________________________
 AliMUONTracker::~AliMUONTracker()
 {
-  /// dtr
+  /// dtor
   delete fTrackReco;
+  delete fTrackHitPatternMaker;
+  delete fClusterStore;
+  delete fTriggerStore;
 }
 
 //_____________________________________________________________________________
-void AliMUONTracker::SetOption(Option_t* option)
+Int_t 
+AliMUONTracker::LoadClusters(TTree* clustersTree)
 {
-  /// set reconstructor class
+  /// Load clusterStore and triggerStore from clustersTree
+  delete fClusterStore;
+  delete fTriggerStore;
 
-  if (!fMUONData)
-    AliError("MUONData not defined");
+  fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
+  fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
+  
+  if (!fClusterStore)
+  {
+    AliError("Could not get clusterStore");
+    return 1;
+  }
+  if (!fTriggerStore)
+  {
+    AliError("Could not get triggerStore");
+    return 2;
+  }
+  
+  fClusterStore->Connect(*clustersTree,kFALSE);
+  fTriggerStore->Connect(*clustersTree,kFALSE);
+  
+  clustersTree->GetEvent(0);
 
-  if (!fTriggerCircuit)
-    AliError("TriggerCircuit not defined");
+  return 0;
+}
 
-  if (strstr(option,"Original")) 
-    fTrackReco = new AliMUONTrackReconstructor(fMUONData);
-  else if (strstr(option,"Combi")) 
-    fTrackReco = new AliMUONTrackReconstructorK(fMUONData,"Combi");
-  else 
-    fTrackReco = new AliMUONTrackReconstructorK(fMUONData,"Kalman");
+//_____________________________________________________________________________
+Int_t
+AliMUONTracker::Clusters2Tracks(AliESD* esd)
+{
+  /// Performs the tracking and store the resulting tracks in both
+  /// the TreeT and the ESD
+  
+  Int_t rv(0);
+  
+  TTree* tracksTree = fLoader->TreeT();
+  
+  if (!tracksTree)
+  {
+    AliError("Cannot get TreeT");
+    rv=1;
+  }
+  if (!fClusterStore)
+  {
+    AliError("ClusterStore is NULL");
+    rv=2;
+  }
+  if (!fTriggerStore)
+  {
+    AliError("TriggerStore is NULL");
+    rv=3;
+  }
+  if (!rv)
+  {
+    rv = Clusters2Tracks(*tracksTree,esd);
+  }
+  return rv;
+}
 
-  fTrackReco->SetTriggerCircuit(fTriggerCircuit);
+//_____________________________________________________________________________
+Int_t AliMUONTracker::Clusters2Tracks(TTree& tracksTree, AliESD* esd)
+{
+  /// Performs the tracking
+  
+  AliDebug(1,"");
+  
+  AliMUONVTrackStore* trackStore(0x0);
+  AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
+  
+  // Make tracker tracks
+  if ( fClusterStore ) 
+  {
+    trackStore = new AliMUONTrackStoreV1;
+    Bool_t alone = ( ( fTriggerStore && fTriggerCircuit ) ? kFALSE : kTRUE );
+    trackStore->Connect(tracksTree,alone);
+    fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
+  }
+  
+  if ( fTriggerStore && fTriggerCircuit )
+  {
+    // Make trigger tracks
+    triggerTrackStore = new AliMUONTriggerTrackStoreV1;
+    Bool_t alone = ( fClusterStore ? kFALSE : kTRUE );
+    triggerTrackStore->Connect(tracksTree,alone);
+    fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
+  }
+
+  if ( trackStore && triggerTrackStore && fTriggerStore && fTrackHitPatternMaker )
+  {
+    fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
+  }
+  
+  // Fills output TreeT 
+  tracksTree.Fill();
+
+  FillESD(*trackStore,esd);
+  
+  // cleanup
+  delete trackStore;
+  delete triggerTrackStore;
+  
+  return 0;
+}
 
+//_____________________________________________________________________________
+void 
+AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESD* esd) const
+{
+  /// Fill the ESD from the trackStore
+  
+  AliDebug(1,"");
+  
+  // Get vertex 
+  Double_t vertex[3] = {0};
+  const AliESDVertex* esdVert = esd->GetVertex(); 
+  if (esdVert->GetNContributors()) 
+  {
+    esdVert->GetXYZ(vertex);
+    AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
+  }
+  
+  // setting ESD MUON class
+  AliESDMuonTrack esdTrack;
+  
+  AliMUONTrack* track;
+  TIter next(trackStore.CreateIterator());
+  
+  while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
+  {
+    AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtHit())->First());
+    AliMUONTrackParam trackParamAtVtx(*trackParam);
+    
+    /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
+    AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0],vertex[1],vertex[2]);
+    
+    // setting data member of ESD MUON
+    
+    // at first station
+    esdTrack.SetInverseBendingMomentumUncorrected(trackParam->GetInverseBendingMomentum());
+    esdTrack.SetThetaXUncorrected(TMath::ATan(trackParam->GetNonBendingSlope()));
+    esdTrack.SetThetaYUncorrected(TMath::ATan(trackParam->GetBendingSlope()));
+    esdTrack.SetZUncorrected(trackParam->GetZ());
+    esdTrack.SetBendingCoorUncorrected(trackParam->GetBendingCoor());
+    esdTrack.SetNonBendingCoorUncorrected(trackParam->GetNonBendingCoor());
+    // at vertex
+    esdTrack.SetInverseBendingMomentum(trackParamAtVtx.GetInverseBendingMomentum());
+    esdTrack.SetThetaX(TMath::ATan(trackParamAtVtx.GetNonBendingSlope()));
+    esdTrack.SetThetaY(TMath::ATan(trackParamAtVtx.GetBendingSlope()));
+    esdTrack.SetZ(trackParamAtVtx.GetZ());
+    esdTrack.SetBendingCoor(trackParamAtVtx.GetBendingCoor());
+    esdTrack.SetNonBendingCoor(trackParamAtVtx.GetNonBendingCoor());
+    // global info
+    esdTrack.SetChi2(track->GetFitFMin());
+    esdTrack.SetNHit(track->GetNTrackHits());
+    esdTrack.SetLocalTrigger(track->GetLocalTrigger());
+    esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
+    esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
+    
+    // storing ESD MUON Track into ESD Event 
+    esd->AddMuonTrack(&esdTrack);
+  } // end of loop on tracks
 }
 
 //_____________________________________________________________________________
-Int_t AliMUONTracker::Clusters2Tracks(AliESD* /*esd*/)
+void AliMUONTracker::SetOption(Option_t* option)
 {
+  /// set reconstructor class
+  
+  if (strstr(option,"Original")) 
+  {
+    fTrackReco = new AliMUONTrackReconstructor;
+  }
+  else if (strstr(option,"Combi")) 
+  {
+    fTrackReco = new AliMUONTrackReconstructorK("Combi");
+  }
+  else 
+  {
+    fTrackReco = new AliMUONTrackReconstructorK("Kalman");
+  }
+}
 
-  /// clusters2Tracks method
-  /// in general tracking framework
-   
-  // open TClonesArray for reading
-  fMUONData->SetTreeAddress("TC,RC");
-
-  // open for writing
-  // trigger branch
-  fMUONData->MakeBranch("RL"); //trigger track
-  fMUONData->SetTreeAddress("RL");
-  fTrackReco->EventReconstructTrigger();
-  fMUONData->Fill("RL");
-
-  // tracking branch
-  fMUONData->MakeBranch("RT"); //track
-  fMUONData->SetTreeAddress("RT");
-  fTrackReco->EventReconstruct();
-  fMUONData->Fill("RT");
-
-  fMUONData->ResetRecTracks();
-  fMUONData->ResetRecTriggerTracks();
-
-  return kTRUE;
+//_____________________________________________________________________________
+void 
+AliMUONTracker::UnloadClusters()
+{
+  /// Delete internal clusterStore
+  delete fClusterStore;
+  fClusterStore = 0x0;
 }
+
index fd25db5..a2499ca 100644 (file)
 //  Author: Christian Finck, SUBATECH Nantes
 
 #include "AliTracker.h"
-class AliESD;
+
 class AliCluster;
-class AliMUONRecData;
-class TClonesArray;
+class AliESD;
+class AliLoader;
+class AliMUONDigitMaker;
+class AliMUONGeometryTransformer;
+class AliMUONTrackHitPattern;
+class AliMUONVClusterStore;
 class AliMUONVTrackReconstructor;
+class AliMUONVTrackStore;
+class AliMUONVTriggerStore;
+class TClonesArray;
 
 class AliMUONTracker : public AliTracker
 {
  public:
 
-  AliMUONTracker();
+  AliMUONTracker(AliLoader* loader,
+                 const AliMUONDigitMaker* digitMaker=0,
+                 const AliMUONGeometryTransformer* transformer=0,
+                 const TClonesArray* triggerCircuit=0);
   virtual ~AliMUONTracker();
-    
-  virtual Int_t Clusters2Tracks(AliESD* /*esd*/); 
   
+  /// Main entry point.
+  virtual Int_t Clusters2Tracks(AliESD* esd);
+
+  /// 
+  virtual Int_t LoadClusters(TTree* clustersTree);
+
+  ///
+  virtual void  UnloadClusters();
+
   /// Dummy implementation
   virtual Int_t PropagateBack(AliESD* /*event*/) {return 0;}
   /// Dummy implementation
   virtual Int_t RefitInward(AliESD* /*event*/) {return 0;}
   /// Dummy implementation
-  virtual Int_t LoadClusters(TTree* /*tree*/) {return 0;}
-  /// Dummy implementation
-  virtual void  UnloadClusters() {return;}
-  /// Dummy implementation
   virtual AliCluster *GetCluster(Int_t /*index*/) const {return 0;}
-
-  /// Set trigger circuit
-  void SetTriggerCircuit(TClonesArray* circuit) {fTriggerCircuit = circuit;}
-  /// Set pointer to data container
-  void SetMUONData(AliMUONRecData* data) {fMUONData = data;}
   /// Set option
   void SetOption(Option_t* opt);
 
@@ -50,10 +58,20 @@ private:
   /// Not implemented
   AliMUONTracker& operator=(const AliMUONTracker& rhs);
     
-  TClonesArray* fTriggerCircuit;                //!< trigger circuit
-  AliMUONRecData*  fMUONData;                   //!< pointer to container
-  AliMUONVTrackReconstructor* fTrackReco;       //!< track reconstructor
+  Int_t Clusters2Tracks(TTree& tracksTree, AliESD* esd);
 
+  void FillESD(AliMUONVTrackStore& trackStore, AliESD* esd) const;
+
+private:
+  AliLoader* fLoader; //!< loader to get access to trees
+  const AliMUONDigitMaker* fDigitMaker; //!< digit maker (not owner)
+  const AliMUONGeometryTransformer* fTransformer; //!< geometry transformer (not owner)
+  const TClonesArray* fTriggerCircuit;                //!< trigger circuit (not owner)
+  AliMUONTrackHitPattern* fTrackHitPatternMaker; //!< trigger hit pattern maker
+  AliMUONVTrackReconstructor* fTrackReco;       //!< track reconstructor
+  AliMUONVClusterStore* fClusterStore; //!< cluster container
+  AliMUONVTriggerStore* fTriggerStore; //!< trigger information
+  
   ClassDef(AliMUONTracker,0)  //tracker base class for MUON
 };
 #endif