Write all track references into one branch of TreeTR.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 27 Jul 2007 08:10:52 +0000 (08:10 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 27 Jul 2007 08:10:52 +0000 (08:10 +0000)
STEER/AliDetector.cxx
STEER/AliDetector.h
STEER/AliMC.cxx
STEER/AliMC.h
STEER/AliModule.cxx
STEER/AliModule.h
STEER/AliTrackReference.cxx
STEER/AliTrackReference.h

index 3bf7125..8612073 100644 (file)
@@ -413,8 +413,6 @@ void AliDetector::SetTreeAddress()
     branch = treeD->GetBranch(GetName());
     if (branch) branch->SetAddress(&fDigits);
   }
-  
-  AliModule::SetTreeAddress();
 }
 
 //_______________________________________________________________________
index aab9a5c..f557645 100644 (file)
@@ -61,6 +61,7 @@ public:
   virtual TBranch*    MakeBranchInTree(TTree *tree, const char* cname, const char* name, void* address, Int_t size=32000, Int_t splitlevel=99, const char *file=0);
   
   void MakeTree(Option_t *option); //skowron
+  virtual void        RemapTrackHitIDs(Int_t *) {}
   
   virtual AliLoader* MakeLoader(const char* topfoldername); //builds standard getter (AliLoader type)
   void    SetLoader(AliLoader* loader){fLoader = loader;}
index a055a4f..94b6f6a 100644 (file)
@@ -28,6 +28,7 @@
 #include <TStopwatch.h>
 #include <TSystem.h>
 #include <TVirtualMC.h>
+#include <TParticle.h>
 #include <TROOT.h>
  
 #include "AliLog.h"
@@ -373,7 +374,8 @@ void AliMC::Stepping()
     //
     // write tracke reference for track which is dissapearing - MI
     if (gMC->IsTrackDisappeared()) {      
-       if (gMC->Etot()>0.05) AddTrackReference(GetCurrentTrackNumber());
+       if (gMC->Etot()>0.05) AddTrackReference(GetCurrentTrackNumber(), 
+                                               AliTrackReference::kDisappeared);
     }
   
     //Call the appropriate stepping routine;
@@ -388,7 +390,7 @@ void AliMC::Stepping()
 //_______________________________________________________________________
 void AliMC::EnergySummary()
 {
-  //
+  //e
   // Print summary of deposited energy
   //
 
@@ -486,7 +488,9 @@ void AliMC::BeginEvent()
   else
     runloader->MakeStack();//or make a new one
   
-  if(gAlice->Lego() == 0x0)
+//  runloader->Stack()->BeginEvent();
+  
+if(gAlice->Lego() == 0x0)
    { 
      AliDebug(1, "fRunLoader->MakeTree(K)");
      runloader->MakeTree("K");
@@ -529,10 +533,6 @@ void AliMC::BeginEvent()
    {
     AliDebug(2, Form("%s->MakeBranch(H)",detector->GetName()));
     detector->MakeBranch("H"); 
-    AliDebug(2, Form("%s->MakeBranchTR()",detector->GetName()));
-    detector->MakeBranchTR();
-    AliDebug(2, Form("%s->SetTreeAddress()",detector->GetName()));
-    detector->SetTreeAddress();
    }
   // make branch for AliRun track References
   TTree * treeTR = runloader->TreeTR();
@@ -540,7 +540,7 @@ void AliMC::BeginEvent()
     // make branch for central track references
     if (!fTrackReferences) fTrackReferences = new TClonesArray("AliTrackReference",0);
     TBranch *branch;
-    branch = treeTR->Branch("AliRun",&fTrackReferences);
+    branch = treeTR->Branch("TrackReferences",&fTrackReferences);
     branch->SetAddress(&fTrackReferences);
   }
   //
@@ -631,10 +631,9 @@ void AliMC::RemapHits()
     
     TObjArray* modules = gAlice->Modules();
     TIter nextmod(modules);
-    AliModule *detector;
-    while((detector = dynamic_cast<AliModule*>(nextmod()))) {
+    AliDetector *detector;
+    while((detector = dynamic_cast<AliDetector*>(nextmod()))) {
        detector->RemapTrackHitIDs(stack->TrackLabelMap());
-       detector->RemapTrackReferencesIDs(stack->TrackLabelMap());
     }
     //
     RemapTrackReferencesIDs(stack->TrackLabelMap());
@@ -1107,16 +1106,20 @@ void AliMC::SetCurrentTrack(Int_t track) const
 }
 
 //_______________________________________________________________________
-void  AliMC::AddTrackReference(Int_t label){
+AliTrackReference*  AliMC::AddTrackReference(Int_t label, Int_t id) 
+{
   //
   // add a trackrefernce to the list
   if (!fTrackReferences) {
     AliError("Container trackrefernce not active");
-    return;
+    return NULL;
   }
+  Int_t primary = GetPrimary(label);
+  Particle(primary)->SetBit(kKeepBit);
+
   Int_t nref = fTrackReferences->GetEntriesFast();
   TClonesArray &lref = *fTrackReferences;
-  new(lref[nref]) AliTrackReference(label);
+  return new(lref[nref]) AliTrackReference(label, id);
 }
 
 
@@ -1128,12 +1131,6 @@ void AliMC::ResetTrackReferences()
   //  Reset all  references
   //
   if (fTrackReferences)   fTrackReferences->Clear();
-
-  TIter next(gAlice->Modules());
-  AliModule *detector;
-  while((detector = dynamic_cast<AliModule*>(next()))) {
-     detector->ResetTrackReferences();
-  }
 }
 
 void AliMC::RemapTrackReferencesIDs(Int_t *map)
index bb175e5..93e3218 100644 (file)
@@ -20,6 +20,7 @@
 class TParticle;
 class AliGenerator;
 class AliMCQA;
+class AliTrackReference;
 
 class AliMC : public TVirtualMCApplication {
 public:
@@ -104,12 +105,12 @@ public:
    virtual  void  KeepTrack(Int_t itra) const;
    virtual  void  FlagTrack(Int_t track) const;
    virtual  void  SetCurrentTrack(Int_t track) const;                           
-// Track reference related 
-   virtual void   AddTrackReference(Int_t label);
-   TClonesArray   *TrackReferences()   const {return fTrackReferences;}
-   virtual void   RemapTrackReferencesIDs(Int_t *map); //remaping track references MI
-   virtual void   ResetTrackReferences();
-   virtual void   FixParticleDecaytime();
+// Track reference related
+   AliTrackReference* AddTrackReference(Int_t label, Int_t id = -999);
+   TClonesArray*      TrackReferences()   const {return fTrackReferences;}
+   virtual void       RemapTrackReferencesIDs(Int_t *map); //remaping track references MI
+   virtual void       ResetTrackReferences();
+   virtual void       FixParticleDecaytime();
 
 private:
    void Copy (TObject &mc) const;
index a1a92d2..72092ae 100644 (file)
@@ -660,161 +660,64 @@ void AliModule::AddAlignableVolumes() const
 }
 
 //_______________________________________________________________________
-void AliModule::RemapTrackReferencesIDs(Int_t *map)
-{
-  // 
-  // Remapping track reference
-  // Called at finish primary
-  //
-  if (!fTrackReferences) return;
-  Int_t nEntries = fTrackReferences->GetEntries();
-  
-  for (Int_t i=0;i<nEntries;i++){
-    AliTrackReference * ref = dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(i));
-    if (ref) {
-      Int_t newID = map[ref->GetTrack()];
-      if (newID>=0) ref->SetTrack(newID);
-      else {
-        ref->SetBit(kNotDeleted,kFALSE);
-        fTrackReferences->RemoveAt(i);  
-      }      
-    }
-  }
-  fTrackReferences->Compress();
-
-}
-
-
-//_______________________________________________________________________
-AliTrackReference* AliModule::FirstTrackReference(Int_t track)
-{
-  //
-  // Initialise the hit iterator
-  // Return the address of the first hit for track
-  // If track>=0 the track is read from disk
-  // while if track<0 the first hit of the current
-  // track is returned
-  // 
-  if(track>=0) 
-   {
-     if (fRunLoader == 0x0)
-       AliFatal("AliRunLoader not initialized. Can not proceed");
-     fRunLoader->GetAliRun()->GetMCApp()->ResetTrackReferences();
-     fRunLoader->TreeTR()->GetEvent(track);
-   }
-  //
-  fMaxIterTrackRef     = fTrackReferences->GetEntriesFast();
-  fCurrentIterTrackRef = 0;
-  if(fMaxIterTrackRef) return dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(0));
-  else            return 0;
-}
-
-//_______________________________________________________________________
-AliTrackReference* AliModule::NextTrackReference()
-{
-  //
-  // Return the next hit for the current track
-  //
-  if(fMaxIterTrackRef) {
-    if(++fCurrentIterTrackRef<fMaxIterTrackRef) 
-      return dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(fCurrentIterTrackRef));
-    else        
-      return 0;
-  } else {
-    AliWarning("Iterator called without calling FistTrackReference before");
-    return 0;
-  }
-}
-
-
-//_______________________________________________________________________
-void AliModule::ResetTrackReferences()
-{
-  //
-  // Reset number of hits and the hits array
-  //
-  fMaxIterTrackRef   = 0;
-  if (fTrackReferences)   fTrackReferences->Clear();
-}
-//_____________________________________________________________________________
 
 AliLoader*  AliModule::MakeLoader(const char* /*topfoldername*/)
 {
   return 0x0;
 }
  
-//PH Merged with v3-09-08 |
-//                        V
-//_____________________________________________________________________________
-
-void AliModule::SetTreeAddress()
-{
-  //
-  // Set branch address for track reference Tree
-  //
-
-  TBranch *branch;
-
-  // Branch address for track reference tree
-  TTree *treeTR = TreeTR();
-
-  if (treeTR && fTrackReferences) {
-     branch = treeTR->GetBranch(GetName());
-    if (branch) 
-     {
-       AliDebug(3, Form("(%s) Setting for TrackRefs",GetName()));
-       branch->SetAddress(&fTrackReferences);
-     }
-    else
-     { 
-     //can be called before MakeBranch and than does not make sense to issue the warning
-       AliDebug(1, Form("(%s) Failed for Track References. Can not find branch in tree.",
-                 GetName()));
-     }
-  }
-}
 
 //_____________________________________________________________________________
-AliTrackReference*  AliModule::AddTrackReference(Int_t label){
+AliTrackReference*  AliModule::AddTrackReference(Int_t label, Int_t id){
   //
   // add a trackrefernce to the list
-  if (!fTrackReferences) {
-    AliError("Container trackrefernce not active");
-    return 0;
-  }
-  Int_t nref = fTrackReferences->GetEntriesFast();
-  TClonesArray &lref = *fTrackReferences;
-  return new(lref[nref]) AliTrackReference(label);
+    return (gAlice->GetMCApp()->AddTrackReference(label, id));
 }
 
-
-//_____________________________________________________________________________
-void AliModule::MakeBranchTR(Option_t */*option*/)
-{ 
+ //_______________________________________________________________________
+AliTrackReference* AliModule::FirstTrackReference(Int_t track)
+{
     //
-    // Makes branch in treeTR
-    //  
-  AliDebug(2,Form("Making Track Refs. Branch for %s",GetName()));
-  TTree * tree = TreeTR();
-  if (fTrackReferences && tree) 
-   {
-      TBranch *branch = tree->GetBranch(GetName());
-     if (branch) 
-       {  
-        AliDebug(2,Form("Branch %s is already in tree.",GetName()));
-        return;
-       }
-  
-     branch = tree->Branch(GetName(),&fTrackReferences);
-   }
-  else
+    // Initialise the hit iterator
+    // Return the address of the first hit for track
+    // If track>=0 the track is read from disk
+    // while if track0 the first hit of the current
+    // track is returned
+    //
+    if(track>=0)
     {
-      AliDebug(2,Form("FAILED for %s: tree=%#x fTrackReferences=%#x",
-            GetName(),tree,fTrackReferences));
+       if (fRunLoader == 0x0)
+           AliFatal("AliRunLoader not initialized. Can not proceed");
+       fRunLoader->GetAliRun()->GetMCApp()->ResetTrackReferences();
+       fRunLoader->TreeTR()->GetEvent(track);
     }
+    //
+    fMaxIterTrackRef     = fTrackReferences->GetEntriesFast();
+    fCurrentIterTrackRef = 0;
+    if(fMaxIterTrackRef) return dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(0));
+    else            return 0;
 }
 
+ //_______________________________________________________________________
+AliTrackReference* AliModule::NextTrackReference()
+{
+    //
+    // Return the next hit for the current track
+    //
+    if(fMaxIterTrackRef) {
+       if(++fCurrentIterTrackRef < fMaxIterTrackRef)
+           return dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(fCurrentIterTrackRef));
+       else
+           return 0;
+    } else {
+       AliWarning("Iterator called without calling FistTrackReference before");
+       return 0;
+    }
+}
+
+
+
+
 //_____________________________________________________________________________
 TTree* AliModule::TreeTR()
 {
index b28c2ba..e28974e 100644 (file)
@@ -127,7 +127,6 @@ public:
   virtual void        ResetSDigits() {}
   virtual void        ResetHits() {}
   virtual void        ResetPoints() {}
-  virtual void        SetTreeAddress();
   virtual void        SetTimeGate(Float_t) {}
   virtual Float_t     GetTimeGate() const {return 1.e10;}
   virtual void        StepManager() {}
@@ -141,13 +140,9 @@ public:
   virtual void        ReadEuclidMedia(const char *filnam);
 // Track reference related
   TClonesArray *TrackReferences()   const {return fTrackReferences;}
-  virtual void        RemapTrackHitIDs(Int_t *) {}
-  virtual void        RemapTrackReferencesIDs(Int_t *map); //remaping track references MI
-  virtual void        ResetTrackReferences();
-  virtual  AliTrackReference * AddTrackReference(Int_t label);
+  virtual  AliTrackReference * AddTrackReference(Int_t label, Int_t id = -999);
   virtual  AliTrackReference * FirstTrackReference(Int_t track);
   virtual  AliTrackReference * NextTrackReference();
-  virtual void        MakeBranchTR(Option_t *opt=" ");
   TTree* TreeTR();  //shorcut method for accessing treeTR from folder
 
   void                SetRunLoader(AliRunLoader* runLoader) 
index 40af88e..5e3729b 100644 (file)
@@ -16,8 +16,9 @@
 /* $Id$ */
 
 #include "TVirtualMC.h"
+#include "TParticle.h"
 
-#include "AliRun.h"
+#include "AliStack.h"
 #include "AliTrackReference.h"
 #include "AliExternalTrackParam.h"
 #include "AliKalmanTrack.h"
@@ -50,7 +51,8 @@ ClassImp(AliTrackReference)
    fPz(0),
    fLength(0),
    fTime(0),
-   fUserId(0)
+   fUserId(0),
+   fDetectorId(-999)
 {
   //
   // Default constructor
@@ -59,8 +61,25 @@ ClassImp(AliTrackReference)
   for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
 }
 
+AliTrackReference::AliTrackReference(const AliTrackReference &tr) :
+  TObject(),
+  fTrack(tr.fTrack),
+  fX(tr.fX),
+  fY(tr.fY),
+  fZ(tr.fZ),
+  fPx(tr.fPx),
+  fPy(tr.fPy),
+  fPz(tr.fPz),
+  fLength(tr.fLength),
+  fTime(tr.fTime),
+  fUserId(tr.fUserId),
+  fDetectorId(tr.fDetectorId)
+{
+    // Copy Constructor
+}
+
 //_______________________________________________________________________
-AliTrackReference::AliTrackReference(Int_t label) :
+AliTrackReference::AliTrackReference(Int_t label, Int_t id) :
   TObject(),
   fTrack(label),
   fX(0),
@@ -71,7 +90,8 @@ AliTrackReference::AliTrackReference(Int_t label) :
   fPz(0),
   fLength(gMC->TrackLength()),
   fTime(gMC->TrackTime()),
-  fUserId(0)
+  fUserId(0),
+  fDetectorId(id)
 {
   //
   // Create Reference object out of label and
@@ -111,6 +131,9 @@ AliTrackReference::AliTrackReference(Int_t label) :
   SetBit(BIT(5), gMC->IsTrackInside());
   SetBit(BIT(6), gMC->IsTrackOut());
   SetBit(BIT(7), gMC->IsTrackStop()); 
+  //
+  // This particle has to be kept
+
 }
 //_______________________________________________________________________
 AliExternalTrackParam * AliTrackReference::MakeTrack(const AliTrackReference *ref, Double_t mass)
@@ -141,7 +164,7 @@ AliExternalTrackParam * AliTrackReference::MakeTrack(const AliTrackReference *re
 
 //_______________________________________________________________________
 void
-AliTrackReference::Print(Option_t* opt) const
+AliTrackReference::Print(Option_t* /*opt*/) const
 {
   cout << Form("Label %d P=%7.2f (X,Y,Z)=(%7.2f,%7.2f,%7.2f) (PX,PY,PZ)=(%7.2f,%7.2f,%7.2f)"
                " Length=%7.2f Time=%7.2f UserId=%d",
index b53f9ce..7f78c47 100644 (file)
 class AliExternalTrackParam;
 
 class AliTrackReference : public TObject {
-
 public:
 
+    enum constants {kDisappeared = -1,
+                   kITS   = 0,
+                   kTPC   = 1,
+                   kFRAME = 2,
+                   kTRD   = 3,
+                   kTOF   = 4,
+                   kMUON  = 5
+    };
   AliTrackReference();
-  AliTrackReference(Int_t label);
+  AliTrackReference(Int_t label, Int_t id = -999);
+  AliTrackReference(const AliTrackReference &tr);
   virtual ~AliTrackReference() {}
 
   static AliExternalTrackParam * MakeTrack(const AliTrackReference *ref, Double_t mass);
@@ -45,6 +53,7 @@ public:
   virtual Float_t Pz() const {return fPz;}
   virtual Float_t P() const {return TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz);}
   virtual Int_t   UserId() const {return fUserId;}
+  virtual Int_t   DetectorId() const {return fDetectorId;}
   virtual void SetPosition(Float_t x, Float_t y, Float_t z){fX=x; fY=y; fZ=z;}
   virtual void SetMomentum(Float_t px, Float_t py, Float_t pz){fPx=px; fPy=py; fPz=pz;}
   virtual void SetUserId(Int_t userId){fUserId=userId;}
@@ -69,17 +78,17 @@ public:
   virtual void Print(Option_t* opt="") const;
     
 protected:
-  Int_t     fTrack;  // Track number
-  Float_t   fX;      // X reference position of the track
-  Float_t   fY;      // Y reference position of the track
-  Float_t   fZ;      // Z reference position of the track
-  Float_t   fPx;     // momentum
-  Float_t   fPy;     // momentum
-  Float_t   fPz;     // momentum
-  Float_t   fLength; // track lenght from its origin in cm
-  Float_t   fTime;   // time of flight in cm  
-  Int_t     fUserId; // optional Id defined by user
-
-  ClassDef(AliTrackReference,5)  //Base class for all Alice track references
+  Int_t     fTrack;      // Track number
+  Float_t   fX;          // X reference position of the track
+  Float_t   fY;          // Y reference position of the track
+  Float_t   fZ;          // Z reference position of the track
+  Float_t   fPx;         // momentum
+  Float_t   fPy;         // momentum
+  Float_t   fPz;         // momentum
+  Float_t   fLength;     // track lenght from its origin in cm
+  Float_t   fTime;       // time of flight in cm  
+  Int_t     fUserId;     // optional Id defined by user
+  Int_t     fDetectorId; // Detector Id
+  ClassDef(AliTrackReference,6)  //Base class for all Alice track references
 };
 #endif