Update AliMUONRecoCheck to find the corresponding trackRefs also for the trigger...
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 30 Mar 2010 16:07:50 +0000 (16:07 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 30 Mar 2010 16:07:50 +0000 (16:07 +0000)
(Diego)

MUON/AliMUONESDInterface.cxx
MUON/AliMUONESDInterface.h
MUON/AliMUONRecoCheck.cxx
MUON/AliMUONRecoCheck.h
MUON/AliMUONTriggerTrack.cxx
MUON/AliMUONTriggerTrack.h
MUON/AliMUONVTrackReconstructor.cxx
MUON/AliMUONVTrackReconstructor.h
MUON/MUONRecoCheck.C

index 0bc7bba..1c7b95e 100644 (file)
@@ -25,6 +25,7 @@
 #include "AliMUONLocalTrigger.h"
 #include "AliMUONTriggerTrack.h"
 #include "AliMUONVTriggerStore.h"
+#include "AliMUONVTriggerTrackStore.h"
 #include "AliMUON2DMapIterator.h"
 #include "AliMUONTrackParam.h"
 #include "AliMUONTrackExtrap.h"
@@ -80,6 +81,7 @@ TString AliMUONESDInterface::fgTrackStoreName = "AliMUONTrackStoreV1";
 TString AliMUONESDInterface::fgClusterStoreName = "AliMUONClusterStoreV2";
 TString AliMUONESDInterface::fgDigitStoreName = "AliMUONDigitStoreV2R";
 TString AliMUONESDInterface::fgTriggerStoreName = "AliMUONTriggerStoreV1";
+TString AliMUONESDInterface::fgTriggerTrackStoreName = "AliMUONTriggerTrackStoreV1";
 
 //_____________________________________________________________________________
 AliMUONESDInterface::AliMUONESDInterface()
@@ -523,6 +525,18 @@ AliMUONVTriggerStore* AliMUONESDInterface::NewTriggerStore()
   return reinterpret_cast<AliMUONVTriggerStore*>(classPtr->New());
 }
 
+//_____________________________________________________________________________
+AliMUONVTriggerTrackStore* AliMUONESDInterface::NewTriggerTrackStore()
+{
+  /// Create an empty trigger track store of type fgTriggerTrackStoreName
+  TClass* classPtr = TClass::GetClass(fgTriggerTrackStoreName);
+  if (!classPtr || !classPtr->InheritsFrom("AliMUONVTriggerTrackStore")) {
+    cout<<"E-AliMUONESDInterface::NewTriggerTrackStore: Unable to create store of type "<<fgTriggerTrackStoreName.Data()<<endl;
+    return 0x0;
+  }
+  return reinterpret_cast<AliMUONVTriggerTrackStore*>(classPtr->New());
+}
+
 //_________________________________________________________________________
 void AliMUONESDInterface::GetParamAtVertex(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam)
 {
@@ -772,6 +786,7 @@ void AliMUONESDInterface::ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONLoca
     return;
   }
   
+  locTrg.SetUniqueID(locTrg.GetUniqueID());
   locTrg.SetLoCircuit(esdTrack.LoCircuit());
   locTrg.SetLoStripX(esdTrack.LoStripX());
   locTrg.SetLoStripY(esdTrack.LoStripY());
index e9e9610..c848406 100644 (file)
@@ -25,6 +25,7 @@ class AliMUONVDigit;
 class AliMUONVDigitStore;
 class AliMUONLocalTrigger;
 class AliMUONTriggerTrack;
+class AliMUONVTriggerTrackStore;
 class AliMUONVTriggerStore;
 class AliMUONTrackParam;
 class AliMUONVTrackReconstructor;
@@ -102,6 +103,7 @@ public: // static methods
   static AliMUONVClusterStore* NewClusterStore();
   static AliMUONVDigitStore* NewDigitStore();
   static AliMUONVTriggerStore* NewTriggerStore();
+  static AliMUONVTriggerTrackStore* NewTriggerTrackStore();
   
   // ESD track parameters --> MUON track parameters
   static void GetParamAtVertex(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
@@ -158,6 +160,7 @@ private:
   static TString fgClusterStoreName; ///< class name of the cluster store to use
   static TString fgDigitStoreName;   ///< class name of the digit store to use
   static TString fgTriggerStoreName; ///< class name of the trigger store to use
+  static TString fgTriggerTrackStoreName; ///< class name of the trigger track store to use
   
   // data containers
   AliMUONVTrackStore*   fTracks;   ///< track container
index aaef0b0..de76f24 100644 (file)
@@ -41,6 +41,8 @@
 #include "AliMUONConstants.h"
 #include "AliMUONESDInterface.h"
 #include "AliMUONTrackParam.h"
+#include "AliMUONTriggerTrack.h"
+#include "AliMUONVTriggerTrackStore.h"
 #include "AliMCEventHandler.h"
 #include "AliMCEvent.h"
 #include "AliStack.h"
 #include "AliESDEvent.h"
 #include "AliESDMuonTrack.h"
 
+#include "AliGeomManager.h"
+#include "AliMpCDB.h"
+#include "AliMpDDLStore.h"
+#include "AliMUONCDB.h"
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONTriggerCircuit.h"
+#include "AliMUONVTrackReconstructor.h"
+#include "AliMUONVTriggerStore.h"
+
+#include "TGeoManager.h"
+
 #include <TFile.h>
 #include <TTree.h>
 #include <TParticle.h>
 #include <TParticlePDG.h>
 #include <Riostream.h>
 
+#include "AliMUONRecoCheck.h"
+
 /// \cond CLASSIMP
 ClassImp(AliMUONRecoCheck)
 /// \endcond
@@ -69,7 +84,11 @@ fESDFile (0x0),
 fCurrentEvent(0),
 fTrackRefStore(0x0),
 fRecoTrackRefStore(0x0),
+fRecoTriggerRefStore(0x0),
 fRecoTrackStore(0x0),
+fRecoTriggerTrackStore(0x0),
+fGeometryTransformer(0x0),
+fTriggerCircuit(0x0),
 fESDEventOwner(kTRUE)
 {
   /// Normal ctor
@@ -105,7 +124,11 @@ fESDFile (0x0),
 fCurrentEvent(0),
 fTrackRefStore(0x0),
 fRecoTrackRefStore(0x0),
+fRecoTriggerRefStore(0x0),
 fRecoTrackStore(0x0),
+fRecoTriggerTrackStore(0x0),
+fGeometryTransformer(0x0),
+fTriggerCircuit(0x0),
 fESDEventOwner(kFALSE)
 {
   /// Normal ctor
@@ -115,7 +138,6 @@ fESDEventOwner(kFALSE)
   
   // ESD MUON Tracks
   fESDEvent = esdEvent;
-  
 }
 
 //_____________________________________________________________________________
@@ -128,6 +150,8 @@ AliMUONRecoCheck::~AliMUONRecoCheck()
     if (fESDFile) fESDFile->Close();
   }
   ResetStores();
+  delete fGeometryTransformer;
+  delete fTriggerCircuit;
 }
 
 //_____________________________________________________________________________
@@ -136,15 +160,44 @@ void AliMUONRecoCheck::ResetStores()
   /// Deletes all the store objects that have been created and resets the pointers to 0x0
   delete fTrackRefStore;      fTrackRefStore = 0x0;
   delete fRecoTrackRefStore;  fRecoTrackRefStore = 0x0;
+  delete fRecoTriggerRefStore;  fRecoTriggerRefStore = 0x0;
   delete fRecoTrackStore;     fRecoTrackStore = 0x0;
+  delete fRecoTriggerTrackStore; fRecoTriggerTrackStore = 0x0;
 }
 
+//_____________________________________________________________________________
+Bool_t AliMUONRecoCheck::InitCircuit()
+{
+
+  if ( fTriggerCircuit ) return kTRUE;
+
+  if ( !AliMUONCDB::CheckOCDB() ) return kFALSE;
+
+  if ( !AliGeomManager::GetGeometry() )
+    AliGeomManager::LoadGeometry();
+
+  if ( !AliMpDDLStore::Instance(false) )
+    AliMpCDB::LoadDDLStore();
+       
+  fGeometryTransformer = new AliMUONGeometryTransformer();
+  fGeometryTransformer->LoadGeometryData();
+  
+  fTriggerCircuit = new AliMUONTriggerCircuit(fGeometryTransformer);
+
+  // reset tracker for local trigger to trigger track conversion
+  if ( ! AliMUONESDInterface::GetTracker() )
+    AliMUONESDInterface::ResetTracker();
+  
+  return kTRUE;
+}
+
+
 //_____________________________________________________________________________
 Int_t AliMUONRecoCheck::GetRunNumber()
 {
   /// Return the run number of the current ESD event
   
-  if (fESDEventOwner && fRecoTrackStore == 0x0) {
+  if (fESDEventOwner && fRecoTrackStore == 0x0 && fRecoTriggerTrackStore == 0x0) {
     if (!fESDTree || fESDTree->GetEvent(fCurrentEvent) <= 0) {
       AliError(Form("fails to read ESD object for event %d: cannot get the run number",fCurrentEvent));
       return -1;
@@ -192,6 +245,36 @@ AliMUONVTrackStore* AliMUONRecoCheck::ReconstructedTracks(Int_t event, Bool_t re
   }
 }
 
+
+//_____________________________________________________________________________
+AliMUONVTriggerTrackStore* AliMUONRecoCheck::TriggeredTracks(Int_t event)
+{
+  /// Return a track store containing the reconstructed trigger tracks (converted into 
+  /// MUONTriggerTrack objects) for a given event.
+       
+  if (!fESDEventOwner) {
+    if (fRecoTriggerTrackStore == 0x0) MakeTriggeredTracks();
+    return fRecoTriggerTrackStore;
+  }
+       
+  if (event != fCurrentEvent) {
+    ResetStores();
+    fCurrentEvent = event;
+  }
+       
+  if (fRecoTriggerTrackStore != 0x0) return fRecoTriggerTrackStore;
+  else {
+    if (!fESDTree) return 0x0;
+    if (fESDTree->GetEvent(event) <= 0) {
+      AliError(Form("fails to read ESD object for event %d", event));
+      return 0x0;
+    }
+    MakeTriggeredTracks();
+    return fRecoTriggerTrackStore;
+  }
+}
+
+
 //_____________________________________________________________________________
 AliMUONVTrackStore* AliMUONRecoCheck::TrackRefs(Int_t event)
 {
@@ -219,6 +302,34 @@ AliMUONVTrackStore* AliMUONRecoCheck::TrackRefs(Int_t event)
   }
 }
 
+//_____________________________________________________________________________
+AliMUONVTriggerTrackStore* AliMUONRecoCheck::TriggerableTracks(Int_t event)
+{
+  /// Return a trigger track store containing the triggerable track references (converted into 
+  /// AliMUONTriggerTrack objects) for a given event
+       
+  if (!fESDEventOwner) {
+    if (fRecoTriggerRefStore == 0x0) MakeTriggerableTracks();
+    return fRecoTriggerRefStore;
+  }
+       
+  if (event != fCurrentEvent) {
+    ResetStores();
+    fCurrentEvent = event;
+  }
+       
+  if (fRecoTriggerRefStore != 0x0) return fRecoTriggerRefStore;
+  else {
+    if (!fMCEventHandler->GetEvent(event)) {
+      AliError(Form("fails to read MC objects for event %d", event));
+      return 0x0;
+    }
+    MakeTriggerableTracks();
+    return fRecoTriggerRefStore;
+  }
+}
+
+
 //_____________________________________________________________________________
 AliMUONVTrackStore* AliMUONRecoCheck::ReconstructibleTracks(Int_t event, UInt_t requestedStationMask, Bool_t request2ChInSameSt45)
 {
@@ -246,6 +357,7 @@ AliMUONVTrackStore* AliMUONRecoCheck::ReconstructibleTracks(Int_t event, UInt_t
   }
 }
 
+
 //_____________________________________________________________________________
 void AliMUONRecoCheck::MakeReconstructedTracks(Bool_t refit)
 {
@@ -261,6 +373,41 @@ void AliMUONRecoCheck::MakeReconstructedTracks(Bool_t refit)
   
 }
 
+
+//_____________________________________________________________________________
+void AliMUONRecoCheck::MakeTriggeredTracks()
+{
+  /// Make reconstructed trigger tracks
+  if (!(fRecoTriggerTrackStore = AliMUONESDInterface::NewTriggerTrackStore())) return;
+       
+  AliMUONVTriggerStore* tmpTriggerStore = AliMUONESDInterface::NewTriggerStore();
+  if ( ! tmpTriggerStore ) return;
+  
+  // loop over all reconstructed tracks and add them to the store (include ghosts)
+  Int_t nTracks = (Int_t) fESDEvent->GetNumberOfMuonTracks();
+  for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
+    AliESDMuonTrack* esdTrack = fESDEvent->GetMuonTrack(iTrack);
+    if (esdTrack->ContainTriggerData()) AliMUONESDInterface::Add(*esdTrack, *tmpTriggerStore);
+  }
+       
+  if ( ! InitCircuit() ) return;
+  
+  AliMUONVTrackReconstructor* tracker = AliMUONESDInterface::GetTracker();
+  tracker->EventReconstructTrigger(*fTriggerCircuit, *tmpTriggerStore, *fRecoTriggerTrackStore);
+  
+  delete tmpTriggerStore;
+}
+
+//_____________________________________________________________________________
+void AliMUONRecoCheck::TriggerToTrack(const AliMUONLocalTrigger& locTrg, AliMUONTriggerTrack& triggerTrack)
+{
+  /// Make trigger track from local trigger info
+  if ( ! InitCircuit() ) return;
+  AliMUONVTrackReconstructor* tracker = AliMUONESDInterface::GetTracker();
+  tracker->TriggerToTrack(*fTriggerCircuit, locTrg, triggerTrack);
+}
+
+
 //_____________________________________________________________________________
 void AliMUONRecoCheck::MakeTrackRefs()
 {
@@ -386,6 +533,74 @@ void AliMUONRecoCheck::MakeTrackRefs()
   delete tmpTrackRefStore;
 }
 
+//_____________________________________________________________________________
+void AliMUONRecoCheck::MakeTriggerableTracks()
+{
+  /// Make triggerable tracks
+ if (!(fRecoTriggerRefStore = AliMUONESDInterface::NewTriggerTrackStore()))
+   return;
+
+  Double_t x, y, z, slopeX, slopeY, pZ;
+  TParticle* particle;
+  TClonesArray* trackRefs;
+  Int_t nTrackRef = fMCEventHandler->MCEvent()->GetNumberOfTracks();
+       
+  // loop over simulated tracks
+  for (Int_t iTrackRef  = 0; iTrackRef < nTrackRef; ++iTrackRef) {
+    Int_t nHits = fMCEventHandler->GetParticleAndTR(iTrackRef, particle, trackRefs);
+               
+    // skip empty trackRefs
+    if (nHits < 1) continue;
+                               
+    AliMUONTriggerTrack track;
+    Int_t hitsOnTrigger = 0;
+    Int_t currCh = -1;
+               
+    // loop over simulated track hits
+    for (Int_t iHit = 0; iHit < nHits; ++iHit) {        
+      AliTrackReference* trackReference = static_cast<AliTrackReference*>(trackRefs->UncheckedAt(iHit));
+                       
+      // skip trackRefs not in MUON
+      if (trackReference->DetectorId() != AliTrackReference::kMUON) continue;
+
+      // check chamberId of current trackReference
+      Int_t detElemId = trackReference->UserId();
+      Int_t chamberId = detElemId / 100 - 1;
+      if (chamberId < AliMUONConstants::NTrackingCh() || chamberId >= AliMUONConstants::NCh() ) continue;
+                       
+                       
+      if ( hitsOnTrigger == 0 ) {
+        // Get track parameters of current hit
+        x = trackReference->X();
+        y = trackReference->Y();
+        z = trackReference->Z();
+        pZ = trackReference->Pz();
+        slopeX = ( pZ == 0. ) ? 99999. : trackReference->Px() / pZ;
+        slopeY = ( pZ == 0. ) ? 99999. : trackReference->Py() / pZ;
+
+        track.SetX11(x);
+        track.SetY11(y);
+        track.SetZ11(z);
+        track.SetSlopeX(slopeX);
+        track.SetSlopeY(slopeY);
+      }
+
+      if ( currCh != chamberId ) {
+        hitsOnTrigger++;
+        currCh = chamberId;
+      }
+
+    } // loop on hits
+               
+    if ( hitsOnTrigger >= 3 ){
+      // store the track
+      track.SetUniqueID(iTrackRef);
+      fRecoTriggerRefStore->Add(track);
+    }
+  }
+}
+
+
 //_____________________________________________________________________________
 void AliMUONRecoCheck::CleanMuonTrackRef(const AliMUONVTrackStore *tmpTrackRefStore)
 {
@@ -567,3 +782,29 @@ AliMUONTrack* AliMUONRecoCheck::FindCompatibleTrack(AliMUONTrack &track, AliMUON
   
 }
 
+
+//_____________________________________________________________________________
+AliMUONTriggerTrack* AliMUONRecoCheck::FindCompatibleTrack(AliMUONTriggerTrack &track, AliMUONVTriggerTrackStore &triggerTrackStore,
+                                                           Double_t sigmaCut)
+{
+  /// Return the trigger track from the store matched with the given track (or 0x0).
+  /// Matching is done by comparing cluster/TrackRef positions.
+  
+  AliMUONTriggerTrack *matchedTrack = 0x0;
+  
+  // look for the corresponding simulated track if any
+  TIter next(triggerTrackStore.CreateIterator());
+  AliMUONTriggerTrack* track2;
+  while ( ( track2 = static_cast<AliMUONTriggerTrack*>(next()) ) ) {
+      
+    // check compatibility
+    if (track.Match(*track2, sigmaCut)) {
+      matchedTrack = track2;
+      break;
+    }
+  }
+  
+  return matchedTrack;
+  
+}
+
index 1d0aa41..5e463cb 100644 (file)
@@ -18,7 +18,12 @@ class TTree;
 class AliESDEvent;
 class AliMCEventHandler;
 class AliMUONVTrackStore;
+class AliMUONVTriggerTrackStore;
 class AliMUONTrack;
+class AliMUONTriggerTrack;
+class AliMUONGeometryTransformer;
+class AliMUONTriggerCircuit;
+class AliMUONLocalTrigger;
 
 class AliMUONRecoCheck : public TObject 
 {
@@ -29,13 +34,22 @@ public:
 
   /// Return the list of reconstructed tracks
   AliMUONVTrackStore* ReconstructedTracks(Int_t event, Bool_t refit = kTRUE);
-  
+
+  /// Return the list of reconstructed trigger tracks
+  AliMUONVTriggerTrackStore* TriggeredTracks(Int_t event);
+
+  void TriggerToTrack(const AliMUONLocalTrigger& locTrg, AliMUONTriggerTrack& triggerTrack);
+       
   /// Return reference muon tracks
   AliMUONVTrackStore* TrackRefs(Int_t event);
 
+  /// Return triggerable reference tracks
+  AliMUONVTriggerTrackStore* TriggerableTracks(Int_t event);
+       
   /// Return reconstructible reference tracks
   AliMUONVTrackStore* ReconstructibleTracks(Int_t event, UInt_t requestedStationMask = 0x1F, Bool_t request2ChInSameSt45 = kTRUE);
-  
+
+       
   /// Return the run number of the current ESD event
   Int_t GetRunNumber();
   
@@ -52,6 +66,11 @@ public:
   static AliMUONTrack* FindCompatibleTrack(AliMUONTrack &track, AliMUONVTrackStore &trackStore,
                                           Int_t &nMatchClusters, Bool_t useLabel = kFALSE, Double_t sigmaCut = 10.);
   
+  /// Return the trigger track from the store matched with the given track (or 0x0)
+  static AliMUONTriggerTrack* FindCompatibleTrack(AliMUONTriggerTrack &track,
+                                                  AliMUONVTriggerTrackStore &triggerTrackStore,
+                                                  Double_t sigmaCut = 10.);
+  
 private:
   /// Not implemented
   AliMUONRecoCheck(const AliMUONRecoCheck& rhs);
@@ -61,12 +80,18 @@ private:
   void ResetStores();
   
   void MakeReconstructedTracks(Bool_t refit);
+       
+  void MakeTriggeredTracks();
   
   void MakeTrackRefs();
   
   void CleanMuonTrackRef(const AliMUONVTrackStore *tmpTrackRefStore);
   
   void MakeReconstructibleTracks(UInt_t requestedStationMask, Bool_t request2ChInSameSt45 = kTRUE);
+       
+  void MakeTriggerableTracks();
+       
+  Bool_t InitCircuit();
 
 private:
   AliMCEventHandler* fMCEventHandler; ///< to access MC truth information
@@ -78,7 +103,12 @@ private:
   
   AliMUONVTrackStore* fTrackRefStore;     ///< current simulated tracks (owner)
   AliMUONVTrackStore* fRecoTrackRefStore; ///< current reconstructible tracks (owner)
+  AliMUONVTriggerTrackStore* fRecoTriggerRefStore; ///< current triggerable tracks (owner)
   AliMUONVTrackStore* fRecoTrackStore;    ///< current reconstructed tracks (owner)
+  AliMUONVTriggerTrackStore* fRecoTriggerTrackStore;    ///< current reconstructed trigger tracks (owner)
+       
+  AliMUONGeometryTransformer* fGeometryTransformer; ///< geometry transformer
+  AliMUONTriggerCircuit* fTriggerCircuit; ///< trigger circuit
   
   Bool_t fESDEventOwner;         ///< using constructor from the analysis task
 
index 5a65466..aed040f 100644 (file)
@@ -49,7 +49,7 @@ AliMUONTriggerTrack::AliMUONTriggerTrack()
     fCovariances(0x0)
 {
   /// default ctr
-      AliDebug(1,Form("this=%p",this));
+      AliDebug(5,Form("this=%p",this));
 }
 //__________________________________________________________________________
 AliMUONTriggerTrack::AliMUONTriggerTrack(Float_t x11, Float_t y11, Float_t z11, Float_t z21, Float_t slopeX, Float_t slopeY, Int_t loTrgNum, Long_t theGTPattern, UShort_t hitsPatternInTrigCh)
@@ -66,7 +66,7 @@ AliMUONTriggerTrack::AliMUONTriggerTrack(Float_t x11, Float_t y11, Float_t z11,
       fCovariances(0x0)
 {
 /// ctor from local trigger output
-        AliDebug(1,Form("this=%p x11=%f y11=%f z11=%f z21=%f slopeX=%f slopeY=%f loTrgNum=%d GTPattern=%ld HitsPatternInTrigCh %i",
+        AliDebug(5,Form("this=%p x11=%f y11=%f z11=%f z21=%f slopeX=%f slopeY=%f loTrgNum=%d GTPattern=%ld HitsPatternInTrigCh %i",
                         this,x11,y11,z11,z21,slopeX,slopeY,loTrgNum,theGTPattern,fHitsPatternInTrigCh));
 
 }
@@ -75,7 +75,7 @@ AliMUONTriggerTrack::AliMUONTriggerTrack(Float_t x11, Float_t y11, Float_t z11,
 AliMUONTriggerTrack::~AliMUONTriggerTrack()
 {
   /// Destructor
-  AliDebug(1,Form("this=%p",this));
+  AliDebug(5,Form("this=%p",this));
   if (fCovariances) {
     delete fCovariances;
     fCovariances = 0x0;
@@ -100,7 +100,7 @@ AliMUONTriggerTrack::AliMUONTriggerTrack (const AliMUONTriggerTrack& theMUONTrig
 /// copy ctor
 ///
   if (theMUONTriggerTrack.fCovariances) fCovariances = new TMatrixD(*(theMUONTriggerTrack.fCovariances));
-  AliDebug(1,Form("this=%p copy ctor",this));
+  AliDebug(5,Form("this=%p copy ctor",this));
 
 }
       
@@ -183,3 +183,41 @@ const TMatrixD& AliMUONTriggerTrack::GetCovariances() const
   }
   return *fCovariances;
 }
+
+//__________________________________________________________________________
+Bool_t AliMUONTriggerTrack::Match(AliMUONTriggerTrack &track, Double_t sigmaCut) const
+{
+  /// Try to match this track with the given track. Matching conditions:
+  /// - x, y position and y slope within sigmaCut
+  
+  TMatrixD paramDiff(3,1);
+  Double_t deltaZ = GetZ11() - track.GetZ11();
+  paramDiff(0,0) = GetX11() - track.GetX11();
+  paramDiff(1,0) = GetY11() - ( track.GetY11() + track.GetSlopeY() * deltaZ );
+  paramDiff(2,0) = GetSlopeY() - track.GetSlopeY();
+  Double_t chi2 = 0.;
+  TMatrixD cov1(GetCovariances());
+  TMatrixD cov2(track.GetCovariances());
+
+  AliDebug(3, Form("this Y11 %f  track Y11: %f (Z11 %f)  -> %f (Z11 %f)", GetY11(), track.GetY11(), track.GetZ11(), track.GetY11() + track.GetSlopeY() * deltaZ, GetZ11()));
+
+  TMatrixD sumCov(cov1,TMatrixD::kPlus,cov2);
+  if (sumCov.Determinant() != 0) {
+    sumCov.Invert();      
+    TMatrixD tmp(sumCov,TMatrixD::kMult,paramDiff);
+    TMatrixD chi2M(paramDiff,TMatrixD::kTransposeMult,tmp);
+    chi2 = chi2M(0,0);
+  } else {
+    AliWarning(" Determinant = 0");
+    Double_t sigma2 = 0.;
+    for (Int_t iVar = 0; iVar < 3; iVar++) {
+      sigma2 = cov1(iVar,iVar) + cov2(iVar,iVar);
+      chi2 += paramDiff(iVar,0) * paramDiff(iVar,0) / sigma2;
+    }
+  }
+
+  if ( chi2/3 > sigmaCut * sigmaCut )
+    return kFALSE;
+  
+  return kTRUE;
+}
index 541e381..fbd6de5 100644 (file)
@@ -81,6 +81,8 @@ class AliMUONTriggerTrack : public TObject
     const TMatrixD& GetCovariances() const;
     void  SetCovariances(const TMatrixD& covariances);
     void  SetCovariances(const Double_t matrix[3][3]);
+  
+    Bool_t Match(AliMUONTriggerTrack &track, Double_t sigmaCut) const;
     
 protected:
   private:
index fac2dea..80a23b9 100644 (file)
@@ -1266,12 +1266,13 @@ void AliMUONVTrackReconstructor::ValidateTracksWithTrigger(AliMUONVTrackStore& t
   trackHitPattern.ExecuteValidation(trackStore, triggerTrackStore, triggerStore);
 }
 
-  //__________________________________________________________________________
+
+//__________________________________________________________________________
 void AliMUONVTrackReconstructor::EventReconstructTrigger(const AliMUONTriggerCircuit& circuit,
                                                          const AliMUONVTriggerStore& triggerStore,
                                                          AliMUONVTriggerTrackStore& triggerTrackStore)
 {
-  /// To make the trigger tracks from Local Trigger
+  /// Fill trigger track store from local trigger
   AliDebug(1, "");
   AliCodeTimerAuto("",0);
 
@@ -1284,64 +1285,75 @@ void AliMUONVTrackReconstructor::EventReconstructTrigger(const AliMUONTriggerCir
     gloTrigPat = globalTrigger->GetGlobalResponse();
   }
   
+  AliMUONTriggerTrack triggerTrack;
+  
   TIter next(triggerStore.CreateIterator());
   AliMUONLocalTrigger* locTrg(0x0);
-
-  const Double_t kTrigNonBendReso = AliMUONConstants::TriggerNonBendingReso();
-  const Double_t kTrigBendReso = AliMUONConstants::TriggerBendingReso();
-  const Double_t kSqrt12 = TMath::Sqrt(12.);
-      
-  AliMUONTriggerTrack triggerTrack;
-  TMatrixD trigCov(3,3);
   
   while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
   {
     if ( locTrg->IsTrigX() && locTrg->IsTrigY() ) 
     { // make Trigger Track if trigger in X and Y
-
-      Int_t localBoardId = locTrg->LoCircuit();
-
-      Float_t y11 = circuit.GetY11Pos(localBoardId, locTrg->LoStripX()); 
-      Float_t z11 = circuit.GetZ11Pos(localBoardId, locTrg->LoStripX());
-      // need first to convert deviation to [0-30] 
-      // (see AliMUONLocalTriggerBoard::LocalTrigger)
-      Int_t deviation = locTrg->GetDeviation(); 
-      Int_t stripX21 = locTrg->LoStripX()+deviation+1;
-      Float_t y21 = circuit.GetY21Pos(localBoardId, stripX21);       
-      Float_t z21 = circuit.GetZ21Pos(localBoardId, stripX21);
-      Float_t x11 = circuit.GetX11Pos(localBoardId, locTrg->LoStripY());
       
-      AliDebug(1, Form(" MakeTriggerTrack %3d %2d %2d %2d (%f %f %f) (%f %f)\n",locTrg->LoCircuit(),
-                       locTrg->LoStripX(),locTrg->LoStripX()+deviation+1,locTrg->LoStripY(),x11, y11, z11, y21, z21));
-
-      Double_t deltaZ = z11 - z21;
-      
-      Float_t slopeX = x11/z11;
-      Float_t slopeY = (y11-y21) / deltaZ;
-
-      Float_t sigmaX = circuit.GetX11Width(localBoardId, locTrg->LoStripY()) / kSqrt12;
-      Float_t sigmaY = circuit.GetY11Width(localBoardId, locTrg->LoStripX()) / kSqrt12;
-      Float_t sigmaY21 = circuit.GetY21Width(localBoardId, locTrg->LoStripX()) / kSqrt12;
-
-      trigCov.Zero();
-      trigCov(0,0) = kTrigNonBendReso * kTrigNonBendReso + sigmaX * sigmaX;
-      trigCov(1,1) = kTrigBendReso * kTrigBendReso + sigmaY * sigmaY;
-      trigCov(2,2) = 
-       (2. * kTrigBendReso * kTrigBendReso + sigmaY * sigmaY + sigmaY21 * sigmaY21 ) / deltaZ / deltaZ;
-      trigCov(1,2) = trigCov(2,1) = trigCov(1,1) / deltaZ;
-
-      triggerTrack.SetX11(x11);
-      triggerTrack.SetY11(y11);
-      triggerTrack.SetZ11(z11);
-      triggerTrack.SetZ21(z21);
-      triggerTrack.SetSlopeX(slopeX);
-      triggerTrack.SetSlopeY(slopeY);
-      triggerTrack.SetGTPattern(gloTrigPat);
-      triggerTrack.SetLoTrgNum(localBoardId);
-      triggerTrack.SetCovariances(trigCov);
+      TriggerToTrack(circuit, *locTrg, triggerTrack, gloTrigPat);
 
       triggerTrackStore.Add(triggerTrack);
     } // board is fired 
   } // end of loop on Local Trigger
 }
+
+//__________________________________________________________________________
+void AliMUONVTrackReconstructor::TriggerToTrack(const AliMUONTriggerCircuit& circuit,
+                                                const AliMUONLocalTrigger& locTrg,
+                                                AliMUONTriggerTrack& triggerTrack,
+                                                UChar_t globalTriggerPattern)
+{
+  /// To make the trigger tracks from Local Trigger
+  const Double_t kTrigNonBendReso = AliMUONConstants::TriggerNonBendingReso();
+  const Double_t kTrigBendReso = AliMUONConstants::TriggerBendingReso();
+  const Double_t kSqrt12 = TMath::Sqrt(12.);
+  
+  TMatrixD trigCov(3,3);
+
+  Int_t localBoardId = locTrg.LoCircuit();
+      
+  Float_t y11 = circuit.GetY11Pos(localBoardId, locTrg.LoStripX()); 
+  Float_t z11 = circuit.GetZ11Pos(localBoardId, locTrg.LoStripX());
+  // need first to convert deviation to [0-30] 
+  // (see AliMUONLocalTriggerBoard::LocalTrigger)
+  Int_t deviation = locTrg.GetDeviation(); 
+  Int_t stripX21 = locTrg.LoStripX()+deviation+1;
+  Float_t y21 = circuit.GetY21Pos(localBoardId, stripX21);       
+  Float_t z21 = circuit.GetZ21Pos(localBoardId, stripX21);
+  Float_t x11 = circuit.GetX11Pos(localBoardId, locTrg.LoStripY());
+      
+  AliDebug(1, Form(" MakeTriggerTrack %3d %2d %2d %2d (%f %f %f) (%f %f)\n",locTrg.LoCircuit(),
+                   locTrg.LoStripX(),locTrg.LoStripX()+deviation+1,locTrg.LoStripY(),x11, y11, z11, y21, z21));
+      
+  Double_t deltaZ = z11 - z21;
+      
+  Float_t slopeX = x11/z11;
+  Float_t slopeY = (y11-y21) / deltaZ;
+      
+  Float_t sigmaX = circuit.GetX11Width(localBoardId, locTrg.LoStripY()) / kSqrt12;
+  Float_t sigmaY = circuit.GetY11Width(localBoardId, locTrg.LoStripX()) / kSqrt12;
+  Float_t sigmaY21 = circuit.GetY21Width(localBoardId, locTrg.LoStripX()) / kSqrt12;
+      
+  trigCov.Zero();
+  trigCov(0,0) = kTrigNonBendReso * kTrigNonBendReso + sigmaX * sigmaX;
+  trigCov(1,1) = kTrigBendReso * kTrigBendReso + sigmaY * sigmaY;
+  trigCov(2,2) = 
+    (2. * kTrigBendReso * kTrigBendReso + sigmaY * sigmaY + sigmaY21 * sigmaY21 ) / deltaZ / deltaZ;
+    trigCov(1,2) = trigCov(2,1) = trigCov(1,1) / deltaZ;
+      
+  triggerTrack.SetX11(x11);
+  triggerTrack.SetY11(y11);
+  triggerTrack.SetZ11(z11);
+  triggerTrack.SetZ21(z21);
+  triggerTrack.SetSlopeX(slopeX);
+  triggerTrack.SetSlopeY(slopeY);
+  triggerTrack.SetGTPattern(globalTriggerPattern);
+  triggerTrack.SetLoTrgNum(localBoardId);
+  triggerTrack.SetCovariances(trigCov);
+  triggerTrack.SetUniqueID(locTrg.GetUniqueID());
+}
index 2a1da70..be29209 100644 (file)
@@ -28,6 +28,7 @@ class AliMUONDigitMaker;
 class AliMUONTriggerCircuit;
 class TClonesArray;
 class AliMUONRecoParam;
+class AliMUONLocalTrigger;
 
 class AliMUONVTrackReconstructor : public TObject {
 
@@ -54,6 +55,12 @@ class AliMUONVTrackReconstructor : public TObject {
   /// Re-fit the given track
   virtual Bool_t RefitTrack(AliMUONTrack &track, Bool_t enableImprovement = kTRUE) = 0;
   
+  void TriggerToTrack(const AliMUONTriggerCircuit& circuit,
+                      const AliMUONLocalTrigger& locTrg,
+                      AliMUONTriggerTrack& triggerTrack,
+                      UChar_t globalTriggerPattern = 0);
+  
+  
   
  protected:
 
index 288211b..c7be352 100644 (file)
@@ -51,6 +51,8 @@
 #include "AliMUONVTrackStore.h"
 #include "AliMUONVCluster.h"
 #include "AliMUONTrackExtrap.h"
+#include "AliMUONVTriggerTrackStore.h"
+#include "AliMUONTriggerTrack.h"
 
 Double_t langaufun(Double_t *x, Double_t *par);
 
@@ -65,10 +67,12 @@ void MUONRecoCheck (Int_t nEvent = -1, const char* pathSim="./generated/", const
   // File for histograms and histogram booking
   TFile *histoFile = new TFile("MUONRecoCheck.root", "RECREATE");
   
-  TH1F *hReconstructible = new TH1F("hReconstructible"," Nb of reconstructible tracks ",15,-0.5,14.5);
+  TH1F *hReconstructible = new TH1F("hReconstructible"," Nb of reconstructible tracks / evt",15,-0.5,14.5);
   TH1F *hReco = new TH1F("hReco"," Nb of reconstructed tracks / evt",15,-0.5,14.5);
   TH1F *hNClusterComp = new TH1F("hNClusterComp"," Nb of compatible clusters / track ",15,-0.5,14.5);
   TH1F *hTrackRefID = new TH1F("hTrackRefID"," track reference ID ",100,-0.5,99.5);
+  TH1F *hTriggerable = new TH1F("hTriggerable"," Nb of triggerable tracks / evt",15,-0.5,14.5);
+  TH1F *hTriggered = new TH1F("hTriggered"," Nb of triggered tracks / evt",15,-0.5,14.5);
   
   // momentum resolution at vertex
   histoFile->mkdir("momentumAtVertex","momentumAtVertex");
@@ -150,6 +154,14 @@ void MUONRecoCheck (Int_t nEvent = -1, const char* pathSim="./generated/", const
   gResidualYPerChSigma->SetName("gResidualYPerChSigma");
   gResidualYPerChSigma->SetTitle("cluster-track residual-Y per Ch: sigma;chamber ID;#sigma_{Y} (cm)");
   gResidualYPerChSigma->SetMarkerStyle(kFullDotLarge);
+
+  histoFile->mkdir("trigger");
+  histoFile->cd("trigger");
+  TH1F* hResidualTrigX11 = new TH1F("hResiudalTrigX11", "Residual X11", 100, -10., 10.);
+  TH1F* hResidualTrigY11 = new TH1F("hResiudalTrigY11", "Residual Y11", 100, -10., 10.);
+  TH1F* hResidualTrigSlopeY = new TH1F("hResiudalTrigSlopeY", "Residual Y slope", 100, -0.1, 0.1);
+  TH1F* hTriggerableMatchFailed = new TH1F("hTriggerableMatchFailed", "Triggerable multiplicity for events with no match", 15, -0.5, 14.5);
+  
   
   // ###################################### initialize ###################################### //
   AliMUONRecoCheck rc(esdFileName, pathSim);
@@ -196,6 +208,45 @@ void MUONRecoCheck (Int_t nEvent = -1, const char* pathSim="./generated/", const
     
     nReconstructibleTracks += trackRefStore->GetSize();
     nReconstructedTracks += trackStore->GetSize();
+
+    AliMUONVTriggerTrackStore* triggerTrackRefStore = rc.TriggerableTracks(ievent);
+    AliMUONVTriggerTrackStore* triggerTrackStore = rc.TriggeredTracks(ievent);
+
+    hTriggerable->Fill(triggerTrackRefStore->GetSize());
+    hTriggered->Fill(triggerTrackStore->GetSize());
+
+    // loop over trigger trackRef
+    TIter nextTrig(triggerTrackRefStore->CreateIterator());
+    AliMUONTriggerTrack* triggerTrackRef;
+    Int_t nTriggerMatches = 0;
+    while ( ( triggerTrackRef = static_cast<AliMUONTriggerTrack*>(nextTrig()) ) )
+    {
+      
+      AliMUONTriggerTrack* triggerTrackMatched = 0x0;
+      
+      // loop over trackReco and look for compatible track
+      TIter nextTrig2(triggerTrackStore->CreateIterator());
+      AliMUONTriggerTrack* triggerTrackReco;
+      while ( ( triggerTrackReco = static_cast<AliMUONTriggerTrack*>(nextTrig2()) ) )
+      {
+       
+        // check if trackReco is compatible with trackRef
+        if (triggerTrackReco->Match(*triggerTrackRef, sigmaCut)) {
+          triggerTrackMatched = triggerTrackReco;
+          nTriggerMatches++;
+          break;
+        }
+      }
+      
+      if (triggerTrackMatched) { // tracking requirements verified, track is found
+        hResidualTrigX11->Fill( triggerTrackMatched->GetX11() - triggerTrackRef->GetX11() );
+        hResidualTrigY11->Fill( triggerTrackMatched->GetY11() - triggerTrackRef->GetY11() );
+        hResidualTrigSlopeY->Fill( triggerTrackMatched->GetSlopeY() - triggerTrackRef->GetSlopeY() );
+      }
+    } // loop on trigger track ref
+    
+    if ( nTriggerMatches != triggerTrackStore->GetSize() )
+      hTriggerableMatchFailed->Fill(triggerTrackRefStore->GetSize());
     
     // loop over trackRef
     TIter next(trackRefStore->CreateIterator());
@@ -203,7 +254,7 @@ void MUONRecoCheck (Int_t nEvent = -1, const char* pathSim="./generated/", const
     while ( ( trackRef = static_cast<AliMUONTrack*>(next()) ) )
     {
       
-      hTrackRefID->Fill(trackRef->GetMCLabel());
+      hTrackRefID->Fill(trackRef->GetUniqueID());
       
       AliMUONTrack* trackMatched = 0x0;
       Int_t nMatchClusters = 0;
@@ -215,10 +266,8 @@ void MUONRecoCheck (Int_t nEvent = -1, const char* pathSim="./generated/", const
       {
        
        // check if trackReco is compatible with trackRef
-       Int_t n = 0;
        if (trackReco->Match(*trackRef, sigmaCut, nMatchClusters)) {
          trackMatched = trackReco;
-         nMatchClusters = n;
          break;
        }