]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New files: used in alice-macros/kine_tracks.C to set path marks in imported tracks.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Feb 2007 18:05:35 +0000 (18:05 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 19 Feb 2007 18:05:35 +0000 (18:05 +0000)
EVE/Alieve/KineTools.cxx [new file with mode: 0644]
EVE/Alieve/KineTools.h [new file with mode: 0644]
EVE/Alieve/LinkDef.h

diff --git a/EVE/Alieve/KineTools.cxx b/EVE/Alieve/KineTools.cxx
new file mode 100644 (file)
index 0000000..c5d7cb6
--- /dev/null
@@ -0,0 +1,159 @@
+// $Header$
+
+#include "KineTools.h"
+
+#include <TObject.h>
+#include <TTree.h>
+#include <TBranchElement.h>
+#include <AliStack.h>
+#include <AliTrackReference.h>
+
+#include "Reve/Track.h"
+#include "Reve/RenderElement.h"
+
+#include <algorithm>
+
+//______________________________________________________________________
+// KineTools
+//
+
+using namespace Reve;
+using namespace Alieve;
+using namespace std;
+
+ClassImp(KineTools)
+
+KineTools::KineTools()
+{
+
+}
+
+/**************************************************************************/
+void KineTools::SetDaughterPathMarks(TrackList* cont,  AliStack* stack )
+{
+  // import daughters birth points 
+  RenderElement::List_i  iter = cont->BeginChildren();
+
+  while(iter != cont->EndChildren())
+  {
+    Track* track = dynamic_cast<Track*>(*iter); 
+    TParticle* p = stack->Particle(track->GetLabel());
+    if(p->GetNDaughters()) {
+      Int_t d0 = p->GetDaughter(0), d1 = p->GetDaughter(1);
+      for(int d=d0; d>0 && d<=d1;++d) 
+      {        
+       TParticle* dp = stack->Particle(d);
+       Reve::PathMark* pm = new PathMark( PathMark::Daughter);
+        pm->V.Set(dp->Vx(),dp->Vy(), dp->Vz());
+       pm->P.Set(dp->Px(),dp->Py(), dp->Pz()); 
+        pm->time = dp->T();
+        track->AddPathMark(pm);
+      }
+    }
+    ++iter;
+  }
+}
+
+/**************************************************************************/
+
+namespace {
+struct cmp_pathmark {
+  bool operator()(PathMark* const & a, PathMark* const & b)
+  { return a->time < b->time; }
+};
+}
+
+void KineTools::SetPathMarks(TrackList* cont, AliStack* stack , TTree* treeTR)
+{
+  // set decay and reference points
+
+  static const Exc_t eH("KineTools::ImportPathMarks");
+
+  if(treeTR == 0) {
+    SetDaughterPathMarks(cont, stack);
+    return;
+  }
+
+  map<Int_t, vector<PathMark*> > refs;
+
+  Int_t nPrimaries = (Int_t) treeTR->GetEntries();
+  TIter next(treeTR->GetListOfBranches());
+  TBranchElement* el;
+  Bool_t isRef = kTRUE;
+  treeTR->SetBranchStatus("*",0);
+
+  while ((el = (TBranchElement*) next()))
+  {
+    if (strcmp("AliRun",el->GetName()) == 0)
+      isRef = kFALSE;
+
+    treeTR->SetBranchStatus(Form("%s*", el->GetName()), 1);
+    for (Int_t iPrimPart = 0; iPrimPart<nPrimaries; iPrimPart++) 
+    {
+     
+      TClonesArray* arr = 0;
+      treeTR->SetBranchAddress(el->GetName(), &arr);
+      treeTR->GetEntry(iPrimPart);
+    
+      for (Int_t iTrackRef = 0; iTrackRef < arr->GetEntriesFast(); iTrackRef++) 
+      {
+       AliTrackReference* atr = (AliTrackReference*)arr->At(iTrackRef);
+       Int_t track = atr->GetTrack();
+        if(atr->TestBit(TObject::kNotDeleted)) {
+         if(track > 0)
+         { 
+            PathMark* pm;
+           if(isRef) 
+             pm = new PathMark(PathMark::Reference);
+           else
+             pm = new PathMark(PathMark::Decay);
+             
+           pm->V.Set(atr->X(),atr->Y(), atr->Z());
+           pm->P.Set(atr->Px(),atr->Py(), atr->Pz());  
+           pm->time = atr->GetTime();
+
+           vector<PathMark*>& v = refs[track];
+            v.push_back(pm);
+         }
+         else
+           throw(eH + "negative label for entry " + Form("%d",iTrackRef) + " in branch " + el->GetName()+ ".");
+       }
+      } // loop track refs 
+      treeTR->SetBranchAddress(el->GetName(), 0);
+    } // loop primaries, clones arrays
+    treeTR->SetBranchStatus(Form("%s*", el->GetName()), 0);
+  } // end loop through top branches
+
+
+  // sort references and add it to tracks
+  RenderElement::List_i  cit = cont->BeginChildren();
+  while(cit != cont->EndChildren())
+  {
+    Track* track = dynamic_cast<Track*>(*cit);
+
+    // add daughters path marks in the map 
+    TParticle* p = stack->Particle(track->GetLabel());
+    if(p->GetNDaughters()) {
+      for(int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter();++d) 
+      {        
+       TParticle* dp = stack->Particle(d);
+       Reve::PathMark* pm = new PathMark( PathMark::Daughter);
+       pm->V.Set(dp->Vx(),dp->Vy(), dp->Vz());
+       pm->P.Set(dp->Px(),dp->Py(), dp->Pz()); 
+       pm->time = dp->T();
+       vector<PathMark*>& v = refs[track->GetLabel()];
+       v.push_back(pm);
+      }
+    }
+    
+    map<Int_t, vector<PathMark*> > ::iterator ri = refs.find(track->GetLabel());
+    if(ri != refs.end()) {
+      vector<PathMark*>& v = ri->second;
+      sort(v.begin(), v.end(), cmp_pathmark());
+      for(vector<PathMark*>::iterator i=v.begin(); i!=v.end(); ++i){
+       track->AddPathMark(*i);
+      }
+    }
+    ++cit;
+  }
+}
diff --git a/EVE/Alieve/KineTools.h b/EVE/Alieve/KineTools.h
new file mode 100644 (file)
index 0000000..0407023
--- /dev/null
@@ -0,0 +1,42 @@
+// $Header$
+
+// Tools for import of kinematics. 
+// Preliminary/minimal solution.
+
+#ifndef ALIEVE_KineTools_H
+#define ALIEVE_KineTools_H
+
+#include <Reve/Reve.h>
+#include <TObject.h>
+
+class TTree;
+class AliStack;
+
+namespace Reve {
+  class TrackList;
+}
+
+namespace Alieve {
+class KineTools
+{
+private:
+  KineTools(const KineTools&);            // Not implemented
+  KineTools& operator=(const KineTools&); // Not implemented
+
+protected:
+  // data from TreeK
+  void SetDaughterPathMarks(Reve::TrackList* cont,  AliStack* stack);
+
+public:
+  KineTools();
+  virtual ~KineTools(){}
+  // data from TreeTR
+  void SetPathMarks(Reve::TrackList* cont, AliStack* stack, TTree* treeTR = 0);
+
+  ClassDef(KineTools, 1);
+}; // endclass KineTools
+
+} // end namespace Alieve
+
+#endif
index ef6d71e531d2e2afa6818a054b42199c05e6edfd..11d9300aa21a99cb10dbdee4de8bea11a9beee6b 100644 (file)
@@ -12,6 +12,8 @@
 #pragma link C++ class  Alieve::Event+;
 #pragma link C++ global Alieve::gEvent;
 
+#pragma link C++ class Alieve::KineTools+;
+
 #pragma link C++ class Alieve::VSDCreator+;
 
 //================================