]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
class with static analysis helper functions
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Jun 2006 10:22:52 +0000 (10:22 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Jun 2006 10:22:52 +0000 (10:22 +0000)
updated selectors to use stack to access particles

PWG0/AliPWG0Helper.cxx [new file with mode: 0644]
PWG0/AliPWG0Helper.h [new file with mode: 0644]
PWG0/AliSelector.cxx
PWG0/AliSelector.h
PWG0/AliSelectorRL.cxx
PWG0/AliSelectorRL.h

diff --git a/PWG0/AliPWG0Helper.cxx b/PWG0/AliPWG0Helper.cxx
new file mode 100644 (file)
index 0000000..98420bc
--- /dev/null
@@ -0,0 +1,100 @@
+/* $Id$ */
+
+#include <AliPWG0Helper.h>
+
+#include <TParticle.h>
+#include <TParticlePDG.h>
+
+#include <AliLog.h>
+#include <AliESD.h>
+#include <AliESDVertex.h>
+
+//____________________________________________________________________
+ClassImp(AliPWG0Helper)
+
+//____________________________________________________________________
+Bool_t AliPWG0Helper::IsEventTriggered(AliESD* aEsd)
+{
+  // check if the event was triggered
+  //
+  // MB should be
+  // ITS_SPD_GFO_L0  : 32
+  // VZERO_OR_LEFT   : 1
+  // VZERO_OR_RIGHT  : 2
+
+  ULong64_t triggerMask = aEsd->GetTriggerMask();
+
+  if (triggerMask&32 && ((triggerMask&1) || (triggerMask&2)))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+//____________________________________________________________________
+Bool_t AliPWG0Helper::IsVertexReconstructed(AliESD* aEsd)
+{
+  // checks if the vertex is reasonable
+
+  const AliESDVertex* vtxESD = aEsd->GetVertex();
+
+  // the vertex should be reconstructed
+  if (strcmp(vtxESD->GetName(), "default")==0)
+    return kFALSE;
+
+  Double_t vtx_res[3];
+  vtx_res[0] = vtxESD->GetXRes();
+  vtx_res[1] = vtxESD->GetYRes();
+  vtx_res[2] = vtxESD->GetZRes();
+
+  if (vtx_res[2]==0 || vtx_res[2]>0.1)
+    return kFALSE;
+
+  return kTRUE;
+}
+
+//____________________________________________________________________
+Bool_t AliPWG0Helper::IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries)
+{
+  //
+  // Returns if the given particle is a primary particle
+  // This function or a equivalent should be available in some common place of AliRoot
+  //
+
+  // if the particle has a daughter primary, we do not want to count it
+  if (aParticle->GetFirstDaughter() != -1 && aParticle->GetFirstDaughter() < aTotalPrimaries)
+  {
+    //AliDebug(AliLog::kDebug+1, "Dropping particle because it has a daughter among the primaries.");
+    return kFALSE;
+  }
+
+  Int_t pdgCode = TMath::Abs(aParticle->GetPdgCode());
+
+  // skip quarks and gluon
+  if (pdgCode <= 10 || pdgCode == 21)
+  {
+    //AliDebug(AliLog::kDebug+1, "Dropping particle because it is a quark or gluon.");
+    return kFALSE;
+  }
+
+  if (strcmp(aParticle->GetName(),"XXX") == 0)
+  {
+    //AliDebug(AliLog::kDebug, Form("WARNING: There is a particle named XXX."));
+    return kFALSE;
+  }
+
+  TParticlePDG* pdgPart = aParticle->GetPDG();
+
+  if (strcmp(pdgPart->ParticleClass(),"Unknown") == 0)
+  {
+    //AliDebug(AliLog::kDebug, Form("WARNING: There is a particle with an unknown particle class (pdg code %d).", pdgCode));
+    return kFALSE;
+  }
+
+  if (pdgPart->Charge() == 0)
+  {
+    //AliDebug(AliLog::kDebug+1, "Dropping particle because it is not charged.");
+    return kFALSE;
+  }
+
+  return kTRUE;
+}
diff --git a/PWG0/AliPWG0Helper.h b/PWG0/AliPWG0Helper.h
new file mode 100644 (file)
index 0000000..404d454
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Id$ */
+
+#ifndef ALIPWG0HELPER_H
+#define ALIPWG0HELPER_H
+
+#include <TObject.h>
+
+// static helper functions
+
+class AliESD;
+class TParticle;
+
+class AliPWG0Helper : public TObject
+{
+  public:
+    static Bool_t IsEventTriggered(AliESD* aEsd);
+    static Bool_t IsVertexReconstructed(AliESD* aEsd);
+    static Bool_t IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries);
+
+  protected:
+    ClassDef(AliPWG0Helper, 0)
+};
+
+#endif
+
index 5a1c1d20d5d647cb6ce214a9e67086fa11baa979..7575b758b64cc896b7fcf8fd9cad31f29cba657f 100644 (file)
@@ -31,8 +31,6 @@
 #include <TCanvas.h>
 #include <TRegexp.h>
 #include <TTime.h>
-#include <TParticle.h>
-#include <TParticlePDG.h>
 #include <TFriendElement.h>
 #include <TTree.h>
 #include <TChain.h>
@@ -242,49 +240,3 @@ void AliSelector::DeleteKinematicsFile()
     fKineFile = 0;
   }
 }
-
-Bool_t AliSelector::IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries) const
-{
-  //
-  // Returns if the given particle is a primary particle
-  // This function or a equivalent should be available in some common place of AliRoot
-  //
-
-  // if the particle has a daughter primary, we do not want to count it
-  if (aParticle->GetFirstDaughter() != -1 && aParticle->GetFirstDaughter() < aTotalPrimaries)
-  {
-    AliDebug(AliLog::kDebug+1, "Dropping particle because it has a daughter among the primaries.");
-    return kFALSE;
-  }
-
-  Int_t pdgCode = TMath::Abs(aParticle->GetPdgCode());
-
-  // skip quarks and gluon
-  if (pdgCode <= 10 || pdgCode == 21)
-  {
-    AliDebug(AliLog::kDebug+1, "Dropping particle because it is a quark or gluon.");
-    return kFALSE;
-  }
-
-  if (strcmp(aParticle->GetName(),"XXX") == 0)
-  {
-    AliDebug(AliLog::kDebug, Form("WARNING: There is a particle named XXX."));
-    return kFALSE;
-  }
-
-  TParticlePDG* pdgPart = aParticle->GetPDG();
-
-  if (strcmp(pdgPart->ParticleClass(),"Unknown") == 0)
-  {
-    AliDebug(AliLog::kDebug, Form("WARNING: There is a particle with an unknown particle class (pdg code %d).", pdgCode));
-    return kFALSE;
-  }
-
-  if (pdgPart->Charge() == 0)
-  {
-    return kFALSE;
-    AliDebug(AliLog::kDebug+1, "Dropping particle because it is not charged.");
-  }
-
-  return kTRUE;
-}
index 2e76020efcaeaecbf648ab46d0d3eccf0f75abd6..07c0ce265dd3de6c2bf6fb88a9f309d73d20c60b 100644 (file)
@@ -30,7 +30,6 @@ class AliSelector : public TSelector {
 
  protected:
     TTree*  GetKinematics();
-    Bool_t IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries) const;
 
     TTree          *fTree;     //! pointer to the TTree containing the events
     AliESD*          fESD;     //! "ESD" branch in fChain
index d4b858d8336b15e924ed5f8a30408de6e7a43932..0255483e5d7155ae95fadfe27ff896a868084e81 100644 (file)
@@ -4,9 +4,8 @@
 
 #include <AliLog.h>
 #include <AliRunLoader.h>
-#include <AliHeader.h>
 
-#include <TChain.h>
+#include <TTree.h>
 #include <TFile.h>
 
 //
@@ -19,10 +18,7 @@ ClassImp(AliSelectorRL)
 
 AliSelectorRL::AliSelectorRL() :
   AliSelector(),
-  fRunLoader(0),
-  fHeaderFile(0),
-  fHeaderTree(0),
-  fHeader(0)
+  fRunLoader(0)
 {
   //
   // Constructor. Initialization of pointers
@@ -48,7 +44,19 @@ Bool_t AliSelectorRL::Notify()
     return kFALSE;
 
   DeleteRunLoader();
-  DeleteHeaderFile();
+
+  return kTRUE;
+}
+
+Bool_t AliSelectorRL::Process(Long64_t entry)
+{
+  // Call the baseclass Process and set event number in runLoader (if loaded)
+
+  if (AliSelector::Process(entry) == kFALSE)
+    return kFALSE;
+
+  if (fRunLoader)
+    fRunLoader->GetEvent(entry);
 
   return kTRUE;
 }
@@ -60,10 +68,9 @@ void AliSelectorRL::SlaveTerminate()
   AliSelector::SlaveTerminate();
 
   DeleteRunLoader();
-  DeleteHeaderFile();
 }
 
-AliRunLoader* AliSelectorRL::GetAliRunLoader()
+AliRunLoader* AliSelectorRL::GetRunLoader()
 {
   // Returns AliRun instance corresponding to current ESD active in fTree
   // Loads galice.root, the file is identified by replacing "AliESDs" to
@@ -82,6 +89,7 @@ AliRunLoader* AliSelectorRL::GetAliRunLoader()
       return 0;
 
     fRunLoader->LoadgAlice();
+    fRunLoader->GetEvent(fTree->GetTree()->GetReadEntry());
   }
 
   return fRunLoader;
@@ -102,47 +110,28 @@ void AliSelectorRL::DeleteRunLoader()
 
 AliHeader* AliSelectorRL::GetHeader()
 {
-  // Returns header corresponding to current ESD active in fTree
-  // Loads the header from galice.root, the file is identified by replacing "AliESDs" to
-  // "galice" in the file path of the ESD file. This is a hack, to be changed!
+  // Returns header retrieved from RunLoader
 
-  if (!fHeaderFile || !fHeaderTree)
-  {
-    if (!fTree->GetCurrentFile())
-      return 0;
+  AliRunLoader* runLoader = GetRunLoader();
+  if (!runLoader)
+    return 0;
 
-    TString fileName(fTree->GetCurrentFile()->GetName());
-    fileName.ReplaceAll("AliESDs", "galice");
+  if (runLoader->GetHeader() == 0)
+    runLoader->LoadHeader();
 
-    AliDebug(AliLog::kInfo, Form("Opening %s", fileName.Data()));
-
-    fHeaderFile = TFile::Open(fileName);
-    if (!fHeaderFile)
-      return 0;
-
-    fHeaderTree = dynamic_cast<TTree*> (fHeaderFile->Get("TE"));
-    if (!fHeaderTree)
-      return 0;
-
-    fHeaderTree->SetBranchAddress("Header", &fHeader);
-  }
-
-  fHeaderTree->GetEntry(fTree->GetTree()->GetReadEntry());
-
-  return fHeader;
+  return runLoader->GetHeader();
 }
 
-void AliSelectorRL::DeleteHeaderFile()
+AliStack* AliSelectorRL::GetStack()
 {
-  //
-  // Closes the kinematics file and deletes the pointer.
-  //
+  // Returns stack retrieved from RunLoader
 
-  if (fHeaderFile)
-  {
-    fHeaderFile->Close();
-    delete fHeaderFile;
-    fHeaderTree = 0;
-    fHeader = 0;
-  }
+  AliRunLoader* runLoader = GetRunLoader();
+  if (!runLoader)
+    return 0;
+
+  if (runLoader->Stack() == 0)
+    runLoader->LoadKinematics();
+
+  return runLoader->Stack();
 }
index 0fee90a6643435dd2db829f561e19feae95f22f5..eda53251931b051045a86e8c03e16cb385fb0564 100644 (file)
@@ -9,6 +9,7 @@
 
 class AliRunLoader;
 class AliHeader;
+class AliStack;
 
 class AliSelectorRL : public AliSelector {
   public:
@@ -16,22 +17,19 @@ class AliSelectorRL : public AliSelector {
     virtual ~AliSelectorRL();
 
     virtual Bool_t  Notify();
+    virtual Bool_t  Process(Long64_t entry);
     virtual void    SlaveTerminate();
 
  protected:
-    AliRunLoader* GetAliRunLoader();
+    AliRunLoader* GetRunLoader();
     AliHeader* GetHeader();
+    AliStack* GetStack();
 
  private:
     void DeleteRunLoader();
-    void DeleteHeaderFile();
 
     AliRunLoader* fRunLoader;    //! pointer to the RunLoader if galice.root was opened
 
-    TFile*        fHeaderFile; //! pointer to galice.root, if the file was opened
-    TTree*        fHeaderTree; //! holds TE tree of current galice.root
-    AliHeader*    fHeader;     //! holds pointer to current header
-
     ClassDef(AliSelectorRL,0);
 };