--- /dev/null
+//
+// Class AliRsnAnalysisME
+//
+// TODO
+//
+// authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+// Martin Vala (martin.vala@cern.ch)
+//
+
+#include "AliRsnAnalysisME.h"
+
+ClassImp(AliRsnAnalysisME)
+
+//_____________________________________________________________________________
+AliRsnAnalysisME::AliRsnAnalysisME(const char *name) :
+ AliRsnVAnalysisTaskME(name),
+ fRsnAnalysisManager()
+{
+//
+// Default constructor
+//
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+AliRsnAnalysisME::AliRsnAnalysisME(const AliRsnAnalysisME& copy) : AliRsnVAnalysisTaskME(copy),
+ fRsnAnalysisManager(copy.fRsnAnalysisManager)
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisME::RsnUserCreateOutputObjects()
+{
+ AliLog::SetClassDebugLevel(GetName(), fLogType);
+ AliDebug(AliLog::kDebug+2,"<-");
+// AliRsnVAnalysisTaskME::UserCreateOutputObjects();
+
+// fRsnEvent = new AliRsnEvent();
+// fRsnEvent->SetName("rsnEvents");
+// fRsnEvent->Init();
+// AddAODBranch("AliRsnEvent", &fRsnEvent);
+
+// fOutList = new TList();
+//
+// fOutList->Add(fTaskInfo.GenerateInfoList());
+
+ fOutList->Add(fRsnAnalysisManager.InitAllPairMgrs());
+// fRsnAnalysisManager.Print();
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+void AliRsnAnalysisME::RsnUserExec(Option_t* )
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ if (fESDEvent) {
+ AliDebug(AliLog::kDebug+1,Form("fESDEvent if %p",fESDEvent));
+ AliDebug(AliLog::kDebug,Form("ESD tracks %d",fESDEvent->GetNumberOfTracks()));
+ }
+ if (fMCEvent) {
+ AliDebug(AliLog::kDebug+1,Form("fMCEvent if %p",fMCEvent));
+ AliDebug(AliLog::kDebug,Form("MC tracks %d",fMCEvent->GetNumberOfTracks()));
+ }
+ if (fAODEvent) {
+ AliDebug(AliLog::kDebug+1,Form("fAODEvent if %p",fAODEvent));
+ AliDebug(AliLog::kDebug,Form("AOD tracks %d",fAODEvent->GetNumberOfTracks()));
+ }
+
+ AliAODEvent* aod1 = (AliAODEvent*)GetEvent(0);
+ AliAODEvent* aod2 = (AliAODEvent*)GetEvent(1);
+
+ // assign events
+ fEvent.SetRef(aod1);
+ fEventMix.SetRef(aod2);
+ if (fEvent.GetMultiplicity() < 2) return;
+ if (fEventMix.GetMultiplicity() < 2) return;
+
+ // sort tracks w.r. to PID
+ fPIDIndex.ResetAll(fEvent.GetMultiplicity());
+ fPIDIndex.SetPriorProbability(fPrior);
+ fPIDIndex.FillFromEvent(&fEvent, fESDCuts);
+ fPIDIndex.SetCorrectIndexSize();
+
+ fPIDIndexMix.ResetAll(fEventMix.GetMultiplicity());
+ fPIDIndexMix.SetPriorProbability(fPrior);
+ fPIDIndexMix.FillFromEvent(&fEventMix, fESDCuts);
+ fPIDIndexMix.SetCorrectIndexSize();
+
+ fRsnAnalysisManager.ProcessAllPairMgrs(&fPIDIndex, &fEvent, &fPIDIndexMix, &fEventMix);
+
+ AliDebug(AliLog::kDebug,Form("AOD tracks %d",aod1->GetNumberOfTracks()));
+ AliDebug(AliLog::kDebug,Form("AOD tracks %d",aod2->GetNumberOfTracks()));
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+
+//_____________________________________________________________________________
+void AliRsnAnalysisME::RsnTerminate(Option_t* )
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+AliRsnAnalysisManager* AliRsnAnalysisME::GetAnalysisManager(TString name)
+{
+ if (!name.IsNull()) {
+ SetAnalysisManagerName(name.Data());
+ }
+ return &fRsnAnalysisManager;
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisME::SetPriorProbability(AliPID::EParticleType type, Double_t p)
+{
+ //
+ // Sets the prior probability for Realistic PID, for a
+ // given particle species.
+ //
+
+ if (type >= 0 && type < (Int_t)AliPID::kSPECIES) {
+ fPrior[type] = p;
+ }
+
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisME::DumpPriors()
+{
+ //
+ // Print all prior probabilities
+ //
+
+ Int_t i;
+ for (i = 0; i < AliPID::kSPECIES; i++) {
+ AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i]));
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisME::GetPriorProbability(Double_t *out)
+{
+
+ Int_t i;
+ for (i=0;i<AliPID::kSPECIES;i++) {
+ out[i] = fPrior[i];
+ }
+}
--- /dev/null
+//\r
+// Class AliRsnAnalysisME\r
+//\r
+// Virtual Class derivated from AliRsnVAnalysisTaskME which will be base class\r
+// for all RSN SE tasks\r
+//\r
+// authors: Martin Vala (martin.vala@cern.ch)\r
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)\r
+//\r
+#ifndef AliRsnAnalysisME_H\r
+#define AliRsnAnalysisME_H\r
+\r
+#include "AliRsnVAnalysisTaskME.h"\r
+#include "AliRsnAnalysisManager.h"\r
+\r
+class AliRsnAnalysisME : public AliRsnVAnalysisTaskME\r
+{\r
+\r
+ public:\r
+ AliRsnAnalysisME(const char *name = "AliRsnAnalysisME");\r
+ AliRsnAnalysisME(const AliRsnAnalysisME& copy);\r
+\r
+ // Implement this\r
+ virtual void RsnUserCreateOutputObjects();\r
+ virtual void RsnUserExec(Option_t*);\r
+ virtual void RsnTerminate(Option_t*);\r
+\r
+ AliRsnAnalysisManager *GetAnalysisManager(TString name="");\r
+ void SetAnalysisManagerName(const char*name) { fRsnAnalysisManager.SetName(name);};\r
+\r
+ // Prior probs\r
+ void SetPriorProbability(AliPID::EParticleType type, Double_t p);\r
+ void DumpPriors();\r
+ void GetPriorProbability(Double_t *out);\r
+\r
+ // ESD cuts\r
+ void SetESDtrackCuts(AliESDtrackCuts *cuts) {fESDCuts = cuts;}\r
+\r
+ private:\r
+\r
+ AliRsnAnalysisManager fRsnAnalysisManager; // analysis main engine\r
+ AliRsnPIDIndex fPIDIndex; // utility --> PID sorter\r
+ AliRsnEvent fEvent; // utility --> event interface\r
+ AliRsnPIDIndex fPIDIndexMix; // utility --> PID sorter (mixed event)\r
+ AliRsnEvent fEventMix; // utility --> event interface (mixed event)\r
+\r
+ AliESDtrackCuts *fESDCuts; // ESD track cuts\r
+ Double_t fPrior[AliPID::kSPECIES]; // prior probabilities\r
+\r
+ ClassDef(AliRsnAnalysisME, 1)\r
+};\r
+\r
+#endif\r
--- /dev/null
+//
+// Class AliRsnAnalysisManager
+//
+// This is the uppermost level of analysis objects collection.
+// It contains a list of pair managers, which all will process
+// a pool of events passed to this object, and fill their histograms.
+//
+// The utility of this object is to define a unique implementation
+// of the whole processing, which can then be included in the different
+// designs of AnalysisTask provided for SE and ME analysis.
+//
+// The base architecture is still AliRsnVManager, but in this case
+// all the objects in the list will be AliRsnPairManager's.
+//
+// author : M. Vala [martin.vala@cern.ch]
+// revised by : A. Pulvirenti [alberto.pulvirenti@ct.infn.it]
+//
+
+#include "AliLog.h"
+
+#include "AliRsnAnalysisManager.h"
+
+ClassImp(AliRsnAnalysisManager)
+
+//_____________________________________________________________________________
+AliRsnAnalysisManager::AliRsnAnalysisManager(const char*name) :
+ AliRsnVManager(name)
+{
+//
+// Default constructor
+//
+
+ AliDebug(AliLog::kDebug+2, "<-");
+ AliDebug(AliLog::kDebug+2, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisManager::Add(AliRsnPairManager *pair)
+{
+//
+// Adds a new pair manager to the list.
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ if (!pair) {
+ AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair));
+ return;
+ }
+
+ AliDebug(AliLog::kDebug+1, Form("Adding %s [%d]...", pair->GetName(), fArray.GetEntries()));
+ fArray.Add((AliRsnPairManager*)pair);
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisManager::Print(Option_t* /*dummy*/) const
+{
+//
+// Overload of the TObject::Print() method
+//
+
+ AliInfo(Form("\t======== Analysis Manager %s ========", GetName()));
+ PrintArray();
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisManager::PrintArray() const
+{
+//
+// Calls the "Print" method of all included pair managers
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ AliRsnPairManager *mgr = 0;
+ TObjArrayIter next(&fArray);
+ while ((mgr = (AliRsnPairManager*)next())) mgr->Print();
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+TList* AliRsnAnalysisManager::InitAllPairMgrs()
+{
+//
+// Initialize all pair managers, and put all the TList of histograms
+// generated by each one into a unique final output TList
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ TList *list = new TList();
+ list->SetName(GetName());
+ list->SetOwner();
+
+ AliRsnPairManager *pairMgr = 0;
+ TObjArrayIter next(&fArray);
+ Int_t i = 0;
+ while ((pairMgr = (AliRsnPairManager*)next())) {
+ AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the AnalysisManager(%s) [%d] ...", pairMgr->GetName(), i++));
+ list->Add(pairMgr->InitAllPairs());
+ }
+ AliDebug(AliLog::kDebug+2, "->");
+ return list;
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisManager::ProcessAllPairMgrs
+(AliRsnPIDIndex *pidIndexes1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndexes2, AliRsnEvent *ev2)
+{
+//
+// Process one or two events for all pair managers.
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ AliRsnPairManager *pairMgr = 0;
+ TObjArrayIter next(&fArray);
+
+ Int_t i = 0;
+ while ((pairMgr = (AliRsnPairManager*)next())) {
+ AliDebug(AliLog::kDebug+1, Form("ProcessAllPairMgrs of the AnalysisManager(%s) [%d] ...", pairMgr->GetName(), i++));
+ pairMgr->ProcessAllPairs(pidIndexes1, ev1, pidIndexes2, ev2);
+ }
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisManager::AddConfig
+(TString config,TString prefix,TString functionName)
+{
+//
+// Adds a new AliRsnPair generated according to a configuration macro
+// which is called interactively and executed from a ROOT session
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ gROOT->LoadMacro(config.Data());
+
+ config.ReplaceAll(".C","");
+ prefix.ReplaceAll("_","-");
+
+ if (!functionName.IsNull()) config = functionName;
+
+ AliRsnPairManager *pairMgr = (AliRsnPairManager*)gROOT->ProcessLine(Form("%s(\"%s\");", config.Data(), prefix.Data()));
+ Add(pairMgr);
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
--- /dev/null
+//
+// Class AliRsnAnalysisManager
+//
+// This is the uppermost level of analysis objects collection.
+// It contains a list of pair managers, which all will process
+// a pool of events passed to this object, and fill their histograms.
+//
+// The utility of this object is to define a unique implementation
+// of the whole processing, which can then be included in the different
+// designs of AnalysisTask provided for SE and ME analysis.
+//
+// The base architecture is still AliRsnVManager, but in this case
+// all the objects in the list will be AliRsnPairManager's.
+//
+// author : M. Vala [martin.vala@cern.ch]
+// revised by : A. Pulvirenti [alberto.pulvirenti@ct.infn.it]
+//
+
+#ifndef AliRsnAnalysisManager_H
+#define AliRsnAnalysisManager_H
+
+#include <TROOT.h>
+
+#include "AliRsnVManager.h"
+#include "AliRsnPairManager.h"
+
+class AliRsnAnalysisManager : public AliRsnVManager
+{
+ public:
+
+ AliRsnAnalysisManager(const char*name = "defaultAnalysisMgr");
+
+ virtual void Add(AliRsnPairManager *pair);
+ virtual void AddConfig(TString config, TString prefix, TString functionName = "");
+ virtual void PrintArray() const;
+ virtual void Print(Option_t *option = "") const;
+
+ TList* InitAllPairMgrs();
+ void ProcessAllPairMgrs(AliRsnPIDIndex *pidIndexes1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndexes2 = 0, AliRsnEvent *ev2 = 0);
+
+ private:
+
+ ClassDef(AliRsnAnalysisManager, 1)
+};
+
+#endif
//
-// Class AliRsnAnalysisSE
+// Class AliRsnAnalysisME
//
// TODO
//
-// authors: Martin Vala (martin.vala@cern.ch)
-// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+// authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+// Martin Vala (martin.vala@cern.ch)
//
-#include <Riostream.h>
-
-#include <TSystem.h>
-#include <TFile.h>
-#include <TFolder.h>
-#include <TROOT.h>
-
-#include "AliLog.h"
-
-#include "AliAnalysisManager.h"
-#include "AliRsnPairMgr.h"
-#include "AliRsnEventBuffer.h"
-
-#include "AliMCEventHandler.h"
-#include "AliESDEvent.h"
-
#include "AliRsnAnalysisSE.h"
ClassImp(AliRsnAnalysisSE)
-//________________________________________________________________________
-AliRsnAnalysisSE::AliRsnAnalysisSE(const char * name, Int_t bufferSize) :
- AliRsnAnalysisTaskSEBase(name),
- fDoesMixing(kFALSE),
- fMixingNum(0),
- fMixingCut(0x0),
- fPairMgrs(0),
- fOutList(0x0),
- fBuffer(0x0),
- fBufferSize(bufferSize)
+//_____________________________________________________________________________
+AliRsnAnalysisSE::AliRsnAnalysisSE(const char *name) :
+ AliRsnVAnalysisTaskSE(name),
+ fRsnAnalysisManager(),
+ fESDCuts(0)
{
//
// Default constructor
//
-
- InitIOVars();
- DefineOutput(1, TList::Class());
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
}
-//________________________________________________________________________
-AliRsnAnalysisSE::~AliRsnAnalysisSE()
+AliRsnAnalysisSE::AliRsnAnalysisSE(const AliRsnAnalysisSE& copy) : AliRsnVAnalysisTaskSE(copy),
+ fRsnAnalysisManager(copy.fRsnAnalysisManager)
{
-//
-// Destructor
-//
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
}
-//________________________________________________________________________
-void AliRsnAnalysisSE::InitIOVars()
+//_____________________________________________________________________________
+void AliRsnAnalysisSE::RsnUserCreateOutputObjects()
{
-//
-// Init input output values
-//
+ AliDebug(AliLog::kDebug+2,"<-");
- AliRsnAnalysisTaskSEBase::InitIOVars();
+ fOutList->Add(fRsnAnalysisManager.InitAllPairMgrs());
- fBuffer = 0;
- fOutList = 0;
+ AliDebug(AliLog::kDebug+2,"->");
}
-//________________________________________________________________________
-void AliRsnAnalysisSE::UserCreateOutputObjects()
+void AliRsnAnalysisSE::RsnUserExec(Option_t* )
{
-//
-// UserCreateOutputObjects() of AliAnalysisTaskSE
-//
-
- OpenFile(0);
- fOutList = new TList();
- fOutList->SetOwner();
- AliRsnPair *def=0;
- AliRsnPairMgr *mgr=0;
- //TList *listTmp;
- fDoesMixing = kFALSE;
- for (Int_t iMgr=0 ;iMgr< fPairMgrs.GetEntries();iMgr++)
- {
- mgr = (AliRsnPairMgr *) fPairMgrs.At(iMgr);
- if (!mgr) continue;
- //listTmp = new TList();
- //listTmp->SetName(mgr->GetName());
- for (Int_t i=0;i< mgr->GetPairs()->GetEntriesFast();i++)
- {
- def = (AliRsnPair *) mgr->GetPairs()->At(i);
- if (def)
- {
- //listTmp->Add(def->GenerateHistograms(mgr->GetName()));
- def->GenerateHistograms(mgr->GetName(), fOutList);
- if (def->IsMixed()) fDoesMixing = kTRUE;
- }
- }
- //fOutList->Add(listTmp);
+ AliDebug(AliLog::kDebug+2,"<-");
+ if (fESDEvent) {
+ AliDebug(AliLog::kDebug+1,Form("fESDEvent if %p",fESDEvent));
+ AliDebug(AliLog::kDebug,Form("ESD tracks %d",fESDEvent->GetNumberOfTracks()));
+ }
+ if (fMCEvent) {
+ AliDebug(AliLog::kDebug+1,Form("fMCEvent if %p",fMCEvent));
+ AliDebug(AliLog::kDebug,Form("MC tracks %d",fMCEvent->GetNumberOfTracks()));
+ }
+ if (fAODEventIn) {
+ AliDebug(AliLog::kDebug+1,Form("fAODEventIn if %p",fAODEventIn));
+ AliDebug(AliLog::kDebug,Form("AOD(in) tracks %d",fAODEventIn->GetNumberOfTracks()));
}
- TH1I *hUsed = new TH1I("hRsnUsed", "skipped and used events in this analysis", 2, 0, 2);
- fOutList->Add(hUsed);
-
- fBuffer = new AliRsnEventBuffer(fBufferSize);
-}
-
-//________________________________________________________________________
-void AliRsnAnalysisSE::UserExec(Option_t *)
-{
-//
-// UserExec() of AliAnalysisTaskSE
-//
-
- static UInt_t eventID = 0;
+ if (fAODEventOut) {
+ AliDebug(AliLog::kDebug+1,Form("fAODEventOut if %p",fAODEventOut));
+ AliDebug(AliLog::kDebug,Form("AOD(out) tracks %d",fAODEventOut->GetNumberOfTracks()));
+ }
- if (fEntry++ % 100 == 0) cout << "[" << GetName() << "] : processing entry " << fEntry-1 << endl;
+ // assign event
+ if (fAODEventOut)
+ fEvent.SetRef(fAODEventOut);
+ else if (fESDEvent)
+ fEvent.SetRef(fESDEvent, fMCEvent);
+ else
+ return;
+ if (fEvent.GetMultiplicity()<2) return;
- TH1I *h = (TH1I*)fOutList->FindObject("hRsnUsed");
+ // sort tracks w.r. to PID
+ fPIDIndex.ResetAll(fEvent.GetMultiplicity());
+ fPIDIndex.SetPriorProbability(fPrior);
+ fPIDIndex.FillFromEvent(&fEvent, fESDCuts);
+ fPIDIndex.SetCorrectIndexSize();
- AliRsnEvent *curEvent = GetRsnEventFromInputType();
- if (curEvent) {
- curEvent->SetUniqueID(eventID++);
- ProcessEventAnalysis(curEvent);
- PostEventProcess();
- h->Fill(1);
- }
- else {
- h->Fill(0);
- }
+ fRsnAnalysisManager.ProcessAllPairMgrs(&fPIDIndex, &fEvent);
- PostData(1, fOutList);
+ AliDebug(AliLog::kDebug+2,"->");
}
-//________________________________________________________________________
-void AliRsnAnalysisSE::Terminate(Option_t *)
-{
-//
-// Terminate() of AliAnalysisTask
-//
- fOutList = dynamic_cast<TList*>(GetOutputData(1));
- if (!fOutList) { AliError("At end of analysis, output list is NULL"); return; }
- //fOutList->Print();
+//_____________________________________________________________________________
+void AliRsnAnalysisSE::RsnTerminate(Option_t* )
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
}
-//________________________________________________________________________
-void AliRsnAnalysisSE::ProcessEventAnalysis(AliRsnEvent *curEvent)
+//_____________________________________________________________________________
+AliRsnAnalysisManager* AliRsnAnalysisSE::GetAnalysisManager(TString name)
{
-//
-// Process of one event
-//
-
- // Adds event to Event Buffer
- fBuffer->AddEvent(curEvent);
- Int_t index = fBuffer->GetEventsBufferIndex();
-
- Int_t nmatches;
- TArrayI matched(0);
- if (fDoesMixing) matched = FindGoodMatches(index, nmatches);
-
- // loop over all Pair managers
- AliRsnPairMgr *mgr=0;
- for (Int_t iMgr=0 ;iMgr< fPairMgrs.GetEntries();iMgr++)
- {
- mgr = (AliRsnPairMgr *) fPairMgrs.At(iMgr);
- AliRsnPair *pair=0;
- for (Int_t i=0;i< mgr->GetPairs()->GetEntriesFast();i++)
- {
- pair = (AliRsnPair *) mgr->GetPairs()->At(i);
- if (!pair->IsMixed()) {
- pair->ProcessPair(curEvent, 0);
- }
- else {
- Int_t j, iev;
- for (j = 0; j < matched.GetSize(); j++) {
- iev = matched[j];
- if (iev < 0) continue;
- AliRsnEvent *evmatch = fBuffer->GetEvent(iev);
- pair->ProcessPair(curEvent, evmatch);
- if (!pair->IsPairEqual()) pair->ProcessPair(evmatch, curEvent);
- }
- }
- }
+ if (!name.IsNull()) {
+ SetAnalysisManagerName(name.Data());
}
+
+ return &fRsnAnalysisManager;
}
-//________________________________________________________________________
-void AliRsnAnalysisSE::PostEventProcess(const Short_t & index)
-{
-//
-// Post process of one event
-//
- if (fInputType[index] != kRSN) return;
+//_____________________________________________________________________________
+void AliRsnAnalysisSE::SetPriorProbability(AliPID::EParticleType type, Double_t p)
+{
+ //
+ // Sets the prior probability for Realistic PID, for a
+ // given particle species.
+ //
- if (fBuffer->GetDeleteBufferWhenReset() == kFALSE) {
- fRSN[index] = (AliRsnEvent*) fBuffer->GetNextEvent();
- SetBranchAddress(0 , "rsnEvents", &fRSN[index]);
+ if (type >= 0 && type < (Int_t)AliPID::kSPECIES) {
+ fPrior[type] = p;
}
-}
-//________________________________________________________________________
-void AliRsnAnalysisSE::AddPairMgr(AliRsnPairMgr * pairmgr)
-{
- fPairMgrs.Add(pairmgr);
}
-//________________________________________________________________________
-void AliRsnAnalysisSE::AddPairMgrFromConfig(TString configfile,TString analysisName)
+//_____________________________________________________________________________
+void AliRsnAnalysisSE::DumpPriors()
{
- gROOT->LoadMacro(configfile.Data());
-
- configfile.ReplaceAll(".C","");
+ //
+ // Print all prior probabilities
+ //
- analysisName.ReplaceAll("_","-");
-
- AliRsnPairMgr *mgrRsn = (AliRsnPairMgr *) gROOT->ProcessLine(Form("%s(\"%s\");", configfile.Data(),analysisName.Data()));
- if (!mgrRsn) return;
-
- fPairMgrs.Add(mgrRsn);
+ Int_t i;
+ for (i = 0; i < AliPID::kSPECIES; i++) {
+ AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i]));
+ }
}
-//________________________________________________________________________
-TArrayI AliRsnAnalysisSE::FindGoodMatches(Int_t iRef, Int_t &foundMatches)
+//_____________________________________________________________________________
+void AliRsnAnalysisSE::GetPriorProbability(Double_t *out)
{
- // initialize the output array to the size of required mixed events
- // and initialize all members to -1
- Int_t i;
- TArrayI matched(fMixingNum);
- for (i = 0; i < fMixingNum; i++) matched[i] = -1;
- foundMatches = 0;
- // starts from the position behind the reference index
- // and goes backward; if it reaches the value 0, stops
- AliRsnEvent *refEvent = fBuffer->GetEvent(iRef);
- if (!refEvent) return matched;
- AliRsnEvent *matchEvent = 0x0;
- Int_t checkIndex;
- for (checkIndex = iRef - 1; ; checkIndex--) {
- if (checkIndex < 0) checkIndex = fBuffer->GetEventsBufferSize() - 1;
- if (checkIndex == iRef) break;
- matchEvent = fBuffer->GetEvent(checkIndex);
- if (!matchEvent) continue;
- if (fMixingCut) {
- if (!fMixingCut->IsSelected(AliRsnCut::kMixEvent, refEvent, matchEvent)) continue;
- }
- // assign to current array slot the matched event
- // and increment current slot and stops if it exceeds array size
- matched[foundMatches++] = checkIndex;
- if (foundMatches >= fMixingNum) break;
+ Int_t i;
+ for (i=0;i<AliPID::kSPECIES;i++) {
+ out[i] = fPrior[i];
}
-
- // returns the current index value,
- // which is also the number of matched events found
- return matched;
}
-//
-// Class AliRsnAnalysisSE
-//
-// TODO
-//
-// authors: Martin Vala (martin.vala@cern.ch)
-// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
-//
-#ifndef ALIRSNANALYSISAT_H
-#define ALIRSNANALYSISAT_H
-
-#include <TH1.h>
-#include <TArrayI.h>
-
-#include "AliRsnEventBuffer.h"
-#include "AliRsnPair.h"
-#include "AliRsnAnalysisTaskSEBase.h"
-
-class AliRsnEvent;
-
-class AliRsnAnalysisSE : public AliRsnAnalysisTaskSEBase
-{
- public:
- AliRsnAnalysisSE(const char *name = "AliRsnAnalysisSE", Int_t bufferSize = 1000);
- ~AliRsnAnalysisSE();
-
- virtual void InitIOVars();
- virtual void UserCreateOutputObjects();
- virtual void UserExec(Option_t *option);
- virtual void Terminate(Option_t *);
-
- void AddPairMgr(AliRsnPairMgr *pairmgr);
- void AddPairMgrFromConfig(TString configfile, TString analysisName = "default");
-
- void SetBufferSize(const Int_t size) {fBufferSize = size;}
- Int_t GetBufferSize() const {return fBufferSize;}
-
- TArrayI FindGoodMatches(Int_t iRef, Int_t &found);
- void SetMixingNum(Int_t i) {fMixingNum = i;}
- void SetMixingCut(AliRsnCutSet *cut) {fMixingCut = cut;}
-
-
- private:
-
- AliRsnAnalysisSE(const AliRsnAnalysisSE& copy) :
- AliRsnAnalysisTaskSEBase(copy),
- fDoesMixing(kFALSE),fMixingNum(0),fMixingCut(0x0),fPairMgrs(0),
- fOutList(0x0),fBuffer(0x0),fBufferSize(0) {}
- AliRsnAnalysisSE& operator= (const AliRsnAnalysisSE&) {return *this;}
-
- void ProcessEventAnalysis(AliRsnEvent *curEvent);
- void PostEventProcess(const Short_t &index = 0);
-
- Bool_t fDoesMixing; // flag set to kTRUE if the task contains pairs for mixing
- Int_t fMixingNum; // number of events to mix
- AliRsnCutSet *fMixingCut; // mixing cut
- TObjArray fPairMgrs; // collections of pairs
- TList *fOutList; // List of output
- AliRsnEventBuffer *fBuffer; // event buffer
- Int_t fBufferSize; // number of events in buffer
-
- ClassDef(AliRsnAnalysisSE, 1)
-};
-
-#endif
+//\r
+// Class AliRsnAnalysisSE\r
+//\r
+// Virtual Class derivated from AliRsnVAnalysisTaskSE which will be base class\r
+// for all RSN SE tasks\r
+//\r
+// authors: Martin Vala (martin.vala@cern.ch)\r
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)\r
+//\r
+#ifndef AliRsnAnalysisSE_H\r
+#define AliRsnAnalysisSE_H\r
+\r
+#include "AliPID.h"\r
+#include "AliRsnVAnalysisTaskSE.h"\r
+#include "AliRsnAnalysisManager.h"\r
+#include "AliRsnPIDIndex.h"\r
+\r
+class AliRsnAnalysisSE : public AliRsnVAnalysisTaskSE\r
+{\r
+\r
+public:\r
+ AliRsnAnalysisSE(const char *name = "AliRsnAnalysisSE");\r
+ AliRsnAnalysisSE(const AliRsnAnalysisSE& copy);\r
+\r
+ // Implement this\r
+ virtual void RsnUserCreateOutputObjects();\r
+ virtual void RsnUserExec(Option_t*);\r
+ virtual void RsnTerminate(Option_t*);\r
+\r
+ AliRsnAnalysisManager *GetAnalysisManager(TString name = "");\r
+ void SetAnalysisManagerName(const char*name) {fRsnAnalysisManager.SetName(name);};\r
+\r
+ // Prior probs\r
+ void SetPriorProbability(AliPID::EParticleType type, Double_t p);\r
+ void DumpPriors();\r
+ void GetPriorProbability(Double_t *out);\r
+\r
+ // ESD cuts\r
+ void SetESDtrackCuts(AliESDtrackCuts *cuts) {fESDCuts = cuts;}\r
+\r
+private:\r
+\r
+ AliRsnAnalysisManager fRsnAnalysisManager; // analysis main engine\r
+ AliRsnPIDIndex fPIDIndex; // utility --> PID sorter\r
+ AliRsnEvent fEvent; // utility --> event interface\r
+\r
+ AliESDtrackCuts *fESDCuts; // ESD track cuts\r
+ Double_t fPrior[AliPID::kSPECIES]; // prior probabilities\r
+\r
+ ClassDef(AliRsnAnalysisSE, 1)\r
+};\r
+\r
+#endif\r
// authors: Martin Vala (martin.vala@cern.ch)
// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
//
-#include "Riostream.h"
#include "AliLog.h"
#include "AliRsnDaughter.h"
-#include "AliRsnMCInfo.h"
#include "AliRsnPairParticle.h"
-#include "AliRsnPairDef.h"
#include "AliRsnEvent.h"
-#include "AliRsnCut.h"
-const Double_t AliRsnCut::fgkDSmallNumber = 1e-100;
-const Double_t AliRsnCut::fgkDBigNumber = 1e10;
-const Int_t AliRsnCut::fgkIBigNumber = 32767;
+#include "AliRsnCut.h"
ClassImp(AliRsnCut)
-//________________________________________________________________________________________________________________
+//_________________________________________________________________________________________________
AliRsnCut::AliRsnCut() :
- TNamed(),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(0),
- fUIMax(2 * (UInt_t) fgkIBigNumber),
- fULMin(0),
- fULMax(2 * (ULong_t) fgkIBigNumber),
- fType(kLastCutType),
- fVarType(kDouble_t)
+ TNamed(),
+ fVarType(kInt),
+ fMinI(0),
+ fMaxI(0),
+ fMinU(0),
+ fMaxU(0),
+ fMinD(0.0),
+ fMaxD(0.0),
+ fCutValueI(0),
+ fCutValueU(0),
+ fCutValueD(0.0),
+ fCutResult(kTRUE)
{
//
-// Constructor
+// Default constructor.
//
}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char *name, const char *title, EType type) :
- TNamed(name,title),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(0),
- fUIMax(2 * (UInt_t) fgkIBigNumber),
- fULMin(0),
- fULMax(2 * (ULong_t) fgkIBigNumber),
- fType(type),
- fVarType(kDouble_t)
+//_________________________________________________________________________________________________
+AliRsnCut::AliRsnCut
+(const char *name, Int_t min, Int_t max) :
+ TNamed(name, ""),
+ fVarType(kInt),
+ fMinI(min),
+ fMaxI(max),
+ fMinU(0),
+ fMaxU(0),
+ fMinD(0.0),
+ fMaxD(0.0),
+ fCutValueI(0),
+ fCutValueU(0),
+ fCutValueD(0.0),
+ fCutResult(kTRUE)
{
//
-// Constructor with arguments but not limits
+// Constructor.
+// If the cut must check values inside a range,
+// both 'value' arguments must be used, and they are, in the order,
+// the minimum and maximum of the allowed range.
+// If the cut must check a value, the second 'value' argument will never be used.
//
}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char *name, const char *title, EType type, Double_t min, Double_t max) :
- TNamed(name,title),
- fDMin(min),
- fDMax(max),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(0),
- fUIMax(2 * (UInt_t) fgkIBigNumber),
- fULMin((ULong_t)min),
- fULMax((ULong_t)max),
- fType(type),
- fVarType(kDouble_t)
+//_________________________________________________________________________________________________
+AliRsnCut::AliRsnCut
+(const char *name, ULong_t min, ULong_t max) :
+ TNamed(name, ""),
+ fVarType(kULong),
+ fMinI(0),
+ fMaxI(0),
+ fMinU(min),
+ fMaxU(max),
+ fMinD(0.0),
+ fMaxD(0.0),
+ fCutValueI(0),
+ fCutValueU(0),
+ fCutValueD(0.0),
+ fCutResult(kTRUE)
{
//
-// Constructor with arguments and limits
+// Constructor.
+// If the cut must check values inside a range,
+// both 'value' arguments must be used, and they are, in the order,
+// the minimum and maximum of the allowed range.
+// If the cut must check a value, the second 'value' argument will never be used.
//
}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, Int_t min, Int_t max) :
- TNamed(name,title),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(min),
- fIMax(max),
- fUIMin(0),
- fUIMax(2 * (UInt_t) fgkIBigNumber),
- fULMin(min),
- fULMax(max),
- fType(type),
- fVarType(kInt_t)
+//_________________________________________________________________________________________________
+AliRsnCut::AliRsnCut
+(const char *name, Double_t min, Double_t max) :
+ TNamed(name, ""),
+ fVarType(kDouble),
+ fMinI(0),
+ fMaxI(0),
+ fMinU(0),
+ fMaxU(0),
+ fMinD(min),
+ fMaxD(max),
+ fCutValueI(0),
+ fCutValueU(0),
+ fCutValueD(0.0),
+ fCutResult(kTRUE)
{
//
-// Constructor with arguments and limits
+// Constructor.
+// If the cut must check values inside a range,
+// both 'value' arguments must be used, and they are, in the order,
+// the minimum and maximum of the allowed range.
+// If the cut must check a value, the second 'value' argument will never be used.
//
}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, UInt_t min, UInt_t max) :
- TNamed(name,title),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(min),
- fUIMax(max),
- fULMin(min),
- fULMax(max),
- fType(type),
- fVarType(kUInt_t)
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::IsSelected(ETarget tgt, AliRsnDaughter *track)
{
//
-// Constructor with arguments and limits
+// Virtual cut-checking method.
+// In base class, these methods compare the argument type
+// with the defined target, in order to detect a mismatch
//
-}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, ULong_t min, ULong_t max) :
- TNamed(name,title),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(min),
- fUIMax(max),
- fULMin(min),
- fULMax(max),
- fType(type),
- fVarType(kUInt_t)
-{
-//
-// Constructor with arguments and limits
-//
-}
-
-//________________________________________________________________________________________________________________
-AliRsnCut::~AliRsnCut()
-{
-//
-// Destructor.
-// Does absolutely nothing.
-//
-}
-
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsBetween(const Double_t &theValue)
-{
-//
-// Interval check.
-// Question: "Is the argument included between fDMin and fDMax?"
-// (not implemented for integer values because usually it is not used with them)
-//
- return ((theValue >= fDMin) && (theValue <= fDMax));
-}
-
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsBetween(const Int_t &theValue)
-{
-//
-// Interval check.
-// Question: "Is the argument included between fDMin and fDMax?"
-// (not implemented for integer values because usually it is not used with them)
-//
- return ((theValue >= fIMin) && (theValue <= fIMax));
-}
-
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue(const Int_t &theValue)
-{
-//
-// Reference check.
-// Question: "Is the argument equal to fIMin?" (fIMax is assumed never used)
-//
- return (theValue == fIMin);
+ return kTRUE;
}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue(const UInt_t &theValue)
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::IsSelected(ETarget tgt, AliRsnPairParticle *pair)
{
//
-// Reference check.
-// Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
+// Virtual cut-checking method.
+// In base class, these methods compare the argument type
+// with the defined target, in order to detect a mismatch
//
- return (theValue == fUIMin);
-}
-
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue(const ULong_t &theValue)
-{
- //
-// Reference check.
-// Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
- //
- return (theValue == fULMin);
-}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue(const Double_t &theValue)
-{
-//
-// Reference check.
-// Question: "Is the argument reasonably close to fDMin?" (fDMax is assumed never used)
-// Here, "reasonably close" means that the difference is smaller than the
-// 'fgkSmallNumber' global static data member of this class
-//
- return (TMath::Abs(theValue - fDMin) < fgkDSmallNumber);
+ return kTRUE;
}
-//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues(EType type, const Double_t &theValue, const Double_t &theValue2)
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::IsSelected(ETarget tgt, AliRsnEvent *event)
{
//
-// (Re)assignment of cut values
+// Virtual cut-checking method.
+// In base class, these methods compare the argument type
+// with the defined target, in order to detect a mismatch
//
- fType = type;
- fDMin = theValue;
- fDMax = theValue2;
-}
-//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues(EType type, const Int_t &theValue, const Int_t &theValue2)
-{
-//
-// (Re)assignment of cut values
-//
- fType = type;
- fIMin = theValue;
- fIMax = theValue2;
+ return kTRUE;
}
-//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues(EType type, const UInt_t &theValue, const UInt_t &theValue2)
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::IsSelected(ETarget tgt, AliRsnEvent *ev1, AliRsnEvent *ev2)
{
//
-// (Re)assignment of cut values
+// Virtual cut-checking method.
+// In base class, these methods compare the argument type
+// with the defined target, in order to detect a mismatch
//
- fType = type;
- fUIMin = theValue;
- fUIMax = theValue2;
-}
-//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues(EType type, const ULong_t &theValue, const ULong_t &theValue2)
-{
- //
-// (Re)assignment of cut values
- //
- fType = type;
- fULMin = theValue;
- fULMax = theValue2;
+ return kTRUE;
}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnDaughter *daughter)
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::OkValue()
{
//
-// Core of the whole class.
-// According to the kind of cut selected in the enumeration,
-// checks the cut taking the right values from the argument.
-// Depending on the second argument type, only some cuts are checked
-// (the ones for that type of object), otherwise kTRUE is returned in order
-// not to act as a cleaning factor for an AND with other cuts.
+// This method is used when the cut consists in comparing the cut value
+// with a reference value to which it must be equal (in case of doubles, 'almost' equal).
+// Then, the cut result is kTRUE if the cut value is equal to this reference value.
//
- AliDebug(AliLog::kDebug, "<-");
- AliRsnMCInfo *mcinfo = daughter->GetMCInfo();
-
- // check type
- if (type != kParticle)
- {
- AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnDaughter)", type, kParticle, daughter->ClassName()));
- return kTRUE;
- }
-
- // utility variables
- AliRsnPID::EType pidType;
- Double_t prob;
- Int_t pdg;
- Bool_t cut;
-
- switch (fType)
- {
- case kMomentum:
- return IsBetween(daughter->P());
- case kTransMomentum:
- return IsBetween(daughter->Pt());
- case kEta:
- return IsBetween(daughter->Eta());
- case kRadialImpactParam:
- return IsBetween(daughter->Dr());
- case kRadialImpactParamMC:
- if (mcinfo) return IsBetween(mcinfo->Dr());
- else return kTRUE;
- case kMomentumMC:
- if (mcinfo) return IsBetween(mcinfo->P());
- else return kTRUE;
- case kTransMomentumMC:
- if (mcinfo) return IsBetween(mcinfo->Pt());
- else return kTRUE;
- case kStatus:
- return daughter->CheckFlag(fUIMin);
- case kChargePos:
- return (daughter->Charge() > 0);
- case kChargeNeg:
- return (daughter->Charge() < 0);
- case kPIDType:
- case kPIDProb:
- pidType = daughter->PIDType(prob);
- if (fType == kPIDType) return MatchesValue((Int_t) pidType);
- if (fType == kPIDProb) return IsBetween(prob);
- case kPIDProbForSpecies:
- cut = IsBetween(daughter->PIDProb()[(AliRsnPID::EType)fIMin]);
- //cout << (AliRsnPID::EType)fIMin << ' ' << daughter->PIDProb()[(AliRsnPID::EType)fIMin] << ' ' << (cut?"OK":"NO") << endl;
- return cut;
- case kAssignedPID:
- pidType = daughter->AssignedPID();
- return MatchesValue((Int_t)pidType);
- case kTruePID:
- pdg = TMath::Abs(mcinfo->PDG());
- cut = MatchesValue(pdg);
- //AliError(Form("PDG = %d -- CUT = %s", pdg, (cut ? "passed" : "not passed")));
- if (mcinfo) return MatchesValue((Int_t) TMath::Abs(mcinfo->PDG()));
- else return kTRUE;
- case kEtaMC:
- if (mcinfo) return IsBetween(mcinfo->Eta());
- else return kTRUE;
- case kIsPrimary:
- if (mcinfo) return (mcinfo->Mother() < 0);
- else return kTRUE;
- case kIsKinkMother:
- return (!daughter->IsKink() || daughter->IsKinkMother());
- case kIsKinkDaughter:
- return daughter->IsKinkDaughter();
- case kNSigma:
- return IsBetween(daughter->NSigmaToVertex());
- /*
- case kEsdNSigmaCalculate:
- return IsBetween (daughter->GetESDInfo()->GetNSigmaCalculate());
- */
- default:
- AliWarning("Requested a cut which cannot be applied to a single track");
- return kTRUE;
- }
-
- return kTRUE;
-}
-
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnPairParticle * pair)
-{
- AliDebug(AliLog::kDebug, "<-");
-
- // check type
- if (type != kPair)
- {
- AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnPairParticle)", type, kPair, pair->ClassName()));
- return kTRUE;
- }
-
- switch (fType)
- {
- case kMomentum:
- return IsBetween(pair->GetP());
- case kTransMomentum:
- return IsBetween(pair->GetPt());
- case kEta:
- return IsBetween(pair->GetEta());
- case kEtaMC:
- return IsBetween(pair->GetEtaMC());
- case kMomentumMC:
- return IsBetween(pair->GetPMC());
- case kTransMomentumMC:
- return IsBetween(pair->GetPtMC());
- case kIsLabelEqual:
- return pair->IsLabelEqual();
- case kIsTruePair:
- return pair->IsTruePair(fIMin);
- default:
- AliWarning("Requested a cut which cannot be applied to a pair");
- return kTRUE;
- }
-
- return kTRUE;
-}
-
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * event)
-{
- AliDebug(AliLog::kDebug, "<-");
-
- // check type
- if (type != kEvent)
- {
- AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnEvent)", type, kEvent, event->ClassName()));
- return kTRUE;
- }
- switch (fType)
+ switch (fVarType)
{
- case kTrueMultiplicity:
- return IsBetween((Int_t) event->GetTrueMultiplicity());
- case kMultiplicity:
- return IsBetween((Int_t) event->GetMultiplicity());
- case kVz:
- return IsBetween((Double_t)event->GetPrimaryVertexZ());
+ case kInt:
+ // eval result
+ fCutResult = (fCutValueI == fMinI);
+ // print debug message
+ AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
+ AliDebug(AliLog::kDebug + 3, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 3, Form("Checked value: %d", fCutValueI));
+ AliDebug(AliLog::kDebug + 3, Form("Cut value : %d", fMinI));
+ AliDebug(AliLog::kDebug + 3, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
+ break;
+ case kULong:
+ // eval result
+ fCutResult = (fCutValueU == fMinU);
+ // print debug message
+ AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
+ AliDebug(AliLog::kDebug + 3, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 3, Form("Checked value: %d", fCutValueU));
+ AliDebug(AliLog::kDebug + 3, Form("Cut value : %d", fMinU));
+ AliDebug(AliLog::kDebug + 3, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
+ break;
+ case kDouble:
+ // eval result
+ fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
+ // print debug message
+ AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
+ AliDebug(AliLog::kDebug + 3, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 3, Form("Checked value: %f", fCutValueD));
+ AliDebug(AliLog::kDebug + 3, Form("Cut value : %f", fMinD));
+ AliDebug(AliLog::kDebug + 3, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
+ break;
default:
- AliWarning("Requested a cut which cannot be applied to an event");
- return kTRUE;
+ AliError(Form("fVarType = %d --> not allowed", fVarType));
+ return kFALSE;
}
- return kTRUE;
+ return fCutResult;
}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * ev1, AliRsnEvent * ev2)
+//_________________________________________________________________________________________________
+Bool_t AliRsnCut::OkRange()
{
- AliDebug(AliLog::kDebug, "<-");
-
- // check type
- if (type != kMixEvent)
- {
- AliWarning(Form("Mismatch: type = %d (expected %d)", type, kMixEvent));
- return kTRUE;
- }
-
- Double_t valueD, mult1, mult2;
- Int_t valueI;
+//
+// This method is used when the cut consists in an allowed range
+// where the cut value must be included to pass the cut.
+// Then, the cut result is kTRUE if the cut value is inside this range.
+//
- switch (fType)
+ switch (fVarType)
{
- case kMultiplicityDifference:
- valueI = TMath::Abs(ev1->GetTrueMultiplicity() - ev2->GetTrueMultiplicity());
- return IsBetween((Int_t)valueI);
- case kMultiplicityRatio:
- mult1 = (Double_t)ev1->GetMultiplicity();
- mult2 = (Double_t)ev2->GetMultiplicity();
- if (mult1 == 0.0 && mult2 == 0.0) return kTRUE;
- valueD = 100.0 * TMath::Abs(mult1 - mult2) / TMath::Max(mult1, mult2); // in %
- return IsBetween((Double_t)valueD);
- case kVzDifference:
- valueD = TMath::Abs(ev1->GetVz() - ev2->GetVz());
- return IsBetween((Double_t)valueD);
- case kPhiMeanDifference:
- valueD = TMath::Abs(ev1->GetPhiMean() - ev2->GetPhiMean());
- if (valueD > 180.0) valueD = 360.0 - valueD;
- return IsBetween((Double_t)valueD);
+ case kInt:
+ // eval result
+ fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI));
+ // print debug message
+ AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
+ AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
+ AliDebug(AliLog::kDebug + 2, Form("Cut range : %d , %d", fMinI, fMaxI));
+ AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
+ break;
+ case kULong:
+ // eval result
+ fCutResult = ((fCutValueU >= fMinU) && (fCutValueU <= fMaxU));
+ // print debug message
+ AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
+ AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueU));
+ AliDebug(AliLog::kDebug + 2, Form("Cut range : %d , %d", fMinU, fMaxU));
+ AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
+ break;
+ case kDouble:
+ // eval result
+ fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD));
+ // print debug message
+ AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
+ AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
+ AliDebug(AliLog::kDebug + 2, Form("Cut range : %f , %f", fMinD, fMaxD));
+ AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
+ break;
default:
- AliWarning("Requested a cut which cannot be applied to an event");
- return kTRUE;
+ AliError(Form("fVarType = %d --> not allowed", fVarType));
+ return kFALSE;
}
- return kTRUE;
+ return fCutResult;
}
-//________________________________________________________________________________________________________________
-void AliRsnCut::PrintAllValues()
-{
- AliInfo(Form("fType=%d fVarType=%d",fType,fVarType));
- AliInfo(Form("fDMin=%.2e fDMax=%.2e",fDMin,fDMax));
- AliInfo(Form("fIMin=%d fIMax=%d",fIMin,fIMax));
- AliInfo(Form("fUIMin=%d fUIMax=%d",fUIMin,fUIMax));
- AliInfo(Form("fULMin=%d fULMax=%d",fULMin,fULMax));
-}
class AliRsnDaughter;
class AliRsnPairParticle;
-class AliRsnPairDef;
class AliRsnEvent;
class AliRsnCut : public TNamed
{
- public:
-
- // available cut types
- // some ones work both for pairs and single tracks
- enum EType {
- kMomentum = 0,
- kTransMomentum,
- kEta,
- kRadialImpactParam,
- kRadialImpactParamMC,
- kMomentumMC,
- kTransMomentumMC,
- kEtaMC,
- kNSigma,
- kNSigmaCalculate,
- kStatus,
- kIsLabelEqual,
- kIsTruePair,
- kIsPrimary,
- kIsKinkDaughter,
- kIsKinkMother,
- kMCTracked,
- kChargePos,
- kChargeNeg,
- kPIDType,
- kPIDProb,
- kPIDProbForSpecies,
- kAssignedPID,
- kTruePID,
- kVz,
- kTrueMultiplicity,
- kMultiplicity,
- kMultiplicityDifference,
- kMultiplicityRatio,
- kPhiMeanDifference,
- kVzDifference,
- kLastCutType
- };
-
- // types of cut variables
- enum EVarType {
- kDouble_t = 0,
- kInt_t,
- kUInt_t
- };
-
- // possible targets for a cut
- enum ETarget {
- kParticle = 0,
- kPair,
- kEvent,
- kMixEvent,
- kLastCutTarget
- };
-
- AliRsnCut();
- AliRsnCut(const char *name, const char *title, EType type);
- AliRsnCut(const char *name, const char *title, EType type, Double_t min, Double_t max = 1e-100);
- AliRsnCut(const char *name, const char *title, EType type, Int_t min, Int_t max = 32767);
- AliRsnCut(const char *name, const char *title, EType type, UInt_t min, UInt_t max = 65534);
- AliRsnCut(const char *name, const char *title, EType type, ULong_t min, ULong_t max = 65534);
-
- ~AliRsnCut();
-
- void SetCutValues(EType type, const Double_t& theValue, const Double_t& theValue2);
- void SetCutValues(EType type, const Int_t& theValue, const Int_t& theValue2);
- void SetCutValues(EType type, const UInt_t& theValue, const UInt_t& theValue2);
- void SetCutValues(EType type, const ULong_t& theValue, const ULong_t& theValue2);
-
- Bool_t IsSelected(ETarget tgt, AliRsnDaughter *daughter);
- Bool_t IsSelected(ETarget tgt, AliRsnPairParticle *pair);
- Bool_t IsSelected(ETarget tgt, AliRsnEvent *event);
- Bool_t IsSelected(ETarget tgt, AliRsnEvent *ev1, AliRsnEvent *ev2);
-
- void PrintAllValues();
-
- Bool_t IsBetween(const Double_t &theValue);
- Bool_t IsBetween(const Int_t &theValue);
- Bool_t MatchesValue(const Int_t &theValue);
- Bool_t MatchesValue(const UInt_t &theValue);
- Bool_t MatchesValue(const ULong_t &theValue);
- Bool_t MatchesValue(const Double_t &theValue);
-
- private:
-
- Double_t fDMin; // min. double value
- Double_t fDMax; // max. double value
- Int_t fIMin; // min. int value
- Int_t fIMax; // max. int value
- UInt_t fUIMin; // min. uint value
- UInt_t fUIMax; // max. uint value
- ULong_t fULMin; // min. ulong value
- ULong_t fULMax; // max. ulong value
-
- EType fType; // cut type
- EVarType fVarType; // variable type
-
- static const Double_t fgkDSmallNumber; // small double value
- static const Double_t fgkDBigNumber; // big double value
- static const Int_t fgkIBigNumber; // big int value
-
- ClassDef(AliRsnCut, 1)
+ public:
+
+ // possible targets for a cut
+ enum ETarget {
+ kParticle = 0,
+ kPair,
+ kEvent,
+ kMixEvent,
+ kLastCutTarget
+ };
+
+ // data type for check
+ enum EVarType {
+ kInt = 0,
+ kULong,
+ kDouble
+ };
+
+ AliRsnCut();
+ AliRsnCut(const char *name, Int_t min, Int_t max = 0);
+ AliRsnCut(const char *name, ULong_t min, ULong_t max = 0);
+ AliRsnCut(const char *name, Double_t min, Double_t max = 0);
+ virtual ~AliRsnCut() { }
+
+ void SetRange(Int_t min, Int_t max) {fMinI = min; fMaxI = max; fVarType = kInt;}
+ void SetRange(ULong_t min, ULong_t max) {fMinU = min; fMaxU = max; fVarType = kULong;}
+ void SetRange(Double_t min, Double_t max) {fMinD = min; fMaxD = max; fVarType = kDouble;}
+
+ void SetValue(Int_t value) {fMinI = value; fVarType = kInt;}
+ void SetValue(ULong_t value) {fMinU = value; fVarType = kULong;}
+ void SetValue(Double_t value) {fMinD = value; fVarType = kDouble;}
+
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnDaughter *daughter);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnPairParticle *pair);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnEvent *event);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnEvent *ev1, AliRsnEvent *ev2);
+
+protected:
+
+ Bool_t OkValue();
+ Bool_t OkRange();
+
+ EVarType fVarType; // type of checked variable
+
+ Int_t fMinI; // lower edge of INT range or ref. value for INT CUT
+ Int_t fMaxI; // upper edge of INT range (not used for value cuts)
+ ULong_t fMinU; // lower edge of ULONG range or ref. value for INT CUT
+ ULong_t fMaxU; // upper edge of ULONG range (not used for value cuts)
+ Double_t fMinD; // lower edge of DOUBLE range or ref. value for INT CUT
+ Double_t fMaxD; // upper edge of DOUBLE range (not used for value cuts)
+
+ Int_t fCutValueI; // cut value
+ ULong_t fCutValueU; // cut value
+ Double_t fCutValueD; // cut value
+ Bool_t fCutResult; // tells if the cut is passed or not
+
+ ClassDef(AliRsnCut, 1)
};
#endif
--- /dev/null
+//
+// Class AliRsnCutBetheBloch
+//
+// General implementation of a single cut strategy, which can be:
+// - a value contained in a given interval [--> IsBetween() ]
+// - a value equal to a given reference [--> MatchesValue()]
+//
+// In all cases, the reference value(s) is (are) given as data members
+// and each kind of cut requires a given value type (Int, UInt, Double),
+// but the cut check procedure is then automatized and chosen thanks to
+// an enumeration of the implemented cut types.
+// At the end, the user (or any other point which uses this object) has
+// to use the method IsSelected() to check if this cut has been passed.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#include "TMath.h"
+
+#include "AliLog.h"
+#include "AliESDtrack.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnCutBetheBloch.h"
+
+ClassImp(AliRsnCutBetheBloch)
+
+//_________________________________________________________________________________________________
+AliRsnCutBetheBloch::AliRsnCutBetheBloch() :
+ AliRsnCut(),
+ fCorrect(kTRUE),
+ fMass(1.0),
+ fMIP(50.0)
+{
+//
+// Default constructor.
+//
+
+ fConst[0] = fConst[1] = fConst[2] = fConst[3] = fConst[4] = 0.0;
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutBetheBloch::AliRsnCutBetheBloch
+(const char *name, Double_t fractionRange, Double_t mass, Double_t mip, Bool_t correct) :
+ AliRsnCut(name, -fractionRange, fractionRange),
+ fCorrect(correct),
+ fMass(mass),
+ fMIP(mip)
+{
+//
+// Main constructor.
+// the cut range is the relative fraction of the value:
+// BB*(1-fraction) < TPC < BB*(1+fraction)
+// which means:
+// -fraction < (TPC - BB)/BB < fraction
+//
+
+ fConst[0] = fConst[1] = fConst[2] = fConst[3] = fConst[4] = 0.0;
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutBetheBloch::AliRsnCutBetheBloch
+(const char *name, Double_t fractionRange, AliPID::EParticleType type, Double_t mip, Bool_t correct) :
+ AliRsnCut(name, -fractionRange, fractionRange),
+ fCorrect(correct),
+ fMass(0.0),
+ fMIP(mip)
+{
+//
+// Main constructor.
+// the cut range is the relative fraction of the value:
+// BB*(1-fraction) < TPC < BB*(1+fraction)
+// which means:
+// -fraction < (TPC - BB)/BB < fraction
+//
+
+ SetMass(type);
+ fConst[0] = fConst[1] = fConst[2] = fConst[3] = fConst[4] = 0.0;
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnCutBetheBloch::BetheBloch(AliRsnDaughter *track)
+{
+//
+// Computes the theoretical dE/dx according to
+// a given mass hypothesis, from which betaGamma is computed
+//
+// This is the empirical ALEPH parameterization of the Bethe-Bloch formula.
+// It is normalized to 1 at the minimum.
+//
+// The default values for the kp* parameters are for ALICE TPC.
+// The value is computed in MIP units, multiplied by 50 to have it in energy.
+//
+
+ Double_t betaGamma = track->P() / fMass;
+ Double_t beta = betaGamma / TMath::Sqrt(1.0 + betaGamma * betaGamma);
+ Double_t aa = TMath::Power(beta, fConst[3]);
+ Double_t bb = TMath::Power(1.0 / betaGamma, fConst[4]);
+
+ bb = TMath::Log(fConst[2] + bb);
+
+ Double_t out = (fConst[1] - aa - bb) * fConst[0] / aa;
+
+ if (fCorrect)
+ {
+ Double_t kMeanCorr = 0.1;
+ Double_t meanCorr = (1 + (out - 1) * kMeanCorr);
+ out *= meanCorr;
+ }
+
+ return out * fMIP;
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutBetheBloch::IsSelected(ETarget tgt, AliRsnDaughter *track)
+{
+//
+// Cut checker.
+//
+
+ // coherence check
+ if (tgt != AliRsnCut::kParticle)
+ {
+ AliError(Form("Wrong target. Skipping cut", GetName()));
+ return kTRUE;
+ }
+
+ // retrieve the TPC signal
+ AliVParticle *vpart = track->GetRef();
+ AliESDtrack *esd = dynamic_cast<AliESDtrack*>(vpart);
+ if (!esd) {
+ AliError("ESD information unavailable");
+ return kTRUE;
+ }
+
+ // compute Bethe-Bloch with the given mass hypothesis
+ Double_t bb = BetheBloch(track);
+
+ // the cut range is the relative fraction of the value:
+ // BB*(1-fraction) < TPC < BB*(1+fraction)
+ // which means:
+ // -fraction < (TPC - BB)/BB < fraction
+ // so we must compute the cut value accordingly
+ fCutValueD = (esd->GetTPCsignal() - bb) / bb;
+
+ // then, this cut is checked inside the range
+ return OkRange();
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutBetheBloch::IsSelected(ETarget tgt, AliRsnPairParticle *pair)
+{
+//
+// Cut checker
+//
+
+ AliWarning("Cannot apply this cut to pairs");
+ return kTRUE;
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutBetheBloch::IsSelected(ETarget tgt, AliRsnEvent *event)
+{
+//
+// Cut checker
+//
+
+ AliWarning("Cannot apply this cut to events");
+ return kTRUE;
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutBetheBloch::IsSelected(ETarget tgt, AliRsnEvent *ev1, AliRsnEvent *ev2)
+{
+//
+// Cut checker
+//
+
+ AliWarning("Cannot apply this cut to event mixing");
+ return kTRUE;
+}
--- /dev/null
+//
+// Class AliRsnCutRange
+//
+// General implementation of cuts which check a value inside a range.
+// This range can be defined by two integers or two doubles.
+// A user-friendly enumeration allows to define what is checked.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef ALIRSNCUTBETHEBLOCK_H
+#define ALIRSNCUTBETHEBLOCK_H
+
+#include "AliPID.h"
+#include "AliRsnCut.h"
+
+class AliRsnCutBetheBloch : public AliRsnCut
+{
+ public:
+
+ AliRsnCutBetheBloch();
+ AliRsnCutBetheBloch(const char *name, Double_t fractionRange, Double_t mass, Double_t mip = 50.0, Bool_t correct = kTRUE);
+ AliRsnCutBetheBloch(const char *name, Double_t fractionRange, AliPID::EParticleType type, Double_t mip = 50.0, Bool_t correct = kTRUE);
+
+ void SetMass(Double_t mass) {fMass = mass;}
+ void SetMass(AliPID::EParticleType type) {AliPID pid; fMass = pid.ParticleMass(type);}
+ void SetMIP(Double_t mip) {fMIP = mip;}
+ void SetCalibConstant(Int_t i, Double_t value) {if (i>=0&&i<5) fConst[i] = value;}
+ Double_t BetheBloch(AliRsnDaughter *track);
+
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnDaughter *daughter);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnPairParticle *pair);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnEvent *event);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnEvent *ev1, AliRsnEvent *ev2);
+
+protected:
+
+ Bool_t fCorrect; // apply or not the saturation corrections
+ Double_t fMass; // mass hypothesis
+ Double_t fMIP; // MIP normalization
+ Double_t fConst[5]; // calibration constants
+
+ ClassDef(AliRsnCutBetheBloch, 1)
+};
+
+#endif
--- /dev/null
+//
+// Class AliRsnCutStd
+//
+// General implementation of a single cut strategy, which can be:
+// - a value contained in a given interval [--> IsBetween() ]
+// - a value equal to a given reference [--> MatchesValue()]
+//
+// In all cases, the reference value(s) is (are) given as data members
+// and each kind of cut requires a given value type (Int, UInt, Double),
+// but the cut check procedure is then automatized and chosen thanks to
+// an enumeration of the implemented cut types.
+// At the end, the user (or any other point which uses this object) has
+// to use the method IsSelected() to check if this cut has been passed.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#include "Riostream.h"
+#include "TParticle.h"
+#include "TMath.h"
+
+#include "AliLog.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnPairParticle.h"
+
+#include "AliRsnCutStd.h"
+
+ClassImp(AliRsnCutStd)
+
+//_________________________________________________________________________________________________
+AliRsnCutStd::AliRsnCutStd() :
+ AliRsnCut(),
+ fType(kLastType),
+ fUseMC(kFALSE)
+{
+//
+// Default constructor.
+//
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutStd::AliRsnCutStd
+(const char *name, EType type, Int_t val1, Int_t val2, Bool_t useMC) :
+ AliRsnCut(name, val1, val2),
+ fType(type),
+ fUseMC(useMC)
+{
+//
+// Main constructor.
+// Checks also that cut values are given in the correct type,
+// in order to avoid that one passes, for example, a value which should be double
+// but is interpreted as integer due to the overloading of constructors
+//
+
+ switch (fType)
+ {
+ // int
+ case kMult:
+ case kMultDiff:
+ case kKink:
+ case kKinkMother:
+ case kAssignedPID:
+ case kTruePID:
+ case kCharge:
+ break;
+ // ulong
+ case kStatus:
+ if (fVarType != kULong)
+ {
+ AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' is based on ULONG. Casting values to ULONG", GetName()));
+ SetRange((ULong_t)val1, (ULong_t)val2);
+ AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' ULONG range = %d, %d", GetName(), fMinU, fMaxU));
+ }
+ break;
+ // double
+ case kP:
+ case kPt:
+ case kEta:
+ case kThetaDeg:
+ case kDr:
+ case kDz:
+ case kTPCsignal:
+ case kMultDiffRel:
+ case kVzDiff:
+ if (fVarType != kDouble)
+ {
+ AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' is based on DOUBLE. Casting values to DOUBLE", GetName()));
+ SetRange((Double_t)val1, (Double_t)val2);
+ AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' DOUBLE range = %f, %f", GetName(), fMinD, fMaxD));
+ }
+ break;
+ // other cuts are not based on a value, so no problem
+ default:
+ break;
+ }
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutStd::AliRsnCutStd
+(const char *name, EType type, ULong_t val1, ULong_t val2, Bool_t useMC) :
+ AliRsnCut(name, val1, val2),
+ fType(type),
+ fUseMC(useMC)
+{
+//
+// Main constructor.
+// Checks also that cut values are given in the correct type,
+// in order to avoid that one passes, for example, a value which should be double
+// but is interpreted as integer due to the overloading of constructors
+//
+
+ switch (fType)
+ {
+ // int
+ case kMult:
+ case kMultDiff:
+ case kKink:
+ case kKinkMother:
+ case kAssignedPID:
+ case kTruePID:
+ case kCharge:
+ if (fVarType != kInt)
+ {
+ AliWarning(Form("[ULONG CONSTRUCTOR] Cut '%s' is based on INT. Casting values to INT", GetName()));
+ SetRange((Int_t)val1, (Int_t)val2);
+ AliWarning(Form("[ULONG CONSTRUCTOR] Cut '%s' INT range = %d, %d", GetName(), fMinI, fMaxI));
+ }
+ break;
+ // ulong
+ case kStatus:
+ break;
+ // double
+ case kP:
+ case kPt:
+ case kEta:
+ case kThetaDeg:
+ case kDr:
+ case kDz:
+ case kTPCsignal:
+ case kMultDiffRel:
+ case kVzDiff:
+ if (fVarType != kDouble)
+ {
+ AliWarning(Form("[ULONG CONSTRUCTOR] Cut '%s' is based on DOUBLE. Casting values to DOUBLE", GetName()));
+ SetRange((Double_t)val1, (Double_t)val2);
+ AliWarning(Form("[ULONG CONSTRUCTOR] Cut '%s' DOUBLE range = %f, %f", GetName(), fMinD, fMaxD));
+ }
+ break;
+ // other cuts are not based on a value, so no problem
+ default:
+ break;
+ }
+}
+
+//_________________________________________________________________________________________________
+AliRsnCutStd::AliRsnCutStd
+(const char *name, EType type, Double_t val1, Double_t val2, Bool_t useMC) :
+ AliRsnCut(name, val1, val2),
+ fType(type),
+ fUseMC(useMC)
+{
+//
+// Main constructor.
+// Checks also that cut values are given in the correct type,
+// in order to avoid that one passes, for example, a value which should be double
+// but is interpreted as integer due to the overloading of constructors
+//
+
+ switch (fType)
+ {
+ // int
+ case kMult:
+ case kMultDiff:
+ case kKink:
+ case kKinkMother:
+ case kAssignedPID:
+ case kTruePID:
+ case kCharge:
+ if (fVarType != kInt)
+ {
+ AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' is based on INT. Casting values to INT", GetName()));
+ SetRange((Int_t)val1, (Int_t)val2);
+ AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' INT range = %d, %d", GetName(), fMinI, fMaxI));
+ }
+ break;
+ // ulong
+ case kStatus:
+ if (fVarType != kULong)
+ {
+ AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' is based on ULONG. Casting values to ULONG", GetName()));
+ SetRange((ULong_t)val1, (ULong_t)val2);
+ AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' ULONG range = %d, %d", GetName(), fMinU, fMaxU));
+ }
+ break;
+ // double
+ case kP:
+ case kPt:
+ case kEta:
+ case kThetaDeg:
+ case kDr:
+ case kDz:
+ case kTPCsignal:
+ case kMultDiffRel:
+ case kVzDiff:
+ break;
+ // other cuts are not based on a value, so no problem
+ default:
+ break;
+ }
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutStd::IsSelected(ETarget tgt, AliRsnDaughter *track)
+{
+//
+// Cut checker.
+//
+
+ // coherence check
+ if (tgt != AliRsnCut::kParticle)
+ {
+ AliError(Form("Wrong target. Skipping cut", GetName()));
+ return kTRUE;
+ }
+
+
+ // if MC info is required, try to retrieve the TParticle:
+ // if it is not present, the cut is skipped
+ // this avoids to raise a seg-fault when accessing the NULL TParticle object
+ TParticle *part = 0x0;
+ if (fUseMC) {
+ part = track->GetParticle();
+ if (!part) {
+ AliError("Required MC info but it is not present. Cut Skipped.");
+ return kTRUE;
+ }
+ }
+
+ // loop on allowed possibilities
+ switch(fType)
+ {
+ case kP:
+ fCutValueD = fUseMC ? part->P() : track->P();
+ return OkRange();
+ case kPt:
+ fCutValueD = fUseMC ? part->Pt() : track->Pt();
+ return OkRange();
+ case kThetaDeg:
+ fCutValueD = track->ThetaDeg();
+ return OkRange();
+ case kEta:
+ fCutValueD = fUseMC ? part->Eta() : track->Eta();
+ return OkRange();
+ case kDr:
+ fCutValueD = track->Dr();
+ return OkRange();
+ case kDz:
+ fCutValueD = track->Dz();
+ return OkRange();
+ case kStatus:
+ fCutValueU = track->GetStatus();
+ return OkValue();
+ case kKink:
+ fCutValueI = track->IsKink();
+ return OkValue();
+ case kKinkMother:
+ fCutValueI = track->IsKinkMother();
+ return OkValue();
+ case kCharge:
+ fCutValueI = (Int_t)track->Charge();
+ return OkValue();
+ case kAssignedPID:
+ fCutValueI = (Int_t)track->AssignedPID();
+ return OkValue();
+ default:
+ AliWarning(Form("Value %d is not included in available cuts for DAUGHTER. Cut skipped.", fType));
+ return kTRUE;
+ }
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutStd::IsSelected(ETarget tgt, AliRsnPairParticle *pair)
+{
+//
+// Cut checker
+//
+
+ // coherence check
+ if (tgt != AliRsnCut::kPair)
+ {
+ AliError(Form("Wrong target. Skipping cut", GetName()));
+ return kTRUE;
+ }
+
+ // loop on allowed possibilities
+ switch(fType)
+ {
+ case kP:
+ fCutValueD = (fUseMC ? pair->GetPMC() : pair->GetP());
+ return OkRange();
+ case kPt:
+ fCutValueD = (fUseMC ? pair->GetPtMC() : pair->GetPt());
+ return OkRange();
+ case kEta:
+ fCutValueD = (fUseMC ? pair->GetEtaMC() : pair->GetEta());
+ return OkRange();
+ case kTruePair:
+ fCutValueI = pair->CommonMother();
+ return OkValue();
+ default:
+ AliWarning(Form("Value %d is not included in available cuts for PAIR. Cut skipped.", fType));
+ return kTRUE;
+ }
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutStd::IsSelected(ETarget tgt, AliRsnEvent *event)
+{
+//
+// Cut checker
+//
+
+ // coherence check
+ if (tgt != AliRsnCut::kEvent)
+ {
+ AliError(Form("Wrong target. Skipping cut", GetName()));
+ return kTRUE;
+ }
+
+ // loop on allowed possibilities
+ switch(fType)
+ {
+ case kMult:
+ fCutValueI = event->GetMultiplicity();
+ return OkRange();
+ default:
+ AliWarning(Form("Value %d is not included in available cuts for EVENT. Cut skipped.", fType));
+ return kTRUE;
+ }
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnCutStd::IsSelected(ETarget tgt, AliRsnEvent *ev1, AliRsnEvent *ev2)
+{
+//
+// Cut checker
+//
+
+ // coherence check
+ if (tgt != AliRsnCut::kMixEvent)
+ {
+ AliError(Form("Wrong target. Skipping cut", GetName()));
+ return kTRUE;
+ }
+
+ // loop on allowed possibilities
+ Double_t mult1, mult2;
+ switch(fType)
+ {
+ case kMultDiff:
+ fCutValueI = TMath::Abs(ev1->GetMultiplicity() - ev2->GetMultiplicity());
+ return OkRange();
+ case kMultDiffRel:
+ mult1 = (Double_t)ev1->GetMultiplicity();
+ mult2 = (Double_t)ev2->GetMultiplicity();
+ if (mult1 == 0.0 && mult2 == 0.0) return kTRUE;
+ fCutValueD = 100.0 * TMath::Abs(mult1 - mult2) / TMath::Max(mult1, mult2); // in %
+ return OkRange();
+ case kVzDiff:
+ fCutValueD = TMath::Abs(ev1->GetVz() - ev2->GetVz());
+ return OkRange();
+ default:
+ AliWarning(Form("Value %d is not included in available cuts for MIXEVENT. Cut skipped.", fType));
+ return kTRUE;
+ }
+}
--- /dev/null
+//
+// Class AliRsnCutRange
+//
+// General implementation of cuts which check a value inside a range.
+// This range can be defined by two integers or two doubles.
+// A user-friendly enumeration allows to define what is checked.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef ALIRSNCUTSTD_H
+#define ALIRSNCUTSTD_H
+
+#include "AliRsnCut.h"
+
+class AliRsnCutStd : public AliRsnCut
+{
+ public:
+
+ // available cut types
+ // some ones work both for pairs and single tracks
+ enum EType {
+ kP = 0,
+ kPt,
+ kEta,
+ kThetaDeg,
+ kDr,
+ kDz,
+ kTPCsignal,
+ kMult,
+ kMultDiff,
+ kMultDiffRel,
+ kVzDiff,
+ // value cuts
+ kStatus,
+ kKink,
+ kKinkMother,
+ kAssignedPID,
+ kTruePID,
+ // cut without reference values
+ kCharge,
+ kSameLabel,
+ kTruePair,
+ // last
+ kLastType
+ };
+
+ AliRsnCutStd();
+ AliRsnCutStd(const char *name, EType type, Int_t val1, Int_t val2 = 0, Bool_t useMC = kFALSE);
+ AliRsnCutStd(const char *name, EType type, ULong_t val1, ULong_t val2 = 0, Bool_t useMC = kFALSE);
+ AliRsnCutStd(const char *name, EType type, Double_t val1, Double_t val2 = 0.0, Bool_t useMC = kFALSE);
+ virtual ~AliRsnCutStd() { }
+
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnDaughter *daughter);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnPairParticle *pair);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnEvent *event);
+ virtual Bool_t IsSelected(ETarget tgt, AliRsnEvent *ev1, AliRsnEvent *ev2);
+
+protected:
+
+ EType fType; // cut type
+ Bool_t fUseMC; // use or not MC values (when applicable)
+
+ ClassDef(AliRsnCutStd, 1)
+};
+
+#endif
//
// Class AliRsnDaughter
//
-// Light-weight AOD object which contains all required track details
-// which are used for resonance analysis.
-// Provides converters from all kinds of input track type: ESD, AOD and MC.
+// Interface to candidate daughters of a resonance (tracks).
+// Points to the source of information, which is generally an AliVParticle-derived object
+// and contains few internal data-members to store "on fly" some important information
+// for the computations required during resonance analysis.
+// ---
+// Since the package revision, this object is not supposed to be stacked in memory
+// but created "on fly" during analysis and used just for computations, as an interface.
//
// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
// M. Vala (martin.vala@cern.ch)
#include <TString.h>
#include "AliLog.h"
+#include "AliStack.h"
#include "AliESDtrack.h"
+#include "AliAODEvent.h"
+#include "AliAODVertex.h"
#include "AliAODTrack.h"
-#include "AliMCParticle.h"
-#include "AliRsnPIDDefESD.h"
-#include "AliRsnMCInfo.h"
#include "AliRsnDaughter.h"
ClassImp(AliRsnDaughter)
AliRsnDaughter::EPIDMethod AliRsnDaughter::fgPIDMethod = AliRsnDaughter::kRealistic;
//_____________________________________________________________________________
-AliRsnDaughter::AliRsnDaughter() :
- AliVParticle(),
- fIndex(-1),
- fLabel(-1),
- fCharge(0),
- fFlags(0),
- fKink(0),
- fMass(0.0),
- fChi2(0.0),
- fNSigmaToVertex(-1.0),
- fITSnum(0),
- fTPCnum(0),
- fAssignedPID(AliRsnPID::kUnknown),
- fRealisticPID(AliRsnPID::kUnknown),
- fMCInfo(0x0)
+AliRsnDaughter::AliRsnDaughter(AliVParticle *ref, TParticle *refMC) :
+ fOK((ref != 0)),
+ fKinkIndex(0),
+ fParticle(refMC),
+ fMotherPDG(0),
+ fStatus(0),
+ fRef(ref)
{
//
// Default constructor.
-// Initializes all data-members with meaningless values.
//
-
- Int_t i;
- for (i = 0; i < AliRsnPID::kSpecies; i++)
- {
- if (i < 3)
- {
- fP[i] = 0.0;
- fV[i] = 0.0;
- }
- fPIDWeight[i] = 0.0;
- fPIDProb[i] = 0.0;
- }
}
//_____________________________________________________________________________
AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter ©) :
- AliVParticle(copy),
- fIndex(copy.fIndex),
- fLabel(copy.fLabel),
- fCharge(copy.fCharge),
- fFlags(copy.fFlags),
- fKink(copy.fKink),
- fMass(copy.fMass),
- fChi2(copy.fChi2),
- fNSigmaToVertex(copy.fNSigmaToVertex),
- fITSnum(copy.fITSnum),
- fTPCnum(copy.fTPCnum),
- fAssignedPID(copy.fAssignedPID),
- fRealisticPID(copy.fRealisticPID),
- fMCInfo(0x0)
+ TObject(copy),
+ fOK(copy.fOK),
+ fKinkIndex(copy.fKinkIndex),
+ fParticle(copy.fParticle),
+ fMotherPDG(copy.fMotherPDG),
+ fStatus(copy.fStatus),
+ fRef(copy.fRef)
{
//
// Copy constructor.
+// Pointers are NOT duplicated.
//
-
- Int_t i;
- for (i = 0; i < AliRsnPID::kSpecies; i++)
- {
- if (i < 3)
- {
- fP[i] = copy.fP[i];
- fV[i] = copy.fV[i];
- }
- fPIDWeight[i] = copy.fPIDWeight[i];
- fPIDProb[i] = copy.fPIDProb[i];
- }
-
- // initialize particle object
- // only if it is present in the template object
- if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
}
//_____________________________________________________________________________
{
//
// Assignment operator.
-// Works like the copy constructor and returns a reference
-// to the initialized object for which it is called.
//
- fIndex = copy.fIndex;
- fLabel = copy.fLabel;
- fCharge = copy.fCharge;
- fFlags = copy.fFlags;
- fKink = copy.fKink;
- fChi2 = copy.fChi2;
- fNSigmaToVertex = copy.fNSigmaToVertex;
- fITSnum = copy.fITSnum;
- fTPCnum = copy.fTPCnum;
+ (TObject)(*this) = (TObject)copy;
- Int_t i;
- for (i = 0; i < AliRsnPID::kSpecies; i++)
- {
- if (i < 3)
- {
- fP[i] = copy.fP[i];
- fV[i] = copy.fV[i];
- }
- fPIDWeight[i] = copy.fPIDWeight[i];
- fPIDProb[i] = copy.fPIDProb[i];
- }
+ fOK = copy.fOK;
+ fKinkIndex = copy.fKinkIndex;
+ fParticle = copy.fParticle;
+ fMotherPDG = copy.fMotherPDG;
+ fStatus = copy.fStatus;
- fMass = copy.fMass;
- fAssignedPID = copy.fAssignedPID;
- fRealisticPID = copy.fRealisticPID;
-
- // initialize particle object
- // only if it is present in the template object;
- // otherwise, it is just cleared and not replaced with anything
- if (fMCInfo)
- {
- delete fMCInfo;
- fMCInfo = 0x0;
- }
- if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
+ fRef = copy.fRef;
return (*this);
}
AliRsnDaughter::~AliRsnDaughter()
{
//
-// Destructor
+// Destructor.
+// Since pointers do not allocate new objects, nothing is done.
//
-
- if (fMCInfo)
- {
- delete fMCInfo;
- fMCInfo = 0;
- }
}
//_____________________________________________________________________________
-void AliRsnDaughter::RotateP(Double_t angle, Bool_t isDegrees)
+void AliRsnDaughter::RotateP
+(Double_t angle, Double_t &x, Double_t &y, Bool_t isDegrees)
{
//
// Rotate the transverse momentum by an angle (in DEGREES)
-// around Z axis (does not change the Z component)
+// around Z axis (does not change the Z component).
+// Rotated values are stored in the two arguments passed by reference.
//
if (isDegrees) angle *= TMath::DegToRad();
Double_t s = TMath::Sin(angle);
Double_t c = TMath::Cos(angle);
- Double_t xx = fP[0];
- fP[0] = c*xx - s*fP[1];
- fP[1] = s*xx + c*fP[1];
+
+ x = c*Px() - s*Py();
+ y = s*Px() + c*Py();
}
//_____________________________________________________________________________
-Double_t AliRsnDaughter::AngleTo(AliRsnDaughter *d, Bool_t outInDegrees)
+Double_t AliRsnDaughter::AngleTo(AliRsnDaughter d, Bool_t outInDegrees)
{
//
// Compute angle between the vector momentum of this
// and the one of argument.
//
- Double_t arg, dot, ptot2 = P2() * d->P2();
+ Double_t arg, dot, ptot2 = P2() * d.P2();
- if(ptot2 <= 0) {
+ if (ptot2 <= 0) {
return 0.0;
- }
- else {
- dot = Px()*d->Px() + Py()*d->Py() + Pz()*d->Pz();
+ } else {
+ dot = Px()*d.Px() + Py()*d.Py() + Pz()*d.Pz();
arg = dot / TMath::Sqrt(ptot2);
if (arg > 1.0) arg = 1.0;
if (arg < -1.0) arg = -1.0;
}
//_____________________________________________________________________________
-void AliRsnDaughter::RealisticPID()
+Int_t AliRsnDaughter::GetID() const
{
//
-// Assign realistic PID from largest probability
+// Return reference index, using the "GetID" method
+// of the possible source object.
//
- Int_t i, imax = 0;
- Double_t pmax = fPIDProb[0];
+ AliESDtrack *esd = dynamic_cast<AliESDtrack*>(fRef);
+ if (esd) return esd->GetID();
- // search for maximum
- for (i = 1; i < AliRsnPID::kSpecies; i++)
- {
- if (fPIDProb[i] > pmax)
- {
- imax = i;
- pmax = fPIDProb[i];
+ AliAODTrack *aod = dynamic_cast<AliAODTrack*>(fRef);
+ if (aod) return aod->GetID();
+
+ return GetLabel();
+}
+
+//_____________________________________________________________________________
+AliPID::EParticleType AliRsnDaughter::RealisticPID() const
+{
+//
+// Return the "realistic" PID of this track,
+// i.e. the particle species to which corresponds the largest PID probability.
+//
+
+ AliPID::EParticleType pid = AliPID::kElectron;
+ Double_t prob = fPID[0];
+
+ Int_t i;
+ for (i = 1; i < AliPID::kSPECIES; i++) {
+ if (fPID[i] > prob) {
+ prob = fPID[i];
+ pid = (AliPID::EParticleType)i;
}
}
- fRealisticPID = (AliRsnPID::EType)imax;
+ return pid;
}
//_____________________________________________________________________________
-AliRsnPID::EType AliRsnDaughter::PIDType(Double_t &prob) const
+AliPID::EParticleType AliRsnDaughter::PerfectPID() const
+{
+//
+// Return the "perfect" PID of this track,
+// reading it from the MC information, if available.
+//
+
+ if (!fParticle) return AliPID::kUnknown;
+
+ Int_t absPDG = TMath::Abs(fParticle->GetPdgCode());
+ switch (absPDG) {
+ case 11:
+ return AliPID::kElectron;
+ case 13:
+ return AliPID::kMuon;
+ case 211:
+ return AliPID::kPion;
+ case 321:
+ return AliPID::kKaon;
+ case 2212:
+ return AliPID::kProton;
+ default:
+ AliDebug(2, Form("PDG code = %d not recognized. Return 'AliPID::kUnknown'", absPDG));
+ return AliPID::kUnknown;
+ }
+}
+
+//_____________________________________________________________________________
+AliPID::EParticleType AliRsnDaughter::PIDType(Double_t &prob) const
{
//
// Return the PID type according to the selected method
// It will be realistic for realistic PID and 1 for perfect PID.
//
- switch (fgPIDMethod)
- {
+ AliPID::EParticleType pid = AssignedPID();
+
+ prob = 1.0;
+ if (fgPIDMethod == kRealistic) prob = fPID[(Int_t)pid];
+
+ return pid;
+}
+
+//_____________________________________________________________________________
+AliPID::EParticleType AliRsnDaughter::AssignedPID() const
+{
+//
+// Return the PID type according to the selected method
+// in the argument passed by reference, the probability is stored.
+// It will be realistic for realistic PID and 1 for perfect PID.
+//
+
+ switch (fgPIDMethod) {
case kNoPID:
- AliWarning("Requested a PIDtype call in NoPID mode");
- prob = 1.0;
- return AliRsnPID::kUnknown;
+ return AliPID::kUnknown;
case kPerfect:
- prob = 1.0;
- if (fMCInfo) return AliRsnPID::InternalType(fMCInfo->PDG());
- else return AliRsnPID::kUnknown;
+ return PerfectPID();
+ case kRealistic:
+ return RealisticPID();
default:
- if (fRealisticPID >= 0 && fRealisticPID < AliRsnPID::kSpecies)
- {
- prob = fPIDProb[fRealisticPID];
- return fRealisticPID;
- }
- else
- {
- prob = 1.0;
- return AliRsnPID::kUnknown;
+ AliWarning("PID method not properly set. Returning realistic PID");
+ return RealisticPID();
+ }
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnDaughter::CombineWithPriors(Double_t *priors)
+{
+//
+// Combine current PID weights (assumed to be them) with prior probs
+//
+
+ Int_t i;
+ Double_t sum = 0.0;
+
+ // multiply weights and priors
+ for (i = 0; i < AliPID::kSPECIES; i++) {
+ fPID[i] = priors[i] * fRef->PID()[i];
+ sum += fPID[i];
+ }
+ if (sum <= (Double_t) 0.) {
+ AliError(Form("Sum of weights = %f <= 0", sum));
+ return kFALSE;
+ }
+
+ // normalize
+ for (i = 0; i < AliPID::kSPECIES; i++) fPID[i] /= sum;
+
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+AliESDtrack* AliRsnDaughter::GetRefESD()
+{
+//
+// Return a reference in format of ESD track
+//
+
+ return dynamic_cast<AliESDtrack *>(fRef);
+}
+
+//_____________________________________________________________________________
+void AliRsnDaughter::FindMotherPDG(AliStack *stack)
+{
+//
+// Searches the stack to find the mother and retrieve its PDG code.
+//
+
+ if (!stack || !fParticle) return;
+
+ Int_t mLabel = fParticle->GetFirstMother();
+ if (mLabel < 0) {
+ fMotherPDG = 0;
+ }
+ else {
+ TParticle *mum = stack->Particle(mLabel);
+ if (mum) fMotherPDG = mum->GetPdgCode();
+ else fMotherPDG = 0;
+ }
+}
+
+//_____________________________________________________________________________
+inline Double_t AliRsnDaughter::GetMCEnergy(Double_t mass)
+{
+//
+// Uses the argument to compute 4-momentum energy
+//
+
+ if (!fParticle) return 0.0;
+
+ Double_t p2 = fParticle->Px()*fParticle->Px();
+ p2 += fParticle->Py()*fParticle->Py();
+ p2 += fParticle->Pz()*fParticle->Pz();
+
+ return TMath::Sqrt(mass*mass + p2);
+}
+
+//_____________________________________________________________________________
+void AliRsnDaughter::FindKinkIndex(AliESDtrack *esdTrack)
+{
+//
+// Assign kink index from an ESD track
+//
+
+ Int_t i, ik[3];
+ for (i = 0; i < 3; i++) ik[i] = esdTrack->GetKinkIndex(i);
+
+ if (ik[0] < 0 || ik[1] < 0 || ik[2] < 0) {
+ SetKinkMother();
+ }
+ else if (ik[0] > 0 || ik[1] > 0 || ik[2] > 0) {
+ SetKinkDaughter();
+ }
+ else SetNoKink();
+}
+
+//_____________________________________________________________________________
+void AliRsnDaughter::FindKinkIndex(AliAODEvent *event)
+{
+//
+// Assign kink index from an AOD event
+//
+
+ Int_t iv, id, nD, nV = event->GetNumberOfVertices();
+ for (iv = 0; iv < nV; iv++) {
+ AliAODVertex *v = event->GetVertex(iv);
+ AliAODVertex::AODVtx_t type = (AliAODVertex::AODVtx_t)v->GetType();
+ if (type != AliAODVertex::kKink) continue;
+ AliAODTrack *mother = (AliAODTrack*)v->GetParent();
+ if (mother == (AliAODTrack*)fRef) {
+ SetKinkMother();
+ return;
+ } else {
+ nD = v->GetNDaughters();
+ for (id = 0; id < nD; id++) {
+ AliAODTrack *son = (AliAODTrack*)v->GetDaughter(id);
+ if (son == (AliAODTrack*)fRef) {
+ SetKinkDaughter();
+ return;
+ }
}
+ }
}
+
+ SetNoKink();
+}
+
+//_____________________________________________________________________________
+void AliRsnDaughter::Reset()
+{
+//
+// Reset this track to meaningless values
+//
+
+ fOK = kFALSE;
+ fKinkIndex = 0;
+ fParticle = 0x0;
+ fMotherPDG = 0;
+ fStatus = 0;
+ fRef = 0x0;
}
//_____________________________________________________________________________
TString opt(option);
opt.ToUpper();
- if (opt.Contains("L") || opt.Contains("ALL"))
- {
- cout << ".......Index : " << fIndex << endl;
- cout << ".......Label : " << fLabel << endl;
+ if (opt.Contains("L") || opt.Contains("ALL")) {
+ cout << ".......Index : " << GetID() << endl;
+ cout << ".......Label : " << GetLabel() << endl;
}
- if (opt.Contains("P") || opt.Contains("ALL"))
- {
+ if (opt.Contains("P") || opt.Contains("ALL")) {
cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
}
- if (opt.Contains("A") || opt.Contains("ALL"))
- {
+ if (opt.Contains("A") || opt.Contains("ALL")) {
cout << ".......Phi, Theta : " << Phi() << ' ' << Theta() << endl;
}
- if (opt.Contains("V") || opt.Contains("ALL"))
- {
+ if (opt.Contains("V") || opt.Contains("ALL")) {
cout << ".......Vx, Vy, Vz : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
}
- if (opt.Contains("I") || opt.Contains("ALL"))
- {
- AliRsnPID::EType type;
+ if (opt.Contains("I") || opt.Contains("ALL")) {
+ AliPID::EParticleType type;
Double_t prob;
type = PIDType(prob);
- cout << ".......PID & prob : " << AliRsnPID::ParticleName(type) << ' ' << prob << endl;
+ cout << ".......PID & prob : " << AliPID::ParticleName(type) << ' ' << prob << endl;
}
- if (opt.Contains("C") || opt.Contains("ALL"))
- {
- cout << ".......Charge : " << fCharge << endl;
+ if (opt.Contains("C") || opt.Contains("ALL")) {
+ cout << ".......Charge : " << Charge() << endl;
}
- if (opt.Contains("F") || opt.Contains("ALL"))
- {
- cout << ".......Flags : " << fFlags << endl;
+ if (opt.Contains("F") || opt.Contains("ALL")) {
+ cout << ".......Flags : " << fStatus << endl;
}
- if (opt.Contains("W") || opt.Contains("ALL"))
- {
+ if (opt.Contains("W") || opt.Contains("ALL")) {
cout << ".......Weights : ";
Int_t i;
- for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[i] << ' ';
+ for (i = 0; i < AliPID::kSPECIES; i++) cout << fPID[i] << ' ';
cout << endl;
}
- if (opt.Contains("M") || opt.Contains("ALL"))
- {
- if (fMCInfo)
- {
- cout << ".......PDG code : " << fMCInfo->PDG() << endl;
- cout << ".......Mother (label) : " << fMCInfo->Mother() << endl;
- cout << ".......Mother (PDG code): " << fMCInfo->MotherPDG() << endl;
- }
- else
- {
+ if (opt.Contains("M") || opt.Contains("ALL")) {
+ if (fParticle) {
+ cout << ".......PDG code : " << fParticle->GetPdgCode() << endl;
+ cout << ".......Mother (label) : " << fParticle->GetFirstMother() << endl;
+ cout << ".......Mother (PDG code): " << fMotherPDG << endl;
+ } else {
cout << ".......MC info not present" << endl;
}
}
}
//_____________________________________________________________________________
-void AliRsnDaughter::InitMCInfo()
-{
+AliPID::EParticleType AliRsnDaughter::InternalType(Int_t pdg)
//
-// Initializes the particle object with default constructor.
+// Return the internal enum value corresponding to the PDG
+// code passed as argument, if possible.
+// Otherwise, returns 'AliPID::kSPECIES' by default.
//
-
- fMCInfo = new AliRsnMCInfo;
-}
-
-//_____________________________________________________________________________
-Bool_t AliRsnDaughter::InitMCInfo(TParticle *particle)
{
-//
-// Copies data from an MC particle into the object which
-// contains all MC details taken from kinematics info.
-// If requested by second argument, momentum and vertex
-// of the Particle are copied into the 'fP' and 'fV'
-// data members, to simulate a perfect reconstruction.
-// If something goes wrong, returns kFALSE,
-// otherwise returns kTRUE.
-//
-
- // retrieve the TParticle object pointed by this MC track
- if (!particle)
- {
- AliError("Passed NULL particle object");
- return kFALSE;
+ AliPID::EParticleType value;
+ Int_t absPDG = TMath::Abs(pdg);
+
+ switch (absPDG) {
+ case 11:
+ value = AliPID::kElectron;
+ break;
+ case 13:
+ value = AliPID::kMuon;
+ break;
+ case 211:
+ value = AliPID::kPion;
+ break;
+ case 321:
+ value = AliPID::kKaon;
+ break;
+ case 2212:
+ value = AliPID::kProton;
+ break;
+ default:
+ value = AliPID::kUnknown;
}
-
- // initialize object if not initialized yet
- if (fMCInfo) delete fMCInfo;
- fMCInfo = new AliRsnMCInfo;
- fMCInfo->Adopt(particle);
-
- return kTRUE;
-}
-
-//_____________________________________________________________________________
-Int_t AliRsnDaughter::Compare(const TObject* obj) const
-{
-//
-// Compare two tracks with respect to their transverse momentum.
-// Citation from ROOT reference:
-// "Must return -1 if this is smaller than obj, 0 if objects are equal
-// and 1 if this is larger than obj".
-//
-
- AliRsnDaughter *that = (AliRsnDaughter*)obj;
- if (Pt() < that->Pt()) return 1;
- else if (Pt() > that->Pt()) return -1;
- else return 0;
+ return value;
}
//
// Class AliRsnDaughter
//
-// Light-weight AOD object which contains all required track details
-// which are used for resonance analysis.
-// Provides converters from all kinds of input track type: ESD, AOD and MC.
+// Interface to candidate daughters of a resonance (tracks).
+// Points to the source of information, which is generally an AliVParticle-derived object
+// and contains few internal data-members to store "on fly" some important information
+// for the computations required during resonance analysis.
+// ---
+// Since the package revision, this object is not supposed to be stacked in memory
+// but created "on fly" during analysis and used just for computations, as an interface.
//
// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
// M. Vala (martin.vala@cern.ch)
#include <TMath.h>
+#include "AliPID.h"
#include "AliVParticle.h"
-#include "AliRsnPID.h"
class TParticle;
-
+class AliStack;
class AliESDtrack;
-class AliAODTrack;
-class AliMCParticle;
-
-class AliRsnMCInfo;
+class AliAODEvent;
-class AliRsnDaughter : public AliVParticle
+class AliRsnDaughter : public TObject
{
public:
kMethods
};
- AliRsnDaughter();
+ AliRsnDaughter(AliVParticle *ref = 0, TParticle *refMC = 0);
AliRsnDaughter(const AliRsnDaughter ©);
virtual ~AliRsnDaughter();
AliRsnDaughter& operator= (const AliRsnDaughter& copy);
- // 4-momentum
- virtual Double_t E() const {return TMath::Sqrt(fMass*fMass + P2());}
- virtual Double_t E(Double_t mass) {SetM(mass); return E();}
- virtual Double_t E(AliRsnPID::EType pid) {AssignPID(pid); return E();}
- virtual Double_t M() const {return fMass;}
- virtual Double_t P2() const {return Px()*Px() + Py()*Py() + Pz()*Pz();}
- virtual Double_t P() const {return TMath::Sqrt(P2());}
- virtual Double_t Px() const {return fP[0];}
- virtual Double_t Py() const {return fP[1];}
- virtual Double_t Pz() const {return fP[2];}
- virtual Double_t Pt() const {return TMath::Sqrt(Px()*Px() + Py()*Py());}
- virtual Double_t OneOverPt() const {return 1.0 / Pt();}
- virtual Bool_t PxPyPz(Double_t p[3]) const {p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE;}
- virtual Double_t Chi2() const {return fChi2;}
- void SetPx(Double_t value) {fP[0] = value;}
- void SetPy(Double_t value) {fP[1] = value;}
- void SetPz(Double_t value) {fP[2] = value;}
- void SetP(Double_t px, Double_t py, Double_t pz) {SetPx(px); SetPy(py); SetPz(pz);}
- void SetM(Double_t m) {fMass = m;}
- void SetChi2(Double_t chi2) {fChi2 = chi2;}
- void RotateP(Double_t angle, Bool_t isDegrees = kTRUE);
- Double_t AngleTo(AliRsnDaughter *d, Bool_t outInDegrees = kTRUE);
+ // momentum
+ Double_t Px() const {return fRef->Px();}
+ Double_t Py() const {return fRef->Py();}
+ Double_t Pz() const {return fRef->Pz();}
+ Double_t Pt() const {return fRef->Pt();}
+ Double_t P2() const {return Pt()*Pt() + Pz()*Pz();}
+ Double_t P() const {return TMath::Sqrt(P2());}
+ Double_t Eta() const {return fRef->Eta();}
+ Double_t Y() const {return fRef->Y();}
+ Double_t Y(Double_t mass) const {return 0.5*TMath::Log((E(mass) + Pz()) / (E(mass) - Pz()));}
+ Double_t E() const {return fRef->E();}
+ Double_t E(Double_t mass) const {return TMath::Sqrt(mass*mass + P2());}
+ Double_t Phi() const {return fRef->Phi();}
+ Double_t Theta() const {return fRef->Theta();}
+ Double_t PhiDeg() const {return TMath::RadToDeg() * Phi();}
+ Double_t ThetaDeg() const {return TMath::RadToDeg() * Theta();}
+ void RotateP(Double_t angle, Double_t &x, Double_t &y, Bool_t isDegrees = kTRUE);
+ Double_t AngleTo(AliRsnDaughter d, Bool_t outInDegrees = kTRUE);
// DCA vertex
- virtual Double_t Xv() const {return fV[0];}
- virtual Double_t Yv() const {return fV[1];}
- virtual Double_t Zv() const {return fV[2];}
- virtual Double_t Dr() const {return TMath::Sqrt(Xv()*Xv() + Yv()*Yv());}
- virtual Bool_t XvYvZv(Double_t x[3]) const {x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE;}
- void SetVx(Double_t value) {fV[0] = value;}
- void SetVy(Double_t value) {fV[1] = value;}
- void SetVz(Double_t value) {fV[2] = value;}
- void SetV(Double_t vx, Double_t vy, Double_t vz) {SetVx(vx); SetVy(vy); SetVz(vz);}
- void ShiftZero(Double_t x, Double_t y, Double_t z){fV[0]-=x;fV[1]-=y;fV[2]-=z;}
-
- // Orientation
- virtual Double_t Phi() const {return TMath::ATan2(Py(), Px());}
- virtual Double_t PhiDeg() const {return Phi() * TMath::RadToDeg();}
- virtual Double_t Theta() const {return TMath::ATan2(Pt(), Pz()) ;}
- virtual Double_t ThetaDeg() const {return Theta() * TMath::RadToDeg();}
- virtual Double_t Eta() const {return -TMath::Log(TMath::Tan(0.5*Theta()));}
- virtual Double_t Y() const {return 0.5*TMath::Log((E() + Pz()) / (E() - Pz()));}
-
- // Kink
- virtual Char_t Kink() const {return fKink;}
- virtual Bool_t IsKinkMother() const {return (fKink < 0);}
- virtual Bool_t IsKinkDaughter() const {return (fKink > 0);}
- virtual Bool_t IsKink() const {return (IsKinkMother() || IsKinkDaughter());}
- void SetKink(Char_t kink) {fKink = kink;}
- void SetKinkMother() {fKink = -1;}
- void SetKinkDaughter() {fKink = 1;}
- void SetNoKink() {fKink = 0;}
-
- // Charge
- virtual Short_t Charge() const {return fCharge;}
- void SetCharge(Short_t value) {fCharge = value;}
+ Double_t Xv() const {return fRef->Xv();}
+ Double_t Yv() const {return fRef->Yv();}
+ Double_t Zv() const {return fRef->Zv();}
+ Double_t Dr() const {return fDr;}
+ Double_t Dz() const {return fDz;}
+ void SetDr(Double_t value) {fDr = value;}
+ void SetDz(Double_t value) {fDz = value;}
// PID
- virtual const Double_t* PID() const {return fPIDWeight;}
- const Double_t* PIDProb() const {return fPIDProb;}
- void SetPIDProb(Int_t i, Double_t value) {if (i>=0&&i<AliRsnPID::kSpecies)fPIDProb[i]=value;}
- void SetPIDWeight(Int_t i, Double_t value) {if (i>=0&&i<AliRsnPID::kSpecies)fPIDWeight[i]=value;}
- static void SetPIDMethod(EPIDMethod method) {fgPIDMethod = method;}
- void RealisticPID();
- void AssignPID(AliRsnPID::EType pid) {fAssignedPID = pid; fMass = AliRsnPID::ParticleMass(pid);}
- AliRsnPID::EType PIDType(Double_t &prob) const;
- AliRsnPID::EType AssignedPID() {return fAssignedPID;}
-
- // check that contains a given ESD flag
- void SetFlags(ULong_t flags) {fFlags = flags;}
- UInt_t GetFlags() {return fFlags;}
- Bool_t CheckFlag(ULong_t flag) {return ((fFlags & flag) == flag);}
-
- // position in stack/array
- Int_t Index() const {return fIndex;}
- Int_t Label() const {return fLabel;}
- Int_t GetLabel() const {return -1;}
- void SetIndex(Int_t value) {fIndex = value;}
- void SetLabel(Int_t value) {fLabel = value;}
-
- // N sigma to vertex
- Float_t NSigmaToVertex() const { return fNSigmaToVertex; }
- void SetNSigmaToVertex(const Float_t& theValue) { fNSigmaToVertex = theValue; }
-
- // ITS/TPC clusters
- Int_t NumberOfITSClusters() const {return fITSnum;}
- Int_t NumberOfTPCClusters() const {return fTPCnum;}
- void SetNumberOfITSClusters(Int_t n) {fITSnum = n;}
- void SetNumberOfTPCClusters(Int_t n) {fTPCnum = n;}
-
- // Utilities
- void Print(Option_t *option = "ALL") const;
- void InitMCInfo();
- Bool_t InitMCInfo(TParticle *particle);
-
- // MC info
- AliRsnMCInfo* GetMCInfo() const { return fMCInfo; }
-
- // sorting (with respect to Pt)
- virtual Bool_t IsSortable() const {return kTRUE;}
- virtual Int_t Compare(const TObject* obj) const;
+ const Double_t *PID() const {return fRef->PID();}
+ Bool_t CombineWithPriors(Double_t *priors);
+ AliPID::EParticleType RealisticPID() const;
+ AliPID::EParticleType PerfectPID() const;
+ Double_t PIDProb(AliPID::EParticleType type) const {return PID()[(Int_t)type];}
+ AliPID::EParticleType PIDType(Double_t &prob) const;
+ AliPID::EParticleType AssignedPID() const;
+
+ // integer parameters
+ Short_t Charge() const {return fRef->Charge();}
+ Int_t GetLabel() const {return fRef->GetLabel();}
+ Int_t GetID() const;
+ void SetStatus(ULong_t value) {fStatus = value;}
+ ULong_t GetStatus() const {return fStatus;}
+ Bool_t CheckFlag(ULong_t flag) const {return ((fStatus & flag) > 0);}
+ void SetGood() {fOK = kTRUE;}
+ void SetBad() {fOK = kFALSE;}
+ Bool_t IsOK() {return fOK;}
+
+ // Kinkness
+ Char_t KinkIndex() const {return fKinkIndex;}
+ Bool_t IsKinkMother() const {return (fKinkIndex < 0);}
+ Bool_t IsKinkDaughter() const {return (fKinkIndex > 0);}
+ Bool_t IsKink() const {return (IsKinkMother() || IsKinkDaughter());}
+ void SetKink(Char_t kink) {fKinkIndex = kink;}
+ void SetKinkMother() {fKinkIndex = -1;}
+ void SetKinkDaughter() {fKinkIndex = 1;}
+ void SetNoKink() {fKinkIndex = 0;}
+ void FindKinkIndex(AliESDtrack *track);
+ void FindKinkIndex(AliAODEvent *event);
+
+ // MC info & references
+ AliVParticle* GetRef() {return fRef;}
+ AliESDtrack* GetRefESD();
+ TParticle* GetParticle() {return fParticle;}
+ Int_t GetMotherPDG() {return fMotherPDG;}
+ void SetRef(AliVParticle *ref) {fRef = ref;}
+ void SetParticle(TParticle *p) {fParticle = p;}
+ void SetMotherPDG(Int_t value) {fMotherPDG = value;}
+ void FindMotherPDG(AliStack *stack);
+ Double_t GetMCEnergy(Double_t mass);
+
+ // utilities
+ void Reset();
+ void Print(Option_t *option = "ALL") const;
+
+ // static functions
+ static void SetPIDMethod(EPIDMethod method) {fgPIDMethod = method;}
+ static AliPID::EParticleType InternalType(Int_t pdgCode);
private:
- Int_t fIndex; // index of source object (ESD/AOD/MC) in its collection
- Int_t fLabel; // label assigned to the track (act. by GEANT3)
-
- Short_t fCharge; // charge sign
- ULong_t fFlags; // status flags
- Char_t fKink; // kink index
-
- Double_t fP[3]; // vector momentum (x, y, z)
- Double_t fV[3]; // DCA vertex (x, y, z)
- Double_t fMass; // mass (assigned externally)
- Double_t fChi2; // chi square of track
- Float_t fNSigmaToVertex; // N sigma to vertex
+ Bool_t fOK; // status flag for usability
+ Int_t fKinkIndex; // indicator of kinkness of the track
+ TParticle *fParticle; // pointer to (eventual) MC information
+ Int_t fMotherPDG; // PDG code of mother (if any)
+ ULong_t fStatus; // track status (if available)
- Int_t fITSnum; // number of ITS clusters
- Int_t fTPCnum; // number of TPC clusters
+ Double_t fDr; // transverse impact parameter
+ Double_t fDz; // longitudinal impact parameter
+ Double_t fPID[AliPID::kSPECIES]; // PID probabilities
- AliRsnPID::EType fAssignedPID; // PID assigned to define mass
- AliRsnPID::EType fRealisticPID; // PID from Bayesian probs (largest one)
- Double_t fPIDProb[AliRsnPID::kSpecies]; // PID probabilities (Bayesian comp.)
- Double_t fPIDWeight[AliRsnPID::kSpecies]; // PID weights
+ AliVParticle *fRef; // reference to read object
- AliRsnMCInfo *fMCInfo; // reference to particle object (if any)
- static EPIDMethod fgPIDMethod; // flag to define how the PID is computed for this object
+ static EPIDMethod fgPIDMethod; // PID method used for analysis
- ClassDef(AliRsnDaughter, 5)
+ ClassDef(AliRsnDaughter, 7)
};
#endif
//
#include <Riostream.h>
-#include <TH1.h>
#include "AliLog.h"
+#include "AliVEvent.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliMCEvent.h"
+#include "AliStack.h"
-#include "AliRsnDaughter.h"
#include "AliRsnEvent.h"
-#include "AliRsnMCInfo.h"
ClassImp(AliRsnEvent)
//_____________________________________________________________________________
-AliRsnEvent::AliRsnEvent() :
- TNamed("rsnEvent", ""),
- fPVx(0.0),
- fPVy(0.0),
- fPVz(0.0),
- fPhiMean(0.0),
- fMult(0),
- fPVxMC(0.0),
- fPVyMC(0.0),
- fPVzMC(0.0),
- fTracks(0x0),
- fTrueMult(0),
- fNoPID(0x0),
- fPerfectPID(0x0),
- fRealisticPID(0x0),
- fSelPIDType(AliRsnPID::kUnknown),
- fSelCharge('0'),
- fSelPIDMethod(AliRsnDaughter::kRealistic),
- fSelCuts(0x0)
+AliRsnEvent::AliRsnEvent(AliVEvent *ref, AliMCEvent *refMC) :
+ fRef(ref),
+ fRefMC(refMC)
{
//
// Default constructor
-// (implemented but not recommended for direct use)
//
}
//_____________________________________________________________________________
AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) :
- TNamed(event),
- fPVx(event.fPVx),
- fPVy(event.fPVy),
- fPVz(event.fPVz),
- fPhiMean(event.fPhiMean),
- fMult(event.fMult),
- fPVxMC(event.fPVxMC),
- fPVyMC(event.fPVyMC),
- fPVzMC(event.fPVzMC),
- fTracks(0x0),
- fTrueMult(event.fTrueMult),
- fNoPID(0x0),
- fPerfectPID(0x0),
- fRealisticPID(0x0),
- fSelPIDType(AliRsnPID::kUnknown),
- fSelCharge('0'),
- fSelPIDMethod(AliRsnDaughter::kRealistic),
- fSelCuts(0x0)
+ TObject(event),
+ fRef(event.fRef),
+ fRefMC(event.fRefMC)
+
{
//
// Copy constructor.
-// Copies all the tracks from the argument's collection
-// to this' one, and then recreates the PID index arrays,
-// trusting on the PID informations in the copied tracks.
//
-
- // during track copy, counts how many faults happen
- Int_t errors = Fill(event.fTracks);
- if (errors) AliWarning(Form("%d errors occurred in copy", errors));
-
- // fill PID index arrays
- // FillPIDArrays();
-
- if (event.fNoPID) fNoPID = new AliRsnPIDIndex(* (event.fNoPID));
- if (event.fPerfectPID) fPerfectPID = new AliRsnPIDIndex(* (event.fPerfectPID));
- if (event.fRealisticPID) fRealisticPID = new AliRsnPIDIndex(* (event.fRealisticPID));
}
//_____________________________________________________________________________
//
// Works in the same way as the copy constructor.
//
- // copy name and title
- SetName(event.GetName());
- SetTitle(event.GetTitle());
-
- // copy primary vertex and initialize track counter to 0
- fPVx = event.fPVx;
- fPVy = event.fPVy;
- fPVz = event.fPVz;
- fPVxMC = event.fPVxMC;
- fPVyMC = event.fPVyMC;
- fPVzMC = event.fPVzMC;
-
- // other data
- fPhiMean = event.fPhiMean;
- fMult = event.fMult;
- fTrueMult = event.fTrueMult;
-
- // add tracks from array of argument
- Int_t errors = Fill(event.fTracks);
- if (errors) AliWarning(Form("%d errors occurred in copy", errors));
-
- // fill PID arrays
- // FillPIDArrays();
- if (event.fNoPID)
- {
- if (!fNoPID) fNoPID = new AliRsnPIDIndex(* (event.fNoPID));
- else (*fNoPID) = * (event.fNoPID);
- }
- if (event.fPerfectPID)
- {
- if (!fPerfectPID) fPerfectPID = new AliRsnPIDIndex(* (event.fPerfectPID));
- else (*fPerfectPID) = * (event.fPerfectPID);
- }
- if (event.fRealisticPID)
- {
- if (!fRealisticPID) fRealisticPID = new AliRsnPIDIndex(* (event.fRealisticPID));
- else (*fRealisticPID) = * (event.fRealisticPID);
- }
- // return this object
+ (TObject)(*this) = (TObject)event;
+ fRef = event.fRef;
+ fRefMC = event.fRefMC;
+
return (*this);
}
{
//
// Destructor.
-// Deletes the TClonesArray, after clearing its content.
-// Other memory-allocating arrays are cleared by their
-// destructor, which is automatically called from here.
-//
-
- Clear();
- if (fTracks) delete fTracks;
-}
-
-//_____________________________________________________________________________
-void AliRsnEvent::Init()
-{
-//
-// Initialize TClonesArray data-member.
-//
-
- fTracks = new TClonesArray("AliRsnDaughter", 1);
- //fTracks->BypassStreamer (kFALSE);
-}
-
-//_____________________________________________________________________________
-void AliRsnEvent::Clear(Option_t* /*option*/)
-{
-//
-// Empties the collections (does not delete the objects).
-// The track collection is emptied only at the end.
-// Since some objects could be uninitialized, some
-// "if" statement are used.
-//
-
- if (fTracks) fTracks->Delete();
- delete fNoPID;
- fNoPID = 0x0;
- delete fPerfectPID;
- fPerfectPID = 0x0;
- delete fRealisticPID;
- fRealisticPID = 0x0;
-}
-
-//_____________________________________________________________________________
-AliRsnDaughter* AliRsnEvent::AddTrack(AliRsnDaughter track)
-{
-//
-// Stores a new track into the array and returns
-// a reference pointer to it (which is NULL in case of errors).
//
-
- Int_t nextIndex = fTracks->GetEntriesFast();
- TClonesArray &tracks = (*fTracks);
- AliRsnDaughter *copy = new(tracks[nextIndex]) AliRsnDaughter(track);
- return copy;
}
//_____________________________________________________________________________
-AliRsnDaughter* AliRsnEvent::GetTrack(Int_t index)
+void AliRsnEvent::SetDaughter(AliRsnDaughter &out, Int_t i)
{
//
-// Returns one track in the collection
-// given the absolute index in the global TClonesArray
+// Return a track stored here in format of AliRsnDaughter.
+// and finds in the reference event the informations to set
+// the proprietary data members of AliRsnDaughter
//
- return (AliRsnDaughter*) fTracks->UncheckedAt(index);
-}
-//_____________________________________________________________________________
-TArrayI* AliRsnEvent::GetCharged(Char_t sign)
-{
-//
-// Returns an array with the indexes of all tracks with a given charge
-// (arg can be '+' or '-'), irrespective of its PID.
-// When the argument is wrong, a NULL pointer is returned.
-//
- if (fNoPID) return fNoPID->GetTracksArray(sign, AliRsnPID::kUnknown);
- return 0x0;
-}
+ // retrieve reference particle from reference event
+ AliVParticle *ref = (AliVParticle*)fRef->GetTrack(i);
-//_____________________________________________________________________________
-TArrayI * AliRsnEvent::GetTracksArray
-(AliRsnDaughter::EPIDMethod pidtype, Char_t sign, AliRsnPID::EType type)
-{
-//
-// Returns an array of indexes of all tracks in this event
-// which match the charge sign and PID type in the arguments,
-// according to one of the allowed PID methods (perfect or realistic).
-// It retrieves this array from the AliRsnPIDIndex data members.
-// If the arguments are wrong a NULL pointer is returned.
-//
+ if (!ref) return;
- switch (pidtype)
- {
- case AliRsnDaughter::kRealistic:
- if (fRealisticPID)
- {
- return fRealisticPID->GetTracksArray(sign, type);
- }
- break;
- case AliRsnDaughter::kPerfect:
- if (fPerfectPID)
- {
- return fPerfectPID->GetTracksArray(sign, type);
- }
- break;
- case AliRsnDaughter::kNoPID:
- if (fNoPID)
- {
- return fNoPID->GetTracksArray(sign, AliRsnPID::kUnknown);
- }
- break;
- default:
- AliError("Handled PID methods here are only fNoPID,kPerfect and kRealistic. Nothing done.");
- return 0x0;
+ // if MC info is present, retrieve from it
+ TParticle *refMC = 0;
+ if (fRefMC) {
+ Int_t label = TMath::Abs(ref->GetLabel());
+ refMC = fRefMC->Stack()->Particle(label);
}
- return 0x0;
-}
-//_____________________________________________________________________________
-void AliRsnEvent::FillPIDArrays(Int_t arraySizeInit)
-{
-//
-// Initializes and fills the AliRsnPIDIndex objects containing
-// arrays of indexes for each possible charge and PID type.
-// This method is the unique way to do this, for safety reasons.
-//
-
- if (fNoPID) delete fNoPID;
- if (fPerfectPID) delete fPerfectPID;
- if (fRealisticPID) delete fRealisticPID;
- fNoPID = new AliRsnPIDIndex(arraySizeInit);
- fPerfectPID = new AliRsnPIDIndex(arraySizeInit);
- fRealisticPID = new AliRsnPIDIndex(arraySizeInit);
-
- // set the default type to Realistic
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic);
-
- // loop on tracks and create references
- Double_t prob;
- Int_t i, icharge, type;
- Short_t charge;
- AliRsnMCInfo *mcinfo = 0;
- AliRsnDaughter *track = 0;
- TObjArrayIter iter(fTracks);
- while ((track = (AliRsnDaughter*) iter.Next()))
- {
- charge = track->Charge();
- type = (Int_t) track->PIDType(prob);
- i = fTracks->IndexOf(track);
- mcinfo = track->GetMCInfo();
- if (charge > 0) icharge = 0;
- else if (charge < 0) icharge = 1;
- else
- {
- AliError("Found particle with ZERO charge!!!");
- continue;
- }
- // add to charged array
- fNoPID->AddIndex(i, icharge, (Int_t) AliRsnPID::kUnknown);
- // add to realistic PID array
- fRealisticPID->AddIndex(i, icharge, (Int_t) type);
- // add to perfect PID array (needs MCInfo present)
- if (mcinfo)
- {
- fPerfectPID->AddIndex(i, icharge, (Int_t) AliRsnPID::InternalType(mcinfo->PDG()));
- }
+ // create output object
+ out.SetRef(ref);
+ out.SetGood();
+ out.SetParticle(refMC);
+ if (fRefMC)
+ out.FindMotherPDG(fRefMC->Stack());
+
+ // retrieve primary vertex and set impact parameters
+ Double_t dx = out.Xv(), dy = out.Yv(), dz = out.Zv();
+ const AliVVertex *v = fRef->GetPrimaryVertex();
+ if (v) {
+ dx -= v->GetX();
+ dy -= v->GetY();
+ dz -= v->GetZ();
}
-
- // adjusts the size of arrays
- if (fNoPID) fNoPID->SetCorrectIndexSize();
- if (fPerfectPID) fPerfectPID->SetCorrectIndexSize();
- if (fRealisticPID) fRealisticPID->SetCorrectIndexSize();
-}
-
-//_____________________________________________________________________________
-void AliRsnEvent::Print(Option_t *option) const
-{
-//
-// Lists the details of the event, and the ones of each
-// contained track.
-// The options are passed to AliRsnDaughter::Print().
-// Look at that method to understand option values.
-//
-
- cout << "...Multiplicity : " << fTracks->GetEntries() << endl;
- cout << "...Primary vertex : " << fPVx << ' ' << fPVy << ' ' << fPVz << endl;
-
- TObjArrayIter iter(fTracks);
- AliRsnDaughter *d = 0;
- while ((d = (AliRsnDaughter*) iter.Next()))
- {
- cout << "....Track #" << fTracks->IndexOf(d) << endl;
- d->Print(option);
+ out.SetDr(TMath::Sqrt(dx*dx + dy*dy));
+ out.SetDz(dz);
+
+ // dynamic reference to true nature of referenced event
+ // to get kink index
+ AliESDEvent *esd = dynamic_cast<AliESDEvent*>(fRef);
+ AliAODEvent *aod = dynamic_cast<AliAODEvent*>(fRef);
+
+ if (esd) {
+ AliESDtrack *esdTrack = esd->GetTrack(i);
+ out.FindKinkIndex(esdTrack);
+ } else if (aod) {
+ out.FindKinkIndex(aod);
}
-}
-
-//_____________________________________________________________________________
-void AliRsnEvent::MakeComputations()
-{
-//
-// Computes all required overall variables:
-// - multiplicity
-// - mean phi of tracks
-//
- if (!fTracks)
- {
- fMult = 0;
- fPhiMean = 1000.0;
- }
- else
- {
- fMult = fTracks->GetEntries();
- if (fMult < 1) {
- fPhiMean = 1000.0;
- }
- else
- {
- fPhiMean = 0.0;
- AliRsnDaughter *d = 0;
- TObjArrayIter next(fTracks);
- while ( (d = (AliRsnDaughter*)next()) ) fPhiMean += d->Phi();
- fPhiMean /= (Double_t)fMult;
- }
- }
+ out.SetGood();
}
//_____________________________________________________________________________
-void AliRsnEvent::CorrectTracks()
+AliRsnDaughter AliRsnEvent::GetDaughter(Int_t i)
{
//
-// Corrects in all tracks the DCA vertex position using the primary vertex.
-// If present, also MC infos are corrected with primaryvertexMC.
+// Return an AliRsnDaughter taken from this event,
+// with all additional data members well set.
//
- AliRsnDaughter *track = 0;
- TObjArrayIter next(fTracks);
+ AliRsnDaughter out;
+ SetDaughter(out, i);
- while ( (track = (AliRsnDaughter*)next()) ) {
- track->ShiftZero(fPVx, fPVy, fPVz);
- if (track->GetMCInfo()) {
- track->GetMCInfo()->ShiftZero(fPVxMC, fPVyMC, fPVzMC);
- }
- }
+ return out;
}
//_____________________________________________________________________________
-Int_t AliRsnEvent::GetNCharged(Char_t sign)
+Int_t AliRsnEvent::GetMultiplicity()
{
//
-// Get number of charged tracks
+// Returns event multiplicity
//
-
- Int_t icharge;
- icharge = ChargeIndex(sign);
- if (icharge < 0) return 0;
- TArrayI *charged = GetCharged(sign);
- if (!charged) return 0;
- return charged->GetSize();
+ AliDebug(AliLog::kDebug+2,"<-");
+ if (!fRef) return 0;
+ AliDebug(AliLog::kDebug+2,"->");
+ return fRef->GetNumberOfTracks();
}
//_____________________________________________________________________________
-Int_t AliRsnEvent::Fill(TObjArray *array)
-{
-//
-// Fills the data-member TClonesArray of tracks with
-// the ones stored in the array passed as argument.
-// If this data-member is already present, it is cleared.
-// Returns the number of tracks which raised problems
-// while attempting to add them. Zero is the best.
-//
-
- // clear the array if it is already instantiated,
- // create if otherwise
- if (fTracks) fTracks->Delete();
- else Init();
-
- // copy argument entries into data-member
- Int_t errors = 0;
- AliRsnDaughter *track = 0;
- TObjArrayIter iter(array);
- while ((track = (AliRsnDaughter*) iter.Next()))
- {
- AliRsnDaughter *ref = AddTrack(*track);
- if (!ref)
- {
- AliWarning(Form("Problem occurred when copying track #%d from passed array", array->IndexOf(track)));
- errors++;
- }
- }
-
- return errors;
-}
-
-//_____________________________________________________________________________
-Int_t AliRsnEvent::ChargeIndex(Char_t sign) const
-//
-// Returns the array index corresponding to charge
-// 0 for positive, 1 for negative
-//
-{
- if (sign == '+') return 0;
- else if (sign == '-') return 1;
- else
- {
- AliError(Form("Character '%c' not recognized as charge sign", sign));
- return -1;
- }
-}
-//_____________________________________________________________________________
-inline void AliRsnEvent::SetSelection
-(AliRsnPID::EType pid, Char_t charge, AliRsnDaughter::EPIDMethod meth, AliRsnCutSet *cuts)
+Double_t AliRsnEvent::GetVz()
{
//
-// Set all selection parameters at once
+// Return Z coord of primary vertex
//
-
- SetSelectionPIDType(pid);
- SetSelectionCharge(charge);
- SetSelectionPIDMethod(meth);
- SetSelectionTrackCuts(cuts);
+ AliDebug(AliLog::kDebug+2,"<-");
+ return fRef->GetPrimaryVertex()->GetZ();
+ AliDebug(AliLog::kDebug+2,"->");
}
//_____________________________________________________________________________
-AliRsnDaughter* AliRsnEvent::GetLeadingParticle(Double_t ptMin)
+AliRsnDaughter AliRsnEvent::GetLeadingParticle
+(Double_t ptMin, AliPID::EParticleType type)
{
//
// Searches the collection of all particles with given PID type and charge,
// otherwise it is done irrespectively of the charge.
//
- Int_t i;
- TArrayI *array = 0x0;
- AliRsnDaughter *track1 = 0x0, *track2 = 0x0, *leading = 0x0;
-
- if (fSelCharge == '+' || fSelCharge == '-') {
- // if the charge '+' or '-' does simply the search
- array = GetTracksArray(fSelPIDMethod, fSelCharge, fSelPIDType);
- for (i = 0; i < array->GetSize(); i++) {
- track1 = (AliRsnDaughter *) fTracks->At(array->At(i));
- if (!track1) continue;
- if (track1->Pt() < ptMin) continue;
- if (!CutPass(track1)) continue;
- ptMin = track1->Pt();
- leading = track1;
- }
- }
- else {
- track1 = GetLeadingParticle(ptMin);
- track2 = GetLeadingParticle(ptMin);
- if (track1 && track2) {
- if (track1->Pt() > track2->Pt()) leading = track1;
- else leading = track2;
+ Int_t i, nTracks = fRef->GetNumberOfTracks();
+ AliRsnDaughter output;
+
+ for (i = 0; i < nTracks; i++) {
+ AliRsnDaughter track = GetDaughter(i);
+ if (!AcceptTrackPID(&track, type)) continue;
+ if (track.Pt() < ptMin) continue;
+ if (!output.IsOK() || track.Pt() > output.Pt()) {
+ output = track;
+ output.SetGood();
}
- else if (track1) leading = track1;
- else if (track2) leading = track2;
- else leading = 0x0;
}
- return leading;
+ return output;
}
-//_____________________________________________________________________________
-Double_t AliRsnEvent::GetAverageMomentum(Int_t &count)
+//_________________________________________________________________________________________________
+Double_t AliRsnEvent::GetAverageMomentum(Int_t &count, AliPID::EParticleType type)
{
//
// Loops on the list of tracks and computes average total momentum.
//
- Int_t i;
+ Int_t i, nTracks = fRef->GetNumberOfTracks();
Double_t pmean = 0.0;
- TArrayI *array = 0x0;
- AliRsnDaughter *d = 0x0;
-
- if (fSelCharge == '+' || fSelCharge == '-') {
- // if the charge '+' or '-' does simply the search
- count = 0;
- array = GetTracksArray(fSelPIDMethod, fSelCharge, fSelPIDType);
- for (i = 0; i < array->GetSize(); i++) {
- d = (AliRsnDaughter *) fTracks->At(array->At(i));
- if (!d) continue;
- if (!CutPass(d)) continue;
- pmean += d->P();
- count++;
- }
- if (count > 0) pmean /= (Double_t)count;
- else pmean = 0.0;
- }
- else {
- Int_t countP, countM;
- Double_t pmeanP = GetAverageMomentum(countP);
- Double_t pmeanM = GetAverageMomentum(countM);
- if (countP && countM) {
- pmean = (pmeanP * (Double_t)countP + pmeanM * (Double_t)countM) / (countP + countM);
- count = countP + countM;
- }
- else if (countP) {
- pmean = pmeanP;
- count = countP;
- }
- else if (countM) {
- pmean = pmeanM;
- count = countM;
- }
- else {
- count = 0;
- pmean = 0.0;
- }
+
+ for (i = 0, count = 0; i < nTracks; i++) {
+ AliRsnDaughter track = GetDaughter(i);
+ if (!AcceptTrackPID(&track, type)) continue;
+ pmean += track.P();
+ count++;
}
+ if (count > 0) pmean /= (Double_t)count;
+ else pmean = 0.0;
+
return pmean;
}
//_____________________________________________________________________________
-Bool_t AliRsnEvent::GetAngleDistrWRLeading
-(Double_t &angleMean, Double_t &angleRMS, Double_t ptMin)
+Bool_t AliRsnEvent::GetAngleDistr
+(Double_t &angleMean, Double_t &angleRMS, AliRsnDaughter leading)
{
//
// Takes the leading particle and computes the mean and RMS
// with respect to the direction of leading particle.
//
- AliRsnDaughter *leading = GetLeadingParticle(ptMin);
- if (!leading) return kFALSE;
+ if (!leading.IsOK()) return kFALSE;
- Int_t count = 0;
- Double_t angle, angle2Mean;
- AliRsnDaughter *trk = 0x0;
- TObjArrayIter next(fTracks);
+ Int_t i, count, nTracks = fRef->GetNumberOfTracks();
+ Double_t angle, angle2Mean = 0.0;
angleMean = angle2Mean = 0.0;
- while ( (trk = (AliRsnDaughter*)next()) )
- {
- if (trk == leading) continue;
+ for (i = 0, count = 0; i < nTracks; i++) {
+ AliRsnDaughter trk = GetDaughter(i);
+ if (trk.GetID() == leading.GetID()) continue;
- angle = leading->AngleTo(trk);
+ angle = leading.AngleTo(trk);
angleMean += angle;
angle2Mean += angle * angle;
return kTRUE;
}
+
+//_____________________________________________________________________________
+Bool_t AliRsnEvent::AcceptTrackPID
+(AliRsnDaughter *d, AliPID::EParticleType type)
+{
+//
+// [PRIVATE]
+// Checks if the track PID (according to method in use) corresponds
+// to the required identification species.
+// If the second argument is "kUnknown", answer of this method is always YES.
+//
+
+ if (type == AliPID::kUnknown) return kTRUE;
+
+ return (d->AssignedPID() == type);
+}
#ifndef ALIRSNEVENT_H
#define ALIRSNEVENT_H
-#include <TNamed.h>
-#include <TArrayI.h>
-#include <TClonesArray.h>
-
-#include "AliRsnPID.h"
-#include "AliRsnPIDIndex.h"
#include "AliRsnDaughter.h"
-#include "AliRsnCutSet.h"
-class TH1D;
+class AliVEvent;
+class AliMCEvent;
-class AliRsnEvent : public TNamed
+class AliRsnEvent : public TObject
{
public:
- AliRsnEvent();
+ AliRsnEvent(AliVEvent *ref = 0, AliMCEvent *refMC = 0);
AliRsnEvent(const AliRsnEvent& copy);
AliRsnEvent& operator= (const AliRsnEvent& copy);
virtual ~AliRsnEvent();
- // Array management
- void Init();
- void Clear(Option_t *option = "");
- AliRsnDaughter* AddTrack(AliRsnDaughter track);
- AliRsnDaughter* GetTrack(Int_t index);
- TClonesArray* GetTracks() {return fTracks;}
- TArrayI* GetCharged(Char_t sign);
- TArrayI* GetTracksArray(AliRsnDaughter::EPIDMethod method, Char_t sign, AliRsnPID::EType type);
- void FillPIDArrays(Int_t arraySizeDefault = 1000);
- void SortTracks() {fTracks->Sort();}
- void Print(Option_t *option = "") const;
- void MakeComputations();
- void CorrectTracks();
-
- // Primary vertex
- Double_t GetPrimaryVertexX() const {return fPVx;}
- Double_t GetPrimaryVertexY() const {return fPVy;}
- Double_t GetPrimaryVertexZ() const {return fPVz;}
- Double_t GetPrimaryVertexXMC() const {return fPVxMC;}
- Double_t GetPrimaryVertexYMC() const {return fPVyMC;}
- Double_t GetPrimaryVertexZMC() const {return fPVzMC;}
- void GetPrimaryVertex(Double_t &x, Double_t &y, Double_t &z) const {x=fPVx;y=fPVy;z=fPVz;}
- Double_t GetVz() const {return GetPrimaryVertexZ();}
- void SetPrimaryVertexX(Double_t value) {fPVx = value;}
- void SetPrimaryVertexY(Double_t value) {fPVy = value;}
- void SetPrimaryVertexZ(Double_t value) {fPVz = value;}
- void SetPrimaryVertexXMC(Double_t value) {fPVxMC = value;}
- void SetPrimaryVertexYMC(Double_t value) {fPVyMC = value;}
- void SetPrimaryVertexZMC(Double_t value) {fPVzMC = value;}
- void SetPrimaryVertex(Double_t x, Double_t y, Double_t z) {fPVx=x;fPVy=y;fPVz=z;}
- void SetPrimaryVertexMC(Double_t x, Double_t y, Double_t z) {fPVxMC=x;fPVyMC=y;fPVzMC=z;}
-
- // Multiplicity
- void SetTrueMultiplicity(Int_t value) {fTrueMult = value;}
- Int_t GetTrueMultiplicity() {return fTrueMult;}
- Int_t GetMultiplicity() const {return fMult;}
- Int_t GetNCharged(Char_t sign);
-
- // Mean phi
- Double_t GetPhiMean() const {return fPhiMean;}
-
- // functions for event selection and computation (require on-fly setting of sel parameters)
- void SetSelectionPIDType(AliRsnPID::EType type) {fSelPIDType = type;}
- void SetSelectionCharge(Char_t charge) {fSelCharge = charge;}
- void SetSelectionPIDMethod(AliRsnDaughter::EPIDMethod method) {fSelPIDMethod = method;}
- void SetSelectionTrackCuts(AliRsnCutSet *cuts) {fSelCuts = cuts;}
- void SetSelection(AliRsnPID::EType pid, Char_t charge, AliRsnDaughter::EPIDMethod meth, AliRsnCutSet *cuts = 0x0);
+ void SetRef(AliVEvent *event, AliMCEvent *mc = 0) {fRef = event; fRefMC = mc;}
+ void SetRefMC(AliMCEvent *mc) {fRefMC = mc;}
- Bool_t CutPass(AliRsnDaughter *d)
- {if (!fSelCuts) return kTRUE; else return fSelCuts->IsSelected(AliRsnCut::kParticle, d);}
-
- AliRsnDaughter* GetLeadingParticle(Double_t ptMin = 0.0);
- Double_t GetAverageMomentum(Int_t &count);
- Bool_t GetAngleDistrWRLeading(Double_t &angleMean, Double_t &angleRMS, Double_t ptMin = 0.0);
+ void SetDaughter(AliRsnDaughter &daughter, Int_t index);
+ AliRsnDaughter GetDaughter(Int_t i);
+ Int_t GetMultiplicity();
+ Double_t GetVz();
+ AliRsnDaughter GetLeadingParticle(Double_t ptMin = 0.0, AliPID::EParticleType type = AliPID::kUnknown);
+ Double_t GetAverageMomentum(Int_t &count, AliPID::EParticleType type = AliPID::kUnknown);
+ Bool_t GetAngleDistr(Double_t &angleMean, Double_t &angleRMS, AliRsnDaughter d);
private:
- Int_t ChargeIndex(Char_t sign) const;
- Int_t Fill(TObjArray *array);
-
- Double_t fPVx; // position of
- Double_t fPVy; // primary
- Double_t fPVz; // vertex
- Double_t fPhiMean; // mean "phi" coord of all tracks
- Int_t fMult; // track multiplicity
- Double_t fPVxMC; // position of
- Double_t fPVyMC; // primary
- Double_t fPVzMC; // vertex in MC
-
- TClonesArray *fTracks; // collection of particles
- Int_t fTrueMult; // true multiplicity taken from source event
-
- AliRsnPIDIndex *fNoPID; // array index only for charged tracks
- AliRsnPIDIndex *fPerfectPID; // array index for perfect PID
- AliRsnPIDIndex *fRealisticPID; // array index for realistic PID (largest prob)
+ Bool_t AcceptTrackPID(AliRsnDaughter *d, AliPID::EParticleType type = AliPID::kUnknown);
- AliRsnPID::EType fSelPIDType; //! (for selection/cut functions) particle type
- Char_t fSelCharge; //! (for selection/cut functions) particle charge ('0' = both)
- AliRsnDaughter::EPIDMethod fSelPIDMethod; //! (for selection/cut functions) PID method used
- AliRsnCutSet *fSelCuts; //! (for selection/cut functions) track cuts used
+ AliVEvent *fRef; // pointer to input event (if it is an AOD, this is NULL)
+ AliMCEvent *fRefMC; // pointer to reference MC event (if any)
ClassDef(AliRsnEvent, 3);
};
//
#include <Riostream.h>
-
-#include <TH1.h>
-#include <TList.h>
#include <TString.h>
#include "AliLog.h"
-#include "AliRsnMCInfo.h"
#include "AliRsnDaughter.h"
#include "AliRsnEvent.h"
#include "AliRsnPairDef.h"
//________________________________________________________________________________________
AliRsnFunction::AliRsnFunction() :
- fFcnType(kFcnTypes),
- fRotAngle(0.0),
- fUseBins(kFALSE),
- fSkipOutsideInterval(kFALSE),
- fNumberOfBinTypes(0),
-// fBins(0),
-// fBinningCut(),
-// fBinningCutType(AliRsnCut::kLastCutType),
- fHistoDef(0x0)
+ TNamed(),
+ fFcnType(kFcnTypes),
+ fPairDef(0x0),
+ fTrack(0x0),
+ fPair(0x0),
+ fEvent(0x0),
+ fHistogram(0x0)
{
- //
- // Constructor.
- // The histogram data member cannot be passed externally,
- // its initialization MUST be defined inside the Init() method,
- // which must be overridden in any derivate implementation.
- //
-
- Int_t i, j;
- for (j = 0 ; j < kFcnBinTypes; j++)
- for (i = 0; i < 100; i++)
- fHisto[j][i] = 0x0;
+//
+// Constructor for 1D functions.
+// Requires only the binning of the output function,
+// which is stored as 'main' histoDef in fHistoDef[0]
+//
+ fBinType[0] = kNoBins;
+ fBinType[1] = kNoBins;
+
+ fHistoDef[0] = 0x0;
+ fHistoDef[1] = 0x0;
+ fHistoDef[2] = 0x0;
}
//________________________________________________________________________________________
AliRsnFunction::AliRsnFunction
-(EFcnType type, AliRsnHistoDef *hd, Bool_t skipOut) :
- fFcnType(type),
- fRotAngle(0.0),
- fUseBins(kFALSE),
- fSkipOutsideInterval(skipOut),
- fNumberOfBinTypes(0),
-// fBins(0),
-// fBinningCut(),
-// fBinningCutType(AliRsnCut::kLastCutType),
- fHistoDef(hd)
+(EFcnType fcnType, AliRsnHistoDef *hd) :
+ TNamed(),
+ fFcnType(fcnType),
+ fPairDef(0x0),
+ fTrack(0x0),
+ fPair(0x0),
+ fEvent(0x0),
+ fHistogram(0x0)
{
- //
- // Constructor.
- // The histogram data member cannot be passed externally,
- // its initialization MUST be defined inside the Init() method,
- // which must be overridden in any derivate implementation.
- //
-
- Int_t i, j;
- for (j = 0 ; j < kFcnBinTypes; j++)
- for (i = 0; i < 100; i++)
- fHisto[j][i] = 0x0;
-}
+//
+// Constructor for 1D functions.
+// Requires only the binning of the output function,
+// which is stored as 'main' histoDef in fHistoDef[0]
+//
-//________________________________________________________________________________________
-AliRsnFunction::AliRsnFunction(const AliRsnFunction ©) :
- TObject(copy),
- fFcnType(copy.fFcnType),
- fRotAngle(copy.fRotAngle),
- fUseBins(copy.fUseBins),
- fSkipOutsideInterval(copy.fSkipOutsideInterval),
- fNumberOfBinTypes(copy.fNumberOfBinTypes),
-// fBins(0),
-// fBinningCut(),
-// fBinningCutType(AliRsnCut::kLastCutType),
- fHistoDef(copy.fHistoDef)
-{
- //
- // Copy constructor.
- // Calls the function to define binning.
- //
+ fBinType[0] = kNoBins;
+ fBinType[1] = kNoBins;
- Int_t i, j, n;
- for (j = 0 ; j < kFcnBinTypes; j++)
- for (i = 0; i < 100; i++)
- fHisto[j][i] = 0x0;
+ fHistoDef[0] = hd;
+ fHistoDef[1] = 0x0;
+ fHistoDef[2] = 0x0;
- if (fUseBins)
- {
- for (i = 0 ; i < kFcnBinTypes; i++){
- if (fNumberOfBinTypes<=i) continue;
- n = copy.fBins[i].GetSize();
- Double_t *array = new Double_t[n];
- for (j = 0; j < n; j++) array[j] = copy.fBins[i][j];
- SetBinningCut(copy.fBinningCutType[i], copy.fBins[i].GetSize(), array,i,kTRUE);
- delete [] array;
- }
- }
+ DefineName();
}
-//________________________________________________________________________________________
-const AliRsnFunction& AliRsnFunction::operator=(const AliRsnFunction& /*copy*/)
-{
- //
- // Assignment operator.
- // Behaves like copy constructor.
- // Also in this case, the histogram is not copied, and,
- // if it was present, it is destroyed and will need to be recreated.
- //
- return (*this);
-}
//________________________________________________________________________________________
-void AliRsnFunction::Clear(Option_t* /*option*/)
+AliRsnFunction::AliRsnFunction
+(EFcnType fcnType, EBinType binType, AliRsnHistoDef *hdMain, AliRsnHistoDef *hdBin) :
+ TNamed(),
+ fFcnType(fcnType),
+ fPairDef(0x0),
+ fTrack(0x0),
+ fPair(0x0),
+ fEvent(0x0),
+ fHistogram(0x0)
{
- //
- // Clear arrays and histogram.
- // For the sake of security, all pointers are also set explicitly to NULL.
- //
-
- Int_t i, j;
- for (j = 0 ; j < kFcnBinTypes; j++)
- for (i = 0; i < 100; i++)
- {
- delete fHisto[j][i];
- fHisto[j][i] = 0x0;
- }
-}
+//
+// Constructor for 2D functions.
+// Requires the binning of the output function,
+// which is stored as 'main' histoDef in fHistoDef[0],
+// and a definition for a secondary binning, stored in fHistoDef[1]
+//
-//________________________________________________________________________________________
-TList* AliRsnFunction::Init(const char *histoName, const char *histoTitle)
-{
- //
- // Initialization function.
- // By default, it initializes the owned histogram using the method
- // from AliRsnHistoDef class, giving the same name and title of this.
- // A user can override this behaviour, if necessary.
- // Before creating, the HistoDef is checked for proper initialization.
- //
-
- Clear();
-
- Int_t i, ibin, nbins = fHistoDef->GetNBins();
- Double_t min = fHistoDef->GetMin(), max = fHistoDef->GetMax();
-
- // list is created and named after the general
- // settings used for the contained histograms
- TList *histos = new TList;
- histos->SetName(Form("%s", GetFcnName().Data()));
-
- // a general histogram is always added,
- // which overrides the binning and collects everything
-
- fHisto[0][0] = new TH1D(histoName, histoTitle, nbins, min, max);
- fHisto[0][0]->Sumw2();
- histos->AddLast(fHisto[0][0]);
-
- // if requested a binning w.r. to some cut variable, histograms are added
- // for that in this part of the method (one per each bin)
- Char_t hName[255];
- Char_t hTitle[255];
- Int_t j;
- if (fUseBins)
- {
- for (j = 0 ; j < kFcnBinTypes; j++){
- if (fNumberOfBinTypes<=j) continue;
- for (ibin = 0, i = 1; ibin < fBins[j].GetSize() - 1; ibin++, i++)
- {
- sprintf(hName, "%s_%d%02d_[%.2f-%.2f]", histoName, j,i,fBins[j][ibin], fBins[j][ibin+1]);
- sprintf(hTitle, "%s [%.2f-%.2f]", histoTitle, fBins[j][ibin], fBins[j][ibin+1]);
-// AliInfo(Form("Adding %s",hName));
- fHisto[j][i] = new TH1D(hName, hTitle, nbins, min, max);
- fHisto[j][i]->Sumw2();
- histos->AddLast(fHisto[j][i]);
- }
- }
- }
+ fBinType[0] = binType;
+ fBinType[1] = kNoBins;
- // returns the full list at the end
- return histos;
+ fHistoDef[0] = hdMain;
+ fHistoDef[1] = hdBin;
+ fHistoDef[2] = 0x0;
+
+ DefineName();
}
//________________________________________________________________________________________
-void AliRsnFunction::Init(const char *histoName, const char *histoTitle, TList *histos)
+AliRsnFunction::AliRsnFunction
+(EFcnType fcnType, EBinType binType1, EBinType binType2,
+ AliRsnHistoDef *hdMain, AliRsnHistoDef *hdBin1, AliRsnHistoDef *hdBin2) :
+ fFcnType(fcnType),
+ fPairDef(0x0),
+ fTrack(0x0),
+ fPair(0x0),
+ fEvent(0x0),
+ fHistogram(0x0)
{
- //
- // Initialization function.
- // By default, it initializes the owned histogram using the method
- // from AliRsnHistoDef class, giving the same name and title of this.
- // A user can override this behaviour, if necessary.
- // Before creating, the HistoDef is checked for proper initialization.
- //
-
- Clear();
-
- Int_t i, ibin, nbins = fHistoDef->GetNBins();
- Double_t min = fHistoDef->GetMin(), max = fHistoDef->GetMax();
-
- // list is created and named after the general
- // settings used for the contained histograms
- if (!histos)
- {
- AliError("NULL target list!");
- return;
- }
+//
+// Constructor for 3D functions.
+// Requires the binning of the output function,
+// which is stored as 'main' histoDef in fHistoDef[0],
+// and a definition for two secondary binnings, stored in fHistoDef[1,2]
+//
- // a general histogram is always added,
- // which overrides the binning and collects everything
- fHisto[0][0] = new TH1D(histoName, histoTitle, nbins, min, max);
- histos->AddLast(fHisto[0][0]);
-
- // if requested a binning w.r. to some cut variable, histograms are added
- // for that in this part of the method (one per each bin)
- Char_t hName[255];
- Char_t hTitle[255];
- Int_t j;
- if (fUseBins)
- {
- for (j = 0 ; j < kFcnBinTypes; j++){
- if (fNumberOfBinTypes<=j) continue;
- for (ibin = 0, i = 1; ibin < fBins[j].GetSize() - 1; ibin++, i++)
- {
-
- sprintf(hName, "%s_%d_%02d[%.2f-%.2f]", histoName,j,i, fBins[j][ibin], fBins[j][ibin+1]);
- sprintf(hTitle, "%s [%.2f-%.2f]", histoTitle, fBins[j][ibin], fBins[j][ibin+1]);
-// AliInfo(Form("Adding %s",hName));
- fHisto[j][i] = new TH1D(hName, hTitle, nbins, min, max);
- histos->AddLast(fHisto[j][i]);
- }
- }
- }
-}
+ fBinType[0] = binType1;
+ fBinType[1] = binType2;
+
+ fHistoDef[0] = hdMain;
+ fHistoDef[1] = hdBin1;
+ fHistoDef[2] = hdBin2;
+
+ DefineName();
+}
//________________________________________________________________________________________
-void AliRsnFunction::SetBinningCut
-(AliRsnCut::EType type, Double_t min, Double_t max, Double_t step,Int_t index,Bool_t IsCopyConstructor)
+AliRsnFunction::AliRsnFunction(const AliRsnFunction ©) :
+ TNamed(copy),
+ fFcnType(copy.fFcnType),
+ fPairDef(copy.fPairDef),
+ fTrack(copy.fTrack),
+ fPair(copy.fPair),
+ fEvent(copy.fEvent),
+ fHistogram(0x0)
{
- //
- // Set fixed bins
- //
+//
+// Copy constructor.
+//
- if (index >= kFcnBinTypes) {
- AliError(Form("We support only %d Binning cuts(0-%d). Skipping...",kFcnBinTypes,kFcnBinTypes-1));
- return;
- }
-
- if (!IsCopyConstructor){
- // TODO if some one sets indexes 0,2,3 it is a bug here(i'll solve it)
- if (index == fNumberOfBinTypes)
- fNumberOfBinTypes++;
- else {
- AliError(Form("Wrong index %d. fUseBins is set to kFALSE",index));
-// fUseBins = kFALSE;
- return;
- }
+ Int_t i;
+ for (i = 0; i < 3; i++) {
+ fHistoDef[i] = copy.fHistoDef[i];
+ if (i < 2) fBinType[i] = copy.fBinType[i];
}
- fUseBins = kTRUE;
- Int_t i, nBins = (Int_t)((max - min) / step) + 1;
- fBinningCutType[index] = type;
- fBins[index].Set(nBins);
- for (i = 0; i < nBins; i++)
- {
- fBins[index][i] = min + (Double_t)i * step;
- }
+ DefineName();
}
//________________________________________________________________________________________
-void AliRsnFunction::SetBinningCut
-(AliRsnCut::EType type, Int_t nbins, Double_t *bins,Int_t index,Bool_t IsCopyConstructor)
+const AliRsnFunction& AliRsnFunction::operator=(const AliRsnFunction& copy)
{
- //
- // Set variable bins
- //
+//
+// Assignment operator.
+//
+
+ SetName(copy.GetName());
+ SetTitle(copy.GetTitle());
+
+ fFcnType = copy.fFcnType;
+
+ fPairDef = copy.fPairDef;
- if (index >= kFcnBinTypes) {
- AliError(Form("We support only %d Binning cuts(0-%d). Skipping...",kFcnBinTypes,kFcnBinTypes-1));
- return;
- }
- if (!IsCopyConstructor){
- // TODO if some one sets indexes 0,2,3 it is a bug here(i'll solve it)
- if (index >= fNumberOfBinTypes)
- fNumberOfBinTypes++;
- else {
- AliError(Form("Wrong index %d (%d). fUseBins is set to kFALSE",index,fNumberOfBinTypes));
- // fUseBins = kFALSE;
- return;
- }
- }
-
- fUseBins = kTRUE;
Int_t i;
- fBinningCutType[index] = type;
- fBins[index].Set(nbins);
- for (i = 0; i < nbins; i++)
- {
- fBins[index][i] = bins[i];
+ for (i = 0; i < 3; i++) {
+ fHistoDef[i] = copy.fHistoDef[i];
+ if (i < 2) fBinType[i] = copy.fBinType[i];
}
+
+ fTrack = copy.fTrack;
+ fPair = copy.fPair;
+ fEvent = copy.fEvent;
+
+ if (fHistogram) delete fHistogram;
+ fHistogram = 0x0;
+
+ DefineName();
+
+ return (*this);
}
//________________________________________________________________________________________
-TString AliRsnFunction::GetFcnName()
+const char* AliRsnFunction::FcnName()
{
- //
- // Return a string which names the function type
- //
-
- TString text("Undef");
+//
+// Defines the name of this object according to
+// the function type and binning
+//
switch (fFcnType)
{
+ case kTrackPt:
+ return "TRKPT";
+ break;
+ case kTrackEta:
+ return "TRKETA";
+ break;
case kInvMass:
- text = "IM";
+ return "IM";
break;
case kInvMassMC:
- text = "IM_MC";
- break;
- case kInvMassRotated:
- text = Form("IMR%.2f", fRotAngle);
+ return "IMMC";
break;
case kResolution:
- text = "RES";
+ return "RES";
break;
- case kPtSpectrum:
- text = "PT";
+ case kPairPt:
+ return "PT";
break;
- case kEtaSpectrum:
- text = "ETA";
+ case kPairEta:
+ return "ETA";
+ break;
+ case kEventMult:
+ return "MULT";
break;
default:
- AliError("Type not defined");
+ return "UNDEF";
}
-
- return text;
}
//________________________________________________________________________________________
-TString AliRsnFunction::GetFcnTitle()
+void AliRsnFunction::DefineName()
{
- //
- // Return a string which names the function type
- //
+//
+// Defines the name of this object according to
+// the function type and binning
+//
- TString text("Undef");
+ Int_t dim = CheckDim();
- switch (fFcnType)
+ switch (dim)
{
- case kInvMass:
- text = "Invariant mass";
+ case 1:
+ SetName(FcnName());
break;
- case kInvMassMC:
- text = "Invariant mass (MC)";
+ case 2:
+ SetName(Form("%s_%s", FcnName(), BinName(fBinType[0])));
break;
- case kResolution:
- text = "Resolution";
- break;
- case kPtSpectrum:
- text = "p_{#perp} distribution";
- break;
- case kEtaSpectrum:
- text = "#eta distribution";
+ case 3:
+ SetName(Form("%s_%s_%s", FcnName(), BinName(fBinType[0]), BinName(fBinType[1])));
break;
default:
- AliError("Type not defined");
+ SetName("UNDEF");
}
-
- return text;
}
//________________________________________________________________________________________
-Bool_t AliRsnFunction::Fill(AliRsnPairParticle *pair, AliRsnPairDef *ref)
+Double_t AliRsnFunction::Eval()
{
- //
- // Fillse the histogram with data contained in a defined pair.
- // This method must be overidden by an appropriate definition in each inheriting class.
- //
+//
+// Compute value for functions with 'event' argument type
+//
+
+ Double_t value;
- Double_t value = FcnValue(pair, ref);
- if (fSkipOutsideInterval)
+ switch (fFcnType)
{
- if (value < fHistoDef->GetMin()) return kFALSE;
- if (value > fHistoDef->GetMax()) return kFALSE;
+ case kTrackPt:
+ return fTrack->Pt();
+ case kTrackEta:
+ return fTrack->Eta();
+ case kInvMass:
+ return fPair->GetInvMass(fPairDef->GetMass(0), fPairDef->GetMass(1));
+ case kInvMassMC:
+ return fPair->GetInvMassMC(fPairDef->GetMass(0), fPairDef->GetMass(1));
+ case kResolution:
+ value = fPair->GetInvMass(fPairDef->GetMass(0), fPairDef->GetMass(1));
+ value -= fPair->GetInvMassMC(fPairDef->GetMass(0), fPairDef->GetMass(1));
+ value /= fPair->GetInvMassMC(fPairDef->GetMass(0), fPairDef->GetMass(1));
+ return value;
+ case kPairPt:
+ return fPair->GetPt();
+ case kPairEta:
+ return fPair->GetEta();
+ case kEventMult:
+ return fEvent->GetMultiplicity();
+ default:
+ AliWarning("Function type not supported");
+ return -999.0;
+ }
+}
+
+//_________________________________________________________________________________________________
+Bool_t AliRsnFunction::CheckInput(Option_t *option)
+{
+//
+// Checks if the argument type is coherent with
+// the function type required
+//
+
+ TString opt(option);
+ opt.ToUpper();
+
+ if (opt.Contains("TRACK")) {
+ if (!fTrack) {
+ AliError("Input track object is NULL");
+ return kFALSE;
+ }
}
- // fill global histogram
- fHisto[0][0]->Fill(value);
+ if (opt.Contains("PAIR")) {
+ if (!fPair) {
+ AliError("Input pair object is NULL");
+ return kFALSE;
+ }
+ }
- // if bins are allocated, find right one and fill it
- if (fUseBins)
- {
- Int_t i, j, ibin;
- for (j = 0 ; j < kFcnBinTypes; j++){
- if (fNumberOfBinTypes<=j) continue;
- for (ibin = 0, i = 1; ibin < fBins[j].GetSize() - 1; ibin++, i++)
- {
- if (!fHisto[j][i]) continue;
- fBinningCut[j].SetCutValues(fBinningCutType[j], fBins[j][ibin], fBins[j][ibin+1]);
- if (fBinningCut[j].IsSelected(AliRsnCut::kPair, pair))
- {
- fHisto[j][i]->Fill(value);
- break;
- }
- }
+ if (opt.Contains("EVENT")) {
+ if (!fEvent) {
+ AliError("Input event object is NULL");
+ return kFALSE;
}
}
}
//________________________________________________________________________________________
-Double_t AliRsnFunction::FcnValue(AliRsnPairParticle *pair, AliRsnPairDef *ref)
+TH1* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTitle)
{
- //
- // This method must be overridden in all inheritin functions.
- // It computes the value which must be used to fill the histogram.
- //
+//
+// Creates and returns the histogram defined using
+// arguments fo name and title, and the first histoDef for binning.
+// Variable-sized histogram binning is always called, due to use of histoDef,
+// even if the bins are equal, since they are defined in this class.
+// Eventually present histoDef's in other slots of array (1, 2) are ignored.
+//
- switch (fFcnType)
+ // first binning is required
+ if (!fHistoDef[0]) return 0;
+
+ // retrieve binnings for main and secondary axes
+ Int_t i, nbins[3] = {0, 0, 0};
+ Double_t min[3] = {0., 0., 0.}, max[3] = {0., 0., 0.};
+ for (i = 0; i < 3; i++)
{
+ if (fHistoDef[i])
+ {
+ nbins[i] = fHistoDef[i]->GetNBins();
+ min[i] = fHistoDef[i]->GetMin();
+ max[i] = fHistoDef[i]->GetMax();
+ }
+ }
+
+ // define the kind of output according to the number of histoDefs
+ if (fHistogram) delete fHistogram;
+ if (!nbins[1] && !nbins[2]) {
+ fHistogram = new TH1D(histoName, histoTitle, nbins[0], min[0], max[0]);
+ fHistogram->SetXTitle(FcnName());
+ }
+ else if (nbins[1] > 0 && !nbins[2]) {
+ fHistogram = new TH2D(histoName, histoTitle, nbins[0], min[0], max[0], nbins[1], min[1], max[1]);
+ fHistogram->SetXTitle(FcnName());
+ fHistogram->SetYTitle(BinName(fBinType[0]));
+ }
+ else {
+ fHistogram = new TH3D(histoName, histoTitle, nbins[0], min[0], max[0], nbins[1], min[1], max[1], nbins[2], min[2], max[2]);
+ fHistogram->SetXTitle(FcnName());
+ fHistogram->SetYTitle(BinName(fBinType[0]));
+ fHistogram->SetZTitle(BinName(fBinType[1]));
+ }
+
+ fHistogram->Sumw2();
+
+ return fHistogram;
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnFunction::Fill()
+{
+//
+// Fill function histogram with values computed from given input object.
+//
+ AliDebug(AliLog::kDebug +2,"->");
+
+ // checks coherence between fcn type and passed argument
+ switch (fFcnType) {
+ case kTrackPt:
+ case kTrackEta:
+ if (!CheckInput("TRACK")) return kFALSE;
+ break;
case kInvMass:
- return pair->GetInvMass(ref->GetMass(0), ref->GetMass(1));
case kInvMassMC:
- return pair->GetInvMassMC(ref->GetMass(0), ref->GetMass(1));
- case kInvMassRotated:
- //AliInfo(Form("*** ROTATION ANGLE = %f ***", fRotAngle));
- //AliInfo(Form("UNROTATED INV MASS = %f", pair->GetInvMass(ref->GetMass(0), ref->GetMass(1))));
- //pair->GetDaughter(1)->Print("P");
- pair->GetDaughter(1)->RotateP(fRotAngle * TMath::DegToRad());
- pair->ResetPair();
- //AliInfo(Form(" ROTATED INV MASS = %f", pair->GetInvMass(ref->GetMass(0), ref->GetMass(1))));
- //pair->GetDaughter(1)->Print("P");
- return pair->GetInvMass(ref->GetMass(0), ref->GetMass(1));
case kResolution:
- return FcnResolution(pair, ref);
- case kPtSpectrum:
- return pair->GetPt();
- case kEtaSpectrum:
- return pair->GetEta();
+ case kPairPt:
+ case kPairEta:
+ if (!CheckInput("PAIR")) return kFALSE;
+ break;
+ case kEventMult:
+ if (!CheckInput("EVENT")) return kFALSE;
+ break;
+ default:
+ AliError(Form("Input type %d not defined", (Int_t)fFcnType));
+ return kFALSE;
+ }
+
+ // check presence of output histogram
+ if (!fHistogram) {
+ AliError("Histogram is not yet initialized");
+ return kFALSE;
+ }
+
+ // compute value and stores into histogram
+ Int_t dim = CheckDim();
+ Double_t mainValue, binValue[2];
+
+ TH1D *h1 = dynamic_cast<TH1D*>(fHistogram);
+ TH2D *h2 = dynamic_cast<TH2D*>(fHistogram);
+ TH3D *h3 = dynamic_cast<TH3D*>(fHistogram);
+
+ mainValue = Eval();
+
+ switch (dim)
+ {
+ case 1:
+ if (h1) h1->Fill(mainValue);
+ break;
+ case 2:
+ binValue[0] = BinValue(fBinType[0]);
+ if (h2) h2->Fill(mainValue, binValue[0]);
+ break;
+ case 3:
+ binValue[0] = BinValue(fBinType[0]);
+ binValue[1] = BinValue(fBinType[1]);
+ if (h3) h3->Fill(mainValue, binValue[0], binValue[1]);
+ break;
default:
- AliError("Type not defined");
+ AliError("Wrong number of dimensions in the histogram. Check HD initialization");
+ return kFALSE;
}
- return 0.0;
+ AliDebug(AliLog::kDebug +2,"->");
+ return kTRUE;
}
//________________________________________________________________________________________
-inline Double_t AliRsnFunction::FcnResolution(AliRsnPairParticle *pair, AliRsnPairDef *ref)
+Double_t AliRsnFunction::BinValue(EBinType binType)
{
- //
- // Invariant mass resolution (compared between reconstructed and montecarlo)
- //
+//
+// Computes the value for binning from the argument.
+// For each kind of binning type, the object is expected
+// to be of a given type, otherwise an error is raised.
+//
- Double_t recInvMass = pair->GetInvMass(ref->GetMass(0), ref->GetMass(1));
- Double_t simInvMass = pair->GetInvMassMC(ref->GetMass(0), ref->GetMass(1));
+ // checks coherence between bin type and passed argument
+ switch (binType) {
+ case kBinPairPt:
+ if (!CheckInput("PAIR")) return 0.0;
+ return fPair->GetPt();
+ case kBinPairEta:
+ if (!CheckInput("PAIR")) return 0.0;
+ return fPair->GetEta();
+ case kBinEventMult:
+ if (!CheckInput("EVENT")) return 0.0;
+ return fEvent->GetMultiplicity();
+ default:
+ AliError(Form("%s: Binning type not defined", GetName()));
+ return 0.0;
+ }
+}
+
+//________________________________________________________________________________________
+Int_t AliRsnFunction::CheckDim()
+{
+//
+// Checks number of dimensions.
+// Makes sure that eventual binnings are coherent and well defined
+//
+
+ if (!fHistoDef[0]) return 0;
+ if (fHistoDef[0] && !fHistoDef[1] && !fHistoDef[2]) return 1;
+ if (fHistoDef[0] && fHistoDef[1] && !fHistoDef[2]) return 2;
- return (simInvMass - recInvMass) / simInvMass;
+ return 3;
}
+
+//________________________________________________________________________________________
+const char* AliRsnFunction::BinName(EBinType binType)
+{
+//
+// Defines the name of binning
+//
+
+ switch (binType)
+ {
+ case kBinPairPt:
+ return "PT";
+ break;
+ case kBinPairEta:
+ return "ETA";
+ break;
+ case kBinEventMult:
+ return "MULT";
+ break;
+ default:
+ return "UNDEF";
+ }
+}
\ No newline at end of file
// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
//
-#ifndef ALIRSNFUNCTION_H
-#define ALIRSNFUNCTION_H
+#ifndef ALIRSNFunction_H
+#define ALIRSNFunction_H
-#include <TArrayD.h>
-#include <TString.h>
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TNamed.h>
#include "AliRsnCut.h"
#include "AliRsnHistoDef.h"
#include "AliRsnPairParticle.h"
-class TH1D;
-class TH2D;
-class AliRsnEvent;
+class TH1;
+class AliRsnPairDef;
-class AliRsnFunction : public TObject
+class AliRsnFunction : public TNamed
{
public:
enum EFcnType
{
+ kTrackPt = 0,
+ kTrackEta,
kInvMass,
kInvMassMC,
- kInvMassRotated,
kResolution,
- kPtSpectrum,
- kEtaSpectrum,
+ kPairPt,
+ kPairEta,
+ kEventMult,
kFcnTypes
};
- enum EFcnBinTypes
+
+ enum EBinType
{
- kFcnBinTypes=5
+ kNoBins = 0,
+ kBinPairPt,
+ kBinPairEta,
+ kBinEventMult,
+ kBinTypes
};
AliRsnFunction();
- AliRsnFunction(EFcnType type, AliRsnHistoDef *hd, Bool_t skipOut = kTRUE);
+ AliRsnFunction(EFcnType fcnType, AliRsnHistoDef *hd);
+ AliRsnFunction(EFcnType fcnType, EBinType binType, AliRsnHistoDef *hdMain, AliRsnHistoDef *hdBin);
+ AliRsnFunction(EFcnType fcnType, EBinType binType1, EBinType binType2, AliRsnHistoDef *hdMain, AliRsnHistoDef *hdBin1, AliRsnHistoDef *hdBin2);
AliRsnFunction(const AliRsnFunction ©);
- virtual ~AliRsnFunction() {Clear();}
- virtual void Clear(Option_t *option = "");
+ virtual ~AliRsnFunction() { delete fHistogram; }
+ const AliRsnFunction& operator=(const AliRsnFunction ©);
- Bool_t UseBins() {return fUseBins;}
- Bool_t SkipOut() {return fSkipOutsideInterval;}
- AliRsnHistoDef* GetHistoDef() {return fHistoDef;}
- TString GetFcnName();
- TString GetFcnTitle();
+ void DefineName();
- void SetBinningCut(AliRsnCut::EType type, Double_t min, Double_t max, Double_t step,Int_t index=0,Bool_t IsCopyConstructor=kFALSE);
- void SetBinningCut(AliRsnCut::EType type, Int_t nbins, Double_t *bins,Int_t index=0,Bool_t IsCopyConstructor=kFALSE);
- void SetHistoDef(AliRsnHistoDef *def) {fHistoDef = def;}
- void SetRotationAngle(Double_t rotAngle) {fRotAngle = rotAngle;}
+ void SetFcnType(EFcnType value) {fFcnType = value;}
+ void SetPairDef(AliRsnPairDef *def) {fPairDef = def;}
+ void SetTrack(AliRsnDaughter *track) {fTrack = track;}
+ void SetPair(AliRsnPairParticle *pair) {fPair = pair;}
+ void SetEvent(AliRsnEvent *event) {fEvent = event;}
+ void SetMainHistoDef(AliRsnHistoDef *hd) {fHistoDef[0] = hd;}
+ void SetPrimaryBinningHistoDef(AliRsnHistoDef *hd) {fHistoDef[1] = hd;}
+ void SetSecondaryBinningHistoDef(AliRsnHistoDef *hd) {fHistoDef[2] = hd;}
- // working routines
- TList* Init(const char *histoName, const char *histoTitle);
- void Init(const char *histoName, const char *histoTitle, TList *tgt);
- Bool_t Fill(AliRsnPairParticle *pair, AliRsnPairDef *ref);
- Double_t FcnValue(AliRsnPairParticle *pair, AliRsnPairDef *ref);
+ EFcnType GetFcnType() {return fFcnType;}
+ AliRsnPairDef* GetPairDef() {return fPairDef;}
+ AliRsnDaughter* GetTrack() {return fTrack;}
+ AliRsnPairParticle* GetPair() {return fPair;}
+ AliRsnEvent* GetEvent() {return fEvent;}
+ AliRsnHistoDef* GetMainHistoDef(AliRsnHistoDef *hd) {return fHistoDef[0];}
+ AliRsnHistoDef* GetPrimaryBinningHistoDef(AliRsnHistoDef *hd) {return fHistoDef[1];}
+ AliRsnHistoDef* GetSecondaryBinningHistoDef(AliRsnHistoDef *hd) { return fHistoDef[2];}
- private:
+ TH1* CreateHistogram(const char *histoName, const char *histoTitle);
- const AliRsnFunction& operator=(const AliRsnFunction ©);
+ Double_t Eval();
+ Bool_t Fill();
- Double_t FcnResolution(AliRsnPairParticle *pair, AliRsnPairDef *pd);
+ protected:
- EFcnType fFcnType; // function type
+ Int_t CheckDim();
+ Bool_t CheckInput(Option_t *option);
+ const char* BinName(EBinType binType);
+ const char* FcnName();
+ Double_t BinValue(EBinType binType);
- Double_t fRotAngle; // rotation angle (for "rotated" invMass)
+ EFcnType fFcnType; // function type
+ EBinType fBinType[2]; // binning type
- Bool_t fUseBins; // flag to choose if binning is used
- Bool_t fSkipOutsideInterval; // skip pairs which fall outside histogram interval
+ AliRsnPairDef *fPairDef; // reference to used pair definition
+ AliRsnHistoDef *fHistoDef[3]; // histogram definition for each axis
- Int_t fNumberOfBinTypes; // number of binning types
- TArrayD fBins[kFcnBinTypes]; // low edge of each bin (upper is the low edge of next bin)
- AliRsnCut fBinningCut[kFcnBinTypes]; // binning cut
- AliRsnCut::EType fBinningCutType[kFcnBinTypes]; // binning cut type
+ AliRsnDaughter *fTrack; // processed track
+ AliRsnPairParticle *fPair; // processed pair
+ AliRsnEvent *fEvent; // processed event
- AliRsnHistoDef *fHistoDef; // definitions for histogram
- TH1D *fHisto[kFcnBinTypes][100]; // binned histograms
+ TH1 *fHistogram; // output histogram
// ROOT dictionary
- ClassDef(AliRsnFunction, 1)
+ ClassDef(AliRsnFunction, 2)
};
#endif
SetBins(nbins, min, max);
}
+//_____________________________________________________________________________
+AliRsnHistoDef::AliRsnHistoDef
+(Double_t min, Double_t max, Double_t step) :
+ fNBins(0),
+ fMin(0.0),
+ fMax(0.0)
+{
+//
+// 1D histo definition.
+//
+ SetBins(min, max, step);
+}
+
//_____________________________________________________________________________
void AliRsnHistoDef::SetBins(Int_t n, Double_t min, Double_t max)
{
//
// Binning for histogram.
//
+
fNBins = n;
if (min < max)
fMax = min;
}
}
+
+//_____________________________________________________________________________
+void AliRsnHistoDef::SetBins(Double_t min, Double_t max, Double_t step)
+{
+//
+// Binning for histogram.
+//
+
+ if (min < max)
+ {
+ fMin = min;
+ fMax = max;
+ }
+ else
+ {
+ fMin = max;
+ fMax = min;
+ }
+
+ fNBins = (Int_t)((fMax - fMin) / (step)) + 1;
+}
AliRsnHistoDef();
AliRsnHistoDef(Int_t n, Double_t min, Double_t max);
+ AliRsnHistoDef(Double_t min, Double_t max, Double_t step);
virtual ~AliRsnHistoDef() { }
Int_t GetNBins() const {return fNBins;}
Double_t GetMax() const {return fMax;}
void SetBins(Int_t n, Double_t min, Double_t max);
+ void SetBins(Double_t min, Double_t max, Double_t step);
private:
#include "AliLog.h"
#include "AliESDtrack.h"
-
-#include "AliRsnPID.h"
+#include "AliRsnDaughter.h"
#include "AliRsnPIDDefESD.h"
ClassImp(AliRsnPIDDefESD)
}
Double_t pt = track->Pt();
- Double_t w[kDetectors][AliRsnPID::kSpecies];
+ Double_t w[kDetectors][AliPID::kSPECIES];
track->GetITSpid(w[kITS]);
track->GetTPCpid(w[kTPC]);
track->GetTRDpid(w[kTRD]);
for (i = 0; i < kDetectors; i++) {
// if (!fUseDet[i] || pt < fDivValue[i])
if (!fUseDet[i] || !CheckDivValue((EDetector)i,pt)) {
- for (j = 0; j < AliRsnPID::kSpecies; j++) {
+ for (j = 0; j < AliPID::kSPECIES; j++) {
w[i][j] = 1.0;
}
}
}
- for (i = 0; i < AliRsnPID::kSpecies; i++) {
+ for (i = 0; i < AliPID::kSPECIES; i++) {
weights[i] = w[kITS][i] * w[kTPC][i] * w[kTRD][i] * w[kTOF][i] * w[kHMPID][i];
}
}
#include <TObject.h>
#include "AliLog.h"
+#include "AliESDtrack.h"
+#include "AliESDtrackCuts.h"
#include "AliRsnPIDIndex.h"
//
// Default constructor
//
- Int_t i, j, k;
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < AliRsnPID::kSpecies+1; j++)
- {
- fNumOfIndex[i][j] = 0;
- fIndex[i][j].Set(num);
- for (k = 0; k < num; k++) fIndex[i][j].AddAt(-1, k);
+ Int_t i, j, k, l;
+
+ for (l = 0; l < AliRsnDaughter::kMethods; l++) {
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j <= AliPID::kSPECIES; j++) {
+ fNumOfIndex[l][i][j] = 0;
+ fIndex[l][i][j].Set(num);
+ for (k = 0; k < num; k++) fIndex[l][i][j].AddAt(-1, k);
+ }
}
}
}
// to store a copy of all objects.
//
- Int_t i, j, k, size;
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < AliRsnPID::kSpecies+1; j++)
- {
- fNumOfIndex[i][j] = copy.fNumOfIndex[i][j];
- size = copy.fIndex[i][j].GetSize();
- fIndex[i][j].Set(size);
- for (k = 0; k < size; k++)
- {
- fIndex[i][j].AddAt(copy.fIndex[i][j].At(k), k);
+ Int_t l, i, j, k, size;
+
+ for (l = 0; l < AliRsnDaughter::kMethods; l++) {
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j <= AliPID::kSPECIES; j++) {
+ fNumOfIndex[l][i][j] = copy.fNumOfIndex[l][i][j];
+ size = copy.fIndex[l][i][j].GetSize();
+ fIndex[l][i][j].Set(size);
+ for (k = 0; k < size; k++) {
+ fIndex[l][i][j].AddAt(copy.fIndex[l][i][j].At(k), k);
+ }
}
}
}
// to store a copy of all objects.
//
- Int_t i, j, k, size;
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < AliRsnPID::kSpecies+1; j++)
- {
- fNumOfIndex[i][j] = copy.fNumOfIndex[i][j];
- size = copy.fIndex[i][j].GetSize();
- fIndex[i][j].Set(size);
- for (k = 0; k < size; k++)
- {
- fIndex[i][j].AddAt(copy.fIndex[i][j].At(k), k);
+ Int_t l, i, j, k, size;
+
+ for (l = 0; l < AliRsnDaughter::kMethods; l++) {
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < AliPID::kSPECIES; j++) {
+ fNumOfIndex[l][i][j] = copy.fNumOfIndex[l][i][j];
+ size = copy.fIndex[l][i][j].GetSize();
+ fIndex[l][i][j].Set(size);
+ for (k = 0; k < size; k++) {
+ fIndex[l][i][j].AddAt(copy.fIndex[l][i][j].At(k), k);
+ }
}
}
}
// Does nothing.
//
}
-
//_____________________________________________________________________________
-void AliRsnPIDIndex::Print(Option_t* /*option*/) const
+void AliRsnPIDIndex::ResetAll(Int_t num)
{
//
-// Prints AliRsnPIDIndex info
+// Resets All
//
- Int_t i, j;
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < AliRsnPID::kSpecies + 1; j++)
- {
- AliInfo(Form(" [%d][%d] %d %d", i, j, fIndex[i][j].GetSize(), fNumOfIndex[i][j]));
+
+ Int_t i, j, k, l;
+
+ for (l = 0; l < AliRsnDaughter::kMethods; l++) {
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j <= AliPID::kSPECIES; j++) {
+ fNumOfIndex[l][i][j] = 0;
+ fIndex[l][i][j].Set(num);
+ for (k = 0; k < num; k++) fIndex[l][i][j].AddAt(-1, k);
+ }
}
}
}
//_____________________________________________________________________________
-void AliRsnPIDIndex::AddIndex(const Int_t index, Char_t sign, AliRsnPID::EType type)
+void AliRsnPIDIndex::Print(Option_t* /*option*/) const
{
//
-// Adds index to corresponding TArrayI
+// Prints AliRsnPIDIndex info
//
- Int_t iCharge = ChargeIndex(sign);
- Int_t iType = (Int_t)type;
- fIndex[iCharge][iType].AddAt(index, fNumOfIndex[iCharge][iType]);
- fNumOfIndex[iCharge][iType]++;
+ Int_t i, j, l;
+
+ for (l = 0; l < AliRsnDaughter::kMethods; l++) {
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j <= AliPID::kSPECIES; j++) {
+ AliInfo(Form(" [%d][%d][%d] %d %d",l, i, j, fIndex[l][i][j].GetSize(), fNumOfIndex[i][j]));
+ }
+ }
+ }
}
//_____________________________________________________________________________
-void AliRsnPIDIndex::AddIndex(const Int_t index, Short_t sign, Int_t type)
+void AliRsnPIDIndex::AddIndex(const Int_t index, AliRsnDaughter::EPIDMethod meth, Char_t sign, AliPID::EParticleType type)
{
//
// Adds index to corresponding TArrayI
//
- fIndex[sign][type].AddAt(index, fNumOfIndex[sign][type]);
- fNumOfIndex[sign][type]++;
+ Int_t iMethod = (Int_t)meth;
+ Int_t iCharge = ChargeIndex(sign);
+ Int_t iType = (Int_t)type;
+ // in AliPID kUnknown = 10 and kSPECIES = 5!
+ if (type == AliPID::kUnknown) iType = (Int_t)AliPID::kSPECIES;
+ AliDebug(AliLog::kDebug+1,Form("Adding index=%d method=%d sign='%c', pidType=%d",index,meth,sign,type));
+ fIndex[iMethod][iCharge][iType].AddAt(index, fNumOfIndex[iMethod][iCharge][iType]);
+ fNumOfIndex[iMethod][iCharge][iType]++;
+
}
//_____________________________________________________________________________
// Sets Correct sizes to all TArrayI
//
- Int_t i, j;
- for (i = 0; i < 2; i++)
- {
- for (j = 0; j < AliRsnPID::kSpecies + 1; j++)
- {
- fIndex[i][j].Set(fNumOfIndex[i][j]);
+ Int_t i, j, l;
+ for (l = 0; l < AliRsnDaughter::kMethods; l++) {
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j <= AliPID::kSPECIES; j++) {
+ fIndex[l][i][j].Set(fNumOfIndex[l][i][j]);
+ }
}
}
}
//_____________________________________________________________________________
-TArrayI* AliRsnPIDIndex::GetTracksArray(Char_t sign, AliRsnPID::EType type)
+TArrayI* AliRsnPIDIndex::GetTracksArray(AliRsnDaughter::EPIDMethod meth, Char_t sign, AliPID::EParticleType type)
{
//
// Returns the array of indexes of tracks whose charge
// Otherwise returns null pointer.
//
+ Int_t iMethod = (Int_t)meth;
Int_t icharge = ChargeIndex(sign);
+ Int_t itype = 0;
if (icharge < 0) return (TArrayI *) 0x0;
- if (type < AliRsnPID::kElectron || type > AliRsnPID::kSpecies)
- {
- AliError(Form("Index %d out of range", type));
+ if (type == AliPID::kUnknown) itype = (Int_t)AliPID::kSPECIES; else itype = (Int_t)type;
+ if (itype < 0 || itype > (Int_t)AliPID::kSPECIES) {
+ AliError(Form("Index %d out of range", itype));
return (TArrayI *) 0x0;
}
- return &fIndex[icharge][type];
+ return &fIndex[iMethod][icharge][itype];
}
//_____________________________________________________________________________
// corresponds to the passed argument
// Otherwise returns a null pointer.
//
+ return GetTracksArray(AliRsnDaughter::kNoPID, sign, AliPID::kUnknown);
- // check that argument is meaningful
- Int_t icharge = ChargeIndex(sign);
- if (icharge < 0) return (TArrayI *)0x0;
-
- // count total number of tracks with that charge
- // and create output object of appropriate size
- Int_t i, total = 0;
- for (i = 0; i <= AliRsnPID::kSpecies; i++) total += fIndex[icharge][i].GetSize();
- TArrayI *output = new TArrayI(total);
-
- // add all indexes
- Int_t j, counter = 0;
- for (i = 0; i <= AliRsnPID::kSpecies; i++)
- {
- for (j = 0; j < fIndex[icharge][i].GetSize(); j++)
- {
- output->AddAt(fIndex[icharge][i].At(j), counter++);
- }
- }
-
- return output;
}
//_____________________________________________________________________________
if (sign == '+') return 0;
else if (sign == '-') return 1;
- else
- {
+ else {
AliError(Form("Character '%c' not recognized as charge sign", sign));
return -1;
}
}
+
+//_____________________________________________________________________________
+Char_t AliRsnPIDIndex::IndexCharge(Short_t sign) const
+{
+ //
+ // Returns the array index corresponding to charge
+ //
+
+ if (sign == 1) return '+';
+ else if (sign == -1) return '-';
+ else {
+ AliError(Form("Charge is different the 0(+) and 1(-) value is '%d'...", sign));
+ return '+';
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnPIDIndex::FillFromEvent(AliRsnEvent* event, AliESDtrackCuts *cuts)
+{
+//
+// Fills indexes from event
+//
+
+ Int_t numOfTracks = event->GetMultiplicity();
+ AliRsnDaughter daughter;
+ Int_t i;
+ for (i=0;i<numOfTracks;i++) {
+ daughter = event->GetDaughter(i);
+ // if ESD track cuts are specified,
+ // and if the reference is an ESD track
+ // skip all tracks not passing the cut
+ if (cuts) {
+ AliESDtrack *track = daughter.GetRefESD();
+ if (track) if (!cuts->IsSelected(track)) continue;
+ }
+ daughter.CombineWithPriors(fPrior);
+// daughter.Print("ALL");
+
+ AddIndex(i,AliRsnDaughter::kNoPID,IndexCharge(daughter.Charge()),AliPID::kUnknown);
+ AddIndex(i,AliRsnDaughter::kRealistic,IndexCharge(daughter.Charge()),(AliPID::EParticleType)daughter.RealisticPID());
+ if (daughter.GetParticle())
+ AddIndex(i,AliRsnDaughter::kPerfect,IndexCharge(daughter.Charge()),(AliPID::EParticleType)daughter.PerfectPID());
+ }
+}
+
+
+//_____________________________________________________________________________
+void AliRsnPIDIndex::SetPriorProbability(AliPID::EParticleType type, Double_t p)
+{
+ //
+ // Sets the prior probability for Realistic PID, for a
+ // given particle species.
+ //
+
+ if (type >= 0 && type < (Int_t)AliPID::kSPECIES) {
+ fPrior[type] = p;
+ }
+
+}
+
+//_____________________________________________________________________________
+void AliRsnPIDIndex::DumpPriors()
+{
+ //
+ // Print all prior probabilities
+ //
+
+ Int_t i;
+ for (i = 0; i < AliPID::kSPECIES; i++) {
+ AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i]));
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnPIDIndex::GetPriorProbability(Double_t *out)
+{
+
+ Int_t i;
+ for (i=0; i<AliPID::kSPECIES; i++) {
+ out[i] = fPrior[i];
+ }
+
+}
+
+//_____________________________________________________________________________
+void AliRsnPIDIndex::SetPriorProbability(Double_t *out)
+{
+
+ Int_t i;
+ for (i=0;i<AliPID::kSPECIES;i++) {
+ fPrior[i] = out[i];
+ }
+
+}
+
#define AliRsnPIDIndex_h
#include <TArrayI.h>
-#include "AliRsnPID.h"
+
+#include "AliRsnEvent.h"
+#include "AliAODTrack.h"
+#include "AliRsnDaughter.h"
+
+class AliESDtrackCuts;
class AliRsnPIDIndex : public TObject
{
AliRsnPIDIndex(const AliRsnPIDIndex ©);
AliRsnPIDIndex& operator= (const AliRsnPIDIndex& copy);
- virtual ~AliRsnPIDIndex();
+ virtual ~AliRsnPIDIndex();
- void Print(Option_t *option = "") const;
+ void Print(Option_t *option = "") const;
+ void ResetAll(Int_t num=1000);
+
+ void FillFromEvent(AliRsnEvent *event = 0, AliESDtrackCuts *cuts = 0);
- void AddIndex(const Int_t index, Char_t sign, AliRsnPID::EType type);
- void AddIndex(const Int_t index, Short_t sign, Int_t type);
- void SetCorrectIndexSize();
+ void AddIndex(const Int_t index, AliRsnDaughter::EPIDMethod meth, Char_t sign, AliPID::EParticleType type);
+ void SetCorrectIndexSize();
- TArrayI* GetTracksArray(Char_t sign, AliRsnPID::EType type);
- TArrayI* GetCharged(Char_t sign);
+ TArrayI* GetTracksArray(AliRsnDaughter::EPIDMethod meth, Char_t sign, AliPID::EParticleType type);
+ TArrayI* GetCharged(Char_t sign);
+
+ // Prior probs
+ void SetPriorProbability(AliPID::EParticleType type, Double_t p);
+ void SetPriorProbability(Double_t *out);
+ void DumpPriors();
+ void GetPriorProbability(Double_t *out);
private:
- Int_t ChargeIndex(Char_t sign) const;
+ Int_t ChargeIndex(Char_t sign) const;
+ Char_t IndexCharge(Short_t sign) const;
- TArrayI fIndex[2][AliRsnPID::kSpecies+1]; // index arrays of pos/neg particles of each PID
- Int_t fNumOfIndex[2][AliRsnPID::kSpecies+1]; //! array size
+ TArrayI fIndex[AliRsnDaughter::kMethods][2][AliPID::kSPECIES + 1]; // index arrays of pos/neg particles of each PID
+ Int_t fNumOfIndex[AliRsnDaughter::kMethods][2][AliPID::kSPECIES + 1]; //! array size
+
+ Double_t fPrior[AliPID::kSPECIES]; // prior probabilities
ClassDef(AliRsnPIDIndex, 1);
};
#include "AliLog.h"
#include "AliRsnFunction.h"
-#include "AliRsnPairParticle.h"
#include "AliRsnPair.h"
//_____________________________________________________________________________
AliRsnPair::AliRsnPair(EPairType type, AliRsnPairDef *def) :
- TObject(),
- fIsMixed(kFALSE),
- fPairType(type),
- fPIDMethod(AliRsnDaughter::kRealistic),
- fPairDef(def),
- fCutMgr(0),
- fFunctions("AliRsnFunction", 0)
+ TObject(),
+ fIsMixed(kFALSE),
+ fPairType(type),
+ fPIDMethod(AliRsnDaughter::kRealistic),
+ fPairDef(def),
+ fCutMgr(0),
+ fFunctions("AliRsnFunction", 0),
+ fTrack1(),
+ fTrack2()
{
//
// Default constructor
//
-
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
SetUp(type);
}
//_____________________________________________________________________________
//
// Destructor
//
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
}
//_____________________________________________________________________________
//
// Sets up flag values by the pair types
//
-
- switch (type)
- {
+ AliDebug(AliLog::kDebug+2,"<-");
+ switch (type) {
case kNoPID:
SetAllFlags(AliRsnDaughter::kNoPID, kFALSE);
break;
SetAllFlags(AliRsnDaughter::kRealistic, kFALSE);
break;
}
+ AliDebug(AliLog::kDebug+2,"->");
}
//_____________________________________________________________________________
//
// Prints info about pair
//
-
+ AliDebug(AliLog::kDebug+2,"<-");
AliInfo(Form("%s", GetPairHistTitle(0x0).Data()));
- AliInfo(Form("PDG %d %d", AliRsnPID::PDGCode(fPairDef->GetType(0)),
- AliRsnPID::PDGCode(fPairDef->GetType(1))));
+ AliInfo(Form("PDG %d %d", AliPID::ParticleCode(fPairDef->GetType(0)),
+ AliPID::ParticleCode(fPairDef->GetType(1))));
AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1)));
AliInfo(Form("Number of functions %d", fFunctions.GetEntries()));
- switch(fPIDMethod)
- {
+ switch (fPIDMethod) {
case AliRsnDaughter::kNoPID:
AliInfo("PID method: none");
break;
default:
AliInfo("PID method: undefined");
}
+ AliDebug(AliLog::kDebug+2,"->");
}
//_____________________________________________________________________________
-void AliRsnPair::ProcessPair(AliRsnEvent *ev1, AliRsnEvent *ev2)
+void AliRsnPair::LoopPair
+(AliRsnPIDIndex *pidIndex1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndex2, AliRsnEvent *ev2)
{
//
-// Fills the functions' histograms using tracks from passed events.
-// What tracks are taken in each event depend from the order of
-// track types defined in the AliRsnPairDef for this object:
-// - tracks of type 0 are the ones stored as pairDef data members with index [0]
-// ---> taken from first argument (ev1)
-// - tracks of type 1 are the ones stored as pairDef data members with index [1]
-// ---> taken from second argument (ev2)
-//
-// When doing single-event analysis (e.g. signal, like-sign), second argument
-// can be NULL, and it will be forced to point to the same object of first one.
+// Prepare the loop for computation of functions.
+// Each PIDIndex is used to retrieve the appropriate array of indexes
+// of the tracks to be used in each event.
+// In case of single-event analysis, only the first two arguments are used
+// and both arrays are taken from the same PIDIndex and will loop on the same event
+// In case of mixing, all arguments are used, and first set of tracks will be found
+// in the first event with the first PIDIndex, and the second set of tracks will
+// be found in second event with second PIDIndex.
//
- if (!ev2) ev2 = ev1;
+ AliDebug(AliLog::kDebug+2,"<-");
- TArrayI *array1 = ev1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(0), fPairDef->GetType(0));
- TArrayI *array2 = ev2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), fPairDef->GetType(1));
+ TArrayI *a1 = 0;
+ TArrayI *a2 = 0;
- LoopPair(ev1, array1, ev2, array2);
+ if (fPIDMethod == AliRsnDaughter::kNoPID)
+ {
+ AliDebug(AliLog::kDebug+2, Form("Returning indexes of with NO PID (%d) ...", fPIDMethod));
+ a1 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(0), AliPID::kUnknown);
+ if (pidIndex2 && ev2)
+ a2 = pidIndex2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), AliPID::kUnknown);
+ else
+ a2 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), AliPID::kUnknown);
+ }
+ else
+ {
+ AliDebug(AliLog::kDebug+2, Form("Returning indexes of with PID (%d) ...", fPIDMethod));
+ a1 = pidIndex1->GetTracksArray(fPIDMethod,fPairDef->GetCharge(0), (AliPID::EParticleType)fPairDef->GetType(0));
+ if (pidIndex2 && ev2)
+ a2 = pidIndex2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), (AliPID::EParticleType)fPairDef->GetType(1));
+ else
+ a2 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), (AliPID::EParticleType)fPairDef->GetType(1));
+ }
+
+ LoopPair(a1, a2, ev1, ev2);
+
+ AliDebug(AliLog::kDebug+2,"->");
}
//_____________________________________________________________________________
-void AliRsnPair::LoopPair
-(AliRsnEvent * ev1, TArrayI * a1, AliRsnEvent * ev2, TArrayI * a2)
+void AliRsnPair::LoopPair(TArrayI *a1, TArrayI *a2, AliRsnEvent *ev1, AliRsnEvent *ev2)
{
//
// Loop on all pairs of tracks of the defined types/charges,
// using the arrays of indexes and the events containing them.
// This method is private, for safety reasons.
//
+ AliDebug(AliLog::kDebug+2,"<-");
+ if (!ev1) {AliError(Form("ev1 is %p. skipping LoopPair() ...",ev1))return;}
+ AliDebug(AliLog::kDebug+1,"ev1 is OK ...");
+
+
+ if (!ev2) {
+ if (fIsMixed) {
+ AliDebug(AliLog::kDebug, "ev2 is null and fIsMixed is true. Skipping ...");
+ return;
+ }
+ ev2 = ev1;
+ }
+
+ if (!a1) {AliDebug(AliLog::kDebug, "No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;}
+ if (!a2) {AliDebug(AliLog::kDebug, "No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;}
+
+ AliDebug(AliLog::kDebug+1,Form("a1=%d a2=%d",a1->GetSize(),a2->GetSize()));
+ if (a1->GetSize()<=0) {AliDebug(AliLog::kDebug, "Size of TArrayI 1 is 0 or less ..."); return;}
+ if (a2->GetSize()<=0) {AliDebug(AliLog::kDebug, "Size of TArrayI 2 is 0 or less ..."); return;}
- if (!a1) {AliDebug(4, "No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;}
- if (!a2) {AliDebug(4, "No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;}
// cuts on events
if (!CutPass(ev1) || !CutPass(ev2)) return;
-
+ AliDebug(AliLog::kDebug+1,"Event cut passed...");
AliRsnDaughter::SetPIDMethod(fPIDMethod);
- AliRsnDaughter *daughter1 = 0;
- AliRsnDaughter *daughter2 = 0;
AliRsnFunction *fcn = 0;
Bool_t isLikeSign = fPairDef->IsLikeSign();
Int_t j, startj = 0;
- for (Int_t i = 0; i < a1->GetSize(); i++)
- {
- // get track #1
- daughter1 = (AliRsnDaughter *) ev1->GetTrack(a1->At(i));
- if (!daughter1) continue;
- // assign PID and mass of particle of type #1
- daughter1->AssignPID(fPairDef->GetType(0));
- // cuts on track #1
- if (!CutPass(daughter1)) continue;
- // get track #2
- daughter2 = 0;
- // check starting index for searching the event:
- // for like-sign pairs we avoid duplicating the pairs
- if (isLikeSign) startj = i+1; else startj = 0;
- // AliInfo(Form("%d",startj));
- // loop on event for all track #2 to be combined with the found track #1
- for (j = startj; j < a2->GetSize(); j++)
- {
- daughter2 = (AliRsnDaughter *) ev2->GetTrack(a2->At(j));
- if (!daughter2) continue;
- // assign PID and mass of particle of type #2
- daughter2->AssignPID(fPairDef->GetType(0));
- // cuts on track #2
- if (!CutPass(daughter2)) continue;
- // make pair
- AliRsnPairParticle pairParticle;
- pairParticle.SetPair(daughter1, daughter2);
- // cuts on pair
- if (!CutPass(&pairParticle)) continue;
- // fill all histograms
- TObjArrayIter nextFcn(&fFunctions);
- while ( (fcn = (AliRsnFunction*)nextFcn()) ) {
- fcn->Fill(&pairParticle, fPairDef);
- }
- /*
- while ( (fnew = (AliRsnFunction*)nextFcn()) ) {
- fnew->Fill(&pairParticle, fPairDef);
- }
- */
- }
+ for (Int_t i = 0; i < a1->GetSize(); i++) {
+ // get track #1
+ ev1->SetDaughter(fTrack1, a1->At(i));
+ if (!fTrack1.IsOK()) continue;
+ AliDebug(AliLog::kDebug+1,"daughter1 is OK ...");
+ // cuts on track #1
+ if (!CutPass(&fTrack1)) continue;
+ AliDebug(AliLog::kDebug+1,"daughter1 cut passed ...");
+ // check starting index for searching the event:
+ // for like-sign pairs we avoid duplicating the pairs
+ if (isLikeSign) startj = i+1; else startj = 0;
+ // loop on event for all track #2 to be combined with the found track #1
+ for (j = startj; j < a2->GetSize(); j++) {
+ ev2->SetDaughter(fTrack2, a2->At(j));
+ if (!fTrack2.IsOK()) continue;
+ AliDebug(AliLog::kDebug+1,"daughter2 is OK ...");
+ // cuts on track #2
+ if (!CutPass(&fTrack2)) continue;
+ AliDebug(AliLog::kDebug+1,"daughter2 cut passed ...");
+ // make pair
+ fPairParticle.SetPair(&fTrack1, &fTrack2);
+
+ // cuts on pair
+ if (!CutPass(&fPairParticle)) continue;
+ AliDebug(AliLog::kDebug+1, "pairParticle cut passed");
+
+// pairParticle.PrintInfo();
+
+ // fill all histograms
+ TObjArrayIter nextFcn(&fFunctions);
+ while ( (fcn = (AliRsnFunction*)nextFcn()) ) {
+ fcn->SetPairDef(fPairDef);
+ fcn->SetPair(&fPairParticle);
+ fcn->SetEvent(ev1);
+ fcn->Fill();
+ }
}
+ }
+ AliDebug(AliLog::kDebug+2,"->");
}
//_____________________________________________________________________________
//
// All generated histograms are stored into the output TList.
//
-
+ AliDebug(AliLog::kDebug+2,"<-");
TList *list = new TList();
list->SetName(GetPairHistName(0x0).Data());
Char_t hName[255], hTitle[255];
+ //AliRsnFunction *fcn = 0;
AliRsnFunction *fcn = 0;
- for (Int_t i=0;i< fFunctions.GetEntries();i++)
- {
+ for (Int_t i=0;i< fFunctions.GetEntries();i++) {
fcn = (AliRsnFunction*)fFunctions.At(i);
sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data());
sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data());
- TList *histos = fcn->Init(hName, hTitle);
+ //TList *histos = fcn->Init(hName, hTitle);
+ list->Add(fcn->CreateHistogram(hName, hTitle));
//histos->Print();
- list->Add(histos);
+ //list->Add(histos);
}
-
+ cout << "PRINTING LIST" << endl;
+ list->Print();
+ AliDebug(AliLog::kDebug+2,"->");
return list;
}
-//_____________________________________________________________________________
-void AliRsnPair::GenerateHistograms(TString prefix, TList *tgt)
-{
-//
-// Generates needed histograms, giving them a name based on
-// the flags defined here, on the pair definition, and attaches
-// a prefix to it, according to the argument.
-//
-// All generated histograms are stored into the TList passed as argument
-//
- if (!tgt) {
- AliError("NULL target list!");
- return;
- }
-
- Char_t hName[255], hTitle[255];
- AliRsnFunction *fcn = 0;
- for (Int_t i=0;i< fFunctions.GetEntries();i++)
- {
- fcn = (AliRsnFunction*)fFunctions.At(i);
- sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data());
- sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data());
- fcn->Init(hName, hTitle, tgt);
- }
-}
//_____________________________________________________________________________
TString AliRsnPair::GetPairTypeName(EPairType type) const
//
// Returns type name, made with particle names ant chosen PID
//
-
- switch (type)
- {
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+ switch (type) {
case kNoPID : return ("NOPID_");break;
case kNoPIDMix : return ("NOPIDMIX_");break;
case kRealisticPID : return ("REALISTIC_");break;
//
// Retruns pair name
//
-
+ AliDebug(AliLog::kDebug+2,"<-");
TString sName;
sName += GetPairTypeName(fPairType);
sName += fPairDef->GetPairName();
-
+ AliDebug(AliLog::kDebug+2,"->");
return sName;
}
//
// Returns definitive histogram name
//
-
+ AliDebug(AliLog::kDebug+2,"<-");
TString sName;
- if (fcn)
- {
- sName = fcn->GetFcnName();
+ if (fcn) {
+ sName = fcn->GetName();
sName += "_";
}
sName += GetPairName();
sName += "_";
if (fCutMgr) sName += fCutMgr->GetName();
sName += text;
-
+ AliDebug(AliLog::kDebug+2,"->");
return sName;
}
//
// Returns definitive histogram title
//
-
+ AliDebug(AliLog::kDebug+2,"<-");
TString sTitle;
- if (fcn)
- {
- sTitle = fcn->GetFcnTitle();
+ if (fcn) {
+ sTitle = fcn->GetTitle();
sTitle += " ";
}
sTitle += GetPairName();
sTitle +=" ";
if (fCutMgr) sTitle += fCutMgr->GetTitle();
sTitle += text;
-
+ AliDebug(AliLog::kDebug+2,"->");
return sTitle;
}
//
// Adds a new computing function
//
-
+ AliDebug(AliLog::kDebug+2,"<-");
Int_t size = fFunctions.GetEntries();
new (fFunctions[size]) AliRsnFunction(*fcn);
+ AliDebug(AliLog::kDebug+2,"->");
}
+/*
+//_____________________________________________________________________________
+void AliRsnPair::AddFunction(AliRsnFunctionDef *fcn)
+{
+//
+// Adds a new computing function
+//
+ AliDebug(AliLog::kDebug+2,"<-");
+ Int_t size = fFunctions.GetEntries();
+ new (fFunctions[size]) AliRsnFunctionNew(fcn);
+ AliDebug(AliLog::kDebug+2,"->");
+}
+*/
//________________________________________________________________________________________
Bool_t AliRsnPair::CutPass(AliRsnDaughter *d)
// Check if the AliRsnDaughter argument pass its cuts.
// If the cut data member is not initialized for it, returns kTRUE.
//
-
+ AliDebug(AliLog::kDebug+2,"<-AliRsnDaughter");
+ AliDebug(AliLog::kDebug+2,"->");
if (!fCutMgr) return kTRUE;
else return fCutMgr->IsSelected(AliRsnCut::kParticle, d);
}
// Check if the AliRsnPairParticle argument pass its cuts.
// If the cut data member is not initialized for it, returns kTRUE.
//
-
+ AliDebug(AliLog::kDebug+2,"<-AliRsnPairParticle");
+ AliDebug(AliLog::kDebug+2,"->");
if (!fCutMgr) return kTRUE;
else return fCutMgr->IsSelected(AliRsnCut::kPair, p);
}
// Check if the AliRsnEvent argument pass its cuts.
// If the cut data member is not initialized for it, returns kTRUE.
//
-
+ AliDebug(AliLog::kDebug+2,"<-AliRsnEvent");
+ AliDebug(AliLog::kDebug+2,"->");
if (!fCutMgr) return kTRUE;
else return fCutMgr->IsSelected(AliRsnCut::kEvent, e);
+
}
#include "TH2.h"
#include "TList.h"
#include "TArrayI.h"
+#include "TClonesArray.h"
#include "AliRsnDaughter.h"
#include "AliRsnPairDef.h"
-#include "AliRsnEventBuffer.h"
+#include "AliRsnPairParticle.h"
#include "AliRsnEvent.h"
#include "AliRsnCutMgr.h"
#include "AliRsnHistoDef.h"
+#include "AliRsnPIDIndex.h"
class AliRsnFunction;
~AliRsnPair();
void Print(Option_t *option = "") const;
- void ProcessPair(AliRsnEvent *ev1, AliRsnEvent *ev2 = 0);
+ void LoopPair(AliRsnPIDIndex *pidIndex1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndex2 = 0, AliRsnEvent *ev2 = 0);
+ void LoopPair(TArrayI *a1, TArrayI *a2, AliRsnEvent *ev1, AliRsnEvent *ev2 = 0);
void SetCutMgr(AliRsnCutMgr* theValue) { fCutMgr = theValue; }
void AddFunction(AliRsnFunction *fcn);
+ //void AddFunction(AliRsnFunctionDef *fcn);
TList* GenerateHistograms(TString prefix = "");
void GenerateHistograms(TString prefix, TList *tgt);
TString GetPairName() const;
TString GetPairHistName(AliRsnFunction *fcn, TString text = "") const;
TString GetPairHistTitle(AliRsnFunction *fcn, TString text = "") const;
+ //TString GetPairHistName(AliRsnFunctionNew *fcn, TString text = "") const;
+ //TString GetPairHistTitle(AliRsnFunctionNew *fcn, TString text = "") const;
private:
AliRsnPair (const AliRsnPair ©) : TObject(copy),
fIsMixed(kFALSE),fPairType(kPairTypes),fPIDMethod(AliRsnDaughter::kRealistic),
- fPairDef(0x0),fCutMgr(0x0),fFunctions("AliRsnFunction",0) {}
+ fPairDef(0x0),fCutMgr(0x0),fFunctions("AliRsnFunction",0),fTrack1(),fTrack2(),fPairParticle() {}
AliRsnPair& operator=(const AliRsnPair&) {return *this;}
void SetUp(EPairType type);
void SetAllFlags(AliRsnDaughter::EPIDMethod pid, Bool_t mix) {fPIDMethod = pid; fIsMixed = mix;}
- void LoopPair(AliRsnEvent *ev1, TArrayI *a1, AliRsnEvent *ev2, TArrayI *a2);
Bool_t CutPass(AliRsnDaughter *d);
Bool_t CutPass(AliRsnPairParticle *p);
AliRsnPairDef *fPairDef; // pair definition (particles, charges)
AliRsnCutMgr *fCutMgr; // cut manager
TClonesArray fFunctions; // functions
+ AliRsnDaughter fTrack1; // track #1 (external loop)
+ AliRsnDaughter fTrack2; // track #2 (internal loop)
+ AliRsnPairParticle fPairParticle; // track pair
ClassDef (AliRsnPair, 2)
};
// author: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
//
+#include <Riostream.h>
+
#include "AliLog.h"
#include "AliRsnDaughter.h"
#include "AliRsnPairDef.h"
{
fCharge[i] = '0';
fMass[i] = 0.0;
- fType[i] = AliRsnPID::kUnknown;
+ fType[i] = AliPID::kUnknown;
}
}
//_____________________________________________________________________________
AliRsnPairDef::AliRsnPairDef
-(Char_t sign1, AliRsnPID::EType type1, Char_t sign2, AliRsnPID::EType type2, Int_t motherPDG) :
+(Char_t sign1, AliPID::EParticleType type1, Char_t sign2, AliPID::EParticleType type2, Int_t motherPDG) :
fMotherPDG(motherPDG)
{
//
//_____________________________________________________________________________
AliRsnPairDef::AliRsnPairDef
-(AliRsnPID::EType type1, Char_t sign1, AliRsnPID::EType type2, Char_t sign2, Int_t motherPDG) :
+(AliPID::EParticleType type1, Char_t sign1, AliPID::EParticleType type2, Char_t sign2, Int_t motherPDG) :
fMotherPDG(motherPDG)
{
//
}
//_____________________________________________________________________________
-Bool_t AliRsnPairDef::SetPairElement(Int_t i, Char_t charge, AliRsnPID::EType type)
+Bool_t AliRsnPairDef::SetPairElement(Int_t i, Char_t charge, AliPID::EParticleType type)
{
//
// Set one element of the pair
// and returns warnings if the type is not valid.
//
+
+ AliPID pid;
+
if (i < 0 || i > 1)
{
AliError("Index out of range");
AliError(Form("Character '%c' not recognized as charge sign"));
return kFALSE;
}
- if (type < AliRsnPID::kElectron && type > AliRsnPID::kUnknown)
+ if (type < 0 && type > (Int_t)AliPID::kSPECIES)
{
AliError("Type index out of enumeration range");
return kFALSE;
}
fCharge[i] = charge;
fType[i] = type;
- fMass[i] = AliRsnPID::ParticleMass(type);
+ fMass[i] = pid.ParticleMass(type);
return kTRUE;
}
//_____________________________________________________________________________
Bool_t AliRsnPairDef::SetPair
-(Char_t charge1, AliRsnPID::EType type1, Char_t charge2, AliRsnPID::EType type2)
+(Char_t charge1, AliPID::EParticleType type1, Char_t charge2, AliPID::EParticleType type2)
{
//
// Set both elements of the pair,
return (part1 && part2);
}
-//_____________________________________________________________________________
-Double_t AliRsnPairDef::ComputeWeight(AliRsnDaughter *d0, AliRsnDaughter *d1)
-{
-//
-// Compute a weight for filling the histograms:
-// probability of first track to be identified as 'type[0]' times
-// the probability of second track to be identified as 'type[1]',
-// according to the order of appearance in argument list.
-//
-
- Double_t prob0 = d0->PIDProb()[fType[0]];
- Double_t prob1 = d1->PIDProb()[fType[1]];
-
- return prob0*prob1;
-}
-
//_____________________________________________________________________________
TString AliRsnPairDef::GetPairName()
{
//
TString sName;
- sName += AliRsnPID::ParticleName(fType[0]);
+ sName += AliPID::ParticleShortName(fType[0]);
sName += fCharge[0];
- sName += AliRsnPID::ParticleName(fType[1]);
+ sName += AliPID::ParticleShortName(fType[1]);
sName += fCharge[1];
return sName;
#include <TString.h>
-#include "AliRsnPID.h"
+#include "AliPID.h"
class AliRsnDaughter;
public:
AliRsnPairDef();
- AliRsnPairDef(Char_t sign1, AliRsnPID::EType type1,
- Char_t sign2, AliRsnPID::EType type2, Int_t motherPDG = 0);
- AliRsnPairDef(AliRsnPID::EType type1, Char_t sign1,
- AliRsnPID::EType type2, Char_t sign2, Int_t motherPDG = 0);
+ AliRsnPairDef(Char_t sign1, AliPID::EParticleType type1,
+ Char_t sign2, AliPID::EParticleType type2, Int_t motherPDG = 0);
+ AliRsnPairDef(AliPID::EParticleType type1, Char_t sign1,
+ AliPID::EParticleType type2, Char_t sign2, Int_t motherPDG = 0);
AliRsnPairDef(const AliRsnPairDef ©);
const AliRsnPairDef& operator= (const AliRsnPairDef ©);
virtual ~AliRsnPairDef() { }
// getters
- Char_t GetCharge(Int_t i) const {if (i>=0&&i<2) return fCharge[i]; else return 0;}
- AliRsnPID::EType GetType(Int_t i) const {if (i>=0&&i<2) return fType[i]; else return AliRsnPID::kUnknown;}
- Double_t GetMass(Int_t i) const {if (i>=0&&i<2) return fMass[i]; else return 0.0;}
- Int_t GetMotherPDG() const {return fMotherPDG;}
- TString GetPairName();
+ Char_t GetCharge(Int_t i) const {if (i>=0&&i<2) return fCharge[i]; else return 0;}
+ AliPID::EParticleType GetType(Int_t i) const {if (i>=0&&i<2) return fType[i]; else return AliPID::kUnknown;}
+ Double_t GetMass(Int_t i) const {if (i>=0&&i<2) return fMass[i]; else return 0.0;}
+ Int_t GetMotherPDG() const {return fMotherPDG;}
+ TString GetPairName();
// setters
- Bool_t SetPairElement(Int_t i, Char_t charge, AliRsnPID::EType pid);
- Bool_t SetPair(Char_t ch1, AliRsnPID::EType pid1, Char_t ch2, AliRsnPID::EType pid2);
+ Bool_t SetPairElement(Int_t i, Char_t charge, AliPID::EParticleType pid);
+ Bool_t SetPair(Char_t ch1, AliPID::EParticleType pid1, Char_t ch2, AliPID::EParticleType pid2);
void SetMotherPDG(Int_t pdg) {fMotherPDG = pdg;}
// pair information methods
Bool_t IsLikeSign() {return (fCharge[0] == fCharge[1]);}
Bool_t HasEqualTypes() {return (fType[0] == fType[1]);}
- // working routines
- Double_t ComputeWeight(AliRsnDaughter *d0, AliRsnDaughter *d1);
-
private:
// pair parameters
- Int_t fMotherPDG; // PDG code of true mother (if known)
- Double_t fMass[2]; // mass of particles
- Char_t fCharge[2]; // charge of particles
- AliRsnPID::EType fType[2]; // PID of particles
+ Int_t fMotherPDG; // PDG code of true mother (if known)
+ Double_t fMass[2]; // mass of particles
+ Char_t fCharge[2]; // charge of particles
+ AliPID::EParticleType fType[2]; // PID of particles
// ROOT dictionary
ClassDef(AliRsnPairDef, 1)
--- /dev/null
+//
+// Class AliRsnPairManager
+//
+// A collection of pairs for an analysis.
+// The function of this collection is just for purposes of well-sorting
+// the analyzed pairs into upper-level groups, in the case of a wide
+// analysis containing many resonances at once, or different settings for the same one.
+//
+// Each PairMgr will result in a separate list of histograms, which
+// can be seen as a folder in the output file, whose name is given by this object.
+//
+// author: M. Vala (email: martin.vala@cern.ch)
+//
+
+#include "AliLog.h"
+
+#include "AliRsnPairManager.h"
+
+ClassImp(AliRsnPairManager)
+
+//_____________________________________________________________________________
+AliRsnPairManager::AliRsnPairManager(const char*name) :
+ AliRsnVManager(name)
+{
+//
+// Default constructor
+//
+
+ AliDebug(AliLog::kDebug +2, "<-");
+ AliDebug(AliLog::kDebug +2, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnPairManager::Add(AliRsnPair *pair)
+{
+//
+// Adds a new AliRsnPair to the list owned by this object.
+//
+
+ AliDebug(AliLog::kDebug+2, "<-");
+
+ if (!pair) {
+ AliWarning(Form("Pair is %p. Skipping ...", pair));
+ return;
+ }
+
+ AliDebug(AliLog::kDebug+1, Form("Adding %s [%d entries] ...", pair->GetPairName().Data(), fArray.GetEntries()));
+ fArray.Add((AliRsnPair*)pair);
+
+ AliDebug(AliLog::kDebug+2, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnPairManager::Print(Option_t* /*dummy*/) const
+{
+//
+// Overload of TObject::Print() method.
+// With respect to the other print method, adds a title string.
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ AliInfo(Form("\t\t======== Pair Manager %s ========", GetName()));
+ PrintArray();
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnPairManager::PrintArray() const
+{
+//
+// Prints all pairs
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ AliRsnPair *pair = 0;
+ TObjArrayIter next(&fArray);
+ while ((pair = (AliRsnPair*)next())) pair->Print();
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+TList* AliRsnPairManager::InitAllPairs()
+{
+//
+// Initialize all pairs, and builds a TList of histograms
+// which are created by each of them, in order to link it
+// to the output handler in the AnalysisTasks.
+//
+
+ AliDebug(AliLog::kDebug+2, "<-");
+
+ TList *list = new TList();
+ list->SetName(GetName());
+ list->SetOwner();
+
+ AliRsnPair *pair = 0;
+ TObjArrayIter next(&fArray);
+
+ Int_t i = 0;
+ while ((pair = (AliRsnPair*)next())) {
+ if (!pair) continue;
+ AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetPairName().Data(), i++));
+ list->Add(pair->GenerateHistograms(GetName()));
+ }
+
+ AliDebug(AliLog::kDebug+2, "->");
+ return list;
+}
+
+//_____________________________________________________________________________
+void AliRsnPairManager::ProcessAllPairs
+(AliRsnPIDIndex *pidIndexes1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndexes2, AliRsnEvent *ev2)
+{
+//
+// Processes one (single-event analysis) or two (event-mixing) events
+// to fill histograms in all stored pairs.
+//
+
+ AliDebug(AliLog::kDebug+2, "<-");
+
+ AliRsnPair *pair = 0;
+ TObjArrayIter next(&fArray);
+
+ Int_t i=0;
+ while ((pair = (AliRsnPair*)next())) {
+ if (!pair) continue;
+ AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the PairManager(%s) [%d] ...", pair->GetPairName().Data(), i++));
+ pair->LoopPair(pidIndexes1, ev1, pidIndexes2, ev2);
+ }
+
+ AliDebug(AliLog::kDebug+2, "->");
+}
--- /dev/null
+//
+// Class AliRsnPairManager
+//
+// A collection of pairs for an analysis.
+// The function of this collection is just for purposes of well-sorting
+// the analyzed pairs into upper-level groups, in the case of a wide
+// analysis containing many resonances at once, or different settings for the same one.
+//
+// Each PairManager will result in a separate list of histograms, which
+// can be seen as a folder in the output file, named after this object.
+//
+// This object inherits from AliRsnVManager, and "forces" the type of the
+// stored objects to be of the "AliRsnPair" class.
+// No further data members are added.
+//
+// author: M. Vala (email: martin.vala@cern.ch)
+//
+
+#ifndef AliRsnPairManager_H
+#define AliRsnPairManager_H
+
+#include <TList.h>
+
+#include "AliRsnVManager.h"
+#include "AliRsnPair.h"
+
+class AliRsnPairManager : public AliRsnVManager
+{
+ public:
+
+ AliRsnPairManager(const char *name = "defaultPairMgr");
+
+ virtual void Add(AliRsnPair *pair);
+ virtual void AddPair(AliRsnPair *pair) {Add(pair);}
+ virtual void PrintArray() const;
+ virtual void Print(Option_t *option = "") const;
+
+ TList* InitAllPairs();
+ void ProcessAllPairs(AliRsnPIDIndex *pidIndexes1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndexes2 = 0, AliRsnEvent *ev2 = 0);
+
+ private:
+
+ ClassDef(AliRsnPairManager, 1)
+};
+
+#endif
// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
//
+#include <TParticle.h>
+
#include "AliLog.h"
#include "AliRsnPairParticle.h"
Int_t i, j;
- for (i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
fPTot[i] = 0.0;
fPTotMC[i] = 0.0;
- if (i < 2)
- {
+ if (i < 2) {
fMotherLabel[i] = -1;
fMotherPDG[i] = 0;
fDaughter[i] = 0x0;
}
- for (j = 0; j < 2; j++)
- {
+ for (j = 0; j < 2; j++) {
fPTrack[j][i] = 0.0;
fPTrackMC[j][i] = 0.0;
}
//
Int_t i, j;
- for (i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
fPTot[i] = obj.fPTot[i];
fPTotMC[i] = obj.fPTotMC[i];
- if (i < 2)
- {
+ if (i < 2) {
fMotherLabel[i] = obj.fMotherLabel[i];
fMotherPDG[i] = obj.fMotherPDG[i];
fDaughter[i] = obj.fDaughter[i];
}
- for (j = 0; j < 2; j++)
- {
+ for (j = 0; j < 2; j++) {
fPTrack[j][i] = obj.fPTrack[j][i];
fPTrackMC[j][i] = obj.fPTrackMC[j][i];
}
//
Int_t i, j;
- for (i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
fPTot[i] = obj.fPTot[i];
fPTotMC[i] = obj.fPTotMC[i];
- if (i < 2)
- {
+ if (i < 2) {
fMotherLabel[i] = obj.fMotherLabel[i];
fMotherPDG[i] = obj.fMotherPDG[i];
fDaughter[i] = obj.fDaughter[i];
}
- for (j = 0; j < 2; j++)
- {
+ for (j = 0; j < 2; j++) {
fPTrack[j][i] = obj.fPTrack[j][i];
fPTrackMC[j][i] = obj.fPTrackMC[j][i];
}
//
// Compute invariant mass using reconstructed values.
// Mass in argument #1 is assigned to first track in the pair (fDaughter[0]),
-// mass in argument #2 is assigned to second track in the pair (fDaughter[1])
+// mass in argument #2 is assigned to second track in the pair (fDaughter[1]).
+// If the third argument is not zero, a rotation of that angle is applied to XY momentum of track #2
+// before computing invariant mass.
// Then, the invariant mass of the pair is computed by using their total momentum
// and the sum of their energies computed after assigned masses.
//
- if (!fDaughter[0] || !fDaughter[1])
- {
+ if (!fDaughter[0] || !fDaughter[1]) {
AliError("One of the two tracks is NULL in this pair!");
return -1000.0;
}
// and the sum of their energies.
//
- if (!fDaughter[0] || !fDaughter[1])
- {
+ if (!fDaughter[0] || !fDaughter[1]) {
AliError("One of the two tracks is NULL in this pair!");
return -1000.0;
}
- if (!fDaughter[0]->GetMCInfo() || !fDaughter[1]->GetMCInfo())
- {
+ if (!fDaughter[0]->GetParticle() || !fDaughter[1]->GetParticle()) {
AliError("One of the two tracks has a NULL MCInfo in this pair!");
return -1000.0;
}
// compute track energies using the shortcut method defined in AliRsnDaughter
Double_t etot = 0.0;
- etot += fDaughter[0]->GetMCInfo()->E(mass0);
- etot += fDaughter[1]->GetMCInfo()->E(mass1);
+ etot += fDaughter[0]->GetMCEnergy(mass0);
+ etot += fDaughter[1]->GetMCEnergy(mass1);
// compute & return invariant mass
return TMath::Sqrt(etot * etot - GetP2MC());
// with a necessary mass hypothesis (MC values).
//
Double_t etot = 0.0;
- etot += fDaughter[0]->GetMCInfo()->E(mass0);
- etot += fDaughter[1]->GetMCInfo()->E(mass1);
+ etot += fDaughter[0]->GetMCEnergy(mass0);
+ etot += fDaughter[1]->GetMCEnergy(mass1);
return etot;
}
//
// if MC info is not available, the pairs is not true by default
- if (!fDaughter[0]->GetMCInfo() || !fDaughter[1]->GetMCInfo())
- {
+ if (!fDaughter[0]->GetParticle() || !fDaughter[1]->GetParticle()) {
AliInfo("Cannot know if the pairs is true or not because MC Info is not present");
return kFALSE;
}
// check that labels are the same
- if (fDaughter[0]->GetMCInfo()->Mother() != fDaughter[1]->GetMCInfo()->Mother())
- {
+ if (fDaughter[0]->GetParticle()->GetFirstMother() != fDaughter[1]->GetParticle()->GetFirstMother()) {
return kFALSE;
}
// if we reach this point, the two tracks have the same mother
// let's check now the PDG code of this common mother
- Int_t motherPDG = TMath::Abs(fDaughter[0]->GetMCInfo()->MotherPDG());
+ Int_t motherPDG = TMath::Abs(fDaughter[0]->GetMotherPDG());
if (refPDG == 0) return kTRUE;
else return (motherPDG == refPDG);
}
+//_____________________________________________________________________________
+Int_t AliRsnPairParticle::CommonMother()
+{
+//
+// Checks if the two tracks in the pair have the same mother.
+// This can be known if MC info is present.
+// If the mother label is the same, rhe PDG code of the mother is returned,
+// otherwise the method returns 0.
+//
+
+ // if MC info is not available, the pairs is not true by default
+ if (!fDaughter[0]->GetParticle() || !fDaughter[1]->GetParticle()) {
+ AliInfo("Cannot know if the pairs is true or not because MC Info is not present");
+ return 0;
+ }
+
+ // check that labels are the same
+ if (fDaughter[0]->GetParticle()->GetFirstMother() != fDaughter[1]->GetParticle()->GetFirstMother()) {
+ return 0;
+ }
+
+ // if we reach this point, the two tracks have the same mother
+ // let's check now the PDG code of this common mother
+ return TMath::Abs(fDaughter[0]->GetMotherPDG());
+}
+
//_____________________________________________________________________________
void AliRsnPairParticle::SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2)
{
fDaughter[1] = daughter2;
// copy MC info (if available)
- if (fDaughter[0]->GetMCInfo() && fDaughter[1]->GetMCInfo())
- {
- for (i = 0; i < 2; i++)
- {
- fPTrackMC[i][0] = fDaughter[i]->GetMCInfo()->Px();
- fPTrackMC[i][1] = fDaughter[i]->GetMCInfo()->Py();
- fPTrackMC[i][2] = fDaughter[i]->GetMCInfo()->Pz();
- fMotherPDG[i] = fDaughter[i]->GetMCInfo()->MotherPDG();
+ if (fDaughter[0]->GetParticle() && fDaughter[1]->GetParticle()) {
+ for (i = 0; i < 2; i++) {
+ fPTrackMC[i][0] = fDaughter[i]->GetParticle()->Px();
+ fPTrackMC[i][1] = fDaughter[i]->GetParticle()->Py();
+ fPTrackMC[i][2] = fDaughter[i]->GetParticle()->Pz();
+ fMotherPDG[i] = fDaughter[i]->GetMotherPDG();
}
for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
}
// copy reconstructed info (always available)
- for (i = 0; i < 2; i++)
- {
+ for (i = 0; i < 2; i++) {
fPTrack[i][0] = fDaughter[i]->Px();
fPTrack[i][1] = fDaughter[i]->Py();
fPTrack[i][2] = fDaughter[i]->Pz();
Int_t i;
// copy MC info (if available)
- if (fDaughter[0]->GetMCInfo() && fDaughter[1]->GetMCInfo())
- {
- for (i = 0; i < 2; i++)
- {
- fPTrackMC[i][0] = fDaughter[i]->GetMCInfo()->Px();
- fPTrackMC[i][1] = fDaughter[i]->GetMCInfo()->Py();
- fPTrackMC[i][2] = fDaughter[i]->GetMCInfo()->Pz();
- fMotherPDG[i] = fDaughter[i]->GetMCInfo()->MotherPDG();
+ if (fDaughter[0]->GetParticle() && fDaughter[1]->GetParticle()) {
+ for (i = 0; i < 2; i++) {
+ fPTrackMC[i][0] = fDaughter[i]->GetParticle()->Px();
+ fPTrackMC[i][1] = fDaughter[i]->GetParticle()->Py();
+ fPTrackMC[i][2] = fDaughter[i]->GetParticle()->Pz();
+ fMotherPDG[i] = fDaughter[i]->GetMotherPDG();
}
for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
}
// copy reconstructed info (always available)
- for (i = 0; i < 2; i++)
- {
+ for (i = 0; i < 2; i++) {
fPTrack[i][0] = fDaughter[i]->Px();
fPTrack[i][1] = fDaughter[i]->Py();
fPTrack[i][2] = fDaughter[i]->Pz();
for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
}
+//_____________________________________________________________________________
+void AliRsnPairParticle::RotateTrack(Int_t idx, Double_t angle, Bool_t isDegrees)
+{
+//
+// Computes the total momentum for REC data and MC if available
+//
+
+ if (idx < 0 || idx > 1) return;
+
+ Int_t i;
+
+ // copy MC info (if available)
+ if (fDaughter[0]->GetParticle() && fDaughter[1]->GetParticle()) {
+ for (i = 0; i < 2; i++) {
+ if (i == idx) {
+ fDaughter[i]->RotateP(angle, fPTrackMC[i][0], fPTrackMC[i][1], isDegrees);
+ } else {
+ fPTrackMC[i][0] = fDaughter[i]->GetParticle()->Px();
+ fPTrackMC[i][1] = fDaughter[i]->GetParticle()->Py();
+ }
+ fPTrackMC[i][2] = fDaughter[i]->GetParticle()->Pz();
+ }
+ for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
+ }
+
+ for (i = 0; i < 2; i++) {
+ if (i == idx) {
+ fDaughter[i]->RotateP(angle, fPTrack[i][0], fPTrack[i][1], isDegrees);
+ } else {
+ fPTrack[i][0] = fDaughter[i]->GetParticle()->Px();
+ fPTrack[i][1] = fDaughter[i]->GetParticle()->Py();
+ }
+ fPTrack[i][2] = fDaughter[i]->GetParticle()->Pz();
+ }
+ for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
+
+}
+
//_____________________________________________________________________________
void AliRsnPairParticle::PrintInfo(const Option_t *option)
{
// Print some info of the pair.
// The options are passed to the AliRsnDaughter::Print() method
//
-
+ option = "ALL";
AliInfo("======== BEGIN PAIR INFO ===========");
AliInfo("Track #1");
fDaughter[0]->Print(option);
#include <TMath.h>
#include "AliRsnDaughter.h"
-#include "AliRsnMCInfo.h"
class AliRsnPairParticle : public TObject
{
AliRsnDaughter* GetDaughter(const Int_t &index) const {return fDaughter[index];}
- Bool_t IsLabelEqual() {return abs(fDaughter[0]->Label()) == abs(fDaughter[1]->Label());}
- Bool_t IsIndexEqual() {return (fDaughter[0]->Index() == fDaughter[1]->Index());}
+ Bool_t IsLabelEqual() {return abs(fDaughter[0]->GetLabel()) == abs(fDaughter[1]->GetLabel());}
+ Bool_t IsIndexEqual() {return (fDaughter[0]->GetID() == fDaughter[1]->GetID());}
Bool_t IsTruePair(Int_t refPDG = 0);
+ Int_t CommonMother();
void SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2);
void ResetPair();
- void PrintInfo(const Option_t *option = "");
+ void RotateTrack(Int_t i, Double_t angle, Bool_t isDegrees = kTRUE);
+ void PrintInfo(const Option_t *option = "ALL");
private:
--- /dev/null
+//
+// *** Class AliRsnVATProcessInfo ***
+//
+// TODO
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
+
+#include <TList.h>
+#include <TH1.h>
+
+#include "AliLog.h"
+
+#include "AliRsnVATProcessInfo.h"
+
+ClassImp(AliRsnVATProcessInfo)
+
+//_____________________________________________________________________________
+AliRsnVATProcessInfo::AliRsnVATProcessInfo(const char *name) : TNamed(name,name),
+ fHistUsedEvents(0x0),
+ fPrintInfoNumber(1000)
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+AliRsnVATProcessInfo::AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy) : TNamed(copy),
+ fHistUsedEvents(copy.fHistUsedEvents),
+ fPrintInfoNumber(copy.fPrintInfoNumber)
+
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+AliRsnVATProcessInfo::~AliRsnVATProcessInfo()
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+TList* AliRsnVATProcessInfo::GenerateInfoList() {
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ AliDebug(AliLog::kWarning,"Doing new TList(), so make sure you delete this list ... ");
+
+ TList* list = new TList();
+ list->SetName(GetName());
+ list->SetOwner();
+
+ fHistUsedEvents = new TH1I(GetEventHistogramName(), "skipped and used events in this analysis", 2, 0, 2);
+ list->Add(fHistUsedEvents);
+
+ AliDebug(AliLog::kDebug+2,"->");
+ return list;
+}
+
+void AliRsnVATProcessInfo::FillInfo() {
+ if (!fNumOfTracks)
+ fHistUsedEvents->Fill(fNumOfTracks);
+ else
+ fHistUsedEvents->Fill(1);
+}
+
+void AliRsnVATProcessInfo::PrintInfo(const Long64_t &num) {
+ if ((num+1)%fPrintInfoNumber == 0){
+ AliInfo(Form("Events processed %d",num+1));
+ }
+
+}
+
--- /dev/null
+//
+// *** Class AliRsnVATProcessInfo ***
+//
+// TODO
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
+
+#ifndef AliRsnVATProcessInfo_H
+#define AliRsnVATProcessInfo_H
+
+#include <TNamed.h>
+#include <TH1.h>
+
+class AliRsnVATProcessInfo : public TNamed
+{
+public:
+ AliRsnVATProcessInfo(const char*name="AT_RSNInfo");
+ AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy);
+ AliRsnVATProcessInfo& operator= (const AliRsnVATProcessInfo& /*copy*/) {
+ return *this;
+ }
+ ~AliRsnVATProcessInfo();
+
+ TList* GenerateInfoList();
+ virtual void FillInfo();
+ virtual void PrintInfo(const Long64_t &num);
+
+ void SetNumberOfTracks(const Int_t & num) { fNumOfTracks = num; }
+ Int_t GetNumberOfTracks() { return fNumOfTracks; };
+
+ const char* GetEventHistogramName() { return Form("hEventsUsed_%s",GetName()); };
+
+ void SetPrintInfoNumber(const Long64_t &num=1) { fPrintInfoNumber = num; }
+
+private:
+
+ TH1I *fHistUsedEvents;
+ Int_t fNumOfTracks;
+
+ Long64_t fPrintInfoNumber;
+
+ ClassDef(AliRsnVATProcessInfo, 1)
+};
+
+#endif
--- /dev/null
+//
+// Class AliRsnVAnalysisTaskME
+//
+// Virtual Class derivated from AliAnalysisTaskME which will be base class
+// for all RSN ME tasks
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+// #include "AliAnalysisManager.h"
+// #include "AliAODHandler.h"
+
+#include "AliESDEvent.h"
+#include "AliMCEvent.h"
+#include "AliAODEvent.h"
+
+#include "AliRsnVAnalysisTaskME.h"
+
+ClassImp(AliRsnVAnalysisTaskME)
+
+//_____________________________________________________________________________
+AliRsnVAnalysisTaskME::AliRsnVAnalysisTaskME(const char *name) :
+ AliAnalysisTaskME(name),
+ fLogType(AliLog::kInfo),
+ fLogClassesString(""),
+ fESDEvent(0x0),
+ fMCEvent(0x0),
+ fAODEvent(0x0),
+ fOutList(0x0),
+ fTaskInfo(name)
+{
+//
+// Default constructor
+//
+ AliDebug(AliLog::kDebug+2,"<-");
+ DefineOutput(1, TList::Class());
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+AliRsnVAnalysisTaskME::AliRsnVAnalysisTaskME(const AliRsnVAnalysisTaskME& copy) : AliAnalysisTaskME(copy),
+ fLogType(copy.fLogType),
+ fLogClassesString(copy.fLogClassesString),
+ fESDEvent(copy.fESDEvent),
+ fMCEvent(copy.fMCEvent),
+ fAODEvent(copy.fAODEvent),
+ fOutList(copy.fOutList),
+ fTaskInfo(copy.fTaskInfo)
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::LocalInit()
+{
+//
+// LocalInit()
+//
+ AliLog::SetClassDebugLevel(GetName(), fLogType);
+ SetDebugForOtherClasses();
+
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliAnalysisTaskME::LocalInit();
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnVAnalysisTaskME::Notify()
+{
+//
+// Notify()
+//
+ AliDebug(AliLog::kDebug+2,"<-");
+ return AliAnalysisTaskME::Notify();
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::ConnectInputData(Option_t *opt)
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliAnalysisTaskME::ConnectInputData(opt);
+
+// fESDEvent = dynamic_cast<AliESDEvent *> (fInputEvent);
+// if (fESDEvent)
+// AliInfo(Form("Input is ESD (%p)",fESDEvent));
+//
+// fMCEvent = (AliMCEvent*) MCEvent();
+// if (fMCEvent)
+// AliInfo(Form("Input is MC (%p)",fMCEvent));
+//
+// fAODEvent = dynamic_cast<AliAODEvent *> (fInputEvent);
+// if (fAODEvent)
+// AliInfo(Form("Input is AOD INPUT (%p)",fAODEvent));
+//
+// if (!fAODEvent) {
+// fAODEvent = dynamic_cast<AliAODEvent *> (AODEvent());
+// if (fAODEvent)
+// AliInfo(Form("Input is AOD OUTPUT (%p)",fAODEvent));
+// }
+
+
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::RsnUserCreateOutputObjects()
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::UserCreateOutputObjects()
+{
+ AliLog::SetClassDebugLevel(GetName(), fLogType);
+
+ SetDebugForOtherClasses();
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ fOutList = new TList();
+ fOutList->SetOwner();
+
+ fOutList->Add(fTaskInfo.GenerateInfoList());
+
+ RsnUserCreateOutputObjects();
+
+ AliDebug(AliLog::kDebug+2,"<-");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::UserExec(Option_t* opt)
+{
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ RsnUserExec(opt);
+
+ FillInfo();
+
+ fTaskInfo.PrintInfo(fEntry);
+
+ PostData(1, fOutList);
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::RsnUserExec(Option_t* )
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+// if (fESDEvent) {
+// AliDebug(AliLog::kDebug+1,Form("fESDEvent if %p",fESDEvent));
+// AliDebug(AliLog::kDebug,Form("ESD tracks %d",fESDEvent->GetNumberOfTracks()));
+// }
+// if (fMCEvent) {
+// AliDebug(AliLog::kDebug+1,Form("fMCEvent if %p",fMCEvent));
+// AliDebug(AliLog::kDebug,Form("MC tracks %d",fMCEvent->GetNumberOfTracks()));
+// }
+// if (fAODEvent) {
+// AliDebug(AliLog::kDebug+1,Form("fAODEvent if %p",fAODEvent));
+// AliDebug(AliLog::kDebug,Form("AOD tracks %d",fAODEvent->GetNumberOfTracks()));
+//
+//
+// }
+ AliAODEvent* aod1 = (AliAODEvent*)GetEvent(0);
+ AliAODEvent* aod2 = (AliAODEvent*)GetEvent(1);
+ AliDebug(AliLog::kDebug,Form("AOD tracks %d",aod1->GetNumberOfTracks()));
+ AliDebug(AliLog::kDebug,Form("AOD tracks %d",aod2->GetNumberOfTracks()));
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::Terminate(Option_t* opt)
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliAnalysisTask::Terminate();
+
+ fOutList = dynamic_cast<TList*>(GetOutputData(1));
+ if (!fOutList) {
+ AliError(Form("At end of analysis, fOutList is %p",fOutList));
+ return;
+ }
+
+ RsnTerminate(opt);
+
+ TList* lEventInfo = (TList*) fOutList->FindObject(fTaskInfo.GetName());
+
+ TH1I *hEventInfo = (TH1I*) lEventInfo->FindObject(fTaskInfo.GetEventHistogramName());
+ if (!hEventInfo) {
+ AliError(Form("hEventInfo is %p",hEventInfo));
+ return;
+ }
+
+ AliInfo(Form("=== %s ==================",GetName()));
+ AliInfo(Form("Number Of Events Processed : %10d",(Long64_t)hEventInfo->Integral()));
+ AliInfo(Form("Number Of Events Accepted : %10d",(Long64_t)hEventInfo->GetBinContent(2)));
+ AliInfo(Form("Number Of Events Skipped : %10d",(Long64_t)hEventInfo->GetBinContent(1)));
+ AliInfo(Form("=== end %s ==============",GetName()));
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::RsnTerminate(Option_t* )
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::FillInfo()
+{
+
+ if (fESDEvent) {
+ fTaskInfo.SetNumberOfTracks(fESDEvent->GetNumberOfTracks());
+ } else if (fAODEvent) {
+ fTaskInfo.SetNumberOfTracks(fAODEvent->GetNumberOfTracks());
+ }
+
+ fTaskInfo.FillInfo();
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::SetLogType(AliLog::EType_t type,TString otherClasses)
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ fLogType = type;
+ fLogClassesString = otherClasses;
+ AliDebug(AliLog::kDebug+2,"->");
+}
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskME::SetDebugForOtherClasses()
+{
+ AliDebug(AliLog::kDebug+2,"<-");
+ TObjArray* array = fLogClassesString.Tokenize(":");
+ TObjString *str;
+ TString strr;
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
+ str = (TObjString *) array->At(i);
+ strr = str->GetString();
+ AliLog::SetClassDebugLevel(strr.Data(), fLogType);
+ }
+ AliDebug(AliLog::kDebug+2,"->");
+}
--- /dev/null
+//\r
+// Class AliRsnVAnalysisTaskME\r
+//\r
+// Virtual Class derivated from AliAnalysisTaskME which will be base class\r
+// for all RSN ME tasks\r
+//\r
+// authors: Martin Vala (martin.vala@cern.ch)\r
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)\r
+//\r
+#ifndef AliRsnVATME_H\r
+#define AliRsnVATME_H\r
+\r
+#include <TH1.h>\r
+\r
+#include "AliLog.h"\r
+\r
+#include "AliESDEvent.h"\r
+#include "AliMCEvent.h"\r
+#include "AliAODEvent.h"\r
+\r
+#include "AliRsnVATProcessInfo.h"\r
+\r
+#include "AliAnalysisTaskME.h"\r
+\r
+class AliRsnVAnalysisTaskME : public AliAnalysisTaskME\r
+{\r
+public:\r
+ AliRsnVAnalysisTaskME(const char *name = "AliRsnVAnalysisTaskME");\r
+ AliRsnVAnalysisTaskME(const AliRsnVAnalysisTaskME& copy);\r
+ AliRsnVAnalysisTaskME& operator= (const AliRsnVAnalysisTaskME& /*copy*/) {\r
+ return *this;\r
+ }\r
+ virtual ~AliRsnVAnalysisTaskME() {/* Does nothing*/}\r
+\r
+ virtual void LocalInit();\r
+ virtual Bool_t Notify();\r
+ virtual void ConnectInputData(Option_t *);\r
+ // Implementation of interface methods\r
+ virtual void UserCreateOutputObjects();\r
+ virtual void UserExec(Option_t*);\r
+ virtual void Terminate(Option_t*);\r
+\r
+ // Implement this\r
+ virtual void RsnUserCreateOutputObjects();\r
+ virtual void RsnUserExec(Option_t*);\r
+ virtual void RsnTerminate(Option_t*);\r
+\r
+ virtual void FillInfo();\r
+\r
+ void SetLogType(AliLog::EType_t type,TString otherClasses="");\r
+ void SetPrintInfoNumber(const Long64_t &num=100) { fTaskInfo.SetPrintInfoNumber(num); }\r
+\r
+protected:\r
+\r
+ AliLog::EType_t fLogType;\r
+ TString fLogClassesString;\r
+\r
+ AliESDEvent *fESDEvent; // AliVEvent event\r
+ AliMCEvent *fMCEvent; // ESD event\r
+ AliAODEvent *fAODEvent; // AOD event\r
+\r
+ TList *fOutList;\r
+ AliRsnVATProcessInfo fTaskInfo;\r
+ \r
+ void SetDebugForOtherClasses();\r
+\r
+ ClassDef(AliRsnVAnalysisTaskME, 1)\r
+};\r
+\r
+#endif\r
--- /dev/null
+//
+// Class AliRsnVAnalysisTaskSE
+//
+// Virtual Class derivated from AliAnalysisTaskSE which will be base class
+// for all RSN SE tasks
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include "AliRsnVAnalysisTaskSE.h"
+
+ClassImp(AliRsnVAnalysisTaskSE)
+
+//_____________________________________________________________________________
+AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const char *name) :
+ AliAnalysisTaskSE(name),
+ fLogType(AliLog::kInfo),
+ fLogClassesString(""),
+ fESDEvent(0x0),
+ fMCEvent(0x0),
+ fAODEventIn(0x0),
+ fAODEventOut(0x0),
+ fOutList(0x0),
+ fTaskInfo(name)
+{
+//
+// Default constructor.
+// Define the output slot for histograms.
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ DefineOutput(1, TList::Class());
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy) :
+ AliAnalysisTaskSE(copy),
+ fLogType(copy.fLogType),
+ fLogClassesString(copy.fLogClassesString),
+ fESDEvent(copy.fESDEvent),
+ fMCEvent(copy.fMCEvent),
+ fAODEventIn(copy.fAODEventIn),
+ fAODEventOut(copy.fAODEventOut),
+ fOutList(copy.fOutList),
+ fTaskInfo(copy.fTaskInfo)
+{
+//
+// Copy constructor.
+// Defined for coding conventions compliance but never used.
+//
+
+ AliDebug(AliLog::kDebug+2, "<-");
+ AliDebug(AliLog::kDebug+2, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::LocalInit()
+{
+//
+// Local initialization.
+// Defines the debug message level and calls the mother class LocalInit().
+//
+
+ AliLog::SetClassDebugLevel(GetName(), fLogType);
+ SetDebugForOtherClasses();
+
+ AliDebug(AliLog::kDebug+2, "<-");
+ AliAnalysisTaskSE::LocalInit();
+ AliDebug(AliLog::kDebug+2, "->");
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnVAnalysisTaskSE::Notify()
+{
+//
+// Calls the mother class Notify()
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+
+ return AliAnalysisTaskSE::Notify();
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::ConnectInputData(Option_t *opt)
+{
+//
+// Connect input data.
+// Links the data member pointers to any possible AliVEvenb input
+// to the appropriate object belonging to the mother class,
+// for a fast retrieval of informations from it through the
+// data interface classes provided in this package.
+// Makes use of dynamic_cast, in order to know the kind of input
+// just checking if the casted pointers are NULL or not.
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliAnalysisTaskSE::ConnectInputData(opt);
+
+ // getting AliESDEvent
+ fESDEvent = dynamic_cast<AliESDEvent *> (fInputEvent);
+
+ if (fESDEvent) {
+ AliInfo(Form("Input is ESD (%p)", fESDEvent));
+
+ // getting AliMCEvent
+ fMCEvent = (AliMCEvent*) MCEvent();
+ if (fMCEvent) AliInfo(Form("Input is MC (%p)", fMCEvent));
+ }
+
+ // getting AliAODEvent from input
+ fAODEventIn = dynamic_cast<AliAODEvent *> (fInputEvent);
+ if (fAODEventIn) AliInfo(Form("Input is AOD INPUT (%p)",fAODEventIn));
+
+ // getting AliAODEvent if it is output from previous task
+ fAODEventOut = dynamic_cast<AliAODEvent *> (AODEvent());
+ if (fAODEventOut) AliInfo(Form("Input is AOD OUTPUT (%p)",fAODEventOut));
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects()
+{
+//
+// Define here all instructions to create output objects.
+// This method will be called inside the "UserCreateOutputObjects"
+// in the used task.
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::UserCreateOutputObjects()
+{
+//
+// Creates and links to task all output objects.
+// They are all stored inside a unique TList which will be saved
+// in output slot #1.
+//
+
+ AliLog::SetClassDebugLevel(GetName(), fLogType);
+
+ SetDebugForOtherClasses();
+
+ AliDebug(AliLog::kDebug+2, "<-");
+
+ fOutList = new TList();
+ fOutList->SetOwner();
+
+ fOutList->Add(fTaskInfo.GenerateInfoList());
+
+ RsnUserCreateOutputObjects();
+
+ AliDebug(AliLog::kDebug+2,"<-");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::UserExec(Option_t* opt)
+{
+
+ AliDebug(AliLog::kDebug+2,"<-");
+
+ RsnUserExec(opt);
+
+ FillInfo();
+
+ fTaskInfo.PrintInfo(fEntry);
+
+ PostData(1, fOutList);
+
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t* )
+{
+
+ if (fESDEvent) {
+ AliDebug(AliLog::kDebug+1, Form("fESDEvent is %p", fESDEvent));
+ AliDebug(AliLog::kDebug, Form("ESD tracks %d", fESDEvent->GetNumberOfTracks()));
+ }
+ if (fMCEvent) {
+ AliDebug(AliLog::kDebug+1, Form("fMCEvent is %p", fMCEvent));
+ AliDebug(AliLog::kDebug, Form("MC tracks %d", fMCEvent->GetNumberOfTracks()));
+ }
+ if (fAODEventIn) {
+ AliDebug(AliLog::kDebug+1, Form("fAODEventIn is %p", fAODEventIn));
+ AliDebug(AliLog::kDebug, Form("AOD (in) tracks %d", fAODEventIn->GetNumberOfTracks()));
+ }
+
+ if (fAODEventOut) {
+ AliDebug(AliLog::kDebug+1, Form("fAODEventOut if %p", fAODEventOut));
+ AliDebug(AliLog::kDebug, Form("AOD (out) tracks %d", fAODEventOut->GetNumberOfTracks()));
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::Terminate(Option_t* opt)
+{
+//
+// Termination routines.
+// Stores all histograms (after checking they exist)
+// and includes to the TList all task informations.
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+ AliAnalysisTask::Terminate();
+
+ fOutList = dynamic_cast<TList*>(GetOutputData(1));
+ if (!fOutList) {
+ AliError(Form("At end of analysis, fOutList is %p", fOutList));
+ return;
+ }
+
+ RsnTerminate(opt);
+
+ TList* lEventInfo = (TList*) fOutList->FindObject(fTaskInfo.GetName());
+
+ TH1I *hEventInfo = (TH1I*) lEventInfo->FindObject(fTaskInfo.GetEventHistogramName());
+ if (!hEventInfo) {
+ AliError(Form("hEventInfo is %p",hEventInfo));
+ return;
+ }
+
+ AliInfo(Form("=== %s ==================",GetName()));
+ AliInfo(Form("Number Of Events Processed : %10d",(Long64_t)hEventInfo->Integral()));
+ AliInfo(Form("Number Of Events Accepted : %10d",(Long64_t)hEventInfo->GetBinContent(2)));
+ AliInfo(Form("Number Of Events Skipped : %10d",(Long64_t)hEventInfo->GetBinContent(1)));
+ AliInfo(Form("=== end %s ==============",GetName()));
+
+ AliDebug(AliLog::kDebug+2, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t* )
+{
+//
+// Overload this to add additional termination operations
+//
+
+ AliDebug(AliLog::kDebug+2, "<-");
+ AliDebug(AliLog::kDebug+2, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::FillInfo()
+{
+//
+// Fill information object with statistics of analysis
+//
+
+ AliDebug(AliLog::kDebug+2, "<-");
+ if (fAODEventOut) {
+ fTaskInfo.SetNumberOfTracks(fAODEventOut->GetNumberOfTracks());
+ }
+ else if (fESDEvent) {
+ fTaskInfo.SetNumberOfTracks(fESDEvent->GetNumberOfTracks());
+ }
+ else if (fAODEventIn) {
+ fTaskInfo.SetNumberOfTracks(fAODEventIn->GetNumberOfTracks());
+ }
+
+ fTaskInfo.FillInfo();
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::SetLogType(AliLog::EType_t type, TString otherClasses)
+{
+//
+// Set Log level for this and other classes (list of their names)
+//
+
+ AliDebug(AliLog::kDebug+2,"<-");
+ fLogType = type;
+ fLogClassesString = otherClasses;
+ AliDebug(AliLog::kDebug+2,"->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::SetDebugForOtherClasses()
+{
+//
+// Set debug level for all classes for which it is required
+//
+
+ AliDebug(AliLog::kDebug+2, "<-");
+ TObjArray* array = fLogClassesString.Tokenize(":");
+ TObjString *str;
+ TString strr;
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
+ str = (TObjString *) array->At(i);
+ strr = str->GetString();
+ AliLog::SetClassDebugLevel(strr.Data(), fLogType);
+ }
+ AliDebug(AliLog::kDebug+2,"->");
+}
--- /dev/null
+//\r
+// Class AliRsnVAnalysisTaskSE\r
+//\r
+// Virtual Class derivated from AliAnalysisTaskSE which will be base class\r
+// for all RSN SE tasks\r
+//\r
+// authors: Martin Vala (martin.vala@cern.ch)\r
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)\r
+//\r
+#ifndef ALIRSNVANALYSISTASKSE_H\r
+#define ALIRSNVANALYSISTASKSE_H\r
+\r
+#include <TH1.h>\r
+\r
+#include "AliLog.h"\r
+\r
+#include "AliAnalysisTaskSE.h"\r
+\r
+\r
+#include "AliESDEvent.h"\r
+#include "AliMCEvent.h"\r
+#include "AliAODEvent.h"\r
+// class AliRsnEvent;\r
+\r
+#include "AliRsnVATProcessInfo.h"\r
+\r
+class AliRsnVAnalysisTaskSE : public AliAnalysisTaskSE\r
+{\r
+ public:\r
+\r
+ AliRsnVAnalysisTaskSE(const char *name = "AliRsnVAnalysisTaskSE");\r
+ AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy);\r
+ AliRsnVAnalysisTaskSE& operator= (const AliRsnVAnalysisTaskSE& /*copy*/) { return *this; }\r
+ virtual ~AliRsnVAnalysisTaskSE() {/* Does nothing*/}\r
+\r
+ virtual void LocalInit();\r
+ virtual Bool_t Notify();\r
+ virtual void ConnectInputData(Option_t *);\r
+ // Implementation of interface methods\r
+ virtual void UserCreateOutputObjects();\r
+ virtual void UserExec(Option_t*);\r
+ virtual void Terminate(Option_t*);\r
+\r
+ // Implement this\r
+ virtual void RsnUserCreateOutputObjects();\r
+ virtual void RsnUserExec(Option_t*);\r
+ virtual void RsnTerminate(Option_t*);\r
+\r
+ virtual void FillInfo();\r
+\r
+ void SetLogType(AliLog::EType_t type, TString otherClasses = "");\r
+ void SetPrintInfoNumber(const Long64_t &num = 100) { fTaskInfo.SetPrintInfoNumber(num); }\r
+\r
+ protected:\r
+\r
+ AliLog::EType_t fLogType;\r
+ TString fLogClassesString;\r
+\r
+ AliESDEvent *fESDEvent; // ESD event\r
+ AliMCEvent *fMCEvent; // MC event\r
+ AliAODEvent *fAODEventIn; // AOD event from input\r
+ AliAODEvent *fAODEventOut; // AOD event from output from previous taks\r
+\r
+ TList *fOutList;\r
+ AliRsnVATProcessInfo fTaskInfo;\r
+ \r
+ void SetDebugForOtherClasses();\r
+\r
+ ClassDef(AliRsnVAnalysisTaskSE, 1)\r
+};\r
+\r
+#endif\r
--- /dev/null
+//
+// Class AliRsnVManager
+//
+// Base "manager" class.
+// It is built in order to manage a list of objects which share
+// the same level in the work flow of the analysis.
+// This base class contains simply the list of "child" objects
+// and the methods to add objects to the list or retrieve the list.
+//
+// author : M. Vala [martin.vala@cern.ch]
+// revised by : A. Pulvirenti [alberto.pulvirenti@ct.infn.it]
+//
+
+#include "AliLog.h"
+
+#include "AliRsnVManager.h"
+
+ClassImp(AliRsnVManager)
+
+//_____________________________________________________________________________
+AliRsnVManager::AliRsnVManager(const char*name) :
+ TNamed(name, name),
+ fArray(0)
+{
+//
+// Default constructor
+//
+}
+
+//_____________________________________________________________________________
+AliRsnVManager::~AliRsnVManager()
+{
+//
+// Destructor
+//
+}
+
+//_____________________________________________________________________________
+void AliRsnVManager::Add(TObject *obj)
+{
+//
+// Add a new object in the list.
+//
+
+ fArray.Add((TObject*)obj);
+}
+
+//_____________________________________________________________________________
+void AliRsnVManager::Print(Option_t* /*dummy*/) const
+{
+//
+// Overload of the standard TObject::Print() method.
+//
+
+ PrintArray();
+}
+
+//_____________________________________________________________________________
+void AliRsnVManager::PrintArray() const
+{
+//
+// Calls the "Print()" method of all objects
+// stored in the list, to print their informations.
+//
+
+ TObject *obj = 0;
+ TObjArrayIter next(&fArray);
+ while ((obj = (TObject*)next())) obj->Print();
+}
--- /dev/null
+//
+// Class AliRsnVManager
+//
+// Base "manager" class.
+// It is built in order to manage a list of objects which share
+// the same level in the work flow of the analysis.
+// This base class contains simply the list of "child" objects
+// and the methods to add objects to the list or retrieve the list.
+//
+// author : M. Vala [martin.vala@cern.ch]
+// revised by : A. Pulvirenti [alberto.pulvirenti@ct.infn.it]
+//
+
+#ifndef AliRsnVManager_H
+#define AliRsnVManager_H
+
+#include <TNamed.h>
+
+class AliRsnVManager : public TNamed
+{
+ public:
+
+ AliRsnVManager(const char*name = "default");
+ ~AliRsnVManager();
+
+ virtual void Add(TObject *pair);
+ TObjArray* GetArray() {return &fArray;}
+ Int_t GetEntries() {return fArray.GetEntries();}
+ Int_t GetEntriesFast() {return fArray.GetEntriesFast();}
+ virtual void PrintArray() const;
+ virtual void Print(Option_t *opt = "") const;
+
+ protected:
+
+ TObjArray fArray; // the managed array
+
+ ClassDef(AliRsnVManager, 1)
+};
+
+#endif
static Bool_t useAutoHandler = kFALSE;
static Int_t bufferSize = 3000;
static Int_t pidArraySize = 2000;
-static Int_t nMixedEvents = 5;
+static Int_t nMixedEvents = 10;
-static Bool_t useRsnTrackCuts = kFALSE;
-static Double_t etaRange = 10.0;
-static Double_t rsnImpactParam = 3.0;
-static Double_t ptMin = 0.0;
-
-static Bool_t useESDTrackCuts = kFALSE;
-static Double_t cov11 = 2;
-static Double_t cov22 = 2;
+static Bool_t useESDTrackCuts = kTRUE;
+static Double_t cov11 = 2000000.0; // disabled (was 2.0)
+static Double_t cov22 = 2000000.0; // disabled (was 2.0)
static Double_t cov33 = 0.5;
static Double_t cov44 = 0.5;
static Double_t cov55 = 2;
static Double_t nSigmaToVertex = 4;
static Double_t dcaToVertex = 3.0;
static Double_t maxChi2PerClusterTPC = 3.5;
-static Bool_t requireTPCRefit = kTRUE;
+static Bool_t requireTPCRefit = kFALSE; // disabled (was kTRUE)
static Bool_t requireSigmaToVertex = kTRUE;
static Bool_t acceptKinkDaughters = kFALSE;
static Int_t minNClustersTPC = 50;
//
// initialize task objects and retrieve managers for PID and reading
- AliRsnAnalysisSE *task = new AliRsnAnalysisSE("RsnAnalysisTask", bufferSize);
- AliRsnReader *reader = task->GetReader();
- AliRsnPID *pid = task->GetPID();
+ AliRsnAnalysisSE *task = new AliRsnAnalysisSE("RsnAnalysisTask", bufferSize);
+ AliRsnReader *reader = task->GetReader();
+ AliRsnPID *pid = task->GetPID();
// set the input type
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ if (!mgr) {
+ Error("AddRsnAnalysisTask", "NO AnalysisManager found!!!");
+ return 0x0;
+ }
task->SetInputType(inputType, mgr, useAutoHandler);
// define event-mixing cuts
- AliRsnCut *cutVz = new AliRsnCut("cutVz" , "", AliRsnCut::kVzDifference, 0.0, 0.5);
+ AliRsnCut *cutVz = new AliRsnCut("cutVz" , "", AliRsnCut::kVzDifference, 0.0, 1.0);
AliRsnCut *cutMult = new AliRsnCut("cutMult", "", AliRsnCut::kMultiplicityDifference, 0, 10);
AliRsnCutSet *cutMixing = new AliRsnCutSet("cutMixing");
cutMixing->AddCut(cutVz);
pid->SetPriorProbability(AliRsnPID::kPion, 0.83);
pid->SetPriorProbability(AliRsnPID::kKaon, 0.07);
pid->SetPriorProbability(AliRsnPID::kProton, 0.06);
- pid->SetMaxPt(100.0);
+ pid->SetMaxPt(1000.0);
pid->SetMinProb(0.0);
- // default cuts for ITS+TPC
+ // ESD primary track cuts
AliESDtrackCuts *esdCuts = reader->GetESDTrackCuts();
esdCuts->SetMaxCovDiagonalElements(cov11, cov22, cov33, cov44, cov55);
esdCuts->SetRequireSigmaToVertex(requireSigmaToVertex);
- if (requireSigmaToVertex) esdCuts->SetMaxNsigmaToVertex(nSigmaToVertex);
- else
- {
+ if (requireSigmaToVertex) {
+ esdCuts->SetMaxNsigmaToVertex(nSigmaToVertex);
+ }
+ else {
esdCuts->SetDCAToVertexZ(dcaToVertex);
esdCuts->SetDCAToVertexXY(dcaToVertex);
}
esdCuts->SetAcceptKingDaughters(acceptKinkDaughters);
esdCuts->SetMinNClustersTPC(minNClustersTPC);
esdCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+ // set usage flag
reader->SetUseESDTrackCuts(useESDTrackCuts);
- // default cuts from package for tracks
- AliRsnCut *cutPt = new AliRsnCut("cutPt", "", AliRsnCut::kTransMomentumMC, ptMin, 1000000.0);
- AliRsnCut *cutEta = new AliRsnCut("cutEtaMC", "", AliRsnCut::kEtaMC, -etaRange, etaRange);
- AliRsnCut *cutDr = new AliRsnCut("cutDr", "", AliRsnCut::kRadialImpactParam, 0.0, rsnImpactParam);
- AliRsnCutSet *rsnCuts = reader->GetRsnTrackCuts();
- rsnCuts->AddCut(cutPt);
- rsnCuts->AddCut(cutEta);
- rsnCuts->AddCut(cutDr);
- rsnCuts->SetCutScheme("cutPt&cutEta&cutDr");
- reader->SetUseRsnTrackCuts(useRsnTrackCuts);
-
- // add configs for all impact parameters
- task->AddPairMgrFromConfig("CreatePairsPhi.C");
+ // add configs for PHI and KSTAR in multiplicity bins
+ Int_t mult[6] = {0, 25, 50, 75, 100, 200};
+ for (Int_t im = 0; im < 5; im++) {
+ task->AddPairMgr(CreatePairs(Form("PHI_%d-%d" , mult[im]+1, mult[im+1]), 333, AliRsnPID::kKaon, AliRsnPID::kKaon, mult[im]+1, mult[im+1]));
+ task->AddPairMgr(CreatePairs(Form("KSTAR_%d-%d", mult[im]+1, mult[im+1]), 313, AliRsnPID::kPion, AliRsnPID::kKaon, mult[im]+1, mult[im+1]));
+ }
+ // integrated
+ task->AddPairMgr(CreatePairs("PHI" , 333, AliRsnPID::kKaon, AliRsnPID::kKaon, 0, 0));
+ task->AddPairMgr(CreatePairs("KSTAR", 313, AliRsnPID::kPion, AliRsnPID::kKaon, 0, 0));
// initialize containers
AliAnalysisDataContainer *input = mgr->GetCommonInputContainer();
- AliAnalysisDataContainer *dummy = mgr->CreateContainer("dummy1", TTree::Class(), AliAnalysisManager::kOutputContainer, "default");
+ AliAnalysisDataContainer *dummy = mgr->CreateContainer("dummy", TTree::Class(), AliAnalysisManager::kOutputContainer, "default");
AliAnalysisDataContainer *out = mgr->CreateContainer("RSN", TList::Class(), AliAnalysisManager::kOutputContainer, outputFileName);
// connect containers to AnalysisManager
mgr->ConnectOutput(task, 0, dummy);
mgr->ConnectOutput(task, 1, out);
}
+
+AliRsnPairMgr* CreatePairs
+(
+ const char *pairMgrName, // name for the pair manager
+ Int_t resonancePDG, // PDG code of resonance (for true pairs)
+ AliRsnPID::EType type1, // PID of one member of decay (+)
+ AliRsnPID::EType type2, // PID of other member of decay (-)
+ Int_t multMin, // lower edge of multiplicity cut
+ Int_t multMax // upper edge of multiplicity cut
+)
+{
+//
+// Creates an AliRsnPairMgr for a specified resonance, which contains:
+// - signal (inv. mass)
+// - event mixing (inv. mass)
+// - like-sign (inv. mass)
+// - true pairs (inv. mass, resolution)
+//
+// For all pairs, a binning in Pt and Eta is provided, and a cut in multiplicity
+// which defines a multiplicity bin where the analysis is computed.
+//
+// Arguments define how the pair manager must be built, and are explained above
+//
+
+ AliRsnPairMgr *pairMgr = new AliRsnPairMgr(pairMgrName);
+
+ // === PAIR DEFINITIONS =========================================================================
+
+ // if particle #1 and #2 are different, two histograms must be built
+ // for each scheme (signal, true, mixed, like-sign) exchanging both particles and signs
+ Int_t i, j, nArray = 1;
+ if (type1 != type2) nArray = 2;
+
+ AliRsnPairDef *defUnlike[2] = {0, 0};
+ AliRsnPairDef *defLikePP[2] = {0, 0};
+ AliRsnPairDef *defLikeMM[2] = {0, 0};
+
+ defUnlike[0] = new AliRsnPairDef(type1, '+', type2, '-', resonancePDG);
+ defLikePP[0] = new AliRsnPairDef(type1, '+', type2, '+', resonancePDG);
+ defLikeMM[0] = new AliRsnPairDef(type1, '-', type2, '-', resonancePDG);
+
+ defUnlike[1] = new AliRsnPairDef(type2, '+', type1, '-', resonancePDG);
+ defLikePP[1] = new AliRsnPairDef(type2, '+', type1, '+', resonancePDG);
+ defLikeMM[1] = new AliRsnPairDef(type2, '-', type1, '-', resonancePDG);
+
+ // === PAIR ANALYSIS ENGINES ====================================================================
+
+ // define null (dummy) objects and initialize only the ones which are needed,
+ // depending again on particle types;
+ // array is organized as follows:
+ // [0] - true pairs
+ // [1] - signal
+ // [2] - mixing
+ // [3] - like PP
+ // [4] - like MM
+ AliRsnPair *noPID[2][5] = {0,0,0,0,0,0,0,0,0,0};
+ AliRsnPair *perfectPID[2][5] = {0,0,0,0,0,0,0,0,0,0};
+
+ for (i = 0; i < nArray; i++) {
+ noPID[i][0] = new AliRsnPair(AliRsnPair::kNoPID, defUnlike[i]);
+ noPID[i][1] = new AliRsnPair(AliRsnPair::kNoPID, defUnlike[i]);
+ noPID[i][2] = new AliRsnPair(AliRsnPair::kNoPIDMix, defUnlike[i]);
+ noPID[i][3] = new AliRsnPair(AliRsnPair::kNoPID, defLikePP[i]);
+ noPID[i][4] = new AliRsnPair(AliRsnPair::kNoPID, defLikeMM[i]);
+
+ perfectPID[i][0] = new AliRsnPair(AliRsnPair::kPerfectPID, defUnlike[i]);
+ perfectPID[i][1] = new AliRsnPair(AliRsnPair::kPerfectPID, defUnlike[i]);
+ perfectPID[i][2] = new AliRsnPair(AliRsnPair::kPerfectPIDMix, defUnlike[i]);
+ perfectPID[i][3] = new AliRsnPair(AliRsnPair::kPerfectPID, defLikePP[i]);
+ perfectPID[i][4] = new AliRsnPair(AliRsnPair::kPerfectPID, defLikeMM[i]);
+ }
+
+ // === CUTS =====================================================================================
+
+ // cuts for tracks:
+ // - nothing
+
+ // cuts on pairs:
+ // - minimum transverse momentum of the pair (for all)
+ // - true daughters of the defined resonance (only for true pairs histogram)
+ AliRsnCut *cutTrue = new AliRsnCut("cutTrue", "", AliRsnCut::kIsTruePair, resonancePDG);
+ AliRsnCutSet *cutSetPairTrue = new AliRsnCutSet("truePairs");
+ cutSetPairTrue->AddCut(cutTrue);
+ cutSetPairTrue->SetCutScheme("cutTrue");
+
+ // cuts on events:
+ // - multiplicity bin
+ AliRsnCut *cutEventMult = new AliRsnCut("cutMult", "", AliRsnCut::kTrueMultiplicity, (Int_t)multMin, (Int_t)multMax);
+ AliRsnCutSet *cutSetEvent = new AliRsnCutSet("multiplicity");
+ cutSetEvent->AddCut(cutEventMult);
+ cutSetEvent->SetCutScheme("cutMult");
+
+ // define cut manager for NOT true pairs
+ AliRsnCutMgr *cutMgr = new AliRsnCutMgr("default", "All pairs");
+ if (multMin != multMax) cutMgr->SetCutSet(AliRsnCut::kEvent, cutSetEvent);
+
+ // define cut manager for true pairs
+ AliRsnCutMgr *cutMgrTrue = new AliRsnCutMgr("true", "True pairs");
+ cutMgrTrue->SetCutSet(AliRsnCut::kPair, cutSetPairTrue);
+ if (multMin != multMax) cutMgrTrue->SetCutSet(AliRsnCut::kEvent, cutSetEvent);
+
+ // add cuts to pair analysis
+ for (i = 0; i < nArray; i++) {
+ noPID[i][0]->SetCutMgr(cutMgrTrue);
+ perfectPID[i][0]->SetCutMgr(cutMgrTrue);
+ for (j = 1; j < 5; j++) {
+ noPID[i][j]->SetCutMgr(cutMgr);
+ perfectPID[i][j]->SetCutMgr(cutMgr);
+ }
+ }
+
+ // === FUNCTIONS ================================================================================
+
+ // define histogram templates
+ AliRsnHistoDef *hdIM = new AliRsnHistoDef(1000, 0.0, 2.0);
+ AliRsnFunction *fcnIM = new AliRsnFunction(AliRsnFunction::kInvMass, hdIM);
+
+ // binning in pt
+ //Double_t mom[36];
+ //mom[0] = 0.2;
+ //for (Int_t i = 1; i < 25; i++) mom[i] = mom[i-1] + 0.2;
+ //for (Int_t i = 25; i <= 35; i++) mom[i] = mom[i-1] + 0.5;
+ //fcnIM->SetBinningCut(AliRsnCut::kTransMomentum, 36, mom, 0);
+ //fcnIM->SetBinningCut(AliRsnCut::kTransMomentum, 0.0, 10.0, 0.5, 0);
+
+ // binning in eta
+ //fcnIM->SetBinningCut(AliRsnCut::kEta, -1.0, 1.0, 0.2, 1);
+
+ for (i = 0; i < nArray; i++) {
+ for (j = 0; j < 5; j++) {
+ noPID[i][j]->AddFunction(fcnIM);
+ perfectPID[i][j]->AddFunction(fcnIM);
+ }
+ }
+
+ // === ADD TO PAIR MANAGER ======================================================================
+
+ for (i = 0; i < nArray; i++) {
+ for (j = 0; j < 5; j++) {
+ pairMgr->AddPair(noPID[i][j]);
+ pairMgr->AddPair(perfectPID[i][j]);
+ }
+ }
+
+ return pairMgr;
+}
--- /dev/null
+#ifndef __CINT__
+#endif
+AliAnalysisManager *AliRsnTrain()
+{
+
+ // debug for ANALYSIS manager
+ Int_t debugAnalysisMgr = 0;
+
+ // debug level for RESONANCE package
+ AliLog::EType_t debugRsnType = AliLog::kInfo;
+ Int_t debugRsn = 0;
+// debugRsnType = AliLog::kDebug+debugRsn;
+
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ if (!mgr)
+ mgr = new AliAnalysisManager ( "RSN Train" );
+
+ // setting AnalysisManager debug level
+ mgr->SetDebugLevel ( debugAnalysisMgr );
+
+ // if runESDMCFilter.C is commented then runRsnAnalysis*.C has ESD and MC input
+ // if it is included then runRsnAnalysis*.C has aod (without MC) which is produced by runESDMCFilter.C
+ // do the ESD and MC filter (you can comment it if you want)
+// AddOneTask("runESDMCFilter.C",debugRsnType);
+
+ // do Resonance analysis
+ AddOneTask("runRsnAnalysisSE.C",debugRsnType);
+
+ // ME is not supported yet
+ // AddOneTask("runRsnAnalysisME.C",debugRsnType);
+
+ return mgr;
+}
+
+void AddOneTask(TString macro,AliLog::EType_t debugRsn)
+{
+ gROOT->LoadMacro(Form("%s",macro.Data()));
+ macro.ReplaceAll(".C","");
+ gROOT->ProcessLine(Form("%s((AliLog::EType_t)%d)",macro.Data(),debugRsn));
+}
class AliRsnUtils
{
public:
- enum EType
- {
+ enum EType {
kLocal = 0,
kProof,
kAlien,
kLastIndex
};
- enum EDataType
- {
+ enum EDataType {
kTxt = 0,
kDataSet,
kXmlCollection,
+ kXmlCollectionTag,
kDataLastIndex
};
AliRsnUtils(EType type, TString where, TString reset = "", TString rootVer = "");
- AliRsnUtils(EType type, Bool_t shouldRun = kTRUE, Bool_t shouldCopy = kTRUE);
+ AliRsnUtils(EType type, Bool_t shouldRun = kTRUE, Bool_t shouldCopy = kTRUE,TAlienJDL*jdl=0);
~AliRsnUtils() {}
Bool_t Connect();
- Bool_t CleanPackages(TString pars = "");
- Bool_t LoadPars(TString pars = "STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice:PWG2resonances");
+ Bool_t CleanPackages(TString pars = "all");
+ Bool_t LoadPars(TString pars = "STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice:PWG2resonances",Bool_t loadParsLocaly=kTRUE);
Bool_t SetInputData(EDataType type = kTxt, TString source = "ESD.txt", TString treeName = "esdTree",
TString port = "", Int_t numfiles = 1000000, Int_t filesSkip = 0);
Bool_t Run(TString macro, Long64_t numEvents = 1, Long64_t numEventsSkip = 0);
void ShouldCopy(const Bool_t& theValue) { fShouldCopy = theValue; }
- void SetAlienRunFile(const TString& theValue) { fAlienRunFile = theValue;}
+ void SetAlienRunFile(const TString& theValue) { fAlienRunFile = theValue; }
void AddFilesToAlien(const TString& theValue);
void SetAlienProjectDir(const TString& theValue) { fAlienProjectDir = theValue; }
TString GetAlienProjectDir() const { return fAlienProjectDir; }
+ TAlienJDL* SetJDL(TAlienJDL*jdl) const { fJDL= jdl;}
TAlienJDL* GetJDL() const;
void ShouldRunAlienJob(const Bool_t& theValue) { fShouldRunAlienJob = theValue; }
+ TString GetTagTypeFromTreeName(TString treeName);
+
+ void SetAlienProjectDirSE(TString se="ALICE::CERN::SE") { fAlienProjectDirSE = se; };
+
+ void DoMixing(Bool_t doMix=kTRUE) { fDoMixing = doMix; }
private:
EType fCurrentType; // current analysis type
EDataType fCurrentDataType; // current data type
+ Bool_t fDoMixing; // flag if we will use mixing (AliAnalysisTaskME)
Bool_t fIsConnected; // flag if we are connected
Bool_t fShouldEnd; // flag if macro should be terminated(in case error)
TString fConnectInfo[3]; // connection info (all 3 are use in proof mode)
// AliEn Part
TString fAlienProjectDir; // alien Project directory
+ TString fAlienProjectDirSE; // alien Project directory Storage Element
TString fAlienOutputDir; // alien output directory
TString fAlienRunFile; // run file name (default is AliRsnAlien.C)
TString fFilesToAlien; // list of files to copy to alien additional to
+
// pars. for example (PWG2resonances.C)
TAlienJDL* fJDL; // jdl class which submits job
Bool_t fShouldCopy; // flag if files should be copied to alien
// gets chain from xml collection file
TChain* CreateChainFromCollection(TString chainName = "esdTree", TString collname = "my.xml", Int_t maxFiles = 1000, Int_t skipfiles = 0);
+ // gets chain from xml collection file
+ TChain* CreateChainFromCollectionTag(TString chainName = "ESD", TString collname = "tag.xml");
// copy to AliEn function
Bool_t CopyFilesToAliEn();
AliRsnUtils::AliRsnUtils(EType type, TString where, TString reset, TString rootVer) :
fCurrentType(type),
fCurrentDataType(kTxt),
+ fDoMixing(kFALSE),
fIsConnected(kFALSE),
fShouldEnd(kFALSE),
fChain(0),
+ fAlienProjectDirSE("ALICE::CERN::SE"),
fJDL(0),
fShouldCopy(kTRUE),
fShouldRunAlienJob(kTRUE),
}
//________________________________________________________________________
-AliRsnUtils::AliRsnUtils(EType type, Bool_t shouldRun, Bool_t shouldCopy) :
+AliRsnUtils::AliRsnUtils(EType type, Bool_t shouldRun, Bool_t shouldCopy,TAlienJDL*jdl) :
fCurrentType(type),
fCurrentDataType(kTxt),
+ fDoMixing(kFALSE),
fIsConnected(kFALSE),
fShouldEnd(kFALSE),
fChain(0),
- fJDL(0),
+ fJDL(jdl),
fShouldRunAlienJob(shouldRun),
fShouldCopy(shouldCopy),
fAlienRunFile("AliRsnAlien.C")
Bool_t AliRsnUtils::Connect()
{
// connect to local, proof, alien if needed
- switch (fCurrentType)
- {
+ switch (fCurrentType) {
case kLocal:
PrintInfoString("Running Local...");
fIsConnected = kTRUE;
case kProof:
PrintInfoString(Form("Running Proof at %s...", fConnectInfo[0].Data()));
fIsConnected = ConnectProof();
- if (!IsConnected())
- {
+ if (!IsConnected()) {
PrintErrorString(Form("Not connected to %s !!!", fConnectInfo[0].Data()));
}
break;
case kAlien:
PrintInfoString(Form("Running AliEn..."));
fIsConnected = ConnectAliEn();
- if (!IsConnected())
- {
+ if (!IsConnected()) {
PrintErrorString("Not connected to AliEn !!!");
}
break;
return kFALSE;
}
- if (!IsConnected())
- {
+ if (!IsConnected()) {
PrintErrorString("Connection failed. Aborting...");
return kFALSE;
}
//________________________________________________________________________
Bool_t AliRsnUtils::CleanPackages(TString pars)
{
+
// cleans packages
if (fShouldEnd) return kFALSE;
- switch (fCurrentType)
- {
+ switch (fCurrentType) {
case kLocal:
- if (!IsConnected()) return kFALSE;
return CleanParsLocal(pars);
break;
case kProof:
}
//________________________________________________________________________
-Bool_t AliRsnUtils::LoadPars(TString pars)
+Bool_t AliRsnUtils::LoadPars(TString pars,Bool_t loadParsLocaly)
{
// loads par files
if (fShouldEnd) return kFALSE;
- switch (fCurrentType)
- {
+ switch (fCurrentType) {
case kLocal:
if (!IsConnected()) return kFALSE;
return LoadParsLocal(pars);
return LoadParsProof(pars);
break;
case kAlien:
- if (!pars.IsNull())
- {
+ if (!pars.IsNull()) {
fParNames = pars;
pars.ReplaceAll(":",".par:");
pars += ".par";
AddFilesToAlien(pars);
+ if (loadParsLocaly)
+ return LoadParsLocal(pars);
}
return kTRUE;
break;
//
fDataInfo[type] = source;
-
- switch (type)
- {
+ switch (type) {
case kTxt:
fCurrentDataType = type;
fChain = CreateChainFromTXT(treeName, fDataInfo[type], numfiles, filesSkip, port);
break;
case kXmlCollection:
fCurrentDataType = type;
+ fTreeName = treeName;
+ if (fCurrentType == AliRsnUtils::kAlien) return kTRUE;
if (fCurrentType == AliRsnUtils::kLocal) ConnectAliEn();
fChain = CreateChainFromCollection(treeName, fDataInfo[type], numfiles, filesSkip);
+ break;
+ case kXmlCollectionTag:
+ fCurrentDataType = type;
fTreeName = treeName;
+ if (fCurrentType == AliRsnUtils::kAlien) return kTRUE;
+ if (fCurrentType == AliRsnUtils::kLocal) ConnectAliEn();
+ fDataInfo[type] = source;
+ fChain = CreateChainFromCollectionTag(treeName, fDataInfo[type]);
+
break;
default:
PrintErrorString("Wrong type");
Bool_t AliRsnUtils::Run(TString macro, Long64_t numEvents, Long64_t numEventsSkip)
{
// runs job
- if (fCurrentType == AliRsnUtils::kAlien)
- {
- Bool_t runFileOK = CreateRunAliEnFile(macro);
- Bool_t copyOK = CopyFilesToAliEn();
- Bool_t runJobOK = RunAliEnJob();
- return runFileOK&©OK&&runJobOK;
+ if (fCurrentType == AliRsnUtils::kAlien) {
+ Bool_t returnBool = CreateRunAliEnFile(macro);
+ if (returnBool == kFALSE) return kFALSE;
+ returnBool = CopyFilesToAliEn();
+ if (returnBool == kFALSE) return kFALSE;
+ returnBool = RunAliEnJob();
+ if (returnBool == kFALSE) return kFALSE;
+ return kTRUE;
}
gROOT->LoadMacro(macro.Data());
macro.ReplaceAll(".C","");
AliAnalysisManager *mgr = (AliAnalysisManager *) gROOT->ProcessLine(Form("%s();", macro.Data()));
+ if (!mgr) return kFALSE;
- if (mgr->InitAnalysis())
- {
+ if (mgr->InitAnalysis()) {
mgr->PrintStatus();
- switch (fCurrentDataType)
- {
+ switch (fCurrentDataType) {
case kTxt:
if (!fChain) PrintErrorString("fChain is null");
TString mode = "local";
if (fCurrentType == AliRsnUtils::kProof) mode="proof";
+ if (fDoMixing) mode="mix";
+ Info("AliRsnUtils::Run",Form("Running mgr->StartAnalysis(\"%s\",%p,%d,%d)",mode.Data(),fChain,numEvents,numEventsSkip));
return mgr->StartAnalysis(mode, fChain,numEvents,numEventsSkip);
break;
case kDataSet:
- return mgr->StartAnalysis("proof", fDataInfo[kDataSet].Data(),numEvents,numEventsSkip);
+ TString mode = "local";
+ if (fCurrentType == AliRsnUtils::kProof) mode="proof";
+ if (fDoMixing) mode="mix";
+ Info("AliRsnUtils::Run",Form("Running mgr->StartAnalysis(\"%s\",\"%s\",%d,%d)",mode.Data(),fDataInfo[kDataSet].Data(),numEvents,numEventsSkip));
+ return mgr->StartAnalysis(mode, fDataInfo[kDataSet].Data(),numEvents,numEventsSkip);
break;
case kXmlCollection:
- if (!fChain) PrintErrorString("fChain is null");
- return mgr->StartAnalysis("local", fChain,numEvents,numEventsSkip);
+ if (!fChain) {
+ PrintErrorString("fChain is null");
+ return kFALSE;
+ }
+ TString mode = "local";
+ if (fDoMixing) mode="mix";
+ Info("AliRsnUtils::Run",Form("Running mgr->StartAnalysis(\"%s\",%p,%d,%d)",mode.Data(),fChain,numEvents,numEventsSkip));
+ return mgr->StartAnalysis(mode, fChain,numEvents,numEventsSkip);
+ break;
+ case kXmlCollectionTag:
+ if (!fChain) {
+ PrintErrorString("fChain is null");
+ return kFALSE;
+ }
+ TString mode = "local";
+ if (fDoMixing) mode="mix";
+ Info("AliRsnUtils::Run",Form("Running mgr->StartAnalysis(\"%s\",%p,%d,%d)",mode.Data(),fChain,numEvents,numEventsSkip));
+ return mgr->StartAnalysis(mode, fChain,numEvents,numEventsSkip);
break;
default:
PrintErrorString("Wrong type");
//________________________________________________________________________
Bool_t AliRsnUtils::ConnectProof()
{
-// connects to proof
-//
-// if one uses AliRsnUtils::kProof constructor
-// AliRsnUtils ( AliRsnUtils::kProof,TString where = "mvala@lxb6046.cern.ch
+ // connects to proof
+ //
+ // if one uses AliRsnUtils::kProof constructor
+ // AliRsnUtils ( AliRsnUtils::kProof,TString where = "mvala@lxb6046.cern.ch
// " , TString reset = "RESET", TString rootVer = "HEADXYZ" );
//
// where : means where to connect
// reset : "RESET" will do gProof->Reset(where.Data());
// rootVer : "HEADXYZ" will use different version of root, in this case "HEADXYZ"
//
- if (fConnectInfo[0].IsNull())
- {
+ if (fConnectInfo[0].IsNull()) {
PrintErrorString("Proof is empty!!!");
return kFALSE;
}
Bool_t AliRsnUtils::ConnectAliEn()
{
// connects to alien
- TGrid::Connect("alien://");
+ if (!gGrid)
+ TGrid::Connect("alien://");
if (!gGrid)
return kFALSE;
// pars = "STEERBase:ESD"
// will delete STEERBase and ESD directories
//
+
+ if (pars.IsNull()) return kTRUE;
+
+ if (!pars.CompareTo("all")) pars = fgPARS;
+
TObjArray* array = pars.Tokenize(":");
TObjString *str;
TString strr;
- for (Int_t i=0;i< array->GetEntriesFast();i++)
- {
- TObjString *str = (TObjString *) array->At(i);
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
+ str = (TObjString *) array->At(i);
strr = str->GetString();
+ Info("",Form("Cleaning %s.par...",strr.Data()));
gSystem->Exec(Form("rm -Rf %s/",strr.Data()));
}
{
// clear par files in proof (divided by ":"). example "STEERBase:ESD"
// will clear STEERBase.par and ESD.par
-// if pars is null clears all packages
+// if pars is ALL clears all packages
- TObjArray* array = (TObjArray*) pars.Tokenize(":");
+ if (pars.IsNull()) return kTRUE;
- if (pars.IsNull())
- {
+ if (!pars.CompareTo("all")) {
+ Info("",Form("Cleaning %s par files...",pars.Data()));
gProof->ClearPackages();
return kTRUE;
}
+
+ TObjArray* array = (TObjArray*) pars.Tokenize(":");
TObjString *str;
TString strr;
- for (Int_t i=0;i< array->GetEntriesFast();i++)
- {
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
str = (TObjString *) array->At(i);
strr = str->GetString();
+ Info("",Form("Cleaning %s.par...",strr.Data()));
gProof->ClearPackage(strr.Data());
}
TObjArray* array = pars.Tokenize(":");
TObjString *str;
TString strr;
- for (Int_t i=0;i< array->GetEntriesFast();i++)
- {
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
str = (TObjString *) array->At(i);
strr = str->GetString();
- if (!ProcessPAR(strr.Data()))
- {
+ if (!ProcessPAR(strr.Data())) {
return kFALSE;
}
}
TObjArray* array = pars.Tokenize(":");
TObjString *str;
TString strr;
- for (Int_t i=0;i< array->GetEntriesFast();i++)
- {
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
if (fShouldEnd) return kFALSE;
str = (TObjString *) array->At(i);
strr = str->GetString();
gSystem->Exec(Form("rm -Rf %s",strr.Data()));
- if (gProof->UploadPackage(Form("%s.par", strr.Data())))
- {
+ if (gProof->UploadPackage(Form("%s.par", strr.Data()))) {
PrintErrorString(Form("Error uploading %s package!!!",strr));
fShouldEnd = kTRUE;
return kFALSE;
}
- if (gProof->EnablePackage(strr))
- {
+ if (gProof->EnablePackage(strr)) {
PrintErrorString(Form("Error loading %s package!!!",strr));
fShouldEnd = kTRUE;
return kFALSE;
if (!fShouldCopy) return kTRUE;
- if (fAlienProjectDir.IsNull())
- {
+ if (fAlienProjectDir.IsNull()) {
fAlienProjectDir = Form("%sRSNTASK/01",gGrid->GetHomeDirectory());
PrintWarningString(Form("Alien Project directory is not defined.Setting \"%s\" as project directory ...",fAlienProjectDir.Data()));
}
TObjArray* array = fFilesToAlien.Tokenize(":");
TObjString *str;
TString strr;
- for (Int_t i=0;i< array->GetEntriesFast();i++)
- {
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
str = (TObjString *) array->At(i);
strr = str->GetString();
if (!CopyFileToAlien(Form("%s",strr.Data()) ,kFALSE)) return kFALSE;
}
- if (CopyFileToAlien(fAlienRunFile.Data(),kFALSE)) return kFALSE;
+ if (!CopyFileToAlien(fAlienRunFile.Data(),kFALSE)) return kFALSE;
return kTRUE;
}
if (!IsConnected()) return kFALSE;
TString file = fAlienRunFile.Data();
ofstream outFile(file.Data());
- if (!outFile)
- {
+ if (!outFile) {
PrintErrorString(Form("Cannot open file %s",file.Data()));
return kFALSE;
}
tmp = Form("Int_t %s() {",file.Data());
outFile << tmp.Data() << endl;
- tmp = "\tgROOT->LoadMacro (\"PWG2resonancesUtils.C\");";
+
+
+ tmp = "\tTStopwatch timer;";
outFile << tmp.Data() << endl;
- tmp = "\tAliRsnUtils *utils = new AliRsnUtils (AliRsnUtils::kLocal);";
+ tmp = "\ttimer.Start();\n";
outFile << tmp.Data() << endl;
- tmp = Form("\tif (!utils->LoadPars(\"%s\")) return -1;",fParNames.Data());
-// tmp = Form("\tif (!utils->LoadPars(\"PWG2resonances\")) return -1;",fParNames.Data());
+ tmp = "\tBool_t returnValue = kTRUE;\n";
outFile << tmp.Data() << endl;
- tmp = Form("\tif (!(utils->SetInputData(AliRsnUtils::kXmlCollection,\"wn.xml\",\"%s\"))) return -1;",fTreeName.Data());
+ tmp = "\tgROOT->LoadMacro (\"PWG2resonancesUtils.C\");\n";
outFile << tmp.Data() << endl;
- tmp = Form("\tutils->Run(\"%s\",10000000);",macro.Data());
+ tmp = "\tAliRsnUtils *utils = new AliRsnUtils (AliRsnUtils::kLocal);\n";
outFile << tmp.Data() << endl;
- tmp = Form("return 0;",file.Data());
+ tmp = Form("\treturnValue = utils->LoadPars(\"%s\");",fParNames.Data());
+ outFile << tmp.Data() << endl;
+
+ tmp = "\tif (returnValue == kFALSE) {\n";
+ tmp += "\t\tError(\"\",\"Error in utils->LoadPars()\");\n";
+ tmp += "\t\ttimer.Stop();\n";
+ tmp += "\t\ttimer.Print();\n";
+ tmp += "\t\treturn -1;\n";
+ tmp += "\t}\n";
+ outFile << tmp.Data() << endl;
+
+ TString collTypeName;
+ if (fCurrentDataType == kXmlCollection) {
+ collTypeName = "AliRsnUtils::kXmlCollection";
+ } else if (fCurrentDataType == kXmlCollectionTag) {
+ collTypeName = "AliRsnUtils::kXmlCollectionTag";
+ } else {
+ Error("",Form("File %s was not created correctly!!!!!!!",macro.Data()));
+ return kFALSE;
+ }
+
+ tmp = Form("\treturnValue = utils->SetInputData(%s,\"wn.xml\",\"%s\");",collTypeName.Data(),fTreeName.Data());
+ outFile << tmp.Data() << endl;
+
+ tmp = "\tif (returnValue == kFALSE) {\n";
+ tmp += "\t\tError(\"\",\"Error in utils->SetInputData()\");\n";
+ tmp += "\t\ttimer.Stop();\n";
+ tmp += "\t\ttimer.Print();\n";
+ tmp += "\t\treturn -1;\n";
+ tmp += "\t}\n";
+ outFile << tmp.Data() << endl;
+
+ tmp = Form("\treturnValue = utils->Run(\"%s\",10000000);",macro.Data());
+ outFile << tmp.Data() << endl;
+
+ tmp = "\tif (returnValue == kFALSE) {\n";
+ tmp += "\t\tError(\"\",\"Error in utils->Run()\");\n";
+ tmp += "\t\ttimer.Stop();\n";
+ tmp += "\t\ttimer.Print();\n";
+ tmp += "\t\treturn -1;\n";
+ tmp += "\t}\n";
+ outFile << tmp.Data() << endl;
+
+ tmp = "\ttimer.Stop();";
+ outFile << tmp.Data() << endl;
+
+ tmp = "\ttimer.Print();\n";
+ outFile << tmp.Data() << endl;
+
+ tmp = Form("\treturn 0;",file.Data());
outFile << tmp.Data() << endl;
tmp = Form("}",file.Data());
TObjArray* array = fFilesToAlien.Tokenize(":");
TObjString *str;
TString strr;
- for (Int_t i=0;i< array->GetEntriesFast();i++)
- {
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
str = (TObjString *) array->At(i);
strr = str->GetString().Data();
fJDL->AddToInputSandbox(Form("LF:%s/%s",fAlienProjectDir.Data(),strr.Data())) ;
if (fShouldRunAlienJob == kFALSE)
PrintInfoString(Form("\n%s",fJDL->Generate().Data()));
- else
- {
+ else {
TGridJob* job = gGrid->Submit(fJDL->Generate());
- if (job == 0)
- {
+ if (job == 0) {
Error("SubmitTest", "submitting failed");
return kFALSE;
}
Bool_t AliRsnUtils::CopyFileToAlien(TString file, Bool_t overwrite)
{
// copy one file to alien
- if (fAlienProjectDir.IsNull())
- {
+ if (fAlienProjectDir.IsNull()) {
PrintErrorString("AliEn project directory does not exist...");
return kFALSE;
}
TString pararchivenameS(pars);
PrintInfoString(Form("==== Processing %s package LOCAL =====",pararchivenameS.Data()));
- if (gSystem->AccessPathName(Form("%s.par",pararchivenameS.Data())))
- {
+ if (gSystem->AccessPathName(Form("%s.par",pararchivenameS.Data()))) {
PrintErrorString(Form("File %s.par was not found !!!",pararchivenameS.Data()));
return kFALSE;
}
// gSystem->ChangeDirectory(Form("%s/%s",dirname,pararchivenameS.Data()));
gSystem->ChangeDirectory(Form("%s",pararchivenameS.Data()));
// check for BUILD.sh and execute
- if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh"))
- {
+ if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
PrintInfoString(Form("==== Building %s package =====",pararchivenameS.Data()));
- if (gSystem->Exec("PROOF-INF/BUILD.sh"))
- {
+ if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
EPrintErrorString("Cannot Build the PAR Archive! - Abort!");
return kFALSE;
}
}
// check for SETUP.C and execute
- if (!gSystem->AccessPathName("PROOF-INF/SETUP.C"))
- {
+ if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
PrintInfoString(Form("==== Running SETUP.C of %s package =====",pararchivenameS.Data()));
gROOT->Macro("PROOF-INF/SETUP.C");
- if (gROOT->Macro("PROOF-INF/SETUP.C"))
- {
+ if (gROOT->Macro("PROOF-INF/SETUP.C")) {
PrintErrorString("Cannot SETUP the PAR Archive! - Abort!");
return kFALSE;
}
// ...
PrintInfoString(Form("Loading the chain %s", chainName.Data()));
- if (aDataDir.IsNull())
- {
+ if (aDataDir.IsNull()) {
PrintErrorString(Form("aDataDir not found."));
return kFALSE;
}
Long_t id, size, flags, modtime;
- if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
- {
+ if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime)) {
PrintErrorString(Form("%s not found.", aDataDir.Data()));
return kFALSE;
}
// Read the input list of files and add them to the chain
TString esdfile;
- while (fileIn.good())
- {
+ while (fileIn.good()) {
fileIn >> esdfile;
if (esdfile.IsNull()) continue;
- if (offset > 0)
- {
+ if (offset > 0) {
--offset;
continue;
}
// add esd file
TString esdFileWithPort(esdfile);
esdFileWithPort.ReplaceAll("root://","");
- esdFileWithPort.ReplaceAll("//",Form(":%s//",portNum.Data()));
- // PrintInfoString (Form ("Adding root://%s",esdFileWithPort.Data()));
+ if (!portNum.IsNull())
+ esdFileWithPort.ReplaceAll("//",Form(":%s//",portNum.Data()));
+ PrintInfoString (Form ("Adding root://%s",esdFileWithPort.Data()));
chain->Add(Form("root://%s",esdFileWithPort.Data()));
}
fileIn.close();
TChain *chain = new TChain(chainName.Data());
TAlienCollection *myCollection = TAlienCollection::Open(collname.Data());
- if (!myCollection)
- {
+ if (!myCollection) {
PrintErrorString(Form("Cannot create an AliEn collection from %s", collectionFile));
return 0x0;
}
Int_t nfiles = 0;
TString filename;
myCollection->Reset();
- while (myCollection->Next())
- {
- if (skipfiles > 0) { --skipfiles; continue; }
+ while (myCollection->Next()) {
+ if (skipfiles > 0) {
+ --skipfiles;
+ continue;
+ }
if (maxFiles > 0 && nfiles >= maxFiles) break;
// char fileName[255];
// sprintf(fileName, "%s", myCollection->GetTURL(""));
return chain;
}
+//________________________________________________________________________
+TChain* AliRsnUtils::CreateChainFromCollectionTag
+(TString chainName, TString collname)
+{
+// gets chain from xml collection file
+
+ TAlienCollection *coll = TAlienCollection::Open(collname.Data());
+ if (!coll) {
+ PrintErrorString(Form("Cannot create an AliEn collection from %s", collname.Data()));
+ return 0x0;
+ }
+
+ TString anaType = GetTagTypeFromTreeName(chainName);
+ if (anaType.IsNull()) {
+ PrintErrorString(Form("anaType is %s", anaType.Data()));
+ return (TChain*)0x0;
+ }
+
+ TGridResult* tagResult = coll->GetGridResult("",kFALSE,kFALSE);
+ AliTagAnalysis *tagAna = new AliTagAnalysis(anaType.Data());
+ tagAna->ChainGridTags(tagResult);
+
+ AliRunTagCuts *runCuts = new AliRunTagCuts();
+ AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
+ AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
+ AliEventTagCuts *evCuts = new AliEventTagCuts();
+ // Check if the cuts configuration file was provided
+ if (!gSystem->AccessPathName("ConfigureCuts.C")) {
+ gROOT->LoadMacro("ConfigureCuts.C");
+ ConfigureCuts(runCuts, lhcCuts, detCuts, evCuts);
+ }
+ TChain *chain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evCuts);
+ if (!chain || !chain->GetNtrees()) return (TChain*)0x0;
+ chain->ls();
+ return chain;
+
+}
+
//________________________________________________________________________
void AliRsnUtils::AddFilesToAlien(const TString &fileName)
{
// adds file to alien's list which will be copied to alien
if (fFilesToAlien.IsNull()) fFilesToAlien += fileName;
- else
- {
+ else {
fFilesToAlien += ":";
fFilesToAlien += fileName;
}
if (!fJDL) fJDL = (TAlienJDL*) gGrid->GetJDLGenerator();
return fJDL;
}
+
+//________________________________________________________________________
+TString AliRsnUtils::GetTagTypeFromTreeName(TString treeName)
+{
+// gets Tag name
+
+ if (!treeName.CompareTo("esdTree"))
+ return "ESD";
+ if (!treeName.CompareTo("aodTree"))
+ return "AOD";
+
+ return "";
+}
+
+// EXTRA MACROS
+
+static TString fgMode,fgProofToConnect,fgLIBS,fgPARS,fgPARSClean,fgMacro,fgPostMacro,fgInputFileName,fgTreeName;
+static TString fgAlirootLibPath;
+static TString fgPort,fgUser,fgReset,fgRootVersionInProof,fgCollName;
+static TString fgProjectDir,fgOutputDir,fgExtraInputFiles,fgProjectDirSE;
+static TString fgPostMacroArgs;
+static Int_t fgDataType,fgAlienSplit;
+static Long64_t fgNumOfEvents,fgNumOfEventsSkip;
+static Bool_t fgAlienShouldRun = kFALSE, fgAlienShoudlCopy = kFALSE,fgUseLocalLibs=kFALSE,fgDoMixing=kFALSE;
+static TAlienJDL *fgJDL=0;
+Bool_t runLocal()
+{
+
+ Bool_t returnBool = kTRUE;
+
+ // creating utils (located in macro PWG2resonancesUtils.C)
+ AliRsnUtils *utils = new AliRsnUtils(AliRsnUtils::kLocal);
+ utils->DoMixing(fgDoMixing);
+
+ returnBool = utils->CleanPackages ( fgPARSClean );
+ if (!returnBool) return kFALSE;
+
+ // Loading pars
+// if (fgUseLocalLibs)
+ returnBool = runLocalLibs(fgLIBS.Data(),fgAlirootLibPath.Data());
+// else
+ returnBool = utils->LoadPars(fgPARS.Data());
+
+ if (!returnBool) return kFALSE;
+
+ // Input Data
+ returnBool = utils->SetInputData((AliRsnUtils::EDataType)fgDataType,fgInputFileName,fgTreeName,fgPort);
+ if (!returnBool) return kFALSE;
+
+// utils->Print();
+
+ if (fgMacro.IsNull()) {
+ utils->PrintErrorString("fMacro is null");
+ return kFALSE;
+ }
+
+ // Running Macro
+ utils->Run(fgMacro.Data(),fgNumOfEvents,fgNumOfEventsSkip);
+
+ return returnBool;
+}
+Bool_t runProof()
+{
+
+ Bool_t returnBool = kTRUE;
+
+ // creating utils (located in macro PWG2resonancesUtils.C)
+ AliRsnUtils *utils = new AliRsnUtils(AliRsnUtils::kProof,fgProofToConnect,fgReset,fgRootVersionInProof);
+ utils->DoMixing(fgDoMixing);
+
+ utils->CleanPackages(fgPARSClean);
+
+ // Loading pars
+ returnBool = utils->LoadPars(fgPARS.Data());
+ if (!returnBool) return kFALSE;
+
+ // Input Data
+ returnBool = utils->SetInputData((AliRsnUtils::EDataType)fgDataType,fgInputFileName,fgTreeName);
+ if (!returnBool) return kFALSE;
+
+ // runs macro
+ if (fgMacro.IsNull()) {
+ utils->PrintErrorString("fgMacro is null");
+ return kFALSE;
+ }
+ utils->Run(fgMacro.Data(),fgNumOfEvents,fgNumOfEventsSkip);
+ return returnBool;
+}
+
+Bool_t runAlien()
+{
+ Bool_t returnBool = kTRUE;
+
+ // creating utils (located in macro PWG2resonancesUtils.C)
+ AliRsnUtils *utils = new AliRsnUtils ( AliRsnUtils::kAlien,fgAlienShouldRun,fgAlienShoudlCopy,fgJDL);
+ utils->DoMixing(fgDoMixing);
+
+ // Loading pars
+ if (fgUseLocalLibs) {
+ returnBool = runLocalLibs(fgPARS.Data());
+ if (!returnBool) return kFALSE;
+ }
+ returnBool = utils->LoadPars(fgPARS.Data(),!fgUseLocalLibs);
+ if (!returnBool) return kFALSE;
+
+ // Input Data
+ returnBool = utils->SetInputData((AliRsnUtils::EDataType)fgDataType,fgInputFileName,fgTreeName);
+ if (!returnBool) return kFALSE;
+
+
+ // set Directory in AliEn where all files will be copied first
+ // WARNING this directory will be removed first when fgAlienShoudlCopy
+ // in AliRsnUtils constructor is set to kTRUE and it is done by default
+// utils->SetAlienProjectDir("/alice/cern.ch/user/m/mvala/RSNTASK/FILTER/28001");
+ utils->SetAlienProjectDir(fgProjectDir.Data());
+ // sets pname string (Project dir) for JDL setup
+// TString pname(utils->GetAlienProjectDir());
+
+ if (fgMacro.IsNull()) {
+ utils->PrintErrorString("fgMacro is null");
+ return kFALSE;
+ }
+
+ // not working
+ if (!fgProjectDirSE.IsNull()) {
+ utils->SetAlienProjectDirSE(fgProjectDirSE);
+ }
+
+ //run AliEn job (if shouldRun is set to kTRUE, if not it will just copy files
+ //if shouldCopy is set to kTRUE)
+ utils->Run(fgMacro.Data(),fgNumOfEvents,fgNumOfEventsSkip);
+
+ // uncomment it when you wanna have
+ // AliEn shell after job is submited
+ //gGrid->Shell();
+
+ return returnBool;
+}
+
+Bool_t runLocalLibs(TString pars,TString pathToAliRoot="$ALICE_ROOT/lib/tgt_$ALICE_TARGET")
+{
+ Bool_t returnBool = kTRUE;
+
+ if (pars.IsNull()) return kTRUE;
+
+ gSystem->Load("libGeom.so");
+
+ TObjArray* array = pars.Tokenize(":");
+ TObjString *str;
+ TString strr;
+ for (Int_t i=0;i< array->GetEntriesFast();i++) {
+ str = (TObjString *) array->At(i);
+ strr = str->GetString();
+ Info("",Form("Loading %s ...",Form("%s/lib%s",gSystem->ExpandPathName(Form("%s",pathToAliRoot.Data())),strr.Data())));
+ gSystem->Load(Form("%s/lib%s",gSystem->ExpandPathName(Form("%s",pathToAliRoot.Data())),strr.Data()));
+ }
+
+
+ return returnBool;
+}
--- /dev/null
+#ifndef __CINT__
+#endif
+Bool_t RunOnProof(TString macro,Long64_t numberOfEvents, Long64_t skipEvents)
+{
+
+ fgMode = "proof";
+
+ // adds standard ANALYSIS parfiles
+ fgPARS = "STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice";
+
+ // adds standard RESONANCE parfiles
+ fgPARS += ":PWG2resonances";
+
+ fgPARSClean = "";
+// fgPARSClean = "all";
+
+ fgUser = gSystem->ExpandPathName("$USER");
+
+// fReset="RESET";
+// fgProofToConnect = Form("%s@localhost:2093",fgUser.Data());
+// fgProofToConnect = Form("%s@localhost:3093",fgUser.Data());
+ fgProofToConnect = Form("%s@alicecaf.cern.ch",fgUser.Data());
+// fgProofToConnect = Form("%s@alicepc100.jinr.ru",fgUser.Data());
+// fgPARSClean = "PWG2resonances:PWG2resonancesTEST";
+// fgPARSClean="ALL";
+
+ fgDataType = (Int_t) AliRsnUtils::kDataSet;
+ fgInputFileName = "/COMMON/COMMON/LHC08c12_0.9TeV_0.5T";
+// fgInputFileName = "/COMMON/COMMON/LHC08c11_10TeV_0.5T";
+// fgInputFileName = "/COMMON/COMMON/LHC09a4_10TeV";
+
+// fgDataType = (Int_t) AliRsnUtils::kTxt;
+// fgInputFileName = "ESD_alicepc100_PDC08_test_ssd.txt";
+// fgInputFileName = "ESD_alicepc100_PDC08_test_hdd.txt";
+
+
+ // sets up macro
+ fgMacro = macro;
+
+ // number of events
+ fgNumOfEvents = numberOfEvents;
+
+ // number of events to skip
+ fgNumOfEventsSkip = skipEvents;
+
+
+ return runProof();
+}
+
+Bool_t RunLocaly(TString macro,Long64_t numberOfEvents, Long64_t skipEvents)
+{
+
+ fgMode = "local";
+// fgUseLocalLibs = kTRUE;
+ fgAlirootLibPath = "$ALICE_ROOT/lib/tgt_$ALICE_TARGET";
+// fgAlirootLibPath = "$ALIMV/$ALICE_TARGET/lib";
+
+ // adds standard ANALYSIS parfiles
+ fgPARS = "STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice";
+ if (fgUseLocalLibs) {
+// Info("","Loading AliRoot Libs ...");
+// gROOT->Macro(Form("%s/macros/loadlibs.C",gSystem->ExpandPathName("$ALICE_ROOT/")));
+// Info("","Loading AliRoot Libs is done...");
+ fgPARS = "";
+ fgLIBS = "STEERBase:ESD:AOD";
+// fgLIBS += ":ANALYSIS:ANALYSISalice";
+ fgPARS += "ANALYSIS:ANALYSISalice";
+ }
+ // adds standard RESONANCE parfiles
+ fgPARS += ":PWG2resonances";
+
+ // clean packages
+// fgPARSClean = "all";
+// fgPARSClean = "ANALYSISTest:PWG2resonances:PWG2resonancesMV";
+
+ // input
+ fgDataType = (Int_t) AliRsnUtils::kTxt;
+ fgInputFileName = "ESD.txt";
+ fgTreeName = "esdTree";
+// fgInputFileName = "AOD_vala_PDC08.txt";
+// fgTreeName = "aodTree";
+// fgDoMixing = kTRUE;
+
+ // sets up macro
+ fgMacro = macro;
+ // number of events
+ fgNumOfEvents = numberOfEvents;
+ // number of events to skip
+ fgNumOfEventsSkip = skipEvents;
+
+ return runLocal();
+
+}
+
+Bool_t RunOnAliEn()
+{
+
+ TGrid::Connect("alien://");
+
+ fgMode = "alien";
+
+// fgAlienShouldRun = kTRUE;
+// fgAlienShoudlCopy = kTRUE;
+
+ // adds standard ANALYSIS parfiles
+ fgPARS = "STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice";
+
+ // adds standard RESONANCE parfiles
+ fgPARS += ":PWG2resonances";
+
+ fgPARSClean = "";
+
+ TString productionName = "PDC07f";
+ Int_t tagCollNum = 160009;
+ if (num>0)
+ tagCollNum = num;
+ fgAlienSplit=50;
+ fgProjectDir = Form("/alice/cern.ch/user/m/mvala/RSNTASK/ANALYSIS/%s_50/ALL",productionName.Data());
+ // fProjectDir = Form("/alice/cern.ch/user/m/mvala/RSNTASK/ANALYSIS/%s/%d",productionName.Data(),tagCollNum);
+ fgOutputDir = Form("/alice/cern.ch/user/m/mvala/DATA/RSN/%s_50/%d",productionName.Data(),tagCollNum);
+
+
+// fgDataType = AliRsnUtils::kXmlCollection;
+// fgCollName = Form("/alice/cern.ch/user/m/mvala/DATA/ESD/collections/PDC07f/%d.xml",tagCollNum);
+ fgDataType = AliRsnUtils::kXmlCollectionTag;
+ fgCollName = Form("/alice/cern.ch/user/m/mvala/DATA/ESD/collections/PDC07f/%d_tag.xml",tagCollNum);
+ fgInputFileName = Form("alien://%s",fCollName.Data());
+
+
+ // extra files
+ fgExtraInputFiles = "PWG2resonancesUtils.C:runRSNFilterAdvanced.C:runPhiAnalysisAll.C:runPIDComparison.C";
+ fgExtraInputFiles += ":runRSNProcessInfo.C:RsnConfig_PHIKK.C";
+
+ fgJDL = (TAlienJDL*) gGrid->GetJDLGenerator();
+
+ // jdl part (you can use mini.jdl or set up by yourself
+ // utils->GetJDL()->... [take look in TAlienJDL in $ROOTSYS/net/alien/])
+// utils->GetJDL()->Parse ( "mini.jdl" );
+ fgJDL->SetExecutable("root.sh");
+// fgJDL->SetExecutable("aliroot.sh");
+ fgJDL->AddToPackages("VO_ALICE@APISCONFIG::V2.4");
+ fgJDL->AddToPackages("VO_ALICE@ROOT::v5-21-01-alice");
+// fgJDL->AddToPackages("VO_ALICE@AliRoot::v4-15-Rev-04");
+ fgJDL->AddToOutputArchive("log_archive.zip:stdout,stderr@ALICE::CERN::SE");
+ fgJDL->AddToOutputArchive("root_archive.zip:*.root@ALICE::CERN::SE");
+// fgJDL->SetOutputDirectory(Form("%s/",pname.Data()));
+ fgJDL->SetOutputDirectory(Form("%s/#alien_counter_03i#",fgOutputDir.Data()));
+ fgJDL->SetSplitMode("se", fgAlienSplit);
+ fgJDL->SetInputDataList("wn.xml");
+ fgJDL->SetInputDataListFormat("xml-single");
+// fgJDL->SetInputDataListFormat(Form("merge:%s",fCollName.Data()));
+
+ fgJDL->AddToInputDataCollection(Form("LF:%s,nodownload",fgCollName.Data()));
+// fgJDL->AddToMerge("histOut.root:/alice/jdl/mergerootfile.jdl:histOut.Merged.root");
+// fgJDL->SetMergedOutputDirectory(Form("%s",pname.Data()));
+
+ return runAlien();
+}
--- /dev/null
+AliRsnPairManager *RsnConfig_PHI(const char *name="PHI")
+{
+ return CreatePairs(name, 333, AliAODTrack::kKaon, AliAODTrack::kKaon, 0, 10000);
+}
+
+AliRsnPairManager *RsnConfig_KSTAR(const char *name="KSTAR")
+{
+ return CreatePairs(name, 313, AliAODTrack::kPion, AliAODTrack::kKaon, 0, 10000);
+}
+
+
+AliRsnPairManager* CreatePairs
+(
+ const char *pairMgrName, // name for the pair manager
+ Int_t resonancePDG, // PDG code of resonance (for true pairs)
+ AliAODTrack::AODTrkPID_t type1, // PID of one member of decay (+)
+ AliAODTrack::AODTrkPID_t type2, // PID of other member of decay (-)
+ Int_t multMin, // lower edge of multiplicity cut
+ Int_t multMax // upper edge of multiplicity cut
+)
+{
+//
+// Creates an AliRsnPairMgr for a specified resonance, which contains:
+// - signal (inv. mass)
+// - event mixing (inv. mass)
+// - like-sign (inv. mass)
+// - true pairs (inv. mass, resolution)
+//
+// For all pairs, a binning in Pt and Eta is provided, and a cut in multiplicity
+// which defines a multiplicity bin where the analysis is computed.
+//
+// Arguments define how the pair manager must be built, and are explained above
+//
+
+ AliRsnPairManager *pairMgr = new AliRsnPairManager(pairMgrName);
+ //cout << "Creating " << pairMgrName << endl;
+
+// return pairMgr;
+
+ // === PAIR DEFINITIONS =========================================================================
+
+ // if particle #1 and #2 are different, two histograms must be built
+ // for each scheme (signal, true, mixed, like-sign) exchanging both particles and signs
+ Int_t i, j, nArray = 1;
+ if (type1 != type2) nArray = 2;
+
+ AliRsnPairDef *defUnlike[2] = {0, 0};
+ AliRsnPairDef *defLikePP[2] = {0, 0};
+ AliRsnPairDef *defLikeMM[2] = {0, 0};
+
+ defUnlike[0] = new AliRsnPairDef(type1, '+', type2, '-', resonancePDG);
+ defLikePP[0] = new AliRsnPairDef(type1, '+', type2, '+', resonancePDG);
+ defLikeMM[0] = new AliRsnPairDef(type1, '-', type2, '-', resonancePDG);
+
+ defUnlike[1] = new AliRsnPairDef(type2, '+', type1, '-', resonancePDG);
+ defLikePP[1] = new AliRsnPairDef(type2, '+', type1, '+', resonancePDG);
+ defLikeMM[1] = new AliRsnPairDef(type2, '-', type1, '-', resonancePDG);
+
+ // === PAIR ANALYSIS ENGINES ====================================================================
+
+ // define null (dummy) objects and initialize only the ones which are needed,
+ // depending again on particle types;
+ // array is organized as follows:
+ // [0] - true pairs
+ // [1] - signal
+ // [2] - mixing
+ // [3] - like PP
+ // [4] - like MM
+ AliRsnPair *noPIDnoCut[2][5] = {0,0,0,0,0,0,0,0,0,0};
+ AliRsnPair *noPIDwithCut[2][5] = {0,0,0,0,0,0,0,0,0,0};
+ AliRsnPair *realisticPID[2][5] = {0,0,0,0,0,0,0,0,0,0};
+ AliRsnPair *perfectPID[2][5] = {0,0,0,0,0,0,0,0,0,0};
+
+ for (i = 0; i < nArray; i++) {
+ noPIDnoCut[i][0] = new AliRsnPair(AliRsnPair::kNoPID, defUnlike[i]);
+ noPIDnoCut[i][1] = new AliRsnPair(AliRsnPair::kNoPID, defUnlike[i]);
+ noPIDnoCut[i][2] = new AliRsnPair(AliRsnPair::kNoPIDMix, defUnlike[i]);
+ noPIDnoCut[i][3] = new AliRsnPair(AliRsnPair::kNoPID, defLikePP[i]);
+ noPIDnoCut[i][4] = new AliRsnPair(AliRsnPair::kNoPID, defLikeMM[i]);
+
+ noPIDwithCut[i][0] = new AliRsnPair(AliRsnPair::kNoPID, defUnlike[i]);
+ noPIDwithCut[i][1] = new AliRsnPair(AliRsnPair::kNoPID, defUnlike[i]);
+ noPIDwithCut[i][2] = new AliRsnPair(AliRsnPair::kNoPIDMix, defUnlike[i]);
+ noPIDwithCut[i][3] = new AliRsnPair(AliRsnPair::kNoPID, defLikePP[i]);
+ noPIDwithCut[i][4] = new AliRsnPair(AliRsnPair::kNoPID, defLikeMM[i]);
+
+ realisticPID[i][0] = new AliRsnPair(AliRsnPair::kRealisticPID, defUnlike[i]);
+ realisticPID[i][1] = new AliRsnPair(AliRsnPair::kRealisticPID, defUnlike[i]);
+ realisticPID[i][2] = new AliRsnPair(AliRsnPair::kRealisticPIDMix, defUnlike[i]);
+ realisticPID[i][3] = new AliRsnPair(AliRsnPair::kRealisticPID, defLikePP[i]);
+ realisticPID[i][4] = new AliRsnPair(AliRsnPair::kRealisticPID, defLikeMM[i]);
+
+ perfectPID[i][0] = new AliRsnPair(AliRsnPair::kPerfectPID, defUnlike[i]);
+ perfectPID[i][1] = new AliRsnPair(AliRsnPair::kPerfectPID, defUnlike[i]);
+ perfectPID[i][2] = new AliRsnPair(AliRsnPair::kPerfectPIDMix, defUnlike[i]);
+ perfectPID[i][3] = new AliRsnPair(AliRsnPair::kPerfectPID, defLikePP[i]);
+ perfectPID[i][4] = new AliRsnPair(AliRsnPair::kPerfectPID, defLikeMM[i]);
+ }
+
+ // === CUTS =====================================================================================
+
+ // cuts for tracks:
+ // - probability to be a kaon (only for kaons)
+ AliRsnCut *cutAssignedKaon = new AliRsnCut("cutAssignedKaon", "", AliRsnCut::kAssignedPID, AliAODTrack::kKaon);
+ AliRsnCut *cutProbKaon = new AliRsnCut("cutProbKaon", "", AliRsnCut::kPIDProbForSpecies, (Int_t)AliAODTrack::kKaon);
+ cutProbKaon->SetCutValues(AliRsnCut::kPIDProbForSpecies, 0.15, 1.0);
+ AliRsnCutSet *cutSetTrack = new AliRsnCutSet("tracks");
+ cutSetTrack->AddCut(cutAssignedKaon);
+ cutSetTrack->AddCut(cutProbKaon);
+ cutSetTrack->SetCutScheme("(!cutAssignedKaon)|(cutAssignedKaon&cutProbKaon)");
+
+ // cuts on pairs:
+ // - true daughters of the defined resonance (only for true pairs histogram)
+ AliRsnCut *cutPairTrue = new AliRsnCut("cutTrue", "", AliRsnCut::kIsTruePair, resonancePDG);
+ AliRsnCutSet *cutSetPairTrue = new AliRsnCutSet("truePairs");
+ cutSetPairTrue->AddCut(cutPairTrue);
+ cutSetPairTrue->SetCutScheme("cutTrue");
+
+ // cuts on events:
+ // - multiplicity bin
+ AliRsnCut *cutEventMult = new AliRsnCut("cutMult", "", AliRsnCut::kMultiplicity, multMin, multMax);
+ AliRsnCutSet *cutSetEvent = new AliRsnCutSet("multiplicity");
+ cutSetEvent->AddCut(cutEventMult);
+ cutSetEvent->SetCutScheme("cutMult");
+
+ // define cut manager for NOT true pairs
+ AliRsnCutMgr *cutMgr = new AliRsnCutMgr("default", "All pairs");
+ cutMgr->SetCutSet(AliRsnCut::kEvent, cutSetEvent);
+
+ // define cut manager for true pairs
+ AliRsnCutMgr *cutMgrTrue = new AliRsnCutMgr("true", "True pairs");
+ cutMgrTrue->SetCutSet(AliRsnCut::kEvent, cutSetEvent);
+ cutMgrTrue->SetCutSet(AliRsnCut::kPair, cutSetPairTrue);
+
+ // define cut manager for NOPID with kaon prob cut
+ // define cut manager for NOT true pairs
+ AliRsnCutMgr *cutMgrProb = new AliRsnCutMgr("probK", "All pairs with kaon probability cut");
+ cutMgrProb->SetCutSet(AliRsnCut::kEvent, cutSetEvent);
+ cutMgrProb->SetCutSet(AliRsnCut::kParticle, cutSetTrack);
+
+ // define cut manager for true pairs
+ AliRsnCutMgr *cutMgrTrueProb = new AliRsnCutMgr("true+probK", "True pairs with kaon probability cut");
+ cutMgrTrueProb->SetCutSet(AliRsnCut::kEvent, cutSetEvent);
+ cutMgrTrueProb->SetCutSet(AliRsnCut::kPair, cutSetPairTrue);
+ cutMgrTrueProb->SetCutSet(AliRsnCut::kParticle, cutSetTrack);
+
+ // add cuts to pair analysis
+ for (i = 0; i < nArray; i++) {
+ noPIDnoCut[i][0]->SetCutMgr(cutMgrTrue);
+ noPIDwithCut[i][0]->SetCutMgr(cutMgrTrueProb);
+ realisticPID[i][0]->SetCutMgr(cutMgrTrue);
+ perfectPID[i][0]->SetCutMgr(cutMgrTrue);
+ for (j = 1; j < 5; j++) {
+ noPIDnoCut[i][j]->SetCutMgr(cutMgr);
+ noPIDwithCut[i][j]->SetCutMgr(cutMgrProb);
+ realisticPID[i][j]->SetCutMgr(cutMgr);
+ perfectPID[i][j]->SetCutMgr(cutMgr);
+ }
+ }
+
+ // === FUNCTIONS ================================================================================
+
+ // define histogram templates
+ AliRsnHistoDef *hdIM = new AliRsnHistoDef(1600, 0.0, 4.0);
+ AliRsnFunction *fcnIM = new AliRsnFunction(AliRsnFunction::kInvMass, hdIM);
+
+ // binning in pt
+ //Double_t mom[36];
+ //mom[0] = 0.2;
+ //for (Int_t i = 1; i < 25; i++) mom[i] = mom[i-1] + 0.2;
+ //for (Int_t i = 25; i <= 35; i++) mom[i] = mom[i-1] + 0.5;
+ //fcnIM->SetBinningCut(AliRsnCut::kTransMomentum, 36, mom, 0);
+ fcnIM->SetBinningCut(AliRsnCut::kTransMomentum, 0.0, 10.0, 0.5, 0);
+
+ // binning in eta
+ //fcnIM->SetBinningCut(AliRsnCut::kEta, -1.0, 1.0, 0.2, 1);
+
+ for (i = 0; i < nArray; i++) {
+ for (j = 0; j < 5; j++) {
+ noPIDnoCut[i][j]->AddFunction(fcnIM);
+ noPIDwithCut[i][j]->AddFunction(fcnIM);
+ realisticPID[i][j]->AddFunction(fcnIM);
+ perfectPID[i][j]->AddFunction(fcnIM);
+ }
+ }
+
+ // === ADD TO PAIR MANAGER ======================================================================
+
+ for (i = 0; i < nArray; i++) {
+ for (j = 0; j < 5; j++) {
+ pairMgr->AddPair(noPIDnoCut[i][j]);
+ pairMgr->AddPair(noPIDwithCut[i][j]);
+ pairMgr->AddPair(realisticPID[i][j]);
+ pairMgr->AddPair(perfectPID[i][j]);
+ }
+ }
+
+ return pairMgr;
+}
--- /dev/null
+AliRsnPairManager *RsnConfigTest(const char *name="PHI->KK")
+{
+ AliRsnPairManager *pairMgr = new AliRsnPairManager(name);
+
+ AliRsnPairDef *defKPKM = new AliRsnPairDef(AliAODTrack::kKaon, '+', AliAODTrack::kKaon, '-');
+ AliRsnPairDef *defKPKP = new AliRsnPairDef(AliAODTrack::kKaon, '+', AliAODTrack::kKaon, '+');
+ AliRsnPairDef *defKMKM = new AliRsnPairDef(AliAODTrack::kKaon, '-', AliAODTrack::kKaon, '-');
+
+ // =========== DEFINE PAIRS ==============
+
+ // NoPID
+ AliRsnPair *pairKPKM_N = new AliRsnPair(AliRsnPair::kNoPID, defKPKM);
+ AliRsnPair *pairKPKM_NS = new AliRsnPair(AliRsnPair::kNoPID, defKPKM);
+ AliRsnPair *pairKPKM_NM = new AliRsnPair(AliRsnPair::kNoPIDMix, defKPKM/*, 5*/);
+ AliRsnPair *pairKPKP_N = new AliRsnPair(AliRsnPair::kNoPID, defKPKP);
+ AliRsnPair *pairKMKM_N = new AliRsnPair(AliRsnPair::kNoPID, defKMKM);
+ // end NoPID
+
+ // REALISTIC PID
+ AliRsnPair *pairKPKM_R = new AliRsnPair(AliRsnPair::kRealisticPID, defKPKM);
+ AliRsnPair *pairKPKP_R = new AliRsnPair(AliRsnPair::kRealisticPID, defKPKP);
+ AliRsnPair *pairKMKM_R = new AliRsnPair(AliRsnPair::kRealisticPID, defKMKM);
+ AliRsnPair *pairKPKM_RM = new AliRsnPair(AliRsnPair::kRealisticPIDMix, defKPKM/*,5*/);
+ // end REALISTIC PID
+
+ // REALISTIC PID Signal
+ AliRsnPair *pairKPKM_RS = new AliRsnPair(AliRsnPair::kRealisticPID, defKPKM);
+ AliRsnPair *pairKPKM_RS2 = new AliRsnPair(AliRsnPair::kRealisticPID, defKPKM);
+ // end REALISTIC PID Signal
+
+ // PERFECT PID
+ AliRsnPair *pairKPKM_P = new AliRsnPair(AliRsnPair::kPerfectPID, defKPKM);
+ // end PERFECT PID
+ // =========== END DEFINE PAIRS ==============
+
+// // =========== CUTS ==============
+ ULong_t status = AliESDtrack::kESDpid;
+ // status |=| AliESDtrack::kITSpid | AliESDtrack::kTPCpid;
+ // status |= AliESDtrack::kTOFpid;
+
+ AliRsnCut *cutStatus = new AliRsnCut("statusCut_ITS_TPC",
+ "Status Cut for ITS and TPC",
+ AliRsnCut::kStatus,
+ status);
+ AliRsnCut *cutESDLabelEqual = new AliRsnCut("cutESDLabelEqual",
+ "cutESDLabelEqual",
+ AliRsnCut::kIsLabelEqual);
+ AliRsnCut *cutPtESDPart = new AliRsnCut("cutPtESDPart", "cutPtESDPart", AliRsnCut::kTransMomentum, 0.2, 10000.0);
+ AliRsnCut *cutEtaESDPart = new AliRsnCut("cutESDEta", "cutESDEta", AliRsnCut::kEta, -0.9,0.9);
+
+ AliRsnCutSet *cutSetParticleESD = new AliRsnCutSet("StatusCut");
+// cutSetParticleESD->AddCut(cutStatus);
+// cutSetParticleESD->SetCutScheme("statusCut_ITS_TPC");
+ cutSetParticleESD->AddCut(cutPtESDPart);
+ cutSetParticleESD->AddCut(cutEtaESDPart);
+// cutSetParticleESD->AddCut(cutStatus);
+// cutSetParticleESD->SetCutScheme("cutPtESDPart&statusCut_ITS_TPC");
+ cutSetParticleESD->SetCutScheme("cutPtESDPart&cutESDEta");
+
+ AliRsnCutSet *cutSetPairESD = new AliRsnCutSet("esdLabel");
+ cutSetPairESD->AddCut(cutESDLabelEqual);
+ cutSetPairESD->SetCutScheme("!cutESDLabelEqual");
+//
+ AliRsnCut *cutPtMCPart = new AliRsnCut("cutPtMCPart", "cutPtMCPart", AliRsnCut::kTransMomentumMC, 0.2, 10000.0);
+ AliRsnCut *cutEtaMCPart = new AliRsnCut("cutMcEta", "cutMcEta", AliRsnCut::kEtaMC, -0.9,0.9);
+ AliRsnCutSet *cutSetParticleMC = new AliRsnCutSet("MCCut");
+ cutSetParticleMC->AddCut(cutPtMCPart);
+ cutSetParticleMC->AddCut(cutEtaMCPart);
+ cutSetParticleMC->SetCutScheme("cutPtMCPart&cutMcEta");
+//
+ AliRsnCutMgr *cutMgrESD = new AliRsnCutMgr("cutMgr", "Cut Mgr");
+ cutMgrESD->SetCutSet(AliRsnCut::kParticle, cutSetParticleESD);
+ cutMgrESD->SetCutSet(AliRsnCut::kPair, cutSetPairESD);
+//
+ AliRsnCut *cutIsTruePair = new AliRsnCut("cutIsTruePair", "cutIsTruePair", AliRsnCut::kIsTruePair, 333);
+//
+ AliRsnCutSet *cutSetPairSignal = new AliRsnCutSet("cutSetPairSignal");
+ cutSetPairSignal->AddCut(cutIsTruePair);
+ cutSetPairSignal->SetCutScheme("cutIsTruePair");
+//
+ AliRsnCutMgr *cutMgrSignal = new AliRsnCutMgr("cutMgrESDSignal","Cut Mgr Signal");
+ cutMgrSignal->SetCutSet(AliRsnCut::kParticle,cutSetParticleESD);
+ cutMgrSignal->SetCutSet(AliRsnCut::kParticle,cutSetParticleMC);
+ cutMgrSignal->SetCutSet(AliRsnCut::kPair,cutSetPairSignal);
+
+ AliRsnCutMgr *cutMgrSignal2 = new AliRsnCutMgr("cutMgrESDSignalNoCut","Cut Mgr Signal");
+// cutMgrSignal2->SetCutSet(AliRsnCut::kParticle,cutSetParticleESD);
+ cutMgrSignal2->SetCutSet(AliRsnCut::kPair,cutSetPairSignal);
+
+ AliRsnCutMgr *cutMgrSignalMC = new AliRsnCutMgr("cutMgrMCSignal","Cut Mgr Signal");
+// cutMgrSignalMC->SetCutSet(AliRsnCut::kParticle,cutSetParticleMC);
+ cutMgrSignalMC->SetCutSet(AliRsnCut::kPair,cutSetPairSignal);
+
+// pairKPKM_N->SetCutMgr(cutMgrESD);
+// // pairKPKM_NS->SetCutMgr(cutMgrESD);
+// pairKPKM_NM->SetCutMgr(cutMgrESD);
+// pairKPKP_N->SetCutMgr(cutMgrESD);
+// pairKMKM_N->SetCutMgr(cutMgrESD);
+ pairKPKM_R->SetCutMgr(cutMgrESD);
+// // pairKPKM_RS->SetCutMgr(cutMgrESD);
+// pairKPKM_RM->SetCutMgr(cutMgrESD);
+ pairKPKP_R->SetCutMgr(cutMgrESD);
+ pairKMKM_R->SetCutMgr(cutMgrESD);
+// pairKPKM_P->SetCutMgr(cutMgrESD);
+ //
+// // pairKPKM_N->SetCutMgr(cutMgrSignal);
+// pairKPKM_NS->SetCutMgr(cutMgrSignal);
+// // pairKPKM_NM->SetCutMgr(cutMgrSignal);
+// // pairKPKP_N->SetCutMgr(cutMgrSignal);
+// // pairKMKM_N->SetCutMgr(cutMgrSignal);
+// // pairKPKM_R->SetCutMgr(cutMgrSignal);
+ pairKPKM_RS->SetCutMgr(cutMgrSignal);
+ pairKPKM_RS2->SetCutMgr(cutMgrSignal2);
+// pairKPKM_RM->SetCutMgr(cutMgrSignal);
+// pairKPKP_R->SetCutMgr(cutMgrSignal);
+// pairKMKM_R->SetCutMgr(cutMgrSignal);
+ pairKPKM_P->SetCutMgr(cutMgrSignalMC);
+
+// // =========== END CUTS ==============
+
+ // =========== FUNCTIONS ==============
+
+ Double_t mom[11] = {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0};
+ Double_t eta[10] = {-0.9,-0.7,-0.5,-0.3,-0.1,0.1,0.3,0.5,0.7,0.9};
+// AliRsnHistoDef *hdInvMass = new AliRsnHistoDef(1400, 0.6, 2.0);
+ AliRsnHistoDef *hdInvMass = new AliRsnHistoDef(200,0.9,1.1);
+ AliRsnHistoDef *hdInvMassMC = new AliRsnHistoDef(200,0.9,1.1);
+
+ AliRsnHistoDef *hdPt = new AliRsnHistoDef(100,0.0,5.0);
+ AliRsnHistoDef *hdEta = new AliRsnHistoDef(100,-2.0,2.0);
+
+ Int_t num=0;
+ AliRsnFunction *fcnIM[10];
+
+ fcnIM[num] = new AliRsnFunction(AliRsnFunction::kInvMass,hdInvMass,kTRUE);
+ fcnIM[num]->SetBinningCut(AliRsnCut::kTransMomentum, 11, mom,0);
+ fcnIM[num]->SetBinningCut(AliRsnCut::kEta, 10, eta,1);
+ num++;
+
+// fcnIMMC[num] = new AliRsnFunction(AliRsnFunction::kInvMassMC,hdInvMassMC, kTRUE);
+// fcnIMMC[num]->SetBinningCut(AliRsnCut::kTransMomentum, 9, mom);
+// num++;
+
+// fcnIM[num] = new AliRsnFunction(AliRsnFunction::kPtSpectrum,hdPt,kTRUE);
+// fcnIM[num]->SetBinningCut(AliRsnCut::kTransMomentum, 11, mom);
+// num++;
+
+ fcnIM[num] = new AliRsnFunction(AliRsnFunction::kEtaSpectrum,hdEta,kTRUE);
+// fcnIM[num]->SetBinningCut(AliRsnCut::kEta, 11, eta);
+ fcnIM[num]->SetBinningCut(AliRsnCut::kTransMomentum, 11, mom,0);
+// fcnIM[num]->SetBinningCut(AliRsnCut::kEta, 10, eta,1);
+ num++;
+
+ Int_t i;
+ for (i=0;i<num ;i++)
+ {
+ pairKPKM_N->AddFunction(fcnIM[i]);
+ pairKPKM_NS->AddFunction(fcnIM[i]);
+ pairKPKM_NM->AddFunction(fcnIM[i]);
+ pairKPKP_N->AddFunction(fcnIM[i]);
+ pairKMKM_N->AddFunction(fcnIM[i]);
+ pairKPKM_R->AddFunction(fcnIM[i]);
+ pairKPKM_RS->AddFunction(fcnIM[i]);
+ pairKPKM_RS2->AddFunction(fcnIM[i]);
+ pairKPKM_RM->AddFunction(fcnIM[i]);
+ pairKPKP_R->AddFunction(fcnIM[i]);
+ pairKMKM_R->AddFunction(fcnIM[i]);
+ pairKPKM_P->AddFunction(fcnIM[i]);
+
+ }
+ // =========== END FUNCTIONS =============
+
+// // pairMgr->AddPair(pairKPKM_N);
+// // pairMgr->AddPair(pairKPKM_NS);
+// // pairMgr->AddPair(pairKPKM_NM);
+// // pairMgr->AddPair(pairKPKP_N);
+// // pairMgr->AddPair(pairKMKM_N);
+ pairMgr->AddPair(pairKPKM_R);
+ pairMgr->AddPair(pairKPKM_RS);
+ pairMgr->AddPair(pairKPKM_RS2);
+// // pairMgr->AddPair(pairKPKM_RM);
+ pairMgr->AddPair(pairKPKP_R);
+ pairMgr->AddPair(pairKMKM_R);
+ pairMgr->AddPair(pairKPKM_P);
+ return pairMgr;
+
+}
--- /dev/null
+void runESDMCFilter(AliLog::EType_t debugRsn=AliLog::kInfo,Bool_t useKine = kTRUE)
+{
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+// useKine = kTRUE;
+
+ AliESDInputHandler* inpHandler = new AliESDInputHandler();
+ // Output
+ AliAODHandler* aodHandler = new AliAODHandler();
+ aodHandler->SetOutputFileName("AliAODs.root");
+ // MC Truth
+ AliMCEventHandler* mcHandler = new AliMCEventHandler();
+
+ if (useKine) mgr->SetMCtruthEventHandler(mcHandler);
+ mgr->SetInputEventHandler (inpHandler);
+ mgr->SetOutputEventHandler (aodHandler);
+
+ // Filtering of MC particles (decays conversions etc)
+ // this task is also needed to set the MCEventHandler
+ // to the AODHandler, this will not be needed when
+ // AODHandler goes to ANALYSISalice
+ AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
+ if (useKine) mgr->AddTask(kinefilter);
+
+
+ // standard
+ AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");
+ esdTrackCutsL->SetMinNClustersTPC(50);
+ esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
+ esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
+ esdTrackCutsL->SetRequireTPCRefit(kTRUE);
+ esdTrackCutsL->SetMaxNsigmaToVertex(3);
+ esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);
+ esdTrackCutsL->SetAcceptKinkDaughters(kTRUE);
+
+ // hard
+ AliESDtrackCuts* esdTrackCutsH = new AliESDtrackCuts("AliESDtrackCuts", "Hard");
+ esdTrackCutsH->SetMinNClustersTPC(100);
+ esdTrackCutsH->SetMaxChi2PerClusterTPC(2.0);
+ esdTrackCutsH->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
+ esdTrackCutsH->SetRequireTPCRefit(kTRUE);
+ esdTrackCutsH->SetMaxNsigmaToVertex(2);
+ esdTrackCutsH->SetRequireSigmaToVertex(kTRUE);
+ esdTrackCutsH->SetAcceptKinkDaughters(kTRUE);
+
+ AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
+ trackFilter->AddCuts(esdTrackCutsL);
+ trackFilter->AddCuts(esdTrackCutsH);
+
+ AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
+
+ // comment it when you wanna have same number of tracks in AOD as in ESD (simply no cut on track)
+ esdfilter->SetTrackFilter(trackFilter);
+
+ mgr->AddTask(esdfilter);
+
+ //
+ // Create containers for input/output
+ AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+ AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();
+
+ coutput1->SetSpecialOutput();
+
+ if (useKine) {
+ mgr->ConnectInput (kinefilter, 0, cinput1 );
+ mgr->ConnectOutput (kinefilter, 0, coutput1 );
+ }
+
+ mgr->ConnectInput (esdfilter, 0, cinput1 );
+ mgr->ConnectOutput (esdfilter, 0, coutput1 );
+
+}
+
--- /dev/null
+#ifndef __CINT__
+#endif
+void runProcess()
+{
+
+ TStopwatch timer;
+ timer.Start();
+
+ Bool_t boolProcess = kTRUE;
+
+ gROOT->LoadMacro("PWG2resonancesUtils.C");
+ gROOT->LoadMacro("ProcessConfig.C");
+
+ // number of events
+ Long64_t numOfEvents = 10000;
+ // number of events to skip
+ Long64_t numOfEventsSkip = 330000*0;
+
+ TString macro;
+ macro = "AliRsnTrain.C";
+
+// boolProcess = RunLocaly(macro,numOfEvents,numOfEventsSkip);
+ boolProcess = RunOnProof(macro,numOfEvents,numOfEventsSkip);
+// boolProcess = RunOnAliEn(macro,numOfEvents,numOfEventsSkip);
+
+ timer.Stop();
+ timer.Print();
+
+ Info("","Process ended %s.",((boolProcess)?"OK":"with an ERROR"));
+
+}
+
--- /dev/null
+void runRsnAnalysisSE(AliLog::EType_t type=AliLog::kInfo,Bool_t useKine = kTRUE)
+{
+
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ AliAnalysisDataContainer *cin;
+ AliAnalysisDataContainer *cout;
+
+ cin = SetCorrectHandlersAndReturnInput(mgr,useKine);
+
+ AliRsnAnalysisSE *task = new AliRsnAnalysisSE("AliRsnAnalysisSE");
+ task->SetLogType(type,"AliRsnAnalysisManager:AliRsnPairManager:AliRsnPairManager:AliRsnPair");
+ task->SetPrintInfoNumber(10);
+
+ task->SetPriorProbability(AliRsnDaughter::kElectron, 0.02);
+ task->SetPriorProbability(AliRsnDaughter::kMuon, 0.02);
+ task->SetPriorProbability(AliRsnDaughter::kPion, 0.83);
+ task->SetPriorProbability(AliRsnDaughter::kKaon, 0.07);
+ task->SetPriorProbability(AliRsnDaughter::kProton, 0.06);
+ task->DumpPriors();
+
+ AliRsnAnalysisManager *analMgr = task->GetAnalysisManager("MyAnalysisSE");
+ Int_t i=0;
+ Int_t analNum=1;
+ for (i=0;i<analNum;i++) {
+// analMgr->AddConfig("RsnConfigTest.C",Form("PHI%d",i),);
+ analMgr->AddConfig("RsnConfig.C",Form("PHI%d",i),"RsnConfig_PHI");
+ analMgr->AddConfig("RsnConfig.C",Form("KSTAR%d",i),"RsnConfig_KSTAR");
+ }
+
+ AliAnalysisDataContainer *output = mgr->CreateContainer("RSNSE", TList::Class(), AliAnalysisManager::kOutputContainer, "RSNAnalysis.root");
+
+ mgr->AddTask(task);
+
+ mgr->ConnectInput(task, 0, cin);
+ mgr->ConnectOutput(task, 1, output);
+
+}
+
+AliAnalysisDataContainer *SetCorrectHandlersAndReturnInput(AliAnalysisManager *mgr,Bool_t useKine = kTRUE)
+{
+
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+
+ AliAnalysisDataContainer *cin;
+
+ if (useKine) {
+ AliMCEventHandler* mcInputHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+ if (!mcInputHandler) {
+ Info("","Creating mcInputHandler ...");
+ AliMCEventHandler* mcInputHandler = new AliMCEventHandler();
+ mgr->SetMCtruthEventHandler(mcInputHandler);
+ }
+ }
+
+ AliESDInputHandler *esdInputHandler = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+ if (!esdInputHandler) {
+ Info("","Creating esdInputHandler ...");
+ esdInputHandler = new AliESDInputHandler();
+ mgr->SetInputEventHandler (esdInputHandler);
+ cin = mgr->GetCommonInputContainer();
+ } else {
+ cin = mgr->GetCommonOutputContainer();
+ }
+
+ return cin;
+}