]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrack.cxx
ReadRaw(): TGraphs are created once per event (B.Polichtchouk)
[u/mrichter/AliRoot.git] / MUON / AliMUONTrack.cxx
index 92b32b7354555bd310dbbcf1bb2e4ea5b6750d8b..f096d8ea234367b80c926b6f3971c97afba9688e 100644 (file)
 //
 ///////////////////////////////////////////////////
 
-#include <stdlib.h> // for exit()
-
-#include <Riostream.h> // for cout
-#include <TMath.h>
-#include <TMatrixD.h>
-#include <TObjArray.h>
-#include <TVirtualFitter.h>
-
-#include "AliLog.h"
+#include "AliMUONTrack.h"
 
 #include "AliMUONTrackReconstructor.h" 
 #include "AliMUONHitForRec.h" 
 #include "AliMUONSegment.h" 
-#include "AliMUONTrack.h"
 #include "AliMUONTrackHit.h"
 #include "AliMUONTriggerTrack.h"
 #include "AliMUONConstants.h"
 
+#include "AliLog.h"
+
+#include <Riostream.h> // for cout
+#include <TMath.h>
+#include <TMatrixD.h>
+#include <TObjArray.h>
+#include <TVirtualFitter.h>
+
+#include <stdlib.h> // for exit()
+
 // Functions to be minimized with Minuit
 void TrackChi2(Int_t &NParam, Double_t *Gradient, Double_t &Chi2, Double_t *Param, Int_t Flag);
 void TrackChi2MCS(Int_t &NParam, Double_t *Gradient, Double_t &Chi2, Double_t *Param, Int_t Flag);
@@ -51,20 +52,20 @@ void mnvertLocal(Double_t* a, Int_t l, Int_t m, Int_t n, Int_t& ifail);
 
 Double_t MultipleScatteringAngle2(AliMUONTrackHit *TrackHit);
 
-ClassImp(AliMUONTrack) // Class implementation in ROOT context
-
 TVirtualFitter* AliMUONTrack::fgFitter = NULL; 
 
-  //__________________________________________________________________________
+ClassImp(AliMUONTrack) // Class implementation in ROOT context
+
+//__________________________________________________________________________
 AliMUONTrack::AliMUONTrack()
   : TObject() 
 {
   // Default constructor
   fgFitter = 0;
   fTrackReconstructor = 0;
-  fTrackHitsPtr = new TObjArray(10);
-  fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);  
-  fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10); 
+  fTrackHitsPtr = NULL;
+  fTrackParamAtHit = NULL;
+  fHitForRecAtHit = NULL;
   fTrackID = 0;
 }
 
@@ -77,10 +78,12 @@ AliMUONTrack::AliMUONTrack(AliMUONSegment* BegSegment, AliMUONSegment* EndSegmen
   // memory allocation for the TObjArray of pointers to reconstructed TrackHit's
   fTrackHitsPtr = new TObjArray(10);
   fNTrackHits = 0;
-  AddSegment(BegSegment); // add hits from BegSegment
-  AddSegment(EndSegment); // add hits from EndSegment
-  fTrackHitsPtr->Sort(); // sort TrackHits according to increasing Z
-  SetTrackParamAtVertex(); // set track parameters at vertex
+  if (BegSegment) { //AZ
+    AddSegment(BegSegment); // add hits from BegSegment
+    AddSegment(EndSegment); // add hits from EndSegment
+    fTrackHitsPtr->Sort(); // sort TrackHits according to increasing Z
+    SetTrackParamAtVertex(); // set track parameters at vertex
+  }
   fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
   fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
   // set fit conditions...
@@ -155,26 +158,35 @@ AliMUONTrack::AliMUONTrack (const AliMUONTrack& theMUONTrack)
   fTrackParamAtVertex = theMUONTrack.fTrackParamAtVertex;
 
  // necessary to make a copy of the objects and not only the pointers in TObjArray.
-  fTrackHitsPtr  =  new TObjArray(10);
-  for (Int_t index = 0; index < (theMUONTrack.fTrackHitsPtr)->GetEntriesFast(); index++) {
-    AliMUONTrackHit *trackHit = new AliMUONTrackHit(*(AliMUONTrackHit*)(theMUONTrack.fTrackHitsPtr)->At(index));
-    fTrackHitsPtr->Add(trackHit);
+  fTrackHitsPtr = 0;
+  if (theMUONTrack.fTrackHitsPtr) {
+    fTrackHitsPtr  =  new TObjArray(10);
+    for (Int_t index = 0; index < (theMUONTrack.fTrackHitsPtr)->GetEntriesFast(); index++) {
+      AliMUONTrackHit *trackHit = new AliMUONTrackHit(*(AliMUONTrackHit*)(theMUONTrack.fTrackHitsPtr)->At(index));
+      fTrackHitsPtr->Add(trackHit);
+    }
+    fTrackHitsPtr->SetOwner(); // nedeed for deleting TClonesArray
   }
-  fTrackHitsPtr->SetOwner(); // nedeed for deleting TClonesArray
 
   // necessary to make a copy of the objects and not only the pointers in TClonesArray.
-  fTrackParamAtHit  =  new TClonesArray("AliMUONTrackParam",10);
-  for (Int_t index = 0; index < (theMUONTrack.fTrackParamAtHit)->GetEntriesFast(); index++) {
-    {new ((*fTrackParamAtHit)[fTrackParamAtHit->GetEntriesFast()]) 
-       AliMUONTrackParam(*(AliMUONTrackParam*)(theMUONTrack.fTrackParamAtHit)->At(index));}
-  }
+  fTrackParamAtHit = 0;
+  if (theMUONTrack.fTrackParamAtHit) {
+    fTrackParamAtHit  =  new TClonesArray("AliMUONTrackParam",10);
+    for (Int_t index = 0; index < (theMUONTrack.fTrackParamAtHit)->GetEntriesFast(); index++) {
+      {new ((*fTrackParamAtHit)[fTrackParamAtHit->GetEntriesFast()]) 
+         AliMUONTrackParam(*(AliMUONTrackParam*)(theMUONTrack.fTrackParamAtHit)->At(index));}
+    }
+  }  
 
   // necessary to make a copy of the objects and not only the pointers in TClonesArray.
-  fHitForRecAtHit  =  new TClonesArray("AliMUONHitForRec",10);
-  for (Int_t index = 0; index < (theMUONTrack.fHitForRecAtHit)->GetEntriesFast(); index++) {
-    {new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()]) 
-       AliMUONHitForRec(*(AliMUONHitForRec*)(theMUONTrack.fHitForRecAtHit)->At(index));}
-  }
+  fHitForRecAtHit = 0;
+  if (theMUONTrack.fHitForRecAtHit) {
+    fHitForRecAtHit  =  new TClonesArray("AliMUONHitForRec",10);
+    for (Int_t index = 0; index < (theMUONTrack.fHitForRecAtHit)->GetEntriesFast(); index++) {
+      {new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()]) 
+         AliMUONHitForRec(*(AliMUONHitForRec*)(theMUONTrack.fHitForRecAtHit)->At(index));}
+    }
+  }  
 
   fNTrackHits       =  theMUONTrack.fNTrackHits;
   fFitMCS           =  theMUONTrack.fFitMCS;
@@ -204,26 +216,35 @@ AliMUONTrack & AliMUONTrack::operator=(const AliMUONTrack& theMUONTrack)
   fTrackParamAtVertex =  theMUONTrack.fTrackParamAtVertex;
 
  // necessary to make a copy of the objects and not only the pointers in TObjArray.
-  fTrackHitsPtr  =  new TObjArray(10);
-  for (Int_t index = 0; index < (theMUONTrack.fTrackHitsPtr)->GetEntriesFast(); index++) {
-    AliMUONTrackHit *trackHit = new AliMUONTrackHit(*(AliMUONTrackHit*)(theMUONTrack.fTrackHitsPtr)->At(index));
-    fTrackHitsPtr->Add(trackHit);
-  }
-  fTrackHitsPtr->SetOwner();  // nedeed for deleting TClonesArray
+  fTrackHitsPtr = 0;
+  if (theMUONTrack.fTrackHitsPtr) {
+    fTrackHitsPtr  =  new TObjArray(10);
+    for (Int_t index = 0; index < (theMUONTrack.fTrackHitsPtr)->GetEntriesFast(); index++) {
+      AliMUONTrackHit *trackHit = new AliMUONTrackHit(*(AliMUONTrackHit*)(theMUONTrack.fTrackHitsPtr)->At(index));
+      fTrackHitsPtr->Add(trackHit);
+    }
+    fTrackHitsPtr->SetOwner();  // nedeed for deleting TClonesArray
+  }  
 
   // necessary to make a copy of the objects and not only the pointers in TClonesArray.
-  fTrackParamAtHit  =  new TClonesArray("AliMUONTrackParam",10);
-  for (Int_t index = 0; index < (theMUONTrack.fTrackParamAtHit)->GetEntriesFast(); index++) {
-    {new ((*fTrackParamAtHit)[fTrackParamAtHit->GetEntriesFast()]) 
-       AliMUONTrackParam(*(AliMUONTrackParam*)(theMUONTrack.fTrackParamAtHit)->At(index));}
-  }
+  fTrackParamAtHit = 0;
+  if (theMUONTrack.fTrackParamAtHit) {
+    fTrackParamAtHit  =  new TClonesArray("AliMUONTrackParam",10);
+    for (Int_t index = 0; index < (theMUONTrack.fTrackParamAtHit)->GetEntriesFast(); index++) {
+      {new ((*fTrackParamAtHit)[fTrackParamAtHit->GetEntriesFast()]) 
+         AliMUONTrackParam(*(AliMUONTrackParam*)(theMUONTrack.fTrackParamAtHit)->At(index));}
+    }
+  }  
 
   // necessary to make a copy of the objects and not only the pointers in TClonesArray.
-  fHitForRecAtHit  =  new TClonesArray("AliMUONHitForRec",10);
-  for (Int_t index = 0; index < (theMUONTrack.fHitForRecAtHit)->GetEntriesFast(); index++) {
-    {new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()]) 
-       AliMUONHitForRec(*(AliMUONHitForRec*)(theMUONTrack.fHitForRecAtHit)->At(index));}
-  }
+  fHitForRecAtHit = 0;
+  if (theMUONTrack.fHitForRecAtHit) {  
+    fHitForRecAtHit  =  new TClonesArray("AliMUONHitForRec",10);
+    for (Int_t index = 0; index < (theMUONTrack.fHitForRecAtHit)->GetEntriesFast(); index++) {
+      {new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()]) 
+         AliMUONHitForRec(*(AliMUONHitForRec*)(theMUONTrack.fHitForRecAtHit)->At(index));}
+    }
+  }  
 
   fNTrackHits         =  theMUONTrack.fNTrackHits;
   fFitMCS             =  theMUONTrack.fFitMCS;
@@ -606,6 +627,26 @@ void AliMUONTrack::SetTrackParamAtVertex()
   trackParam->SetNonBendingCoor(0.0);
 }
 
+  //__________________________________________________________________________
+void AliMUONTrack::AddTrackParamAtHit(const AliMUONTrackParam *trackParam) 
+{
+  // Add track paremeters
+
+  if (!fTrackParamAtHit)
+    fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);  
+
+  new ((*fTrackParamAtHit)[fTrackParamAtHit->GetEntriesFast()]) AliMUONTrackParam(*trackParam);
+}
+
+  //__________________________________________________________________________
+void AliMUONTrack::AddHitForRecAtHit(const AliMUONHitForRec *hitForRec) 
+{
+  if (!fHitForRecAtHit)
+    fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10); 
+
+  new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()]) AliMUONHitForRec(*hitForRec);
+}
+
   //__________________________________________________________________________
 void TrackChi2(Int_t &NParam, Double_t * /*Gradient*/, Double_t &Chi2, Double_t *Param, Int_t /*Flag*/)
 {
@@ -946,3 +987,29 @@ L100:
     ifail = 1;
 } /* mnvertLocal */
 
+//_____________________________________________-
+void AliMUONTrack::Print(Option_t* opt) const
+{
+//
+  // Printing Track information 
+  // "full" option for printing all the information about the track
+  //
+  TString sopt(opt);
+  sopt.ToUpper();
+  if ( sopt.Contains("FULL") ) { 
+    cout << "<AliMUONTrack> No.Clusters=" << setw(2)   << GetNTrackHits() << 
+      //      ", Bending P="<< setw(8) << setprecision(5)      << 1./GetInverseBendingMomentum() << 
+      //", NonBendSlope=" << setw(8) << setprecision(5)  << GetNonBendingSlope()*180./TMath::Pi() <<
+      //", BendSlope=" << setw(8) << setprecision(5)     << GetBendingSlope()*180./TMath::Pi() <<
+      ", Match2Trig=" << setw(1) << GetMatchTrigger()  << 
+      ", Chi2-tracking-trigger=" << setw(8) << setprecision(5) <<  GetChi2MatchTrigger() << endl ;
+    GetTrackParamAtHit()->First()->Print("full");
+  }
+  else {
+    cout << "<AliMUONTrack>";
+    GetTrackParamAtHit()->First()->Print("");
+
+  }
+    
+}