--- /dev/null
+//
+// Class AliRsnAnalysisSE
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include <TSystem.h>
+#include <TFile.h>
+#include <TFolder.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)
+ : AliRsnAnalysisTaskSEBase(name),
+ fPairMgrs(0),fOutList(0x0),fRsnEventBuffer(0x0),
+ fNumOfEventsInBuffer(1000)
+{
+//=========================================================
+// Default constructor
+//=========================================================
+
+ InitIOVars();
+ DefineOutput(1, TList::Class());
+}
+
+//________________________________________________________________________
+AliRsnAnalysisSE::~AliRsnAnalysisSE()
+{
+//=========================================================
+// Destructor
+//=========================================================
+}
+
+//________________________________________________________________________
+void AliRsnAnalysisSE::InitIOVars()
+{
+//=========================================================
+// Init input output values
+//=========================================================
+
+ AliDebug(AliLog::kDebug, "<-");
+ AliRsnAnalysisTaskSEBase::InitIOVars();
+
+ fRsnEventBuffer = 0;
+ fOutList = 0;
+
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//________________________________________________________________________
+void AliRsnAnalysisSE::UserCreateOutputObjects()
+{
+//=========================================================
+// UserCreateOutputObjects() of AliAnalysisTaskSE
+//=========================================================
+
+ AliDebug(AliLog::kDebug, "<-");
+// fPID.DumpPriors();
+ OpenFile ( 0 );
+ fOutList = new TList();
+ fOutList->SetOwner();
+ AliRsnPair *def=0;
+ AliRsnPairMgr *mgr=0;
+ TList *listTmp;
+ 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)
+ {
+ def->Init();
+ //listTmp->Add(def->GenerateHistograms(mgr->GetName()));
+ def->GenerateHistograms(mgr->GetName(), listTmp);
+ //def->Print();
+ }
+ }
+ fOutList->Add(listTmp);
+ }
+
+ fRsnEventBuffer = new AliRsnEventBuffer(100);
+// fRsnEventBuffer = new AliRsnEventBuffer ( 10000 ,kFALSE );
+ AliDebug(AliLog::kDebug, "->");
+
+}
+
+//________________________________________________________________________
+void AliRsnAnalysisSE::UserExec(Option_t *)
+{
+//=========================================================
+// UserExec() of AliAnalysisTaskSE
+//=========================================================
+
+ if (fEntry++%1000==0)
+ AliInfo(Form("Event %d",-1));
+
+ AliRsnEvent *curEvent = GetRsnEventFromInputType();
+ if (!curEvent) return;
+
+ ProcessEventAnalysis(curEvent);
+ PostEventProcess();
+
+ PostData(1, fOutList);
+}
+
+//________________________________________________________________________
+void AliRsnAnalysisSE::Terminate(Option_t *)
+{
+//=========================================================
+// Terminate() of AliAnalysisTask
+//=========================================================
+
+ fOutList = dynamic_cast<TList*>(GetOutputData(1));
+ if (!fOutList) { AliError(" fOutList not available"); return; }
+ fOutList->Print();
+}
+
+//________________________________________________________________________
+void AliRsnAnalysisSE::ProcessEventAnalysis(AliRsnEvent *curEvent)
+{
+//=========================================================
+// Process of one event
+//=========================================================
+
+
+ // Adds event to Event Buffer
+ fRsnEventBuffer->AddEvent(curEvent);
+
+ // 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);
+ pair->ProcessPair(fRsnEventBuffer);
+ }
+ }
+}
+
+//________________________________________________________________________
+void AliRsnAnalysisSE::PostEventProcess(const Short_t & index)
+{
+//=========================================================
+// Post process of one event
+//=========================================================
+
+ switch (fInputType[index])
+ {
+ case kAOD:
+ break;
+ case kESD:
+ break;
+ case kESDMC:
+ break;
+ case kMC:
+ break;
+ case kRSN:
+ {
+ if (fRsnEventBuffer->GetDeleteBufferWhenReset() == kFALSE)
+ {
+ fRSN[index] = (AliRsnEvent*) fRsnEventBuffer->GetNextEvent();
+ SetBranchAddress(0 , "rsnEvents", &fRSN[index]);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+}
+
+void AliRsnAnalysisSE::AddPairMgr(AliRsnPairMgr * pairmgr)
+{
+ fPairMgrs.Add(pairmgr);
+}
--- /dev/null
+//
+// 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 "AliRsnEventBuffer.h"
+#include "AliRsnPair.h"
+#include "AliRsnAnalysisTaskSEBase.h"
+
+class AliRsnEvent;
+
+class AliRsnAnalysisSE : public AliRsnAnalysisTaskSEBase
+{
+ public:
+ AliRsnAnalysisSE(const char *name = "AliRsnAnalysisSE");
+ AliRsnAnalysisSE(const AliRsnAnalysisSE& copy): AliRsnAnalysisTaskSEBase(copy),
+ fPairMgrs(0),fOutList(0x0),fRsnEventBuffer(0x0),fNumOfEventsInBuffer(100) {}
+ AliRsnAnalysisSE& operator= (const AliRsnAnalysisSE&) {return *this;}
+ ~AliRsnAnalysisSE();
+
+ virtual void InitIOVars();
+// virtual void LocalInit();
+// virtual Bool_t Notify();
+ virtual void UserCreateOutputObjects();
+ virtual void UserExec(Option_t *option);
+ virtual void Terminate(Option_t *);
+
+ void AddPairMgr(AliRsnPairMgr*pairmgr);
+
+ void SetNumOfEventsInBuffer(const Int_t& theValue) { fNumOfEventsInBuffer = theValue; }
+ Int_t GetNumOfEventsInBuffer() const { return fNumOfEventsInBuffer; }
+
+
+ private:
+
+ TObjArray fPairMgrs;
+
+ TList *fOutList; // List of output
+ AliRsnEventBuffer *fRsnEventBuffer; // event buffer
+ Int_t fNumOfEventsInBuffer; // number of events in buffer
+
+ void ProcessEventAnalysis(AliRsnEvent *curEvent);
+ void PostEventProcess(const Short_t &index=0);
+
+ ClassDef(AliRsnAnalysisSE, 1)
+};
+
+#endif
--- /dev/null
+//
+// Class AliRsnAnalysisTask2ndStep
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#include <TTree.h>
+#include <TChain.h>
+#include <TH1F.h>
+#include <TList.h>
+#include <TObjArray.h>
+
+#include "AliLog.h"
+
+#include "AliAODEvent.h"
+#include "AliAODInputHandler.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisTaskSE.h"
+
+#include "AliRsnEvent.h"
+#include "AliRsnPair.h"
+#include "AliRsnPairMgr.h"
+
+#include "AliRsnAnalysisTask2ndStep.h"
+
+ClassImp(AliRsnAnalysisTask2ndStep)
+
+//_____________________________________________________________________________
+AliRsnAnalysisTask2ndStep::AliRsnAnalysisTask2ndStep(const char *name) :
+ AliAnalysisTaskSE(name),
+ fOutList(0x0),
+ fPairMgrs(0x0),
+ fEventBuffer(0x0),
+ fRsnHandlerAOD(0x0),
+ fAnalysisMgr(0x0)
+{
+//
+// Default constructor
+//
+
+ DefineOutput(1, TList::Class());
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask2ndStep::CreateHandlers(AliAnalysisManager* am)
+{
+//
+// Sets the handlers.
+//
+
+ fAnalysisMgr = am;
+ if (!fAnalysisMgr) {
+ AliWarning("Passed a NULL AnalysisManager!");
+ return;
+ }
+
+ // this task is made only for building histograms from
+ // a set of RSN events saved as non-standard branches in AOD tree
+ fRsnHandlerAOD = new AliAODInputHandler();
+ if (fRsnHandlerAOD) fAnalysisMgr->SetInputEventHandler(fRsnHandlerAOD);
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask2ndStep::UserCreateOutputObjects()
+{
+//
+// Creates output objects, as a TList of all histograms
+//
+ AliInfo("--->");
+
+ //OpenFile (1);
+ if (fOutList) {
+ fOutList->Clear();
+ delete fOutList;
+ }
+ fOutList = new TList();
+ fOutList->SetOwner();
+ AliRsnPairMgr *pairMgr = 0x0;
+ AliRsnPair *pair = 0x0;
+
+ if (!fPairMgrs) {
+ AliError("No pair managers defined!");
+ return;
+ }
+
+ TObjArrayIter next(fPairMgrs);
+ while ( (pairMgr = (AliRsnPairMgr*)next()) ) {
+ TList *listTmp = new TList();
+ listTmp->SetName(pairMgr->GetName());
+ TObjArrayIter nextPair(pairMgr->GetPairs());
+ while ( (pair = (AliRsnPair*)nextPair()) ) {
+ pair->Init();
+ //pair->Print();
+ pair->GenerateHistograms(pairMgr->GetName(), listTmp);
+ //listTmp->Add(pair->GenerateHistograms(pairMgr->GetName()));
+ //fOutList->Add(listTmp);
+ }
+ fOutList->Add(listTmp);
+ }
+ fEventBuffer = new AliRsnEventBuffer(1000);
+
+ AliInfo("<---");
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask2ndStep::UserExec(Option_t *)
+{
+//
+// Executes the task
+//
+
+ if (fEntry++ % 1000 == 0) AliInfo(Form("Event %d",-1));
+
+ // retrieve AOD
+ AliAODEvent *aod = dynamic_cast<AliAODEvent*>(fInputEvent);
+
+ // find RSN event
+ AliRsnEvent *rsn = (AliRsnEvent*)(aod->GetList()->FindObject("rsnEvents"));
+
+ // execute analysis
+ ProcessEventAnalysis(rsn);
+ PostEventProcess();
+
+ PostData(1, fOutList);
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask2ndStep::Terminate(Option_t *)
+{
+//
+// A simple check on the output list
+//
+
+ fOutList = dynamic_cast<TList*>(GetOutputData(1));
+ if (!fOutList) { AliError("--- Output list not available ---"); return; }
+ fOutList->Print();
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask2ndStep::ProcessEventAnalysis(AliRsnEvent *curEvent)
+{
+//
+// Process of one event
+//
+
+ // Adds event to Event Buffer
+ fEventBuffer->AddEvent(curEvent);
+
+ // loop over all Pair managers
+ AliRsnPair *pair = 0;
+ AliRsnPairMgr *mgr = 0;
+ TObjArrayIter nextMgr(fPairMgrs);
+ while ( (mgr = (AliRsnPairMgr*)nextMgr()) ) {
+ TObjArrayIter nextPair(mgr->GetPairs());
+ while ( (pair = (AliRsnPair*)nextPair()) ) {
+ pair->ProcessPair(fEventBuffer);
+ }
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask2ndStep::PostEventProcess()
+{
+//
+// Some work done after event processing
+//
+
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask2ndStep::AddPairMgr(AliRsnPairMgr *pairmgr)
+{
+ if (!fPairMgrs) fPairMgrs = new TObjArray;
+ fPairMgrs->Add(pairmgr);
+}
--- /dev/null
+//
+// Class AliRsnAnalysisTask2ndStep
+//
+// AnalysisTask which collects an input of RSN events
+// and produces histograms.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#ifndef ALIRSNANALYSISTASK2NDSTEP_H
+#define ALIRSNANALYSISTASK2NDSTEP_H
+
+#include "AliRsnDaughter.h"
+#include "AliAnalysisTaskSE.h"
+
+class TObjArray;
+
+class AliAODEvent;
+class AliAODInputHandler;
+class AliAnalysisManager;
+
+class AliRsnEvent;
+class AliRsnEventBuffer;
+class AliRsnPairMgr;
+
+class AliRsnAnalysisTask2ndStep : public AliAnalysisTaskSE
+{
+ public:
+ AliRsnAnalysisTask2ndStep(const char *name = "AliRsnAnalysisTask2ndStep");
+ virtual ~AliRsnAnalysisTask2ndStep() {/* Does nothing*/}
+
+ virtual void UserCreateOutputObjects();
+ virtual void UserExec(Option_t *option);
+ virtual void Terminate(Option_t *option);
+
+ void AddPairMgr(AliRsnPairMgr *pairmgr);
+ void CreateHandlers(AliAnalysisManager *am);
+ void SetAnalysisMgr(AliAnalysisManager* theValue) { fAnalysisMgr = theValue; }
+ AliAnalysisManager* GetAnalysisMgr() const { return fAnalysisMgr; }
+ void ProcessEventAnalysis(AliRsnEvent *curEvent);
+ void PostEventProcess();
+
+ private:
+
+ AliRsnAnalysisTask2ndStep(const AliRsnAnalysisTask2ndStep& copy) :
+ AliAnalysisTaskSE(copy),fOutList(0x0),fPairMgrs(0x0),fEventBuffer(0x0),
+ fRsnHandlerAOD(0x0),fAnalysisMgr(0x0) {}
+ AliRsnAnalysisTask2ndStep& operator= (const AliRsnAnalysisTask2ndStep&) {return *this;}
+
+ TList *fOutList; // list of output histograms
+ TObjArray *fPairMgrs; // array if pair managers used
+ AliRsnEventBuffer *fEventBuffer; // event buffer
+
+ AliAODInputHandler *fRsnHandlerAOD; // AOD event handler
+ AliAnalysisManager *fAnalysisMgr; // pointer to current AnalysisMgr
+
+ ClassDef(AliRsnAnalysisTask2ndStep, 1)
+};
+
+#endif
--- /dev/null
+//
+// Class AliRsnAnalysisTaskSEBase
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#include <TTree.h>
+#include <TH1F.h>
+#include <TCanvas.h>
+
+#include "AliLog.h"
+
+#include "AliAnalysisManager.h"
+#include "AliAnalysisTaskSE.h"
+
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliRsnEvent.h"
+#include "AliMCEvent.h"
+
+#include "AliRsnAnalysisTaskSEBase.h"
+
+
+ClassImp(AliRsnAnalysisTaskSEBase)
+
+//_____________________________________________________________________________
+AliRsnAnalysisTaskSEBase::AliRsnAnalysisTaskSEBase(const char *name) :
+ AliAnalysisTaskSE(name),
+ fUseAutoHandler(kTRUE),
+ fReader(),
+ fPID(),
+ fAnalysisMgr(0x0) // pointer to current AnalysisMgr
+{
+//
+// Default constructor
+//
+ InitIOVars();
+ DefineInput(0, TChain::Class());
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::InitIOVars()
+{
+//
+// Initial values for constructor
+//
+
+ fUseAutoHandler = kFALSE;
+
+ Int_t i;
+ for (i = 0; i < 2; i++) {
+ fChain[i] = 0;
+ fRSN[i] = 0;
+ fRsnESD[i] = 0;
+ fRsnMC[i] = 0;
+ fRsnAOD[i] = 0;
+ fRsnESDEH[i] = 0;
+ fRsnMCEH[i] = 0;
+ fRsnAODEH[i] = 0;
+ fInputType[i] = kRSN;
+ }
+
+ fAnalysisMgr = 0;
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::LocalInit()
+{
+//
+// LocalInit()
+//
+ AliAnalysisTaskSE::LocalInit();
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnAnalysisTaskSEBase::Notify()
+{
+//
+// Notify()
+//
+
+ return AliAnalysisTaskSE::Notify();
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::SetInputType
+(EInputType type, AliAnalysisManager* am, Bool_t autohandler, Short_t inputIndex)
+{
+//
+// Sets input type.
+// When autohandler is kTRUE handlers are created and connected
+// to the passed AliAnalysisManager if it exists.
+// The internal AliAnalysisManager object is redirected to the passed one.
+//
+
+ fInputType[inputIndex] = type;
+ fAnalysisMgr = am;
+
+ UseAutoHandler(autohandler);
+ if (!fUseAutoHandler) return;
+
+ if (!fAnalysisMgr) {
+ AliWarning(Form("fAnalysisMgr is %p and fUseAutoHandler is %d", fAnalysisMgr, fUseAutoHandler));
+ return;
+ }
+
+ switch (fInputType[inputIndex]) {
+ case kAOD:
+ fRsnAODEH[0] = new AliAODInputHandler();
+ if (fRsnAODEH[0]) fAnalysisMgr->SetInputEventHandler(fRsnAODEH[0]);
+ break;
+ case kESD:
+ fRsnESDEH[0] = new AliESDInputHandler();
+ if (fRsnESDEH[0]) fAnalysisMgr->SetInputEventHandler(fRsnESDEH[0]);
+ break;
+ case kESDMC:
+ fRsnESDEH[0] = new AliESDInputHandler();
+ fRsnMCEH[0] = new AliMCEventHandler();
+ if ((fRsnESDEH[0]) && (fRsnMCEH[0])) {
+ fAnalysisMgr->SetInputEventHandler(fRsnESDEH[0]);
+ fAnalysisMgr->SetMCtruthEventHandler(fRsnMCEH[0]);
+ }
+ break;
+ case kMC:
+ fRsnMCEH[0] = new AliMCEventHandler();
+ if (fRsnMCEH[0]) {
+ fAnalysisMgr->SetMCtruthEventHandler(fRsnMCEH[0]);
+ }
+ break;
+ case kRSN:
+ AliError("Not Implemented Yet ...");
+ break;
+ default:
+ AliError("Type not supported ...");
+ break;
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::ConnectInputData(Option_t *)
+{
+//
+// ConnectInputData() for AliAnalysisTaskSE
+// just define myTask->SetInputType ( AliRsnAnalysisTaskSEBase::kRSN ); for Rsn input
+// just define myTask->SetInputType ( AliRsnAnalysisTaskSEBase::kESDMC ); for ESD and MC input
+// just define myTask->SetInputType ( AliRsnAnalysisTaskSEBase::kAOD ); for Rsn input
+//
+
+ if (fInputType[0] != kRSN) AliAnalysisTaskSE::ConnectInputData();
+
+ // connects input handlers according to the type of analysis being done
+ ConnectInputDataByInputType(fInputType[0], 0);
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::ConnectInputDataByInputType
+(EInputType type, Short_t inputIndex)
+{
+//
+// Connect input data dependint on the input type used.
+//
+ AliDebug(AliLog::kDebug, "<-");
+
+ switch (type)
+ {
+ case kAOD:
+ ConnectAOD(inputIndex);
+ break;
+ case kESD:
+ ConnectESD(inputIndex);
+ break;
+ case kESDMC:
+ ConnectESDMC(inputIndex);
+ break;
+ case kMC:
+ ConnectESDMC(inputIndex);
+ break;
+ case kRSN:
+ ConnectRSN(inputIndex);
+ break;
+ default:
+ AliError("Type not supported ...");
+ break;
+ }
+
+ AliDebug(AliLog::kDebug, "->");
+}
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::ConnectRSN(Short_t inputIndex)
+{
+//
+// Connect input data by RSN input type
+//
+
+ AliDebug(AliLog::kDebug, "<-");
+
+ char ** address = (char **) GetBranchAddress(inputIndex, "rsnEvents");
+ if (address)
+ {
+ fRSN[inputIndex] = (AliRsnEvent*)(*address);
+ }
+ else
+ {
+ fRSN[inputIndex] = 0;
+ SetBranchAddress(inputIndex, "rsnEvents", &fRSN[inputIndex]);
+ }
+
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::ConnectESD(Short_t inputIndex)
+{
+//
+// Connect input data by ESD input type
+//
+
+ AliDebug(AliLog::kDebug, "<-");
+ fRsnESD[inputIndex] = (AliESDEvent*)fInputEvent;
+ AliDebug(AliLog::kDebug, "->");
+
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::ConnectESDMC(Short_t inputIndex)
+{
+//
+// Connect input data by ESDMC input type
+//
+
+ AliDebug(AliLog::kDebug, "<-");
+ fRsnESD[inputIndex] = (AliESDEvent*)fInputEvent;
+ //fRSNMC[inputIndex] = fMCEvent;
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTaskSEBase::ConnectAOD(Short_t inputIndex)
+{
+//
+// Connect input data by AOD input type
+//
+
+ AliDebug(AliLog::kDebug, "<-");
+
+ TTree* tree = dynamic_cast<TTree*>(GetInputData(inputIndex));
+ if (!tree) { AliError("Could not read chain from input slot 0");}
+ else
+ {
+ AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+ if (!aodH) { AliError("Could not get AODInputHandler"); }
+ else fRsnAOD[inputIndex] = aodH->GetEvent();
+ }
+
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//_____________________________________________________________________________
+AliRsnEvent * AliRsnAnalysisTaskSEBase::GetRsnEventFromInputType(const Short_t & index)
+{
+//
+// Gets Event from input type
+//
+
+ switch (fInputType[index])
+ {
+ case kAOD: return GetRsnFromAOD(index);
+ case kESD: return GetRsnFromESD(index);
+ case kESDMC: return GetRsnFromESDMC(index);
+ case kMC: return GetRsnFromMC(index);
+ case kRSN: return GetRsnFromRSN(index);
+ default:
+ AliError("Type not supported ...");
+ return (AliRsnEvent*) 0x0;
+ }
+
+ return (AliRsnEvent*) 0x0;
+}
+
+//_____________________________________________________________________________
+AliRsnEvent * AliRsnAnalysisTaskSEBase::GetRsnFromAOD(const Short_t & index)
+{
+//
+// Gets RSN event from AOD
+//
+
+ if (!fRsnAOD[index])
+ {
+ AliError("fRsnAOD not available.");
+ return (AliRsnEvent *) 0x0;
+ }
+
+ if (!fRSN[0])
+ {
+ fRSN[0] = new AliRsnEvent();
+ fRSN[0]->SetName("rsnEvents");
+ fRSN[0]->Init();
+ }
+
+ // clear pevious event
+ fRSN[0]->Clear();
+ if (!fReader.FillFromAOD(fRSN[0], fRsnAOD[index])) return (AliRsnEvent*) 0x0;
+ if (!fPID.Process(fRSN[0])) AliWarning("Failed PID");
+
+ return (AliRsnEvent*) fRSN[0];
+}
+
+//_____________________________________________________________________________
+AliRsnEvent * AliRsnAnalysisTaskSEBase::GetRsnFromESD(const Short_t & index)
+{
+//
+// Gets RSN event from ESD
+//
+
+ if (!fRsnESD[index])
+ {
+ AliError("fRsnESD not available.");
+ return (AliRsnEvent *) 0x0;
+ }
+
+ if (!fRSN[index])
+ {
+ fRSN[index] = new AliRsnEvent();
+ fRSN[index]->SetName("rsnEvents");
+ fRSN[index]->Init();
+ }
+
+ // clear pevious event
+ fRSN[index]->Clear();
+
+ if (!fReader.FillFromESD(fRSN[index], fRsnESD[index])) return (AliRsnEvent*) 0x0;
+
+ if (!fPID.Process(fRSN[index]))
+ {
+ AliWarning("Failed PID");
+ return (AliRsnEvent*) 0x0;
+ }
+
+ return fRSN[index];
+}
+
+//_____________________________________________________________________________
+AliRsnEvent * AliRsnAnalysisTaskSEBase::GetRsnFromMC(const Short_t & index)
+{
+//
+// Gets RSN event from ESD
+//
+
+ if (!fRSN[index])
+ {
+ fRSN[index] = new AliRsnEvent();
+ fRSN[index]->SetName("rsnEvents");
+ fRSN[index]->Init();
+ }
+
+ // clear pevious event
+ fRSN[index]->Clear();
+ fRsnMC[index] = MCEvent();
+
+ if (!fReader.FillFromMC(fRSN[index], fRsnMC[index])) return (AliRsnEvent*) 0x0;
+ fRSN[index]->FillPIDArrays();
+ return fRSN[index];
+}
+
+//_____________________________________________________________________________
+AliRsnEvent * AliRsnAnalysisTaskSEBase::GetRsnFromESDMC(const Short_t & index)
+{
+//
+// Gets RSN event from ESD and MC
+//
+
+ if (!fRsnESD[index])
+ {
+ AliError("fRsnESD not available.");
+ return (AliRsnEvent *) 0x0;
+ }
+
+ if (!fRSN[index])
+ {
+ fRSN[index] = new AliRsnEvent();
+ fRSN[index]->SetName("rsnEvents");
+ fRSN[index]->Init();
+ }
+
+ // clear pevious event
+ fRSN[index]->Clear();
+ fRsnMC[index] = MCEvent();
+
+ if (!fRsnMC[index]) return (AliRsnEvent *) 0x0;
+ if (!fReader.FillFromESD(fRSN[index], fRsnESD[index], fRsnMC[index])) return (AliRsnEvent*) 0x0;
+ if (!fPID.Process(fRSN[index]))
+ {
+ AliWarning("Failed PID");
+ return (AliRsnEvent*) 0x0;
+ }
+
+ return fRSN[index];
+}
+
+//_____________________________________________________________________________
+AliRsnEvent * AliRsnAnalysisTaskSEBase::GetRsnFromRSN(const Short_t & index)
+{
+//
+// Gets RSN event from RSN
+// not fully implemented yet
+//
+ AliRsnEvent *event = fRSN[index];
+ return event;
+}
--- /dev/null
+//\r
+// Class AliRsnAnalysisTaskSEBase\r
+//\r
+// TODO\r
+//\r
+// authors: Martin Vala (martin.vala@cern.ch)\r
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)\r
+//\r
+#ifndef ALIRSNANALYSISTASKSEBASE_H\r
+#define ALIRSNANALYSISTASKSEBASE_H\r
+\r
+#include <TChain.h>\r
+\r
+#include "AliAnalysisTaskSE.h"\r
+#include "AliRsnReader.h"\r
+\r
+class AliAnalysisManager;\r
+class AliESDEvent;\r
+class AliAODEvent;\r
+class AliRsnEvent;\r
+class AliMCEvent;\r
+\r
+#include "AliESDInputHandler.h"\r
+#include "AliMCEventHandler.h"\r
+#include "AliAODInputHandler.h"\r
+\r
+class AliRsnAnalysisTaskSEBase : public AliAnalysisTaskSE\r
+{\r
+ public:\r
+ AliRsnAnalysisTaskSEBase(const char *name = "AliRsnAnalysisTaskSEBase");\r
+ AliRsnAnalysisTaskSEBase(const AliRsnAnalysisTaskSEBase& copy) :\r
+ AliAnalysisTaskSE(copy),fUseAutoHandler(kFALSE),fReader(),fPID(),fAnalysisMgr(0x0) {}\r
+ AliRsnAnalysisTaskSEBase& operator= (const AliRsnAnalysisTaskSEBase& /*copy*/) {return *this;}\r
+ virtual ~AliRsnAnalysisTaskSEBase() {/* Does nothing*/}\r
+\r
+ enum EInputType\r
+ {\r
+ kAOD = 0,\r
+ kESD,\r
+ kESDMC,\r
+ kMC,\r
+ kRSN,\r
+ kLastIndex\r
+ };\r
+\r
+ virtual void InitIOVars();\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
+ void SetInputType(EInputType type, AliAnalysisManager* am, Bool_t autohandler = kFALSE, Short_t inputIndex = 0);\r
+ EInputType GetInputType(Short_t inputIndex = 0) { return fInputType[inputIndex]; }\r
+\r
+ TChain* GetChain(const Int_t& index = 0) const { return fChain[index]; }\r
+\r
+ AliRsnEvent *GetRSNEvent(Int_t index = 0) { return fRSN[index]; }\r
+\r
+ void SetAnalysisMgr(AliAnalysisManager* theValue) { fAnalysisMgr = theValue; }\r
+ AliAnalysisManager* GetAnalysisMgr() const { return fAnalysisMgr; }\r
+\r
+ AliESDInputHandler* GetESDHandler(const Int_t& theValue = 0) const { return fRsnESDEH[theValue]; }\r
+ AliMCEventHandler* GetMCHandler(const Int_t& theValue = 0) const { return fRsnMCEH[theValue]; }\r
+ AliAODInputHandler* GetAODHandler(const Int_t& theValue = 0) const { return fRsnAODEH[theValue]; }\r
+\r
+ AliRsnReader *GetReader() { return &fReader; }\r
+ AliRsnPID *GetPID() { return &fPID;}\r
+\r
+ protected:\r
+\r
+ TChain *fChain[2]; // input chain\r
+ EInputType fInputType[2]; // input type\r
+ Bool_t fUseAutoHandler; // flag if should create handler\r
+\r
+ AliRsnEvent *fRSN[2]; // RSN (internal format) event\r
+ AliESDEvent *fRsnESD[2]; // ESD event\r
+ AliMCEvent *fRsnMC[2]; // ESD event\r
+ AliAODEvent *fRsnAOD[2]; // AOD event\r
+\r
+ AliESDInputHandler *fRsnESDEH[2]; // ESD event handler\r
+ AliMCEventHandler *fRsnMCEH[2]; // ESD event handler\r
+ AliAODInputHandler *fRsnAODEH[2]; // AOD event handler\r
+\r
+ AliRsnReader fReader; // Reader\r
+ AliRsnPID fPID; // PID\r
+\r
+ AliAnalysisManager *fAnalysisMgr; // pointer to current AnalysisMgr\r
+\r
+ virtual void UseAutoHandler(const Bool_t& theValue) {fUseAutoHandler = theValue;}\r
+\r
+ virtual void ConnectInputDataByInputType(EInputType type ,Short_t inputIndex=0);\r
+ virtual void ConnectRSN(Short_t inputIndex);\r
+ virtual void ConnectESD(Short_t inputIndex);\r
+ virtual void ConnectESDMC(Short_t inputIndex);\r
+ virtual void ConnectAOD(Short_t inputIndex);\r
+\r
+ virtual AliRsnEvent* GetRsnEventFromInputType(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromAOD(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromESD(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromESDMC(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromRSN(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromMC(const Short_t &index=0);\r
+\r
+ ClassDef(AliRsnAnalysisTaskSEBase, 1)\r
+};\r
+\r
+#endif\r
--- /dev/null
+//
+// Class AliRsnBaseAT
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#include <TTree.h>
+#include <TH1F.h>
+#include <TCanvas.h>
+
+#include "AliLog.h"
+
+#include "AliAnalysisManager.h"
+#include "AliAnalysisTask.h"
+
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliRsnEvent.h"
+#include "AliMCEvent.h"
+
+#include "AliRsnBaseAT.h"
+
+
+ClassImp(AliRsnBaseAT)
+
+//________________________________________________________________________
+AliRsnBaseAT::AliRsnBaseAT(const char *name)
+ : AliAnalysisTask(name, ""),
+ fNumOfEvents(100),
+ fUseAutoHandler(100),
+ fRsnInput(),
+ fReader(),
+ fPID(),
+ fAnalysisMgr(0x0)
+{
+//=========================================================
+// Default constructor
+//=========================================================
+ InitIOVars();
+ DefineInput(0, TChain::Class());
+// DefineInput ( 1, AliRsnReader::Class() );
+// DefineInput ( 2, AliRsnPID::Class() );
+}
+
+//________________________________________________________________________
+void AliRsnBaseAT::InitIOVars()
+{
+//=========================================================
+// Initial values for constructor
+//=========================================================
+ AliDebug(AliLog::kDebug, "<-");
+
+ fNumOfEvents=0;
+ fUseAutoHandler = kFALSE;
+ for (Int_t i=0;i<2;i++)
+ {
+ fChain[i] = 0;
+ fRSN[i] = 0;
+ fESD[i] = 0;
+ fMC[i] = 0;
+ fAOD[i] = 0;
+ fESDEH[i] = 0;
+ fMCEH[i] = 0;
+ fAODEH[i] = 0;
+ fInputType[i] = kRSN;
+ }
+
+ fAnalysisMgr=0;
+
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//________________________________________________________________________
+void AliRsnBaseAT::LocalInit()
+{
+//=========================================================
+// LocalInit()
+//=========================================================
+}
+
+//________________________________________________________________________
+Bool_t AliRsnBaseAT::Notify()
+{
+//=========================================================
+// Notify()
+//=========================================================
+
+ return AliAnalysisTask::Notify();
+}
+
+//________________________________________________________________________
+void AliRsnBaseAT::SetInputType(EInputType type,AliAnalysisManager* am,Bool_t autohandler, Short_t inputIndex)
+{
+//=========================================================
+// Sets input type.
+// When autohandler is kTRUE handlers are created and sets
+// to AliAnalysisManager (fAnalysisMgr) if exists
+//=========================================================
+
+ AliDebug(AliLog::kDebug, "<-");
+
+ fInputType[inputIndex] = type;
+ fAnalysisMgr = am;
+
+ UseAutoHandler(autohandler);
+
+ if (!fUseAutoHandler) return;
+
+ if (!fAnalysisMgr)
+ {
+ AliWarning(Form("fAnalysisMgr is %p and fUseAutoHandler is %d",fAnalysisMgr,fUseAutoHandler));
+ return;
+ }
+
+ switch (fInputType[inputIndex])
+ {
+ case kAOD:
+ {
+ if (fAnalysisMgr)
+ {
+ fAODEH[0] = new AliAODInputHandler();
+ if (fAODEH[0])
+ fAnalysisMgr->SetInputEventHandler(fAODEH[0]);
+ }
+ break;
+ }
+ case kESD:
+ {
+ if (fAnalysisMgr)
+ {
+ fESDEH[0] = new AliESDInputHandler();
+ if (fESDEH[0])
+ fAnalysisMgr->SetInputEventHandler(fESDEH[0]);
+ }
+
+ break;
+ }
+ case kESDMC:
+ {
+ if (fAnalysisMgr)
+ {
+ fESDEH[0] = new AliESDInputHandler();
+ fMCEH[0] = new AliMCEventHandler();
+ if ((fESDEH[0]) && (fMCEH[0]))
+ {
+ fAnalysisMgr->SetInputEventHandler(fESDEH[0]);
+ fAnalysisMgr->SetMCtruthEventHandler(fMCEH[0]);
+ }
+ }
+ break;
+ }
+ case kMC:
+ AliError("Not Implemented Yet ...");
+ break;
+ case kRSN:
+ {
+ AliError("Not Implemented Yet ...");
+ break;
+ }
+ default:
+ AliError("Type not supported ...");
+ break;
+ }
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//________________________________________________________________________
+void AliRsnBaseAT::ConnectInputData(Option_t *)
+{
+//=========================================================
+// ConectInputData() for AliAnalysisTask
+// just define myTask->SetInputType ( AliRsnBaseAT::kRSN ); for Rsn input
+// just define myTask->SetInputType ( AliRsnBaseAT::kESDMC ); for ESD and MC input
+// just define myTask->SetInputType ( AliRsnBaseAT::kAOD ); for Rsn input
+//=========================================================
+
+ ConnectInputDataByInputType(fInputType[0],0);
+}
+
+void AliRsnBaseAT::ConnectInputDataByInputType(EInputType type ,Short_t inputIndex)
+{
+//=========================================================
+// Connect input data by input type
+//=========================================================
+
+ AliDebug(AliLog::kDebug, "<-");
+
+ switch (type)
+ {
+ case kAOD:
+ {
+ ConnectAOD(inputIndex);
+ break;
+ }
+ case kESD:
+ {
+ ConnectESD(inputIndex);
+ break;
+ }
+ case kESDMC:
+ {
+ ConnectESDMC(inputIndex);
+ break;
+ }
+ case kMC:
+ AliError("Not Implemented Yet ...");
+ break;
+ case kRSN:
+ {
+ ConnectRSN(inputIndex);
+ break;
+ }
+ default:
+ AliError("Type not supported ...");
+ break;
+ }
+ AliDebug(AliLog::kDebug, "->");
+}
+//________________________________________________________________________
+void AliRsnBaseAT::ConnectRSN(Short_t inputIndex)
+{
+//=========================================================
+// Connect input data by RSN input type
+//=========================================================
+
+ AliDebug(AliLog::kDebug, "<-");
+ char ** address = (char **) GetBranchAddress(inputIndex, "rsnEvents");
+ if (address)
+ {
+ fRSN[inputIndex] = (AliRsnEvent*)(*address);
+ }
+ else
+ {
+ fRSN[inputIndex] = 0;
+ SetBranchAddress(inputIndex, "rsnEvents", &fRSN[inputIndex]);
+ }
+ AliDebug(AliLog::kDebug, "->");
+}
+
+void AliRsnBaseAT::ConnectESD(Short_t inputIndex)
+{
+//=========================================================
+// Connect input data by ESD input type
+//=========================================================
+
+ AliDebug(AliLog::kDebug, "<-");
+
+ TTree* tree = dynamic_cast<TTree*>(GetInputData(inputIndex));
+ if (!tree) { AliError("Could not read chain from input slot 0"); }
+ else
+ {
+ // Disable all branches, we want to process only MC
+ tree->SetBranchStatus("*", kFALSE);
+ tree->SetBranchStatus("fTracks.*", kTRUE);
+
+ AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+
+ if (!esdH) { AliError("Could not get ESDInputHandler"); }
+ else
+ fESD[inputIndex] = esdH->GetEvent();
+ }
+ AliDebug(AliLog::kDebug, "->");
+
+}
+//________________________________________________________________________
+void AliRsnBaseAT::ConnectESDMC(Short_t inputIndex)
+{
+//=========================================================
+// Connect input data by ESDMC input type
+//=========================================================
+
+ AliDebug(AliLog::kDebug, "<-");
+
+
+ TTree* tree = dynamic_cast<TTree*>(GetInputData(inputIndex));
+ if (!tree) { AliError("Could not read chain from input slot 0"); }
+ else
+ {
+ // Disable all branches, we want to process only MC
+ tree->SetBranchStatus("*", kFALSE);
+ tree->SetBranchStatus("fTracks.*", kTRUE);
+
+ AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+
+ if (!esdH) { AliError("Could not get ESDInputHandler"); }
+ else
+ fESD[inputIndex] = esdH->GetEvent();
+ }
+ AliDebug(AliLog::kDebug, "->");
+
+}
+//________________________________________________________________________
+void AliRsnBaseAT::ConnectAOD(Short_t inputIndex)
+{
+//=========================================================
+// Connect input data by AOD input type
+//=========================================================
+
+ AliDebug(AliLog::kDebug, "<-");
+
+ TTree* tree = dynamic_cast<TTree*>(GetInputData(inputIndex));
+ if (!tree) { AliError("Could not read chain from input slot 0");}
+ else
+ {
+ AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+
+ if (!aodH) { AliError("Could not get AODInputHandler"); }
+ else
+ {
+ fAOD[inputIndex] = aodH->GetEvent();
+ }
+ }
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//________________________________________________________________________
+AliRsnEvent * AliRsnBaseAT::GetRsnEventFromInputType(const Short_t & index)
+{
+//=========================================================
+// Gets Evetn from input type
+//=========================================================
+
+ switch (fInputType[index])
+ {
+ case kAOD:
+ {
+ return GetRsnFromAOD(index);
+ break;
+ }
+ case kESD:
+ {
+ AliWarning("Not Implemented Yet ...");
+ return GetRsnFromESD(index);
+ break;
+ }
+ case kESDMC:
+ {
+ return GetRsnFromESDMC(index);
+ break;
+ }
+ case kMC:
+ AliWarning("Not Implemented Yet ...");
+ return (AliRsnEvent*) 0x0;
+ break;
+ case kRSN:
+ {
+ return GetRsnFromRSN(index);
+ break;
+ }
+ default:
+ AliError("Type not supported ...");
+ return (AliRsnEvent*) 0x0;
+ break;
+ }
+ return (AliRsnEvent*) 0x0;
+}
+
+
+
+//________________________________________________________________________
+AliRsnEvent * AliRsnBaseAT::GetRsnFromAOD(const Short_t & index)
+{
+//=========================================================
+// Gets RSN event from AOD
+//=========================================================
+
+ if (!fAOD[index]) { AliError("fAOD not available."); return (AliRsnEvent *) 0x0; }
+
+ if (!fRSN[0])
+ {
+ fRSN[0] = new AliRsnEvent();
+ fRSN[0]->SetName("rsnEvents");
+ fRSN[0]->Init();
+ }
+ // clear pevious event
+ fRSN[0]->Clear();
+
+ if (!fReader.Fill(fRSN[0], (AliVEvent*) fAOD[index]))
+ {
+ return (AliRsnEvent*) 0x0;
+ };
+
+ if (!fPID.Process(fRSN[0])) AliWarning("Failed PID");
+
+ return (AliRsnEvent*) fRSN[0];
+
+}
+//________________________________________________________________________
+AliRsnEvent * AliRsnBaseAT::GetRsnFromESD(const Short_t & index)
+{
+//=========================================================
+// Gets RSN event from ESD
+//=========================================================
+
+ if (!fESD[index]) { AliError("fESD not available."); return (AliRsnEvent *) 0x0; }
+
+ if (!fRSN[index])
+ {
+ fRSN[index] = new AliRsnEvent();
+ fRSN[index]->SetName("rsnEvents");
+ fRSN[index]->Init();
+ }
+ // clear pevious event
+ fRSN[index]->Clear();
+
+ if (!fReader.Fill(fRSN[index], (AliVEvent*) fESD[index]))
+ {
+ return (AliRsnEvent*) 0x0;
+ };
+
+ if (!fPID.Process(fRSN[index])) AliWarning("Failed PID");
+
+ return fRSN[index];
+}
+//________________________________________________________________________
+AliRsnEvent * AliRsnBaseAT::GetRsnFromESDMC(const Short_t & index)
+{
+//=========================================================
+// Gets RSN event from ESD and MC
+//=========================================================
+
+ if (!fESD[index]) { AliError("fESD not available."); return (AliRsnEvent *) 0x0; }
+ AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+ if (!mcHandler) { AliError("Could not retrieve MC event handler"); return (AliRsnEvent *) 0x0; }
+
+ if (!fRSN[index])
+ {
+ fRSN[index] = new AliRsnEvent();
+ fRSN[index]->SetName("rsnEvents");
+ fRSN[index]->Init();
+ }
+ // clear pevious event
+ fRSN[index]->Clear();
+
+ fMC[index] = mcHandler->MCEvent();
+
+ if (!fMC[index]) return (AliRsnEvent *) 0x0;
+
+ if (!fReader.Fill(fRSN[index], (AliVEvent*) fESD[index],fMC[index]))
+ {
+ return (AliRsnEvent*) 0x0;
+ };
+
+ if (!fPID.Process(fRSN[index]))
+ {
+ AliWarning("Failed PID");
+ return (AliRsnEvent*) 0x0;
+ }
+
+ return fRSN[index];
+}
+//________________________________________________________________________
+AliRsnEvent * AliRsnBaseAT::GetRsnFromRSN(const Short_t & index)
+{
+//=========================================================
+// Gets RSN event from RSN
+// not fully implemented yet
+//=========================================================
+
+ AliRsnEvent *event = fRSN[index];
+// if ( fRsnEventBuffer->GetDeleteBufferWhenReset() == kTRUE )
+// {
+// event = ( AliRsnEvent * ) fRSN[index]->Clone();
+// }
+// AliInfo ( Form ( "%p %p",event,fRSN[index] ) );
+ return event;
+}
+
+//________________________________________________________________________
+void AliRsnBaseAT::UseAutoHandler(const Bool_t & theValue)
+{
+//=========================================================
+// Sets should create handlers
+//=========================================================
+ fUseAutoHandler = theValue;
+}
--- /dev/null
+//\r
+// Class AliRsnBaseAT\r
+//\r
+// TODO\r
+//\r
+// authors: Martin Vala (martin.vala@cern.ch)\r
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)\r
+//\r
+#ifndef ALIRSNBASEAT_H\r
+#define ALIRSNBASEAT_H\r
+\r
+#include <TChain.h>\r
+\r
+#include "AliAnalysisTask.h"\r
+#include "AliRsnReader.h"\r
+\r
+class AliAnalysisManager;\r
+class AliESDEvent;\r
+class AliAODEvent;\r
+class AliRsnEvent;\r
+class AliMCEvent;\r
+\r
+#include "AliESDInputHandler.h"\r
+#include "AliMCEventHandler.h"\r
+#include "AliAODInputHandler.h"\r
+\r
+\r
+class AliRsnBaseAT : public AliAnalysisTask\r
+{\r
+ public:\r
+ AliRsnBaseAT(const char *name = "AliRsnBaseAT");\r
+ AliRsnBaseAT(const AliRsnBaseAT& copy):AliAnalysisTask(copy),\r
+ fNumOfEvents(0),fUseAutoHandler(kTRUE),\r
+ fRsnInput(1),fReader(),fPID(),fAnalysisMgr(0x0) {}\r
+ AliRsnBaseAT& operator= (const AliRsnBaseAT&) {return *this;}\r
+ virtual ~AliRsnBaseAT() {/* Does nothing*/}\r
+\r
+ enum EInputType\r
+ {\r
+ kAOD = 0,\r
+ kESD,\r
+ kESDMC,\r
+ kMC,\r
+ kRSN,\r
+ kLastIndex\r
+ };\r
+\r
+ virtual void InitIOVars();\r
+ virtual void LocalInit();\r
+ virtual Bool_t Notify();\r
+ virtual void ConnectInputData(Option_t *);\r
+ virtual void CreateOutputObjects() {;}\r
+ virtual void Exec(Option_t *) {;}\r
+ virtual void Terminate(Option_t *) {;}\r
+\r
+ void SetInputType(EInputType type,AliAnalysisManager* am,Bool_t autohandler=kFALSE, Short_t inputIndex=0);\r
+ EInputType GetInputType(Short_t inputIndex=0) { return fInputType[inputIndex]; }\r
+\r
+ TChain* GetChain(const Int_t& index = 0) const { return fChain[index]; }\r
+\r
+ AliRsnEvent *GetRSNEvent(Int_t index=0) { return fRSN[index]; }\r
+\r
+ void SetAnalysisMgr(AliAnalysisManager* theValue) { fAnalysisMgr = theValue; }\r
+ AliAnalysisManager* GetAnalysisMgr() const { return fAnalysisMgr; }\r
+\r
+ AliESDInputHandler* GetESDHandler(const Int_t& theValue=0) const { return fESDEH[theValue]; }\r
+ AliMCEventHandler* GetMCHandler(const Int_t& theValue=0) const { return fMCEH[theValue]; }\r
+ AliAODInputHandler* GetAODHandler(const Int_t& theValue=0) const { return fAODEH[theValue]; }\r
+\r
+ AliRsnReader *GetReader() { return &fReader; }\r
+ AliRsnPID *GetPID() { return &fPID;}\r
+ \r
+ protected:\r
+\r
+ Long64_t fNumOfEvents; // number of events\r
+\r
+ TChain *fChain[2]; // input chain\r
+ EInputType fInputType[2]; // input type\r
+ Bool_t fUseAutoHandler; // flag if should create handler\r
+\r
+ AliRsnEvent *fRSN[2]; // RsnMV event\r
+ AliESDEvent *fESD[2]; // ESD event\r
+ AliMCEvent *fMC[2]; // ESD event\r
+ AliAODEvent *fAOD[2]; // AOD event\r
+\r
+ AliESDInputHandler *fESDEH[2]; // ESD event handler\r
+ AliMCEventHandler *fMCEH[2]; // ESD event handler\r
+ AliAODInputHandler *fAODEH[2]; // AOD event handler\r
+\r
+\r
+ TObjArray fRsnInput; // array of rsn input (reader,pid,...)\r
+ AliRsnReader fReader; // Reader\r
+ AliRsnPID fPID; // PID\r
+\r
+ AliAnalysisManager *fAnalysisMgr; // pointer to current AnalysisMgr\r
+\r
+ virtual void UseAutoHandler(const Bool_t& theValue);\r
+\r
+ virtual void ConnectInputDataByInputType(EInputType type ,Short_t inputIndex=0);\r
+ virtual void ConnectRSN(Short_t inputIndex);\r
+ virtual void ConnectESD(Short_t inputIndex);\r
+ virtual void ConnectESDMC(Short_t inputIndex);\r
+ virtual void ConnectAOD(Short_t inputIndex);\r
+\r
+ virtual AliRsnEvent* GetRsnEventFromInputType(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromAOD(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromESD(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromESDMC(const Short_t &index=0);\r
+ virtual AliRsnEvent* GetRsnFromRSN(const Short_t &index=0);\r
+\r
+\r
+ ClassDef(AliRsnBaseAT, 1)\r
+};\r
+\r
+#endif\r
--- /dev/null
+//
+// Class AliRsnComparisonAT
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#include "TChain.h"
+#include "TTree.h"
+#include "TH1F.h"
+#include "TFolder.h"
+#include "TCanvas.h"
+#include "TClonesArray.h"
+
+#include "AliLog.h"
+
+#include "AliESDtrack.h"
+#include "AliMCEvent.h"
+
+#include "AliRsnMCInfo.h"
+#include "AliRsnComparisonObj.h"
+#include "AliRsnComparisonAT.h"
+
+ClassImp(AliRsnComparisonAT)
+
+//________________________________________________________________________
+AliRsnComparisonAT::AliRsnComparisonAT(const char*name)
+ : AliRsnBaseAT(name),fOutList(0x0),fMyInputNum(1),fMyPIDInputNum(0)
+{
+//=========================================================
+// Default constructor
+//=========================================================
+
+ InitIOVars();
+
+ DefineOutput(0, TList::Class());
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::InitIOVars()
+{
+//=========================================================
+// Sets default values for input and output
+//=========================================================
+ AliDebug(AliLog::kDebug, "<-");
+ AliRsnBaseAT::InitIOVars();
+ fOutList = 0;
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::LocalInit()
+{
+//=========================================================
+// Local init
+//=========================================================
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::CreateOutputObjects()
+{
+//=========================================================
+// CreateOutputObjects()
+//=========================================================
+ AliDebug(AliLog::kDebug, "<-");
+
+// AliRsnDaughter::SetPIDMethod ( AliRsnDaughter::kRealistic );
+// fReader = dynamic_cast<AliRsnReader*> ( GetInputData ( 1 ) );
+// fPID = dynamic_cast<AliRsnPID*> ( GetInputData ( 2 ) );
+
+
+ OpenFile(0);
+ fOutList = new TList();
+ AliRsnComparisonObj* obj;
+
+ TList *listMainParticle,*listMainPID,*listPID,*listParticle,*listTmp;
+
+ listMainParticle = new TList();
+ listMainParticle->SetName("MCParticles");
+ for (Int_t i=0;i<fMyInput[0].GetEntries();i++)
+ {
+ obj = (AliRsnComparisonObj*) fMyInput[0].At(i);
+ if (!obj) continue;
+ listParticle = obj->GenerateParticleInfoHistogramList("");
+ if (!listParticle)
+ {
+ AliError(Form("List not crated for i=%d",i));
+ continue;
+ }
+
+ listMainParticle->Add(listParticle);
+ }
+ fOutList->Add(listMainParticle);
+ if (fMyPIDInputNum>0)
+ {
+ listMainPID = new TList();
+ listMainPID->SetName("PID");
+ for (Int_t j=0;j<fMyPIDInputNum;j++)
+ {
+ listPID = new TList();
+ listPID->SetName(fMyPIDInput[j].GetName());
+ for (Int_t i=0;i<fMyPIDInput[j].GetEntries();i++)
+ {
+ obj = (AliRsnComparisonObj*) fMyPIDInput[j].At(i);
+ if (!obj) continue;
+ listTmp = obj->GeneratePIDHistogramList(fMyPIDInput[j].GetName());
+ if (!listTmp)
+ {
+ AliError(Form("List not crated for i=%d",i));
+ continue;
+ }
+ listPID->Add(listTmp);
+
+ }
+ listMainPID->Add(listPID);
+ }
+ fOutList->Add(listMainPID);
+// listMainPID->Print();
+ }
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::Exec(Option_t *)
+{
+//=========================================================
+// Exec()
+//=========================================================
+
+ if (fInputType[0]==kESDMC)
+ {
+ fRSN[0] = GetRsnEventFromInputType(0);
+ LoopOverESDtracks();
+ LoopOverMCtracks();
+ }
+
+
+ if (!fRSN[0]) return;
+ LoopOverRSNDaughters();
+
+ if (fInputType[0]==kESDMC)
+ {
+ delete fRSN[0];
+ fRSN[0] = 0;
+ }
+
+// fNumEventsProcessed++;
+ PostData(0, fOutList);
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::Terminate(Option_t *)
+{
+//=========================================================
+// Terminate()
+//=========================================================
+ AliDebug(AliLog::kDebug, "<-");
+ fOutList = dynamic_cast<TList*>(GetOutputData(0));
+ if (!fOutList)
+ {
+ AliError(" fOutList not available");
+ return;
+ }
+
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::LoopOverESDtracks()
+{
+//=========================================================
+// Loop over all ESD tracks
+//=========================================================
+ if (!fESD[0]) return;
+// AliInfo(Form("%d",fESD[0]->GetNumberOfTracks()));
+ AliRsnComparisonObj* input=0;
+ for (Int_t i=0;i< fESD[0]->GetNumberOfTracks(); i++)
+ {
+ AliESDtrack *esdtrack = fESD[0]->GetTrack(i);
+ for (Int_t j=0;j<fMyInputNum;j++)
+ {
+ for (Int_t i=0;i<fMyInput[j].GetEntries();i++)
+ {
+ input = (AliRsnComparisonObj*) fMyInput[j].At(i);
+// input->FillPIDHistograms(esdtrack, fMC[0]);
+ }
+ }
+ for (Int_t j=0;j<fMyPIDInputNum;j++)
+ {
+ for (Int_t i=0;i<fMyPIDInput[j].GetEntries();i++)
+ {
+ input = (AliRsnComparisonObj*) fMyPIDInput[j].At(i);
+ input->FillPIDHistograms(esdtrack, fMC[0]);
+ }
+ }
+ }
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::LoopOverMCtracks()
+{
+//=========================================================
+// Loop over all MC tracks
+//=========================================================
+
+ if (!fMC[0]) return;
+
+ AliRsnComparisonObj* input=0;
+ AliMCParticle *mctrack;
+ for (Int_t i=0;i<fMC[0]->GetNumberOfTracks(); i++)
+ {
+ mctrack = fMC[0]->GetTrack(i);
+ if (!mctrack) {AliInfo("mctrack == null");continue;}
+ for (Int_t j=0;j<fMyInputNum;j++)
+ {
+ for (Int_t i=0;i<fMyInput[j].GetEntries();i++)
+ {
+ input = (AliRsnComparisonObj*) fMyInput[j].At(i);
+ input->FillHistograms(mctrack);
+ }
+ }
+ for (Int_t j=0;j<fMyPIDInputNum;j++)
+ {
+ for (Int_t i=0;i<fMyPIDInput[j].GetEntries();i++)
+ {
+ input = (AliRsnComparisonObj*) fMyPIDInput[j].At(i);
+ input->FillPIDHistograms(mctrack);
+ }
+ }
+ }
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::LoopOverRSNDaughters()
+{
+//=========================================================
+// Loop over all rsn daughters
+//=========================================================
+
+ TClonesArray *tracks = (TClonesArray*) fRSN[0]->GetTracks();
+ AliRsnDaughter *daughter=0;
+ AliRsnComparisonObj* input=0;
+ for (Int_t i=0;i< tracks->GetEntriesFast(); i++)
+ {
+ daughter = (AliRsnDaughter*) tracks->At(i);
+ for (Int_t j=0;j<fMyInputNum;j++)
+ {
+ for (Int_t i=0;i<fMyInput[j].GetEntries();i++)
+ {
+ input = (AliRsnComparisonObj*) fMyInput[j].At(i);
+// input->FillPIDHistograms(daughter);
+ }
+ }
+ for (Int_t j=0;j<fMyPIDInputNum;j++)
+ {
+ for (Int_t i=0;i<fMyPIDInput[j].GetEntries();i++)
+ {
+ input = (AliRsnComparisonObj*) fMyPIDInput[j].At(i);
+ input->FillPIDHistograms(daughter);
+ }
+ }
+ }
+}
+
+//________________________________________________________________________
+void AliRsnComparisonAT::PrintStat()
+{
+//=========================================================
+// Print stat
+//=========================================================
+ AliDebug(AliLog::kDebug, "<-");
+
+ AliDebug(AliLog::kDebug, "->");
+}
+
+void AliRsnComparisonAT::AddMyInput(AliRsnComparisonObj * obj, const Int_t & index)
+{
+// if ( ( index<0 ) || ( index>kMyInputNum ) ) return;
+
+ fMyInput[index].Add(obj);
+// AliInfo(Form("%d %s",fMyInput[index].GetEntries(),fMyInput[index].GetName()));
+}
+
+void AliRsnComparisonAT::AddMyPIDInput(AliRsnComparisonObj * obj, const Int_t & index)
+{
+// if ( ( index<0 ) || ( index>kMyInputNum ) ) return;
+
+ fMyPIDInput[index].Add(obj);
+// AliInfo(Form("%d %s",fMyInput[index].GetEntries(),fMyInput[index].GetName()));
+}
+
+void AliRsnComparisonAT::SetMyPIDInputName(TString name, const Int_t & index)
+{
+ fMyPIDInput[index].SetName(name.Data());
+}
+
--- /dev/null
+//
+// Class AliRsnComparisonAT
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#ifndef ALIRSNMVCOMPARISONAT_H
+#define ALIRSNMVCOMPARISONAT_H
+
+#include "TObjArray.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnBaseAT.h"
+#include "AliRsnCut.h"
+#include "AliRsnCutSet.h"
+
+class AliRsnComparisonAT : public AliRsnBaseAT
+{
+ public:
+
+ enum
+ {
+ kMyInputNum=1,
+ kMyPIDInputNum=5
+ };
+
+ AliRsnComparisonAT(const char*name="AliRsnComparisonAT");
+
+ virtual ~AliRsnComparisonAT() {}
+
+ virtual void InitIOVars();
+ virtual void LocalInit();
+ virtual void CreateOutputObjects();
+ virtual void Exec(Option_t *option);
+ virtual void Terminate(Option_t *);
+
+ void LoopOverESDtracks();
+ void LoopOverMCtracks();
+ void LoopOverRSNDaughters();
+ void PrintStat();
+
+ void AddMyInput(AliRsnComparisonObj *obj,const Int_t &index=0);
+ void AddMyPIDInput(AliRsnComparisonObj *obj,const Int_t &index=0);
+ void SetMyPIDInputName(TString name="default",const Int_t &index=0);
+
+ void SetNumberOfPIDInputs(const Int_t& theValue) { fMyPIDInputNum = theValue; }
+
+
+ private:
+
+ AliRsnComparisonAT(const AliRsnComparisonAT&)
+ : AliRsnBaseAT(""),fOutList(0x0),fMyInputNum(1),fMyPIDInputNum(0) {}
+ AliRsnComparisonAT& operator=(const AliRsnComparisonAT&) {return *this;}
+
+ TList *fOutList; // output list
+
+ Int_t fMyInputNum;
+ TObjArray fMyInput[kMyInputNum];
+ Int_t fMyPIDInputNum;
+ TObjArray fMyPIDInput[kMyPIDInputNum];
+
+
+
+ ClassDef(AliRsnComparisonAT, 1)
+};
+
+#endif
--- /dev/null
+//
+// *** Class AliRsnComparisonObj ***
+//
+// TODO
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
+
+#include "AliLog.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnMCInfo.h"
+
+#include "AliRsnComparisonObj.h"
+
+ClassImp(AliRsnComparisonObj)
+
+//_____________________________________________________________________________
+AliRsnComparisonObj::AliRsnComparisonObj(const char *name)
+ : TNamed(name,name),fCurrentComparisonType(kParticleInfo),fCurrentESDPID(kEsd),
+ fESDstatus(0),fITSClusters(0),fTPCClusters(0),fTRDClusters(0),fPIDDivValue(0.)
+{
+//=========================================================
+// Default constructor
+//=========================================================
+ TH1::SetDefaultSumw2();
+
+ for (Int_t i=0;i<kLastFormat;i++)
+ for (Int_t j=0;j<kLastHistoType;j++)
+ for (Int_t k=0;k<AliRsnPID::kSpecies+1;k++)
+ fHistosPID[i][j][k] = 0;
+
+ for (Int_t i=0;i<kLastParameterType;i++)
+ for (Int_t j=0;j<2;j++)
+ for (Int_t k=0;k<AliRsnPID::kSpeciesAll;k++)
+ fHistosPartInfo[i][j][k] = 0;
+
+ fPriorProbs[0]=0.02;
+ fPriorProbs[1]=0.02;
+ fPriorProbs[2]=0.83;
+ fPriorProbs[3]=0.07;
+ fPriorProbs[4]=0.06;
+ fITSClusters = -1;
+ fTPCClusters = -1;
+ fTRDClusters = -1;
+ fPIDDivValue = 0.0;
+
+}
+//_____________________________________________________________________________
+AliRsnComparisonObj::~AliRsnComparisonObj()
+{
+//=========================================================
+// Destructor
+//=========================================================
+}
+
+//________________________________________________________________________
+TList * AliRsnComparisonObj::GeneratePIDHistogramList(TString prefix)
+{
+//=========================================================
+// Generate histograms
+//=========================================================
+
+ TList *list = new TList();
+ list->SetName(GetName());
+
+ TString varname("p");
+ for (Int_t i=0;i<kLastFormat;i++)
+ for (Int_t j=0;j<kLastHistoType;j++)
+ for (Int_t k=0;k<AliRsnPID::kSpecies+1;k++)
+ {
+ if ((i == kMC) && (j>kIndent)) continue;
+
+ fHistosPID[i][j][k]= new TH1D(Form("%s_%s_%s_%s_%s_%s",prefix.Data(),GetName(),varname.Data(),AliRsnPID::ParticleName((AliRsnPID::EType) k),GetFormatName((EFormat) i).Data(),GetHistoTypeName((EHistoType) j).Data()),Form("%s %s %s %s %s",GetName(),varname.Data(),AliRsnPID::ParticleNameLatex((AliRsnPID::EType) k),GetFormatName((EFormat) i).Data(),GetHistoTypeName((EHistoType) j).Data()),1000,0,5);
+ list->Add(fHistosPID[i][j][k]);
+ }
+
+ return list;
+}
+
+TList * AliRsnComparisonObj::GenerateParticleInfoHistogramList(TString prefix)
+{
+ TList *list = new TList();
+ list->SetName(GetName());
+ TString charge;
+ if (!prefix.IsNull())
+ prefix+="_";
+
+ Int_t bins[] = {1000,1000,1000,1000};
+ Double_t min[] = {0.0,0.0,-10.0,-10.0};
+ Double_t max[] = {5.0,5.0,10.0,10.0};
+
+ for (Int_t i=0;i<kLastParameterType;i++)
+ for (Int_t j=0;j<2;j++)
+ for (Int_t k=0;k<AliRsnPID::kSpeciesAll;k++)
+ {
+// if (k == AliRsnPID::kUnknown) continue;
+// if ((j>0) && (k>AliRsnPID::kSpecies-1)) continue;
+ charge = (j>0) ? "-":"+";
+ AliInfo(Form("%s%s %d%d",AliRsnPID::ParticleName((AliRsnPID::EType) k),charge.Data(),j,k));
+// if (k>AliRsnPID::kSpecies-1) charge="";
+ fHistosPartInfo[i][j][k]= new TH1D(Form("%s%s%s_%s",prefix.Data(),AliRsnPID::ParticleName((AliRsnPID::EType) k),charge.Data(),GetParameterName((EParameterType) i).Data()),Form("%s%s %s",AliRsnPID::ParticleNameLatex((AliRsnPID::EType) k),charge.Data(),GetParameterName((EParameterType) i).Data()),bins[i],min[i],max[i]);
+ list->Add(fHistosPartInfo[i][j][k]);
+ }
+ return list;
+}
+
+//________________________________________________________________________
+void AliRsnComparisonObj::FillPIDHistograms(AliRsnDaughter * daughter)
+{
+//=========================================================
+// Fill Histograms with AliRsnDaughter info
+//=========================================================
+
+ if (!(daughter->CheckFlag(fESDstatus))) return;
+
+ daughter->AssignRealisticPID();
+
+ Double_t prob;
+ Double_t p = daughter->P();
+ Int_t indexType = (Int_t) daughter->PIDType(prob);
+ Int_t pdg = daughter->GetMCInfo()->PDG();
+ Int_t indexTypeFromPDG = (Int_t) AliRsnPID::InternalType(pdg);
+
+ fHistosPID[kRSN][kIndent][indexType]->Fill(p);
+ fHistosPID[kRSN][kTrue][indexTypeFromPDG]->Fill(p);
+
+ if (indexType == indexTypeFromPDG)
+ fHistosPID[kRSN][kGood][indexType]->Fill(p);
+ else
+ fHistosPID[kRSN][kFake][indexType]->Fill(p);
+}
+
+//________________________________________________________________________
+void AliRsnComparisonObj::FillPIDHistograms(AliESDtrack * track,AliMCEvent *mc)
+{
+//=========================================================
+// Fill Histograms with AliRsnDaughter info
+//=========================================================
+
+ if (fITSClusters>0)
+ if (track->GetITSclusters(0) < fITSClusters) return;
+
+ if (fTPCClusters>0)
+ if (track->GetTPCclusters(0) < fTPCClusters) return;
+
+ if (fTRDClusters>0)
+ if (track->GetTRDclusters(0) < fTRDClusters) return;
+
+ ULong_t status = track->GetStatus();
+ if (!((fESDstatus & status) == fESDstatus)) return;
+
+ Int_t label = track->GetLabel();
+ AliMCParticle *mctrack = mc->GetTrack(TMath::Abs(label));
+
+ Double_t p = track->P();
+ Int_t pdg =0;
+ Int_t indexTypeFromPDG = AliRsnPID::kUnknown;
+ if (mctrack)
+ {
+ pdg = mctrack->Particle()->GetPdgCode();
+ indexTypeFromPDG = (Int_t) AliRsnPID::InternalType(pdg);
+ }
+ Double_t pid[5];
+ GetESDPID(track,pid,p);
+
+
+ if (fCurrentESDPID == kITS_TPC_TOF_SP)
+ if (p>0.7)
+ if (!track->IsOn(AliESDtrack::kTOFpid)) return;
+
+ Int_t i;
+ Double_t sum = 0.0, prob[AliRsnPID::kSpecies];
+ for (i = 0; i < AliRsnPID::kSpecies; i++)
+ {
+ prob[i] = fPriorProbs[i] * pid[i];
+ sum += prob[i];
+ }
+
+ if (sum <= (Double_t) 0.0)
+ {
+ AliError(Form("Sum of weights = %f <= 0", sum));
+ return;
+ }
+
+
+ // normalize
+ for (i = 0; i < AliRsnPID::kSpecies; i++)
+ {
+ prob[i] /= sum;
+ }
+
+ Int_t indexType = 0;
+ Double_t pmax = prob[0];
+ for (i = 1; i < AliRsnPID::kSpecies; i++)
+ {
+ if (prob[i] > pmax)
+ {
+ indexType = i;
+ pmax = prob[i];
+ }
+ }
+
+ fHistosPID[kESD][kIndent][indexType]->Fill(p);
+ fHistosPID[kESD][kTrue][indexTypeFromPDG]->Fill(p);
+
+ if (indexType == indexTypeFromPDG)
+ fHistosPID[kESD][kGood][indexType]->Fill(p);
+ else
+ fHistosPID[kESD][kFake][indexType]->Fill(p);
+
+}
+
+//________________________________________________________________________
+void AliRsnComparisonObj::FillPIDHistograms(AliMCParticle * mctrack)
+{
+//=========================================================
+// Fill Histograms with mctrack info
+//=========================================================
+
+ if (!mctrack) { AliError("mctrack is null"); return;}
+
+ Double_t p = mctrack->P();
+ Int_t pdg = mctrack->Particle()->GetPdgCode();
+ Int_t indexTypeFromPDG = (Int_t) AliRsnPID::InternalType(pdg);
+ if (indexTypeFromPDG < AliRsnPID::kSpecies)
+ fHistosPID[kMC][kIndent][indexTypeFromPDG]->Fill(p);
+}
+
+void AliRsnComparisonObj::FillHistograms(AliMCParticle * mctrack)
+{
+ Int_t charge;
+ if (!mctrack) { AliError("mctrack is null"); return;}
+
+ Int_t pdg = mctrack->Particle()->GetPdgCode();
+// if (pdg>0) charge=0;
+ charge = (pdg>0) ? 0 : 1;
+// if (TMath::Abs(pdg) == 333 ) AliInfo(Form("%d",charge));
+ if (pdg == 11) charge = 1;
+ if (pdg == -11) charge = 0;
+
+ Int_t indexTypeFromPDG = (Int_t) AliRsnPID::InternalType(pdg);
+ for (Int_t i=0;i<kLastParameterType;i++)
+ fHistosPartInfo[i][charge][indexTypeFromPDG]->Fill(GetParameterNameValue((EParameterType)i,mctrack));
+}
+
+//________________________________________________________________________
+TString AliRsnComparisonObj::GetFormatName(EFormat type)
+{
+//=========================================================
+// returns Format Name
+//=========================================================
+ switch (type)
+ {
+ case kRSN :
+ return "RSN";
+ break;
+ case kESD :
+ return "ESD";
+ break;
+ case kMC :
+ return "MC";
+ break;
+ default:
+ AliWarning("Unrecognized value of EOutputType argument");
+ break;
+ }
+ return "";
+}
+
+//________________________________________________________________________
+TString AliRsnComparisonObj::GetHistoTypeName(EHistoType type)
+{
+//=========================================================
+// returns Histo Type Name
+//=========================================================
+ switch (type)
+ {
+ case kIndent :
+ return "Ident";
+ case kGood :
+ return "Good";
+ case kFake :
+ return "Fake";
+ case kTrue :
+ return "True";
+ default:
+ AliWarning("Unrecognized value of EHistoType argument");
+ break;
+ }
+ return "XXX";
+}
+
+void AliRsnComparisonObj::GetESDPID(AliESDtrack *track,Double_t *pid,Double_t p)
+{
+ Double_t ctmp[AliRsnPID::kSpecies];
+ switch (fCurrentESDPID)
+ {
+ case kEsd :
+ track->GetESDpid(pid);
+ break;
+ case kITS :
+ track->GetITSpid(pid);
+ break;
+ case kTPC :
+ track->GetTPCpid(pid);
+ break;
+ case kTOF :
+ track->GetTOFpid(pid);
+ break;
+ case kITS_TPC :
+ track->GetITSpid(pid);
+ track->GetTPCpid(ctmp);
+ for (Int_t i=0;i<5;i++) pid[i]*=ctmp[i];
+ break;
+ case kITS_TOF :
+ track->GetITSpid(pid);
+ track->GetTOFpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ break;
+ case kTPC_TOF :
+ track->GetTPCpid(pid);
+ track->GetTOFpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ break;
+ case kITS_TPC_TOF :
+ track->GetITSpid(pid);
+ track->GetTPCpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ track->GetTOFpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ break;
+ case kITS_TPC_TOF_SP :
+
+ if (p<fPIDDivValue)
+ {
+ track->GetITSpid(pid);
+ track->GetTPCpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ }
+ else
+ {
+ track->GetTOFpid(pid);
+ }
+ break;
+ default:
+ AliWarning("Unrecognized value of EPIDType argument");
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]=1.0;
+ break;
+ }
+}
+
+void AliRsnComparisonObj::SetESDTrackQualityCuts(const Int_t & its, const Int_t & tpc, const Int_t & trd)
+{
+ fITSClusters = its;
+ fTPCClusters = tpc;
+ fTRDClusters = trd;
+}
+
+void AliRsnComparisonObj::SetESDstatus(const ULong_t status)
+{
+ fESDstatus = status;
+}
+
+void AliRsnComparisonObj::SetCurrentESDPID(const EPIDType & type, const Double_t & divValue)
+{
+ fCurrentESDPID = type;
+ fPIDDivValue = divValue;
+}
+
+TString AliRsnComparisonObj::GetParameterName(EParameterType type)
+{
+ switch (type)
+ {
+ case kP :
+ return "p";
+ case kPt :
+ return "pt";
+ case kEta :
+ return "eta";
+ case kY :
+ return "y";
+ default:
+ break;
+ }
+ return "?";
+}
+
+Double_t AliRsnComparisonObj::GetParameterNameValue(EParameterType type,AliMCParticle * mctrack)
+{
+ switch (type)
+ {
+ case kP :
+ return mctrack->P();
+ case kPt :
+ return mctrack->Pt();
+ case kEta :
+ return mctrack->Eta();
+ case kY :
+ return mctrack->Y();
+ default:
+ break;
+ }
+ return -10000.0;
+}
+
--- /dev/null
+//
+// *** Class AliRsnComparisonObj ***
+//
+// TODO
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
+
+#ifndef ALIRSNCOMPARISONOBJ_H
+#define ALIRSNCOMPARISONOBJ_H
+
+#include <TNamed.h>
+#include <TList.h>
+#include <TH1.h>
+
+#include "AliMCEvent.h"
+#include "AliESDtrack.h"
+#include "AliMCParticle.h"
+
+#include "AliRsnPID.h"
+
+class AliRsnComparisonObj : public TNamed
+{
+ public:
+
+ enum EFormat
+ {
+ kRSN=0,
+ kESD,
+ kMC,
+ kLastFormat
+ };
+
+ enum EComparisonType
+ {
+ kParticleInfo=0,
+ kPid,
+ kLastComparisonType
+ };
+
+ enum EParameterType
+ {
+ kP = 0,
+ kPt,
+ kEta,
+ kY,
+ kLastParameterType
+ };
+
+ enum EHistoType
+ {
+ kIndent=0,
+ kGood,
+ kFake,
+ kTrue,
+ kLastHistoType
+ };
+
+ enum EPIDType
+ {
+ kEsd=0,
+ kITS,
+ kTPC,
+ kTOF,
+ kITS_TPC,
+ kITS_TOF,
+ kTPC_TOF,
+ kITS_TPC_TOF,
+ kITS_TPC_TOF_SP,
+ kLastPIDType
+ };
+
+ AliRsnComparisonObj(const char*name="RSN");
+ ~AliRsnComparisonObj();
+
+ TList *GenerateParticleInfoHistogramList(TString prefix="");
+ TList *GeneratePIDHistogramList(TString prefix="");
+ void FillPIDHistograms(AliRsnDaughter *daughter);
+ void FillPIDHistograms(AliESDtrack *track,AliMCEvent *mc=0);
+ void FillPIDHistograms(AliMCParticle *mctrack);
+
+ void FillHistograms(AliMCParticle *mctrack);
+
+ void SetCurrentESDPID(const EPIDType& type,const Double_t&divValue = 0.0);
+ void SetPriorProbs(Double_t* pid) { for (Int_t i=0; i<5; i++) fPriorProbs[i]=pid[i]; }
+
+ void SetESDstatus(const ULong_t status);
+ void SetESDTrackQualityCuts(const Int_t& its=-1,const Int_t& tpc=-1,const Int_t& trd=-1);
+ private:
+
+ AliRsnComparisonObj(const AliRsnComparisonObj& copy)
+ : TNamed(copy),fCurrentComparisonType(kParticleInfo),fCurrentESDPID(kEsd),
+ fESDstatus(0),fITSClusters(0),fTPCClusters(0),fTRDClusters(0),fPIDDivValue(0.) {}
+ const AliRsnComparisonObj& operator=(const AliRsnComparisonObj&) {return *this;}
+
+ EComparisonType fCurrentComparisonType;
+ EPIDType fCurrentESDPID;
+ Double_t fPriorProbs[5];
+ ULong_t fESDstatus;
+ Int_t fITSClusters;
+ Int_t fTPCClusters;
+ Int_t fTRDClusters;
+
+ Double_t fPIDDivValue;
+
+ TH1D *fHistosPartInfo[kLastParameterType][2][AliRsnPID::kSpeciesAll];
+ TH1D *fHistosPID[kLastFormat][kLastHistoType][AliRsnPID::kSpecies+1];
+
+ TString GetFormatName(EFormat type);
+ TString GetHistoTypeName(EHistoType type);
+
+ void GetESDPID(AliESDtrack *track,Double_t *pid,Double_t p=-1.0);
+ TString GetParameterName(EParameterType type);
+ Double_t GetParameterNameValue(EParameterType type,AliMCParticle * mctrack);
+
+ ClassDef(AliRsnComparisonObj, 1)
+};
+
+#endif
const Double_t AliRsnCut::fgkDBigNumber = 1e10;
const Int_t AliRsnCut::fgkIBigNumber = 32767;
-ClassImp (AliRsnCut)
+ClassImp(AliRsnCut)
//________________________________________________________________________________________________________________
AliRsnCut::AliRsnCut() :
- TNamed(),
- fDMin(-fgkDBigNumber),
- fDMax( fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax( fgkIBigNumber),
- fUIMin(0),
- fUIMax(2 * (UInt_t)fgkIBigNumber),
- fType (kLastCutType),
- fVarType (kDouble_t)
+ 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)
{
//
// 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),
- fType (type),
- fVarType (kDouble_t)
+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)
{
//
// Constructor with arguments but not limits
}
//________________________________________________________________________________________________________________
-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),
- fType (type),
- fVarType (kDouble_t)
+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(min),
+ fULMax(max),
+ fType(type),
+ fVarType(kDouble_t)
{
//
// Constructor with arguments and limits
}
//________________________________________________________________________________________________________________
-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),
- fType (type),
- fVarType (kInt_t)
+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)
{
//
// Constructor with arguments and limits
}
//________________________________________________________________________________________________________________
-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),
- fType (type),
- fVarType (kUInt_t)
+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)
+{
+//
+// Constructor with arguments and limits
+//
+}
+
+//________________________________________________________________________________________________________________
+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
}
//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsBetween (const Double_t &theValue)
+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));
+ return ((theValue >= fDMin) && (theValue <= fDMax));
}
//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsBetween (const Int_t &theValue)
+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));
+ return ((theValue >= fIMin) && (theValue <= fIMax));
}
//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue (const Int_t &theValue)
+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 (theValue == fIMin);
}
//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue (const UInt_t &theValue)
+Bool_t AliRsnCut::MatchesValue(const UInt_t &theValue)
{
//
// Reference check.
// Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
//
- return (theValue == fUIMin);
+ 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)
+Bool_t AliRsnCut::MatchesValue(const Double_t &theValue)
{
//
// Reference check.
// 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 (TMath::Abs(theValue - fDMin) < fgkDSmallNumber);
}
//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues (EType type, const Double_t &theValue, const Double_t &theValue2)
+void AliRsnCut::SetCutValues(EType type, const Double_t &theValue, const Double_t &theValue2)
{
//
// (Re)assignment of cut values
//
- fType = type;
- fDMin = theValue;
- fDMax = theValue2;
+ fType = type;
+ fDMin = theValue;
+ fDMax = theValue2;
}
//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues (EType type, const Int_t &theValue, const Int_t &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;
+ fType = type;
+ fIMin = theValue;
+ fIMax = theValue2;
}
//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues (EType type, const UInt_t &theValue, const UInt_t &theValue2)
+void AliRsnCut::SetCutValues(EType type, const UInt_t &theValue, const UInt_t &theValue2)
{
//
// (Re)assignment of cut values
//
- fType = type;
- fUIMin = theValue;
- fUIMax = theValue2;
+ 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;
}
//________________________________________________________________________________________________________________
// (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.
//
- 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;
-
- 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 kMomentumMC:
- if (mcinfo) return IsBetween (mcinfo->P());
- else return kTRUE;
- case kTransMomentumMC:
- if (mcinfo) return IsBetween (mcinfo->P());
- 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 kEtaMC:
- if (mcinfo) return IsBetween (mcinfo->Eta());
- else return kTRUE;
- case kMcVt:
- if (mcinfo) return IsBetween (mcinfo->Vt());
- else return kTRUE;
- case kEsdNSigma:
- return IsBetween (daughter->GetNSigma());
- case kEsdNSigmaCalculate:
- return IsBetween (daughter->GetESDInfo()->GetNSigmaCalculate());
- */
- default:
- AliWarning("Requested a cut which cannot be applied to a single track");
- return kTRUE;
- }
+ 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;
+
+ 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 kMomentumMC:
+ if (mcinfo) return IsBetween(mcinfo->P());
+ else return kTRUE;
+ case kTransMomentumMC:
+ if (mcinfo) return IsBetween(mcinfo->P());
+ 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 kEtaMC:
+ if (mcinfo) return IsBetween(mcinfo->Eta());
+ else return kTRUE;
+ /*
+ case kEsdNSigma:
+ return IsBetween (daughter->GetNSigma());
+ 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 (daughter->Eta());
- */
- 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;
- }
+ 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 (daughter->Eta());
+ */
+ 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) {
- case kMultiplicity:
- return IsBetween ((Int_t)event->GetMultiplicity());
- default:
- AliWarning("Requested a cut which cannot be applied to an event");
- return kTRUE;
- }
+ 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)
+ {
+ case kMultiplicity:
+ return IsBetween((Int_t) event->GetMultiplicity());
+ default:
+ AliWarning("Requested a cut which cannot be applied to an event");
+ return kTRUE;
+ }
+
+ return kTRUE;
}
//________________________________________________________________________________________________________________
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("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 AliRsnCut : public TNamed
{
-public:
-
- // available cut types
- // some ones work both for pairs and single tracks
- enum EType
- {
- kMomentum = 0,
- kTransMomentum,
- kEta,
- kRadialImpactParam,
- kMomentumMC,
- kTransMomentumMC,
- kEtaMC,
- kNSigma,
- kNSigmaCalculate,
- kStatus,
- kIsLabelEqual,
- kIsTruePair,
- kChargePos,
- kChargeNeg,
- kPIDType,
- kPIDProb,
- kMultiplicity,
- 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,
- kMixEventFinderCut,
- 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();
-
- 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);
-
- Bool_t IsSelected (ETarget tgt, AliRsnDaughter *daughter);
- Bool_t IsSelected (ETarget tgt, AliRsnPairParticle *pair);
- Bool_t IsSelected (ETarget tgt, AliRsnEvent *event);
-
- 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 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
-
- 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:
+
+ // available cut types
+ // some ones work both for pairs and single tracks
+ enum EType {
+ kMomentum = 0,
+ kTransMomentum,
+ kEta,
+ kRadialImpactParam,
+ kMomentumMC,
+ kTransMomentumMC,
+ kEtaMC,
+ kNSigma,
+ kNSigmaCalculate,
+ kStatus,
+ kIsLabelEqual,
+ kIsTruePair,
+ kChargePos,
+ kChargeNeg,
+ kPIDType,
+ kPIDProb,
+ kMultiplicity,
+ 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,
+ kMixEventFinderCut,
+ 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);
+
+ 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)
};
#endif
#include "AliRsnCutSet.h"
#include "AliRsnCutMgr.h"
-ClassImp (AliRsnCutMgr)
+ClassImp(AliRsnCutMgr)
//_____________________________________________________________________________
AliRsnCutMgr::AliRsnCutMgr() :
- TNamed("defaultName", "defaultTitle")
+ TNamed("defaultName", "defaultTitle")
{
//
// Constructor without arguments.
//
- Int_t i;
- for (i = 0; i < AliRsnCut::kLastCutTarget; i++) {
- fCutSets[i] = 0;
- }
+ Int_t i;
+ for (i = 0; i < AliRsnCut::kLastCutTarget; i++)
+ {
+ fCutSets[i] = 0;
+ }
}
//_____________________________________________________________________________
-AliRsnCutMgr::AliRsnCutMgr (const char *name, const char *title) :
- TNamed (name, title)
+AliRsnCutMgr::AliRsnCutMgr(const char *name, const char *title) :
+ TNamed(name, title)
{
//
// Constructor with name and title.
//
- Int_t i;
- for (i = 0; i < AliRsnCut::kLastCutTarget; i++) {
- fCutSets[i] = 0;
- }
+ Int_t i;
+ for (i = 0; i < AliRsnCut::kLastCutTarget; i++)
+ {
+ fCutSets[i] = 0;
+ }
}
//_____________________________________________________________________________
// Deletes all cut definitions.
//
- Int_t i;
- for (i = 0; i < AliRsnCut::kLastCutTarget; i++) {
- delete fCutSets[i];
- }
+ Int_t i;
+ for (i = 0; i < AliRsnCut::kLastCutTarget; i++)
+ {
+ delete fCutSets[i];
+ }
}
//_____________________________________________________________________________
-void AliRsnCutMgr::SetCutSet (AliRsnCut::ETarget type, AliRsnCutSet* cutset)
+void AliRsnCutMgr::SetCutSet(AliRsnCut::ETarget type, AliRsnCutSet* cutset)
{
//
// Assign a cut set to a given target
//
- if (!fCutSets[type]) fCutSets[type] = (AliRsnCutSet*) cutset->Clone();
- AliDebug (AliLog::kDebug, Form ("DatasetName %s", fCutSets[type]->GetName()));
+ if (!fCutSets[type]) fCutSets[type] = (AliRsnCutSet*) cutset->Clone();
+ AliDebug(AliLog::kDebug, Form("DatasetName %s", fCutSets[type]->GetName()));
}
//_____________________________________________________________________________
-Bool_t AliRsnCutMgr::IsSelected ( AliRsnCut::ETarget type,TObject *obj )
+Bool_t AliRsnCutMgr::IsSelected(AliRsnCut::ETarget type,TObject *obj)
{
//
// Check if a given object passes the cuts defined for it.
// The target of the check is here a TObject, in order to allo generality
-// but then the kind of cut to be used is defined as first argument, and
+// but then the kind of cut to be used is defined as first argument, and
// in the single cut it will be checked if it is appropriate for passed target
//
- AliDebug (AliLog::kDebug, "<-");
- if (!fCutSets[type]) return kTRUE;
-
- switch (type) {
- case AliRsnCut::kParticle:
- return fCutSets[type]->IsSelected (type, (AliRsnDaughter*)obj);
- break;
- case AliRsnCut::kPair:
- return fCutSets[type]->IsSelected (type, (AliRsnPairParticle*)obj);
- break;
- case AliRsnCut::kEvent:
- return fCutSets[type]->IsSelected (type, (AliRsnEvent*)obj);
- break;
- default:
- AliWarning ("Wrong target selected.");
- return kTRUE;
- break;
- }
-
- return kTRUE;
+ AliDebug(AliLog::kDebug, "<-");
+ if (!fCutSets[type]) return kTRUE;
+
+ switch (type)
+ {
+ case AliRsnCut::kParticle:
+ return fCutSets[type]->IsSelected(type, (AliRsnDaughter*)obj);
+ break;
+ case AliRsnCut::kPair:
+ return fCutSets[type]->IsSelected(type, (AliRsnPairParticle*)obj);
+ break;
+ case AliRsnCut::kEvent:
+ return fCutSets[type]->IsSelected(type, (AliRsnEvent*)obj);
+ break;
+ default:
+ AliWarning("Wrong target selected.");
+ return kTRUE;
+ break;
+ }
+
+ return kTRUE;
}
AliRsnCutSet *fCutSets[AliRsnCut::kLastCutTarget]; // cut definitions for all targets
- ClassDef (AliRsnCutMgr, 1); // dictionary
+ ClassDef(AliRsnCutMgr, 1); // dictionary
};
#endif
#include "AliRsnCutSet.h"
-ClassImp (AliRsnCutSet)
+ClassImp(AliRsnCutSet)
//_____________________________________________________________________________
AliRsnCutSet::AliRsnCutSet() :
- TNamed(),
- fCuts(0),
- fNumOfCuts(0),
- fCutScheme (""),
- fCutSchemeIndexed (""),
- fBoolValues (0),
- fIsScheme (kFALSE),
- fExpression(0)
+ TNamed(),
+ fCuts(0),
+ fNumOfCuts(0),
+ fCutScheme(""),
+ fCutSchemeIndexed(""),
+ fBoolValues(0),
+ fIsScheme(kFALSE),
+ fExpression(0)
{
//
// Constructor without name (not recommended)
//
- fBoolValues = new Bool_t[1];
- AliRsnExpression::sCutSet = this;
+ fBoolValues = new Bool_t[1];
+ AliRsnExpression::sCutSet = this;
}
//_____________________________________________________________________________
-AliRsnCutSet::AliRsnCutSet (TString name) :
- TNamed (name, name),
- fCuts(0),
- fNumOfCuts(0),
- fCutScheme (""),
- fCutSchemeIndexed (""),
- fBoolValues (0),
- fIsScheme (kFALSE),
- fExpression(0)
+AliRsnCutSet::AliRsnCutSet(TString name) :
+ TNamed(name, name),
+ fCuts(0),
+ fNumOfCuts(0),
+ fCutScheme(""),
+ fCutSchemeIndexed(""),
+ fBoolValues(0),
+ fIsScheme(kFALSE),
+ fExpression(0)
{
//
// Constructor with argument name (recommended)
//
- fBoolValues = new Bool_t[1];
- fExpression = 0;
- AliRsnExpression::sCutSet = this;
+ fBoolValues = new Bool_t[1];
+ fExpression = 0;
+ AliRsnExpression::sCutSet = this;
}
//_____________________________________________________________________________
-AliRsnCutSet::AliRsnCutSet (const AliRsnCutSet & copy) :
- TNamed ((TNamed) copy),
- fCuts(copy.fCuts),
- fNumOfCuts(copy.fNumOfCuts),
- fCutScheme(copy.fCutScheme),
- fCutSchemeIndexed (copy.fCutSchemeIndexed),
- fBoolValues(0),
- fIsScheme(copy.fIsScheme),
- fExpression(copy.fExpression)
+AliRsnCutSet::AliRsnCutSet(const AliRsnCutSet & copy) :
+ TNamed((TNamed) copy),
+ fCuts(copy.fCuts),
+ fNumOfCuts(copy.fNumOfCuts),
+ fCutScheme(copy.fCutScheme),
+ fCutSchemeIndexed(copy.fCutSchemeIndexed),
+ fBoolValues(0),
+ fIsScheme(copy.fIsScheme),
+ fExpression(copy.fExpression)
{
//
// Copy constructor
//
- AliRsnExpression::sCutSet = this;
+ AliRsnExpression::sCutSet = this;
}
//_____________________________________________________________________________
// Destructor
//
- delete fExpression;
- delete [] fBoolValues;
+ delete fExpression;
+ delete [] fBoolValues;
}
//_____________________________________________________________________________
-void AliRsnCutSet::AddCut (AliRsnCut *cut)
+void AliRsnCutSet::AddCut(AliRsnCut *cut)
{
//
// Add a new cut.
// This must be done for all components of the final expression
//
- Int_t i;
-
- AliDebug (AliLog::kDebug,"<-");
- fCuts.Add (cut);
- fNumOfCuts++;
-
- if (fBoolValues) delete fBoolValues;
-
- fBoolValues = new Bool_t[fNumOfCuts];
- for (i = 0; i < fNumOfCuts; i++) {
- fBoolValues[i] = kTRUE;
- }
-
- AliDebug (AliLog::kDebug,Form ("%d",fCuts.GetEntriesFast()));
- AliDebug (AliLog::kDebug,"->");
+ Int_t i;
+
+ AliDebug(AliLog::kDebug,"<-");
+ fCuts.Add(cut);
+ fNumOfCuts++;
+
+ if (fBoolValues) delete fBoolValues;
+
+ fBoolValues = new Bool_t[fNumOfCuts];
+ for (i = 0; i < fNumOfCuts; i++)
+ {
+ fBoolValues[i] = kTRUE;
+ }
+
+ AliDebug(AliLog::kDebug,Form("%d",fCuts.GetEntriesFast()));
+ AliDebug(AliLog::kDebug,"->");
}
//_____________________________________________________________________________
-void AliRsnCutSet::ShowCuts ()
+void AliRsnCutSet::ShowCuts()
{
//
// Prints all cuts
}
//_____________________________________________________________________________
-Bool_t AliRsnCutSet::IsSelected (AliRsnCut::ETarget type, AliRsnDaughter *daughter)
+Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnDaughter *daughter)
{
//
// Checks an object according to the cut expression defined here.
//
- Int_t i;
-
- if (!fNumOfCuts) return kTRUE;
-
- Bool_t boolReturn = kTRUE;
- AliRsnCut *cut;
- for (i = 0; i < fNumOfCuts; i++) {
- cut = (AliRsnCut*)fCuts.At(i);
- fBoolValues[i] = cut->IsSelected (type,daughter);
- }
-
- if (fIsScheme) boolReturn = Passed();
- return boolReturn;
+ Int_t i;
+
+ if (!fNumOfCuts) return kTRUE;
+
+ Bool_t boolReturn = kTRUE;
+ AliRsnCut *cut;
+ for (i = 0; i < fNumOfCuts; i++)
+ {
+ cut = (AliRsnCut*)fCuts.At(i);
+ fBoolValues[i] = cut->IsSelected(type,daughter);
+ }
+
+ if (fIsScheme) boolReturn = Passed();
+ return boolReturn;
}
//_____________________________________________________________________________
-Bool_t AliRsnCutSet::IsSelected (AliRsnCut::ETarget type, AliRsnPairParticle * pair)
+Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnPairParticle * pair)
{
//
// Checks an object according to the cut expression defined here.
//
- Int_t i;
-
- if (!fNumOfCuts) return kTRUE;
-
- Bool_t boolReturn = kTRUE;
- AliRsnCut *cut;
- for (i = 0; i < fNumOfCuts; i++) {
- cut = (AliRsnCut*) fCuts.At (i);
- fBoolValues[i] = cut->IsSelected (type,pair);
- }
-
- if (fIsScheme) boolReturn = Passed();
- return boolReturn;
+ Int_t i;
+
+ if (!fNumOfCuts) return kTRUE;
+
+ Bool_t boolReturn = kTRUE;
+ AliRsnCut *cut;
+ for (i = 0; i < fNumOfCuts; i++)
+ {
+ cut = (AliRsnCut*) fCuts.At(i);
+ fBoolValues[i] = cut->IsSelected(type,pair);
+ }
+
+ if (fIsScheme) boolReturn = Passed();
+ return boolReturn;
}
//_____________________________________________________________________________
-Bool_t AliRsnCutSet::IsSelected (AliRsnCut::ETarget type, AliRsnEvent * event)
+Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnEvent * event)
{
//
// Checks an object according to the cut expression defined here.
//
- Int_t i;
- if (!fNumOfCuts) return kTRUE;
-
- Bool_t boolReturn = kTRUE;
- AliRsnCut *cut;
- for (i = 0; i < fNumOfCuts; i++) {
- cut = (AliRsnCut*) fCuts.At (i);
- fBoolValues[i] = cut->IsSelected (type,event);
- }
-
- if (fIsScheme) boolReturn = Passed();
- return boolReturn;
+ Int_t i;
+ if (!fNumOfCuts) return kTRUE;
+
+ Bool_t boolReturn = kTRUE;
+ AliRsnCut *cut;
+ for (i = 0; i < fNumOfCuts; i++)
+ {
+ cut = (AliRsnCut*) fCuts.At(i);
+ fBoolValues[i] = cut->IsSelected(type,event);
+ }
+
+ if (fIsScheme) boolReturn = Passed();
+ return boolReturn;
}
//_____________________________________________________________________________
-void AliRsnCutSet::SetCutScheme (const TString & theValue)
+void AliRsnCutSet::SetCutScheme(const TString & theValue)
{
//
// Define the combination of cuts with logical operators
// and using the names given to all defined cuts.
//
- AliDebug (AliLog::kDebug,"<-");
- fCutScheme = theValue;
- SetCutSchemeIndexed (theValue);
- fIsScheme = kTRUE;
- AliDebug (AliLog::kDebug,"->");
+ AliDebug(AliLog::kDebug,"<-");
+ fCutScheme = theValue;
+ SetCutSchemeIndexed(theValue);
+ fIsScheme = kTRUE;
+ AliDebug(AliLog::kDebug,"->");
}
//_____________________________________________________________________________
-void AliRsnCutSet::SetCutSchemeIndexed (TString theValue)
+void AliRsnCutSet::SetCutSchemeIndexed(TString theValue)
{
//
// Internal method which indexes all cuts to organize their combo
//
- AliDebug (AliLog::kDebug,"<-");
- theValue.Append(" ");
- // fCutSchemeIndexed = theValue;
- fCutSchemeIndexed = GetCutSchemeIndexed();
- AliDebug (AliLog::kDebug,"->");
+ AliDebug(AliLog::kDebug,"<-");
+ theValue.Append(" ");
+ // fCutSchemeIndexed = theValue;
+ fCutSchemeIndexed = GetCutSchemeIndexed();
+ AliDebug(AliLog::kDebug,"->");
}
//_____________________________________________________________________________
-Int_t AliRsnCutSet::GetIndexByCutName (TString s)
+Int_t AliRsnCutSet::GetIndexByCutName(TString s)
{
//
// Retrieve the cut index from its name
//
- Int_t i;
- AliRsnCut *cut;
-
- for (i = 0; i < fCuts.GetEntriesFast(); i++) {
- cut = (AliRsnCut*) fCuts.At (i);
- if (!s.CompareTo (cut->GetName())) return i;
- }
-
- return -1;
+ Int_t i;
+ AliRsnCut *cut;
+
+ for (i = 0; i < fCuts.GetEntriesFast(); i++)
+ {
+ cut = (AliRsnCut*) fCuts.At(i);
+ if (!s.CompareTo(cut->GetName())) return i;
+ }
+
+ return -1;
}
//_____________________________________________________________________________
// and gives a global response to the cut check
//
- AliRsnExpression::sCutSet = this;
- if (!fExpression) {
- fExpression = new AliRsnExpression (fCutSchemeIndexed);
- AliDebug (AliLog::kDebug,"fExpression was created.");
- }
-
- return fExpression->Value (*GetCuts());
+ AliRsnExpression::sCutSet = this;
+ if (!fExpression)
+ {
+ fExpression = new AliRsnExpression(fCutSchemeIndexed);
+ AliDebug(AliLog::kDebug,"fExpression was created.");
+ }
+
+ return fExpression->Value(*GetCuts());
}
//_____________________________________________________________________________
// Validity check on cut expression specified by user
//
- return (! (ShowCutScheme().Contains ("Error")));
+ return (!(ShowCutScheme().Contains("Error")));
}
//_____________________________________________________________________________
//
// Utility method to check validity of expression
//
- return fExpression->Unparse();
+ return fExpression->Unparse();
}
//_____________________________________________________________________________
-Int_t AliRsnCutSet::TestExpression (TString opt)
+Int_t AliRsnCutSet::TestExpression(TString opt)
{
// AliRsnCut *cut1 = new AliRsnCut ("aaa","aaa");
//
// set->ShowCuts ();
- AliDebug(1, opt.Data());
- return 0;
+ AliDebug(1, opt.Data());
+ return 0;
}
//_____________________________________________________________________________
// Show data about the cut set
//
- Int_t i;
-
- AliInfo ("========== Rsn Cut Set info ==============");
- AliInfo (Form ("Sheme : %s",fCutScheme.Data()));
- AliInfo (Form ("Sheme : %s",fCutSchemeIndexed.Data()));
- AliInfo (Form ("Num of Cuts: %d", fCuts.GetEntriesFast()));
- AliInfo ("====== Cuts ======");
- AliRsnCut *cut;
- for (i = 0; i < fCuts.GetEntriesFast(); i++) {
- cut = (AliRsnCut*) fCuts.At (i);
- if (cut) AliInfo (Form ("%d %d",i,fBoolValues[i]));
- }
- AliInfo ("========== END Rsn Cut Mgr info ==============");
+ Int_t i;
+
+ AliInfo("========== Rsn Cut Set info ==============");
+ AliInfo(Form("Sheme : %s",fCutScheme.Data()));
+ AliInfo(Form("Sheme : %s",fCutSchemeIndexed.Data()));
+ AliInfo(Form("Num of Cuts: %d", fCuts.GetEntriesFast()));
+ AliInfo("====== Cuts ======");
+ AliRsnCut *cut;
+ for (i = 0; i < fCuts.GetEntriesFast(); i++)
+ {
+ cut = (AliRsnCut*) fCuts.At(i);
+ if (cut) AliInfo(Form("%d %d",i,fBoolValues[i]));
+ }
+ AliInfo("========== END Rsn Cut Mgr info ==============");
}
//_____________________________________________________________________________
// for evaluation of cut expression
//
- AliDebug (AliLog::kDebug,"<-");
- Int_t i;
- TString str (fCutScheme);
- AliDebug (AliLog::kDebug,Form ("Num of cuts %d",fCuts.GetEntriesFast()));
- AliRsnCut *cut;
- for (i = 0; i < fCuts.GetEntriesFast(); i++) {
- cut = (AliRsnCut*) fCuts.At (i);
- str.ReplaceAll (cut->GetName(),Form ("%d",i));
- }
- AliDebug (AliLog::kDebug,"->");
- return str;
+ AliDebug(AliLog::kDebug,"<-");
+ Int_t i;
+ TString str(fCutScheme);
+ AliDebug(AliLog::kDebug,Form("Num of cuts %d",fCuts.GetEntriesFast()));
+ AliRsnCut *cut;
+ for (i = 0; i < fCuts.GetEntriesFast(); i++)
+ {
+ cut = (AliRsnCut*) fCuts.At(i);
+ str.ReplaceAll(cut->GetName(),Form("%d",i));
+ }
+ AliDebug(AliLog::kDebug,"->");
+ return str;
}
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice *
**************************************************************************/
-
+
//
// class AliRsnCutSet
// Combination of simple cuts
class AliRsnCutSet : public TNamed
{
-public:
+ public:
AliRsnCutSet();
- AliRsnCutSet (TString name);
- AliRsnCutSet (const AliRsnCutSet ©);
+ AliRsnCutSet(TString name);
+ AliRsnCutSet(const AliRsnCutSet ©);
~AliRsnCutSet();
- void AddCut (AliRsnCut* cut);
+ void AddCut(AliRsnCut* cut);
void ShowCuts();
- Int_t GetIndexByCutName (TString s);
+ Int_t GetIndexByCutName(TString s);
Bool_t Passed();
Bool_t IsValidScheme();
TString ShowCutScheme();
- Int_t TestExpression (TString opt="short");
+ Int_t TestExpression(TString opt="short");
void PrintSetInfo();
- Bool_t IsSelected (AliRsnCut::ETarget type, AliRsnDaughter *daughter);
- Bool_t IsSelected (AliRsnCut::ETarget type, AliRsnPairParticle *pair);
- Bool_t IsSelected (AliRsnCut::ETarget type, AliRsnEvent *event);
+ Bool_t IsSelected(AliRsnCut::ETarget type, AliRsnDaughter *daughter);
+ Bool_t IsSelected(AliRsnCut::ETarget type, AliRsnPairParticle *pair);
+ Bool_t IsSelected(AliRsnCut::ETarget type, AliRsnEvent *event);
- void SetBoolValue (Bool_t theValue,Int_t index) { fBoolValues[index] = theValue; }
- Bool_t GetBoolValue (Int_t index) const { return fBoolValues[index]; }
+ void SetBoolValue(Bool_t theValue,Int_t index) { fBoolValues[index] = theValue; }
+ Bool_t GetBoolValue(Int_t index) const { return fBoolValues[index]; }
- void SetCutScheme (const TString& theValue);
+ void SetCutScheme(const TString& theValue);
TString GetCutScheme() const { return fCutScheme; }
- void SetCutSchemeIndexed (TString theValue);
+ void SetCutSchemeIndexed(TString theValue);
TString GetCutSchemeIndexed();
TObjArray *GetCuts() { return &fCuts; }
-private:
+ private:
AliRsnCutSet& operator=(const AliRsnCutSet& /*copy*/) {return (*this);}
Bool_t *fBoolValues; //[fNumOfCuts]
Bool_t fIsScheme; // is scheme
-
+
AliRsnExpression *fExpression; // pointer to AliRsnExpression
- ClassDef (AliRsnCutSet,1); // ROOT dictionary
+ ClassDef(AliRsnCutSet,1); // ROOT dictionary
};
#endif
//_____________________________________________________________________________
AliRsnDaughter::AliRsnDaughter() :
- AliVParticle(),
- fIndex(-1),
- fLabel(-1),
- fCharge(0),
- fFlags(0),
- fMass(0.0),
- fRealisticPID(AliRsnPID::kUnknown),
- fMCInfo(0x0)
+ AliVParticle(),
+ fIndex(-1),
+ fLabel(-1),
+ fCharge(0),
+ fFlags(0),
+ fMass(0.0),
+ fRealisticPID(AliRsnPID::kUnknown),
+ fMCInfo(0x0)
{
//
// 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;
+ 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),
- fMass(copy.fMass),
- fRealisticPID(copy.fRealisticPID),
- fMCInfo(0x0)
+ AliVParticle(copy),
+ fIndex(copy.fIndex),
+ fLabel(copy.fLabel),
+ fCharge(copy.fCharge),
+ fFlags(copy.fFlags),
+ fMass(copy.fMass),
+ fRealisticPID(copy.fRealisticPID),
+ fMCInfo(0x0)
{
//
// Copy constructor.
//
- 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];
+ 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));
+ // initialize particle object
+ // only if it is present in the template object
+ if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
}
//_____________________________________________________________________________
AliRsnDaughter::AliRsnDaughter(AliESDtrack *track, Bool_t useTPC) :
- AliVParticle(),
- fIndex(-1),
- fLabel(-1),
- fCharge(0),
- fFlags(0),
- fMass(0.0),
- fRealisticPID(AliRsnPID::kUnknown),
- fMCInfo(0x0)
+ AliVParticle(),
+ fIndex(-1),
+ fLabel(-1),
+ fCharge(0),
+ fFlags(0),
+ fMass(0.0),
+ fRealisticPID(AliRsnPID::kUnknown),
+ fMCInfo(0x0)
{
//
// Constructor to get data from an ESD track.
//
- Int_t i;
- for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
- Adopt(track, useTPC);
+ Int_t i;
+ for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
+ Adopt(track, kEsd,0.0,useTPC);
}
//_____________________________________________________________________________
AliRsnDaughter::AliRsnDaughter(AliAODTrack *track) :
- AliVParticle(),
- fIndex(-1),
- fLabel(-1),
- fCharge(0),
- fFlags(0),
- fMass(0.0),
- fRealisticPID(AliRsnPID::kUnknown),
- fMCInfo(0x0)
+ AliVParticle(),
+ fIndex(-1),
+ fLabel(-1),
+ fCharge(0),
+ fFlags(0),
+ fMass(0.0),
+ fRealisticPID(AliRsnPID::kUnknown),
+ fMCInfo(0x0)
{
//
// Constructor to get data from an AOD track.
//
- Int_t i;
- for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
- Adopt(track);
+ Int_t i;
+ for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
+ Adopt(track);
}
//_____________________________________________________________________________
AliRsnDaughter::AliRsnDaughter(AliMCParticle *track) :
- AliVParticle(),
- fIndex(-1),
- fLabel(-1),
- fCharge(0),
- fFlags(0),
- fMass(0.0),
- fRealisticPID(AliRsnPID::kUnknown),
- fMCInfo(0x0)
+ AliVParticle(),
+ fIndex(-1),
+ fLabel(-1),
+ fCharge(0),
+ fFlags(0),
+ fMass(0.0),
+ fRealisticPID(AliRsnPID::kUnknown),
+ fMCInfo(0x0)
{
//
// Constructor to get data from an MC track.
//
- Int_t i;
- for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
- Adopt(track);
+ Int_t i;
+ for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
+ Adopt(track);
}
//_____________________________________________________________________________
// to the initialized object for which it is called.
//
- fIndex = copy.fIndex;
- fLabel = copy.fLabel;
- fCharge = copy.fCharge;
- fFlags = copy.fFlags;
-
- 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];
- }
-
- fMass = copy.fMass;
- fRealisticPID = copy.fRealisticPID;
+ fIndex = copy.fIndex;
+ fLabel = copy.fLabel;
+ fCharge = copy.fCharge;
+ fFlags = copy.fFlags;
- // 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;
+ Int_t i;
+ for (i = 0; i < AliRsnPID::kSpecies; i++)
+ {
+ if (i < 3)
+ {
+ fP[i] = copy.fP[i];
+ fV[i] = copy.fV[i];
}
- if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
-
- return (*this);
+ fPIDWeight[i] = copy.fPIDWeight[i];
+ fPIDProb[i] = copy.fPIDProb[i];
+ }
+
+ fMass = copy.fMass;
+ 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));
+
+ return (*this);
}
//_____________________________________________________________________________
// Destructor
//
- if (fMCInfo) {
- delete fMCInfo;
- fMCInfo = 0;
- }
+ if (fMCInfo)
+ {
+ delete fMCInfo;
+ fMCInfo = 0;
+ }
}
//_____________________________________________________________________________
// sets the i-th PID weight to 'value'
//
- if (i >= 0 && i < AliRsnPID::kSpecies) fPIDWeight[i] = value;
- else {
- AliError(Form("Cannot set a weight related to slot %d", i));
- }
+ if (i >= 0 && i < AliRsnPID::kSpecies) fPIDWeight[i] = value;
+ else
+ {
+ AliError(Form("Cannot set a weight related to slot %d", i));
+ }
}
//_____________________________________________________________________________
// Assign realistic PID from largest probability
//
- Int_t i, imax = 0;
- Double_t pmax = fPIDProb[0];
-
- // search for maximum
- for (i = 1; i < AliRsnPID::kSpecies; i++) {
- if (fPIDProb[i] > pmax) {
- imax = i;
- pmax = fPIDProb[i];
- }
+ Int_t i, imax = 0;
+ Double_t pmax = fPIDProb[0];
+
+ // search for maximum
+ for (i = 1; i < AliRsnPID::kSpecies; i++)
+ {
+ if (fPIDProb[i] > pmax)
+ {
+ imax = i;
+ pmax = fPIDProb[i];
}
-
- fRealisticPID = (AliRsnPID::EType)imax;
+ }
+
+ fRealisticPID = (AliRsnPID::EType)imax;
}
//_____________________________________________________________________________
-AliRsnPID::EType AliRsnDaughter::PIDType(Double_t &prob)
+AliRsnPID::EType 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) {
- case kNoPID:
- AliWarning("Requested a PIDtype call in NoPID mode");
- return AliRsnPID::kUnknown;
- case kPerfect:
- if (fMCInfo) return AliRsnPID::InternalType(fMCInfo->PDG());
- else return AliRsnPID::kUnknown;
- default:
- if (fRealisticPID > 0 && fRealisticPID < AliRsnPID::kSpecies) {
- prob = fPIDProb[fRealisticPID];
- return fRealisticPID;
- }
- else {
- prob = 1.0;
- return AliRsnPID::kUnknown;
- }
- }
+ switch (fgPIDMethod)
+ {
+ case kNoPID:
+ AliWarning("Requested a PIDtype call in NoPID mode");
+ return AliRsnPID::kUnknown;
+ case kPerfect:
+ if (fMCInfo) return AliRsnPID::InternalType(fMCInfo->PDG());
+ else return AliRsnPID::kUnknown;
+ default:
+ if (fRealisticPID > 0 && fRealisticPID < AliRsnPID::kSpecies)
+ {
+ prob = fPIDProb[fRealisticPID];
+ return fRealisticPID;
+ }
+ else
+ {
+ prob = 1.0;
+ return AliRsnPID::kUnknown;
+ }
+ }
}
//_____________________________________________________________________________
// sets the i-th PID probability to 'value'
//
- if (i >= 0 && i < AliRsnPID::kSpecies) fPIDProb[i] = value;
- else {
- AliError(Form("Cannot set a weight related to slot %d", i));
- }
+ if (i >= 0 && i < AliRsnPID::kSpecies) fPIDProb[i] = value;
+ else
+ {
+ AliError(Form("Cannot set a weight related to slot %d", i));
+ }
}
//_____________________________________________________________________________
-Bool_t AliRsnDaughter::Adopt(AliESDtrack* esdTrack, Bool_t useTPCInnerParam)
+Bool_t AliRsnDaughter::Adopt(AliESDtrack* esdTrack,EPIDType pidType ,Double_t divValue, Bool_t useTPCInnerParam)
{
//
// Copies data from an AliESDtrack into "this":
// In case of errors returns kFALSE, otherwise kTRUE.
//
- if (!esdTrack) {
- AliError("Passed NULL object: nothing done");
- return kFALSE;
- }
-
- // copy momentum and vertex
- if (!useTPCInnerParam) {
- esdTrack->GetPxPyPz(fP);
- esdTrack->GetXYZ(fV);
- }
- else {
- if (!esdTrack->GetTPCInnerParam()) return kFALSE;
- esdTrack->GetTPCInnerParam()->GetPxPyPz(fP);
- esdTrack->GetTPCInnerParam()->GetXYZ(fV);
- }
-
- // copy PID weights
- Int_t i;
- Double_t pid[5];
- if (!useTPCInnerParam) {
- esdTrack->GetESDpid(pid);
- }
- else {
- esdTrack->GetTPCpid(pid);
- }
- for (i = 0; i < 5; i++) fPIDWeight[i] = pid[i];
-
- // copy flags
- fFlags = esdTrack->GetStatus();
-
- // copy charge sign
- fCharge = (Short_t)esdTrack->Charge();
-
- return kTRUE;
+ if (!esdTrack)
+ {
+ AliError("Passed NULL object: nothing done");
+ return kFALSE;
+ }
+
+ // copy momentum and vertex
+ if (!useTPCInnerParam)
+ {
+ esdTrack->GetPxPyPz(fP);
+ esdTrack->GetXYZ(fV);
+ }
+ else
+ {
+ if (!esdTrack->GetTPCInnerParam()) return kFALSE;
+ esdTrack->GetTPCInnerParam()->GetPxPyPz(fP);
+ esdTrack->GetTPCInnerParam()->GetXYZ(fV);
+ }
+
+ Double_t p = esdTrack->P();
+ // copy PID weights
+ Int_t i;
+ Double_t pid[5];
+ if (!useTPCInnerParam)
+ {
+ GetESDPID(esdTrack,pid,pidType,divValue,p);
+ }
+ else
+ {
+// fCurrentESDPID = kTPC;
+ GetESDPID(esdTrack,pid,kTPC,0.0,p);
+ }
+ for (i = 0; i < 5; i++) fPIDWeight[i] = pid[i];
+
+ // copy flags
+ fFlags = esdTrack->GetStatus();
+
+ // copy charge sign
+ fCharge = (Short_t)esdTrack->Charge();
+
+ return kTRUE;
}
// In case of errors returns kFALSE, otherwise kTRUE.
//
- if (!aodTrack) {
- AliError("Passed NULL object: nothing done");
- return kFALSE;
- }
+ if (!aodTrack)
+ {
+ AliError("Passed NULL object: nothing done");
+ return kFALSE;
+ }
- // copy momentum and vertex
- fP[0] = aodTrack->Px();
- fP[1] = aodTrack->Py();
- fP[2] = aodTrack->Pz();
- fV[0] = aodTrack->Xv();
- fV[1] = aodTrack->Yv();
- fV[2] = aodTrack->Zv();
+ // copy momentum and vertex
+ fP[0] = aodTrack->Px();
+ fP[1] = aodTrack->Py();
+ fP[2] = aodTrack->Pz();
+ fV[0] = aodTrack->Xv();
+ fV[1] = aodTrack->Yv();
+ fV[2] = aodTrack->Zv();
- // copy PID weights
- Int_t i;
- for (i = 0; i < 5; i++) fPIDWeight[i] = aodTrack->PID()[i];
-
- // copy flags
- fFlags = aodTrack->GetStatus();
+ // copy PID weights
+ Int_t i;
+ for (i = 0; i < 5; i++) fPIDWeight[i] = aodTrack->PID()[i];
+
+ // copy flags
+ fFlags = aodTrack->GetStatus();
- // copy sign
- fCharge = aodTrack->Charge();
+ // copy sign
+ fCharge = aodTrack->Charge();
- return kTRUE;
+ return kTRUE;
}
// In case of errors returns kFALSE, otherwise kTRUE.
//
- if (!mcParticle) {
- AliError("Passed NULL object: nothing done");
- return kFALSE;
- }
-
- // retrieve the TParticle object from the argument
- TParticle *particle = mcParticle->Particle();
- if (!particle) {
- AliError("AliMCParticle::Particle() returned NULL");
- return kFALSE;
- }
-
- // copy momentum and vertex
- fP[0] = particle->Px();
- fP[1] = particle->Py();
- fP[2] = particle->Pz();
- fV[0] = particle->Vx();
- fV[1] = particle->Vy();
- fV[2] = particle->Vz();
-
- // recognize charge sign from PDG code sign
- Int_t pdg = particle->GetPdgCode();
- Int_t absPDG = TMath::Abs(pdg);
- if (absPDG <= 15) {
- if (pdg > 0) fCharge = -1; else fCharge = 1;
- }
- else if (absPDG < 3000) {
- if (pdg > 0) fCharge = 1; else fCharge = -1;
- }
- else {
- fCharge = 0;
- return kFALSE;
- }
-
- // flags and PID weights make no sense with MC tracks
- fFlags = 0;
- for (pdg = 0; pdg < AliRsnPID::kSpecies; pdg++) fPIDWeight[pdg] = 0.0;
- fPIDWeight[AliRsnPID::InternalType(absPDG)] = 1.0;
-
- // copy other MC info (mother PDG code cannot be retrieved here)
- InitMCInfo(particle);
-
- return kTRUE;
+ if (!mcParticle)
+ {
+ AliError("Passed NULL object: nothing done");
+ return kFALSE;
+ }
+
+ // retrieve the TParticle object from the argument
+ TParticle *particle = mcParticle->Particle();
+ if (!particle)
+ {
+ AliError("AliMCParticle::Particle() returned NULL");
+ return kFALSE;
+ }
+
+ // copy momentum and vertex
+ fP[0] = particle->Px();
+ fP[1] = particle->Py();
+ fP[2] = particle->Pz();
+ fV[0] = particle->Vx();
+ fV[1] = particle->Vy();
+ fV[2] = particle->Vz();
+
+ // recognize charge sign from PDG code sign
+ Int_t pdg = particle->GetPdgCode();
+ Int_t absPDG = TMath::Abs(pdg);
+ if (absPDG <= 15)
+ {
+ if (pdg > 0) fCharge = -1; else fCharge = 1;
+ }
+ else if (absPDG < 3000)
+ {
+ if (pdg > 0) fCharge = 1; else fCharge = -1;
+ }
+ else
+ {
+ fCharge = 0;
+ return kFALSE;
+ }
+
+ // flags and PID weights make no sense with MC tracks
+ fFlags = 0;
+ for (pdg = 0; pdg < AliRsnPID::kSpecies; pdg++) fPIDWeight[pdg] = 0.0;
+ fPIDWeight[AliRsnPID::InternalType(absPDG)] = 1.0;
+
+ // copy other MC info (mother PDG code cannot be retrieved here)
+ InitMCInfo(particle);
+
+ return kTRUE;
}
//_____________________________________________________________________________
// Index and label are printed by default.
//
- TString opt(option);
- opt.ToUpper();
-
- if (opt.Contains("L") || opt.Contains("ALL")) {
- cout << ".......Index : " << fIndex << endl;
- cout << ".......Label : " << fLabel << endl;
- }
- if (opt.Contains("P") || opt.Contains("ALL")) {
- cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
- }
- if (opt.Contains("V") || opt.Contains("ALL")) {
- cout << ".......Vx, Vy, Vz : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
- }
- if (opt.Contains("C") || opt.Contains("ALL")) {
- cout << ".......Charge : " << fCharge << endl;
- }
- if (opt.Contains("F") || opt.Contains("ALL")) {
- cout << ".......Flags : " << fFlags << endl;
- }
- if (opt.Contains("W") || opt.Contains("ALL")) {
- cout << ".......Weights : ";
- Int_t i;
- for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[i] << ' ';
- cout << endl;
+ TString opt(option);
+ opt.ToUpper();
+
+ if (opt.Contains("L") || opt.Contains("ALL"))
+ {
+ cout << ".......Index : " << fIndex << endl;
+ cout << ".......Label : " << fLabel << endl;
+ }
+ if (opt.Contains("P") || opt.Contains("ALL"))
+ {
+ cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
+ }
+ 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;
+ Double_t prob;
+ type = PIDType(prob);
+ cout << ".......PID & prob : " << AliRsnPID::ParticleName(type) << ' ' << prob << endl;
+ }
+ if (opt.Contains("C") || opt.Contains("ALL"))
+ {
+ cout << ".......Charge : " << fCharge << endl;
+ }
+ if (opt.Contains("F") || opt.Contains("ALL"))
+ {
+ cout << ".......Flags : " << fFlags << endl;
+ }
+ if (opt.Contains("W") || opt.Contains("ALL"))
+ {
+ cout << ".......Weights : ";
+ Int_t i;
+ for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[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;
}
- 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 {
- cout << ".......MC info not present" << endl;
- }
+ else
+ {
+ cout << ".......MC info not present" << endl;
}
+ }
}
//_____________________________________________________________________________
// Initializes the particle object with default constructor.
//
- fMCInfo = new AliRsnMCInfo;
+ fMCInfo = new AliRsnMCInfo;
}
//_____________________________________________________________________________
// otherwise returns kTRUE.
//
- // retrieve the TParticle object pointed by this MC track
- if (!particle) {
- AliError("Passed NULL particle object");
- return kFALSE;
- }
+ // retrieve the TParticle object pointed by this MC track
+ if (!particle)
+ {
+ AliError("Passed NULL particle object");
+ return kFALSE;
+ }
- // initialize object if not initialized yet
- if (fMCInfo) delete fMCInfo;
- fMCInfo = new AliRsnMCInfo;
- fMCInfo->Adopt(particle);
+ // initialize object if not initialized yet
+ if (fMCInfo) delete fMCInfo;
+ fMCInfo = new AliRsnMCInfo;
+ fMCInfo->Adopt(particle);
- return kTRUE;
+ return kTRUE;
}
//_____________________________________________________________________________
// otherwise returns kTRUE.
//
- // retrieve the TParticle object pointed by this MC track
- TParticle *particle = mcParticle->Particle();
- return InitMCInfo(particle);
+ // retrieve the TParticle object pointed by this MC track
+ TParticle *particle = mcParticle->Particle();
+ return InitMCInfo(particle);
}
//_____________________________________________________________________________
{
//
// 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
+// 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;
+ AliRsnDaughter *that = (AliRsnDaughter*)obj;
+ if (Pt() < that->Pt()) return 1;
+ else if (Pt() > that->Pt()) return -1;
+ else return 0;
}
+
+//_____________________________________________________________________________
+void AliRsnDaughter::GetESDPID(AliESDtrack * track, Double_t * pid,EPIDType pidType, Double_t divValue, Double_t val)
+{
+//
+// return PID from EPIDType type
+//
+
+ Double_t ctmp[AliRsnPID::kSpecies];
+ switch (pidType)
+ {
+ case kEsd :
+ track->GetESDpid(pid);
+ break;
+ case kITS :
+ track->GetITSpid(pid);
+ break;
+ case kTPC :
+ track->GetTPCpid(pid);
+ break;
+ case kTOF :
+ track->GetTOFpid(pid);
+ break;
+ case kITS_TPC :
+ track->GetITSpid(pid);
+ track->GetTPCpid(ctmp);
+ for (Int_t i=0;i<5;i++) pid[i]*=ctmp[i];
+ break;
+ case kITS_TOF :
+ track->GetITSpid(pid);
+ track->GetTOFpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ break;
+ case kTPC_TOF :
+ track->GetTPCpid(pid);
+ track->GetTOFpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ break;
+ case kITS_TPC_TOF :
+ track->GetITSpid(pid);
+ track->GetTPCpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ track->GetTOFpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ break;
+ case kITS_TPC_TOF_SP :
+ if (val<divValue)
+ {
+ track->GetITSpid(pid);
+ track->GetTPCpid(ctmp);
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
+ }
+ else
+ {
+ track->GetTOFpid(pid);
+ }
+ break;
+ default:
+// AliWarning("Unrecognized value of EPIDType argument");
+ for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]=1.0;
+ break;
+ }
+}
+
class AliRsnDaughter : public AliVParticle
{
public:
-
- enum EPIDMethod {
- kNoPID = 0,
- kRealistic,
- kWeighted,
- kPerfect,
- kMethods
+
+ enum EPIDMethod
+ {
+ kNoPID = 0,
+ kRealistic,
+ kWeighted,
+ kPerfect,
+ kMethods
+ };
+
+ enum EPIDType
+ {
+ kEsd=0,
+ kITS,
+ kTPC,
+ kTOF,
+ kITS_TPC,
+ kITS_TOF,
+ kTPC_TOF,
+ kITS_TPC_TOF,
+ kITS_TPC_TOF_SP,
+ kLastPIDType
};
+
AliRsnDaughter();
- AliRsnDaughter (const AliRsnDaughter ©);
- AliRsnDaughter (AliESDtrack *track, Bool_t useTPCInnerParam = kFALSE);
- AliRsnDaughter (AliAODTrack *track);
- AliRsnDaughter (AliMCParticle *track);
+ AliRsnDaughter(const AliRsnDaughter ©);
+ AliRsnDaughter(AliESDtrack *track, Bool_t useTPCInnerParam = kFALSE);
+ AliRsnDaughter(AliAODTrack *track);
+ AliRsnDaughter(AliMCParticle *track);
virtual ~AliRsnDaughter();
AliRsnDaughter& operator= (const AliRsnDaughter& copy);
// 4-momentum
- virtual Double_t E() const {return TMath::Sqrt (fMass*fMass + P2());}
+ 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 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 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 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;}
- 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;}
+ virtual Bool_t PxPyPz(Double_t p[3]) const {p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE;}
+ 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;}
// 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);}
+ 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 Theta() const {return TMath::ATan2 (Pt(), Pz());}
- virtual Double_t Eta() const {return -TMath::Log (TMath::Tan (0.5*Theta()));}
- virtual Double_t Y() const {return TMath::Log ((E() + Pz()) / (E() - Pz()));}
+ virtual Double_t Phi() const {return TMath::ATan2(Py(), Px());}
+ virtual Double_t Theta() const {return TMath::ATan2(Pt(), Pz());}
+ virtual Double_t Eta() const {return -TMath::Log(TMath::Tan(0.5*Theta()));}
+ virtual Double_t Y() const {return TMath::Log((E() + Pz()) / (E() - Pz()));}
// Charge
virtual Short_t Charge() const {return fCharge;}
- void SetCharge (Short_t value) {fCharge = value;}
+ void SetCharge(Short_t value) {fCharge = 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);
- void SetPIDWeight (Int_t i, Double_t value);
+ void SetPIDProb(Int_t i, Double_t value);
+ void SetPIDWeight(Int_t i, Double_t value);
static void SetPIDMethod(EPIDMethod method) {fgPIDMethod = method;}
void AssignRealisticPID();
- AliRsnPID::EType PIDType(Double_t &prob);
+ AliRsnPID::EType PIDType(Double_t &prob) const;
// check that contains a given ESD flag
- Bool_t CheckFlag (ULong_t flag) {return (fFlags & flag);}
+ Bool_t CheckFlag(ULong_t flag) {return ((fFlags & flag) == flag);}
// information getters from objects
- Bool_t Adopt (AliESDtrack *track, Bool_t useTPCInnerParam = kFALSE);
- Bool_t Adopt (AliAODTrack *track);
- Bool_t Adopt (AliMCParticle *track);
+ Bool_t Adopt(AliESDtrack *track, EPIDType pidType = kEsd,Double_t divValue = 0.0,Bool_t useTPCInnerParam = kFALSE);
+ Bool_t Adopt(AliAODTrack *track);
+ Bool_t Adopt(AliMCParticle *track);
// 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;}
+ void SetIndex(Int_t value) {fIndex = value;}
+ void SetLabel(Int_t value) {fLabel = value;}
// Utilities
- void Print (Option_t *option = "ALL") const;
+ void Print(Option_t *option = "ALL") const;
void InitMCInfo();
- Bool_t InitMCInfo (TParticle *particle);
- Bool_t InitMCInfo (AliMCParticle *mcParticle);
+ Bool_t InitMCInfo(TParticle *particle);
+ Bool_t InitMCInfo(AliMCParticle *mcParticle);
// 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;
Double_t fPIDWeight[AliRsnPID::kSpecies]; // PID weights
AliRsnMCInfo *fMCInfo; // reference to particle object (if any)
+
static EPIDMethod fgPIDMethod; // flag to define how the PID is computed for this object
- ClassDef (AliRsnDaughter, 4);
+ static void GetESDPID(AliESDtrack *track,Double_t *pid,EPIDType pidType = kEsd,Double_t divValue=-1.0,Double_t val=-1.0);
+
+ ClassDef(AliRsnDaughter, 4);
};
#endif
#include "AliRsnEvent.h"
#include "AliRsnMCInfo.h"
-ClassImp (AliRsnEvent)
+ClassImp(AliRsnEvent)
//_____________________________________________________________________________
AliRsnEvent::AliRsnEvent() :
- TNamed ("rsnEvent", ""),
- fPVx (0.0),
- fPVy (0.0),
- fPVz (0.0),
- fTracks (0x0),
+ TNamed("rsnEvent", ""),
+ fPVx(0.0),
+ fPVy(0.0),
+ fPVz(0.0),
+ fTracks(0x0),
fNoPID(0x0),
- fPerfectPID (0x0),
- fRealisticPID (0x0)
+ fPerfectPID(0x0),
+ fRealisticPID(0x0)
{
//
// Default constructor
}
//_____________________________________________________________________________
-AliRsnEvent::AliRsnEvent (const AliRsnEvent &event) :
- TNamed (event),
- fPVx (event.fPVx),
- fPVy (event.fPVy),
- fPVz (event.fPVz),
- fTracks (0x0),
+AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) :
+ TNamed(event),
+ fPVx(event.fPVx),
+ fPVy(event.fPVy),
+ fPVz(event.fPVz),
+ fTracks(0x0),
fNoPID(0x0),
- fPerfectPID (0x0),
- fRealisticPID (0x0)
+ fPerfectPID(0x0),
+ fRealisticPID(0x0)
{
//
// Copy constructor.
// 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));
+ // 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();
+ // 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));
+ 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;
-
- // 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
- return (*this);
+ // 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;
+
+ // 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
+ return (*this);
}
//_____________________________________________________________________________
// destructor, which is automatically called from here.
//
- Clear();
- if (fTracks) delete fTracks;
+ Clear();
+ if (fTracks) delete fTracks;
}
//_____________________________________________________________________________
// Initialize TClonesArray data-member.
//
- fTracks = new TClonesArray ("AliRsnDaughter", 1);
- //fTracks->BypassStreamer (kFALSE);
+ fTracks = new TClonesArray("AliRsnDaughter", 1);
+ //fTracks->BypassStreamer (kFALSE);
}
//_____________________________________________________________________________
-void AliRsnEvent::Clear (Option_t* /*option*/)
+void AliRsnEvent::Clear(Option_t* /*option*/)
{
//
// Empties the collections (does not delete the objects).
// "if" statement are used.
//
- if (fTracks) fTracks->Delete();
- delete fNoPID;
- fNoPID = 0x0;
- delete fPerfectPID;
- fPerfectPID = 0x0;
- delete fRealisticPID;
- fRealisticPID = 0x0;
+ if (fTracks) fTracks->Delete();
+ delete fNoPID;
+ fNoPID = 0x0;
+ delete fPerfectPID;
+ fPerfectPID = 0x0;
+ delete fRealisticPID;
+ fRealisticPID = 0x0;
}
//_____________________________________________________________________________
-AliRsnDaughter* AliRsnEvent::AddTrack (AliRsnDaughter track)
+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;
+ Int_t nextIndex = fTracks->GetEntriesFast();
+ TClonesArray &tracks = (*fTracks);
+ AliRsnDaughter *copy = new(tracks[nextIndex]) AliRsnDaughter(track);
+ return copy;
}
//_____________________________________________________________________________
// Returns one track in the collection
// given the absolute index in the global TClonesArray
//
- return (AliRsnDaughter*) fTracks->UncheckedAt (index);
+ return (AliRsnDaughter*) fTracks->UncheckedAt(index);
}
//_____________________________________________________________________________
// If one specifies "AliRsnPID::kUnknown" as second arguments, the PID check is not done.
//
- Double_t prob;
- AliRsnPID::EType trackType;
- AliRsnDaughter *track, *leading = 0x0;
- TObjArrayIter iter(fTracks);
- while ( (track = (AliRsnDaughter*)iter.Next()) ) {
- if (track->Pt() < ptMin) continue;
- if (realistic) {
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic);
- }
- else {
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kPerfect);
- }
- trackType = track->PIDType(prob);
- if (type != AliRsnPID::kUnknown && trackType != type) continue;
- ptMin = track->Pt();
- leading = track;
+ Double_t prob;
+ AliRsnPID::EType trackType;
+ AliRsnDaughter *track, *leading = 0x0;
+ TObjArrayIter iter(fTracks);
+ while ((track = (AliRsnDaughter*) iter.Next()))
+ {
+ if (track->Pt() < ptMin) continue;
+ if (realistic)
+ {
+ AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic);
}
-
- return leading;
+ else
+ {
+ AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kPerfect);
+ }
+ trackType = track->PIDType(prob);
+ if (type != AliRsnPID::kUnknown && trackType != type) continue;
+ ptMin = track->Pt();
+ leading = track;
+ }
+
+ return leading;
}
//_____________________________________________________________________________
// When no tracks are found this way, the value "-1" is returned.
//
- if (realistic) {
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic);
- }
- else {
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kPerfect);
- }
-
- Double_t prob;
- Int_t i, nTracks = fTracks->GetEntries(), lastIndex = -1;
- for (i = 0; i < nTracks; i++) {
- AliRsnDaughter *d = (AliRsnDaughter*)fTracks->At(i);
- AliRsnPID::EType trackType = d->PIDType(prob);
- if (type != AliRsnPID::kUnknown && trackType != type) continue;
- if (d->Pt() >= ptMin) lastIndex = i;
- }
-
- return lastIndex;
+ if (realistic)
+ {
+ AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic);
+ }
+ else
+ {
+ AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kPerfect);
+ }
+
+ Double_t prob;
+ Int_t i, nTracks = fTracks->GetEntries(), lastIndex = -1;
+ for (i = 0; i < nTracks; i++)
+ {
+ AliRsnDaughter *d = (AliRsnDaughter*) fTracks->At(i);
+ AliRsnPID::EType trackType = d->PIDType(prob);
+ if (type != AliRsnPID::kUnknown && trackType != type) continue;
+ if (d->Pt() >= ptMin) lastIndex = i;
+ }
+
+ return lastIndex;
}
//_____________________________________________________________________________
-TArrayI* AliRsnEvent::GetCharged (Char_t sign)
+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;
+ if (fNoPID) return fNoPID->GetTracksArray(sign, AliRsnPID::kUnknown);
+ return 0x0;
}
//_____________________________________________________________________________
// If the arguments are wrong a NULL pointer is returned.
//
- switch (pidtype) {
- case AliRsnDaughter::kRealistic:
- if (fRealisticPID) {
- return fRealisticPID->GetTracksArray (sign, type);
- }
- break;
- case AliRsnDaughter::kPerfect:
- if (fPerfectPID) {
- return fPerfectPID->GetTracksArray (sign, type);
- }
- break;
- default:
- AliError ("Handled PID methods here are only kPerfect and kRealistic. Nothing done.");
- return 0x0;
- }
-
- return 0x0;
+ 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;
+ }
+ return 0x0;
}
//_____________________________________________________________________________
// 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;
- fPerfectPID = new AliRsnPIDIndex;
- fRealisticPID = new AliRsnPIDIndex;
-
- // 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()));
- }
+ if (fNoPID) delete fNoPID;
+ if (fPerfectPID) delete fPerfectPID;
+ if (fRealisticPID) delete fRealisticPID;
+ fNoPID = new AliRsnPIDIndex(2000);
+ fPerfectPID = new AliRsnPIDIndex(2000);
+ fRealisticPID = new AliRsnPIDIndex(2000);
+
+ // 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()));
}
+ }
- // adjusts the size of arrays
- if (fNoPID) fNoPID->SetCorrectIndexSize();
- if (fPerfectPID) fPerfectPID->SetCorrectIndexSize();
- if (fRealisticPID) fRealisticPID->SetCorrectIndexSize();
+ // adjusts the size of arrays
+ if (fNoPID) fNoPID->SetCorrectIndexSize();
+ if (fPerfectPID) fPerfectPID->SetCorrectIndexSize();
+ if (fRealisticPID) fRealisticPID->SetCorrectIndexSize();
}
//_____________________________________________________________________________
-void AliRsnEvent::Print (Option_t *option) const
+void AliRsnEvent::Print(Option_t *option) const
{
//
// Lists the details of the event, and the ones of each
// Look at that method to understand option values.
//
- cout << "...Multiplicity : " << fTracks->GetEntries() << endl;
- cout << "...Primary vertex : " << fPVx << ' ' << fPVy << ' ' << fPVz << endl;
+ 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);
+ }
+}
- TObjArrayIter iter (fTracks);
+//_____________________________________________________________________________
+void AliRsnEvent::CorrectByPrimaryVertex()
+{
+//
+// Corrects the X,Y,Z position of DCA vertex of all tracks
+// by the amount of stored primary vertex
+//
+
+ TObjArrayIter iter(fTracks);
AliRsnDaughter *d = 0;
while ((d = (AliRsnDaughter*) iter.Next())) {
- cout << "....Track #" << fTracks->IndexOf (d) << endl;
- d->Print (option);
+ d->ShiftZero(fPVx, fPVy, fPVz);
}
}
// Get number of all tracks
//
- if (!fTracks) return 0;
- return fTracks->GetEntries();
+ if (!fTracks) return 0;
+ return fTracks->GetEntries();
}
//_____________________________________________________________________________
-Int_t AliRsnEvent::GetNCharged (Char_t sign)
+Int_t AliRsnEvent::GetNCharged(Char_t sign)
{
//
// Get number of charged tracks
//
- Int_t icharge;
- icharge = ChargeIndex (sign);
- if (icharge < 0) return 0;
- TArrayI *charged = GetCharged(sign);
- if (!charged) return 0;
- return charged->GetSize();
+ Int_t icharge;
+ icharge = ChargeIndex(sign);
+ if (icharge < 0) return 0;
+ TArrayI *charged = GetCharged(sign);
+ if (!charged) return 0;
+ return charged->GetSize();
}
//_____________________________________________________________________________
-Int_t AliRsnEvent::Fill (TObjArray *array)
+Int_t AliRsnEvent::Fill(TObjArray *array)
{
//
// Fills the data-member TClonesArray of tracks with
// 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++;
- }
+ // 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;
+ return errors;
}
//_____________________________________________________________________________
-Int_t AliRsnEvent::ChargeIndex (Char_t sign) const
+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;
- }
+ if (sign == '+') return 0;
+ else if (sign == '-') return 1;
+ else
+ {
+ AliError(Form("Character '%c' not recognized as charge sign", sign));
+ return -1;
+ }
}
public:
AliRsnEvent();
- AliRsnEvent (const AliRsnEvent& copy);
+ 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);
+ void Clear(Option_t *option = "");
+ AliRsnDaughter* AddTrack(AliRsnDaughter track);
+ AliRsnDaughter* GetTrack(Int_t index);
AliRsnDaughter* GetLeadingParticle(Double_t ptMin = 0.0, AliRsnPID::EType type = AliRsnPID::kUnknown, Bool_t realistic = kTRUE);
Int_t GetLastFastTrack(Double_t ptMin, AliRsnPID::EType type = AliRsnPID::kUnknown, Bool_t realistic = kTRUE);
TClonesArray* GetTracks() {return fTracks;}
- TArrayI* GetCharged (Char_t sign);
- TArrayI* GetTracksArray (AliRsnDaughter::EPIDMethod method, Char_t sign, AliRsnPID::EType type);
+ TArrayI* GetCharged(Char_t sign);
+ TArrayI* GetTracksArray(AliRsnDaughter::EPIDMethod method, Char_t sign, AliRsnPID::EType type);
void FillPIDArrays();
void SortTracks() {fTracks->Sort();}
- void Print (Option_t *option = "") const;
+ void Print(Option_t *option = "") const;
// Primary vertex
Double_t GetPrimaryVertexX() const {return fPVx;}
Double_t GetPrimaryVertexY() const {return fPVy;}
Double_t GetPrimaryVertexZ() const {return fPVz;}
- void GetPrimaryVertex (Double_t &x, Double_t &y, Double_t &z) const {x=fPVx;y=fPVy;z=fPVz;}
- void SetPrimaryVertexX (Double_t value) {fPVx = value;}
- void SetPrimaryVertexY (Double_t value) {fPVy = value;}
- void SetPrimaryVertexZ (Double_t value) {fPVz = value;}
- void SetPrimaryVertex (Double_t x, Double_t y, Double_t z) {fPVx=x;fPVy=y;fPVz=z;}
+ void GetPrimaryVertex(Double_t &x, Double_t &y, Double_t &z) const {x=fPVx;y=fPVy;z=fPVz;}
+ void SetPrimaryVertexX(Double_t value) {fPVx = value;}
+ void SetPrimaryVertexY(Double_t value) {fPVy = value;}
+ void SetPrimaryVertexZ(Double_t value) {fPVz = value;}
+ void SetPrimaryVertex(Double_t x, Double_t y, Double_t z) {fPVx=x;fPVy=y;fPVz=z;}
+ void CorrectByPrimaryVertex();
// Multiplicity
Int_t GetMultiplicity() const;
- Int_t GetNCharged (Char_t sign);
+ Int_t GetNCharged(Char_t sign);
private:
- Int_t ChargeIndex (Char_t sign) const;
- Int_t Fill (TObjArray *array);
+ Int_t ChargeIndex(Char_t sign) const;
+ Int_t Fill(TObjArray *array);
Double_t fPVx; // position of
Double_t fPVy; // primary
AliRsnPIDIndex *fPerfectPID; // array index for perfect PID
AliRsnPIDIndex *fRealisticPID; // array index for realistic PID (largest prob)
- ClassDef (AliRsnEvent, 2);
+ ClassDef(AliRsnEvent, 2);
};
#endif
#include "AliLog.h"
#include "AliRsnEventBuffer.h"
-ClassImp (AliRsnEventBuffer)
+ClassImp(AliRsnEventBuffer)
//_____________________________________________________________________________
-AliRsnEventBuffer::AliRsnEventBuffer (Int_t buffSize, Bool_t deleteBufferWhenReset) :
- fDeleteBufferWhenReset (deleteBufferWhenReset),
- fEventsBufferSize (buffSize),
- fEventsBufferIndex (-1)
+AliRsnEventBuffer::AliRsnEventBuffer(Int_t buffSize, Bool_t deleteBufferWhenReset) :
+ fDeleteBufferWhenReset(deleteBufferWhenReset),
+ fEventsBufferSize(buffSize),
+ fEventsBufferIndex(-1)
{
//
// Constructor.
// Initializes to NULL all AliRsnEvent pointers.
//
- Int_t i;
- for (i = 0; i < fEventsBufferSize; i++) fEventsBuffer[i] = 0;
+ Int_t i;
+ for (i = 0; i < fEventsBufferSize; i++) fEventsBuffer[i] = 0;
}
//_____________________________________________________________________________
// Actually does nothing.
//
- //ClearBuffer();
+ //ClearBuffer();
}
//_____________________________________________________________________________
// Clears buffer, resetting all pointers.
// If an event is on the HEAP, it is deleted.
//
- Int_t i;
- for (i = 0; i < fEventsBufferSize; i++) {
- AliDebug(1, Form ("Clearing slot #%p in buffer", fEventsBuffer[i]));
- if (fEventsBuffer[i]->IsOnHeap()) delete fEventsBuffer[i];
- fEventsBuffer[i] = 0;
- }
+ Int_t i;
+ for (i = 0; i < fEventsBufferSize; i++)
+ {
+ AliDebug(1, Form("Clearing slot #%p in buffer", fEventsBuffer[i]));
+ if (fEventsBuffer[i]->IsOnHeap()) delete fEventsBuffer[i];
+ fEventsBuffer[i] = 0;
+ }
}
//_____________________________________________________________________________
//
// Resets the index for accessing events in buffer
//
- fEventsBufferIndex = -1;
- if (fDeleteBufferWhenReset == kTRUE) ClearBuffer();
+ fEventsBufferIndex = -1;
+ if (fDeleteBufferWhenReset == kTRUE) ClearBuffer();
}
//_____________________________________________________________________________
-void AliRsnEventBuffer::AddEvent (AliRsnEvent * event)
+void AliRsnEventBuffer::AddEvent(AliRsnEvent * event)
{
//
// Insert a new event in the buffer.
// the new event replaces the oldest one in the buffer
//
- if (fEventsBufferIndex >= fEventsBufferSize - 1) ResetIndex();
- fEventsBufferIndex++;
- if (fEventsBuffer[fEventsBufferIndex])
- *fEventsBuffer[fEventsBufferIndex] = *event;
- else
- fEventsBuffer[fEventsBufferIndex] = new AliRsnEvent(*event);
+ if (fEventsBufferIndex >= fEventsBufferSize - 1) ResetIndex();
+ fEventsBufferIndex++;
+ if (fEventsBuffer[fEventsBufferIndex])
+ *fEventsBuffer[fEventsBufferIndex] = *event;
+ else
+ fEventsBuffer[fEventsBufferIndex] = new AliRsnEvent(*event);
}
//_____________________________________________________________________________
//
// Returns the current event in the buffer
//
- return GetEvent(fEventsBufferIndex);
+ return GetEvent(fEventsBufferIndex);
}
//_____________________________________________________________________________
//
// Returns next event in the buffer w.r. to current
//
- if (fEventsBufferIndex == fEventsBufferSize - 1) return GetEvent (0);
- else return GetEvent (fEventsBufferIndex + 1);
+ if (fEventsBufferIndex == fEventsBufferSize - 1) return GetEvent(0);
+ else return GetEvent(fEventsBufferIndex + 1);
}
//_____________________________________________________________________________
-AliRsnEvent * AliRsnEventBuffer::GetEvent (Int_t index)
+AliRsnEvent * AliRsnEventBuffer::GetEvent(Int_t index)
{
//
// Returns an event in the buffer, provided its index
//
- if (index < 0 || index >= fEventsBufferSize) {
- AliError(Form("Index out of range (index = %d , size = %d)", index, fEventsBufferSize));
- return 0x0;
- }
- return (AliRsnEvent*)fEventsBuffer[index];
+ if (index < 0 || index >= fEventsBufferSize)
+ {
+ AliDebug(AliLog::kError,Form("Index out of range (index = %d , size = %d)", index, fEventsBufferSize));
+ return 0x0;
+ }
+ return (AliRsnEvent*)fEventsBuffer[index];
}
//_____________________________________________________________________________
//
// Tells if the buffer is completely filled or has empty slots
//
- Int_t i, counter = 0;
- for (i = 0; i < fEventsBufferSize; i++) {
- if (!fEventsBuffer[i]) counter++;
- }
-
- return counter;
+ Int_t i, counter = 0;
+ for (i = 0; i < fEventsBufferSize; i++)
+ {
+ if (!fEventsBuffer[i]) counter++;
+ }
+
+ return counter;
}
class AliRsnEventBuffer : public TObject
{
-public:
+ public:
- AliRsnEventBuffer (Int_t buffsize = 1000, Bool_t deleteBufferWhenReset=kTRUE);
+ AliRsnEventBuffer(Int_t buffsize = 1000, Bool_t deleteBufferWhenReset=kTRUE);
~AliRsnEventBuffer();
void ClearBuffer();
void ResetIndex();
- void AddEvent (AliRsnEvent *event);
- AliRsnEvent *GetEvent (Int_t index) ;
- AliRsnEvent *GetCurrentEvent ();
- AliRsnEvent *GetNextEvent ();
+ void AddEvent(AliRsnEvent *event);
+ AliRsnEvent *GetEvent(Int_t index) ;
+ AliRsnEvent *GetCurrentEvent();
+ AliRsnEvent *GetNextEvent();
- void SetEventsBufferSize (const Int_t& theValue) { fEventsBufferSize = theValue; }
+ void SetEventsBufferSize(const Int_t& theValue) { fEventsBufferSize = theValue; }
Int_t GetEventsBufferSize() const { return fEventsBufferSize; }
Int_t GetEventsBufferIndex() const { return fEventsBufferIndex; }
- void SetDeleteBufferWhenReset (const Bool_t& theValue = kTRUE) { fDeleteBufferWhenReset = theValue; }
+ void SetDeleteBufferWhenReset(const Bool_t& theValue = kTRUE) { fDeleteBufferWhenReset = theValue; }
Bool_t GetDeleteBufferWhenReset() const { return fDeleteBufferWhenReset; }
Int_t NEmptySlots();
private:
- AliRsnEventBuffer (const AliRsnEventBuffer& buf) :
- TObject(buf), fDeleteBufferWhenReset(0),fEventsBufferSize(0),fEventsBufferIndex(0) {}
+ AliRsnEventBuffer(const AliRsnEventBuffer& buf) :
+ TObject(buf), fDeleteBufferWhenReset(0),fEventsBufferSize(0),fEventsBufferIndex(0) {}
const AliRsnEventBuffer& operator=(const AliRsnEventBuffer& /*buf*/) {return (*this);}
Bool_t fDeleteBufferWhenReset; // flag if buffer should be deleted when reset is done
Int_t fEventsBufferIndex; // current buffer index
AliRsnEvent *fEventsBuffer[10000]; // array of events
- ClassDef (AliRsnEventBuffer, 1)
+ ClassDef(AliRsnEventBuffer, 1)
};
#endif
#include "AliRsnCutSet.h"
#include "AliRsnExpression.h"
-ClassImp ( AliRsnExpression )
+ClassImp(AliRsnExpression)
AliRsnCutSet *AliRsnExpression::sCutSet = 0;
//______________________________________________________________________________
-AliRsnExpression::AliRsnExpression ( TString exp ) :
+AliRsnExpression::AliRsnExpression(TString exp) :
TObject(),
- fVname ( "" ),
- fArg1 ( 0x0 ),
- fArg2 ( 0x0 ),
- fOperator ( 0 )
+ fVname(""),
+ fArg1(0x0),
+ fArg2(0x0),
+ fOperator(0)
{
// Default constructor
- TObjArray* tokens = Tokenize ( exp );
+ TObjArray* tokens = Tokenize(exp);
Int_t i = -1;
- AliRsnExpression* e = Expression ( *tokens, i );
+ AliRsnExpression* e = Expression(*tokens, i);
// Copy !!!
fArg1 = e->fArg1; e->fArg1 = 0;
fArg2 = e->fArg2; e->fArg2 = 0;
//______________________________________________________________________________
AliRsnExpression::~AliRsnExpression()
{
- if ( fArg1 ) delete fArg1;
- if ( fArg2 ) delete fArg2;
+ if (fArg1) delete fArg1;
+ if (fArg2) delete fArg2;
}
-AliRsnExpression::AliRsnExpression ( const AliRsnExpression & exp ) : TObject ( exp ),
- fVname ( exp.fVname ),
- fArg1 ( exp.fArg1 ),
- fArg2 ( exp.fArg2 ),
- fOperator ( exp.fOperator )
+AliRsnExpression::AliRsnExpression(const AliRsnExpression & exp) : TObject(exp),
+ fVname(exp.fVname),
+ fArg1(exp.fArg1),
+ fArg2(exp.fArg2),
+ fOperator(exp.fOperator)
{}
//______________________________________________________________________________
-AliRsnExpression& AliRsnExpression::operator= ( const AliRsnExpression& e )
+AliRsnExpression& AliRsnExpression::operator= (const AliRsnExpression& e)
{
// AliRsnExpression assignment operator.
- if ( this != &e )
+ if (this != &e)
{
- TObject::operator= ( e );
+ TObject::operator= (e);
fArg1 = e.fArg1;
fArg2 = e.fArg2;
fOperator = e.fOperator;
}
//______________________________________________________________________________
-AliRsnExpression::AliRsnExpression ( int op, AliRsnExpression* a, AliRsnExpression* b ) :
+AliRsnExpression::AliRsnExpression(int op, AliRsnExpression* a, AliRsnExpression* b) :
TObject(),
- fVname ( "" ),
- fArg1 ( a ),
- fArg2 ( b ),
- fOperator ( op )
+ fVname(""),
+ fArg1(a),
+ fArg2(b),
+ fOperator(op)
{
// Create a new expression
}
//______________________________________________________________________________
-AliRsnExpression::AliRsnExpression ( int op, AliRsnExpression* a ) :
+AliRsnExpression::AliRsnExpression(int op, AliRsnExpression* a) :
TObject(),
- fVname ( "" ),
- fArg1 ( 0 ),
- fArg2 ( a ),
- fOperator ( op )
+ fVname(""),
+ fArg1(0),
+ fArg2(a),
+ fOperator(op)
{
// Create a unary expression.
}
//______________________________________________________________________________
-Bool_t AliRsnExpression::Value ( TObjArray &vars )
+Bool_t AliRsnExpression::Value(TObjArray &vars)
{
// Evaluate the expression
- if ( fArg2 == 0 && fVname.IsNull() )
+ if (fArg2 == 0 && fVname.IsNull())
{
- AliError ( "Expression undefined." );
+ AliError("Expression undefined.");
return kFALSE;
}
// AliDebug(AliLog::kDebug,Form("fOperator %d",fOperator));
- switch ( fOperator )
+ switch (fOperator)
{
case kOpOR :
- return fArg1->Value ( vars ) || fArg2->Value ( vars );
+ return fArg1->Value(vars) || fArg2->Value(vars);
case kOpAND :
- return fArg1->Value ( vars ) && fArg2->Value ( vars );
+ return fArg1->Value(vars) && fArg2->Value(vars);
case kOpNOT :
- return ! ( fArg2->Value ( vars ) );
+ return !(fArg2->Value(vars));
case 0 :
{
// Int_t indexx = sCutSet->GetIndexByCutName ( fVname.Data() );
AliDebug(AliLog::kDebug,Form("Vname %s",fVname.Data()));
// return sCutSet->GetBoolValue ( indexx );
- return sCutSet->GetBoolValue (fVname.Atoi());
+ return sCutSet->GetBoolValue(fVname.Atoi());
}
default:
- AliError ( "Illegal operator in expression!" );
+ AliError("Illegal operator in expression!");
}
return kFALSE;
// Unparse the expression
TString opVals[4] = { "", "&", "|","!" };
- if ( fArg2 == 0 && fVname.IsNull() )
+ if (fArg2 == 0 && fVname.IsNull())
{
- AliError ( "Expression undefined." );
+ AliError("Expression undefined.");
return "Error";
}
- if ( fArg2 == 0 && !fVname.IsNull() ) return fVname;
+ if (fArg2 == 0 && !fVname.IsNull()) return fVname;
- if ( fArg1 == 0 && fArg2 )
+ if (fArg1 == 0 && fArg2)
{
return opVals[fOperator]+fArg2->Unparse();
}
}
//______________________________________________________________________________
-TObjArray* AliRsnExpression::Tokenize ( TString str ) const
+TObjArray* AliRsnExpression::Tokenize(TString str) const
{
// tokenize the expression
// Remove spaces
TString str1;
- for ( Int_t i=0; i<str.Length(); i++ )
+ for (Int_t i=0; i<str.Length(); i++)
{
- if ( str[i] == ' ' ) continue;
- str1.Append ( str[i] );
+ if (str[i] == ' ') continue;
+ str1.Append(str[i]);
}
// get variable tokens
- TObjArray* valtok = str1.Tokenize ( "!&|()" );
+ TObjArray* valtok = str1.Tokenize("!&|()");
// put all variables together
Int_t nvt = valtok->GetEntriesFast();
TString sumval;
- for ( Int_t i=0; i<nvt; i++ )
+ for (Int_t i=0; i<nvt; i++)
{
- TObjString* val = ( TObjString* ) valtok->At ( i );
- sumval.Append ( val->String() );
+ TObjString* val = (TObjString*) valtok->At(i);
+ sumval.Append(val->String());
}
// get the operator tokens
- TObjArray* optok = str1.Tokenize ( sumval.Data() );
+ TObjArray* optok = str1.Tokenize(sumval.Data());
// put all operator in one string
TString operators;
Int_t nopt = optok->GetEntriesFast();
- for ( Int_t i=0; i<nopt; i++ )
+ for (Int_t i=0; i<nopt; i++)
{
- TObjString* val1 = ( TObjString* ) optok->At ( i );
- operators.Append ( val1->String() );
+ TObjString* val1 = (TObjString*) optok->At(i);
+ operators.Append(val1->String());
}
// add more room to be safe
- TObjString* blank = new TObjString ( " " );
- operators.Append ( " " );
- valtok->AddLast ( blank );
+ TObjString* blank = new TObjString(" ");
+ operators.Append(" ");
+ valtok->AddLast(blank);
// Now put var. and oper. together
- TObjArray* tokens = new TObjArray ( valtok->GetEntriesFast() + operators.Length() );
+ TObjArray* tokens = new TObjArray(valtok->GetEntriesFast() + operators.Length());
int io = 0,iv = 0;
int index = 0;
- while ( 1 )
+ while (1)
{
TString so = operators[io];
- int indexO = str1.Index ( so, index );
- TString val2 = ( ( TObjString* ) valtok->At ( iv ) )->String();
- int indexV = str1.Index ( val2, index );
- if ( ( indexO < indexV || indexV < 0 ) && indexO >=0 )
+ int indexO = str1.Index(so, index);
+ TString val2 = ((TObjString*) valtok->At(iv))->String();
+ int indexV = str1.Index(val2, index);
+ if ((indexO < indexV || indexV < 0) && indexO >=0)
{
- tokens->AddLast ( new TObjString ( so ) );
+ tokens->AddLast(new TObjString(so));
index += so.Length();
io++;
}
- if ( ( indexV < indexO || indexO < 0 ) && indexV >=0 )
+ if ((indexV < indexO || indexO < 0) && indexV >=0)
{
- tokens->AddLast ( new TObjString ( val2 ) );
+ tokens->AddLast(new TObjString(val2));
index += val2.Length();
iv++;
}
- if ( index >= str1.Length() ) break;
+ if (index >= str1.Length()) break;
}
// // Debug -> Print the tokens
//______________________________________________________________________________
-AliRsnExpression* AliRsnExpression::Element ( TObjArray &st, Int_t &i )
+AliRsnExpression* AliRsnExpression::Element(TObjArray &st, Int_t &i)
{
// create an element
TString token = "@";
TObjString* valt;
// next token
- if ( i < nt-1 )
+ if (i < nt-1)
{
i++;
- valt = ( TObjString* ) st.At ( i );
+ valt = (TObjString*) st.At(i);
token = valt->String();
}
// token type
- char ttok = ( token[0]!='|' && token[0]!='&' &&
- token[0]!='!' && token[0]!='('&& token[0]!=')' ) ? 'w' : token[0];
- switch ( ttok )
+ char ttok = (token[0]!='|' && token[0]!='&' &&
+ token[0]!='!' && token[0]!='('&& token[0]!=')') ? 'w' : token[0];
+ switch (ttok)
{
case 'w' :
{
- result = new AliRsnVariableExpression ( token );
+ result = new AliRsnVariableExpression(token);
break;
}
case '(' :
- result = Expression ( st, i );
+ result = Expression(st, i);
// next token
- if ( i < nt-1 )
+ if (i < nt-1)
{
i++;
- valt = ( TObjString* ) st.At ( i );
+ valt = (TObjString*) st.At(i);
token = valt->String();
}
- if ( token[0] != ')' )
+ if (token[0] != ')')
{
// i--; // push back
- AliErrorGeneral ( "AliRsnExpression::Element", "Mismatched parenthesis." );
+ AliErrorGeneral("AliRsnExpression::Element", "Mismatched parenthesis.");
delete result;
result = new AliRsnExpression;
}
break;
default:
i--; // push back
- AliErrorGeneral ( "AliRsnExpression::Element", Form ( "Unexpected symbol on input. %s", token.Data() ) );
- if ( result ) delete result;
+ AliErrorGeneral("AliRsnExpression::Element", Form("Unexpected symbol on input. %s", token.Data()));
+ if (result) delete result;
result = new AliRsnExpression;
}
return result;
}
//______________________________________________________________________________
-AliRsnExpression* AliRsnExpression::Primary ( TObjArray &st, Int_t &i )
+AliRsnExpression* AliRsnExpression::Primary(TObjArray &st, Int_t &i)
{
// create a primary
TString token = "@";
TObjString* valt;
// next token
- if ( i < nt-1 )
+ if (i < nt-1)
{
i++;
- valt = ( TObjString* ) st.At ( i );
+ valt = (TObjString*) st.At(i);
token = valt->String();
}
- switch ( token[0] )
+ switch (token[0])
{
case '!' :
- return new AliRsnExpression ( kOpNOT, Primary ( st, i ) );
+ return new AliRsnExpression(kOpNOT, Primary(st, i));
default:
i--; // push back
- return Element ( st, i );
+ return Element(st, i);
}
}
//______________________________________________________________________________
-AliRsnExpression* AliRsnExpression::Expression ( TObjArray &st,Int_t &i )
+AliRsnExpression* AliRsnExpression::Expression(TObjArray &st,Int_t &i)
{
// create an expression
stack++;
Int_t nt = st.GetEntriesFast();
- result = Primary ( st, i );
+ result = Primary(st, i);
// cout <<"i "<<i<< "Primary " << result->Unparse() << endl;
- while ( ! done )
+ while (! done)
{
// next token
- if ( i < nt-1 ) i++;
+ if (i < nt-1) i++;
else break;
- valt = ( TObjString* ) st.At ( i );
+ valt = (TObjString*) st.At(i);
token = valt->String();
- switch ( token[0] )
+ switch (token[0])
{
case '&' :
- result = new AliRsnExpression ( kOpAND, result, Primary ( st, i ) );
+ result = new AliRsnExpression(kOpAND, result, Primary(st, i));
// cout <<"i "<<i<< " Expression AND " << result->Unparse() << endl;
break;
case '|' :
- result = new AliRsnExpression ( kOpOR, result, Primary ( st, i ) );
+ result = new AliRsnExpression(kOpOR, result, Primary(st, i));
// cout <<"i "<<i<< " Expression OR " << result->Unparse() << endl;
break;
default:
}
}
stack--;
- if ( stack == 0 && !token.IsNull() && token[0] == ')' )
+ if (stack == 0 && !token.IsNull() && token[0] == ')')
{
- AliErrorGeneral ( "AliRsnExpression::Expression", "To many closing parenthesis." );
+ AliErrorGeneral("AliRsnExpression::Expression", "To many closing parenthesis.");
delete result;
result = new AliRsnExpression;
}
else
- if ( stack == 0 && i< nt-1 )
+ if (stack == 0 && i< nt-1)
{
- AliErrorGeneral ( "AliRsnExpression::Expression", Form ( "Unexpected symbol on input. %s", token.Data() ) );
+ AliErrorGeneral("AliRsnExpression::Expression", Form("Unexpected symbol on input. %s", token.Data()));
delete result;
result = new AliRsnExpression;
}
////////////////////////////////////////////////////////////////////////////////
-ClassImp ( AliRsnVariableExpression )
+ClassImp(AliRsnVariableExpression)
//______________________________________________________________________________
-Bool_t AliRsnVariableExpression::Value ( TObjArray& /*pgm*/)
+Bool_t AliRsnVariableExpression::Value(TObjArray& /*pgm*/)
{
// Int_t indexx = sCutSet->GetIndexByCutName ( fVname.Data() );
AliDebug(AliLog::kDebug,Form("Vname %s",fVname.Data()));
// return sCutSet->GetBoolValue ( indexx );
- return sCutSet->GetBoolValue ( fVname.Atoi() );
+ return sCutSet->GetBoolValue(fVname.Atoi());
}
{
public:
-
- // operators for complex cut expressions
+
+ // operators for complex cut expressions
enum ECutOp
{
- kOpAND=1, // AND '&'
- kOpOR, // OR '|'
- kOpNOT // Unary negation '!'
+ kOpAND=1, // AND '&'
+ kOpOR, // OR '|'
+ kOpNOT // Unary negation '!'
};
-
- AliRsnExpression() : fVname ( 0 ), fArg1 ( 0 ), fArg2 ( 0 ), fOperator ( 0 ) {}
- AliRsnExpression ( TString exp );
+
+ AliRsnExpression() : fVname(0), fArg1(0), fArg2(0), fOperator(0) {}
+ AliRsnExpression(TString exp);
virtual ~AliRsnExpression();
- AliRsnExpression ( const AliRsnExpression& exp );
- AliRsnExpression& operator= ( const AliRsnExpression& exp );
+ AliRsnExpression(const AliRsnExpression& exp);
+ AliRsnExpression& operator= (const AliRsnExpression& exp);
- virtual Bool_t Value ( TObjArray & vars );
+ virtual Bool_t Value(TObjArray & vars);
virtual TString Unparse() const;
- void SetCutSet ( AliRsnCutSet* theValue ) { sCutSet = theValue; }
+ void SetCutSet(AliRsnCutSet* theValue) { sCutSet = theValue; }
AliRsnCutSet* GetCutSet() const { return sCutSet; }
AliRsnExpression* fArg2; // right argument
Int_t fOperator; // operator
- AliRsnExpression ( int op, AliRsnExpression* a );
- AliRsnExpression ( int op, AliRsnExpression* a, AliRsnExpression* b );
+ AliRsnExpression(int op, AliRsnExpression* a);
+ AliRsnExpression(int op, AliRsnExpression* a, AliRsnExpression* b);
- TObjArray* Tokenize ( TString str ) const;
- static AliRsnExpression* Element ( TObjArray &st, Int_t &i );
- static AliRsnExpression* Primary ( TObjArray &st, Int_t &i );
- static AliRsnExpression* Expression ( TObjArray &st, Int_t &i );
+ TObjArray* Tokenize(TString str) const;
+ static AliRsnExpression* Element(TObjArray &st, Int_t &i);
+ static AliRsnExpression* Primary(TObjArray &st, Int_t &i);
+ static AliRsnExpression* Expression(TObjArray &st, Int_t &i);
- ClassDef ( AliRsnExpression, 1 ); // Class to evaluate an expression
+ ClassDef(AliRsnExpression, 1); // Class to evaluate an expression
};
class AliRsnVariableExpression: public AliRsnExpression
{
public:
- AliRsnVariableExpression ( TString a) : AliRsnExpression() { fVname = a; };
+ AliRsnVariableExpression(TString a) : AliRsnExpression() { fVname = a; };
~AliRsnVariableExpression() {}
- virtual Bool_t Value ( TObjArray& pgm );
+ virtual Bool_t Value(TObjArray& pgm);
virtual TString Unparse() const { return fVname; }
- ClassDef ( AliRsnVariableExpression, 1 ); // Class to define a variable expression
+ ClassDef(AliRsnVariableExpression, 1); // Class to define a variable expression
};
#endif
//
#include <TH1.h>
-#include <TH2.h>
#include "AliLog.h"
-
#include "AliRsnHistoDef.h"
ClassImp(AliRsnHistoDef)
//_____________________________________________________________________________
AliRsnHistoDef::AliRsnHistoDef() :
- fNDim(0)
+ fNBins(0),
+ fMin(0.0),
+ fMax(0.0)
{
//
// Default constructor
//_____________________________________________________________________________
AliRsnHistoDef::AliRsnHistoDef
(Int_t nbins, Double_t min, Double_t max) :
- fNDim(1)
+ fNBins(0),
+ fMin(0.0),
+ fMax(0.0)
{
//
// 1D histo definition.
//
-
SetBins(nbins, min, max);
}
-//_____________________________________________________________________________
-AliRsnHistoDef::AliRsnHistoDef
-(Int_t nbinsX, Double_t minX, Double_t maxX, Int_t nbinsY, Double_t minY, Double_t maxY):
- fNDim(2)
-{
-//
-// 1D histo definition.
-//
-
- SetBins(nbinsX, minX, maxX, nbinsY, minY, maxY);
-}
//_____________________________________________________________________________
void AliRsnHistoDef::SetBins(Int_t n, Double_t min, Double_t max)
{
//
-// Binning for 1D histograms.
-//
-
- fNDim = 1;
-
- fNBins[0] = n;
- fMin[0] = min;
- fMax[0] = max;
-
- CheckEdges();
-}
-
-//_____________________________________________________________________________
-void AliRsnHistoDef::SetBins
-(Int_t nx, Double_t minx, Double_t maxx, Int_t ny, Double_t miny, Double_t maxy)
-{
-//
-// Binning for 1D histograms.
+// Binning for histogram.
//
-
- fNDim = 2;
-
- fNBins[0] = nx;
- fMin[0] = minx;
- fMax[0] = maxx;
-
- fNBins[1] = ny;
- fMin[1] = miny;
- fMax[1] = maxy;
+ fNBins = n;
+ fMin = min;
+ fMax = max;
CheckEdges();
}
// otherwise swaps them.
//
- Int_t i;
- for (i = 0; i < fNDim; i++) {
- if (fMin[i] > fMax[i]) {
- AliWarning(Form("min = %f -- max = %f --> swapping", fMin, fMax));
- Double_t temp = fMin[i];
- fMin[i] = fMax[i];
- fMax[i] = temp;
- }
- }
-}
-
-//_____________________________________________________________________________
-TH1D* AliRsnHistoDef::Create1DHistogram(const char *name, const char *title)
-{
-//
-// Create 1D histogram, if the configuration is appropriate for this.
-//
-
- if (fNDim != 1) {
- AliError("Number of dimension not set to 1!");
- return 0x0;
+ if (fMin > fMax) {
+ AliWarning(Form("min = %f -- max = %f --> swapping", fMin, fMax));
+ Double_t temp = fMin;
+ fMin = fMax;
+ fMax = temp;
}
-
- TH1D *histo = new TH1D(name, title, fNBins[0], fMin[0], fMax[0]);
- return histo;
}
//_____________________________________________________________________________
-TH2D* AliRsnHistoDef::Create2DHistogram(const char *name, const char *title)
+TH1D* AliRsnHistoDef::CreateHistogram(const char *name, const char *title)
{
//
-// Create 2D histogram, if the configuration is appropriate for this.
+// Create a histogram with given name and title,
+// whose binning is specified according to this class members.
//
-
- if (fNDim != 2) {
- AliError("Number of dimension not set to 2!");
- return 0x0;
- }
-
- TH2D *histo = new TH2D(name, title, fNBins[0], fMin[0], fMax[0], fNBins[1], fMin[1], fMax[1]);
+ TH1D *histo = new TH1D(name, title, fNBins, fMin, fMax);
return histo;
}
//
// Class AliRsnHistoDef
//
-// Definition for a histogram type.
-// Since one could do an analysis which is not an invariant mass
-// the histogram definition should be more flexible, and it is stored
-// separately in a new class.
-// This class considers the possibility of a 1D or 2D histograms
-// with its related binning, and can create a new histo from his definitions
+// Histogram definition.
+// Contains required informations to create a histogram
+// with fixed bin size: number of bins, minimum and maximum.
+// Variable bin sizes are not considered because they are
+// not used as typical output of analysis in this package.
//
-#ifndef AliRsnHistoDef_H
-#define AliRsnHistoDef_H
+#ifndef ALIRSNHISTODEF_H
+#define ALIRSNHISTODEF_H
-class TH1;
class TH1D;
-class TH2D;
class AliRsnHistoDef : public TObject
{
-public:
+ public:
AliRsnHistoDef();
AliRsnHistoDef(Int_t n, Double_t min, Double_t max);
- AliRsnHistoDef(Int_t nX, Double_t minX, Double_t maxX, Int_t nY, Double_t minY, Double_t maxY);
virtual ~AliRsnHistoDef() { }
- Int_t GetNDimensions() const {return fNDim;}
- Int_t GetNBins(Int_t axis=0) const {return (axis==0)?fNBins[0]:fNBins[1];}
- Double_t GetMin(Int_t axis=0) const {return (axis==0)?fMin[0]:fMin[1];}
- Double_t GetMax(Int_t axis=0) const {return (axis==0)?fMax[0]:fMax[1];}
+ Int_t GetNBins() const {return fNBins;}
+ Double_t GetMin() const {return fMin;}
+ Double_t GetMax() const {return fMax;}
void SetBins(Int_t n, Double_t min, Double_t max);
- void SetBins(Int_t nX, Double_t minX, Double_t maxX, Int_t nY, Double_t minY, Double_t maxY);
+ TH1D* CreateHistogram(const char *name, const char *title);
+ void CheckEdges();
- TH1D* Create1DHistogram(const char *name, const char *title);
- TH2D* Create2DHistogram(const char *name, const char *title);
+ private:
-private:
+ Int_t fNBins; // number of bins
+ Double_t fMin; // lower edge
+ Double_t fMax; // upper edge
- void CheckEdges();
-
- Int_t fNDim; // number of dimensions
- Int_t fNBins[2]; // number of bins
- Double_t fMin[2]; // lower edge
- Double_t fMax[2]; // upper edge
-
// ROOT dictionary
ClassDef(AliRsnHistoDef, 1)
};
#include "AliRsnMCInfo.h"
-ClassImp ( AliRsnMCInfo )
+ClassImp(AliRsnMCInfo)
//_____________________________________________________________________________
AliRsnMCInfo::AliRsnMCInfo() : TObject(),
- fEnergy ( 0 ),
- fPDG ( 0 ),
- fMother ( -1 ),
- fMotherPDG ( 0 )
+ fEnergy(0),
+ fPDG(0),
+ fMother(-1),
+ fMotherPDG(0)
{
//
// Default constructor.
// Initializes all data-members with meaningless values.
//
- for ( Int_t i = 0; i < 3; i++ ) fP[i] = 0.0;
+ for (Int_t i = 0; i < 3; i++) fP[i] = 0.0;
}
//_____________________________________________________________________________
-AliRsnMCInfo::AliRsnMCInfo ( const AliRsnMCInfo & copy ) : TObject ( copy ),
- fEnergy ( copy.fEnergy ),
- fPDG ( copy.fPDG ),
- fMother ( copy.fMother ),
- fMotherPDG ( copy.fMotherPDG )
+AliRsnMCInfo::AliRsnMCInfo(const AliRsnMCInfo & copy) : TObject(copy),
+ fEnergy(copy.fEnergy),
+ fPDG(copy.fPDG),
+ fMother(copy.fMother),
+ fMotherPDG(copy.fMotherPDG)
{
//
// Copy constructor.
// Initializes all data-members with meaningless values.
//
-
- for ( Int_t i = 0; i < 3; i++ ) fP[i] = copy.fP[i];
-
+
+ for (Int_t i = 0; i < 3; i++) fP[i] = copy.fP[i];
+
}
//_____________________________________________________________________________
}
//_____________________________________________________________________________
-void AliRsnMCInfo::Adopt ( TParticle * particle )
+void AliRsnMCInfo::Adopt(TParticle * particle)
{
//
// Copies data from a TParticle into "this":
// is given by the method.
//
- if (!particle) {
- AliError ( "NULL argument passed. Nothing done." );
- return;
- }
-
- fP[0] = particle->Px();
- fP[1] = particle->Py();
- fP[2] = particle->Pz();
-
- fEnergy = particle->Energy();
-
- fPDG = particle->GetPdgCode();
- fMother = particle->GetFirstMother();
- fMotherPDG = ( Short_t ) 0;
+ if (!particle)
+ {
+ AliError("NULL argument passed. Nothing done.");
+ return;
+ }
+
+ fP[0] = particle->Px();
+ fP[1] = particle->Py();
+ fP[2] = particle->Pz();
+
+ fEnergy = particle->Energy();
+
+ fPDG = particle->GetPdgCode();
+ fMother = particle->GetFirstMother();
+ fMotherPDG = (Short_t) 0;
}
class AliRsnMCInfo : public TObject
{
-public:
+ public:
AliRsnMCInfo();
- AliRsnMCInfo ( const AliRsnMCInfo © );
+ AliRsnMCInfo(const AliRsnMCInfo ©);
~AliRsnMCInfo();
- void Adopt ( TParticle *part );
+ void Adopt(TParticle *part);
// 4-momentum
virtual Double_t E() const {return fEnergy;}
virtual Double_t E(Double_t mass) {return TMath::Sqrt(mass*mass + P2());}
- virtual Double_t M() const {return TMath::Sqrt (fEnergy*fEnergy - P2());}
+ virtual Double_t M() const {return TMath::Sqrt(fEnergy*fEnergy - P2());}
virtual Double_t P2() const {return Px()*Px() + Py()*Py() + Pz()*Pz();}
- virtual Double_t P() const {return TMath::Sqrt ( P2() );}
+ 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 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;}
- 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 SetE ( Double_t e ) {fEnergy = e;}
+ virtual Bool_t PxPyPz(Double_t p[3]) const {p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE;}
+
+ virtual Double_t Phi() const {return TMath::ATan2(Py(), Px());}
+ virtual Double_t Theta() const {return TMath::ATan2(Pt(), Pz());}
+ virtual Double_t Eta() const {return -TMath::Log(TMath::Tan(0.5*Theta()));}
+ virtual Double_t Y() const {return TMath::Log((E() + Pz()) / (E() - Pz()));}
+
+ 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 SetE(Double_t e) {fEnergy = e;}
Int_t PDG() const {return fPDG;}
Int_t Mother() const {return fMother;}
Short_t MotherPDG() const {return fMotherPDG;}
- void SetPDG ( Int_t pdg ) {fPDG = pdg;}
- void SetMother ( Int_t mlabel ) {fMother = mlabel;}
- void SetMotherPDG ( Int_t pdg ) {fMotherPDG = ( Short_t ) pdg;}
+ void SetPDG(Int_t pdg) {fPDG = pdg;}
+ void SetMother(Int_t mlabel) {fMother = mlabel;}
+ void SetMotherPDG(Int_t pdg) {fMotherPDG = (Short_t) pdg;}
-private:
+ private:
Double_t fP[3]; // MC momentum
Double_t fEnergy; // MC energy
Int_t fMother; // GEANT label of mother particle
Short_t fMotherPDG; // PDG code of mother particle
- ClassDef ( AliRsnMCInfo,1 );
+ ClassDef(AliRsnMCInfo,1)
};
#endif
#include "AliRsnPID.h"
-ClassImp(AliRsnPID)
+ClassImp ( AliRsnPID )
-const Double_t AliRsnPID::fgkParticleMass[AliRsnPID::kSpecies + 1] =
+ const Double_t AliRsnPID::fgkParticleMass[AliRsnPID::kSpeciesAll + 1] =
{
0.00051099892, // electron
0.105658369, // muon
0.13957018, // pion
0.493677, // kaon
0.93827203, // proton
- 0.0 // nothing
+ 0.0, // nothing
+ 1.019413, // phi
+ 3.09693 // jpsi
};
-const char* AliRsnPID::fgkParticleNameLong[AliRsnPID::kSpecies + 1] =
+const char* AliRsnPID::fgkParticleNameLong[AliRsnPID::kSpeciesAll + 1] =
{
"electron",
"muon",
"pion",
"kaon",
"proton",
- "unknown"
+ "unknown",
+ "phi",
+ "jpsi"
};
-const char* AliRsnPID::fgkParticleNameShort[AliRsnPID::kSpecies + 1] =
+const char* AliRsnPID::fgkParticleNameShort[AliRsnPID::kSpeciesAll + 1] =
{
"e",
"mu",
"pi",
"K",
"p",
- "unk"
+ "unk",
+ "phi",
+ "jpsi"
};
-const char* AliRsnPID::fgkParticleNameLatex[AliRsnPID::kSpecies + 1] =
+const char* AliRsnPID::fgkParticleNameLatex[AliRsnPID::kSpeciesAll + 1] =
{
"e",
"#mu",
"#pi",
"K",
"p",
- "?"
+ "?",
+ "#phi",
+ "J/#psi"
};
-const Int_t AliRsnPID::fgkParticlePDG[AliRsnPID::kSpecies + 1] =
+const Int_t AliRsnPID::fgkParticlePDG[AliRsnPID::kSpeciesAll + 1] =
{
- 11,
- 13,
- 211,
- 321,
- 2212,
- 0
+ 11,
+ 13,
+ 211,
+ 321,
+ 2212,
+ 0,
+ 333,
+ 443
};
//_____________________________________________________________________________
AliRsnPID::AliRsnPID() :
- TNamed("RsnPID", ""),
- fMaxPt(100.0),
- fMinProb(0.0)
+ TNamed ( "RsnPID", "" ),
+ fMaxPt ( 100.0 ),
+ fMinProb ( 0.0 )
{
//
// Constructor.
// Adds also the object in the default directory of the session.
//
- Int_t i;
- for (i = 0; i < kSpecies; i++) fPrior[i] = 0.0;
-
- gDirectory->Append(this, kTRUE);
+ Int_t i;
+ for ( i = 0; i < kSpecies; i++ ) fPrior[i] = 0.0;
+
+// gDirectory->Append(this, kTRUE);
}
//_____________________________________________________________________________
-AliRsnPID::EType AliRsnPID::InternalType(Int_t pdg)
+AliRsnPID::EType AliRsnPID::InternalType ( Int_t pdg )
//
// Return the internal enum value corresponding to the PDG
// code passed as argument, if possible.
// Otherwise, returns 'kUnknown' by default.
//
{
- EType value;
- Int_t absPDG = TMath::Abs(pdg);
-
- switch (absPDG) {
- case 11:
- value = kElectron;
- break;
- case 13:
- value = kMuon;
- break;
- case 211:
- value = kPion;
- break;
- case 321:
- value = kKaon;
- break;
- case 2212:
- value = kProton;
- break;
- default:
- value = kUnknown;
- }
- return value;
+ EType value;
+ Int_t absPDG = TMath::Abs ( pdg );
+
+ switch ( absPDG )
+ {
+ case 11:
+ value = kElectron;
+ break;
+ case 13:
+ value = kMuon;
+ break;
+ case 211:
+ value = kPion;
+ break;
+ case 321:
+ value = kKaon;
+ break;
+ case 2212:
+ value = kProton;
+ break;
+ case 333:
+ value = kPhi;
+ break;
+ case 443:
+ value = kJPsi;
+ break;
+ default:
+ value = kUnknown;
+ }
+ return value;
}
//_____________________________________________________________________________
-Int_t AliRsnPID::PDGCode(EType type)
+Int_t AliRsnPID::PDGCode ( EType type )
{
//
// Returns the PDG code of the particle type
// specified as argument (w.r. to the internal enum)
//
- if (type >= kElectron && type <= kUnknown) {
- return fgkParticlePDG[type];
- }
- else {
- return 0;
- }
+ if ( type >= kElectron && type <= kUnknown )
+ {
+ return fgkParticlePDG[type];
+ }
+ else
+ {
+ return 0;
+ }
}
//_____________________________________________________________________________
-const char* AliRsnPID::ParticleName(EType type, Bool_t shortName)
+const char* AliRsnPID::ParticleName ( EType type, Bool_t shortName )
{
//
// Returns the name of the particle type
// specified as argument (w.r. to the internal enum)
//
- if (type >= kElectron && type <= kUnknown) {
- return shortName ? fgkParticleNameShort[type] : fgkParticleNameLong[type];
- }
- else {
- return shortName ? "unk" : "unknown";
- }
+ if ( type >= kElectron && type <= kSpeciesAll )
+ {
+ return shortName ? fgkParticleNameShort[type] : fgkParticleNameLong[type];
+ }
+ else
+ {
+ return shortName ? "unk" : "unknown";
+ }
}
//_____________________________________________________________________________
-const char* AliRsnPID::ParticleNameLatex(EType type)
+const char* AliRsnPID::ParticleNameLatex ( EType type )
{
//
// Returns the name of the particle type
// specified as argument (w.r. to the internal enum)
//
- if (type >= kElectron && type <= kUnknown) {
- return fgkParticleNameLatex[type];
- }
- else {
- return "?";
- }
+ if ( type >= kElectron && type <= kSpeciesAll )
+ {
+ return fgkParticleNameLatex[type];
+ }
+ else
+ {
+ return "?";
+ }
}
//_____________________________________________________________________________
-Double_t AliRsnPID::ParticleMass(EType type)
+Double_t AliRsnPID::ParticleMass ( EType type )
{
//
// Returns the mass corresponding to the particle type
// specified as argument (w.r. to the internal enum)
//
- /*
- TDatabasePDG *db = TDatabasePDG::Instance();
- Int_t pdg = PDGCode(type);
- return db->GetParticle(pdg)->Mass();
- */
- if (type >= kElectron && type < kSpecies) return fgkParticleMass[type];
- return 0.0;
+ /*
+ TDatabasePDG *db = TDatabasePDG::Instance();
+ Int_t pdg = PDGCode(type);
+ return db->GetParticle(pdg)->Mass();
+ */
+ if ( type >= kElectron && type < kSpeciesAll ) return fgkParticleMass[type];
+ return 0.0;
}
//_____________________________________________________________________________
-Bool_t AliRsnPID::ComputeProbs(AliRsnDaughter *daughter)
+Bool_t AliRsnPID::ComputeProbs ( AliRsnDaughter *daughter )
{
//
// Uses the Bayesian combination of prior probabilities
// the return value will be "FALSE", otherwise it is "TRUE".
//
- // reset all PID probabilities to 0.0
- Int_t i;
- for (i = 0; i < kSpecies; i++) daughter->SetPIDProb(i, 1.0 / (Double_t)kSpecies);
-
- // multiply weights and priors
- Double_t sum = 0.0, prob[kSpecies];
- for (i = 0; i < kSpecies; i++) {
- prob[i] = fPrior[i] * daughter->PID()[i];
- sum += prob[i];
- }
- if (sum <= (Double_t)0.) {
- AliError(Form("Sum of weights = %f <= 0", sum));
- return kFALSE;
- }
-
- // normalize
- for (i = 0; i < kSpecies; i++) {
- prob[i] /= sum;
- daughter->SetPIDProb(i, prob[i]);
- }
-
- return kTRUE;
+ // reset all PID probabilities to 0.0
+ Int_t i;
+ for ( i = 0; i < kSpecies; i++ ) daughter->SetPIDProb ( i, 1.0 / ( Double_t ) kSpecies );
+
+ // multiply weights and priors
+ Double_t sum = 0.0, prob[kSpecies];
+ for ( i = 0; i < kSpecies; i++ )
+ {
+ prob[i] = fPrior[i] * daughter->PID() [i];
+ sum += prob[i];
+ }
+ if ( sum <= ( Double_t ) 0. )
+ {
+ AliError ( Form ( "Sum of weights = %f <= 0", sum ) );
+ return kFALSE;
+ }
+
+ // normalize
+ for ( i = 0; i < kSpecies; i++ )
+ {
+ prob[i] /= sum;
+ daughter->SetPIDProb ( i, prob[i] );
+ }
+
+ daughter->AssignRealisticPID();
+ Double_t assprob;
+ AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic);
+ AliRsnPID::EType type = daughter->PIDType(assprob);
+ AliDebug(5, Form("Assigned PID: %s [%.2f %]", AliRsnPID::ParticleName(type), assprob*100.));
+
+ return kTRUE;
}
//_____________________________________________________________________________
-Bool_t AliRsnPID::IdentifiedAs(AliRsnDaughter *d, EType type, Short_t charge)
+Bool_t AliRsnPID::IdentifiedAs ( AliRsnDaughter *d, EType type, Short_t charge )
{
//
// Tells if a particle has can be identified to be of a given tipe and charge.
// is kFALSE even when the type and charge are matched.
//
- EType dType = TrackType(d);
- if (dType != type) return kFALSE;
- if (charge == 0) {
- return kTRUE;
- }
- else if (charge > 0) {
- return (d->Charge() > 0);
- }
- else {
- return (d->Charge() < 0);
- }
+ EType dType = TrackType ( d );
+ if ( dType != type ) return kFALSE;
+ if ( charge == 0 )
+ {
+ return kTRUE;
+ }
+ else if ( charge > 0 )
+ {
+ return ( d->Charge() > 0 );
+ }
+ else
+ {
+ return ( d->Charge() < 0 );
+ }
}
//_____________________________________________________________________________
-AliRsnPID::EType AliRsnPID::TrackType(AliRsnDaughter *d)
+AliRsnPID::EType AliRsnPID::TrackType ( AliRsnDaughter *d )
{
//
// Returns the track type according to the object settings
// and to the static settings in the AliRsnDaughter object.
//
- Double_t prob;
- EType type = d->PIDType(prob);
-
- if (d->Pt() > fMaxPt) return kUnknown;
- if (prob < fMinProb) return kUnknown;
-
- return type;
+ Double_t prob;
+ EType type = d->PIDType ( prob );
+
+ if ( d->Pt() > fMaxPt ) return kUnknown;
+ if ( prob < fMinProb ) return kUnknown;
+
+ return type;
}
//_____________________________________________________________________________
-Bool_t AliRsnPID::Process(AliRsnEvent *event)
+Bool_t AliRsnPID::Process ( AliRsnEvent *event )
{
//
// Performs identification for all tracks in a given event.
// Returns the logical AND of all PID operations.
//
- Bool_t check = kTRUE;
- if (!event) return check;
- if (!event->GetTracks()) return check;
- if (event->GetTracks()->IsEmpty()) return check;
+ Bool_t check = kTRUE;
+ if ( !event ) return check;
+ if ( !event->GetTracks() ) return check;
+ if ( event->GetTracks()->IsEmpty() ) return check;
- AliRsnDaughter *daughter = 0;
- TObjArrayIter iter(event->GetTracks());
- while ( (daughter = (AliRsnDaughter*)iter.Next()) ) {
- check = check && ComputeProbs(daughter);
- }
- event->FillPIDArrays();
+ AliRsnDaughter *daughter = 0;
+ TObjArrayIter iter ( event->GetTracks() );
+ while ( ( daughter = ( AliRsnDaughter* ) iter.Next() ) )
+ {
+ check = check && ComputeProbs ( daughter );
+ }
+ event->FillPIDArrays();
- return check;
+ return check;
}
//_____________________________________________________________________________
-void AliRsnPID::SetPriorProbability(EType type, Double_t p)
+void AliRsnPID::SetPriorProbability ( EType type, Double_t p )
{
//
// Sets the prior probability for Realistic PID, for a
// given particle species.
//
- if (type >= kElectron && type < kSpecies) {
- fPrior[type] = p;
- }
+ if ( type >= kElectron && type < kSpecies )
+ {
+ fPrior[type] = p;
+ }
}
//_____________________________________________________________________________
// Print all prior probabilities
//
- Int_t i;
- Char_t msg[200];
-
- for (i = 0; i < kSpecies; i++) {
- sprintf(msg, "Prior probability for '%s' = %3.5f", fgkParticleNameLong[i], fPrior[i]);
- AliInfo(msg);
- }
+ Int_t i;
+ Char_t msg[200];
+
+ for ( i = 0; i < kSpecies; i++ )
+ {
+ sprintf ( msg, "Prior probability for '%s' = %3.5f", fgkParticleNameLong[i], fPrior[i] );
+ AliInfo ( msg );
+ }
}
class AliRsnPID : public TNamed
{
-public:
+ public:
// types enum
- enum EType {
- kElectron = 0,
- kMuon,
- kPion,
- kKaon,
- kProton,
- kUnknown,
- kSpecies = 5
+ enum EType
+ {
+ kElectron = 0,
+ kMuon,
+ kPion,
+ kKaon,
+ kProton,
+ kUnknown,
+ kSpecies = 5,
+ kPhi=6,
+ kJPsi,
+ kSpeciesAll = 8
};
AliRsnPID();
// conversions from PDG code to local type
static EType InternalType(Int_t pdgCode);
-
+
// retrieve particle informations from internal type
static Int_t PDGCode(EType pid);
static const char* ParticleName(EType pid, Bool_t shortName = kTRUE);
// other
void DumpPriors();
-private:
+ private:
Double_t fPrior[kSpecies]; // prior probabilities
Double_t fMaxPt; // pt threshold for realistic PID
Double_t fMinProb; // threshold on acceptable largest probability
- static const Double_t fgkParticleMass[kSpecies + 1]; // PDG particle mass
- static const char* fgkParticleNameShort[kSpecies + 1]; // short particle name
- static const char* fgkParticleNameLong[kSpecies + 1]; // long particle name
- static const char* fgkParticleNameLatex[kSpecies + 1]; // latex particle name
- static const Int_t fgkParticlePDG[kSpecies + 1]; // PDG code of particle
+ static const Double_t fgkParticleMass[kSpeciesAll + 1]; // PDG particle mass
+ static const char* fgkParticleNameShort[kSpeciesAll + 1]; // short particle name
+ static const char* fgkParticleNameLong[kSpeciesAll + 1]; // long particle name
+ static const char* fgkParticleNameLatex[kSpeciesAll + 1]; // latex particle name
+ static const Int_t fgkParticlePDG[kSpeciesAll + 1]; // PDG code of particle
ClassDef(AliRsnPID,1);
};
#include "AliRsnPIDIndex.h"
-ClassImp (AliRsnPIDIndex)
+ClassImp(AliRsnPIDIndex)
//_____________________________________________________________________________
-AliRsnPIDIndex::AliRsnPIDIndex (Int_t num)
+AliRsnPIDIndex::AliRsnPIDIndex(Int_t num)
{
//
// 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;
+ 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);
}
+ }
}
//_____________________________________________________________________________
-AliRsnPIDIndex::AliRsnPIDIndex (const AliRsnPIDIndex & copy)
- : TObject (copy)
+AliRsnPIDIndex::AliRsnPIDIndex(const AliRsnPIDIndex & copy)
+ : TObject(copy)
{
//
// Copy constructor.
// 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 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);
+ }
}
+ }
}
//_____________________________________________________________________________
// 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 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);
+ }
}
+ }
- // return this object
- return (*this);
+ // return this object
+ return (*this);
}
AliRsnPIDIndex::~AliRsnPIDIndex()
}
//_____________________________________________________________________________
-void AliRsnPIDIndex::Print (Option_t* /*option*/) const
+void AliRsnPIDIndex::Print(Option_t* /*option*/) const
{
//
// Prints AliRsnPIDIndex info
//
- 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;
+ 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]));
}
+ }
}
//_____________________________________________________________________________
-void AliRsnPIDIndex::AddIndex (const Int_t index, Char_t sign, AliRsnPID::EType type)
+void AliRsnPIDIndex::AddIndex(const Int_t index, Char_t sign, AliRsnPID::EType type)
{
//
// Adds index to corresponding TArrayI
//
- Int_t iCharge = ChargeIndex(sign);
- Int_t iType = (Int_t)type;
- fIndex[iCharge][iType].AddAt(index, fNumOfIndex[iCharge][iType]);
- fNumOfIndex[iCharge][iType]++;
+ Int_t iCharge = ChargeIndex(sign);
+ Int_t iType = (Int_t)type;
+ fIndex[iCharge][iType].AddAt(index, fNumOfIndex[iCharge][iType]);
+ fNumOfIndex[iCharge][iType]++;
}
//_____________________________________________________________________________
// Adds index to corresponding TArrayI
//
- fIndex[sign][type].AddAt (index, fNumOfIndex[sign][type]);
- fNumOfIndex[sign][type]++;
+ fIndex[sign][type].AddAt(index, fNumOfIndex[sign][type]);
+ fNumOfIndex[sign][type]++;
}
//_____________________________________________________________________________
// 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;
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < AliRsnPID::kSpecies + 1; j++)
+ {
+ fIndex[i][j].Set(fNumOfIndex[i][j]);
}
+ }
}
//_____________________________________________________________________________
-TArrayI* AliRsnPIDIndex::GetTracksArray (Char_t sign, AliRsnPID::EType type)
+TArrayI* AliRsnPIDIndex::GetTracksArray(Char_t sign, AliRsnPID::EType type)
{
//
// Returns the array of indexes of tracks whose charge
// Otherwise returns null pointer.
//
- Int_t icharge = ChargeIndex (sign);
- if (icharge < 0) return (TArrayI *) 0x0;
- if (type < AliRsnPID::kElectron || type > AliRsnPID::kSpecies) {
- AliError (Form ("Index %d out of range", type));
- return (TArrayI *) 0x0;
- }
+ Int_t icharge = ChargeIndex(sign);
+ if (icharge < 0) return (TArrayI *) 0x0;
+ if (type < AliRsnPID::kElectron || type > AliRsnPID::kSpecies)
+ {
+ AliError(Form("Index %d out of range", type));
+ return (TArrayI *) 0x0;
+ }
- return &fIndex[icharge][type];
+ return &fIndex[icharge][type];
}
//_____________________________________________________________________________
-TArrayI* AliRsnPIDIndex::GetCharged (Char_t sign)
+TArrayI* AliRsnPIDIndex::GetCharged(Char_t sign)
{
//
// Returns the array of indexes of tracks whose charge
// Otherwise returns a null pointer.
//
- // check that argument is meaningful
- Int_t icharge = ChargeIndex (sign);
- if (icharge < 0) return (TArrayI *)0x0;
+ // 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);
+ // 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++);
- }
+ // 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;
+ return output;
}
//_____________________________________________________________________________
-Int_t AliRsnPIDIndex::ChargeIndex (Char_t sign) const
+Int_t AliRsnPIDIndex::ChargeIndex(Char_t sign) const
{
//
// Returns the array index corresponding to charge
//
- if (sign == '+') return 0;
- else if (sign == '-') return 1;
- else {
- AliError (Form ("Character '%c' not recognized as charge sign", sign));
- return -1;
- }
+ if (sign == '+') return 0;
+ else if (sign == '-') return 1;
+ else
+ {
+ AliError(Form("Character '%c' not recognized as charge sign", sign));
+ return -1;
+ }
}
class AliRsnPIDIndex : public TObject
{
-public:
+ public:
- AliRsnPIDIndex (Int_t num = 1000);
- AliRsnPIDIndex (const AliRsnPIDIndex ©);
+ AliRsnPIDIndex(Int_t num = 2000);
+ AliRsnPIDIndex(const AliRsnPIDIndex ©);
AliRsnPIDIndex& operator= (const AliRsnPIDIndex& copy);
virtual ~AliRsnPIDIndex();
void AddIndex(const Int_t index, Short_t sign, Int_t type);
void SetCorrectIndexSize();
- TArrayI* GetTracksArray (Char_t sign, AliRsnPID::EType type);
- TArrayI* GetCharged (Char_t sign);
+ TArrayI* GetTracksArray(Char_t sign, AliRsnPID::EType type);
+ TArrayI* GetCharged(Char_t sign);
-private:
+ private:
- Int_t ChargeIndex (Char_t sign) const;
+ Int_t ChargeIndex(Char_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
- ClassDef (AliRsnPIDIndex, 1);
+ ClassDef(AliRsnPIDIndex, 1);
};
#endif
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-
+
//-------------------------------------------------------------------------
// Class AliRsnPIDWeightsMgr
// -------------------
// selected from an ESD event
// to be used for analysis.
// .........................................
-//
+//
// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
//-------------------------------------------------------------------------
ClassImp(AliRsnPIDWeightsMgr)
//_____________________________________________________________________________
-AliRsnPIDWeightsMgr::AliRsnPIDWeightsMgr()
+AliRsnPIDWeightsMgr::AliRsnPIDWeightsMgr()
{
//
// Default and unique constructor which initializes arrays
//
- Int_t i, j;
- for (i = 0; i < kDetectors; i++) {
- for (j = 0; j < AliRsnPID::kSpecies; j++) fWeights[i][j] = 0.0;
- fDetPtMin[i] = 0.0;
- fDetPtMax[i] = 1E25;
- fUseDet[i] = kTRUE;
- }
+ Int_t i, j;
+ for (i = 0; i < kDetectors; i++)
+ {
+ for (j = 0; j < AliRsnPID::kSpecies; j++) fWeights[i][j] = 0.0;
+ fDetPtMin[i] = 0.0;
+ fDetPtMax[i] = 1E25;
+ fUseDet[i] = kTRUE;
+ }
}
//_____________________________________________________________________________
// Copy into the array the PID weights of a detector
//
- Int_t i;
- if (!CheckBounds(det)) return;
- for (i = 0; i < AliRsnPID::kSpecies; i++) fWeights[det][i] = weights[i];
+ Int_t i;
+ if (!CheckBounds(det)) return;
+ for (i = 0; i < AliRsnPID::kSpecies; i++) fWeights[det][i] = weights[i];
}
//_____________________________________________________________________________
// did not accept to use the global ESD pid.
//
- if (!CheckBounds(det)) return;
-
- // swap values if necessary
- if (ptmin > ptmax) {
- AliWarning("Values passed in wrong order. Swapping");
- Double_t temp = ptmin;
- ptmin = ptmax;
- ptmax = temp;
- }
- fDetPtMin[det] = ptmin;
- fDetPtMax[det] = ptmax;
+ if (!CheckBounds(det)) return;
+
+ // swap values if necessary
+ if (ptmin > ptmax)
+ {
+ AliWarning("Values passed in wrong order. Swapping");
+ Double_t temp = ptmin;
+ ptmin = ptmax;
+ ptmax = temp;
+ }
+ fDetPtMin[det] = ptmin;
+ fDetPtMax[det] = ptmax;
}
//_____________________________________________________________________________
// Computes the global PID weights using the given ranges
//
- if (type < 0 or type >= AliRsnPID::kSpecies) {
- AliError("Index out of range");
- return kFALSE;
- }
-
- Int_t i;
- Double_t prob = 1.0;
- for (i = 0; i < kDetectors; i++) {
- //AliInfo(Form("weights[%d] = %f %f %f %f %f", i, fWeights[i][0], fWeights[i][1], fWeights[i][2], fWeights[i][3], fWeights[i][4], fWeights[i][5]));
- if (!fUseDet[i]) continue;
- if (pt < fDetPtMin[i] || pt > fDetPtMax[i]) continue;
- prob *= fWeights[i][type];
- }
-
- return prob;
+ if (type < 0 or type >= AliRsnPID::kSpecies)
+ {
+ AliError("Index out of range");
+ return kFALSE;
+ }
+
+ Int_t i;
+ Double_t prob = 1.0;
+ for (i = 0; i < kDetectors; i++)
+ {
+ //AliInfo(Form("weights[%d] = %f %f %f %f %f", i, fWeights[i][0], fWeights[i][1], fWeights[i][2], fWeights[i][3], fWeights[i][4], fWeights[i][5]));
+ if (!fUseDet[i]) continue;
+ if (pt < fDetPtMin[i] || pt > fDetPtMax[i]) continue;
+ prob *= fWeights[i][type];
+ }
+
+ return prob;
}
//_____________________________________________________________________________
//
// Bounds checker
//
-
- if (det < 0 or det >= kDetectors) {
- AliError("Index out of range");
- return kFALSE;
- }
-
- return kTRUE;
+
+ if (det < 0 or det >= kDetectors)
+ {
+ AliError("Index out of range");
+ return kFALSE;
+ }
+
+ return kTRUE;
}
//-------------------------------------------------------------------------
// Class AliRsnPIDWeightsMgr
// Simple collection of reconstructed tracks, selected from an ESD event
-//
+//
// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
//-------------------------------------------------------------------------
class AliRsnPIDWeightsMgr : public TObject
{
-public:
+ public:
// detectors for customizing PID weights
- enum EDetector {
- kITS,
- kTPC,
- kTRD,
- kTOF,
- kHMPID,
- kDetectors
+ enum EDetector
+ {
+ kITS,
+ kTPC,
+ kTRD,
+ kTOF,
+ kHMPID,
+ kDetectors
};
-
+
AliRsnPIDWeightsMgr();
virtual ~AliRsnPIDWeightsMgr() {}
-
+
void UseDetector(EDetector det, Bool_t use) {if (CheckBounds(det)) fUseDet[det] = use;}
void SetDetectorWeights(EDetector det, Double_t *weights);
void SetAcceptanceRange(EDetector det, Double_t ptmin, Double_t ptmax);
Double_t GetWeight(AliRsnPID::EType type, Double_t pt);
Double_t* GetWeightArray(EDetector det) {if (CheckBounds(det)) return fWeights[det]; else return 0x0;}
-
-private:
+
+ private:
Bool_t CheckBounds(EDetector det);
--- /dev/null
+//
+// *** Class AliRsnPair ***
+//
+// "Core" method for defining the work on a pari of particles.
+// For one analysis, one must setup one of this for each pair he wants to analyze,
+// adding to it all analysis which he desires to do.
+// Here he defines the cuts, and the particle types and charges, and can add
+// functions which do different operations on the same pair, and some binning
+// with respect to some kinematic variables (eta, momentum)
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
+
+#include "TObjArray.h"
+
+#include "AliLog.h"
+
+#include "AliRsnFunction.h"
+#include "AliRsnPairParticle.h"
+
+#include "AliRsnPair.h"
+
+ClassImp(AliRsnPair)
+
+//_____________________________________________________________________________
+AliRsnPair::AliRsnPair
+(EPairType type, AliRsnPairDef *def, Int_t mixNum) :
+ TObject(),
+ fIsMixed(kFALSE),
+ fUseMC(kFALSE),
+ fIsLikeSign(kFALSE),
+ fMixNum(mixNum),
+ fPairDef(def),
+ fPairType(type),
+ fTypePID(AliRsnDaughter::kRealistic),
+ fCutMgr(0),
+ fFunctions("AliRsnFunction", 0)
+{
+//
+// Default constructor
+//
+
+ SetUp(type);
+}
+//_____________________________________________________________________________
+AliRsnPair::~AliRsnPair()
+{
+//
+// Destructor
+//
+}
+
+//_____________________________________________________________________________
+void AliRsnPair::SetUp(EPairType type)
+{
+//
+// Sets up flag values by the pair types
+//
+
+ switch (type)
+ {
+ case kNoPID:
+ SetAllFlags(AliRsnDaughter::kNoPID, kFALSE, kFALSE);
+ break;
+ case kNoPIDMix:
+ SetAllFlags(AliRsnDaughter::kNoPID, kTRUE, kFALSE);
+ break;
+ case kRealisticPID:
+ SetAllFlags(AliRsnDaughter::kRealistic, kFALSE, kFALSE);
+ break;
+ case kRealisticPIDMix:
+ SetAllFlags(AliRsnDaughter::kRealistic, kTRUE, kFALSE);
+ break;
+ case kPerfectPID:
+ // SetAllFlags (AliRsnDaughter::kPerfect, kFALSE, kFALSE);
+ SetAllFlags(AliRsnDaughter::kPerfect, kFALSE, kTRUE);
+ break;
+ case kPerfectPIDMix:
+ // SetAllFlags (AliRsnDaughter::kPerfect, kTRUE, kFALSE);
+ SetAllFlags(AliRsnDaughter::kPerfect, kTRUE, kTRUE);
+ break;
+ default :
+ AliWarning("Wrong type selected: setting up for kRealisticPID.");
+ SetAllFlags(AliRsnDaughter::kRealistic, kFALSE, kFALSE);
+ break;
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnPair::SetAllFlags(AliRsnDaughter::EPIDMethod pidType, Bool_t isMix, Bool_t useMC)
+{
+//
+// Sets up all flags values
+//
+
+ fTypePID = pidType;
+ fIsMixed = isMix;
+ fUseMC = useMC;
+}
+
+//_____________________________________________________________________________
+void AliRsnPair::Init()
+{
+//
+// Init pair
+//
+
+ fIsLikeSign = fPairDef->IsLikeSign();
+ Print();
+}
+
+//_____________________________________________________________________________
+void AliRsnPair::Print()
+{
+//
+// Prints info about pair
+//
+ AliInfo(Form("%s", GetPairHistTitle(0x0).Data()));
+ AliInfo(Form("PDG %d %d", AliRsnPID::PDGCode(fPairDef->GetType(0)),
+ AliRsnPID::PDGCode(fPairDef->GetType(1))));
+ AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1)));
+ AliInfo(Form("Number of functions %d", fFunctions.GetEntries()));
+ switch(fTypePID) {
+ case AliRsnDaughter::kNoPID:
+ AliInfo("PID method: none");
+ break;
+ case AliRsnDaughter::kRealistic:
+ AliInfo("PID method: realistic");
+ break;
+ case AliRsnDaughter::kPerfect:
+ AliInfo("PID method: perfect");
+ break;
+ default:
+ AliInfo("PID method: undefined");
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnPair::ProcessPair(AliRsnEventBuffer *buf)
+{
+//
+// Process one event in this pair
+//
+
+ AliRsnEvent *e1 = buf->GetCurrentEvent();
+ if (!e1) return;
+ if (e1->GetMultiplicity() < 1) return;
+ TArrayI* array1 = e1->GetTracksArray(fTypePID, fPairDef->GetCharge(0), fPairDef->GetType(0));
+
+ Int_t i = 0;
+ Int_t numMixed = 0;
+ Int_t lastOkEvent = 1;
+ TArrayI* array2 = 0;
+ for (i = 0; i < fMixNum; i++)
+ {
+ // find other event by event cut
+ AliRsnEvent *e2 = FindEventByEventCut(buf, lastOkEvent);
+ if (!e2) return;
+ if (e2->GetMultiplicity() < 1) return;
+ array2 = e2->GetTracksArray(fTypePID, fPairDef->GetCharge(1), fPairDef->GetType(1));
+ LoopPair(e1, array1, e2, array2);
+ numMixed++;
+ }
+// if (fIsMixed) AliInfo (Form ("NumMixed = %d",numMixed));
+}
+
+//_____________________________________________________________________________
+AliRsnEvent * AliRsnPair::FindEventByEventCut(AliRsnEventBuffer *buf, Int_t& num)
+{
+//
+// For now it just returns num events before current event
+// in buffer (buf)
+// TODO event cut selection
+//
+
+ AliRsnEvent *returnEvent = 0x0;
+
+ if (fIsMixed)
+ {
+ returnEvent = buf->GetEvent(buf->GetEventsBufferIndex() - num);
+ }
+ else
+ {
+ returnEvent = buf->GetCurrentEvent();
+ }
+
+ return returnEvent;
+}
+
+//_____________________________________________________________________________
+void AliRsnPair::LoopPair
+(AliRsnEvent * ev1, TArrayI * a1, AliRsnEvent * ev2, TArrayI * a2)
+{
+//
+// Loop on all pairs of tracks of the defined types/charges,
+// using the arrays of indexes and the events containing them.
+//
+
+ if (!a1) {AliError("No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;}
+ if (!a2) {AliError("No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;}
+
+ AliRsnDaughter::SetPIDMethod(fTypePID);
+ AliRsnDaughter *daughter1 = 0;
+ AliRsnDaughter *daughter2 = 0;
+ AliRsnFunction *fcn = 0;
+ 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;
+ // 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 (fIsLikeSign) 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;
+ // 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);
+ }
+ }
+ }
+}
+
+//_____________________________________________________________________________
+TList * AliRsnPair::GenerateHistograms(TString prefix)
+{
+//
+// Generates needed histograms
+//
+
+ TList *list = new TList();
+ list->SetName(GetPairHistName(0x0).Data());
+
+ 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());
+ TList *histos = fcn->Init(hName, hTitle);
+ histos->Print();
+ list->Add(histos);
+ }
+
+ return list;
+}
+
+//_____________________________________________________________________________
+void AliRsnPair::GenerateHistograms(TString prefix, TList *tgt)
+{
+//
+// Generates needed histograms
+//
+
+ 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)
+{
+//
+// Returns type name, made with particle names ant chosen PID
+//
+ switch (type)
+ {
+ case kNoPID : return ("NOPID_");break;
+ case kNoPIDMix : return ("NOPIDMIX_");break;
+ case kRealisticPID : return ("REALISTIC_");break;
+ case kRealisticPIDMix : return ("REALISTICMIX_");break;
+ case kPerfectPID : return ("PERFECT_");break;
+ case kPerfectPIDMix : return ("PERFECTMIX_");break;
+ case kTruePairs : return ("TRUEPAIRS_"); break;
+ default:
+ AliWarning("Unrecognized value of EPairTypeName argument");
+ break;
+ }
+
+ return "NOTYPE";
+}
+
+//_____________________________________________________________________________
+TString AliRsnPair::GetPairName()
+{
+//
+// Retruns pair name
+//
+ TString sName;
+ sName += GetPairTypeName(fPairType);
+ sName += fPairDef->GetPairName();
+
+ return sName;
+}
+
+//_____________________________________________________________________________
+TString AliRsnPair::GetPairHistName(AliRsnFunction *fcn, TString text)
+{
+//
+// Returns eff. mass histogram name
+//
+
+ TString sName;
+ if (fcn)
+ {
+ sName = fcn->GetFcnName();
+ sName += "_";
+ }
+ sName += GetPairName();
+ sName += "_";
+ if (fCutMgr) sName += fCutMgr->GetName();
+ sName += text;
+
+ return sName;
+}
+
+//_____________________________________________________________________________
+TString AliRsnPair::GetPairHistTitle(AliRsnFunction *fcn, TString text)
+{
+//
+// Returns eff. mass histogram title
+//
+
+ TString sTitle;
+ if (fcn)
+ {
+ sTitle = fcn->GetFcnTitle();
+ sTitle += " ";
+ }
+ sTitle += GetPairName();
+ sTitle +=" ";
+ if (fCutMgr) sTitle += fCutMgr->GetTitle();
+ sTitle += text;
+
+ return sTitle;
+}
+
+//_____________________________________________________________________________
+void AliRsnPair::AddFunction(AliRsnFunction *fcn)
+{
+//
+// Adds a new computing function
+//
+// if (!fFunctions) fFunctions = new TList;
+ //fFunctions.Add((AliRsnFunction *)fcn->Clone());
+ Int_t size = fFunctions.GetEntries();
+ new(fFunctions[size]) AliRsnFunction(*fcn);
+ //fFunctions.AddLast(fcopy);
+}
+
+//________________________________________________________________________________________
+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.
+//
+ if (!fCutMgr) return kTRUE;
+ else return fCutMgr->IsSelected(AliRsnCut::kParticle, d);
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnPair::CutPass(AliRsnPairParticle *p)
+{
+//
+// Check if the AliRsnPairParticle argument pass its cuts.
+// If the cut data member is not initialized for it, returns kTRUE.
+// In this case, another separate check which could be necessary
+// concerns the possibility that the two tracks are a "true pair" of
+// daughters of the same resonance. If the corresponding flag is set,
+// this further check is done, and the method returns kTRUE only
+// when also this check is passed.
+//
+
+ if (!fCutMgr) return kTRUE;
+ else return fCutMgr->IsSelected(AliRsnCut::kPair, p);
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnPair::CutPass(AliRsnEvent *e)
+{
+//
+// Check if the AliRsnEvent argument pass its cuts.
+// If the cut data member is not initialized for it, returns kTRUE.
+//
+ if (!fCutMgr) return kTRUE;
+ else return fCutMgr->IsSelected(AliRsnCut::kEvent, e);
+}
--- /dev/null
+//
+// *** Class AliRsnPair ***
+//
+// TODO
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
+
+#ifndef ALIRSNPAIR_H
+#define ALIRSNPAIR_H
+
+#include "TH1.h"
+#include "TH2.h"
+#include "TList.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnPairDef.h"
+#include "AliRsnEventBuffer.h"
+#include "AliRsnEvent.h"
+#include "AliRsnCutMgr.h"
+#include "AliRsnHistoDef.h"
+
+class AliRsnFunction;
+
+class AliRsnPair : public TObject
+{
+ public:
+
+ enum EPairType
+ {
+ kNoPID = 0, kNoPIDMix,
+ kRealisticPID, kRealisticPIDMix,
+ kPerfectPID, kPerfectPIDMix,
+ kTruePairs,
+ kPairTypes
+ };
+
+ enum EOutputType
+ {
+ kInvMass = 0,
+ kInvMassResolution,
+ kOutputTypes
+ };
+
+
+ AliRsnPair (EPairType type = kRealisticPID, AliRsnPairDef *def = 0, Int_t mixNum = 1);
+ ~AliRsnPair();
+
+ void Init();
+ void Print();
+ void ProcessPair(AliRsnEventBuffer *buf);
+ void SetCutMgr(AliRsnCutMgr* theValue) { fCutMgr = theValue; }
+ void AddFunction(AliRsnFunction *fcn);
+ TList* GenerateHistograms(TString prefix = "");
+ void GenerateHistograms(TString prefix, TList *tgt);
+
+ TString GetPairTypeName(EPairType type);
+ TString GetPairName();
+ TString GetPairHistName(AliRsnFunction *fcn, TString text = "");
+ TString GetPairHistTitle(AliRsnFunction *fcn, TString text="");
+
+ private:
+
+ AliRsnPair (const AliRsnPair ©) : TObject(copy),
+ fIsMixed(kFALSE),fUseMC(kFALSE),fIsLikeSign(kFALSE),fMixNum(1),
+ fPairDef(0x0),fPairType(kPairTypes),fTypePID(AliRsnDaughter::kRealistic),
+ fCutMgr(0x0),fFunctions("AliRsnFunction",0) {}
+ AliRsnPair& operator=(const AliRsnPair&) {return *this;}
+
+ void SetUp(EPairType type); // sets up all flags
+ void SetAllFlags(AliRsnDaughter::EPIDMethod pidType,Bool_t isMix, Bool_t useMC);
+ AliRsnEvent* FindEventByEventCut(AliRsnEventBuffer *buf,Int_t & num);
+ void LoopPair(AliRsnEvent *ev1,TArrayI *a1,AliRsnEvent *ev2,TArrayI *a2);
+
+ void FillHistogram(EOutputType type,AliRsnPairParticle*pairPart);
+ void FillEffMass(EOutputType type,AliRsnPairParticle*pairPart);
+ void FillResolution(EOutputType type,AliRsnPairParticle*pairPart);
+
+ TString GetOutputTypeName(EOutputType type);
+ TString GetOutputTypeTitle(EOutputType type);
+
+ Bool_t CutPass(AliRsnDaughter *d);
+ Bool_t CutPass(AliRsnPairParticle *p);
+ Bool_t CutPass(AliRsnEvent *e);
+
+ // flags & integer data
+ Bool_t fIsMixed; // doing event-mixing ?
+ Bool_t fUseMC; // using MC inv. mass ?
+ Bool_t fIsLikeSign; // is a like-sign pair ?
+ Int_t fMixNum; // number of mixed events
+
+ // work management
+ AliRsnPairDef *fPairDef; // pair definition (particles, charges)
+ EPairType fPairType; // pair type (PID + mixing or not)
+ AliRsnDaughter::EPIDMethod fTypePID; // pid type variable for single track
+ AliRsnCutMgr *fCutMgr; // cut manager
+ TClonesArray fFunctions; // functions
+
+ ClassDef (AliRsnPair, 1)
+};
+
+#endif
ClassImp(AliRsnPairDef)
//_____________________________________________________________________________
-AliRsnPairDef::AliRsnPairDef() :
- fMotherPDG(0)
+AliRsnPairDef::AliRsnPairDef() : fMotherPDG(0)
{
//
// Empty constructor.
//_____________________________________________________________________________
AliRsnPairDef::AliRsnPairDef
(Char_t sign1, AliRsnPID::EType type1, Char_t sign2, AliRsnPID::EType type2, Int_t motherPDG) :
- fMotherPDG(motherPDG)
+ fMotherPDG(motherPDG)
{
//
// Constructor with arguments.
SetPair(sign1, type1, sign2, type2);
}
+//_____________________________________________________________________________
+AliRsnPairDef::AliRsnPairDef
+(AliRsnPID::EType type1, Char_t sign1, AliRsnPID::EType type2, Char_t sign2, Int_t motherPDG) :
+ fMotherPDG(motherPDG)
+{
+//
+// Constructor with arguments.
+// This constructor allows to define all the working parameters.
+//
+
+ SetPair(sign1, type1, sign2, type2);
+}
+
+
//_____________________________________________________________________________
AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef ©) :
- TObject(copy),
- fMotherPDG(copy.fMotherPDG)
+ TObject(copy),
+ fMotherPDG(copy.fMotherPDG)
{
//
// Copy constructor with standard behavior
fCharge[i] = charge;
fType[i] = type;
fMass[i] = AliRsnPID::ParticleMass(type);
+
return kTRUE;
}
// Set both elements of the pair,
// returning logical AND of check for each one.
//
-
Bool_t part1 = SetPairElement(0, charge1, type1);
Bool_t part2 = SetPairElement(1, charge2, type2);
+
return (part1 && part2);
}
return prob0*prob1;
}
+
+//_____________________________________________________________________________
+TString AliRsnPairDef::GetPairName()
+{
+//
+// Returns a compact string with the name of the pair,
+// to be used for naming objects related to it.
+//
+
+ TString sName;
+ sName += AliRsnPID::ParticleName(fType[0]);
+ sName += fCharge[0];
+ sName += AliRsnPID::ParticleName(fType[1]);
+ sName += fCharge[1];
+
+ return sName;
+}
#ifndef ALIRSNPAIRDEF_H
#define ALIRSNPAIRDEF_H
+#include <TString.h>
+
#include "AliRsnPID.h"
class AliRsnDaughter;
class AliRsnPairDef : public TObject
{
-public:
+ public:
AliRsnPairDef();
- AliRsnPairDef(Char_t ch1, AliRsnPID::EType pid1,
- Char_t ch2, AliRsnPID::EType pid2, Int_t motherPDG = 0);
+ 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(const AliRsnPairDef ©);
- const AliRsnPairDef& operator=(const AliRsnPairDef ©);
+ const AliRsnPairDef& operator= (const AliRsnPairDef ©);
virtual ~AliRsnPairDef() { }
// getters
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();
// setters
Bool_t SetPairElement(Int_t i, Char_t charge, AliRsnPID::EType pid);
// working routines
Double_t ComputeWeight(AliRsnDaughter *d0, AliRsnDaughter *d1);
-private:
+ private:
// pair parameters
Int_t fMotherPDG; // PDG code of true mother (if known)
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+//
+// *** Class AliRsnPairMgr ***
+//
+// TODO
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
+
+#include "AliLog.h"
+
+#include "AliRsnPairMgr.h"
+
+ClassImp ( AliRsnPairMgr )
+
+//_____________________________________________________________________________
+AliRsnPairMgr::AliRsnPairMgr ( const char*name )
+ : TNamed ( name,name),fPairs(0)
+{
+//=========================================================
+// Default constructor
+//=========================================================
+
+}
+
+//_____________________________________________________________________________
+AliRsnPairMgr::~AliRsnPairMgr()
+{
+//=========================================================
+// Destructor
+//=========================================================
+
+}
+
+//_____________________________________________________________________________
+void AliRsnPairMgr::AddPair ( AliRsnPair * pair )
+{
+//=========================================================
+// Adds pair
+//=========================================================
+
+ fPairs.Add ( ( AliRsnPair * ) pair );
+}
+
+//_____________________________________________________________________________
+void AliRsnPairMgr::PrintPairs()
+{
+//=========================================================
+// Prints all pairs
+//=========================================================
+ AliRsnPair * pair=0;
+ for ( Int_t i=0;i<fPairs.GetEntriesFast() ;i++ )
+ {
+ pair = ( AliRsnPair * ) fPairs.At ( i );
+ pair->Print();
+ }
+}
--- /dev/null
+//
+// *** Class AliRsnPairMgr ***
+//
+// TODO
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
+
+#ifndef ALIRSNMVPAIRMGR_H
+#define ALIRSNMVPAIRMGR_H
+
+#include "AliRsnPair.h"
+
+class AliRsnPairMgr : public TNamed
+{
+ public:
+ AliRsnPairMgr(const char*name="default");
+
+ ~AliRsnPairMgr();
+
+ void AddPair ( AliRsnPair *pair );
+ TObjArray *GetPairs() { return &fPairs; }
+ void PrintPairs();
+
+ private:
+
+ TObjArray fPairs; // array of pairs
+
+ ClassDef ( AliRsnPairMgr, 1 )
+};
+
+#endif
#include "AliRsnPairParticle.h"
-ClassImp (AliRsnPairParticle)
+ClassImp(AliRsnPairParticle)
//_____________________________________________________________________________
AliRsnPairParticle::AliRsnPairParticle()
// Initializes all variables to meaningless values.
//
- Int_t i, j;
-
- for (i = 0; i < 3; i++) {
- fPTot[i] = 0.0;
- fPTotMC[i] = 0.0;
- if (i < 2) {
- fMotherLabel[i] = -1;
- fMotherPDG[i] = 0;
- fDaughter[i] = 0x0;
- }
- 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++)
+ {
+ fPTot[i] = 0.0;
+ fPTotMC[i] = 0.0;
+ if (i < 2)
+ {
+ fMotherLabel[i] = -1;
+ fMotherPDG[i] = 0;
+ fDaughter[i] = 0x0;
}
+ for (j = 0; j < 2; j++)
+ {
+ fPTrack[j][i] = 0.0;
+ fPTrackMC[j][i] = 0.0;
+ }
+ }
}
//_____________________________________________________________________________
AliRsnPairParticle::AliRsnPairParticle(const AliRsnPairParticle &obj) :
- TObject(obj)
+ TObject(obj)
{
//
// Copy constructor.
// Does not duplicate pointers.
//
- Int_t i, j;
- for (i = 0; i < 3; i++) {
- fPTot[i] = obj.fPTot[i];
- fPTotMC[i] = obj.fPTotMC[i];
- if (i < 2) {
- fMotherLabel[i] = obj.fMotherLabel[i];
- fMotherPDG[i] = obj.fMotherPDG[i];
- fDaughter[i] = obj.fDaughter[i];
- }
- 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++)
+ {
+ fPTot[i] = obj.fPTot[i];
+ fPTotMC[i] = obj.fPTotMC[i];
+ if (i < 2)
+ {
+ fMotherLabel[i] = obj.fMotherLabel[i];
+ fMotherPDG[i] = obj.fMotherPDG[i];
+ fDaughter[i] = obj.fDaughter[i];
+ }
+ for (j = 0; j < 2; j++)
+ {
+ fPTrack[j][i] = obj.fPTrack[j][i];
+ fPTrackMC[j][i] = obj.fPTrackMC[j][i];
}
+ }
}
//_____________________________________________________________________________
// Does not duplicate pointers.
//
- Int_t i, j;
- for (i = 0; i < 3; i++) {
- fPTot[i] = obj.fPTot[i];
- fPTotMC[i] = obj.fPTotMC[i];
- if (i < 2) {
- fMotherLabel[i] = obj.fMotherLabel[i];
- fMotherPDG[i] = obj.fMotherPDG[i];
- fDaughter[i] = obj.fDaughter[i];
- }
- 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++)
+ {
+ fPTot[i] = obj.fPTot[i];
+ fPTotMC[i] = obj.fPTotMC[i];
+ if (i < 2)
+ {
+ fMotherLabel[i] = obj.fMotherLabel[i];
+ fMotherPDG[i] = obj.fMotherPDG[i];
+ fDaughter[i] = obj.fDaughter[i];
+ }
+ for (j = 0; j < 2; j++)
+ {
+ fPTrack[j][i] = obj.fPTrack[j][i];
+ fPTrackMC[j][i] = obj.fPTrackMC[j][i];
}
+ }
- return (*this);
+ return (*this);
}
//_____________________________________________________________________________
// and the sum of their energies as they result from assigned masses.
//
- if (!fDaughter[0] || !fDaughter[1]) {
- AliError("One of the two tracks is NULL in this pair!");
- return -1000.0;
- }
+ if (!fDaughter[0] || !fDaughter[1])
+ {
+ AliError("One of the two tracks is NULL in this pair!");
+ return -1000.0;
+ }
- // compute track energies using the shortcut method defined in AliRsnDaughter
- Double_t etot = 0.0;
- etot += fDaughter[0]->E(mass0);
- etot += fDaughter[1]->E(mass1);
+ // compute track energies using the shortcut method defined in AliRsnDaughter
+ Double_t etot = 0.0;
+ etot += fDaughter[0]->E(mass0);
+ etot += fDaughter[1]->E(mass1);
- // compute & return invariant mass
- return TMath::Sqrt (etot * etot - GetP2());
+ // compute & return invariant mass
+ return TMath::Sqrt(etot * etot - GetP2());
}
//_____________________________________________________________________________
// and the sum of their energies as they result from assigned masses.
//
- 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()) {
- AliError("One of the two tracks has a NULL MCInfo in this pair!");
- return -1000.0;
- }
+ 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())
+ {
+ 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);
+
+ // compute & return invariant mass
+ return TMath::Sqrt(etot * etot - GetP2());
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnPairParticle::GetEtot(Double_t mass0, Double_t mass1) const
+{
+//
+// Compute total pair energy from the sum of single track energies
+// with a necessary mass hypothesis (rec. values).
+//
+ Double_t etot = 0.0;
+ etot += fDaughter[0]->E(mass0);
+ etot += fDaughter[1]->E(mass1);
+
+ return etot;
+}
- // compute track energies using the shortcut method defined in AliRsnDaughter
+//_____________________________________________________________________________
+Double_t AliRsnPairParticle::GetEtotMC(Double_t mass0, Double_t mass1) const
+{
+//
+// Compute total pair energy from the sum of single track energies
+// with a necessary mass hypothesis (MC values).
+//
Double_t etot = 0.0;
etot += fDaughter[0]->GetMCInfo()->E(mass0);
etot += fDaughter[1]->GetMCInfo()->E(mass1);
-
- // compute & return invariant mass
- return TMath::Sqrt (etot * etot - GetP2());
+
+ return etot;
}
//_____________________________________________________________________________
// Return value is in DEGREES.
//
- Double_t dotProd = 0.0;
- dotProd += fDaughter[0]->Px() * fDaughter[1]->Px();
- dotProd += fDaughter[0]->Py() * fDaughter[1]->Pz();
- dotProd += fDaughter[0]->Pz() * fDaughter[1]->Pz();
-
- Double_t cosAngle = dotProd / (fDaughter[0]->P() * fDaughter[1]->P());
-
- return TMath::ACos(cosAngle) * TMath::RadToDeg();
+ Double_t dotProd = 0.0;
+ dotProd += fDaughter[0]->Px() * fDaughter[1]->Px();
+ dotProd += fDaughter[0]->Py() * fDaughter[1]->Pz();
+ dotProd += fDaughter[0]->Pz() * fDaughter[1]->Pz();
+
+ Double_t cosAngle = dotProd / (fDaughter[0]->P() * fDaughter[1]->P());
+
+ return TMath::ACos(cosAngle) * TMath::RadToDeg();
}
//_____________________________________________________________________________
// if the mother is the same and its PDG code is equal to the argument.
//
- // if MC info is not available, the pairs is not true by default
- if (!fDaughter[0]->GetMCInfo() || !fDaughter[1]->GetMCInfo()) {
- return kFALSE;
- }
-
- // check that labels are the same
- if (fDaughter[0]->GetMCInfo()->Mother() != fDaughter[1]->GetMCInfo()->Mother()) {
- 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());
- if (refPDG == 0) return kTRUE;
- else return (motherPDG == refPDG);
+ // if MC info is not available, the pairs is not true by default
+ if (!fDaughter[0]->GetMCInfo() || !fDaughter[1]->GetMCInfo())
+ {
+ 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())
+ {
+ 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());
+ if (refPDG == 0) return kTRUE;
+ else return (motherPDG == refPDG);
}
//_____________________________________________________________________________
// and computes the total momentum for REC data and MC if available
//
- Int_t i;
+ Int_t i;
- fDaughter[0] = daughter1;
- 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();
- }
- for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
- }
+ fDaughter[0] = daughter1;
+ fDaughter[1] = daughter2;
- // copy reconstructed info (always available)
- for (i = 0; i < 2; i++) {
- fPTrack[i][0] = fDaughter[i]->Px();
- fPTrack[i][1] = fDaughter[i]->Py();
- fPTrack[i][2] = fDaughter[i]->Pz();
+ // 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();
}
- for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
+ 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++)
+ {
+ 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::PrintInfo (const Option_t *option)
+void AliRsnPairParticle::PrintInfo(const Option_t *option)
{
//
-// Print some info of the pair.
+// Print some info of the pair.
// The options are passed to the AliRsnDaughter::Print() method
//
- AliInfo("======== BEGIN PAIR INFO ===========");
- AliInfo("Track #1");
- fDaughter[0]->Print(option);
- AliInfo("Track #2");
- fDaughter[1]->Print(option);
- AliInfo ("========= END PAIR INFO ===========");
+ AliInfo("======== BEGIN PAIR INFO ===========");
+ AliInfo("Track #1");
+ fDaughter[0]->Print(option);
+ AliInfo("Track #2");
+ fDaughter[1]->Print(option);
+ AliInfo("========= END PAIR INFO ===========");
}
class AliRsnPairParticle : public TObject
{
-public:
+ public:
AliRsnPairParticle();
AliRsnPairParticle(const AliRsnPairParticle &obj);
AliRsnPairParticle& operator=(const AliRsnPairParticle &obj);
virtual ~AliRsnPairParticle();
- Double_t GetInvMass (Double_t m1, Double_t m2);
- Double_t GetInvMassMC (Double_t m1 = -1.0, Double_t m2 = -1.0);
-
+ Double_t GetInvMass(Double_t m1, Double_t m2);
+ Double_t GetInvMassMC(Double_t m1, Double_t m2);
+
+ Double_t GetEtot(Double_t m1, Double_t m2) const;
Double_t GetP2() const {return (fPTot[0]*fPTot[0] + fPTot[1]*fPTot[1] + fPTot[2]*fPTot[2]);}
Double_t GetPt2() const {return (fPTot[0]*fPTot[0] + fPTot[1]*fPTot[1]);}
Double_t GetP() const {return TMath::Sqrt(GetP2());}
Double_t GetPy() const {return fPTot[1];}
Double_t GetPz() const {return fPTot[2];}
Double_t GetPt() const {return TMath::Sqrt(GetPt2());}
+ Double_t GetPhi() const {return TMath::Pi() + TMath::ATan2(-fPTot[1], -fPTot[0]);}
+ Double_t GetTheta() const {if(fPTot[2]==0.0){return TMath::PiOver2();}else{return TMath::ACos(fPTot[2]/GetP());}}
+ Double_t GetEta() const {return -TMath::Log(TMath::ATan(0.5*GetTheta()));}
+ Double_t GetY(Double_t m1, Double_t m2) const {return 0.5*TMath::Log((GetEtot(m1,m2)+fPTot[2])/(GetEtot(m1,m2)-fPTot[2]));}
+ Double_t GetEtotMC(Double_t m1, Double_t m2) const;
Double_t GetP2MC() const {return (fPTotMC[0]*fPTotMC[0] + fPTotMC[1]*fPTotMC[1] + fPTotMC[2]*fPTotMC[2]);}
Double_t GetPt2MC() const {return (fPTotMC[0]*fPTotMC[0] + fPTotMC[1]*fPTotMC[1]);}
Double_t GetPMC() const {return TMath::Sqrt(GetP2MC());}
Double_t GetPyMC() const {return fPTotMC[1];}
Double_t GetPzMC() const {return fPTotMC[2];}
Double_t GetPtMC() const {return TMath::Sqrt(GetPt2MC());}
-
+ Double_t GetPhiMC() const {return TMath::Pi() + TMath::ATan2(-fPTotMC[1], -fPTotMC[0]);}
+ Double_t GetThetaMC() const {if(fPTotMC[2]==0.0){return TMath::PiOver2();}else{return TMath::ACos(fPTotMC[2]/GetPMC());}}
+ Double_t GetEtaMC() const {return -TMath::Log(TMath::ATan(0.5*GetThetaMC()));}
+ Double_t GetYMC(Double_t m1, Double_t m2) const {return 0.5*TMath::Log((GetEtotMC(m1,m2)+fPTotMC[2])/(GetEtotMC(m1,m2)-fPTotMC[2]));}
+
Double_t GetAngle() const;
AliRsnDaughter* GetDaughter(const Int_t &index) const {return fDaughter[index];}
Bool_t IsTruePair(Int_t refPDG = 0);
void SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2);
- void PrintInfo (const Option_t *option = "");
+ void PrintInfo(const Option_t *option = "");
-private:
+ private:
Double_t fPTot[3]; // total momentum computed with rec. values
Double_t fPTotMC[3]; // total momentum computed with MC values
AliRsnDaughter *fDaughter[2]; // elements of the pair
- ClassDef (AliRsnPairParticle,1)
+ ClassDef(AliRsnPairParticle,1)
};
#endif
// Class AliRsnReader
//
// This is the universal converter from any kind of source event
-// (i.e. ESD, standard AOD, MC) into the internal non-standard
+// (i.e. ESD, standard AOD, MC) into the internal non-standard
// AOD format used by RSN package.
// ---
// This class reads all tracks in an input event and converts them
//
#include <TString.h>
-#include <TDirectory.h>
#include "AliLog.h"
#include "AliRsnDaughter.h"
#include "AliRsnEvent.h"
#include "AliRsnPIDWeightsMgr.h"
+
#include "AliRsnReader.h"
ClassImp(AliRsnReader)
//_____________________________________________________________________________
-AliRsnReader::AliRsnReader(ESource source, AliRsnPIDWeightsMgr *mgr) :
- TNamed("RsnReader", ""),
- fSource(source),
- fCheckSplit(kFALSE),
- fRejectFakes(kFALSE),
- fWeightsMgr(mgr)
+AliRsnReader::AliRsnReader(AliRsnPIDWeightsMgr *mgr) :
+ TNamed("RsnReader", ""),
+ fCheckSplit(kFALSE),
+ fRejectFakes(kFALSE),
+ fWeightsMgr(mgr),
+ fCurrentPIDtype(AliRsnDaughter::kEsd),
+ fPIDDivValue(0.0),
+ fITSClusters(0),
+ fTPCClusters(0),
+ fTRDClusters(0)
{
//
// Constructor.
-// Adds also this object to global directory.
//
- gDirectory->Append(this, kTRUE);
}
//_____________________________________________________________________________
-Bool_t AliRsnReader::Fill(AliRsnEvent *rsn, AliVEvent *event, AliMCEvent *mc)
+Bool_t AliRsnReader::Fill
+(AliRsnEvent *rsn, AliVEvent *event, AliMCEvent *mc, Bool_t useTPCOnly)
{
//
// According to the class type of event and the selected source
Bool_t success = kFALSE;
TString str(event->ClassName());
- switch (fSource) {
- case kESD:
- if (!str.Contains("AliESDEvent")) {
- AliError(Form("Source class mismatch [expected: 'AliESDEvent' -- passed: '%s'", str.Data()));
- return kFALSE;
- }
- success = FillFromESD(rsn, (AliESDEvent*)event, mc);
- break;
- case kESDTPC:
- if (!str.Contains("AliESDEvent")) {
- AliError(Form("Source class mismatch [expected: 'AliESDEvent' -- passed: '%s'", str.Data()));
- return kFALSE;
- }
- success = FillFromESD(rsn, (AliESDEvent*)event, mc, kTRUE);
- break;
- case kAOD:
- if (!str.Contains("AliAODEvent")) {
- AliError(Form("Source class mismatch [expected: 'AliAODEvent' -- passed: '%s'", str.Data()));
- return kFALSE;
- }
- success = FillFromAOD(rsn, (AliAODEvent*)event, mc);
- break;
- case kMC:
- if (!str.Contains("AliMCEvent")) {
- AliError(Form("Source class mismatch [expected: 'AliMCEvent' -- passed: '%s'", str.Data()));
- return kFALSE;
- }
- success = FillFromMC(rsn, (AliMCEvent*)event);
- break;
- default:
- return kFALSE;
+ if (!str.CompareTo("AliESDEvent")) {
+ AliDebug(1, "Reading an ESD event");
+ success = FillFromESD(rsn, (AliESDEvent*)event, mc, useTPCOnly);
}
-
+ else if (!str.CompareTo("AliAODEvent")) {
+ AliDebug(1, "Reading an AOD event");
+ success = FillFromAOD(rsn, (AliAODEvent*)event, mc);
+ }
+ else if (!str.CompareTo("AliMCEvent")) {
+ AliDebug(1, "Reading an MC event");
+ success = FillFromMC(rsn, (AliMCEvent*)event);
+ }
+ else {
+ AliError(Form("ClassName '%s' not recognized as possible source data: aborting.", str.Data()));
+ return kFALSE;
+ }
+
// sort tracks w.r. to Pt (from largest to smallest)
rsn->SortTracks();
-
return success;
}
// Stores all tracks (if a filter is defined, it will store
// only the ones which survive the cuts).
// If a reference MC event is provided, it is used to store
-// the MC informations for each track (true PDG code,
+// the MC informations for each track (true PDG code,
// GEANT label of mother, PDG code of mother, if any).
// When this is used, the 'source' flag of the output
// AliRsnEvent object will be set to 'kESD'.
Int_t i1, i2, lab1, lab2;
Bool_t *accept = new Bool_t[ntracks];
for (i1 = 0; i1 < ntracks; i1++) accept[i1] = kTRUE;
- if (fCheckSplit) {
- for (i1 = 0; i1 < ntracks; i1++) {
+ if (fCheckSplit)
+ {
+ for (i1 = 0; i1 < ntracks; i1++)
+ {
AliESDtrack *trk1 = esd->GetTrack(i1);
lab1 = TMath::Abs(trk1->GetLabel());
- for (i2 = i1+1; i2 < ntracks; i2++) {
+ for (i2 = i1+1; i2 < ntracks; i2++)
+ {
AliESDtrack *trk2 = esd->GetTrack(i2);
lab2 = TMath::Abs(trk2->GetLabel());
// check if labels are equal
- if (lab1 == lab2) {
- if (trk1->GetConstrainedChi2() < trk2->GetConstrainedChi2()) {
+ if (lab1 == lab2)
+ {
+ if (trk1->GetConstrainedChi2() < trk2->GetConstrainedChi2())
+ {
accept[i1] = kTRUE;
accept[i2] = kFALSE;
}
- else {
+ else
+ {
accept[i1] = kFALSE;
accept[i2] = kTRUE;
}
// get primary vertex
Double_t vertex[3];
- if (!useTPCOnly) {
+ if (!useTPCOnly)
+ {
vertex[0] = esd->GetVertex()->GetXv();
vertex[1] = esd->GetVertex()->GetYv();
vertex[2] = esd->GetVertex()->GetZv();
}
- else {
+ else
+ {
vertex[0] = esd->GetPrimaryVertexTPC()->GetXv();
vertex[1] = esd->GetPrimaryVertexTPC()->GetYv();
vertex[2] = esd->GetPrimaryVertexTPC()->GetZv();
rsn->SetPrimaryVertex(vertex[0], vertex[1], vertex[2]);
// store tracks from ESD
- Int_t i, index, label, labmum;
+ Int_t i, index, label, labmum;
Bool_t check;
AliRsnDaughter temp;
- for (index = 0; index < ntracks; index++) {
+ for (index = 0; index < ntracks; index++)
+ {
// skip track recognized as the worse one in a splitted pair
- if (!accept[index]) {
+ if (!accept[index])
+ {
AliInfo(Form("Rejecting split track #%d in this event", index));
continue;
}
if (fRejectFakes && (label < 0)) continue;
// copy ESD track data into RsnDaughter
// if unsuccessful, this track is skipped
- check = temp.Adopt(esdTrack, useTPCOnly);
+// temp.SetCurrentESDPID(fCurrentPIDtype);
+
+ if (fITSClusters>0)
+ if (esdTrack->GetITSclusters(0) < fITSClusters) continue;
+
+ if (fTPCClusters>0)
+ if (esdTrack->GetTPCclusters(0) < fTPCClusters) continue;
+
+ if (fTRDClusters>0)
+ if (esdTrack->GetTRDclusters(0) < fTRDClusters) continue;
+
+ check = temp.Adopt(esdTrack,fCurrentPIDtype,fPIDDivValue, useTPCOnly);
if (!check) continue;
// if the AliRsnWeightsMgr object is initialized
// this means that ESD PID weights are not used
// and they are computed according to the Weight manager
- if (fWeightsMgr) {
+ if (fWeightsMgr)
+ {
//AliInfo("Using customized weights");
//AliInfo(Form("ESD weights = %f %f %f %f %f", temp.PID()[0], temp.PID()[1], temp.PID()[2], temp.PID()[3], temp.PID()[4], temp.PID()[5]));
esdTrack->GetITSpid(fWeightsMgr->GetWeightArray(AliRsnPIDWeightsMgr::kITS));
esdTrack->GetTRDpid(fWeightsMgr->GetWeightArray(AliRsnPIDWeightsMgr::kTRD));
esdTrack->GetTOFpid(fWeightsMgr->GetWeightArray(AliRsnPIDWeightsMgr::kTOF));
esdTrack->GetHMPIDpid(fWeightsMgr->GetWeightArray(AliRsnPIDWeightsMgr::kHMPID));
- for (i = 0; i < AliRsnPID::kSpecies; i++) {
+ for (i = 0; i < AliRsnPID::kSpecies; i++)
+ {
temp.SetPIDWeight(i, fWeightsMgr->GetWeight((AliRsnPID::EType)i, temp.Pt()));
}
//AliInfo(Form("Used weights = %f %f %f %f %f", temp.PID()[0], temp.PID()[1], temp.PID()[2], temp.PID()[3], temp.PID()[4], temp.PID()[5]));
}
- else {
+ else
+ {
//AliInfo("Using standard ESD weights");
}
// if stack is present, copy MC info
- if (stack) {
+ if (stack)
+ {
TParticle *part = stack->Particle(TMath::Abs(label));
- if (part) {
+ if (part)
+ {
temp.InitMCInfo(part);
labmum = part->GetFirstMother();
- if (labmum >= 0) {
+ if (labmum >= 0)
+ {
TParticle *mum = stack->Particle(labmum);
temp.GetMCInfo()->SetMotherPDG(mum->GetPdgCode());
}
}
// compute total multiplicity
- if (rsn->GetMultiplicity() <= 0) {
- AliWarning("Zero Multiplicity in this event");
+ if (rsn->GetMultiplicity() <= 0)
+ {
+ AliDebug(1, "Zero Multiplicity in this event");
return kFALSE;
}
// Stores all tracks (if a filter is defined, it will store
// only the ones which survive the cuts).
// If a reference MC event is provided, it is used to store
-// the MC informations for each track (true PDG code,
+// the MC informations for each track (true PDG code,
// GEANT label of mother, PDG code of mother, if any).
// When this is used, the 'source' flag of the output
// AliRsnEvent object will be set to 'kAOD'.
// get number of tracks
Int_t ntracks = aod->GetNTracks();
- if (!ntracks) {
- AliWarning("No tracks in this event");
- return kFALSE;
+ if (!ntracks)
+ {
+ AliWarning("No tracks in this event");
+ return kFALSE;
}
// get primary vertex
rsn->SetPrimaryVertex(vertex[0], vertex[1], vertex[2]);
// store tracks from ESD
- Int_t index, label, labmum;
+ Int_t index, label, labmum;
Bool_t check;
AliAODTrack *aodTrack = 0;
AliRsnDaughter temp;
TObjArrayIter iter(aod->GetTracks());
- while ( (aodTrack = (AliAODTrack*)iter.Next()) ) {
+ while ((aodTrack = (AliAODTrack*)iter.Next()))
+ {
// retrieve index
index = aod->GetTracks()->IndexOf(aodTrack);
label = aodTrack->GetLabel();
check = temp.Adopt(aodTrack);
if (!check) continue;
// if stack is present, copy MC info
- if (stack) {
+ if (stack)
+ {
TParticle *part = stack->Particle(TMath::Abs(label));
- if (part) {
+ if (part)
+ {
temp.InitMCInfo(part);
labmum = part->GetFirstMother();
- if (labmum >= 0) {
+ if (labmum >= 0)
+ {
TParticle *mum = stack->Particle(labmum);
temp.GetMCInfo()->SetMotherPDG(mum->GetPdgCode());
}
}
// compute total multiplicity
- if (rsn->GetMultiplicity() <= 0) {
- AliWarning("Zero multiplicity in this event");
+ if (rsn->GetMultiplicity() <= 0)
+ {
+ AliDebug(1, "Zero multiplicity in this event");
return kFALSE;
}
{
//
// Filler from an ESD event.
-// Stores all tracks which generate at least one
+// Stores all tracks which generate at least one
// TrackReference (a point in a sensitive volume).
-// In this case, the MC info is stored by default and
+// In this case, the MC info is stored by default and
// perfect particle identification is the unique available.
// When this is used, the 'source' flag of the output
// AliRsnEvent object will be set to 'kMC'.
// get number of tracks
Int_t ntracks = mc->GetNumberOfTracks();
- if (!ntracks) {
- AliWarning("No tracks in this event");
- return kFALSE;
+ if (!ntracks)
+ {
+ AliWarning("No tracks in this event");
+ return kFALSE;
}
AliStack *stack = mc->Stack();
rsn->SetPrimaryVertex(vertex[0], vertex[1], vertex[2]);
// store tracks from MC
- Int_t index, labmum;
+ Int_t index, labmum;
Bool_t check;
AliRsnDaughter temp;
- for (index = 0; index < ntracks; index++) {
+ for (index = 0; index < ntracks; index++)
+ {
// get and check MC track
AliMCParticle *mcTrack = mc->GetTrack(index);
// if particle has no track references, it is rejected
check = temp.Adopt(mcTrack);
if (!check) continue;
labmum = temp.GetMCInfo()->Mother();
- if (labmum >= 0) {
+ if (labmum >= 0)
+ {
TParticle *mum = stack->Particle(labmum);
temp.GetMCInfo()->SetMotherPDG(mum->GetPdgCode());
}
}
// compute total multiplicity
- if (rsn->GetMultiplicity() <= 0) {
- AliWarning("Zero multiplicity in this event");
+ if (rsn->GetMultiplicity() <= 0)
+ {
+ AliDebug(1, "Zero multiplicity in this event");
return kFALSE;
}
return kTRUE;
}
+
+void AliRsnReader::SetPIDtype(const AliRsnDaughter::EPIDType & theValue, Double_t divValue)
+{
+ fCurrentPIDtype = theValue;
+ fPIDDivValue = divValue;
+}
+
+
+void AliRsnReader::SetITSTPCTRDSectors(const Int_t & its, const Int_t & tpc, const Int_t & trd)
+{
+ fITSClusters = its;
+ fTPCClusters = tpc;
+ fTRDClusters = trd;
+}
// Class AliRsnReader
//
// This is the universal converter from any kind of source event
-// (i.e. ESD, standard AOD, MC) into the internal non-standard
+// (i.e. ESD, standard AOD, MC) into the internal non-standard
// AOD format used by RSN package.
// ---
// This class reads all tracks in an input event and converts them
#define ALIRSNREADER_H
#include <TNamed.h>
+#include "AliRsnDaughter.h"
class AliVEvent;
class AliESDEvent;
class AliRsnReader : public TNamed
{
-public:
+ public:
- enum ESource {
- kESD = 0,
- kESDTPC,
- kAOD,
- kMC,
- kSources
- };
-
- AliRsnReader(ESource source = kESD, AliRsnPIDWeightsMgr *mgr = 0x0);
+ AliRsnReader(AliRsnPIDWeightsMgr *mgr = 0x0);
virtual ~AliRsnReader() {}
-
- void SetSource(ESource source) {fSource = source;}
+
void SetWeightsMgr(AliRsnPIDWeightsMgr *mgr) {fWeightsMgr = mgr;}
void SetCheckSplit(Bool_t doit = kTRUE) {fCheckSplit = doit;}
void SetRejectFakes(Bool_t doit = kTRUE) {fRejectFakes = doit;}
-
- ESource GetSource() {return fSource;}
+
Bool_t CheckSplit() {return fCheckSplit;}
Bool_t RejectFakes() {return fRejectFakes;}
- Bool_t Fill(AliRsnEvent *rsn, AliVEvent *event, AliMCEvent *refMC = 0);
-
-protected:
+
+ Bool_t Fill(AliRsnEvent *rsn, AliVEvent *event, AliMCEvent *refMC = 0, Bool_t useTPCOnly = kFALSE);
+ Bool_t FillFromESD(AliRsnEvent *rsn, AliESDEvent *event, AliMCEvent *refMC = 0, Bool_t useTPCOnly = kFALSE);
+ Bool_t FillFromAOD(AliRsnEvent *rsn, AliAODEvent *event, AliMCEvent *refMC = 0);
+ Bool_t FillFromMC(AliRsnEvent *rsn, AliMCEvent *mc);
+
+ // sets PID TYPE
+ void SetPIDtype(const AliRsnDaughter::EPIDType& theValue = AliRsnDaughter::kEsd, Double_t divValue = 0.0);
+ AliRsnDaughter::EPIDType GetPIDtype() const { return fCurrentPIDtype; }
+
+ // sets Sectors cut
+ void SetITSTPCTRDSectors(const Int_t& its = -1, const Int_t& tpc = -1, const Int_t& trd = -1);
+
+ protected:
// dummy copy methods
AliRsnReader(const AliRsnReader ©) : TNamed(copy),
- fSource(kESD),fCheckSplit(0),fRejectFakes(0),fWeightsMgr(0x0) { /*nothing*/ }
+ fCheckSplit(0),fRejectFakes(0),fWeightsMgr(0x0),fCurrentPIDtype(AliRsnDaughter::kEsd),
+ fPIDDivValue(0.),fITSClusters(0),fTPCClusters(0),fTRDClusters(0) { /*nothing*/ }
AliRsnReader& operator=(const AliRsnReader&) {return (*this);}
- Bool_t FillFromESD(AliRsnEvent *rsn, AliESDEvent *event, AliMCEvent *refMC = 0, Bool_t useTPCOnly = kFALSE);
- Bool_t FillFromAOD(AliRsnEvent *rsn, AliAODEvent *event, AliMCEvent *refMC = 0);
- Bool_t FillFromMC(AliRsnEvent *rsn, AliMCEvent *mc);
+ Bool_t fCheckSplit; // flag to check and remove split tracks
+ Bool_t fRejectFakes; // flag to reject fake tracks (negative label)
+
+ AliRsnPIDWeightsMgr *fWeightsMgr; // manager for alternative PID weights
+ AliRsnDaughter::EPIDType fCurrentPIDtype; // PID type
+ Double_t fPIDDivValue; // PID div Value
+ Int_t fITSClusters; //
+ Int_t fTPCClusters; //
+ Int_t fTRDClusters; //
- ESource fSource; // flag to choose what kind of data to be read
- Bool_t fCheckSplit; // flag to check and remove split tracks
- Bool_t fRejectFakes; // flag to reject fake tracks (negative label)
- AliRsnPIDWeightsMgr *fWeightsMgr; // manager for alternative PID weights
+ private:
-private:
-
ClassDef(AliRsnReader, 1);
};
--- /dev/null
+//
+// Class AliRsnReaderTask
+//
+// An AnalysisTask object to convert any kind of source event type (ESD/AOD/MC)
+// into the RSN internal format (AliRsnEvent).
+// The output of this task is a TTree with converted events, which is saved in a file
+// and can then be processed as many times as desired, to build invariant mass spectra.
+// ---
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include "AliLog.h"
+
+#include "AliAnalysisManager.h"
+#include "AliMCEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliAODInputHandler.h"
+#include "AliAODHandler.h"
+
+#include "AliRsnEvent.h"
+#include "AliRsnReader.h"
+#include "AliRsnPID.h"
+#include "AliRsnReaderTask.h"
+
+ClassImp(AliRsnReaderTask)
+
+//_____________________________________________________________________________
+AliRsnReaderTask::AliRsnReaderTask() :
+ AliRsnBaseAT(),
+ fRsnTree(0x0)
+{
+//=========================================================
+// Default constructor (not recommended)
+//=========================================================
+}
+
+//_____________________________________________________________________________
+AliRsnReaderTask::AliRsnReaderTask(const char *name) :
+ AliRsnBaseAT(name),
+ fRsnTree(0x0)
+{
+//=========================================================
+// Working constructor (recommended)
+//=========================================================
+ InitIOVars();
+ DefineOutput(0, TTree::Class());
+}
+
+//_____________________________________________________________________________
+AliRsnReaderTask::AliRsnReaderTask(const AliRsnReaderTask& obj) :
+ AliRsnBaseAT(obj),
+ fRsnTree(0x0)
+{
+//=========================================================
+// Copy constructor (not recommended)
+//=========================================================
+}
+
+//_____________________________________________________________________________
+AliRsnReaderTask& AliRsnReaderTask::operator= (const AliRsnReaderTask& /*obj*/)
+{
+//=========================================================
+// Assignment operator (not recommended)
+//=========================================================
+
+ AliInfo("Not implemented. Avoid using the assignment operator");
+ return *this;
+}
+
+//_____________________________________________________________________________
+void AliRsnReaderTask::InitIOVars()
+{
+//=========================================================
+// Init values for input and output data
+//=========================================================
+ AliDebug(AliLog::kDebug, "<-");
+ AliRsnBaseAT::InitIOVars();
+ AliDebug(AliLog::kDebug, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnReaderTask::CreateOutputObjects()
+{
+//=========================================================
+// Create the output container
+//=========================================================
+
+ AliDebug(1, "Creating output objects");
+ OpenFile(0);
+ fRsnTree = new TTree("aodTree", "AliRsnEvents");
+
+ fRSN[0] = new AliRsnEvent();
+ fRSN[0]->SetName("rsnEvents");
+ fRSN[0]->Init();
+ fRsnTree->Branch("rsnEvents","AliRsnEvent",&fRSN[0]);
+// AddAODBranch("AliRsnEvent", &fRsnEvent);
+}
+
+//_____________________________________________________________________________
+void AliRsnReaderTask::LocalInit()
+{
+//=========================================================
+// Initialization
+//=========================================================
+
+ AliDebug(1, "Initializing");
+}
+
+Bool_t AliRsnReaderTask::Notify()
+{
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+void AliRsnReaderTask::Exec(Option_t */*option*/)
+{
+//=========================================================
+// Loops on input container to store data of all tracks.
+// Uses the AliRsnReader methods to save them in the output.
+//=========================================================
+
+ fRSN[0] = GetRsnEventFromInputType(0);
+ if (!fRSN[0]) return;
+ AliInfo(Form("Collected %d tracks", fRSN[0]->GetMultiplicity()));
+
+ fRsnTree->Fill();
+ PostData(0, fRsnTree);
+}
+
+//_____________________________________________________________________________
+void AliRsnReaderTask::Terminate(Option_t */*option*/)
+{
+//=========================================================
+// Terminate analysis
+//=========================================================
+
+ AliDebug(1, "Terminating");
+}
+
--- /dev/null
+//
+// Class AliRsnReaderTask
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#ifndef ALIRSNREADERTASK_H
+#define ALIRSNREADERTASK_H
+
+#include "AliRsnBaseAT.h"
+
+class AliRsnPID;
+class AliRsnReader;
+
+class AliRsnReaderTask : public AliRsnBaseAT
+{
+ public:
+
+ AliRsnReaderTask();
+ AliRsnReaderTask(const char *name);
+ virtual ~AliRsnReaderTask() {}
+
+ // Implementation of interface methods
+ virtual void InitIOVars();
+ virtual void LocalInit();
+ virtual Bool_t Notify();
+ virtual void CreateOutputObjects();
+ virtual void Exec(Option_t *option);
+ virtual void Terminate(Option_t *);
+
+ private:
+
+ AliRsnReaderTask(const AliRsnReaderTask&);
+ AliRsnReaderTask& operator= (const AliRsnReaderTask&);
+
+ TTree* fRsnTree; // output tree
+
+ ClassDef(AliRsnReaderTask, 0) // implementation of RsnReader as AnalysisTask
+};
+
+#endif
//_____________________________________________________________________________
AliRsnReaderTaskSE::AliRsnReaderTaskSE() :
- AliAnalysisTaskSE(),
- fReader(0x0),
- fPID(0x0),
- fRsnEvent(0x0)
+ AliRsnAnalysisTaskSEBase(),
+ fRsnEvent(0x0)
{
//
// Default constructor (not recommended)
//_____________________________________________________________________________
AliRsnReaderTaskSE::AliRsnReaderTaskSE(const char *name) :
- AliAnalysisTaskSE(name),
- fReader(0x0),
- fPID(0x0),
- fRsnEvent(0x0)
+ AliRsnAnalysisTaskSEBase(name),
+ fRsnEvent(0x0)
{
//
// Working constructor (recommended)
// raises a fatal error which breaks the AliRoot session.
//
- if (!fReader) {
- AliFatal("Event reader not initialized. Impossible to continue");
- return;
- }
- if (!fPID) {
- AliFatal("PID not initialized. Impossible to continue");
- return;
- }
-
- fRsnEvent = new AliRsnEvent();
- fRsnEvent->SetName("rsnEvents");
- fRsnEvent->Init();
- AddAODBranch("AliRsnEvent", &fRsnEvent);
+ fRsnEvent = new AliRsnEvent();
+ fRsnEvent->SetName("rsnEvents");
+ fRsnEvent->Init();
+ AddAODBranch("AliRsnEvent", &fRsnEvent);
}
//_____________________________________________________________________________
// and store them in the output AOD event, with all required computations.
//
- AliInfo(Form("Reading event %d", ++fEntry));
-
- // before adding new data, the ones from previous event
- // must be cleared explicitly
- fRsnEvent->Clear();
-
- // step 1: conversion
- if (!fReader->Fill(fRsnEvent, fInputEvent, fMCEvent)) AliWarning("Failed reading");
+ AliInfo(Form("Reading event %d", ++fEntry));
+
+ // before adding new data, the ones from previous event
+ // must be cleared explicitly
+ fRsnEvent->Clear();
+
+
+ // step 1: conversion
+ Bool_t ok = kFALSE;
+ switch (fInputType[0])
+ {
+ case kAOD:
+ AliDebug(5, "Reading AOD event...");
+ ok = fReader.FillFromAOD(fRsnEvent, (AliAODEvent*)fInputEvent, fMCEvent);
+ AliDebug(5, "...done");
+ break;
+ case kESD:
+ AliDebug(5, "Reading ESD event...");
+ ok = fReader.FillFromESD(fRsnEvent, (AliESDEvent*)fInputEvent, fMCEvent);
+ AliDebug(5, "...done");
+ break;
+ case kESDMC:
+ AliDebug(5, "Reading ESD event with MC...");
+ ok = fReader.FillFromESD(fRsnEvent, (AliESDEvent*)fInputEvent, fMCEvent);
+ AliDebug(5, "...done");
+ break;
+ case kMC:
+ AliDebug(5, "Reading MC only event...");
+ ok = fReader.FillFromMC(fRsnEvent, fMCEvent);
+ AliDebug(5, "...done");
+ break;
+ default:
+ AliError("Type not supported ...");
+ return;
+ }
+ if (!ok) AliWarning("Failed reading");
- // step 2: PID probability computation
- if (!fPID->Process(fRsnEvent)) AliWarning("Failed PID");
+ // step 2: PID probability computation
+ if (!fPID.Process(fRsnEvent)) AliWarning("Failed PID");
- AliInfo(Form("Collected %d tracks", fRsnEvent->GetMultiplicity()));
+ AliInfo(Form("Collected %d tracks", fRsnEvent->GetMultiplicity()));
}
//_____________________________________________________________________________
#ifndef AliRsnReaderTaskSE_H
#define AliRsnReaderTaskSE_H
-#include "AliAnalysisTaskSE.h"
+#include "AliRsnAnalysisTaskSEBase.h"
class AliRsnPID;
class AliESDEvent;
class AliRsnReader;
-class AliRsnReaderTaskSE : public AliAnalysisTaskSE
+class AliRsnReaderTaskSE : public AliRsnAnalysisTaskSEBase
{
public:
virtual void UserExec(Option_t *option);
virtual void Terminate(Option_t *option);
- void SetReader(AliRsnReader *reader) {fReader = reader;}
- void SetPID(AliRsnPID *pid) {fPID = pid;}
- AliRsnReader* GetReader() {return fReader;}
- AliRsnPID* GetPID() {return fPID;}
+// void SetReader(AliRsnReader *reader) {fReader = reader;}
+// void SetPID(AliRsnPID *pid) {fPID = pid;}
+// AliRsnReader* GetReader() {return fReader;}
+// AliRsnPID* GetPID() {return fPID;}
AliRsnEvent* GetCurrentEvent() {return fRsnEvent;}
private:
AliRsnReaderTaskSE(const AliRsnReaderTaskSE ©) :
- AliAnalysisTaskSE(copy),fReader(0x0),fPID(0x0),fRsnEvent(0x0) { /*nothing*/ }
+ AliRsnAnalysisTaskSEBase(copy),fRsnEvent(0x0) { /*nothing*/ }
AliRsnReaderTaskSE& operator=(const AliRsnReaderTaskSE&)
{ /*nothing*/ return (*this); }
- AliRsnReader *fReader; // read manager
- AliRsnPID *fPID; // PID manager
AliRsnEvent *fRsnEvent; // output events in the AliRsnEvent format
ClassDef(AliRsnReaderTaskSE, 1); // implementation of RsnReader as AnalysisTaskSE
//_____________________________________________________________________________
AliRsnSimpleAnalysis::AliRsnSimpleAnalysis(AliRsnSimpleAnalyzer *ana, AliRsnPID *pid) :
- TObject(),
- fInitialized(kFALSE),
- fStep(1000),
- fTree(0x0),
- fPID(pid),
- fAnalyzer(ana)
+ TObject(),
+ fInitialized(kFALSE),
+ fStep(1000),
+ fTree(0x0),
+ fPID(pid),
+ fAnalyzer(ana)
{
//
// Constructor
// Initializes all pointers and collections to NULL.
//
- strcpy(fFileName, "default.root");
+ strcpy(fFileName, "default.root");
}
// Counts also the number of events and stores it in a private datamember.
// This can avoid the time-wasting entries count in a long TChain.
//
- fTree = tree;
- AliInfo(Form("Total number of events to be processed: %d", fTree->GetEntries()));
+ fTree = tree;
+ AliInfo(Form("Total number of events to be processed: %d", fTree->GetEntries()));
}
//_____________________________________________________________________________
//
// Various initialization processes
//
- // check process objects
- if (!fAnalyzer) {
- AliError("Analyzer not initialized");
- return kFALSE;
- }
+ // check process objects
+ if (!fAnalyzer)
+ {
+ AliError("Analyzer not initialized");
+ return kFALSE;
+ }
- // initialize analyzer
- fAnalyzer->Init();
+ // initialize analyzer
+ fAnalyzer->Init();
- // at the end, update flag for initialization
- fInitialized = kTRUE;
+ // at the end, update flag for initialization
+ fInitialized = kTRUE;
- return kTRUE;
+ return kTRUE;
}
//_____________________________________________________________________________
// Depending on the kind of background evaluation method, computes also this one.
//
- // check initialization
- if (!fInitialized) {
- AliError("Analysis not initialized. Use method 'Initialize()'");
- return 0.0;
- }
-
- // set cursor object
- AliRsnEvent *event = 0x0;
- fTree->SetBranchAddress("rsnEvents", &event);
-
- // output counter
- Stat_t nPairs = 0.0;
-
- // loop on events
- Int_t i, nEvents = (Int_t)fTree->GetEntries();
- for (i = 0; i < nEvents; i++) {
- // message
- if ((i % fStep) == 0) AliInfo(Form("Processing event %d", i));
- // get entry
- fTree->GetEntry(i);
- if (!event) continue;
- fPID->Process(event);
- fAnalyzer->Process(event);
- }
-
- return nPairs;
+ // check initialization
+ if (!fInitialized)
+ {
+ AliError("Analysis not initialized. Use method 'Initialize()'");
+ return 0.0;
+ }
+
+ // set cursor object
+ AliRsnEvent *event = 0x0;
+ fTree->SetBranchAddress("rsnEvents", &event);
+
+ // output counter
+ Stat_t nPairs = 0.0;
+
+ // loop on events
+ Int_t i, nEvents = (Int_t)fTree->GetEntries();
+ for (i = 0; i < nEvents; i++)
+ {
+ // message
+ if ((i % fStep) == 0) AliInfo(Form("Processing event %d", i));
+ // get entry
+ fTree->GetEntry(i);
+ if (!event) continue;
+ fPID->Process(event);
+ fAnalyzer->Process(event);
+ }
+
+ return nPairs;
}
//_____________________________________________________________________________
//
// Writes histograms in current directory
//
- TFile *file = TFile::Open(fFileName, "RECREATE");
- AliRsnSimpleFunction *pair = 0;
- TH1D *h1D = 0;
- TH2D *h2D = 0;
- TObjArrayIter pairIterator(fAnalyzer->GetSingle());
- while ( (pair = (AliRsnSimpleFunction*)pairIterator.Next()) ) {
- h1D = pair->GetHistogram1D();
- h2D = pair->GetHistogram2D();
- if (h1D) h1D->Write();
- if (h2D) h2D->Write();
+ TFile *file = TFile::Open(fFileName, "RECREATE");
+ AliRsnSimpleFunction *pair = 0;
+ TH1D *h1D = 0;
+ TH2D *h2D = 0;
+ TObjArrayIter pairIterator(fAnalyzer->GetSingle());
+ while ((pair = (AliRsnSimpleFunction*)pairIterator.Next()))
+ {
+ h1D = pair->GetHistogram1D();
+ h2D = pair->GetHistogram2D();
+ if (h1D) h1D->Write();
+ if (h2D) h2D->Write();
+ }
+ if (fAnalyzer->GetMix() && !fAnalyzer->GetMix()->IsEmpty())
+ {
+ TObjArrayIter mixIterator(fAnalyzer->GetMix());
+ while ((pair = (AliRsnSimpleFunction*)mixIterator.Next()))
+ {
+ h1D = pair->GetHistogram1D();
+ h2D = pair->GetHistogram2D();
+ if (h1D) h1D->Write();
+ if (h2D) h2D->Write();
}
- if (fAnalyzer->GetMix() && !fAnalyzer->GetMix()->IsEmpty()) {
- TObjArrayIter mixIterator(fAnalyzer->GetMix());
- while ( (pair = (AliRsnSimpleFunction*)mixIterator.Next()) ) {
- h1D = pair->GetHistogram1D();
- h2D = pair->GetHistogram2D();
- if (h1D) h1D->Write();
- if (h2D) h2D->Write();
- }
- }
- file->Close();
+ }
+ file->Close();
}
class AliRsnSimpleAnalysis : public TObject
{
-public:
+ public:
AliRsnSimpleAnalysis(AliRsnSimpleAnalyzer *ana = 0x0, AliRsnPID *pid = 0x0);
virtual ~AliRsnSimpleAnalysis() {Clear();}
Stat_t Process();
void SaveOutput() const;
-private:
+ private:
AliRsnSimpleAnalysis(const AliRsnSimpleAnalysis ©) :
- TObject(copy),fInitialized(kFALSE),fStep(1000),fTree(0x0),fPID(0x0),fAnalyzer(0x0) { }
- AliRsnSimpleAnalysis& operator=(const AliRsnSimpleAnalysis & /*copy*/)
- { return (*this); }
+ TObject(copy),fInitialized(kFALSE),fStep(1000),fTree(0x0),fPID(0x0),fAnalyzer(0x0) { }
+ AliRsnSimpleAnalysis& operator=(const AliRsnSimpleAnalysis & /*copy*/)
+ { return (*this); }
Bool_t fInitialized; // flag to check initialization
Int_t fStep; // progress step
//_____________________________________________________________________________
AliRsnSimpleAnalysisTaskSE::AliRsnSimpleAnalysisTaskSE() :
- AliAnalysisTaskSE(),
- fReader(0x0),
- fPID(0x0),
- fAnalyzer(0x0),
- fRsnEvent(0x0),
- fHistograms(0x0)
+ AliAnalysisTaskSE(),
+ fReader(0x0),
+ fPID(0x0),
+ fAnalyzer(0x0),
+ fRsnEvent(0x0),
+ fHistograms(0x0)
{
//
// Default constructor (not recommended)
//_____________________________________________________________________________
AliRsnSimpleAnalysisTaskSE::AliRsnSimpleAnalysisTaskSE(const char *name) :
- AliAnalysisTaskSE(name),
- fReader(0x0),
- fPID(0x0),
- fAnalyzer(0x0),
- fRsnEvent(0x0),
- fHistograms(0x0)
+ AliAnalysisTaskSE(name),
+ fReader(0x0),
+ fPID(0x0),
+ fAnalyzer(0x0),
+ fRsnEvent(0x0),
+ fHistograms(0x0)
{
//
// Working constructor (recommended)
//
- DefineOutput (1, TList::Class());
+ DefineOutput(1, TList::Class());
}
//_____________________________________________________________________________
// Create the output container
//
- // check for presence of NECESSARY data-members
- if (!fReader) {
- AliFatal("Event reader not initialized. Impossible to continue. Aborting with fatal error.");
- return;
- }
- if (!fPID) {
- AliFatal("PID manager not initialized. Impossible to continue. Aborting with fatal error.");
- return;
- }
- if (!fAnalyzer) {
- AliFatal("Analysis manager not initialized. Impossible to continue. Aborting with fatal error.");
- return;
- }
+ // check for presence of NECESSARY data-members
+ if (!fReader)
+ {
+ AliFatal("Event reader not initialized. Impossible to continue. Aborting with fatal error.");
+ return;
+ }
+ if (!fPID)
+ {
+ AliFatal("PID manager not initialized. Impossible to continue. Aborting with fatal error.");
+ return;
+ }
+ if (!fAnalyzer)
+ {
+ AliFatal("Analysis manager not initialized. Impossible to continue. Aborting with fatal error.");
+ return;
+ }
+
+ // output histogram list
+ fHistograms = new TList;
+
+ // initialize analyzer
+ fAnalyzer->Init();
+
+ // store all histograms in the functions into the list
+ TObjArray *array = fAnalyzer->GetSingle();
+ AliRsnSimpleFunction *fcn;
+ TH1D *h1D;
+ TH2D *h2D;
+ if (array)
+ {
+ TObjArrayIter iter(array);
+ while ((fcn = (AliRsnSimpleFunction*)iter.Next()))
+ {
+ h1D = fcn->GetHistogram1D();
+ h2D = fcn->GetHistogram2D();
+ if (h1D) fHistograms->AddLast(h1D);
+ if (h2D) fHistograms->AddLast(h2D);
- // output histogram list
- fHistograms = new TList;
-
- // initialize analyzer
- fAnalyzer->Init();
-
- // store all histograms in the functions into the list
- TObjArray *array = fAnalyzer->GetSingle();
- AliRsnSimpleFunction *fcn;
- TH1D *h1D;
- TH2D *h2D;
- if (array) {
- TObjArrayIter iter(array);
- while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
- h1D = fcn->GetHistogram1D();
- h2D = fcn->GetHistogram2D();
- if (h1D) fHistograms->AddLast(h1D);
- if (h2D) fHistograms->AddLast(h2D);
-
- }
- }
- else {
- AliWarning("No single-event functions in analyzer");
- }
- array = fAnalyzer->GetMix();
- if (array) {
- TObjArrayIter iter(array);
- while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
- h1D = fcn->GetHistogram1D();
- h2D = fcn->GetHistogram2D();
- if (h1D) fHistograms->AddLast(h1D);
- if (h2D) fHistograms->AddLast(h2D);
- }
}
- else {
- AliWarning("No mixing functions in analyzer");
+ }
+ else
+ {
+ AliWarning("No single-event functions in analyzer");
+ }
+ array = fAnalyzer->GetMix();
+ if (array)
+ {
+ TObjArrayIter iter(array);
+ while ((fcn = (AliRsnSimpleFunction*)iter.Next()))
+ {
+ h1D = fcn->GetHistogram1D();
+ h2D = fcn->GetHistogram2D();
+ if (h1D) fHistograms->AddLast(h1D);
+ if (h2D) fHistograms->AddLast(h2D);
}
+ }
+ else
+ {
+ AliWarning("No mixing functions in analyzer");
+ }
}
//_____________________________________________________________________________
// Uses the AliRsnReader methods to save them in the output.
//
- // clear previous event
- if (!fRsnEvent) {
- fRsnEvent = new AliRsnEvent;
- fRsnEvent->Init();
- }
- else fRsnEvent->Clear();
-
- // read event
- if (!fReader->Fill(fRsnEvent, fInputEvent, fMCEvent)) AliWarning("Failed reading");
- AliInfo(Form("Collected %d tracks", fRsnEvent->GetMultiplicity()));
-
- // identify event if the class is available
- if (fPID) fPID->Process(fRsnEvent);
-
- // process event with analyzer
- fAnalyzer->Process(fRsnEvent);
-
- // post histograms in slot #1
- PostData(1, fHistograms);
+ // clear previous event
+ if (!fRsnEvent)
+ {
+ fRsnEvent = new AliRsnEvent;
+ fRsnEvent->Init();
+ }
+ else fRsnEvent->Clear();
+
+ // read event
+ if (!fReader->Fill(fRsnEvent, fInputEvent, fMCEvent)) AliWarning("Failed reading");
+ AliInfo(Form("Collected %d tracks", fRsnEvent->GetMultiplicity()));
+
+ // identify event if the class is available
+ if (fPID) fPID->Process(fRsnEvent);
+
+ // process event with analyzer
+ fAnalyzer->Process(fRsnEvent);
+
+ // post histograms in slot #1
+ PostData(1, fHistograms);
}
//_____________________________________________________________________________
// Returns kFALSE if not all the required objects were created.
//
- gROOT->LoadMacro(configFile);
- gROOT->ProcessLine("RsnConfig()");
-
- fReader = (AliRsnReader*)gDirectory->Get("RsnReader");
- fPID = (AliRsnPID*)gDirectory->Get("RsnPID");
- fAnalyzer = (AliRsnSimpleAnalyzer*)gDirectory->Get("RsnSimpleAnalyzer");
-
- // check for presence of NECESSARY data-members
- if (!fReader) {
- AliError("Event reader not initialized. Impossible to continue. Aborting with fatal error.");
- return kFALSE;
- }
- if (!fPID) {
- AliError("PID manager not initialized. Impossible to continue. Aborting with fatal error.");
- return kFALSE;
- }
- if (!fAnalyzer) {
- AliError("Analysis manager not initialized. Impossible to continue. Aborting with fatal error.");
- return kFALSE;
- }
-
- return kTRUE;
+ gROOT->LoadMacro(configFile);
+ gROOT->ProcessLine("RsnConfig()");
+
+ fReader = (AliRsnReader*)gDirectory->Get("RsnReader");
+ fPID = (AliRsnPID*)gDirectory->Get("RsnPID");
+ fAnalyzer = (AliRsnSimpleAnalyzer*)gDirectory->Get("RsnSimpleAnalyzer");
+
+ // check for presence of NECESSARY data-members
+ if (!fReader)
+ {
+ AliError("Event reader not initialized. Impossible to continue. Aborting with fatal error.");
+ return kFALSE;
+ }
+ if (!fPID)
+ {
+ AliError("PID manager not initialized. Impossible to continue. Aborting with fatal error.");
+ return kFALSE;
+ }
+ if (!fAnalyzer)
+ {
+ AliError("Analysis manager not initialized. Impossible to continue. Aborting with fatal error.");
+ return kFALSE;
+ }
+
+ return kTRUE;
}
//_____________________________________________________________________________
// Print analysis settings
//
- AliInfo("==== ANALYSIS TASK INFO =======================================================");
-
- // reader
- AliInfo(Form("Reader address, name: %x %s", fReader, fReader->GetName()));
- switch (fReader->GetSource()) {
- case AliRsnReader::kESD:
- AliInfo("Reader source: kESD");
- break;
- case AliRsnReader::kESDTPC:
- AliInfo("Reader source: kESDTPC");
- break;
- case AliRsnReader::kAOD:
- AliInfo("Reader source: kAOD");
- break;
- case AliRsnReader::kMC:
- AliInfo("Reader source: kMC");
- break;
- default:
- AliInfo("Reader source not properly set");
- }
- AliInfo(Form("Reader->CheckSplit = %s", (fReader->CheckSplit() ? "true" : "false")));
- AliInfo(Form("Reader->RejectFakes = %s", (fReader->RejectFakes() ? "true" : "false")));
-
- // PID
- Int_t i;
- AliRsnPID::EType type;
- AliInfo(Form("PID address, name: %x", fPID, fPID->GetName()));
- for (i = 0; i < AliRsnPID::kSpecies; i++) {
- type = (AliRsnPID::EType)i;
- AliInfo(Form("Prior probability [%d] = %f (%s)", i, fPID->GetPriorProbability(type), AliRsnPID::ParticleName(type)));
- }
- AliInfo(Form("PID momentum threshold = %f", fPID->GetMaxPt()));
- AliInfo(Form("PID probability threshold = %f", fPID->GetMinProb()));
-
- // analyzer
- AliRsnSimpleFunction *fcn;
- AliInfo(Form("Analyzer address, name: %x", fAnalyzer, fAnalyzer->GetName()));
- TObjArrayIter iter1(fAnalyzer->GetSingle());
- while ( (fcn = (AliRsnSimpleFunction*)iter1.Next()) ) {
- AliInfo(Form("Single-event function: %s [%s]", fcn->GetName(), fcn->ClassName()));
- }
- if (fAnalyzer->GetMix()) {
- TObjArrayIter iter2(fAnalyzer->GetMix());
- while ( (fcn = (AliRsnSimpleFunction*)iter2.Next()) ) {
- AliInfo(Form("Mix function: %s [%s]", fcn->GetName(), fcn->ClassName()));
- }
+ AliInfo("==== ANALYSIS TASK INFO =======================================================");
+
+ // reader
+ AliInfo(Form("Reader address, name: %x %s", fReader, fReader->GetName()));
+ switch (fReader->GetSource())
+ {
+ case AliRsnReader::kESD:
+ AliInfo("Reader source: kESD");
+ break;
+ case AliRsnReader::kESDTPC:
+ AliInfo("Reader source: kESDTPC");
+ break;
+ case AliRsnReader::kAOD:
+ AliInfo("Reader source: kAOD");
+ break;
+ case AliRsnReader::kMC:
+ AliInfo("Reader source: kMC");
+ break;
+ default:
+ AliInfo("Reader source not properly set");
+ }
+ AliInfo(Form("Reader->CheckSplit = %s", (fReader->CheckSplit() ? "true" : "false")));
+ AliInfo(Form("Reader->RejectFakes = %s", (fReader->RejectFakes() ? "true" : "false")));
+
+ // PID
+ Int_t i;
+ AliRsnPID::EType type;
+ AliInfo(Form("PID address, name: %x", fPID, fPID->GetName()));
+ for (i = 0; i < AliRsnPID::kSpecies; i++)
+ {
+ type = (AliRsnPID::EType)i;
+ AliInfo(Form("Prior probability [%d] = %f (%s)", i, fPID->GetPriorProbability(type), AliRsnPID::ParticleName(type)));
+ }
+ AliInfo(Form("PID momentum threshold = %f", fPID->GetMaxPt()));
+ AliInfo(Form("PID probability threshold = %f", fPID->GetMinProb()));
+
+ // analyzer
+ AliRsnSimpleFunction *fcn;
+ AliInfo(Form("Analyzer address, name: %x", fAnalyzer, fAnalyzer->GetName()));
+ TObjArrayIter iter1(fAnalyzer->GetSingle());
+ while ((fcn = (AliRsnSimpleFunction*)iter1.Next()))
+ {
+ AliInfo(Form("Single-event function: %s [%s]", fcn->GetName(), fcn->ClassName()));
+ }
+ if (fAnalyzer->GetMix())
+ {
+ TObjArrayIter iter2(fAnalyzer->GetMix());
+ while ((fcn = (AliRsnSimpleFunction*)iter2.Next()))
+ {
+ AliInfo(Form("Mix function: %s [%s]", fcn->GetName(), fcn->ClassName()));
}
+ }
- AliInfo("===============================================================================");
+ AliInfo("===============================================================================");
}
class AliRsnSimpleAnalysisTaskSE : public AliAnalysisTaskSE
{
-public:
+ public:
AliRsnSimpleAnalysisTaskSE();
AliRsnSimpleAnalysisTaskSE(const char *name);
virtual ~AliRsnSimpleAnalysisTaskSE() { }
-
+
// Implementation of interface methods
virtual void UserCreateOutputObjects();
virtual void UserExec(Option_t *option);
-
+
// setters
Bool_t Configure(const char *configFile = "RsnConfig.C");
void SetReader(AliRsnReader *reader) {fReader = reader;}
void SetPID(AliRsnPID *pid) {fPID = pid;}
void SetAnalyzer(AliRsnSimpleAnalyzer *analyzer) {fAnalyzer = analyzer;}
void PrintSettings();
-
-private:
+
+ private:
AliRsnSimpleAnalysisTaskSE(const AliRsnSimpleAnalysisTaskSE&) :
- AliAnalysisTaskSE(),fReader(0x0),fPID(0x0),fAnalyzer(0x0),fRsnEvent(0x0),fHistograms(0x0)
- { /*nothing*/ }
+ AliAnalysisTaskSE(),fReader(0x0),fPID(0x0),fAnalyzer(0x0),fRsnEvent(0x0),fHistograms(0x0)
+ { /*nothing*/ }
AliRsnSimpleAnalysisTaskSE& operator=(const AliRsnSimpleAnalysisTaskSE&)
- { /*nothing*/ return (*this); }
+ { /*nothing*/ return (*this); }
AliRsnReader* fReader; // read manager
AliRsnPID* fPID; // PID manager
//_____________________________________________________________________________
AliRsnSimpleAnalyzer::AliRsnSimpleAnalyzer(Int_t bufferSize) :
- TNamed("RsnSimpleAnalyzer", ""),
- fBufferSize(bufferSize),
- fMixMultCut(10),
- fMixVzCut(0.5),
- fNMix(10),
- fSingle(0x0),
- fMix(0x0),
- fBuffer(0x0)
+ TNamed("RsnSimpleAnalyzer", ""),
+ fBufferSize(bufferSize),
+ fMixMultCut(10),
+ fMixVzCut(0.5),
+ fNMix(10),
+ fSingle(0x0),
+ fMix(0x0),
+ fBuffer(0x0)
{
//
// Constructor
// Initializes all pointers and collections to NULL.
// Adds this object to the global Directory.
//
- gDirectory->Append(this, kTRUE);
+ gDirectory->Append(this, kTRUE);
}
// Clear heap
//
- fSingle->Clear(option);
- fMix->Clear(option);
- delete fBuffer;
- fBuffer = 0;
+ fSingle->Clear(option);
+ fMix->Clear(option);
+ delete fBuffer;
+ fBuffer = 0;
}
//_____________________________________________________________________________
// Second argument tells if the added object is for event mixing.
//
- Bool_t mixing = fcn->MixFlag();
- TObjArray* &target = mixing ? fMix : fSingle;
- if (!target) target = new TObjArray(0);
- target->AddLast(fcn);
+ Bool_t mixing = fcn->MixFlag();
+ TObjArray* &target = mixing ? fMix : fSingle;
+ if (!target) target = new TObjArray(0);
+ target->AddLast(fcn);
}
//_____________________________________________________________________________
// Initialize what needs to.
//
- // buffer
- fBuffer = new AliRsnEventBuffer(fBufferSize, kFALSE);
-
- // histograms
- AliRsnSimpleFunction *fcn = 0;
- if (fSingle) {
- TObjArrayIter iter(fSingle);
- while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
- fcn->Init();
- }
+ // buffer
+ fBuffer = new AliRsnEventBuffer(fBufferSize, kFALSE);
+
+ // histograms
+ AliRsnSimpleFunction *fcn = 0;
+ if (fSingle)
+ {
+ TObjArrayIter iter(fSingle);
+ while ((fcn = (AliRsnSimpleFunction*)iter.Next()))
+ {
+ fcn->Init();
}
- if (fMix) {
- TObjArrayIter iter(fMix);
- while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
- fcn->Init();
- }
+ }
+ if (fMix)
+ {
+ TObjArrayIter iter(fMix);
+ while ((fcn = (AliRsnSimpleFunction*)iter.Next()))
+ {
+ fcn->Init();
}
+ }
}
//_____________________________________________________________________________
// Depending on the kind of background evaluation method, computes also this one.
//
- // loop over the collection of pair defs
- ProcessEvents(fSingle, event, 0x0);
-
- if (fMix) {
- // variables for mixing
- Int_t mult1, mult2, i, j, count = 0;
- Double_t vz1, vz2;
- // add this event to buffer
- fBuffer->AddEvent(event);
- // event mixing
- vz1 = event->GetPrimaryVertexZ();
- mult1 = event->GetMultiplicity();
- if (!fBuffer->NEmptySlots()) {
- i = fBuffer->GetEventsBufferIndex();
- j = i+1;
- for (;;j++) {
- if (count >= fNMix) break;
- if (j == fBufferSize) j = 0;
- if (j == i) break;
- AliRsnEvent *evmix = fBuffer->GetEvent(j);
- if (!evmix) continue;
- vz2 = evmix->GetPrimaryVertexZ();
- mult2 = evmix->GetMultiplicity();
- if (TMath::Abs(vz1 - vz2) <= fMixVzCut && TMath::Abs(mult1- mult2) <= fMixMultCut) {
- // loop over the collection of pair defs
- ProcessEvents(fMix, event, evmix);
- ProcessEvents(fMix, evmix, event);
- count++;
- }
- }
+ // loop over the collection of pair defs
+ ProcessEvents(fSingle, event, 0x0);
+
+ if (fMix)
+ {
+ // variables for mixing
+ Int_t mult1, mult2, i, j, count = 0;
+ Double_t vz1, vz2;
+ // add this event to buffer
+ fBuffer->AddEvent(event);
+ // event mixing
+ vz1 = event->GetPrimaryVertexZ();
+ mult1 = event->GetMultiplicity();
+ if (!fBuffer->NEmptySlots())
+ {
+ i = fBuffer->GetEventsBufferIndex();
+ j = i+1;
+ for (;;j++)
+ {
+ if (count >= fNMix) break;
+ if (j == fBufferSize) j = 0;
+ if (j == i) break;
+ AliRsnEvent *evmix = fBuffer->GetEvent(j);
+ if (!evmix) continue;
+ vz2 = evmix->GetPrimaryVertexZ();
+ mult2 = evmix->GetMultiplicity();
+ if (TMath::Abs(vz1 - vz2) <= fMixVzCut && TMath::Abs(mult1- mult2) <= fMixMultCut)
+ {
+ // loop over the collection of pair defs
+ ProcessEvents(fMix, event, evmix);
+ ProcessEvents(fMix, evmix, event);
+ count++;
}
+ }
}
+ }
}
//_____________________________________________________________________________
// If the array is NULL nothing is done
//
- if (!array) return;
+ if (!array) return;
- AliRsnSimpleFunction *fcn = 0;
- TObjArrayIter iter(array);
- while ( (fcn = (AliRsnSimpleFunction*)iter.Next()) ) {
- if (event2) fcn->ProcessTwo(event1, event2);
- else fcn->ProcessOne(event1);
- }
+ AliRsnSimpleFunction *fcn = 0;
+ TObjArrayIter iter(array);
+ while ((fcn = (AliRsnSimpleFunction*)iter.Next()))
+ {
+ if (event2) fcn->ProcessTwo(event1, event2);
+ else fcn->ProcessOne(event1);
+ }
}
class AliRsnSimpleAnalyzer : public TNamed
{
-public:
+ public:
AliRsnSimpleAnalyzer(Int_t bufferSize = 1000);
virtual ~AliRsnSimpleAnalyzer() {Clear();}
void Add(AliRsnSimpleFunction *pair);
void Process(AliRsnEvent *event);
-private:
+ private:
AliRsnSimpleAnalyzer(const AliRsnSimpleAnalyzer ©) :
- TNamed(copy),fBufferSize(1000),
- fMixMultCut(10),fMixVzCut(0.5),fNMix(10),
- fSingle(0x0),fMix(0x0),fBuffer(0x0) { }
+ TNamed(copy),fBufferSize(1000),
+ fMixMultCut(10),fMixVzCut(0.5),fNMix(10),
+ fSingle(0x0),fMix(0x0),fBuffer(0x0) { }
AliRsnSimpleAnalyzer& operator=(const AliRsnSimpleAnalyzer & /*copy*/) { return (*this); }
void ProcessEvents(TObjArray *pairs, AliRsnEvent *event1, AliRsnEvent *event2 = 0x0);
//________________________________________________________________________________________
AliRsnSimpleFcnResolution::AliRsnSimpleFcnResolution() :
- AliRsnSimpleFunction()
+ AliRsnSimpleFunction()
{
//
// Constructor.
// Only default initializations.
//
- fTrueFlag = kTRUE;
- fMixFlag = kFALSE;
+ fTrueFlag = kTRUE;
+ fMixFlag = kFALSE;
}
//________________________________________________________________________________________
AliRsnSimpleFcnResolution::AliRsnSimpleFcnResolution
-(const char *name, AliRsnPairDef *pd,
+(const char *name, AliRsnPairDef *pd,
AliRsnHistoDef *hd, AliRsnCutMgr *cuts, Option_t *option) :
- AliRsnSimpleFunction(name, pd, hd, cuts, option)
+ AliRsnSimpleFunction(name, pd, hd, cuts, option)
{
//
// Constructor.
// Only default initializations.
//
- fTrueFlag = kTRUE;
- fMixFlag = kFALSE;
+ fTrueFlag = kTRUE;
+ fMixFlag = kFALSE;
}
//________________________________________________________________________________________
// This class uses always the perfect PID.
//
- if (!event) {
- AliError("Argument cannot be NULL.");
- return kFALSE;
- }
-
- // check event cut
- if (!CutPass(event)) return kFALSE;
-
- // assign pointers to the list of indexes to be used
- AliRsnDaughter::EPIDMethod mtd = AliRsnDaughter::kPerfect;
- TArrayI *plist1 = event->GetTracksArray(mtd, fPairDef->GetCharge(0), fPairDef->GetType(0));
- TArrayI *plist2 = event->GetTracksArray(mtd, fPairDef->GetCharge(1), fPairDef->GetType(1));
- if (!plist1 || !plist2) return 0.0;
- TArrayI &list1 = *plist1;
- TArrayI &list2 = *plist2;
-
- Stat_t count = 0;
- Int_t i1, i2, start2;
- AliRsnDaughter *track1 = 0x0, *track2 = 0x0;
-
- // loop on particle of type 1
- for (i1 = 0; i1 < list1.GetSize(); i1++) {
- track1 = event->GetTrack(list1[i1]);
- if (!CutPass(track1)) continue;
- // loop on particle of type 2
- // in case we are building a like-sign histogram with particles
- // of the same type, we must avoid that each pair is used twice
- start2 = 0;
- if (plist1 == plist2) start2 = i1 + 1;
- for (i2 = start2; i2 < list2.GetSize(); i2++) {
- track2 = event->GetTrack(list2[i2]);
- if (!CutPass(track2)) continue;
- if (Add(track1, track2)) count++;
- }
+ if (!event)
+ {
+ AliError("Argument cannot be NULL.");
+ return kFALSE;
+ }
+
+ // check event cut
+ if (!CutPass(event)) return kFALSE;
+
+ // assign pointers to the list of indexes to be used
+ AliRsnDaughter::EPIDMethod mtd = AliRsnDaughter::kPerfect;
+ TArrayI *plist1 = event->GetTracksArray(mtd, fPairDef->GetCharge(0), fPairDef->GetType(0));
+ TArrayI *plist2 = event->GetTracksArray(mtd, fPairDef->GetCharge(1), fPairDef->GetType(1));
+ if (!plist1 || !plist2) return 0.0;
+ TArrayI &list1 = *plist1;
+ TArrayI &list2 = *plist2;
+
+ Stat_t count = 0;
+ Int_t i1, i2, start2;
+ AliRsnDaughter *track1 = 0x0, *track2 = 0x0;
+
+ // loop on particle of type 1
+ for (i1 = 0; i1 < list1.GetSize(); i1++)
+ {
+ track1 = event->GetTrack(list1[i1]);
+ if (!CutPass(track1)) continue;
+ // loop on particle of type 2
+ // in case we are building a like-sign histogram with particles
+ // of the same type, we must avoid that each pair is used twice
+ start2 = 0;
+ if (plist1 == plist2) start2 = i1 + 1;
+ for (i2 = start2; i2 < list2.GetSize(); i2++)
+ {
+ track2 = event->GetTrack(list2[i2]);
+ if (!CutPass(track2)) continue;
+ if (Add(track1, track2)) count++;
}
+ }
- return (count > (Stat_t)0);
+ return (count > (Stat_t)0);
}
//________________________________________________________________________________________
// In case the study is done only for true pairs, this is checked automatically.
//
- // setup pair and check pair cuts
- fPair.SetPair(track1, track2);
- if (!CutPass(&fPair)) return kFALSE;
-
- // computation variables
- Double_t mass1 = fPairDef->GetMass(0);
- Double_t mass2 = fPairDef->GetMass(1);
-
- // make computation
- Double_t invmass = fPair.GetInvMass(mass1, mass2);
- Double_t invmassMC = fPair.GetInvMassMC(mass1, mass2);
- Double_t res = (invmassMC - invmass) / invmassMC;
-
- // fill
- fHisto1D->Fill(res);
-
- return kTRUE;
+ // setup pair and check pair cuts
+ fPair.SetPair(track1, track2);
+ if (!CutPass(&fPair)) return kFALSE;
+
+ // computation variables
+ Double_t mass1 = fPairDef->GetMass(0);
+ Double_t mass2 = fPairDef->GetMass(1);
+
+ // make computation
+ Double_t invmass = fPair.GetInvMass(mass1, mass2);
+ Double_t invmassMC = fPair.GetInvMassMC(mass1, mass2);
+ Double_t res = (invmassMC - invmass) / invmassMC;
+
+ // fill
+ fHisto1D->Fill(res);
+
+ return kTRUE;
}
class AliRsnSimpleFcnResolution : public AliRsnSimpleFunction
{
-public:
+ public:
AliRsnSimpleFcnResolution();
AliRsnSimpleFcnResolution
- (const char* name, AliRsnPairDef *pd,
- AliRsnHistoDef *hd, AliRsnCutMgr *cuts=0, Option_t *option="");
+ (const char* name, AliRsnPairDef *pd,
+ AliRsnHistoDef *hd, AliRsnCutMgr *cuts=0, Option_t *option="");
// virtual working routines
virtual Bool_t ProcessOne(AliRsnEvent *event);
-private:
+ private:
// dummy required methods
AliRsnSimpleFcnResolution(const AliRsnSimpleFcnResolution ©) :
- AliRsnSimpleFunction(copy) { /*nothing */ }
+ AliRsnSimpleFunction(copy) { /*nothing */ }
AliRsnSimpleFcnResolution& operator=(const AliRsnSimpleFcnResolution& /*copy*/)
- { /* nothing */ return (*this); }
-
+ { /* nothing */ return (*this); }
+
// utility methods
Bool_t Add(AliRsnDaughter *t1, AliRsnDaughter *t2);
Char_t name[200];
sprintf(name, "h_%s", GetName());
- switch (fHistoDef->GetNDimensions()) {
- case 1:
- fHisto1D = (TH1D*)fHistoDef->Create1DHistogram(name, "");
- return kTRUE;
- case 2:
- fHisto2D = (TH2D*)fHistoDef->Create1DHistogram(name, "");
- return kTRUE;
- default:
- AliError("Number of dimensions not properly set.");
- return kFALSE;
- }
+ fHisto1D = (TH1D*)fHistoDef->CreateHistogram(name, "");
+ return kTRUE;
}
//________________________________________________________________________________________