--- /dev/null
+/* $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;
+}
--- /dev/null
+/* $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
+
#include <TCanvas.h>
#include <TRegexp.h>
#include <TTime.h>
-#include <TParticle.h>
-#include <TParticlePDG.h>
#include <TFriendElement.h>
#include <TTree.h>
#include <TChain.h>
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;
-}
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
#include <AliLog.h>
#include <AliRunLoader.h>
-#include <AliHeader.h>
-#include <TChain.h>
+#include <TTree.h>
#include <TFile.h>
//
AliSelectorRL::AliSelectorRL() :
AliSelector(),
- fRunLoader(0),
- fHeaderFile(0),
- fHeaderTree(0),
- fHeader(0)
+ fRunLoader(0)
{
//
// Constructor. Initialization of pointers
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;
}
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
return 0;
fRunLoader->LoadgAlice();
+ fRunLoader->GetEvent(fTree->GetTree()->GetReadEntry());
}
return fRunLoader;
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();
}
class AliRunLoader;
class AliHeader;
+class AliStack;
class AliSelectorRL : public AliSelector {
public:
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);
};