After discussion and merging strategy with Martin Vala, we defined a common base for our
internal AOD (AliRsnEvent & AliRsnDaughter) and for the cut system.
We defined the read standards for conversion from ESD and AOD or MC, and some support
classes for analysis. The "Simple" classes work for a simpler version of analysis which
is complete but probably could be improved.
This is a version which works, but it waits for another contribution which is in
development.
--- /dev/null
+#include <TSystem.h>
+#include <TFile.h>
+
+#include "AliLog.h"
+
+#include "AliAnalysisManager.h"
+#include "AliRsnPairMgr.h"
+#include "AliRsnEventBuffer.h"
+
+#include "AliMCEventHandler.h"
+
+#include "AliRsnAnalysisAT.h"
+
+ClassImp ( AliRsnAnalysisAT )
+AliRsnAnalysisAT::AliRsnAnalysisAT ( const char * name )
+ : AliRsnBaseAT ( name )
+{
+ InitIOVars ();
+ DefineInput ( 1, AliRsnPairMgr::Class() );
+
+ DefineOutput ( 0, TList::Class() );
+}
+
+AliRsnAnalysisAT::~AliRsnAnalysisAT()
+{
+}
+
+void AliRsnAnalysisAT::InitIOVars()
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+ AliRsnBaseAT::InitIOVars();
+
+ fPairMgr = 0;
+ fRsnMVEventBuffer = 0;
+ fOutList = 0;
+
+ for ( Int_t i=0;i<100 ;i++ )
+ for ( Int_t j=0;j<100 ;j++ )
+ {
+ fHist[i][j] = 0;
+ }
+
+ AliDebug ( AliLog::kDebug, "->" );
+}
+
+void AliRsnAnalysisAT::LocalInit()
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+ fPairMgr = dynamic_cast<AliRsnPairMgr*> ( GetInputData ( 1 ) );
+ fPairMgr->PrintPairs();
+ AliDebug ( AliLog::kDebug, "->" );
+}
+
+Bool_t AliRsnAnalysisAT::Notify()
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+ fChain[0] = ( TChain* ) GetInputData ( 0 );
+ if ( fChain[0] )
+ {
+ TFile *f = fChain[0]->GetCurrentFile();
+ if ( f ) { AliInfo ( Form ( "Processing file %s", f->GetName() ) );}
+ else AliError ( "fTree->GetCurrentFile() is 0" );
+ AliInfo ( Form ( "NumOfEvents %d", fChain[0]->GetTree()->GetEntries() ) );
+ }
+ else
+ {
+ AliError ( "fChain[0] not available" );
+ }
+
+ AliDebug ( AliLog::kDebug, "->" );
+ return AliRsnBaseAT::Notify();
+}
+
+void AliRsnAnalysisAT::CreateOutputObjects()
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+
+ fPairMgr = dynamic_cast<AliRsnPairMgr*> ( GetInputData ( 1 ) );
+ OpenFile ( 0 );
+ fOutList = new TList();
+
+ AliRsnPair *def=0;
+ for ( Int_t i=0;i< fPairMgr->GetPairs()->GetEntriesFast();i++ )
+ {
+ def = ( AliRsnPair * ) fPairMgr->GetPairs()->At ( i );
+ for ( Int_t j=0;j<def->GetCutMgr()->GetEntriesFast() ;j++ )
+ {
+ fHist[i][j] = def->GenerateEffMassHist ( j );
+ fOutList->Add ( fHist[i][j] );
+ }
+ }
+
+ fRsnMVEventBuffer = new AliRsnEventBuffer ( 1000 );
+// fRsnMVEventBuffer = new AliRsnEventBuffer ( 100 ,kFALSE );
+ AliDebug ( AliLog::kDebug, "->" );
+
+}
+
+void AliRsnAnalysisAT::Exec ( Option_t * option )
+{
+ TTree *tree = ( ( TChain* ) GetInputData ( 0 ) )->GetTree();
+ Long64_t ientry = ( Long64_t ) tree->GetReadEntry();
+
+ if ( ientry%100==0 )
+ AliInfo ( Form ( "Event #%d",ientry ) );
+
+// AliRsnEvent *curEvent = GetRsnMVEventFromInputType();
+// if ( !curEvent ) { AliError ( "Could not get AliRsnEvent from GetRsnMVEventFromInputType(). Skipping..." ); return; }
+
+// ProcessEventAnalysis ( curEvent );
+// PostEventProcess();
+
+// if (ientry%10000==0)
+// AliInfo(Form("Event #%d",ientry));
+ PostData ( 0, fOutList );
+}
+
+void AliRsnAnalysisAT::Terminate ( Option_t * )
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+ fOutList = dynamic_cast<TList*> ( GetOutputData ( 0 ) );
+ if ( !fOutList ) { AliError ( " fOutList not available" ); return; }
+ fOutList->Print();
+
+ AliDebug ( AliLog::kDebug, "->" );
+}
+
+void AliRsnAnalysisAT::Cleanup()
+{
+ AliInfo ( Form ( "Cleaning up in worker %s ...",gSystem->HostName() ) );
+// fRsnMVEventBuffer->ClearBuffer();
+// AliRsnPair *def = ( AliRsnPair * ) fPairMgr->GetPairs()->At ( 0 );
+// def->DoCleanUpAfterOneEvent();
+}
+
+void AliRsnAnalysisAT::ProcessEventAnalysis ( AliRsnEvent *curEvent )
+{
+
+
+
+ fRsnMVEventBuffer->AddEvent ( curEvent );
+ AliRsnPair *def=0;
+ AliRsnEvent *event=0;
+ Int_t numOfTracks;
+ for ( Int_t i=0;i< fPairMgr->GetPairs()->GetEntriesFast();i++ )
+ {
+ def = ( AliRsnPair * ) fPairMgr->GetPairs()->At ( i );
+ def->SetRsnMVEventBuffer ( fRsnMVEventBuffer );
+ for ( Int_t j=0;j<def->GetCutMgr()->GetEntriesFast() ;j++ )
+ {
+ event = fRsnMVEventBuffer->GetCurrentEvent();
+ numOfTracks = event->GetMultiplicity();
+// AliInfo ( Form ( "%d",event->GetMultiplicity() ) );
+
+ if ( numOfTracks>0 )
+ def->ProcessPair ( event ,fHist[i][j] ,j );
+ }
+ }
+
+}
+
+
+
+AliRsnEvent * AliRsnAnalysisAT::GetRsnMVEventFromInputType ( const Short_t & index )
+{
+ switch ( fInputType[index] )
+ {
+ case kAOD:
+ {
+ return GetRsnMVFromAOD ( index );
+ break;
+ }
+ case kESD:
+ {
+ AliWarning ( "Not Implemented Yet ..." );
+ return GetRsnMVFromESD ( index );
+ break;
+ }
+ case kESDMC:
+ {
+ AliWarning ( "Not Implemented Yet ..." );
+ return GetRsnMVFromESDMC ( index );
+ break;
+ }
+ case kMC:
+ AliWarning ( "Not Implemented Yet ..." );
+ return ( AliRsnEvent* ) 0x0;
+ break;
+ case kRSN:
+ {
+ return GetRsnMVFromRSN();
+ break;
+ }
+ default:
+ AliError ( "Type not supported ..." );
+ return ( AliRsnEvent* ) 0x0;
+ break;
+ }
+ return ( AliRsnEvent* ) 0x0;
+}
+
+void AliRsnAnalysisAT::PostEventProcess ( const Short_t & index )
+{
+ switch ( fInputType[index] )
+ {
+ case kAOD:
+ break;
+ case kESD:
+ break;
+ case kESDMC:
+ break;
+ case kMC:
+ break;
+ case kRSN:
+ {
+ if ( fRsnMVEventBuffer->GetDeleteBufferWhenReset() == kFALSE )
+ {
+ fRSN[index] = ( AliRsnEvent* ) fRsnMVEventBuffer->GetNextEvent();
+ SetBranchAddress ( 0 , "RsnEvents", &fRSN[index] );
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+}
+
+AliRsnEvent * AliRsnAnalysisAT::GetRsnMVFromAOD ( const Short_t & index )
+{
+
+ if ( !fAOD[index] ) { AliError ( "fAOD not available." ); return ( AliRsnEvent * ) 0x0; }
+
+
+// fRSN[0] = new AliRsnEvent();
+// fRSN[0]->Init();
+// fRSN[0]->BuildEvent ( fAOD[index] );
+// return fRSN[0];
+
+ return ( AliRsnEvent* ) 0x0;
+
+}
+
+AliRsnEvent * AliRsnAnalysisAT::GetRsnMVFromESD ( const Short_t & index )
+{
+ if ( !fESD[index] ) { AliError ( "fESD not available." ); return ( AliRsnEvent * ) 0x0; }
+
+// fRSN[0] = new AliRsnEvent();
+// fRSN[0]->Init();
+// fRSN[0]->BuildEvent ( fESD[index] );
+// return fRSN[0];
+
+ return ( AliRsnEvent* ) 0x0;
+}
+
+AliRsnEvent * AliRsnAnalysisAT::GetRsnMVFromESDMC ( const Short_t & index )
+{
+
+ 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; }
+
+// fRSN[0] = new AliRsnEvent();
+// fRSN[0]->Init();
+// fRSN[0]->BuildEvent ( fESD[index] ,mcHandler );
+// return fRSN[0];
+
+ return ( AliRsnEvent* ) 0x0;
+}
+
+AliRsnEvent * AliRsnAnalysisAT::GetRsnMVFromRSN ( const Short_t & index )
+{
+ AliRsnEvent *event = fRSN[index];
+ if ( fRsnMVEventBuffer->GetDeleteBufferWhenReset() == kTRUE )
+ {
+ event = ( AliRsnEvent * ) fRSN[index]->Clone();
+ }
+// AliInfo ( Form ( "%p %p",event,fRSN[index] ) );
+ return event;
+}
--- /dev/null
+#ifndef AliRsnAnalysisAT_h
+#define AliRsnAnalysisAT_h
+
+#include "AliRsnBaseAT.h"
+
+class AliRsnEvent;
+
+/**
+ @author Martin Vala <Martin.Vala@cern.ch>
+*/
+class AliRsnAnalysisAT : public AliRsnBaseAT
+{
+ public:
+ AliRsnAnalysisAT ( const char *name = "AliRsnAnalysisAT");
+
+ ~AliRsnAnalysisAT();
+
+ virtual void InitIOVars();
+ virtual void LocalInit();
+ virtual Bool_t Notify();
+ virtual void CreateOutputObjects();
+ virtual void Exec ( Option_t *option );
+ virtual void Terminate ( Option_t * );
+ virtual void Cleanup ();
+
+ private:
+ AliRsnPairMgr *fPairMgr;
+
+ TList *fOutList; // List of output
+ TH1F *fHist[100][100]; // output histograms
+
+ AliRsnEventBuffer *fRsnMVEventBuffer;
+
+ void ProcessEventAnalysis(AliRsnEvent *curEvent);
+ void PostEventProcess(const Short_t &index=0);
+ AliRsnEvent* GetRsnMVEventFromInputType(const Short_t &index=0);
+
+ AliRsnEvent* GetRsnMVFromAOD(const Short_t &index=0);
+ AliRsnEvent* GetRsnMVFromESD(const Short_t &index=0);
+ AliRsnEvent* GetRsnMVFromESDMC(const Short_t &index=0);
+ AliRsnEvent* GetRsnMVFromRSN(const Short_t &index=0);
+
+ ClassDef ( AliRsnAnalysisAT, 1 );
+};
+
+#endif
--- /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 AliRsnAnalysisSimple
+//-------------------------------------------------------------------------
+// This class is a manager to process one or more pair analysis with a
+// given event sample, specified as a TTree passed to this object.
+// Each single pair analysis must be defined with its specifications, like
+// histogram binning, cuts and everything else.
+// This class utiliy consists in defining a unique event sample which is
+// used for all pairs analysis, and all kinds of event mixing (if required).
+// All histograms computed in a single execution, are then saved into a file.
+// This object contains a two TObjArray's:
+// - one to contain single event pair analysis objects (signal, like-sign)
+// - one to contain all event-mixing pair analysis objects
+// When a new pair is added, it must be then specified in what container it
+// must be placed, in order to avoid meaningless results.
+//
+// author: A. Pulvirenti
+// email : alberto.pulvirenti@ct.infn.it
+//-------------------------------------------------------------------------
+
+#include <TH1.h>
+#include <TTree.h>
+#include <TFile.h>
+#include <TArray.h>
+#include <TClonesArray.h>
+
+#include "AliLog.h"
+#include "AliRsnPID.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnEventBuffer.h"
+#include "AliRsnPairSimple.h"
+#include "AliRsnAnalyzerSimple.h"
+#include "AliRsnAnalysisSimple.h"
+
+ClassImp(AliRsnAnalysisSimple)
+
+//_____________________________________________________________________________
+AliRsnAnalysisSimple::AliRsnAnalysisSimple(AliRsnAnalyzerSimple *ana, AliRsnPID *pid) :
+ TObject(),
+ fInitialized(kFALSE),
+ fStep(1000),
+ fTree(0x0),
+ fPID(pid),
+ fAnalyzer(ana)
+{
+//
+// Constructor
+// Initializes all pointers and collections to NULL.
+//
+
+ strcpy(fFileName, "default.root");
+}
+
+
+//_____________________________________________________________________________
+void AliRsnAnalysisSimple::Clear(Option_t *option)
+{
+//
+// Clear heap
+//
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisSimple::SetEventsTree(TTree *tree)
+{
+//
+// Set the tree containing the events to be processed.
+// 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()));
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnAnalysisSimple::Initialize()
+{
+//
+// Various initialization processes
+//
+ // check process objects
+ if (!fPID) {
+ AliError("PID not initialized");
+ return kFALSE;
+ }
+ if (!fAnalyzer) {
+ AliError("Analyzer not initialized");
+ return kFALSE;
+ }
+
+ // set reference to PID method to all pairs
+ AliRsnPairSimple *pair = 0;
+ TObjArrayIter pairIterator(fAnalyzer->GetPairs());
+ while ( (pair = (AliRsnPairSimple*)pairIterator.Next()) ) {
+ pair->SetPIDMethod(fPID->GetMethod());
+ }
+ if (fAnalyzer->GetMixPairs() && !fAnalyzer->GetMixPairs()->IsEmpty()) {
+ TObjArrayIter mixIterator(fAnalyzer->GetMixPairs());
+ while ( (pair = (AliRsnPairSimple*)mixIterator.Next()) ) {
+ pair->SetPIDMethod(fPID->GetMethod());
+ }
+ }
+
+ // initialize analyzer
+ fAnalyzer->Init();
+
+ // at the end, update flag for initialization
+ fInitialized = kTRUE;
+
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Stat_t AliRsnAnalysisSimple::Process()
+{
+//
+// Computes all invariant mass distributions defined in the AliRsnPair objects collected.
+// 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->Identify(event);
+ nPairs += fAnalyzer->Process(event);
+ }
+
+ return nPairs;
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisSimple::SaveOutput() const
+{
+//
+// Writes histograms in current directory
+//
+ TFile *file = TFile::Open(fFileName, "RECREATE");
+ AliRsnPairSimple *pair = 0;
+ TH1D *hist = 0;
+ TObjArrayIter pairIterator(fAnalyzer->GetPairs());
+ while ( (pair = (AliRsnPairSimple*)pairIterator.Next()) ) {
+ hist = pair->GetHistogram();
+ if (hist) hist->Write();
+ hist = pair->GetHistogramMC();
+ if (hist) hist->Write();
+ }
+ if (fAnalyzer->GetMixPairs() && !fAnalyzer->GetMixPairs()->IsEmpty()) {
+ TObjArrayIter mixIterator(fAnalyzer->GetMixPairs());
+ while ( (pair = (AliRsnPairSimple*)mixIterator.Next()) ) {
+ hist = pair->GetHistogram();
+ if (hist) hist->Write();
+ hist = pair->GetHistogramMC();
+ if (hist) hist->Write();
+ }
+ }
+ file->Close();
+}
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//-------------------------------------------------------------------------
+// Class AliRsnAnalysisSimple
+// Reconstruction and analysis of K* Rsn
+// ........................................
+// ........................................
+// ........................................
+// ........................................
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//-------------------------------------------------------------------------
+
+#ifndef AliRsnAnalysisSimple_H
+#define AliRsnAnalysisSimple_H
+
+#include "AliRsnPID.h"
+
+class TTree;
+class TArrayI;
+class TObjArray;
+class AliRsnPairSimple;
+class AliRsnPID;
+class AliRsnEventBuffer;
+class AliRsnAnalyzerSimple;
+
+class AliRsnAnalysisSimple : public TObject
+{
+public:
+
+ AliRsnAnalysisSimple(AliRsnAnalyzerSimple *ana = 0x0, AliRsnPID *pid = 0x0);
+ virtual ~AliRsnAnalysisSimple() {Clear();}
+ virtual void Clear(Option_t *option = "C");
+
+ /* setters */
+ void SetAnalyzer(AliRsnAnalyzerSimple *analyzer) {fAnalyzer = analyzer;}
+ void SetEventsTree(TTree *tree);
+ void SetFileName(char *fname) {strcpy(fFileName, fname);}
+ void SetStep(Int_t step) {fStep = step;}
+ void SetPID(AliRsnPID *pid) {fPID = pid;}
+
+ /* working routines */
+ Bool_t Initialize();
+ Stat_t Process();
+ void SaveOutput() const;
+
+private:
+
+ AliRsnAnalysisSimple(const AliRsnAnalysisSimple ©) :
+ TObject(copy),fInitialized(kFALSE),fStep(1000),fTree(0x0),fPID(0x0),fAnalyzer(0x0) { }
+ AliRsnAnalysisSimple& operator=(const AliRsnAnalysisSimple & /*copy*/) { return (*this); }
+
+ Bool_t fInitialized; // flag to check initialization
+ Int_t fStep; // progress step
+ Char_t fFileName[250]; // output file name
+ TTree *fTree; //! TTree of events
+ AliRsnPID *fPID; //! PID object
+ AliRsnAnalyzerSimple *fAnalyzer; //! analyzer
+
+ // Rsn analysis implementation
+ ClassDef(AliRsnAnalysisSimple,1)
+};
+
+#endif
--- /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 AliRsnAnalysisSimpleTask
+// ------------------------
+// Reader for conversion of ESD output into the internal format
+// used for resonance study.
+// ---
+// original author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// ---
+// adapted for Analysis Framework
+// by : R. Vernet (email: renaud.vernet@cern.ch)
+//----------------------------------------------------------------------------------
+
+#include <TChain.h>
+
+#include "AliLog.h"
+#include "AliVEvent.h"
+#include "AliMCEventHandler.h"
+#include "AliInputEventHandler.h"
+#include "AliAnalysisManager.h"
+
+#include "AliMCEvent.h"
+
+#include "AliRsnEvent.h"
+#include "AliRsnReader.h"
+#include "AliRsnPID.h"
+#include "AliRsnPairSimple.h"
+#include "AliRsnAnalyzerSimple.h"
+#include "AliRsnAnalysisSimpleTask.h"
+
+ClassImp(AliRsnAnalysisSimpleTask)
+
+//_____________________________________________________________________________
+AliRsnAnalysisSimpleTask::AliRsnAnalysisSimpleTask() :
+ AliAnalysisTask(),
+ fEvent(0x0),
+ fMC(0x0),
+ fReader(0x0),
+ fPID(0x0),
+ fAnalyzer(0x0),
+ fCurrEvent(0x0),
+ fHistograms(0x0)
+{
+//
+// Default constructor (not recommended)
+//
+}
+
+//_____________________________________________________________________________
+AliRsnAnalysisSimpleTask::AliRsnAnalysisSimpleTask(const char *name) :
+ AliAnalysisTask(name, ""),
+ fEvent(0x0),
+ fMC(0x0),
+ fReader(0x0),
+ fPID(0x0),
+ fAnalyzer(0x0),
+ fCurrEvent(0x0),
+ fHistograms(0x0)
+{
+//
+// Working constructor (recommended)
+//
+
+ DefineInput (0, TChain::Class());
+ DefineOutput (0, TList::Class());
+}
+
+//_____________________________________________________________________________
+AliRsnAnalysisSimpleTask::AliRsnAnalysisSimpleTask(const AliRsnAnalysisSimpleTask& obj) :
+ AliAnalysisTask(obj),
+ fEvent(0x0),
+ fMC(0x0),
+ fReader(obj.fReader),
+ fPID(obj.fPID),
+ fAnalyzer(obj.fAnalyzer),
+ fCurrEvent(0x0),
+ fHistograms(0x0)
+{
+//
+// Copy constructor (not recommended)
+//
+}
+
+//_____________________________________________________________________________
+AliRsnAnalysisSimpleTask& AliRsnAnalysisSimpleTask::operator=(const AliRsnAnalysisSimpleTask& /*obj*/)
+{
+//
+// Assignment operator (not recommended)
+//
+
+ AliInfo("Not implemented. Avoid using the assignment operator");
+ return *this;
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisSimpleTask::CreateOutputObjects()
+{
+//
+// 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;
+ }
+
+ // OpenFile (0);
+
+ // output histogram list
+ fHistograms = new TList(0);
+
+ // initialize analyzer
+ fAnalyzer->Init();
+
+ // store all histograms in the pairs into the list
+ TObjArray *array = fAnalyzer->GetPairs();
+ AliRsnPairSimple *pair;
+ if (array) {
+ TObjArrayIter iter(array);
+ while ( (pair = (AliRsnPairSimple*)iter.Next()) ) {
+ fHistograms->AddLast((TObject*)pair->GetHistogram());
+ fHistograms->AddLast((TObject*)pair->GetHistogramMC());
+ }
+ }
+ array = fAnalyzer->GetMixPairs();
+ if (array) {
+ TObjArrayIter iter(array);
+ while ( (pair = (AliRsnPairSimple*)iter.Next()) ) {
+ fHistograms->AddLast((TObject*)pair->GetHistogram());
+ fHistograms->AddLast((TObject*)pair->GetHistogramMC());
+ }
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisSimpleTask::ConnectInputData(Option_t *)
+{
+//
+// Connect the input data
+//
+
+ // connect ESD
+ AliInputEventHandler *inH = dynamic_cast<AliInputEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+ if (!inH) {
+ AliError("Could not get InputHandler");
+ }
+ else {
+ fEvent = inH->GetEvent();
+ }
+
+ // connect MC
+ AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*>((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
+ if (!mcH) {
+ AliError("Could not get MCInputHandler");
+ }
+ else {
+ fMC = mcH->MCEvent();
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisSimpleTask::Exec(Option_t */*option*/)
+{
+//
+// Loops on input container to store data of all tracks.
+// Uses the AliRsnReader methods to save them in the output.
+//
+
+ // check ESD and MC events
+ if (!fEvent) {
+ AliWarning("Event not available here");
+ return;
+ }
+ if (!fMC) {
+ AliWarning("MC event not available here");
+ return;
+ }
+
+ // clear previous event
+ if (!fCurrEvent) {
+ fCurrEvent = new AliRsnEvent;
+ fCurrEvent->Init();
+ }
+ else fCurrEvent->Clear();
+
+ // read event, identify
+ if (!fReader->Fill(fCurrEvent, fEvent, fMC)) AliWarning("Failed reading");
+ if (!fPID->Identify(fCurrEvent)) AliWarning("Failed PID");
+ AliInfo(Form("Collected %d tracks", fCurrEvent->GetMultiplicity()));
+
+ // process event with analyzer
+ fPID->Identify(fCurrEvent);
+ fAnalyzer->Process(fCurrEvent);
+
+ // post collected data
+ PostData (0, fHistograms);
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisSimpleTask::Terminate(Option_t */*option*/)
+{
+//
+// Terminate analysis
+//
+
+ AliDebug(1, "Terminating");
+ AliAnalysisTask::Terminate();
+}
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//----------------------------------------------------------------------------------
+// Class AliRsnAnalysisSimpleTask
+// ------------------------
+// Reader for conversion of ESD output into the internal format
+// used for resonance study.
+// ---
+// original author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// ---
+// adapted for Analysis Framework
+// by : R. Vernet (email: renaud.vernet@cern.ch)
+//----------------------------------------------------------------------------------
+
+#ifndef AliRsnAnalysisSimpleTask_H
+#define AliRsnAnalysisSimpleTask_H
+
+#include "AliAnalysisTask.h"
+
+class TList;
+class AliVEvent;
+class AliMCEvent;
+class AliRsnPID;
+class AliRsnReader;
+class AliRsnEvent;
+class AliRsnAnalyzerSimple;
+
+class AliRsnAnalysisSimpleTask : public AliAnalysisTask
+{
+public:
+
+ AliRsnAnalysisSimpleTask();
+ AliRsnAnalysisSimpleTask(const char *name);
+ virtual ~AliRsnAnalysisSimpleTask() { }
+
+ // Implementation of interface methods
+ virtual void ConnectInputData (Option_t *);
+ virtual void CreateOutputObjects();
+ virtual void Exec (Option_t *option);
+ virtual void Terminate(Option_t *option);
+
+ // setters
+ void SetReader(AliRsnReader *reader) {fReader = reader;}
+ void SetPID(AliRsnPID *pid) {fPID = pid;}
+ void SetAnalyzer(AliRsnAnalyzerSimple *analyzer) {fAnalyzer = analyzer;}
+
+private:
+
+ AliRsnAnalysisSimpleTask(const AliRsnAnalysisSimpleTask&);
+ AliRsnAnalysisSimpleTask& operator=(const AliRsnAnalysisSimpleTask&);
+
+ AliVEvent* fEvent; // input event
+ AliMCEvent* fMC; // corresponding MC event
+ AliRsnReader* fReader; // read manager
+ AliRsnPID* fPID; // particle identification manager
+ AliRsnAnalyzerSimple* fAnalyzer; // analyzer
+ AliRsnEvent* fCurrEvent; // current event pointer -> for moving among methods
+ TList* fHistograms; // list of output histograms
+
+ ClassDef(AliRsnAnalysisSimpleTask, 1); // implementation of RsnReader as ReaderTaskSE
+};
+
+#endif
--- /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 AliRsnAnalyzerSimple
+//
+// Implementation of the event processing which returns histograms of
+// invariant mass for resonances and backgrounds evaluation.
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//=========================================================================
+
+#include <TTree.h>
+#include <TFile.h>
+#include <TArray.h>
+#include <TClonesArray.h>
+
+#include "AliLog.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnEventBuffer.h"
+#include "AliRsnPairSimple.h"
+#include "AliRsnAnalyzerSimple.h"
+
+ClassImp(AliRsnAnalyzerSimple)
+
+//_____________________________________________________________________________
+AliRsnAnalyzerSimple::AliRsnAnalyzerSimple(Int_t bufferSize) :
+ TObject(),
+ fBufferSize(bufferSize),
+ fMixMultCut(10),
+ fMixVzCut(0.5),
+ fNMix(10),
+ fPairs(0x0),
+ fMixPairs(0x0),
+ fBuffer(0x0)
+{
+//
+// Constructor
+// Initializes all pointers and collections to NULL.
+//
+}
+
+
+//_____________________________________________________________________________
+void AliRsnAnalyzerSimple::Clear(Option_t *option)
+{
+//
+// Clear heap
+//
+ fPairs->Clear(option);
+ fMixPairs->Clear(option);
+ delete fBuffer;
+ fBuffer = 0;
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalyzerSimple::AddPair(AliRsnPairSimple *pair)
+{
+//
+// Add a pair of particle types to be analyzed.
+// Second argument tells if the added object is for event mixing.
+//
+ Bool_t mixing = pair->IsForMixing();
+ TObjArray* &target = mixing ? fMixPairs : fPairs;
+ if (!target) target = new TObjArray(0);
+ target->AddLast(pair);
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalyzerSimple::Init()
+{
+//
+// Initialize what needs to.
+//
+
+ // buffer
+ fBuffer = new AliRsnEventBuffer(fBufferSize, kFALSE);
+
+ // histograms
+ AliRsnPairSimple *pair = 0;
+ if (fPairs) {
+ TObjArrayIter pairIterator(fPairs);
+ while ( (pair = (AliRsnPairSimple*)pairIterator.Next()) ) pair->InitHistograms();
+ }
+ if (fMixPairs) {
+ TObjArrayIter mixIterator(fMixPairs);
+ while ( (pair = (AliRsnPairSimple*)mixIterator.Next()) ) pair->InitHistograms();
+ }
+}
+
+//_____________________________________________________________________________
+Stat_t AliRsnAnalyzerSimple::Process(AliRsnEvent *event)
+{
+//
+// Computes all invariant mass distributions defined in the AliRsnPair objects collected.
+// Depending on the kind of background evaluation method, computes also this one.
+//
+
+ // skip empty events
+ if (event->GetMultiplicity() < 1) return 0.0;
+
+ // create buffer if not already present
+ if (!fBuffer) Init();
+
+ // initialize output values and utility variables
+ Stat_t nPairs = 0;
+ AliRsnPairSimple *pair = 0x0;
+
+ // break here if NULL argument is passed
+ if (!event) {
+ AliError("NULL event passed");
+ return 0.0;
+ }
+
+ // loop over the collection of pair defs
+ if (fPairs) {
+ TObjArrayIter pairIterator(fPairs);
+ while ( (pair = (AliRsnPairSimple*)pairIterator.Next()) ) {
+ nPairs += pair->Process(event, event);
+ }
+ }
+ if (fMixPairs) {
+ // 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
+ TObjArrayIter mixIterator(fMixPairs);
+ while ( (pair = (AliRsnPairSimple*)mixIterator.Next()) ) {
+ nPairs += pair->Process(event, evmix);
+ nPairs += pair->Process(evmix, event);
+ }
+ count++;
+ }
+ }
+ }
+ }
+
+ return nPairs;
+}
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//=========================================================================
+// Class AliRsnAnalyzerSimple
+//
+// Implementation of the event processing which returns histograms of
+// invariant mass for resonances and backgrounds evaluation.
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//=========================================================================
+
+#ifndef AliRsnAnalyzerSimple_H
+#define AliRsnAnalyzerSimple_H
+
+#include "AliRsnPID.h"
+
+class TObjArray;
+class AliRsnPairSimple;
+class AliRsnEventBuffer;
+
+class AliRsnAnalyzerSimple : public TObject
+{
+public:
+
+ AliRsnAnalyzerSimple(Int_t bufferSize = 1000);
+ virtual ~AliRsnAnalyzerSimple() {Clear();}
+
+ // setters
+ void SetBufferSize(Int_t value) {fBufferSize = value;}
+ void SetMixMultiplicityCut(Int_t cut) {fMixMultCut = cut;}
+ void SetMixVzCut(Double_t cut) {fMixVzCut = cut;}
+ void SetNMix(Int_t value) {fNMix = value;}
+
+ // getters
+ TObjArray* GetPairs() {return fPairs;}
+ TObjArray* GetMixPairs() {return fMixPairs;}
+
+ // working routines
+ void Init();
+ virtual void Clear(Option_t *option = "C");
+ void AddPair(AliRsnPairSimple *pair);
+ Stat_t Process(AliRsnEvent *event);
+
+private:
+
+ AliRsnAnalyzerSimple(const AliRsnAnalyzerSimple ©) :
+ TObject(copy),fBufferSize(1000),
+ fMixMultCut(10),fMixVzCut(0.5),fNMix(10),
+ fPairs(0x0),fMixPairs(0x0),fBuffer(0x0) { }
+ AliRsnAnalyzerSimple& operator=(const AliRsnAnalyzerSimple & /*copy*/) { return (*this); }
+
+ Int_t fBufferSize; // size of buffer
+ Int_t fMixMultCut; // multiplicity cut for event mixing
+ Double_t fMixVzCut; // difference in VZ cut for event mixing
+ Int_t fNMix; // number of events for mixing
+
+ TObjArray *fPairs; //! collection of particle pairs to be read for 1-event analysis
+ TObjArray *fMixPairs; //! collection of particle pairs to be read for event-mixing
+ AliRsnEventBuffer *fBuffer; //! buffer for event mixing
+
+ // Rsn analyzer implementation
+ ClassDef(AliRsnAnalyzerSimple,1)
+};
+
+#endif
--- /dev/null
+#include "TChain.h"
+#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 "AliESDInputHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliAODInputHandler.h"
+
+#include "AliRsnBaseAT.h"
+
+
+ClassImp ( AliRsnBaseAT );
+
+//________________________________________________________________________
+AliRsnBaseAT::AliRsnBaseAT ( const char *name /*,Bool_t isSecondChain*/ )
+ : AliAnalysisTask ( name, "" ) /*,fIsSecondChain ( isSecondChain )*/
+{
+ InitIOVars ();
+ DefineInput ( 0, TChain::Class() );
+// if ( IsSecondChain() )
+// DefineInput ( 1, TChain::Class() );
+}
+
+void AliRsnBaseAT::InitIOVars ()
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+
+ fNumOfEvents=0;
+ for ( Int_t i=0;i<3;i++ )
+ {
+ fChain[i]=0;
+ fRSN[i] = 0;
+ fESD[i] = 0;
+ fAOD[i] = 0;
+ fInputType[i] = kRSN;
+ }
+
+ fAnalysisMgr=0;
+
+ AliDebug ( AliLog::kDebug, "->" );
+}
+
+Bool_t AliRsnBaseAT::Notify()
+{
+ return AliAnalysisTask::Notify();
+}
+
+//________________________________________________________________________
+void AliRsnBaseAT::ConnectInputData ( Option_t * )
+{
+ ConnectInputDataByInputType ( fInputType[0],0 );
+// if ( IsSecondChain() )
+// ConnectInputDataByInputType ( fInputType[1],1 );
+
+}
+
+void AliRsnBaseAT::ConnectInputDataByInputType ( EInputType type ,Short_t inputIndex )
+{
+ 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 )
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+ char ** address = ( char ** ) GetBranchAddress ( inputIndex, "RsnEvents" );
+ if ( address )
+ {
+ fRSN[inputIndex] = ( AliRsnEvent* ) ( *address );
+ }
+ else
+ {
+// fRSN[inputIndex] = new AliRsnEvent();
+ fRSN[inputIndex] = 0;
+ SetBranchAddress ( inputIndex, "RsnEvents", &fRSN[inputIndex] );
+ }
+ AliDebug ( AliLog::kDebug, "->" );
+}
+
+void AliRsnBaseAT::ConnectESD(Short_t inputIndex)
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+
+// fAnalysisMgr->SetInputEventHandler ( new AliESDInputHandler() );
+
+ 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)
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+
+// fAnalysisMgr->SetInputEventHandler ( new AliESDInputHandler() );
+// fAnalysisMgr->SetMCtruthEventHandler ( new AliMCEventHandler() );
+
+
+ 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)
+{
+ AliDebug ( AliLog::kDebug, "<-" );
+
+ // fAnalysisMgr->SetInputEventHandler ( new AliAODInputHandler());
+
+ 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, "->" );
+}
--- /dev/null
+#ifndef AliRsnBaseAT_cxx\r
+#define AliRsnBaseAT_cxx\r
+\r
+#include <TChain.h>\r
+\r
+#include "AliAnalysisTask.h"\r
+\r
+class AliAnalysisManager;\r
+\r
+class AliESDEvent;\r
+class AliAODEvent;\r
+class AliRsnEvent;\r
+\r
+\r
+class AliRsnBaseAT : public AliAnalysisTask\r
+{\r
+ public:\r
+ AliRsnBaseAT ( const char *name = "AliRsnBaseAT" );\r
+ virtual ~AliRsnBaseAT() {}\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 *option ) {;}\r
+ virtual void Terminate ( Option_t * ) {;}\r
+\r
+ void SetInputType (EInputType& theValue, Short_t inputIndex=0) { fInputType[inputIndex] = theValue; }\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
+ protected:\r
+ \r
+ Long64_t fNumOfEvents;\r
+\r
+ TChain *fChain[2]; // input chain\r
+ EInputType fInputType[2]; // input type\r
+\r
+ AliRsnEvent *fRSN[2]; // RsnMV event\r
+ AliESDEvent *fESD[2]; // ESD event\r
+ AliAODEvent *fAOD[2]; // AOD event\r
+\r
+ AliAnalysisManager *fAnalysisMgr; // pointer to current AnalysisMgr\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
+ ClassDef ( AliRsnBaseAT, 1 );\r
+};\r
+\r
+#endif\r
--- /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 AliRsnCut
+//
+// General implementation of a single cut strategy, which can be:
+// - a value contained in a given interval [--> IsBetween()]
+// - a value equal to a given reference [--> IsEqual() ]
+// In all cases, the reference value(s) is (are) given as data members
+// and each kind of cut requires a given value type (Int, UInt, Double),
+// but the cut check procedure is then automatized and chosen thanks to
+// an enumeration of the implemented cut types.
+// At the end, the user (or any other point which uses this object) has
+// to use the method IsSelected() to check if this cut has been passed.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//=========================================================================
+
+#include "AliLog.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnMCInfo.h"
+#include "AliRsnPairParticle.h"
+#include "AliRsnPairDef.h"
+#include "AliRsnCut.h"
+
+const Double_t AliRsnCut::fgkDSmallNumber = 1e-100;
+const Double_t AliRsnCut::fgkDBigNumber = 1e10;
+const Int_t AliRsnCut::fgkIBigNumber = 32767;
+
+ClassImp (AliRsnCut)
+
+//________________________________________________________________________________________________________________
+AliRsnCut::AliRsnCut() :
+ TNamed(),
+ fDMin(-fgkDBigNumber),
+ fDMax( fgkDBigNumber),
+ fIMin(-fgkIBigNumber),
+ fIMax( fgkIBigNumber),
+ fUIMin(0),
+ fUIMax(2 * (UInt_t)fgkIBigNumber),
+ fRsnCutType (kLastCutType),
+ fRsnCutVarType (kDouble_t)
+{
+//
+// Constructor
+//
+}
+
+//________________________________________________________________________________________________________________
+AliRsnCut::AliRsnCut (const char *name, const char *title, ERsnCutType type) :
+ TNamed (name,title),
+ fDMin(-fgkDBigNumber),
+ fDMax( fgkDBigNumber),
+ fIMin(-fgkIBigNumber),
+ fIMax( fgkIBigNumber),
+ fUIMin(0),
+ fUIMax(2 * (UInt_t)fgkIBigNumber),
+ fRsnCutType (type),
+ fRsnCutVarType (kDouble_t)
+{
+//
+// Constructor with arguments but not limits
+//
+}
+
+//________________________________________________________________________________________________________________
+AliRsnCut::AliRsnCut (const char *name, const char *title, ERsnCutType 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),
+ fRsnCutType (type),
+ fRsnCutVarType (kDouble_t)
+{
+//
+// Constructor with arguments and limits
+//
+}
+
+//________________________________________________________________________________________________________________
+AliRsnCut::AliRsnCut (const char * name, const char * title, ERsnCutType 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),
+ fRsnCutType (type),
+ fRsnCutVarType (kInt_t)
+{
+//
+// Constructor with arguments and limits
+//
+}
+
+//________________________________________________________________________________________________________________
+AliRsnCut::AliRsnCut (const char * name, const char * title, ERsnCutType type, UInt_t min, UInt_t max) :
+ TNamed (name,title),
+ fDMin(-fgkDBigNumber),
+ fDMax( fgkDBigNumber),
+ fIMin(-fgkIBigNumber),
+ fIMax( fgkIBigNumber),
+ fUIMin(min),
+ fUIMax(max),
+ fRsnCutType (type),
+ fRsnCutVarType (kUInt_t)
+{
+//
+// Constructor with arguments and limits
+//
+}
+
+//________________________________________________________________________________________________________________
+AliRsnCut::~ AliRsnCut()
+{
+//
+// Destructor.
+// Does absolutely nothing.
+//
+}
+
+//________________________________________________________________________________________________________________
+Bool_t AliRsnCut::IsBetween (const Double_t & theValue)
+{
+//
+// Interval check.
+// Question: "Is the argument included between fDMin and fDMax?"
+// (not implemented for integer values because usually it is not used with them)
+//
+ return ((theValue >= fDMin) && (theValue <= fDMax));
+}
+
+//________________________________________________________________________________________________________________
+Bool_t AliRsnCut::IsEqual (const Int_t &theValue)
+{
+//
+// Reference check.
+// Question: "Is the argument equal to fIMin?" (fIMax is assumed never used)
+//
+ return (theValue == fIMin);
+}
+
+//________________________________________________________________________________________________________________
+Bool_t AliRsnCut::IsEqual (const UInt_t &theValue)
+{
+//
+// Reference check.
+// Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
+//
+ return (theValue == fUIMin);
+}
+
+//________________________________________________________________________________________________________________
+Bool_t AliRsnCut::IsEqual (const Double_t &theValue)
+{
+//
+// Reference check.
+// Question: "Is the argument reasonably close to fDMin?" (fDMax is assumed never used)
+// Here, "reasonably close" means that the difference is smaller than the
+// 'fgkSmallNumber' global static data member of this class
+//
+ return (TMath::Abs (theValue - fDMin) < fgkDSmallNumber);
+}
+
+//________________________________________________________________________________________________________________
+void AliRsnCut::SetCutValues (ERsnCutType type, const Double_t & theValue, const Double_t & theValue2)
+{
+//
+// (Re)assignment of cut values
+//
+ fRsnCutType = type;
+ fDMin = theValue;
+ fDMax = theValue2;
+}
+
+//________________________________________________________________________________________________________________
+void AliRsnCut::SetCutValues (ERsnCutType type, const Int_t& theValue, const Int_t& theValue2)
+{
+//
+// (Re)assignment of cut values
+//
+ fRsnCutType = type;
+ fIMin = theValue;
+ fIMax = theValue2;
+}
+
+//________________________________________________________________________________________________________________
+void AliRsnCut::SetCutValues (ERsnCutType type, const UInt_t& theValue, const UInt_t& theValue2)
+{
+//
+// (Re)assignment of cut values
+//
+ fRsnCutType = type;
+ fUIMin = theValue;
+ fUIMax = theValue2;
+}
+
+//________________________________________________________________________________________________________________
+Bool_t AliRsnCut::IsSelected(ECutSetType type, AliRsnDaughter *daughter)
+{
+//
+// Core of the whole class.
+// According to the kind of cut selected in the enumeration,
+// checks the cut taking the right values from the argument.
+// Depending on the second argument type, only some cuts are checked
+// (the ones for that type of object), otherwise kTRUE is returned in order
+// not to act as a cleaning factor for an AND with other cuts.
+//
+ 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;
+ }
+
+ switch (fRsnCutType) {
+ case kMomentum:
+ return IsBetween (daughter->P());
+ case kTransMomentum:
+ return IsBetween (daughter->Pt());
+ case kEta:
+ return IsBetween (daughter->Eta());
+ case kRadialImpactParam:
+ return IsBetween (daughter->Vt());
+ 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:
+ return IsEqual((Int_t)daughter->PIDType());
+ /*
+ 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());
+ */
+ }
+
+ return kTRUE;
+}
+
+//________________________________________________________________________________________________________________
+Bool_t AliRsnCut::IsSelected(ECutSetType 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 (fRsnCutType) {
+ 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 kRestMomentum:
+ return CheckRestMomentum(pair);
+ case kIsPdgEqual:
+ return pair->IsPDGEqual();
+ case kIsLabelEqual:
+ return pair->IsLabelEqual();
+ case kIsTruePair:
+ return pair->IsTruePair(fIMin);
+ }
+
+ return kTRUE;
+}
+
+//________________________________________________________________________________________________________________
+void AliRsnCut::PrintAllValues()
+{
+ AliInfo (Form ("fRsnCutType=%d fRsnCutVarType=%d",fRsnCutType,fRsnCutVarType));
+ AliInfo (Form ("fDMin=%.2e fDMax=%.2e",fDMin,fDMax));
+ AliInfo (Form ("fIMin=%d fIMax=%d",fIMin,fIMax));
+ AliInfo (Form ("fUIMin=%d fUIMax=%d",fUIMin,fUIMax));
+}
+
+//________________________________________________________________________________________________________________
+Bool_t AliRsnCut::CheckRestMomentum(AliRsnPairParticle *pair)
+{
+//
+// Check the cut on daughter momenta in rest reference frame of mother
+//
+
+ Double_t beta = pair->GetP() / pair->GetMass();
+ Double_t gamma = 1. / TMath::Sqrt(1. - beta*beta);
+
+ Double_t p1labP = 0.0, p1labT, p1restP, p1restTot;
+ p1labP += pair->GetDaughter(0)->Px() * pair->GetP(0);
+ p1labP += pair->GetDaughter(0)->Py() * pair->GetP(1);
+ p1labP += pair->GetDaughter(0)->Pz() * pair->GetP(2);
+ p1labP /= pair->GetP();
+
+ p1labT = TMath::Sqrt(pair->GetDaughter(0)->P2() - p1labP*p1labP);
+
+ p1restP = gamma*p1labP - beta*gamma*pair->GetDaughter(0)->E();
+
+ p1restTot = TMath::Sqrt(p1restP*p1restP + p1labT*p1labT);
+
+ return IsBetween(p1restTot);
+}
+
+
+
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//=========================================================================
+// Class AliRsnCut
+//
+// General implementation of a single cut strategy, which can be:
+// - a value contained in a given interval [--> IsBetween()]
+// - a value equal to a given reference [--> IsEqual() ]
+// In all cases, the reference value(s) is (are) given as data members
+// and each kind of cut requires a given value type (Int, UInt, Double),
+// but the cut check procedure is then automatized and chosen thanks to
+// an enumeration of the implemented cut types.
+// At the end, the user (or any other point which uses this object) has
+// to use the method IsSelected() to check if this cut has been passed.
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//=========================================================================
+
+#ifndef ALIRSNCUT_H
+#define ALIRSNCUT_H
+
+#include "TNamed.h"
+
+class AliRsnDaughter;
+class AliRsnPairParticle;
+class AliRsnPairDef;
+
+class AliRsnCut : public TNamed
+{
+public:
+ enum ERsnCutType
+ {
+ kMomentum = 0,
+ kTransMomentum,
+ kEta,
+ kRadialImpactParam,
+ kMomentumMC,
+ kTransMomentumMC,
+ kEtaMC,
+ kRestMomentum,
+ kNSigma,
+ kNSigmaCalculate,
+ kStatus,
+ kIsPdgEqual,
+ kIsLabelEqual,
+ kIsTruePair,
+ kChargePos,
+ kChargeNeg,
+ kPIDType,
+ kLastCutType
+ };
+
+ enum ERsnCutVarType
+ {
+ kDouble_t = 0,
+ kInt_t,
+ kUInt_t
+ };
+
+ enum ECutSetType
+ {
+ kParticle = 0,
+ kPair,
+ kMixEventFinderCut,
+ kLastCutSetIndex
+ };
+
+ AliRsnCut();
+ AliRsnCut (const char *name, const char *title, ERsnCutType type);
+ AliRsnCut (const char *name, const char *title, ERsnCutType type, Double_t min, Double_t max = 1e-100);
+ AliRsnCut (const char *name, const char *title, ERsnCutType type, Int_t min, Int_t max = 32767);
+ AliRsnCut (const char *name, const char *title, ERsnCutType type, UInt_t min, UInt_t max = 65534);
+
+ ~AliRsnCut();
+
+ void SetCutValues (ERsnCutType type, const Double_t& theValue, const Double_t& theValue2);
+ void SetCutValues (ERsnCutType type, const Int_t& theValue, const Int_t& theValue2);
+ void SetCutValues (ERsnCutType type, const UInt_t& theValue, const UInt_t& theValue2);
+
+ Bool_t IsSelected (ECutSetType type, AliRsnDaughter *daughter);
+ Bool_t IsSelected (ECutSetType type, AliRsnPairParticle *pair);
+
+ void PrintAllValues();
+
+ Bool_t IsBetween (const Double_t &theValue);
+ Bool_t IsEqual (const Int_t &theValue);
+ Bool_t IsEqual (const UInt_t &theValue);
+ Bool_t IsEqual (const Double_t &theValue);
+
+private:
+
+ Bool_t CheckRestMomentum(AliRsnPairParticle *pair);
+
+ 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
+
+ ERsnCutType fRsnCutType; // cut type
+ ERsnCutVarType fRsnCutVarType; // 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
--- /dev/null
+#include "AliLog.h"
+
+#include "AliRsnDaughter.h"
+#include "AliRsnCutSet.h"
+#include "AliRsnCutMgr.h"
+
+ClassImp ( AliRsnCutMgr )
+
+AliRsnCutMgr::AliRsnCutMgr()
+ : TNamed("defaultName","default Tilte")
+{
+ for ( Int_t i=0 ;i<AliRsnCut::kLastCutSetIndex ;i++ )
+ {
+ fCutSets[i] = 0;
+ }
+
+}
+
+AliRsnCutMgr::AliRsnCutMgr ( const char * name, const char * title )
+ : TNamed ( name,title )
+{
+
+ for ( Int_t i=0 ;i<AliRsnCut::kLastCutSetIndex ;i++ )
+ {
+ fCutSets[i] = 0 ;
+ }
+
+}
+
+AliRsnCutMgr::~AliRsnCutMgr()
+{
+ for ( Int_t i=0 ;i<AliRsnCut::kLastCutSetIndex ;i++ )
+ {
+ delete fCutSets[i];
+ }
+
+}
+
+void AliRsnCutMgr::SetCutSet ( AliRsnCut::ECutSetType type, AliRsnCutSet* cutset )
+{
+ if ( !fCutSets[type] )
+ fCutSets[type] = ( AliRsnCutSet* ) cutset->Clone() ;
+ AliDebug (AliLog::kDebug ,Form ( "DatasetName %s",fCutSets[type]->GetName() ) );
+}
+
+
+Bool_t AliRsnCutMgr::IsSelected ( AliRsnCut::ECutSetType type,TObject *obj )
+{
+ AliDebug ( AliLog::kDebug,"<-" );
+
+ if (!fCutSets[type]) return kTRUE;
+
+ switch ( type )
+ {
+ case AliRsnCut::kParticle:
+// AliDebug ( AliLog::kDebug,"kParticle" );
+ return fCutSets[type]->IsSelected (type, ( AliRsnDaughter * ) obj );
+ break;
+ case AliRsnCut::kPair:
+// AliInfo ( Form("%p" ,fCutSets[type]));
+ return fCutSets[type]->IsSelected (type, ( AliRsnPairParticle * ) obj );
+ break;
+ default:
+ AliWarning ( "Wrong ECutSetType selected." );
+ return kTRUE;
+ break;
+
+ }
+ return kTRUE;
+}
--- /dev/null
+#ifndef ALIRSNMVCUTMGR_H
+#define ALIRSNMVCUTMGR_H
+
+#include "TNamed.h"
+#include "TObjArray.h"
+
+#include "AliRsnCut.h"
+// #include "AliRsnCutSet.h"
+// class AliRsnCut;
+class AliRsnCutSet;
+
+/**
+ @author Martin Vala <Martin.Vala@cern.ch>
+*/
+class AliRsnCutMgr : public TNamed
+{
+ public:
+
+// enum ECutSetType {
+// kParticle= 0,
+// kPair,
+// kMixEventFinderCut,
+// kLastCutSetIndex
+// };
+
+
+ AliRsnCutMgr();
+ AliRsnCutMgr(const char *name, const char* title);
+
+ ~AliRsnCutMgr();
+
+ void SetCutSet(AliRsnCut::ECutSetType type,AliRsnCutSet* cutset);
+ AliRsnCutSet* GetCutSet(AliRsnCut::ECutSetType type) { return fCutSets[type];}
+
+ Bool_t IsSelected(AliRsnCut::ECutSetType type,TObject *obj);
+
+ private:
+
+ AliRsnCutSet *fCutSets[AliRsnCut::kLastCutSetIndex];
+
+ ClassDef ( AliRsnCutMgr,1 );
+};
+
+#endif
--- /dev/null
+#include "AliLog.h"
+
+#include "AliRsnCut.h"
+#include "AliRsnExpression.h"
+
+#include "AliRsnCutSet.h"
+
+ClassImp ( AliRsnCutSet )
+
+AliRsnCutSet::AliRsnCutSet()
+ : TNamed(),fNumOfCuts ( 0 ),
+ fCutScheme ( "" ),
+ fCutSchemeIndexed ( "" ),
+ fBoolValues ( 0 ),fIsScheme ( kFALSE )
+{
+ fBoolValues = new Bool_t[1];
+// fExpression = new AliRsnExpression ( fCutSchemeIndexed );
+ fExpression = 0;
+ AliRsnExpression::sCutSet = this;
+}
+
+AliRsnCutSet::AliRsnCutSet ( TString name )
+ : TNamed ( name,name ),fNumOfCuts ( 0 ),
+ fCutScheme ( "" ),
+ fCutSchemeIndexed ( "" ),
+ fBoolValues ( 0 ),fIsScheme ( kFALSE )
+{
+ 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 ),
+ fIsScheme ( copy.fIsScheme ),
+ fExpression ( copy.fExpression )
+{
+ AliRsnExpression::sCutSet = this;
+}
+
+AliRsnCutSet::~AliRsnCutSet()
+{
+ delete fExpression;
+ delete [] fBoolValues;
+}
+
+void AliRsnCutSet::AddCut ( AliRsnCut * cut )
+{
+ AliDebug ( AliLog::kDebug,"<-" );
+ fCuts.Add ( cut );
+ fNumOfCuts++;
+ if ( fBoolValues )
+ delete fBoolValues;
+ fBoolValues = new Bool_t[fNumOfCuts];
+ for ( Int_t i=0;i<fNumOfCuts ; i++ )
+ {
+ fBoolValues[i] = kTRUE;
+ }
+
+ AliDebug ( AliLog::kDebug,Form ( "%d",fCuts.GetEntriesFast() ) );
+ AliDebug ( AliLog::kDebug,"->" );
+}
+
+void AliRsnCutSet::ShowCuts ( )
+{
+// AliRsnCut *cut;
+// for ( Int_t i=0; i<fCuts.GetEntriesFast() ;i++ )
+// {
+// cut = ( AliRsnCut* ) fCuts.At ( i );
+// AliInfo ( Form ( "%s (\"%s\") [%.2f - %.2f]",cut->GetName(),cut->GetTitle(),cut->GetMin(),cut->GetMax() ) );
+// }
+}
+
+Bool_t AliRsnCutSet::IsSelected ( AliRsnCut::ECutSetType type, AliRsnDaughter *daughter )
+{
+ if ( !fNumOfCuts )
+ return kTRUE;
+
+ Bool_t boolReturn = kTRUE;
+ AliRsnCut *cut;
+ for ( Int_t i=0; i<fNumOfCuts ;i++ )
+ {
+ cut = ( AliRsnCut* ) fCuts.At ( i );
+ fBoolValues[i] = cut->IsSelected ( type,daughter );
+// AliInfo(Form("%s %d",cut->GetName(),fBoolValues[i]));
+ }
+
+ if ( fIsScheme )
+ boolReturn = Passed();
+
+ return boolReturn;
+}
+
+Bool_t AliRsnCutSet::IsSelected ( AliRsnCut::ECutSetType type, AliRsnPairParticle * pair )
+{
+ if ( !fNumOfCuts )
+ return kTRUE;
+
+ Bool_t boolReturn = kTRUE;
+ AliRsnCut *cut;
+ for ( Int_t i=0; i<fNumOfCuts ;i++ )
+ {
+ cut = ( AliRsnCut* ) fCuts.At ( i );
+ fBoolValues[i] = cut->IsSelected (type,pair );
+// AliInfo(Form("%s %d",cut->GetName(),fBoolValues[i]));
+ }
+
+ if ( fIsScheme )
+ boolReturn = Passed();
+
+ return boolReturn;
+}
+
+
+void AliRsnCutSet::SetCutScheme ( const TString & theValue )
+{
+ AliDebug ( AliLog::kDebug,"<-" );
+ fCutScheme = theValue;
+ SetCutSchemeIndexed ( theValue );
+ fIsScheme = kTRUE;
+ AliDebug ( AliLog::kDebug,"->" );
+}
+
+
+void AliRsnCutSet::SetCutSchemeIndexed ( TString theValue )
+{
+ AliDebug ( AliLog::kDebug,"<-" );
+// fCutSchemeIndexed = theValue;
+ fCutSchemeIndexed = GetCutSchemeIndexed();
+ AliDebug ( AliLog::kDebug,"->" );
+}
+
+Int_t AliRsnCutSet::GetIndexByCutName ( TString s )
+{
+ AliRsnCut *cut;
+ for ( Int_t i=0 ;i< fCuts.GetEntriesFast() ;i++ )
+ {
+ cut = ( AliRsnCut* ) fCuts.At ( i );
+// if ( !cut->GetName().CompareTo ( s ) )
+ if ( !s.CompareTo ( cut->GetName() ) )
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+Bool_t AliRsnCutSet::Passed()
+{
+ AliRsnExpression::sCutSet = this;
+ if ( !fExpression )
+ {
+ fExpression = new AliRsnExpression ( fCutSchemeIndexed );
+ AliDebug ( AliLog::kDebug,"fExpression was created." );
+ }
+ return fExpression->Value ( *GetCuts() );
+}
+
+Bool_t AliRsnCutSet::IsValidScheme()
+{
+ return ( ! ( ShowCutScheme().Contains ( "Error" ) ) );
+}
+
+TString AliRsnCutSet::ShowCutScheme()
+{
+ return fExpression->Unparse();
+}
+
+Int_t AliRsnCutSet::TestExpression ( TString opt )
+{
+// AliRsnCut *cut1 = new AliRsnCut ( "aaa","aaa" );
+// cut1->SetCutValues ( AliRsnCut::kEsdPt,0.0,1.0 );
+// AliRsnCut *cut2 = new AliRsnCut ( "bbb","bbb" );
+// cut2->SetCutValues ( AliRsnCut::kEsdPt,1.,2.0 );
+// AliRsnCut *cut3 = new AliRsnCut ( "ccc","ccc" );
+// cut3->SetCutValues ( AliRsnCut::kEsdPt,2.0,3.0 );
+//
+// AliRsnCutSet* set = new AliRsnCutSet ( "setOne" );
+// set->AddCut ( cut1 );
+// set->AddCut ( cut2 );
+// set->AddCut ( cut3 );
+//
+// set->SetCutScheme ( "(aaa&!(ccc))&(bbb&!(ccc))" );
+//
+// set->ShowCuts ();
+
+ return 0;
+}
+
+void AliRsnCutSet::PrintSetInfo()
+{
+
+
+ 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 ( Int_t 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 ==============" );
+
+}
+
+TString AliRsnCutSet::GetCutSchemeIndexed()
+{
+ AliDebug ( AliLog::kDebug,"<-" );
+ TString str ( fCutScheme );
+ AliDebug ( AliLog::kDebug,Form ( "Num of cuts %d",fCuts.GetEntriesFast() ) );
+ AliRsnCut *cut;
+ for ( Int_t i=0; i<fCuts.GetEntriesFast();i++ )
+ {
+ cut = ( AliRsnCut* ) fCuts.At ( i );
+ str.ReplaceAll ( cut->GetName(),Form ( "%d",i ) );
+ }
+ AliDebug ( AliLog::kDebug,"->" );
+ return str;
+}
+
--- /dev/null
+#ifndef ALIRSNCUTSET_H
+#define ALIRSNCUTSET_H
+
+#include <TNamed.h>
+#include <TObjArray.h>
+
+#include "AliRsnCut.h"
+// class AliRsnCut;
+class AliRsnCutMgr;
+
+class AliRsnDaughter;
+class AliRsnExpression;
+class AliRsnPairParticle;
+
+class AliRsnCutSet : public TNamed
+{
+
+ public:
+ AliRsnCutSet();
+ AliRsnCutSet ( TString name );
+ AliRsnCutSet ( const AliRsnCutSet © );
+
+ ~AliRsnCutSet();
+
+ void AddCut ( AliRsnCut* cut );
+// void SetCutScheme ( TString sheme ) {fCutScheme = sheme;}
+
+ void ShowCuts();
+ Int_t GetIndexByCutName ( TString s );
+ Bool_t Passed();
+ Bool_t IsValidScheme();
+ TString ShowCutScheme();
+ Int_t TestExpression ( TString opt="short" );
+ void PrintSetInfo();
+
+ Bool_t IsSelected (AliRsnCut::ECutSetType type, AliRsnDaughter *daughter );
+ Bool_t IsSelected (AliRsnCut::ECutSetType type, AliRsnPairParticle *pair );
+// Bool_t IsSelected ( AliRsnEffectiveParticle *pair );
+// Bool_t IsSelected(TObject*obj);
+
+ 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 );
+ TString GetCutScheme() const { return fCutScheme; }
+
+ void SetCutSchemeIndexed ( TString theValue );
+ TString GetCutSchemeIndexed();
+
+ TObjArray *GetCuts() { return &fCuts; }
+
+
+ private:
+ TObjArray fCuts; // array of cuts
+ Int_t fNumOfCuts; // number of cuts
+ TString fCutScheme; // cut scheme
+ TString fCutSchemeIndexed; // cut scheme indexed
+
+ Bool_t *fBoolValues; //[fNumOfCuts]
+ Bool_t fIsScheme; // is scheme
+ AliRsnExpression *fExpression; // pointer to AliRsnExpression
+
+ ClassDef ( AliRsnCutSet,1 );
+};
+
+#endif
* provided "as is" without express or implied warranty. *
**************************************************************************/
-// ***********************
-// *** AliRsnDaughter ****
-// ***********************
-//
+//=========================================================================
+// Class AliRsnDaughter
+//
+//
// Light-weight 'track' object into an internal format used
// for further steps of resonance analysis.
// Provides converters from all kinds of input track type
// Contains also a facility to compute invariant mass of a pair.
//
// author: A. Pulvirenti --- email: alberto.pulvirenti@ct.infn.it
+//=========================================================================
#include <Riostream.h>
#include "AliMCParticle.h"
#include "AliRsnPID.h"
-#include "AliRsnParticle.h"
+#include "AliRsnMCInfo.h"
#include "AliRsnDaughter.h"
ClassImp(AliRsnDaughter)
fCharge(0),
fFlags(0),
fPIDType(AliRsnPID::kUnknown),
- fPIDProb(0.0),
fMass(0.0),
- fParticle(0x0)
+ fMCInfo(0x0)
{
-//=========================================================
+//
// Default constructor.
// Initializes all data-members with meaningless values.
-//=========================================================
+//
Int_t i;
for (i = 0; i < AliRsnPID::kSpecies; i++) {
fV[i] = 0.0;
}
fPIDWeight[i] = 0.0;
+ fPIDProb[i] = 0.0;
}
}
fCharge(copy.fCharge),
fFlags(copy.fFlags),
fPIDType(copy.fPIDType),
- fPIDProb(copy.fPIDProb),
fMass(copy.fMass),
- fParticle(0x0)
+ fMCInfo(0x0)
{
-//=========================================================
+//
// Copy constructor.
-//=========================================================
+//
Int_t i;
for (i = 0; i < AliRsnPID::kSpecies; i++) {
fV[i] = copy.fV[i];
}
fPIDWeight[i] = copy.fPIDWeight[i];
+ fPIDProb[i] = copy.fPIDProb[i];
}
- // initialize particle object
+ // initialize particle object
// only if it is present in the template object
- if (copy.fParticle) fParticle = new AliRsnParticle(*(copy.fParticle));
+ if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
}
//_____________________________________________________________________________
-AliRsnDaughter::AliRsnDaughter(AliESDtrack *track) :
+AliRsnDaughter::AliRsnDaughter(AliESDtrack *track, Bool_t useTPC) :
AliVParticle(),
fIndex(-1),
fLabel(-1),
fCharge(0),
fFlags(0),
fPIDType(AliRsnPID::kUnknown),
- fPIDProb(0.0),
fMass(0.0),
- fParticle(0x0)
+ fMCInfo(0x0)
{
-//=========================================================
+//
// Constructor to get data from an ESD track.
-//=========================================================
+//
- Adopt(track);
+ Int_t i;
+ for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
+ Adopt(track, useTPC);
}
//_____________________________________________________________________________
fCharge(0),
fFlags(0),
fPIDType(AliRsnPID::kUnknown),
- fPIDProb(0.0),
fMass(0.0),
- fParticle(0x0)
+ 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);
}
fCharge(0),
fFlags(0),
fPIDType(AliRsnPID::kUnknown),
- fPIDProb(0.0),
fMass(0.0),
- fParticle(0x0)
+ 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);
}
//_____________________________________________________________________________
AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter ©)
{
-//=========================================================
+//
// Assignment operator.
// Works like the copy constructor and returns a reference
// to the initialized object for which it is called.
-//=========================================================
-
+//
+
fIndex = copy.fIndex;
fLabel = copy.fLabel;
fCharge = copy.fCharge;
fV[i] = copy.fV[i];
}
fPIDWeight[i] = copy.fPIDWeight[i];
+ fPIDProb[i] = copy.fPIDProb[i];
}
-
+
fPIDType = copy.fPIDType;
- fPIDProb = copy.fPIDProb;
fMass = copy.fMass;
-
- // initialize particle object
+
+ // initialize particle object
// only if it is present in the template object;
// otherwise, it is just cleared and not replaced with anything
- if (fParticle) {
- delete fParticle;
- fParticle = 0x0;
+ if (fMCInfo) {
+ delete fMCInfo;
+ fMCInfo = 0x0;
}
- if (copy.fParticle) fParticle = new AliRsnParticle(*(copy.fParticle));
+ if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
return (*this);
}
//_____________________________________________________________________________
AliRsnDaughter::~AliRsnDaughter()
{
-//=========================================================
+//
// Destructor
-//=========================================================
+//
- if (fParticle) {
- delete fParticle;
- fParticle = 0;
+ if (fMCInfo) {
+ delete fMCInfo;
+ fMCInfo = 0;
}
}
//_____________________________________________________________________________
void AliRsnDaughter::SetPIDWeight(Int_t i, Double_t value)
{
-//=========================================================
+//
// I the argument 'i' is in the correct range,
// sets the i-th PID weight to 'value'
-//=========================================================
+//
if (i >= 0 && i < AliRsnPID::kSpecies) fPIDWeight[i] = value;
else {
}
}
+//_____________________________________________________________________________
+void AliRsnDaughter::SetPIDProb(Int_t i, Double_t value)
+{
+//
+// I the argument 'i' is in the correct range,
+// 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));
+ }
+}
//_____________________________________________________________________________
void AliRsnDaughter::SetPIDWeights(const Double_t *pid)
{
-//=========================================================
+//
// Sets ALL PID weights at once.
// The passed array is supposed to have at least as many
// slots as the number of allowed particle species.
-//=========================================================
+//
Int_t i;
for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDWeight[i] = pid[i];
//_____________________________________________________________________________
-Bool_t AliRsnDaughter::Adopt(AliESDtrack* esdTrack)
+Bool_t AliRsnDaughter::Adopt(AliESDtrack* esdTrack, Bool_t useTPCInnerParam)
{
-//=========================================================
+//
// Copies data from an AliESDtrack into "this":
// - charge sign
// - momentum
// - point of closest approach to primary vertex
// - ESD pid weights
// In case of errors returns kFALSE, otherwise kTRUE.
-//=========================================================
+//
if (!esdTrack) {
AliError("Passed NULL object: nothing done");
return kFALSE;
}
-
+
// copy momentum and vertex
- esdTrack->GetPxPyPz(fP);
- esdTrack->GetXYZ(fV);
+ 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];
- esdTrack->GetESDpid(pid);
+ 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;
}
//_____________________________________________________________________________
Bool_t AliRsnDaughter::Adopt(AliAODTrack* aodTrack)
{
-//=========================================================
+//
// Copies data from an AliAODtrack into "this":
// - charge sign
// - momentum
// - point of closest approach to primary vertex
// - ESD pid weights
// In case of errors returns kFALSE, otherwise kTRUE.
-//=========================================================
+//
if (!aodTrack) {
AliError("Passed NULL object: nothing done");
return kFALSE;
}
-
+
// copy momentum and vertex
fP[0] = aodTrack->Px();
fP[1] = aodTrack->Py();
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 sign
fCharge = aodTrack->Charge();
//_____________________________________________________________________________
Bool_t AliRsnDaughter::Adopt(AliMCParticle *mcParticle)
{
-//=========================================================
+//
// Copies data from a MCParticle into "this":
// - charge sign
// - momentum
// - true PDG code
// - mother
// 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();
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);
fCharge = 0;
return kFALSE;
}
-
+
// identify track perfectly using PDG code
fPIDType = AliRsnPID::InternalType(pdg);
- fPIDProb = 1.0;
fMass = AliRsnPID::ParticleMass(fPIDType);
-
+
// flags and PID weights make no sense with MC tracks
fFlags = 0;
for (pdg = 0; pdg < AliRsnPID::kSpecies; pdg++) fPIDWeight[pdg] = 0.0;
fPIDWeight[fPIDType] = 1.0;
-
+
// copy other MC info (mother PDG code cannot be retrieved here)
- InitParticle(particle);
+ InitMCInfo(particle);
return kTRUE;
}
//_____________________________________________________________________________
void AliRsnDaughter::Print(Option_t *option) const
{
-//=========================================================
+//
// Prints the values of data members, using the options:
// - P --> momentum
// - V --> DCA vertex
// - F --> flags
// - I --> identification (PID, probability and mass)
// - W --> PID weights
-// - M --> Montecarlo (from AliRsnParticle)
+// - M --> Montecarlo (from AliRsnMCInfo)
// - ALL --> All oprions switched on
//
// Index and label are printed by default.
-//=========================================================
+//
TString opt(option);
opt.ToUpper();
-
+
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("I") || opt.Contains("ALL")) {
cout << ".......PID : " << AliRsnPID::ParticleName(fPIDType) << endl;
- cout << ".......PID probability : " << fPIDProb << endl;
+ if (fPIDType > 0 && fPIDType < AliRsnPID::kSpecies) {
+ cout << ".......PID probability : " << fPIDProb[fPIDType] << endl;
+ }
cout << ".......Mass : " << fMass << endl;
}
if (opt.Contains("W") || opt.Contains("ALL")) {
cout << endl;
}
if (opt.Contains("M") || opt.Contains("ALL")) {
- if (fParticle) {
- cout << ".......PDG code : " << fParticle->PDG() << endl;
- cout << ".......Mother (label) : " << fParticle->Mother() << endl;
- cout << ".......Mother (PDG code): " << fParticle->MotherPDG() << endl;
+ 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;
}
}
-
//_____________________________________________________________________________
-AliRsnDaughter AliRsnDaughter::Sum(AliRsnDaughter t1, AliRsnDaughter t2)
+void AliRsnDaughter::InitMCInfo()
{
-//=========================================================
-// Creates an AliRsnDaughter object composing momenta
-// of the particles passed as arguments.
-// The vector momentum of the returned object is
-// the sum of the ones of the arguments.
-// The mass of the object is set to the invariant mass
-// computed from the relativistic sum of the 4-momenta
-// of the two arguments.
-// Finally, if both arguments have the same 'fMother'
-// (when this MC information is available), it is set
-// also as the 'fMother' of the returned object, together
-// with its PDG code.
-//=========================================================
-
- // create a 'default' new AliRsnDaughter
- AliRsnDaughter out;
-
- // define the momentum of the sum as the
- // relativistic sum of 4-momenta of arguments
- Double_t etot = t1.E() + t2.E();
- Double_t pxTot = t1.Px() + t2.Px();
- Double_t pyTot = t1.Py() + t2.Py();
- Double_t pzTot = t1.Pz() + t2.Pz();
- Double_t mass = TMath::Sqrt(etot*etot - pxTot*pxTot - pyTot*pyTot - pzTot*pzTot);
- out.SetM(mass);
- out.SetP(pxTot, pyTot, pzTot);
-
- // if both arguments have MC info, it is used here
- // to check if they (in the truth MC) are daughters
- // of the same resonance and, if this is the case,
- // details of that resonance are set into the
- // 'fParticle' object of the sum
- Int_t mum1, mum2;
- if (t1.GetParticle() && t2.GetParticle()) {
- out.InitParticle();
- mum1 = t1.GetParticle()->Mother();
- mum2 = t2.GetParticle()->Mother();
- if (mum1 == mum2 && mum1 >= 0) {
- out.SetLabel(mum1);
- out.GetParticle()->SetPDG(t1.GetParticle()->MotherPDG());
- }
- }
-
- return out;
-}
-
-
-//_____________________________________________________________________________
-void AliRsnDaughter::InitParticle()
-{
-//=========================================================
+//
// Initializes the particle object with default constructor.
-//=========================================================
+//
- fParticle = new AliRsnParticle;
+ fMCInfo = new AliRsnMCInfo;
}
//_____________________________________________________________________________
-Bool_t AliRsnDaughter::InitParticle(TParticle *particle)
+Bool_t AliRsnDaughter::InitMCInfo(TParticle *particle)
{
-//=========================================================
+//
// Copies data from an MC particle into the object which
// contains all MC details taken from kinematics info.
// If requested by second argument, momentum and vertex
// of the Particle are copied into the 'fP' and 'fV'
// data members, to simulate a perfect reconstruction.
-// If something goes wrong, returns kFALSE,
+// If something goes wrong, returns kFALSE,
// otherwise returns kTRUE.
-//=========================================================
+//
// retrieve the TParticle object pointed by this MC track
if (!particle) {
AliError("Passed NULL particle object");
return kFALSE;
}
-
+
// initialize object if not initialized yet
- if (fParticle) delete fParticle;
- fParticle = new AliRsnParticle;
- fParticle->Adopt(particle);
+ if (fMCInfo) delete fMCInfo;
+ fMCInfo = new AliRsnMCInfo;
+ fMCInfo->Adopt(particle);
return kTRUE;
}
-
//_____________________________________________________________________________
-Bool_t AliRsnDaughter::InitParticle(AliMCParticle *mcParticle)
+Bool_t AliRsnDaughter::InitMCInfo(AliMCParticle *mcParticle)
{
-//=========================================================
+//
// Copies data from an MC particle into the object which
// contains all MC details taken from kinematics info.
// If requested by second argument, momentum and vertex
// of the Particle are copied into the 'fP' and 'fV'
// data members, to simulate a perfect reconstruction.
-// If something goes wrong, returns kFALSE,
+// If something goes wrong, returns kFALSE,
// otherwise returns kTRUE.
-//=========================================================
+//
// retrieve the TParticle object pointed by this MC track
TParticle *particle = mcParticle->Particle();
- return InitParticle(particle);
+ return InitMCInfo(particle);
}
* See cxx source for full Copyright notice *
**************************************************************************/
-// ***********************
-// *** AliRsnDaughter ****
-// ***********************
-//
-// Light-weight 'track' object into an internal format used
-// for further steps of resonance analysis.
-// Provides converters from all kinds of input track type
-// (ESD, AOD and MC).
-// Contains also a facility to compute invariant mass of a pair.
+//=============================================================================
+// Class AliRsnDaughter
+//
+// Light-weight 'track' AOD object which contains all required track details
+// which are used for resonance analysis.
+// Provides converters from all kinds of input track type: ESD, AOD and MC.
//
// author: A. Pulvirenti --- email: alberto.pulvirenti@ct.infn.it
+//=============================================================================
#ifndef ALIRSNDAUGHTER_H
#define ALIRSNDAUGHTER_H
class AliAODTrack;
class AliMCParticle;
-class AliRsnParticle;
+class AliRsnMCInfo;
class AliRsnDaughter : public AliVParticle
{
-public:
+ public:
AliRsnDaughter();
- AliRsnDaughter(const AliRsnDaughter ©);
- AliRsnDaughter(AliESDtrack *track);
- 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);
+ 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 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 P2() const {return Px() *Px() + Py() *Py() + Pz() *Pz();}
+ virtual Double_t P() const {return TMath::Sqrt (P2());}
virtual Double_t Px() const {return fP[0];}
virtual Double_t Py() const {return fP[1];}
virtual Double_t Pz() const {return fP[2];}
- virtual Double_t Pt() const {return TMath::Sqrt(Px()*Px() + Py()*Py());}
+ virtual Double_t 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 Vt() 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 Vt() 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);}
// 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;}
AliRsnPID::EType PIDType() const {return fPIDType;}
- Double_t PIDProb() {return fPIDProb;}
- void SetPIDType(AliRsnPID::EType type) {fPIDType = type;}
- void SetPIDProb(Double_t value) {fPIDProb = value;}
- void SetPIDWeight(Int_t i, Double_t value);
- void SetPIDWeights(const Double_t *pid);
+ const Double_t* PIDProb() const {return fPIDProb;}
+ void SetPIDType (AliRsnPID::EType type) {fPIDType = type;}
+ void SetPIDProb (Int_t i, Double_t value);
+ void SetPIDWeight (Int_t i, Double_t value);
+ void SetPIDWeights (const Double_t *pid);
// 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);}
// information getters from objects
- Bool_t Adopt(AliESDtrack *track);
- Bool_t Adopt(AliAODTrack *track);
- Bool_t Adopt(AliMCParticle *track);
+ Bool_t Adopt (AliESDtrack *track, 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;}
- void SetIndex(Int_t value) {fIndex = value;}
- void SetLabel(Int_t value) {fLabel = value;}
+ Int_t Index() const {return fIndex;}
+ Int_t Label() const {return fLabel;}
+ void SetIndex (Int_t value) {fIndex = value;}
+ void SetLabel (Int_t value) {fLabel = value;}
// Utilities
- void Print(Option_t *option = "ALL") const;
- static AliRsnDaughter Sum(AliRsnDaughter t1, AliRsnDaughter t2);
- AliRsnParticle *GetParticle() {return fParticle;}
- void InitParticle();
- Bool_t InitParticle(TParticle *particle);
- Bool_t InitParticle(AliMCParticle *mcParticle);
+ void Print (Option_t *option = "ALL") const;
+ void InitMCInfo();
+ Bool_t InitMCInfo (TParticle *particle);
+ Bool_t InitMCInfo (AliMCParticle *mcParticle);
+
+ AliRsnMCInfo* GetMCInfo() const { return fMCInfo; }
-private:
+ private:
Int_t fIndex; // index of source object (ESD/AOD/MC) in its collection
Int_t fLabel; // label assigned to the track (act. by GEANT3)
Double_t fV[3]; // DCA vertex (x, y, z)
AliRsnPID::EType fPIDType; // assigned PID
- Double_t fPIDProb; // probability related to assigned PID
+ Double_t fPIDProb[AliRsnPID::kSpecies]; // probability related to assigned PID
Double_t fPIDWeight[AliRsnPID::kSpecies]; // PID weights
Double_t fMass; // mass (defined by PID)
- AliRsnParticle *fParticle; // reference to particle object (if any)
+ AliRsnMCInfo *fMCInfo; // reference to particle object (if any)
- ClassDef(AliRsnDaughter, 3)
+ ClassDef (AliRsnDaughter, 3);
};
#endif
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-
-//-------------------------------------------------------------------------
-// Class AliRsnEvent
-// -------------------
-// Simple collection of reconstructed tracks
-// selected from an ESD event
-// to be used for analysis.
-// .........................................
-//
-// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
-//-------------------------------------------------------------------------
-#include <Riostream.h>
+//
+// *** Class AliRsnEvent ***
+//
+// A container for a collection of AliRsnDaughter objects from an event.
+// Contains also the primary vertex, useful for some cuts.
+// In order to retrieve easily the tracks which have been identified
+// as a specific type and charge, there is an array of indexes which
+// allows to avoid to loop on all tracks and have only the neede ones.
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
-#include <TString.h>
-#include <TRefArray.h>
-#include <TClonesArray.h>
+#include <Riostream.h>
#include "AliLog.h"
-#include "AliESDtrack.h"
-#include "AliAODTrack.h"
-#include "AliRsnDaughter.h"
+#include "AliRsnDaughter.h"
#include "AliRsnEvent.h"
+#include "AliRsnMCInfo.h"
-ClassImp(AliRsnEvent)
+ClassImp (AliRsnEvent)
//_____________________________________________________________________________
AliRsnEvent::AliRsnEvent() :
- fSource(kUnknown),
- fPVx(0.0),
- fPVy(0.0),
- fPVz(0.0),
- fTracks(0x0),
- fPos(0x0),
- fNeg(0x0)
+ TNamed ("rsnEvent", ""),
+ fPVx (0.0),
+ fPVy (0.0),
+ fPVz (0.0),
+ fTracks (0x0),
+ fNoPID(0x0),
+ fPerfectPID (0x0),
+ fRealisticPID (0x0)
{
-//=========================================================
-// Default constructor
+//
+// Default constructor
// (implemented but not recommended for direct use)
-//=========================================================
-
- Int_t i;
- for (i = 0; i <= AliRsnPID::kSpecies; i++) {
- fPosID[i] = 0x0;
- fNegID[i] = 0x0;
- }
+//
}
//_____________________________________________________________________________
-AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) :
- TObject((TObject)event),
- fSource(event.fSource),
- fPVx(event.fPVx),
- fPVy(event.fPVy),
- fPVz(event.fPVz),
- fTracks(0x0),
- fPos(0x0),
- fNeg(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)
{
-//=========================================================
+//
// Copy constructor.
-// Creates new instances of all collections
-// to store a copy of all objects.
-//=========================================================
-
- // initialize arrays
- Init();
-
- // duplcate entries
- AliRsnDaughter *track = 0;
- TObjArrayIter iter(event.fTracks);
- while ( (track = (AliRsnDaughter*)iter.Next()) ) {
- AliRsnDaughter *ref = AddTrack(*track);
- if (!ref) AliWarning(Form("Problem occurred when copying track #%d", fTracks->IndexOf(ref)));
- }
-
- // fill PID arrays
- FillPIDArrays();
+// Copies all the tracks from the argument's collection
+// to this' one, and then recreates the PID index arrays,
+// trusting on the PID informations in the copied tracks.
+//
+
+ // during track copy, counts how many faults happen
+ Int_t errors = Fill (event.fTracks);
+ if (errors) AliWarning (Form ("%d errors occurred in copy", errors));
+
+ // fill PID index arrays
+ // FillPIDArrays();
+
+ if (event.fNoPID) fNoPID = new AliRsnPIDIndex(*(event.fNoPID));
+ if (event.fPerfectPID) fPerfectPID = new AliRsnPIDIndex(*(event.fPerfectPID));
+ if (event.fRealisticPID) fRealisticPID = new AliRsnPIDIndex(*(event.fRealisticPID));
}
//_____________________________________________________________________________
-AliRsnEvent& AliRsnEvent::operator=(const AliRsnEvent &event)
+AliRsnEvent& AliRsnEvent::operator= (const AliRsnEvent &event)
{
-//=========================================================
-// Assignment operator.
-// Creates new instances of all collections
-// to store a copy of all objects.
-//=========================================================
-
- // copy source info
- fSource = event.fSource;
-
+//
+// 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;
-
- // initialize with size of argument
- Init();
- // loop on collection of argument's tracks and store a copy here
- AliRsnDaughter *track = 0;
- TObjArrayIter iter(event.fTracks);
- while ( (track = (AliRsnDaughter*)iter.Next()) ) {
- AliRsnDaughter *ref = AddTrack(*track);
- if (!ref) AliWarning(Form("Problem occurred when copying track #%d", fTracks->IndexOf(ref)));
- }
-
+ // 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();
-
- // return the newly created object
+ // 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);
}
//_____________________________________________________________________________
AliRsnEvent::~AliRsnEvent()
{
-//=========================================================
+//
// Destructor.
-// Deletes the collection objects.
-// If statements are present because if the event is
-// destroyed before that any track is added to it, then
-// its collection classes will not be initialized.
-//=========================================================
-
+// Deletes the TClonesArray, after clearing its content.
+// Other memory-allocating arrays are cleared by their
+// destructor, which is automatically called from here.
+//
+
Clear();
-
if (fTracks) delete fTracks;
- if (fPos) delete fPos;
- if (fNeg) delete fNeg;
-
- Int_t i;
- for (i = 0; i <= AliRsnPID::kSpecies; i++) {
- if (fPosID[i]) delete fPosID[i];
- if (fNegID[i]) delete fNegID[i];
- }
}
//_____________________________________________________________________________
void AliRsnEvent::Init()
{
-//=========================================================
-// Initialize arrays
-//=========================================================
-
- fTracks = new TClonesArray("AliRsnDaughter", 0);
- fTracks->BypassStreamer(kFALSE);
- fPos = new TRefArray;
- fNeg = new TRefArray;
-
- Int_t i;
- for (i = 0; i <= AliRsnPID::kSpecies; i++) {
- fPosID[i] = new TRefArray;
- fNegID[i] = new TRefArray;
- }
+//
+// Initialize TClonesArray data-member.
+//
+
+ fTracks = new TClonesArray ("AliRsnDaughter", 1);
+ //fTracks->BypassStreamer (kFALSE);
}
//_____________________________________________________________________________
-AliRsnDaughter* AliRsnEvent::AddTrack(AliRsnDaughter track)
+void AliRsnEvent::Clear (Option_t* /*option*/)
{
-//=========================================================
-// Stores a track into the array and proper references.
-//=========================================================
-
+//
+// Empties the collections (does not delete the objects).
+// The track collection is emptied only at the end.
+// Since some objects could be uninitialized, some
+// "if" statement are used.
+//
+
+ if (fTracks) fTracks->Delete();
+ delete fNoPID;
+ fNoPID = 0x0;
+ delete fPerfectPID;
+ fPerfectPID = 0x0;
+ delete fRealisticPID;
+ fRealisticPID = 0x0;
+}
+
+//_____________________________________________________________________________
+AliRsnDaughter* AliRsnEvent::AddTrack (AliRsnDaughter track)
+{
+//
+// Stores a new track into the array and returns
+// a reference pointer to it (which is NULL in case of errors).
+//
+
Int_t nextIndex = fTracks->GetEntriesFast();
TClonesArray &tracks = (*fTracks);
- AliRsnDaughter *copy = new (tracks[nextIndex]) AliRsnDaughter(track);
- if (!copy) return 0x0;
- if (copy->Charge() > 0) {
- fPos->Add(copy);
- return copy;
- }
- else if (copy->Charge() < 0) {
- fNeg->Add(copy);
- return copy;
- }
- else {
- return 0x0;
+ AliRsnDaughter *copy = new (tracks[nextIndex]) AliRsnDaughter (track);
+ return copy;
+}
+
+//_____________________________________________________________________________
+AliRsnDaughter* AliRsnEvent::GetTrack(Int_t index)
+{
+//
+// Returns one track in the collection
+// given the absolute index in the global TClonesArray
+//
+ return (AliRsnDaughter*) fTracks->UncheckedAt (index);
+}
+
+//_____________________________________________________________________________
+TArrayI* AliRsnEvent::GetCharged (Char_t sign)
+{
+//
+// Returns an array with the indexes of all tracks with a given charge
+// (arg can be '+' or '-'), irrespective of its PID.
+// When the argument is wrong, a NULL pointer is returned.
+//
+ if (fNoPID) return fNoPID->GetTracksArray(sign, AliRsnPID::kUnknown);
+ return 0x0;
+}
+
+//_____________________________________________________________________________
+TArrayI * AliRsnEvent::GetTracksArray
+(AliRsnPID::EMethod pidtype, Char_t sign, AliRsnPID::EType type)
+{
+//
+// Returns an array of indexes of all tracks in this event
+// which match the charge sign and PID type in the arguments,
+// according to one of the allowed PID methods (perfect or realistic).
+// It retrieves this array from the AliRsnPIDIndex data members.
+// If the arguments are wrong a NULL pointer is returned.
+//
+
+ switch (pidtype) {
+ case AliRsnPID::kRealistic:
+ if (fRealisticPID) {
+ return fRealisticPID->GetTracksArray (sign, type);
+ }
+ break;
+ case AliRsnPID::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;
}
//_____________________________________________________________________________
-void AliRsnEvent::Clear(Option_t* /*option*/)
+void AliRsnEvent::FillPIDArrays()
{
-//=========================================================
-// Empties the collections (does not delete the objects).
-// The track collection is emptied only at the end.
-// Again, since the objects could be uninitialized, some
-// if statement are used.
-//=========================================================
-
- if (fPos) fPos->Delete();
- if (fNeg) fNeg->Delete();
-
- Int_t i;
- for (i = 0; i <= AliRsnPID::kSpecies; i++) {
- if (fPosID[i]) fPosID[i]->Delete();
- if (fNegID[i]) fNegID[i]->Delete();
+//
+// Initializes and fills the AliRsnPIDIndex objects containing
+// arrays of indexes for each possible charge and PID type.
+// This method is the unique way to do this, for safety reasons.
+//
+
+ if (fNoPID) delete fNoPID;
+ if (fPerfectPID) delete fPerfectPID;
+ if (fRealisticPID) delete fRealisticPID;
+ fNoPID = new AliRsnPIDIndex;
+ fPerfectPID = new AliRsnPIDIndex;
+ fRealisticPID = new AliRsnPIDIndex;
+
+ // loop on tracks and create references
+ 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();
+ 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 (fTracks) fTracks->Delete();
+
+ // 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
-// contained track, usind the Dump method of the track.
+// contained track.
// The options are passed to AliRsnDaughter::Print().
// Look at that method to understand option values.
-//=========================================================
+//
cout << "...Multiplicity : " << fTracks->GetEntries() << endl;
cout << "...Primary vertex : " << fPVx << ' ' << fPVy << ' ' << fPVz << endl;
-
- TObjArrayIter iter(fTracks);
+
+ TObjArrayIter iter (fTracks);
AliRsnDaughter *d = 0;
- while ( (d = (AliRsnDaughter*)iter.Next()) ) {
- cout << "....Track #" << fTracks->IndexOf(d) << endl;
- d->Print(option);
+ while ((d = (AliRsnDaughter*) iter.Next())) {
+ cout << "....Track #" << fTracks->IndexOf (d) << endl;
+ d->Print (option);
}
}
//_____________________________________________________________________________
-Int_t AliRsnEvent::GetMultiplicity() const
+Int_t AliRsnEvent::GetMultiplicity() const
{
-//=========================================================
+//
// Get number of all tracks
-//=========================================================
-
+//
+
if (!fTracks) return 0;
return fTracks->GetEntries();
}
//_____________________________________________________________________________
-Int_t AliRsnEvent::GetNPos() const
+Int_t AliRsnEvent::GetNCharged (Char_t sign)
{
-//=========================================================
-// Get number of positive tracks
-//=========================================================
-
- if (!fPos) return 0;
- return fPos->GetEntries();
-}
+//
+// Get number of charged tracks
+//
-//_____________________________________________________________________________
-Int_t AliRsnEvent::GetNNeg() const
-{
-//=========================================================
-// Get number of negative tracks
-//=========================================================
-
- if (!fNeg) return 0;
- return fNeg->GetEntries();
+ Int_t icharge;
+ icharge = ChargeIndex (sign);
+ if (icharge < 0) return 0;
+ TArrayI *charged = GetCharged(sign);
+ if (!charged) return 0;
+ return charged->GetSize();
}
//_____________________________________________________________________________
-TRefArray* AliRsnEvent::GetTracks(Char_t sign, AliRsnPID::EType refType)
+Int_t AliRsnEvent::Fill (TObjArray *array)
{
-//=========================================================
-// Returns the particle collection specified in argument.
-// Arguments :
-// 1) sign of particle ('+' or '-')
-// 2) PID of particle (from AliRsnPID::EType)
-//=========================================================
-
- if (sign == '+') {
- if (refType >= AliRsnPID::kElectron && refType <= AliRsnPID::kSpecies) {
- return fPosID[refType];
- }
- else {
- AliError(Form("Index %d out of range", refType));
- return 0x0;
- }
- }
- else if (sign == '-') {
- if (refType >= AliRsnPID::kElectron && refType <= AliRsnPID::kSpecies) {
- return fNegID[refType];
- }
- else {
- AliError(Form("Index %d out of range", refType));
- return 0x0;
+//
+// Fills the data-member TClonesArray of tracks with
+// the ones stored in the array passed as argument.
+// If this data-member is already present, it is cleared.
+// Returns the number of tracks which raised problems
+// while attempting to add them. Zero is the best.
+//
+
+ // clear the array if it is already instantiated,
+ // create if otherwise
+ if (fTracks) fTracks->Delete();
+ else Init();
+
+ // copy argument entries into data-member
+ Int_t errors = 0;
+ AliRsnDaughter *track = 0;
+ TObjArrayIter iter (array);
+ while ((track = (AliRsnDaughter*) iter.Next())) {
+ AliRsnDaughter *ref = AddTrack (*track);
+ if (!ref) {
+ AliWarning (Form ("Problem occurred when copying track #%d from passed array", array->IndexOf (track)));
+ errors++;
}
}
- else {
- AliError(Form("Character '%c' not recognized as charge sign", sign));
- return 0x0;
- }
+
+ return errors;
}
//_____________________________________________________________________________
-void AliRsnEvent::FillPIDArrays()
+Int_t AliRsnEvent::ChargeIndex (Char_t sign) const
+//
+// Returns the array index corresponding to charge
+// 0 for positive, 1 for negative
+//
{
-//=========================================================
-// Initializes and fills all the TRefArrays containing
-// references to particles identified as each available
-// PID type (from AliRsnPID).
-// This method is the unique way to do this, because it
-// cannot be assumed that the track PID is known when
-// it is added to this event by AddTrack.
-// Of course, if tracks have not been identified, this
-// method will do nothing and all tracks will be placed
-// in the TRefArray of 'Unknown' particles and the
-// GetTracks() method will not work properly.
-//=========================================================
-
- // clear arrays if they are present
- // initialize them if they are still 0x0
- Int_t i;
- for (i = 0; i <= AliRsnPID::kSpecies; i++) {
- if (fPosID[i]) fPosID[i]->Delete(); else fPosID[i] = new TRefArray;
- if (fNegID[i]) fNegID[i]->Delete(); else fNegID[i] = new TRefArray;
- }
-
- // loop on tracks and create references
- Short_t charge;
- AliRsnPID::EType type;
- AliRsnDaughter *track = 0;
- TObjArrayIter iter(fTracks);
- while ( (track = (AliRsnDaughter*)iter.Next()) ) {
- charge = track->Charge();
- type = track->PIDType();
- i = (Int_t)type;
- if (charge > 0) {
- fPosID[i]->Add(track);
- }
- else if (charge < 0) {
- fNegID[i]->Add(track);
- }
- else {
- AliError("Found particle with ZERO charge!!!");
- }
+ if (sign == '+') return 0;
+ else if (sign == '-') return 1;
+ else {
+ AliError (Form ("Character '%c' not recognized as charge sign", sign));
+ return -1;
}
}
-
/* $Id$ */
-//-------------------------------------------------------------------------
-// Class AliRsnEvent
-// Simple collection of reconstructed tracks, selected from an ESD event
-//
-// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
-//-------------------------------------------------------------------------
+//
+// *** Class AliRsnEvent ***
+//
+// A container for a collection of AliRsnDaughter objects from an event.
+// Contains also the primary vertex, useful for some cuts.
+// In order to retrieve easily the tracks which have been identified
+// as a specific type and charge, there is an array of indexes which
+// allows to avoid to loop on all tracks and have only the neede ones.
+//
+// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+// M. Vala (email: martin.vala@cern.ch)
+//
#ifndef ALIRSNEVENT_H
#define ALIRSNEVENT_H
-class TTree;
-class TParticle;
-class TRefArray;
-class TClonesArray;
-
-class AliESDtrack;
-class AliAODTrack;
class AliRsnDaughter;
+#include <TNamed.h>
+#include <TArrayI.h>
+#include <TClonesArray.h>
#include "AliRsnPID.h"
+#include "AliRsnPIDIndex.h"
-class AliRsnEvent : public TObject
+class AliRsnEvent : public TNamed
{
-public:
-
- enum ESource {
- kUnknown = 0,
- kESD,
- kAOD,
- kMC
- };
-
+ public:
+
AliRsnEvent();
- AliRsnEvent(const AliRsnEvent& copy);
- AliRsnEvent& operator=(const AliRsnEvent& copy);
+ AliRsnEvent (const AliRsnEvent& copy);
+ AliRsnEvent& operator= (const AliRsnEvent& copy);
virtual ~AliRsnEvent();
// Array management
void Init();
- AliRsnDaughter* AddTrack(AliRsnDaughter track);
- void Clear(Option_t *option = "");
- void Print(Option_t *option = "") const;
- TClonesArray* GetAllTracks() {return fTracks;}
- TRefArray* GetTracks(Char_t sign, AliRsnPID::EType type);
- TRefArray* GetCharged(Char_t sign) {if (sign=='+') return fPos; else if (sign=='-') return fNeg; else return 0x0;}
+ void Clear (Option_t *option = "");
+ AliRsnDaughter* AddTrack (AliRsnDaughter track);
+ AliRsnDaughter* GetTrack (Int_t index);
+ TClonesArray* GetTracks() {return fTracks;}
+ TArrayI* GetCharged (Char_t sign);
+ TArrayI* GetTracksArray (AliRsnPID::EMethod pidtype, Char_t sign, AliRsnPID::EType type);
void FillPIDArrays();
+ 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 GetPrimaryVertex(Double_t* &v) {GetPrimaryVertex(v[0], v[1], v[2]);}
- 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 SetPrimaryVertex(Double_t* &v) {SetPrimaryVertex(v[0], v[1], v[2]);}
+ 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;}
// Multiplicity
Int_t GetMultiplicity() const;
- Int_t GetNPos() const;
- Int_t GetNNeg() const;
-
- // Source type
- void SetSource(ESource source) {fSource = source;}
- ESource GetSource() {return fSource;}
-
-private:
-
- ESource fSource; // type of source event
-
- Double_t fPVx; // position of
- Double_t fPVy; // primary
- Double_t fPVz; // vertex
-
- TClonesArray *fTracks; // collection of particles
- TRefArray *fPos; // ref array to all positive particles
- TRefArray *fNeg; // ref array to all negative particles
- TRefArray *fPosID[AliRsnPID::kSpecies + 1]; // ref array to pos particles of each PID
- TRefArray *fNegID[AliRsnPID::kSpecies + 1]; // ref array to pos particles of each PID
-
- ClassDef(AliRsnEvent,1);
+ Int_t GetNCharged (Char_t sign);
+
+ private:
+
+ Int_t ChargeIndex (Char_t sign) const;
+ Int_t Fill (TObjArray *array);
+
+ Double_t fPVx; // position of
+ Double_t fPVy; // primary
+ Double_t fPVz; // vertex
+
+ TClonesArray *fTracks; // collection of particles
+
+ AliRsnPIDIndex *fNoPID; // array index only for charged tracks
+ AliRsnPIDIndex *fPerfectPID; // array index for perfect PID
+ AliRsnPIDIndex *fRealisticPID; // array index for realistic PID (largest prob)
+
+ ClassDef (AliRsnEvent, 2);
};
#endif
--- /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 AliRsnEventBuffer
+//
+// Implements a temporary buffer of many AliRsnEvent objects
+// which is useful for event mixing.
+//
+// author: Martin Vala (Martin.Vala@cern.ch)
+// revised by: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include "AliLog.h"
+#include "AliRsnEventBuffer.h"
+
+ClassImp (AliRsnEventBuffer)
+
+//_____________________________________________________________________________
+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;
+}
+
+//_____________________________________________________________________________
+AliRsnEventBuffer::~AliRsnEventBuffer()
+{
+//
+// Destructor.
+// Actually does nothing.
+//
+
+ //ClearBuffer();
+}
+
+//_____________________________________________________________________________
+void AliRsnEventBuffer::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;
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnEventBuffer::ResetIndex()
+{
+//
+// Resets the index for accessing events in buffer
+//
+ fEventsBufferIndex = -1;
+ if (fDeleteBufferWhenReset == kTRUE) ClearBuffer();
+}
+
+//_____________________________________________________________________________
+void AliRsnEventBuffer::AddEvent (AliRsnEvent * event)
+{
+//
+// Insert a new event in the buffer.
+// Since the buffer has a fixed size, when the last index is reached,
+// 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);
+}
+
+//_____________________________________________________________________________
+AliRsnEvent* AliRsnEventBuffer::GetCurrentEvent()
+{
+//
+// Returns the current event in the buffer
+//
+ return GetEvent(fEventsBufferIndex);
+}
+
+//_____________________________________________________________________________
+AliRsnEvent * AliRsnEventBuffer::GetNextEvent()
+{
+//
+// Returns next event in the buffer w.r. to current
+//
+ if (fEventsBufferIndex == fEventsBufferSize - 1) return GetEvent (0);
+ else return GetEvent (fEventsBufferIndex + 1);
+}
+
+//_____________________________________________________________________________
+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];
+}
+
+//_____________________________________________________________________________
+Int_t AliRsnEventBuffer::NEmptySlots()
+{
+//
+// 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;
+}
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//
+// Class AliRsnEventBuffer
+//
+// Implements a temporary buffer of many AliRsnEvent objects
+// which is useful for event mixing.
+//
+// author: Martin Vala (Martin.Vala@cern.ch)
+// revised by: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef AliRsnEventBuffer_h
+#define AliRsnEventBuffer_h
+
+#include "AliRsnEvent.h"
+
+class AliRsnEventBuffer : public TObject
+{
+public:
+
+ 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 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; }
+ Bool_t GetDeleteBufferWhenReset() const { return fDeleteBufferWhenReset; }
+
+ Int_t NEmptySlots();
+
+ private:
+
+ AliRsnEventBuffer (const AliRsnEventBuffer& /*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 fEventsBufferSize; // buffer size
+ Int_t fEventsBufferIndex; // current buffer index
+ AliRsnEvent *fEventsBuffer[10000]; // array of events
+
+ ClassDef (AliRsnEventBuffer, 1)
+};
+
+#endif
--- /dev/null
+#include "AliLog.h"
+
+#include "AliRsnMCInfo.h"
+
+ClassImp ( AliRsnMCInfo )
+
+//_____________________________________________________________________________
+AliRsnMCInfo::AliRsnMCInfo() : TObject(),
+ 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;
+}
+
+//_____________________________________________________________________________
+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];
+
+}
+
+//_____________________________________________________________________________
+AliRsnMCInfo::~AliRsnMCInfo()
+{
+}
+
+//_____________________________________________________________________________
+void AliRsnMCInfo::Adopt ( TParticle * particle )
+{
+//
+// Copies data from a TParticle into "this":
+// - PDG code
+// - GEANT label of mother (if any, otherwise -1)
+// If the argument is NULL, nothing is done, and an alert
+// 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;
+}
--- /dev/null
+#ifndef AliRsnMCInfo_h
+#define AliRsnMCInfo_h
+
+#include <AliVParticle.h>
+#include <TParticle.h>
+
+class AliRsnMCInfo : public TObject
+{
+public:
+ AliRsnMCInfo();
+ AliRsnMCInfo ( const AliRsnMCInfo © );
+
+ ~AliRsnMCInfo();
+ void Adopt ( TParticle *part );
+
+ // 4-momentum
+ virtual Double_t E() const {return fEnergy;}
+ 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 Px() const {return fP[0];}
+ virtual Double_t Py() const {return fP[1];}
+ virtual Double_t Pz() const {return fP[2];}
+ virtual Double_t Pt() const {return TMath::Sqrt ( Px() *Px() + Py() *Py() );}
+ virtual Double_t OneOverPt() const {return 1.0 / Pt();}
+ virtual Bool_t PxPyPz ( Double_t p[3] ) const {p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE;}
+ 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;}
+
+private:
+
+ Double_t fP[3]; // MC momentum
+ Double_t fEnergy; // MC energy
+ Int_t fPDG; // PDG code
+ Int_t fMother; // GEANT label of mother particle
+ Short_t fMotherPDG; // PDG code of mother particle
+
+ ClassDef ( AliRsnMCInfo,1 );
+};
+
+#endif
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-
+
//-------------------------------------------------------------------------
// Class AliRsnPID
// -------------------
// selected from an ESD event
// to be used for analysis.
// .........................................
-//
+//
// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
//-------------------------------------------------------------------------
#include <TDatabasePDG.h>
#include "AliLog.h"
-#include "AliRsnParticle.h"
+#include "AliRsnMCInfo.h"
#include "AliRsnDaughter.h"
#include "AliRsnEvent.h"
ClassImp(AliRsnPID)
-const char* AliRsnPID::fgkParticleName[AliRsnPID::kSpecies + 1] =
+const char* AliRsnPID::fgkParticleNameLong[AliRsnPID::kSpecies + 1] =
{
"electron",
"muon",
"unknown"
};
-const Int_t AliRsnPID::fgkParticlePDG[AliRsnPID::kSpecies + 1] =
+const char* AliRsnPID::fgkParticleNameShort[AliRsnPID::kSpecies + 1] =
+{
+ "e",
+ "mu",
+ "pi",
+ "K",
+ "p",
+ "unk"
+};
+
+const char* AliRsnPID::fgkParticleNameLatex[AliRsnPID::kSpecies + 1] =
+{
+ "e",
+ "#mu",
+ "#pi",
+ "K",
+ "p",
+ "?"
+};
+
+const Int_t AliRsnPID::fgkParticlePDG[AliRsnPID::kSpecies + 1] =
{
11,
13,
fMaxPt(10.0),
fMinProb(0.0)
{
-//=========================================================
-// Default constructor
+//
+// Default constructor
// Sets a default setup:
// - realistic PID
// - no lower limit for probability
// - upper limit of 10 GeV for Pt
// - suitable values for prior probabilities
-//=========================================================
-
+//
+
fPrior[kElectron] = 0.20;
fPrior[kMuon ] = 0.20;
fPrior[kPion ] = 0.83;
fMaxPt(event.fMaxPt),
fMinProb(event.fMinProb)
{
-//=========================================================
+//
// Copy constructor.
// Implemented to manage the array safely.
-//=========================================================
-
+//
+
Int_t i;
for (i = 0; i < kSpecies; i++) fPrior[i] = event.fPrior[i];
}
//_____________________________________________________________________________
AliRsnPID& AliRsnPID::operator=(const AliRsnPID &event)
{
-//=========================================================
+//
// Assignment operator.
// Implemented to manage the array safely.
-//=========================================================
-
+//
+
fMethod = event.fMethod;
fMaxPt = event.fMaxPt;
fMinProb = event.fMinProb;
-
+
Int_t i;
for (i = 0; i < kSpecies; i++) fPrior[i] = event.fPrior[i];
-
+
// return the newly created object
return (*this);
}
//_____________________________________________________________________________
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;
//_____________________________________________________________________________
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];
}
}
//_____________________________________________________________________________
-const char* AliRsnPID::ParticleName(EType type)
+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 fgkParticleName[type];
+ return shortName ? fgkParticleNameShort[type] : fgkParticleNameLong[type];
}
else {
- return "unknown";
+ return shortName ? "unk" : "unknown";
+ }
+}
+
+//_____________________________________________________________________________
+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 "?";
}
}
//_____________________________________________________________________________
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();
//_____________________________________________________________________________
Bool_t AliRsnPID::IdentifyRealistic(AliRsnDaughter *daughter)
{
-//=========================================================
+//
// Uses the Bayesian combination of prior probabilities
// with the PID weights of the passed object to compute
// the overall PID probabilities for each particle type.
// or the probability is smaller than the cut defined (fMinProb),
// the track is considered unidentified.
//
-// If the identification procedure encounters errors,
+// If the identification procedure encounters errors,
// the return value will be "FALSE", otherwise it is "TRUE".
-//=========================================================
+//
- // retrieve PID weights from argument
- Int_t i;
+ // reset all PID probabilities to 0.0
+ Unidentify(daughter, 0.0);
+
+ // check the transverse momentum:
+ // if it is larger than the cut, the particle is unidentified
+ // setting all its probabilities to 1.0
+ if (daughter->Pt() > fMaxPt) {
+ Unidentify(daughter, 1.0);
+ return kTRUE;
+ }
+
+ // 0 - retrieve PID weights from argument
+ Int_t i;
+ Double_t sum = 0.0;
Double_t *prob = new Double_t[kSpecies];
Double_t *weight = new Double_t[kSpecies];
for (i = 0; i < kSpecies; i++) weight[i] = (daughter->PID())[i];
-
+
// step 1 - compute the normalization factor
- Double_t sum = 0.0;
for (i = 0; i < kSpecies; i++) {
prob[i] = fPrior[i] * weight[i];
sum += prob[i];
}
- if (sum <= 0.0) {
- AliError(Form("Sum of weights = %f < 0.0", sum));
- Unidentify(daughter);
+ if (sum <= (Double_t)0.) {
+ AliError(Form("Sum of weights = %f < 0", sum));
return kFALSE;
}
-
- // step 2 - normalize PID weights
+
+ // step 2 - normalize PID weights and update daughter data-member
for (i = 0; i < kSpecies; i++) {
prob[i] /= sum;
+ daughter->SetPIDProb(i, prob[i]);
}
-
- // step 3 - finds the maximum probability
- Int_t imax = 0;
+
+ // step 3 - find the maximum probability and update daughter data members
+ Int_t imax = 0;
+ Double_t pmax = prob[0];
for (i = 1; i < kSpecies; i++) {
- if (prob[i] > prob[imax]) imax = i;
+ if (prob[i] > pmax) {
+ imax = i;
+ pmax = prob[i];
+ }
}
-
- // step 4 - update daughter data members
- // and check pt & prob
- Double_t pt = daughter->Pt();
- EType type = (EType)imax;
- Double_t maxProb = prob[imax];
- if (pt <= fMaxPt && maxProb >= fMinProb) {
+ EType type = (EType)imax;
+ if (pmax >= fMinProb) {
daughter->SetPIDType(type);
- daughter->SetPIDProb(maxProb);
daughter->SetM(ParticleMass(type));
}
else {
- Unidentify(daughter);
+ daughter->SetPIDType(kUnknown);
}
-
+
return kTRUE;
}
//_____________________________________________________________________________
Bool_t AliRsnPID::IdentifyPerfect(AliRsnDaughter *daughter)
{
-//=========================================================
+//
// Uses the true PDG code to make a perfect identification.
-// If the true PDG code does not correspond to any
-// of the expected PID types, gives a warning, sets the
+// If the true PDG code does not correspond to any
+// of the expected PID types, gives a warning, sets the
// PID to 'unknown' and returns kFALSE.
// Otherwise, returns kTRUE.
-//=========================================================
+//
+
+ // reset all PID probabilities to 0.0
+ Unidentify(daughter, 0.0);
- // retrieve true PDG code from argument
- AliRsnParticle *particle = daughter->GetParticle();
+ // if the MCInfo is not present, the particle cannot be identified perfectly
+ // in this case, to notice the error, the probs are maintained all to 0.0
+ AliRsnMCInfo *particle = daughter->GetMCInfo();
if (!particle) {
AliWarning("Particle object not initialized: impossible to do perfect PID");
- Unidentify(daughter);
return kFALSE;
}
+
+ // convert the PDG into the internal enum
Int_t pdgCode = particle->PDG();
EType type = InternalType(pdgCode);
- if (type == kUnknown) {
- //AliWarning(Form("Unrecognized PDG code = %d -- set PID to Unknown", pdgCode));
- Unidentify(daughter);
- return kFALSE;
- }
- else {
+
+ // if the type is one of the available ones in the PID enum
+ // (e, mu, pi, K, p)
+ // the corresponding probability is set to 1, and the other remain 0
+ if (type >= 0 && type < kSpecies) {
daughter->SetPIDType(type);
- daughter->SetPIDProb(1.0);
+ daughter->SetPIDProb(type, 1.0);
daughter->SetM(ParticleMass(type));
return kTRUE;
}
+
+ return kFALSE;
}
//_____________________________________________________________________________
-Bool_t AliRsnPID::Unidentify(AliRsnDaughter *daughter)
+Bool_t AliRsnPID::Unidentify(AliRsnDaughter *daughter, Double_t value)
{
-//=========================================================
+//
// Sets the PID to 'unknown' to every track.
-//=========================================================
+//
+ Int_t i;
+ for (i = 0; i < kSpecies; i++) daughter->SetPIDProb(i, value);
daughter->SetPIDType(kUnknown);
return kTRUE;
}
//_____________________________________________________________________________
Bool_t AliRsnPID::Identify(AliRsnDaughter *daughter)
{
-//=========================================================
+//
// Recalls one of the above methods, according to the one
// defined in the related data member.
-// If the method is not recognized, returns kFALSE and
+// If the method is not recognized, returns kFALSE and
// gives an alert. Otherwise, returns kTRUE.
-//=========================================================
+//
switch (fMethod) {
case kNone:
}
}
+//_____________________________________________________________________________
+Bool_t AliRsnPID::IdentifiedAs(AliRsnDaughter *d, EType type, Short_t charge)
+{
+//
+// Tells if a particle has been identified to be of a given tipe and charge.
+// If the charge is zero, the check is done only on the PID type, otherwise
+// both charge and PID type are required to match
+//
+ if (charge == 0) {
+ return (d->PIDType() == type);
+ }
+ else if (charge > 0) {
+ return (d->PIDType() == type && d->Charge() > 0);
+ }
+ else {
+ return (d->PIDType() == type && d->Charge() < 0);
+ }
+}
+
//_____________________________________________________________________________
Bool_t AliRsnPID::Identify(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;
+
AliRsnDaughter *daughter = 0;
- TObjArrayIter iter(event->GetAllTracks());
+ TObjArrayIter iter(event->GetTracks());
while ( (daughter = (AliRsnDaughter*)iter.Next()) ) {
check = check && Identify(daughter);
}
//_____________________________________________________________________________
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;
}
//-------------------------------------------------------------------------
// Class AliRsnPID
// Simple collection of reconstructed tracks, selected from an ESD event
-//
+//
// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
//-------------------------------------------------------------------------
#ifndef ALIRSNPID_H
#define ALIRSNPID_H
+class AliRsnPIDProb;
class AliRsnDaughter;
class AliRsnEvent;
class AliRsnPID : public TObject
{
public:
-
+
AliRsnPID();
AliRsnPID(const AliRsnPID& copy);
AliRsnPID& operator=(const AliRsnPID& copy);
virtual ~AliRsnPID() {}
-
+
// types enum
- enum EType {
- kElectron = 0,
- kMuon,
- kPion,
- kKaon,
- kProton,
- kUnknown,
- kSpecies = 5
+ enum EType {
+ kElectron = 0,
+ kMuon,
+ kPion,
+ kKaon,
+ kProton,
+ kUnknown,
+ kSpecies = 5
};
-
+
// identification method enum
enum EMethod {
kNone = 0,
kRealistic,
- kPerfect
+ kPerfect,
+ kMethods
};
-
- // conversions from PDG code to local type
+
+ // 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);
+ static const char * ParticleName(EType pid, Bool_t shortName = kTRUE);
+ static const char * ParticleNameLatex(EType pid);
static Double_t ParticleMass(EType pid);
-
+
// identification routines
- Bool_t Identify(AliRsnDaughter *d);
- Bool_t Identify(AliRsnEvent *e);
-
+ Bool_t Identify(AliRsnDaughter *d);
+ Bool_t Identify(AliRsnEvent *e);
+ Bool_t IdentifiedAs(AliRsnDaughter *d, EType type, Short_t charge = 0);
+
// setters
void SetMethod(EMethod method) {fMethod = method;}
void SetPriorProbability(EType type, Double_t p);
void SetMinProb(Double_t p) {fMinProb = p;}
void SetMaxPt(Double_t p) {fMaxPt = p;}
-
+
// getters
EMethod GetMethod() {return fMethod;}
-
+
private:
// identification routines
Bool_t IdentifyPerfect(AliRsnDaughter *d);
Bool_t IdentifyRealistic(AliRsnDaughter *d);
- Bool_t Unidentify(AliRsnDaughter *d);
+ Bool_t Unidentify(AliRsnDaughter *d, Double_t value = 1.0);
EMethod fMethod; // PID method
-
- Double_t fPrior[kSpecies]; // prior probabilities
+
+ Double_t fPrior[kSpecies]; // prior probabilities
Double_t fMaxPt; // realistic PID is done for Pt < this parameter
Double_t fMinProb; // threshold on acceptable largest probability
-
- static const char* fgkParticleName[kSpecies+1];
+
+ static const char* fgkParticleNameShort[kSpecies+1];
+ static const char* fgkParticleNameLong[kSpecies+1];
+ static const char* fgkParticleNameLatex[kSpecies+1];
static const Int_t fgkParticlePDG[kSpecies+1];
ClassDef(AliRsnPID,1);
--- /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 AliRsnPIDIndex ***
+//
+// It sorts the indexes of all tracks in an AliRsnEvent
+// for a fast retrieval of them according to charge and PID.
+//
+// author: M. Vala (email: martin.vala@cern.ch)
+//
+
+#include <TObject.h>
+
+#include "AliLog.h"
+
+#include "AliRsnPIDIndex.h"
+
+ClassImp (AliRsnPIDIndex)
+
+//_____________________________________________________________________________
+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);
+ }
+ }
+}
+
+//_____________________________________________________________________________
+AliRsnPIDIndex::AliRsnPIDIndex (const AliRsnPIDIndex & copy)
+ : TObject (copy)
+{
+//
+// Copy constructor.
+// Creates new instances of all collections
+// 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);
+ }
+ }
+ }
+}
+
+//_____________________________________________________________________________
+AliRsnPIDIndex& AliRsnPIDIndex::operator= (const AliRsnPIDIndex & copy)
+{
+//
+// Assignment operator.
+// Creates new instances of all collections
+// 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);
+ }
+ }
+ }
+
+ // return this object
+ return (*this);
+}
+
+AliRsnPIDIndex::~AliRsnPIDIndex()
+{
+//
+// Destructor.
+// Does nothing.
+//
+}
+
+//_____________________________________________________________________________
+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]));
+ }
+ }
+}
+
+//_____________________________________________________________________________
+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]++;
+}
+
+//_____________________________________________________________________________
+void AliRsnPIDIndex::AddIndex(const Int_t index, Short_t sign, Int_t type)
+{
+//
+// Adds index to corresponding TArrayI
+//
+
+ fIndex[sign][type].AddAt (index, fNumOfIndex[sign][type]);
+ fNumOfIndex[sign][type]++;
+}
+
+//_____________________________________________________________________________
+void AliRsnPIDIndex::SetCorrectIndexSize()
+{
+//
+// 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]);
+ }
+ }
+}
+
+//_____________________________________________________________________________
+TArrayI* AliRsnPIDIndex::GetTracksArray (Char_t sign, AliRsnPID::EType type)
+{
+//
+// Returns the array of indexes of tracks whose charge
+// and PID correspond to the passed arguments:
+// 1) sign of particle ('+' or '-')
+// 2) PID of particle (from AliRsnPID::EType)
+// 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;
+ }
+
+ return &fIndex[icharge][type];
+}
+
+//_____________________________________________________________________________
+TArrayI* AliRsnPIDIndex::GetCharged (Char_t sign)
+{
+//
+// Returns the array of indexes of tracks whose charge
+// corresponds to the passed argument
+// Otherwise returns a null pointer.
+//
+
+ // check that argument is meaningful
+ Int_t icharge = ChargeIndex (sign);
+ if (icharge < 0) return (TArrayI *)0x0;
+
+ // count total number of tracks with that charge
+ // and create output object of appropriate size
+ Int_t i, total = 0;
+ for (i = 0; i <= AliRsnPID::kSpecies; i++) total += fIndex[icharge][i].GetSize();
+ TArrayI *output = new TArrayI(total);
+
+ // add all indexes
+ Int_t j, counter = 0;
+ for (i = 0; i <= AliRsnPID::kSpecies; i++) {
+ for (j = 0; j < fIndex[icharge][i].GetSize(); j++) {
+ output->AddAt (fIndex[icharge][i].At(j), counter++);
+ }
+ }
+
+ return output;
+}
+
+//_____________________________________________________________________________
+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;
+ }
+}
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//
+// *** Class AliRsnPIDIndex ***
+//
+// It sorts the indexes of all tracks in an AliRsnEvent
+// for a fast retrieval of them according to charge and PID.
+//
+// author: M. Vala (email: martin.vala@cern.ch)
+//
+
+#ifndef AliRsnPIDIndex_h
+#define AliRsnPIDIndex_h
+
+#include <TArrayI.h>
+#include "AliRsnPID.h"
+
+class AliRsnPIDIndex : public TObject
+{
+public:
+
+ AliRsnPIDIndex (Int_t num = 1000);
+ AliRsnPIDIndex (const AliRsnPIDIndex ©);
+ AliRsnPIDIndex& operator= (const AliRsnPIDIndex& copy);
+
+ virtual ~AliRsnPIDIndex();
+
+ void Print(Option_t *option = "") const;
+
+ void AddIndex(const Int_t index, Char_t sign, AliRsnPID::EType type);
+ void AddIndex(const Int_t index, Short_t sign, Int_t type);
+ void SetCorrectIndexSize();
+
+ TArrayI* GetTracksArray (Char_t sign, AliRsnPID::EType type);
+ TArrayI* GetCharged (Char_t sign);
+
+private:
+
+ 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);
+};
+
+#endif
--- /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 AliRsnPIDWeightsMgr
+// -------------------
+// Simple collection of reconstructed tracks
+// selected from an ESD event
+// to be used for analysis.
+// .........................................
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//-------------------------------------------------------------------------
+
+#include <TMath.h>
+#include <TString.h>
+#include <TClonesArray.h>
+#include <TDatabasePDG.h>
+
+#include "AliLog.h"
+#include "AliRsnPIDWeightsMgr.h"
+
+ClassImp(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;
+ }
+}
+
+//_____________________________________________________________________________
+void AliRsnPIDWeightsMgr::SetDetectorWeights(EDetector det, Double_t *weights)
+{
+//
+// 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];
+}
+
+//_____________________________________________________________________________
+void AliRsnPIDWeightsMgr::SetAcceptanceRange(EDetector det, Double_t ptmin, Double_t ptmax)
+{
+//
+// Sets a range in pt for which the PID weights of this detector
+// are accepted in the global computation, in the case that one
+// 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;
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnPIDWeightsMgr::GetWeight(AliRsnPID::EType type, Double_t pt)
+{
+//
+// 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;
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnPIDWeightsMgr::CheckBounds(EDetector det)
+{
+//
+// Bounds checker
+//
+
+ if (det < 0 or det >= kDetectors) {
+ AliError("Index out of range");
+ return kFALSE;
+ }
+
+ return kTRUE;
+}
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+/* $Id: AliRsnPIDWeightsMgr.h,v 1.5 2007/02/21 14:33:25 pulvir Exp $ */
+
+//-------------------------------------------------------------------------
+// Class AliRsnPIDWeightsMgr
+// Simple collection of reconstructed tracks, selected from an ESD event
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//-------------------------------------------------------------------------
+
+#ifndef AliRsnPIDWeightsMgr_H
+#define AliRsnPIDWeightsMgr_H
+
+#include "AliRsnPID.h"
+
+class AliRsnPIDWeightsMgr : public TObject
+{
+public:
+
+ 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:
+
+ Bool_t CheckBounds(EDetector det);
+
+ Bool_t fUseDet[kDetectors]; // flag to switch off info from a detector
+ Double_t fDetPtMin[kDetectors]; // min value for detector weight acceptance
+ Double_t fDetPtMax[kDetectors]; // max value for detector weight acceptance
+ Double_t fWeights[kDetectors][AliRsnPID::kSpecies]; // PID weights of a single detector
+
+ ClassDef(AliRsnPIDWeightsMgr,1);
+};
+
+#endif
--- /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. *
+ **************************************************************************/
+
+//
+// ALIRSNPAIRDEF
+//
+// Definition of working parameters for a specific resonance analysis.
+// This object allows to define the particles to be used for computation
+// with respect to charge and PID type (included 'kUnknown'), and
+// the binning of the output histogram.
+// These definitions can then be used by many AliRsnPair objects
+// which can operate on the same track samples under different conditions.
+//
+// author: A. Pulvirenti
+// email : alberto.pulvirenti@ct.infn.it
+//
+
+#include <Riostream.h>
+
+#include "AliLog.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnPairDef.h"
+
+ClassImp(AliRsnPairDef)
+
+//_____________________________________________________________________________
+AliRsnPairDef::AliRsnPairDef() :
+ TObject(),
+ fMotherPDG(0),
+ fNBins(0),
+ fMin(0.0),
+ fMax(0.0)
+{
+//
+// Empty constructor.
+// Initializes the data members to default values:
+// - no definition of particles in the pair;
+// - histogram binning undefined.
+// When using this constructor, all analysis elements (particles, histogram)
+// must be defined before starting event processing.
+//
+
+ Int_t i;
+ for (i = 0; i < 2; i++) {
+ fCharge[i] = '0';
+ fMass[i] = 0.0;
+ fType[i] = AliRsnPID::kUnknown;
+ }
+}
+
+//_____________________________________________________________________________
+AliRsnPairDef::AliRsnPairDef
+(Char_t sign1, AliRsnPID::EType type1, Char_t sign2, AliRsnPID::EType type2,
+ Int_t nbins, Double_t min, Double_t max) :
+ TObject(),
+ fMotherPDG(0),
+ fNBins(0),
+ fMin(0.0),
+ fMax(0.0)
+{
+//
+// Constructor with arguments.
+// This constructor allows to define all the working parameters.
+//
+
+ SetPair(sign1, type1, sign2, type2);
+ SetBins(nbins, min, max);
+}
+
+//_____________________________________________________________________________
+AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef ©) :
+ TObject(copy),
+ fMotherPDG(copy.fMotherPDG),
+ fNBins(0),
+ fMin(0.0),
+ fMax(0.0)
+{
+//
+// Copy constructor with standard behavior
+//
+
+ SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
+ SetBins(copy.fNBins, copy.fMin, copy.fMax);
+}
+
+//_____________________________________________________________________________
+const AliRsnPairDef& AliRsnPairDef::operator=(const AliRsnPairDef ©)
+{
+//
+// Assignment operator with standard behavior.
+//
+
+ fMotherPDG = copy.fMotherPDG;
+ SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
+ SetBins(copy.fNBins, copy.fMin, copy.fMax);
+
+ return (*this);
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnPairDef::SetPairElement(Int_t i, Char_t charge, AliRsnPID::EType type)
+{
+//
+// Set one element of the pair
+// and returns warnings if the type is not valid.
+//
+ if (i < 0 || i > 1) {
+ AliError("Index out of range");
+ return kFALSE;
+ }
+ if (charge != '+' && charge != '-') {
+ AliError(Form("Character '%c' not recognized as charge sign"));
+ return kFALSE;
+ }
+ if (type < AliRsnPID::kElectron && type > AliRsnPID::kUnknown) {
+ AliError("Type index out of enumeration range");
+ return kFALSE;
+ }
+ fCharge[i] = charge;
+ fType[i] = type;
+ fMass[i] = AliRsnPID::ParticleMass(type);
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnPairDef::SetPair
+(Char_t charge1, AliRsnPID::EType type1, Char_t charge2, AliRsnPID::EType type2)
+{
+//
+// 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);
+}
+
+//_____________________________________________________________________________
+void AliRsnPairDef::CheckEdges()
+{
+//
+// Checks that histogram edges are appropriate,
+// otherwise swaps them.
+//
+ if (fMin > fMax) {
+ AliWarning(Form("min = %f -- max = %f --> swapping", fMin, fMax));
+ Double_t temp = fMin;
+ fMin = fMax;
+ fMax = temp;
+ }
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnPairDef::ComputeWeight(AliRsnDaughter *d0, AliRsnDaughter *d1)
+{
+//
+// Compute a weight for filling the histograms:
+// probability of first track to be identified as 'type[0]' times
+// the probability of second track to be identified as 'type[1]',
+// according to the order of appearance in argument list.
+//
+
+ Double_t prob0 = d0->PIDProb()[fType[0]];
+ Double_t prob1 = d1->PIDProb()[fType[1]];
+
+ return prob0*prob1;
+}
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//-------------------------------------------------------------------------
+// Class AliRsnAnalysis
+// Reconstruction and analysis of K* Rsn
+// ........................................
+// ........................................
+// ........................................
+// ........................................
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//-------------------------------------------------------------------------
+
+#ifndef ALIRSNPAIRDEF_H
+#define ALIRSNPAIRDEF_H
+
+class AliRsnDaughter;
+#include "AliRsnPID.h"
+
+class AliRsnPairDef : public TObject
+{
+public:
+
+ AliRsnPairDef();
+ AliRsnPairDef(Char_t sign1, AliRsnPID::EType type1, Char_t sign2, AliRsnPID::EType type2,
+ Int_t nbins, Double_t min, Double_t max);
+ AliRsnPairDef(const AliRsnPairDef ©);
+ const AliRsnPairDef& operator=(const AliRsnPairDef ©);
+ virtual ~AliRsnPairDef() { }
+
+ // getters
+ Char_t GetCharge(Int_t i) const {if (i>=0&&i<2) return fCharge[i]; else return 0;}
+ AliRsnPID::EType GetType(Int_t i) const {if (i>=0&&i<2) return fType[i]; else return AliRsnPID::kUnknown;}
+ Double_t GetMass(Int_t i) const {if (i>=0&&i<2) return fMass[i]; else return 0.0;}
+ Int_t GetNBins() const {return fNBins;}
+ Double_t GetMin() const {return fMin;}
+ Double_t GetMax() const {return fMax;}
+ Int_t GetMotherPDG() const {return fMotherPDG;}
+
+ // setters
+ Bool_t SetPairElement(Int_t i, Char_t charge, AliRsnPID::EType pid);
+ Bool_t SetPair(Char_t charge1, AliRsnPID::EType pid1, Char_t charge2, AliRsnPID::EType pid2);
+ void SetMotherPDG(Int_t pdg) {fMotherPDG = pdg;}
+ void SetNBins(Int_t value) {fNBins = value;}
+ void SetMin(Double_t value) {fMin = value; CheckEdges();}
+ void SetMax(Double_t value) {fMax = value; CheckEdges();}
+ void SetBins(Int_t nbins, Double_t min, Double_t max) {fNBins=nbins; fMin=min; fMax=max; CheckEdges();}
+
+ // pair information methods
+ Bool_t IsLikeSign() {return (fCharge[0] == fCharge[1]);}
+ Bool_t HasEqualTypes() {return (fType[0] == fType[1]);}
+
+ // working routines
+ void CheckEdges();
+ Double_t ComputeWeight(AliRsnDaughter *d0, AliRsnDaughter *d1);
+
+private:
+
+ // pair parameters
+ Int_t fMotherPDG; // PDG code of true mother (if known)
+ Double_t fMass[2]; // mass of particles
+ Char_t fCharge[2]; // charge of particles
+ AliRsnPID::EType fType[2]; // PID of particles
+
+ // histogram parameters
+ Int_t fNBins; // number of histogram bins
+ Double_t fMin; // lower edge
+ Double_t fMax; // upper edge
+
+ // ROOT dictionary
+ ClassDef(AliRsnPairDef, 1)
+};
+
+#endif
--- /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 AliRsnPairParticle
+//
+// Implementation of a pair of tracks, for several purposes
+// - computing the total 4-momentum & inv. mass for output histos filling
+// - evaluating cut checks on the pair of particles
+//
+// author: Martin Vala (martin.vala@cern.ch)
+// revised by: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include "AliLog.h"
+
+#include "AliRsnPairParticle.h"
+
+ClassImp (AliRsnPairParticle)
+
+//_____________________________________________________________________________
+AliRsnPairParticle::AliRsnPairParticle() :
+ fMass(0.0)
+{
+//
+// Constructor.
+// 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;
+ }
+ }
+}
+
+//_____________________________________________________________________________
+AliRsnPairParticle::AliRsnPairParticle(const AliRsnPairParticle &obj) :
+ TObject(obj),
+ fMass(obj.fMass)
+{
+//
+// Copy constructor.
+// Initializes all variables to copy values.
+// 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];
+ }
+ }
+}
+
+//_____________________________________________________________________________
+AliRsnPairParticle& AliRsnPairParticle::operator=(const AliRsnPairParticle &obj)
+{
+//
+// Assignment operator.
+// Initializes all variables to copy values.
+// Does not duplicate pointers.
+//
+
+ fMass = obj.fMass;
+
+ 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);
+}
+
+//_____________________________________________________________________________
+AliRsnPairParticle::~AliRsnPairParticle()
+{
+//
+// Desctructor.
+// Does nothing.
+//
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnPairParticle::GetInvMass(Double_t m1, Double_t m2)
+{
+//
+// Compute invariant mass using REC values.
+// The masses in argument have default value = -1.0;
+// when this is used, the mass for computation is taken from daughter object.
+// Otherwise, the passed values are used.
+//
+ Double_t etot = 0.0;
+
+ // energy of particle 1
+ if (m1 > 0.0) etot = GetDaughterEnergy(0, m1);
+ else etot = fDaughter[0]->E();
+
+ // energy of particle 2
+ if (m2 > 0.0) etot += GetDaughterEnergy(1, m2);
+ else etot += fDaughter[1]->E();
+
+ // total momentum square module
+ Double_t p2Tot = fPTot[0]*fPTot[0] + fPTot[1]*fPTot[1] + fPTot[2]*fPTot[2];
+
+ // invariant mass returned
+ return TMath::Sqrt (etot * etot - p2Tot);
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnPairParticle::GetInvMassMC(Double_t m1, Double_t m2)
+{
+//
+// Compute invariant mass using MC values.
+// The masses in argument have default value = -1.0;
+// when a negative mass value is passed as one of the arguments,
+// the energy of tracks for computation is taken from daughter object.
+// Otherwise, the passed mass values are used to re-compute the track energy.
+//
+ Double_t etot = 0.0;
+
+ // energy of particle 1
+ if (m1 > 0.0) etot = GetDaughterEnergyMC(0, m1);
+ else etot = fDaughter[0]->GetMCInfo()->E();
+
+ // energy of particle 2
+ if (m2 > 0.0) etot += GetDaughterEnergyMC(1, m2);
+ else etot += fDaughter[1]->GetMCInfo()->E();
+
+ // total momentum square module
+ Double_t p2Tot = fPTotMC[0]*fPTotMC[0] + fPTotMC[1]*fPTotMC[1] +fPTotMC[2]*fPTotMC[2];
+
+ // invariant mass returned
+ return TMath::Sqrt (etot * etot - p2Tot);
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnPairParticle::GetDaughterEnergy(const Int_t &index, const Double_t &mass)
+{
+//
+// Compute track energy from REC momentum using a passed mass value.
+// The index argument refers to the used track among the two of the pair.
+//
+
+ Int_t i;
+ Double_t p2Tot = 0.0;
+ if (mass > 0 && index >= 0 && index < 2) {
+ AliRsnDaughter temp(*fDaughter[index]);
+ temp.SetM(mass);
+ return temp.E();
+ }
+
+ AliWarning("Negative mass or wrong index passed. Returning 0");
+ return 0.0;
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnPairParticle::GetDaughterEnergyMC(const Int_t &index, const Double_t &mass)
+{
+//
+// Compute track energy from MC momentum using a passed mass value.
+// The index argument refers to the used track among the two of the pair.
+//
+ Int_t i;
+ Double_t p2Tot = 0.0;
+ if (mass > 0 && index >= 0 && index < 2) {
+ for (i = 0; i < 3; i++) p2Tot += fPTrackMC[index][i] * fPTrackMC[index][i];
+ return TMath::Sqrt(mass*mass + p2Tot);
+ }
+
+ AliWarning("Negative mass or wrong index passed. Returning 0");
+ return 0.0;
+}
+
+//_____________________________________________________________________________
+Int_t AliRsnPairParticle::GetPDG(const Int_t &index)
+{
+//
+// Return PDG code of one track in the pair
+//
+
+ if (index < 0 || index > 1) {
+ AliError("Index out of range");
+ return 0;
+ }
+ if (!fDaughter[index]->GetMCInfo()) {
+ AliError(Form("MCInfo not initialized for track %d", index));
+ return 0;
+ }
+ return fDaughter[index]->GetMCInfo()->PDG();
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnPairParticle::IsTruePair(Int_t refPDG)
+{
+//
+// Checks if the tweo tracks in the pair come from the same resonance.
+// This can be known if MC info is present, looking at the GEANT label of mother
+// (which should be the same).
+// If the argument is 0, the answer is kTRUE whenever the labels of mothers of the
+// two tracks is the same. When the argument is not zero, the answer is kTRUE only
+// 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);
+}
+
+//_____________________________________________________________________________
+void AliRsnPairParticle::SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2)
+{
+//
+// Main object filling method.
+// Accepts two AliRsnDaughter's which are the two tracks in the pair,
+// fills all data-members which contain their momenta & info,
+// and computes the total momentum for REC data and MC if available
+//
+
+ 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];
+ }
+
+ // 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)
+{
+//
+// Print some info of the pair
+//
+
+ TString s(option);
+
+ AliInfo ( "======== BEGIN PAIR INFO ===========" );
+ if (s.Contains("p")) {
+ AliInfo (Form("Px1 = %.6f --- Py1 = %.6f --- Pz1 = %.6f", fPTrack[0][0], fPTrack[0][1], fPTrack[0][2]));
+ AliInfo (Form("Px2 = %.6f --- Py2 = %.6f --- Pz2 = %.6f", fPTrack[1][0], fPTrack[1][1], fPTrack[1][2]));
+ }
+ if (s.Contains("t")) {
+ AliInfo (Form("PDG1 = %d --- PDG2 = %d", GetPDG(0), GetPDG(1)));
+ AliInfo (Form("type1 = %d --- type2 = %d", GetType(0), GetType(1)));
+ AliInfo (Form("label1 = %d --- label2 = %d", GetLabel(0), GetLabel(1)));
+ }
+ AliInfo ( "====== END PAIR INFO =========" );
+}
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//
+// Class AliRsnPairParticle
+//
+// Implementation of a pair of tracks, for several purposes
+// - computing the total 4-momentum & inv. mass for output histos filling
+// - evaluating cut checks on the pair of particles
+//
+// author: Martin Vala (martin.vala@cern.ch)
+// revised by: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef ALIRSNPAIRPARTICLE_H
+#define ALIRSNPAIRPARTICLE_H
+
+#include <TMath.h>
+
+#include "AliRsnDaughter.h"
+#include "AliRsnMCInfo.h"
+
+class AliRsnPairParticle : public TObject
+{
+public:
+
+ AliRsnPairParticle();
+ AliRsnPairParticle(const AliRsnPairParticle &obj);
+ AliRsnPairParticle& operator=(const AliRsnPairParticle &obj);
+ virtual ~AliRsnPairParticle();
+
+ Double_t GetInvMass (Double_t m1 = -1.0, Double_t m2 = -1.0);
+ Double_t GetInvMassMC (Double_t m1 = -1.0, Double_t m2 = -1.0);
+ Double_t GetDaughterEnergy(const Int_t &index, const Double_t &mass);
+ Double_t GetDaughterEnergyMC(const Int_t &index, const Double_t &mass);
+
+ 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 GetP(Int_t index) const {return fPTot[index];}
+ Double_t GetPt() const {return TMath::Sqrt(GetPt2());}
+
+ 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 GetPMC(Int_t index) const {return fPTotMC[index];}
+ Double_t GetPtMC() const {return TMath::Sqrt(GetPt2MC());}
+
+ Int_t GetPDG(const Int_t &index);
+ Int_t GetType(const Int_t &index) const {return (Int_t) fDaughter[index]->PIDType();}
+ Int_t GetLabel(const Int_t &index) const {return (Int_t) fDaughter[index]->Label();}
+ Int_t GetIndex(const Int_t &index) const {return (Int_t) fDaughter[index]->Index();}
+ Double_t GetMass() const {return fMass;}
+ AliRsnDaughter* GetDaughter(const Int_t &index) const {return fDaughter[index];}
+
+ Bool_t IsPDGEqual() {return abs(GetPDG(0)) == abs(GetPDG(1));}
+ Bool_t IsTypeEqual() {return GetType(0) == GetType(1);}
+ Bool_t IsLabelEqual() {return abs(GetLabel(0)) == abs(GetLabel(1));}
+ Bool_t IsIndexEqual() {return GetIndex(0) == GetIndex(1);}
+ Bool_t IsTruePair(Int_t refPDG = 0);
+
+ void SetMass(Double_t mass) {fMass = mass;}
+ void SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2);
+ void PrintInfo (const Option_t *option = "");
+
+private:
+
+ Double_t fPTot[3]; // total momentum computed with rec. values
+ Double_t fPTotMC[3]; // total momentum computed with MC values
+ Double_t fPTrack[2][3]; // rec. momentum of single tracks
+ Double_t fPTrackMC[2][3]; // MC momentum of single tracks
+
+ Double_t fMass; // mass hypothesis for resonance
+
+ Int_t fMotherLabel[2]; // GEANT label of tracks
+ Int_t fMotherPDG[2]; // PDG code of mother of tracks
+
+ AliRsnDaughter *fDaughter[2]; // elements of the pair
+
+ ClassDef (AliRsnPairParticle,1)
+};
+
+#endif
--- /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 AliRsnPairSimple
+//-------------------------------------------------------------------------
+// This class computes the invariant mass spectrum of a specified pair of
+// particles, throughout a list of AliRsnEvents, and returns it as a TH1D.
+// This object is not supposed to be used directly: an AliRsnAnalysis
+// should be initialized in a macro and filled with one or more AliRsnPairSimple's
+// which are then processed with a given sample of events.
+//
+// author: A. Pulvirenti
+// email : alberto.pulvirenti@ct.infn.it
+//-------------------------------------------------------------------------
+
+#include <Riostream.h>
+
+#include <TH1.h>
+#include <TString.h>
+#include <TArrayI.h>
+#include <TClonesArray.h>
+
+#include "AliLog.h"
+#include "AliRsnMCInfo.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnCut.h"
+#include "AliRsnCutMgr.h"
+#include "AliRsnPairDef.h"
+#include "AliRsnPID.h"
+
+#include "AliRsnPairSimple.h"
+
+ClassImp(AliRsnPairSimple)
+
+//--------------------------------------------------------------------------------------------------------
+AliRsnPairSimple::AliRsnPairSimple(AliRsnPairDef *pd, const char *name, const char *title) :
+ TNamed(name, title),
+ fPIDMethod(AliRsnPID::kNone),
+ fForMixing(kFALSE),
+ fStoreOnlyTrue(kFALSE),
+ fCuts(0x0),
+ fPair(),
+ fPairDef(pd),
+ fHistogram(0x0),
+ fHistogramMC(0x0)
+{
+//
+// Constructor.
+// This constructor allows to define some of the initialization values:
+// - name and title of the object
+// - histogram binning and edges
+// The other parameters are initialized as in the default constructor.
+//
+}
+//--------------------------------------------------------------------------------------------------------
+AliRsnPairSimple::AliRsnPairSimple(const AliRsnPairSimple ©) :
+ TNamed(copy),
+ fPIDMethod(copy.fPIDMethod),
+ fForMixing(copy.fForMixing),
+ fStoreOnlyTrue(copy.fStoreOnlyTrue),
+ fCuts(0x0),
+ fPair(),
+ fPairDef(copy.fPairDef),
+ fHistogram(0x0),
+ fHistogramMC(0x0)
+{
+//
+// Copy constructor.
+// Default behavior as a copy constructor for what concerns non-array data-members.
+// The arrays are cloned if they are not NULL.
+//
+}
+//--------------------------------------------------------------------------------------------------------
+const AliRsnPairSimple& AliRsnPairSimple::operator=(const AliRsnPairSimple ©)
+{
+//
+// Assignment operator.
+// Default behavior like copy constructor.
+//
+ SetName(copy.GetName());
+ SetTitle(copy.GetTitle());
+
+ fHistogram = 0x0;
+ fHistogramMC = 0x0;
+ fPairDef = copy.fPairDef;
+
+ fPIDMethod = copy.fPIDMethod;
+ fForMixing = copy.fForMixing;
+ fStoreOnlyTrue = copy.fStoreOnlyTrue;
+ if (copy.fHistogram) fHistogram = (TH1D*)(copy.fHistogram->Clone());
+
+ fCuts = 0x0;
+
+ return (*this);
+}
+//--------------------------------------------------------------------------------------------------------
+void AliRsnPairSimple::Clear(Option_t* /*option*/)
+{
+//
+// Clear arrays and histogram.
+// For the sake of security, all pointers are also set explicitly to NULL.
+//
+ delete fHistogram;
+ fHistogram = 0x0;
+ delete fHistogramMC;
+ fHistogramMC = 0x0;
+}
+
+//--------------------------------------------------------------------------------------------------------
+void AliRsnPairSimple::InitHistograms()
+{
+//
+// Initialize histograms
+//
+
+ Int_t nbins = fPairDef->GetNBins();
+ Double_t min = fPairDef->GetMin(), max = fPairDef->GetMax();
+
+ if (strlen(GetName()) > 0) {
+ fHistogram = new TH1D(GetName(), GetTitle(), nbins, min, max);
+ fHistogramMC = new TH1D(Form("MC_%s", GetName()), Form("%s (MC)", GetTitle()), nbins, min, max);
+ }
+ else {
+ Char_t name[200], title[200];
+ strcpy(name, GetHistName());
+ strcpy(title, GetHistTitle());
+ fHistogram = new TH1D(name, title, nbins, min, max);
+ fHistogramMC = new TH1D(Form("MC_%s", name), Form("%s (MC)", title), nbins, min, max);
+ }
+ fHistogram->Sumw2();
+ fHistogramMC->Sumw2();
+}
+
+const char* AliRsnPairSimple::GetHistName ()
+{
+//
+// Creates the histogram name, given a cut manager
+//
+
+ TString strName("");
+ strName.Append(AliRsnPID::ParticleName(fPairDef->GetType(0)));
+ strName += '(';
+ strName += fPairDef->GetCharge(0);
+ strName += ')';
+ strName += '_';
+ strName.Append(AliRsnPID::ParticleName(fPairDef->GetType(1)));
+ strName += '(';
+ strName += fPairDef->GetCharge(1);
+ strName += ')';
+ strName += '_';
+ if (fCuts) {
+ strName.Append("cuts:");
+ strName.Append(fCuts->GetName());
+ }
+ else {
+ strName.Append("NoCuts");
+ }
+ if (fStoreOnlyTrue) strName.Append("_true");
+ if (fForMixing) strName.Append("_mix");
+
+ return strName.Data();
+}
+
+const char* AliRsnPairSimple::GetHistTitle()
+{
+//
+// Creates the histogram title, given a cut manager
+//
+
+ TString strName("Inv. mass of ");
+ strName.Append(AliRsnPID::ParticleName(fPairDef->GetType(0), kFALSE));
+ strName += 's';
+ strName += ' ';
+ strName += '(';
+ strName += fPairDef->GetCharge(0);
+ strName += ')';
+ strName.Append(" and ");
+ strName.Append(AliRsnPID::ParticleName(fPairDef->GetType(1), kFALSE));
+ strName += 's';
+ strName += ' ';
+ strName += '(';
+ strName += fPairDef->GetCharge(1);
+ strName += ')';
+ if (fCuts) {
+ strName.Append(" [cuts: ");
+ strName.Append(fCuts->GetTitle());
+ strName.Append("] ");
+ }
+ else {
+ strName.Append(" [No cuts] ");
+ }
+ if (fStoreOnlyTrue) strName.Append(" [true pairs]");
+ if (fForMixing) strName.Append(" [event mixing]");
+
+ return strName.Data();
+}
+
+//--------------------------------------------------------------------------------------------------------
+Stat_t AliRsnPairSimple::Process(AliRsnEvent *event1, AliRsnEvent *event2)
+{
+//
+// Scans the two events specified in argument to fill the histogram.
+// This method essentially calls the AliRsnPairSimple::Fill() method one or many times.
+// When the "noPID" argument is kFALSE, the analysis is done with identified particles
+// and this causes the Fill() method to be called only once, for the two lists of
+// identified particles of the two kinds specified in AliRsnPairSimple datamembers.
+// When the "noPID" argument is kTRUE, the analysis is done with all collections
+// of particles of the same sign as specified in the two arguments of the pair.
+// ---
+// Particles of type #1 are taken in 'event1', and particles of type #2 are taken in 'event2'.
+// When doing single-event analysis (for resonance signal or like-sign background),
+// the second argument can be simply skipped.
+// When doing event mixing, the two arguments must be not null and different.
+// If argument #1 is NULL, an error is raised, while if argument #2 is NULL, no error is raised,
+// and 'event2' argument is set equal to 'event1' (= single event processing).
+// ---
+// Return value is the total number of pairs processed.
+//
+
+ if (!event1) {
+ // argument #1 cannot be NULL
+ AliError("Argument #1 cannot be NULL.");
+ return 0.0;
+ }
+ if (!event2) {
+ // if argument #2 is NULL, it is put equal to argument #1
+ event2 = event1;
+ }
+ if (!fPairDef) {
+ AliError("No pairdef defined");
+ return 0.0;
+ }
+ if (!fHistogram) {
+ AliError("Histograms not initialized");
+ return 0.0;
+ }
+
+ // assign pointers to the list of indexes to be used
+ TArrayI *listCharged1 = 0x0, *listCharged2 = 0x0;
+ //if (pidMethod == AliRsnPID::kNone) {
+ listCharged1 = event1->GetCharged(fPairDef->GetCharge(0));
+ listCharged2 = event2->GetCharged(fPairDef->GetCharge(1));
+ //}
+ //else {
+ //listCharged1 = event1->GetTracksArray(pidMethod, fPairDef->GetCharge(0), fPairDef->GetType(0));
+ //listCharged2 = event2->GetTracksArray(pidMethod, fPairDef->GetCharge(1), fPairDef->GetType(1));
+ //}
+ if (!listCharged1 || !listCharged2) return 0.0;
+ TArrayI &list1 = *listCharged1;
+ TArrayI &list2 = *listCharged2;
+
+ Int_t i1, i2, start2;
+ Stat_t nPairs = 0;
+ AliRsnDaughter *track1 = 0x0, *track2 = 0x0;
+
+ // loop on particle of type 1 (in first event)
+ for (i1 = 0; i1 < list1.GetSize(); i1++) {
+ track1 = event1->GetTrack(list1[i1]);
+ //if (!track1) continue;
+ if (!fCuts->IsSelected(AliRsnCut::kParticle, track1)) continue;
+ // loop on particle of type 2 (in second event)
+ // in case we are building a like-sign histogram with particles
+ // of the same type in the same event, we must avoid that
+ // each pair is computed twice
+ start2 = 0;
+ if (listCharged1 == listCharged2) start2 = i1 + 1;
+ for (i2 = start2; i2 < list2.GetSize(); i2++) {
+ track2 = event2->GetTrack(list2[i2]);
+ //if (!track2) continue;
+ if (!fCuts->IsSelected(AliRsnCut::kParticle, track2)) continue;
+ nPairs += Process(track1, track2);
+ }
+ }
+
+ return nPairs;
+}
+
+//_____________________________________________________________________________
+Stat_t AliRsnPairSimple::Process
+(AliRsnDaughter *track1, AliRsnDaughter *track2)
+{
+//
+// Checks the single tracks and the pair against track cuts and,
+// if the cuts are passed, fill the histograms with a weight
+// given by the product of the appropriate PID probabilities of both.
+// The method returns a boolean success value for eventually counting.
+//
+
+ // setup pair and check pair cuts
+ fPair.SetPair(track1, track2);
+ if (!fCuts->IsSelected(AliRsnCut::kPair, &fPair)) return 0.0;
+
+ // if there is a request to process only the pairs born from a true resonance
+ // this is checked here
+ if (fStoreOnlyTrue && !fPair.IsTruePair(fPairDef->GetMotherPDG())) return 0.0;
+
+ // computation variables
+ Double_t mass1 = fPairDef->GetMass(0);
+ Double_t mass2 = fPairDef->GetMass(1);
+ Double_t invmass, invmassMC, weight;
+
+ // assign nominal masses to daughters
+ track1->SetM(mass1);
+ track2->SetM(mass2);
+
+ // if we are here, all cuts are passed - fill histograms
+ invmass = fPair.GetInvMass(mass1, mass2);
+ invmassMC = fPair.GetInvMassMC(mass1, mass2);
+ if (fPIDMethod == AliRsnPID::kNone) {
+ fHistogram->Fill(invmass);
+ fHistogramMC->Fill(invmassMC);
+ if (fPairDef->IsLikeSign() && !fPairDef->HasEqualTypes()) {
+ track1->SetM(mass1);
+ track2->SetM(mass2);
+ if (fCuts->IsSelected(AliRsnCut::kPair, &fPair)) {
+ invmass = fPair.GetInvMass(mass2, mass1);
+ invmassMC = fPair.GetInvMassMC(mass2, mass1);
+ fHistogram->Fill(invmass);
+ fHistogramMC->Fill(invmassMC);
+ }
+ }
+ }
+ else {
+ weight = fPairDef->ComputeWeight(track1, track2);
+ if (weight > 0.0) {
+ fHistogram->Fill(invmass, weight);
+ fHistogramMC->Fill(invmassMC, weight);
+ }
+ // if we are treating a like-sign pair with different types for track #1 and #2,
+ // we must also exchange the tracks and fill again the histogram
+ if (fPairDef->IsLikeSign() && !fPairDef->HasEqualTypes()) {
+ track1->SetM(mass1);
+ track2->SetM(mass2);
+ if (fCuts->IsSelected(AliRsnCut::kPair, &fPair)) {
+ weight = fPairDef->ComputeWeight(track2, track1);
+ invmass = fPair.GetInvMass(mass2, mass1);
+ invmassMC = fPair.GetInvMassMC(mass2, mass1);
+ if (weight > 0.0) {
+ fHistogram->Fill(invmass, weight);
+ fHistogramMC->Fill(invmassMC, weight);
+ }
+ }
+ }
+ }
+
+ return 1.0;
+}
--- /dev/null
+/*************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice *
+ **************************************************************************/
+
+//-------------------------------------------------------------------------
+// Class AliRsnAnalysis
+// Reconstruction and analysis of K* Rsn
+// ........................................
+// ........................................
+// ........................................
+// ........................................
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//-------------------------------------------------------------------------
+
+#ifndef AliRsnPairSimple_H
+#define AliRsnPairSimple_H
+
+#include <TNamed.h>
+#include "AliRsnPID.h"
+#include "AliRsnPairParticle.h"
+
+class TH1D;
+class AliRsnEvent;
+class AliRsnPairDef;
+class AliRsnCutMgr;
+class AliRsnPID;
+
+class AliRsnPairSimple : public TNamed
+{
+
+public:
+
+ AliRsnPairSimple(AliRsnPairDef *pd = 0x0, const char *name = "", const char *title = "");
+ virtual ~AliRsnPairSimple() {Clear();}
+ virtual void Clear(Option_t *option = "");
+
+ // getters
+ TH1D* GetHistogram() {return fHistogram;}
+ TH1D* GetHistogramMC() {return fHistogramMC;}
+ AliRsnPairDef* GetPairDef() {return fPairDef;}
+ AliRsnPairParticle* GetPair() {return &fPair;}
+ Bool_t StoreOnlyTruePairs() const {return fStoreOnlyTrue;}
+ Bool_t IsForMixing() const {return fForMixing;}
+
+ // setters
+ void SetPIDMethod(AliRsnPID::EMethod method) {fPIDMethod = method;}
+ void SetPairDef(AliRsnPairDef *def) {fPairDef = def;}
+ void SetStoreOnlyTrue(Bool_t doit = kTRUE) {fStoreOnlyTrue = doit;}
+ void SetForMixing(Bool_t doit = kTRUE) {fForMixing = doit;}
+ void SetCutManager(AliRsnCutMgr *cutMgr) {fCuts = cutMgr;}
+
+ // working parameters
+ void InitHistograms();
+ Stat_t Process(AliRsnEvent *event1, AliRsnEvent *event2 = 0);
+ Stat_t Process(AliRsnDaughter *t1, AliRsnDaughter *t2);
+
+private:
+
+ // private functions
+ AliRsnPairSimple(const AliRsnPairSimple ©);
+ const AliRsnPairSimple& operator=(const AliRsnPairSimple ©);
+ const char* GetHistName();
+ const char* GetHistTitle();
+
+ // flags
+ AliRsnPID::EMethod fPIDMethod; // flag to know PID method used
+ Bool_t fForMixing; // flag is true for objects created for event mixing
+ Bool_t fStoreOnlyTrue; // output = only spectra of true pairs
+
+ // cut manager
+ AliRsnCutMgr *fCuts; // cut manager for single particle
+
+ // objects
+ AliRsnPairParticle fPair; // utility class for pair
+ AliRsnPairDef *fPairDef; // definitions for pair
+ TH1D *fHistogram; // invariant mass distribution
+ TH1D *fHistogramMC; // invariant mass distribution (MC)
+
+ // ROOT dictionary
+ ClassDef(AliRsnPairSimple, 1)
+};
+
+#endif
// email : alberto.pulvirenti@ct.infn.it
//
+#include <TString.h>
+
#include "AliLog.h"
+#include "AliVEvent.h"
+
#include "AliESDEvent.h"
#include "AliESDtrack.h"
#include "AliESDVertex.h"
#include "AliMCParticle.h"
#include "AliGenEventHeader.h"
-#include "AliRsnParticle.h"
+#include "AliRsnMCInfo.h"
#include "AliRsnDaughter.h"
#include "AliRsnEvent.h"
+#include "AliRsnPIDWeightsMgr.h"
#include "AliRsnReader.h"
ClassImp(AliRsnReader)
-
+
//_____________________________________________________________________________
-AliRsnReader::AliRsnReader(Bool_t checkSplit, Bool_t rejectFakes) :
+AliRsnReader::AliRsnReader(ESource source, AliRsnPIDWeightsMgr *mgr) :
TObject(),
- fCheckSplit(checkSplit),
- fRejectFakes(rejectFakes)
+ fSource(source),
+ fCheckSplit(kFALSE),
+ fRejectFakes(kFALSE),
+ fWeightsMgr(mgr)
{
-//=========================================================
+//
// Constructor.
// Initializes the base-type data members:
// - management of fake tracks
-//=========================================================
+//
}
//_____________________________________________________________________________
AliRsnReader::AliRsnReader(const AliRsnReader ©) :
TObject(copy),
+ fSource(copy.fSource),
fCheckSplit(copy.fCheckSplit),
- fRejectFakes(copy.fRejectFakes)
+ fRejectFakes(copy.fRejectFakes),
+ fWeightsMgr(copy.fWeightsMgr)
{
-//=========================================================
+//
// Copy constructor.
-//=========================================================
+//
}
//_____________________________________________________________________________
AliRsnReader& AliRsnReader::operator=(const AliRsnReader ©)
{
-//=========================================================
+//
// Assignment operator.
-//=========================================================
-
- fCheckSplit = copy.fCheckSplit;
- fRejectFakes = copy.fRejectFakes;
- return (*this);
+//
+
+ fSource = copy.fSource;
+ fCheckSplit = copy.fCheckSplit;
+ fRejectFakes = copy.fRejectFakes;
+ fWeightsMgr = copy.fWeightsMgr;
+ return (*this);
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnReader::Fill(AliRsnEvent *rsn, AliVEvent *event, AliMCEvent *mc)
+{
+//
+// According to the class type of event and the selected source
+// recalls one of the private reading methods to fill the RsnEvent
+// passed by reference as first argument.
+//
+
+ TString str(event->ClassName());
+
+ switch (fSource) {
+ case kESD:
+ if (!str.Contains("AliESDEvent")) {
+ AliError("A reader set to 'kESD' or 'kESDTPC' can read only ESD events");
+ return kFALSE;
+ }
+ return FillFromESD(rsn, (AliESDEvent*)event, mc);
+ case kESDTPC:
+ if (!str.Contains("AliESDEvent")) {
+ AliError("A reader set to 'kESD' or 'kESDTPC' can read only ESD events");
+ return kFALSE;
+ }
+ return FillFromESD(rsn, (AliESDEvent*)event, mc, kTRUE);
+ case kAOD:
+ if (!str.Contains("AliAODEvent")) {
+ AliError("A reader set to 'kAOD' can read only AOD events");
+ return kFALSE;
+ }
+ return FillFromAOD(rsn, (AliAODEvent*)event, mc);
+ case kMC:
+ if (!str.Contains("AliMCEvent")) {
+ AliError("A reader set to 'kMC' can read only MC events");
+ return kFALSE;
+ }
+ return FillFromMC(rsn, (AliMCEvent*)event);
+ default:
+ return kFALSE;
+ }
}
//_____________________________________________________________________________
-Bool_t AliRsnReader::FillFromESD(AliRsnEvent *rsn, AliESDEvent *esd, AliMCEvent *mc)
+Bool_t AliRsnReader::FillFromESD
+(AliRsnEvent *rsn, AliESDEvent *esd, AliMCEvent *mc, Bool_t useTPCOnly)
{
-//=========================================================
+//
// Filler from an ESD event.
// Stores all tracks (if a filter is defined, it will store
// only the ones which survive the cuts).
// 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'.
-//=========================================================
-
- // set source flag
- rsn->SetSource(AliRsnEvent::kESD);
-
- // retrieve stack (if possible)
- AliStack *stack = 0x0;
- if (mc) stack = mc->Stack();
-
- // get number of tracks
- Int_t ntracks = esd->GetNumberOfTracks();
- if (!ntracks) {
- AliWarning("No tracks in this event");
- return kFALSE;
+//
+
+ // retrieve stack (if possible)
+ AliStack *stack = 0x0;
+ if (mc) stack = mc->Stack();
+
+ // get number of tracks
+ Int_t ntracks = esd->GetNumberOfTracks();
+ /*
+ if (!ntracks) {
+ AliWarning("No tracks in this event");
+ return kFALSE;
}
+ */
// if required with the flag, scans the event
// and searches all split tracks (= 2 tracks with the same label);
lab2 = TMath::Abs(trk2->GetLabel());
// check if labels are equal
if (lab1 == lab2) {
- if (trk1->GetConstrainedChi2() > trk2->GetConstrainedChi2()) {
+ if (trk1->GetConstrainedChi2() < trk2->GetConstrainedChi2()) {
accept[i1] = kTRUE;
accept[i2] = kFALSE;
}
}
}
}
-
- // get primary vertex
- Double_t vertex[3];
- vertex[0] = esd->GetVertex()->GetXv();
- vertex[1] = esd->GetVertex()->GetYv();
- vertex[2] = esd->GetVertex()->GetZv();
- rsn->SetPrimaryVertex(vertex[0], vertex[1], vertex[2]);
-
- // store tracks from ESD
- Int_t index, label, labmum;
+
+ // get primary vertex
+ Double_t vertex[3];
+ if (!useTPCOnly) {
+ vertex[0] = esd->GetVertex()->GetXv();
+ vertex[1] = esd->GetVertex()->GetYv();
+ vertex[2] = esd->GetVertex()->GetZv();
+ }
+ 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;
Bool_t check;
AliRsnDaughter temp;
for (index = 0; index < ntracks; index++) {
if (fRejectFakes && (label < 0)) continue;
// copy ESD track data into RsnDaughter
// if unsuccessful, this track is skipped
- check = temp.Adopt(esdTrack);
+ check = temp.Adopt(esdTrack, 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) {
+ //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->GetTPCpid(fWeightsMgr->GetWeightArray(AliRsnPIDWeightsMgr::kTPC));
+ 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++) {
+ 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 {
+ //AliInfo("Using standard ESD weights");
+ }
+
// if stack is present, copy MC info
if (stack) {
TParticle *part = stack->Particle(TMath::Abs(label));
if (part) {
- temp.InitParticle(part);
+ temp.InitMCInfo(part);
labmum = part->GetFirstMother();
if (labmum >= 0) {
TParticle *mum = stack->Particle(labmum);
- temp.GetParticle()->SetMotherPDG(mum->GetPdgCode());
+ temp.GetMCInfo()->SetMotherPDG(mum->GetPdgCode());
}
}
}
//_____________________________________________________________________________
Bool_t AliRsnReader::FillFromAOD(AliRsnEvent *rsn, AliAODEvent *aod, AliMCEvent *mc)
{
-//=========================================================
+//
// Filler from an AOD event.
// Stores all tracks (if a filter is defined, it will store
// only the ones which survive the cuts).
// 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'.
-//=========================================================
-
- // set source flag
- rsn->SetSource(AliRsnEvent::kAOD);
+//
// retrieve stack (if possible)
- AliStack *stack = 0x0;
- if (mc) stack = mc->Stack();
+ AliStack *stack = 0x0;
+ if (mc) stack = mc->Stack();
// get number of tracks
- Int_t ntracks = aod->GetNTracks();
- if (!ntracks) {
- AliWarning("No tracks in this event");
- return kFALSE;
+ Int_t ntracks = aod->GetNTracks();
+ if (!ntracks) {
+ AliWarning("No tracks in this event");
+ return kFALSE;
}
-
- // get primary vertex
- Double_t vertex[3];
- vertex[0] = aod->GetPrimaryVertex()->GetX();
- vertex[1] = aod->GetPrimaryVertex()->GetY();
- vertex[2] = aod->GetPrimaryVertex()->GetZ();
- rsn->SetPrimaryVertex(vertex[0], vertex[1], vertex[2]);
-
- // store tracks from ESD
+
+ // get primary vertex
+ Double_t vertex[3];
+ vertex[0] = aod->GetPrimaryVertex()->GetX();
+ vertex[1] = aod->GetPrimaryVertex()->GetY();
+ vertex[2] = aod->GetPrimaryVertex()->GetZ();
+ rsn->SetPrimaryVertex(vertex[0], vertex[1], vertex[2]);
+
+ // store tracks from ESD
Int_t index, label, labmum;
Bool_t check;
AliAODTrack *aodTrack = 0;
if (stack) {
TParticle *part = stack->Particle(TMath::Abs(label));
if (part) {
- temp.InitParticle(part);
+ temp.InitMCInfo(part);
labmum = part->GetFirstMother();
if (labmum >= 0) {
TParticle *mum = stack->Particle(labmum);
- temp.GetParticle()->SetMotherPDG(mum->GetPdgCode());
+ temp.GetMCInfo()->SetMotherPDG(mum->GetPdgCode());
}
}
}
//_____________________________________________________________________________
Bool_t AliRsnReader::FillFromMC(AliRsnEvent *rsn, AliMCEvent *mc)
{
-//=========================================================
+//
// Filler from an ESD event.
// Stores all tracks which generate at least one
// TrackReference (a point in a sensitive volume).
// perfect particle identification is the unique available.
// When this is used, the 'source' flag of the output
// AliRsnEvent object will be set to 'kMC'.
-//=========================================================
-
- // set source flag
- rsn->SetSource(AliRsnEvent::kMC);
-
- // get number of tracks
- Int_t ntracks = mc->GetNumberOfTracks();
- if (!ntracks) {
- AliWarning("No tracks in this event");
- return kFALSE;
+//
+
+ // get number of tracks
+ Int_t ntracks = mc->GetNumberOfTracks();
+ if (!ntracks) {
+ AliWarning("No tracks in this event");
+ return kFALSE;
}
AliStack *stack = mc->Stack();
-
- // get primary vertex
- TArrayF fvertex(3);
- Double_t vertex[3];
- mc->GenEventHeader()->PrimaryVertex(fvertex);
- vertex[0] = (Double_t)fvertex[0];
- vertex[1] = (Double_t)fvertex[1];
- vertex[2] = (Double_t)fvertex[2];
- rsn->SetPrimaryVertex(vertex[0], vertex[1], vertex[2]);
-
- // store tracks from MC
+
+ // get primary vertex
+ TArrayF fvertex(3);
+ Double_t vertex[3];
+ mc->GenEventHeader()->PrimaryVertex(fvertex);
+ vertex[0] = (Double_t)fvertex[0];
+ vertex[1] = (Double_t)fvertex[1];
+ vertex[2] = (Double_t)fvertex[2];
+ rsn->SetPrimaryVertex(vertex[0], vertex[1], vertex[2]);
+
+ // store tracks from MC
Int_t index, labmum;
Bool_t check;
AliRsnDaughter temp;
// try to insert in the RsnDaughter its data
check = temp.Adopt(mcTrack);
if (!check) continue;
- labmum = temp.GetParticle()->Mother();
+ labmum = temp.GetMCInfo()->Mother();
if (labmum >= 0) {
TParticle *mum = stack->Particle(labmum);
- temp.GetParticle()->SetMotherPDG(mum->GetPdgCode());
+ temp.GetMCInfo()->SetMotherPDG(mum->GetPdgCode());
}
// if successful, set other data and stores it
temp.SetIndex(index);
#ifndef ALIRSNREADER_H
#define ALIRSNREADER_H
+class AliVEvent;
class AliESDEvent;
class AliAODEvent;
class AliMCEvent;
class AliRsnEvent;
+class AliRsnPIDWeightsMgr;
class AliRsnReader : public TObject
{
public:
+
+ enum ESource {
+ kESD = 0,
+ kESDTPC,
+ kAOD,
+ kMC,
+ kSources
+ };
+
+ AliRsnReader(ESource source = kESD, AliRsnPIDWeightsMgr *mgr = 0x0);
+ AliRsnReader(const AliRsnReader& copy);
+ AliRsnReader& operator=(const AliRsnReader& copy);
+ virtual ~AliRsnReader() {}
- AliRsnReader(Bool_t checkSplit = kTRUE, Bool_t rejectFakes = kFALSE);
- AliRsnReader(const AliRsnReader& copy);
- AliRsnReader& operator=(const AliRsnReader& copy);
- virtual ~AliRsnReader() {}
-
- void SetCheckSplit(Bool_t doit = kTRUE) {fCheckSplit = doit;}
- void SetRejectFakes(Bool_t doit = kTRUE) {fRejectFakes = doit;}
- Bool_t FillFromESD(AliRsnEvent *rsn, AliESDEvent *event, AliMCEvent *refMC = 0);
- Bool_t FillFromAOD(AliRsnEvent *rsn, AliAODEvent *event, AliMCEvent *refMC = 0);
- Bool_t FillFromMC(AliRsnEvent *rsn, AliMCEvent *mc);
+ void SetWeightsMgr(AliRsnPIDWeightsMgr *mgr) {fWeightsMgr = mgr;}
+ void SetCheckSplit(Bool_t doit = kTRUE) {fCheckSplit = doit;}
+ void SetRejectFakes(Bool_t doit = kTRUE) {fRejectFakes = doit;}
+
+ Bool_t Fill(AliRsnEvent *rsn, AliVEvent *event, AliMCEvent *refMC = 0);
protected:
- Bool_t fCheckSplit; // flag to check and remove split tracks
- Bool_t fRejectFakes; // flag to reject fake tracks (negative label)
+ 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);
+
+ 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:
- ClassDef(AliRsnReader, 1);
+ ClassDef(AliRsnReader, 1);
};
#endif
**************************************************************************/
//----------------------------------------------------------------------------------
-// Class AliRsnReaderTask
+// Class AliRsnReaderTaskSE
// ------------------------
// Reader for conversion of ESD output into the internal format
// used for resonance study.
#include "AliAODHandler.h"
#include "AliRsnEvent.h"
-#include "AliRsnReaderTask.h"
+#include "AliRsnReader.h"
+#include "AliRsnPID.h"
+#include "AliRsnReaderTaskSE.h"
-ClassImp(AliRsnReaderTask)
+ClassImp(AliRsnReaderTaskSE)
//_____________________________________________________________________________
-AliRsnReaderTask::AliRsnReaderTask(ESource source) :
+AliRsnReaderTaskSE::AliRsnReaderTaskSE() :
AliAnalysisTaskSE(),
- fSource(source),
fReader(0x0),
fPID(0x0),
- fRsnEvents(0x0)
+ fRsnEvent(0x0)
{
//=========================================================
// Default constructor (not recommended)
}
//_____________________________________________________________________________
-AliRsnReaderTask::AliRsnReaderTask(const char *name, ESource source) :
+AliRsnReaderTaskSE::AliRsnReaderTaskSE(const char *name) :
AliAnalysisTaskSE(name),
- fSource(source),
fReader(0x0),
fPID(0x0),
- fRsnEvents(0x0)
+ fRsnEvent(0x0)
{
//=========================================================
// Working constructor (recommended)
+// Initializes the reader and PID objects.
//=========================================================
+
+ fReader = new AliRsnReader;
+ fPID = new AliRsnPID;
}
//_____________________________________________________________________________
-AliRsnReaderTask::AliRsnReaderTask(const AliRsnReaderTask& obj) :
+AliRsnReaderTaskSE::AliRsnReaderTaskSE(const AliRsnReaderTaskSE& obj) :
AliAnalysisTaskSE(obj),
- fSource(obj.fSource),
fReader(obj.fReader),
fPID(obj.fPID),
- fRsnEvents(0x0)
+ fRsnEvent(0x0)
{
//=========================================================
// Copy constructor (not recommended)
}
//_____________________________________________________________________________
-AliRsnReaderTask& AliRsnReaderTask::operator=(const AliRsnReaderTask& /*obj*/)
+AliRsnReaderTaskSE& AliRsnReaderTaskSE::operator=(const AliRsnReaderTaskSE& /*obj*/)
{
//=========================================================
// Assignment operator (not recommended)
}
//_____________________________________________________________________________
-void AliRsnReaderTask::UserCreateOutputObjects()
+void AliRsnReaderTaskSE::UserCreateOutputObjects()
{
//=========================================================
// Create the output container
//=========================================================
AliDebug(1, "Creating USER output objects");
- fRsnEvents = new TClonesArray("AliRsnEvent", 0);
- fRsnEvents->SetName("AliRsnEvents");
- AddAODBranch("TClonesArray", fRsnEvents);
+
+ // check for existence of reader, otherwise abort
+ if (!fReader) {
+ AliFatal("Event reader not initialized. Impossible to continue");
+ return;
+ }
+ if (!fPID) {
+ AliFatal("PID manager not initialized. Impossible to continue");
+ return;
+ }
+ else {
+ // the PID object is always used in realistic mode here
+ // to fill the "realistic" index array in AliRsnEvent
+ fPID->SetMethod(AliRsnPID::kRealistic);
+ }
+
+ fRsnEvent = new AliRsnEvent();
+ fRsnEvent->SetName("rsnEvents");
+ fRsnEvent->Init();
+ AddAODBranch("AliRsnEvent", &fRsnEvent);
}
//_____________________________________________________________________________
-void AliRsnReaderTask::Init()
+void AliRsnReaderTaskSE::Init()
{
//=========================================================
// Initialization
}
//_____________________________________________________________________________
-void AliRsnReaderTask::UserExec(Option_t */*option*/)
+void AliRsnReaderTaskSE::UserExec(Option_t */*option*/)
{
//=========================================================
// Loops on input container to store data of all tracks.
//=========================================================
// static counter
- static Int_t ientry = 0;
- AliInfo(Form("Reading event %d", ++ientry));
-
+ AliInfo(Form("Reading event %d", ++fEntry));
+
// clear previous sample
- fRsnEvents->Clear();
-
- // check for existence of reader, otherwise abort
- if (!fReader) {
- AliError("Event reader not initialized. Impossible to continue");
- return;
- }
- if (!fPID) {
- AliError("PID manager not initialized. Impossible to continue");
- return;
- }
-
-
- // get MC reference event
- AliMCEventHandler* mcHandler = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
- AliMCEvent *mcEvent = 0x0;
- if (mcHandler) mcEvent = mcHandler->MCEvent();
-
- // work-flow variables
- Bool_t successRead;
- Int_t nextIndex = fRsnEvents->GetEntries();
- TClonesArray &array = *fRsnEvents;
- AliRsnEvent *event = new(array[nextIndex]) AliRsnEvent;
- if (!event) {
- AliError("Problem occurred while creating new AliRsnEvent object. Aborting");
- return;
- }
- event->Init();
- AliESDInputHandler *handlerESD;
- AliAODInputHandler *handlerAOD;
- AliESDEvent *esd;
- AliAODEvent *aod;
-
- // read source event according to reader settings
- switch (fSource) {
- case kESD: // read from ESD event
- handlerESD = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
- if (!handlerESD) {
- AliError("Source set to 'ESD' but ESD handler not initialized");
- return;
- }
- esd = handlerESD->GetEvent();
- if (!esd) {
- AliError("Source set to 'ESD' but ESD event not found in handler");
- return;
- }
- if (!mcEvent) AliWarning("MC info not present");
- successRead = fReader->FillFromESD(event, esd, mcEvent);
- break;
- case kAOD: // read from AOD event
- handlerAOD = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
- if (!handlerAOD) {
- AliError("Source set to 'AOD' but AOD handler not initialized");
- return;
- }
- aod = handlerAOD->GetEvent();
- if (!aod) {
- AliError("Source set to 'AOD' but AOD event not found in handler");
- return;
- }
- if (!mcEvent) AliWarning("MC info not present");
- successRead = fReader->FillFromAOD(event, aod, mcEvent);
- break;
- case kMC: // read from MC truth only
- if (!mcEvent) {
- AliError("Required usage of MC event for reading. Not possible without MC info. Impossible to continue");
- return;
- }
- successRead = fReader->FillFromMC(event, mcEvent);
- break;
- default: // unrecognized option
- AliError("Source flag not properly set");
- return;
- }
- if (!successRead) {
- array.RemoveAt(nextIndex);
- return;
- }
-
- // if the event reading is successful, perform particle identification
- if (!fPID->Identify(event)) AliWarning(Form("Failed PID for event %d", ientry));
- AliInfo(Form("Event %d: collected %d tracks", ientry, event->GetMultiplicity()));
+ fRsnEvent->Clear();
+
+ // read event, identify
+ if (!fReader->Fill(fRsnEvent, fInputEvent, fMCEvent)) AliWarning("Failed reading");
+ if (!fPID->Identify(fRsnEvent)) AliWarning("Failed PID");
+ AliInfo(Form("Collected %d tracks", fRsnEvent->GetMultiplicity()));
}
//_____________________________________________________________________________
-void AliRsnReaderTask::Terminate(Option_t */*option*/)
+void AliRsnReaderTaskSE::Terminate(Option_t */*option*/)
{
//=========================================================
// Terminate analysis
**************************************************************************/
//----------------------------------------------------------------------------------
-// Class AliRsnReaderTask
+// Class AliRsnReaderTaskSE
// ------------------------
// Reader for conversion of ESD output into the internal format
// used for resonance study.
// by : R. Vernet (email: renaud.vernet@cern.ch)
//----------------------------------------------------------------------------------
-#ifndef ALIRSNREADERTASK_H
-#define ALIRSNREADERTASK_H
+#ifndef AliRsnReaderTaskSE_H
+#define AliRsnReaderTaskSE_H
#include "AliAnalysisTaskSE.h"
-#include "AliRsnReader.h"
-#include "AliRsnPID.h"
+//#include "AliRsnReader.h"
+//#include "AliRsnPID.h"
-class TTree;
-class TBranch;
class AliESDEvent;
+class AliRsnPID;
+class AliRsnReader;
-class AliRsnReaderTask : public AliAnalysisTaskSE
+class AliRsnReaderTaskSE : public AliAnalysisTaskSE
{
public:
- enum ESource {
- kESD = 0,
- kAOD,
- kMC
- };
-
- AliRsnReaderTask(ESource source = kESD);
- AliRsnReaderTask(const char *name, ESource source = kESD);
- virtual ~AliRsnReaderTask() {Clear();}
+ AliRsnReaderTaskSE();
+ AliRsnReaderTaskSE(const char *name);
+ virtual ~AliRsnReaderTaskSE() {Clear();}
// Implementation of interface methods
virtual void UserCreateOutputObjects();
virtual void LocalInit() {Init();}
virtual void UserExec(Option_t *option);
virtual void Terminate(Option_t *option);
-
+
// setters
void SetReader(AliRsnReader *reader) {fReader = reader;}
void SetPID(AliRsnPID *pid) {fPID = pid;}
- void SetSource(ESource source) {fSource = source;}
-
+
// getters
AliRsnReader* GetReader() {return fReader;}
AliRsnPID* GetPID() {return fPID;}
private:
- AliRsnReaderTask(const AliRsnReaderTask&);
- AliRsnReaderTask& operator=(const AliRsnReaderTask&);
-
- ESource fSource; // source of data
-
- AliRsnReader* fReader; // read manager
- AliRsnPID* fPID; // particle identification manager
- TClonesArray* fRsnEvents; // output events in the AliRsnEvent format
-
- ClassDef(AliRsnReaderTask, 0); // implementation of RsnReader as AnalysisTaskSE
+ AliRsnReaderTaskSE(const AliRsnReaderTaskSE&);
+ AliRsnReaderTaskSE& operator=(const AliRsnReaderTaskSE&);
+
+ AliRsnReader *fReader; // read manager
+ AliRsnPID *fPID; // particle identification manager
+ AliRsnEvent *fRsnEvent; // output events in the AliRsnEvent format
+
+ ClassDef(AliRsnReaderTaskSE, 0); // implementation of RsnReader as AnalysisTaskSE
};
#endif