/************************************************************************** * 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. * **************************************************************************/ /////////////////////////////////////////////////////////////////////////// // The class AliCFManager is designed to handle inside the // task the basic components for a particle-level correction of single // particle analysis // The class provides methods to set lists of cuts and to loop over them // for several different selection steps to be then used for // efficiency calculation. // prototype version by S.Arcelli silvia.arcelli@cern.ch /////////////////////////////////////////////////////////////////////////// #include "TBits.h" #include "TList.h" #include "TH1.h" #include "AliLog.h" #include "AliCFCutBase.h" #include "AliCFManager.h" ClassImp(AliCFManager) //_____________________________________________________________________________ AliCFManager::AliCFManager() : TNamed(), fEvtContainer(0x0), fPartContainer(0x0), fhQABits(0x0) { // // ctor // for(Int_t i=0;ifEvtContainer=c.fEvtContainer; this->fPartContainer=c.fPartContainer; this->fhQABits=c.fhQABits; for(Int_t i=0;ifEvtCutList[i]=c.fEvtCutList[i]; for(Int_t i=0;ifPartCutList[i]=c.fPartCutList[i]; return *this ; } //_____________________________________________________________________________ AliCFManager::~AliCFManager() { // //dtor // if(fhQABits) delete fhQABits; } //_____________________________________________________________________________ Bool_t AliCFManager::CheckParticleCuts(Int_t isel, TObject *obj, const TString &selcuts) const { // // check whether object obj passes particle-level selection isel // if(isel>=kNPartSel){ AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNPartSel)); return kTRUE; } if(!fPartCutList[isel])return kTRUE; TObjArrayIter iter(fPartCutList[isel]); AliCFCutBase *cut = 0; while ( (cut = (AliCFCutBase*)iter.Next()) ) { TString cutName=cut->GetName(); Bool_t checkCut=CompareStrings(cutName,selcuts); if(checkCut && !cut->IsSelected(obj)) return kFALSE; } return kTRUE; } //_____________________________________________________________________________ Bool_t AliCFManager::CheckEventCuts(Int_t isel, TObject *obj, const TString &selcuts) const{ // // check whether object obj passes event-level selection isel // if(isel>=kNEvtSel){ AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNEvtSel)); return kTRUE; } if(!fEvtCutList[isel])return kTRUE; TObjArrayIter iter(fEvtCutList[isel]); AliCFCutBase *cut = 0; while ( (cut = (AliCFCutBase*)iter.Next()) ) { TString cutName=cut->GetName(); Bool_t checkCut=CompareStrings(cutName,selcuts); if(checkCut && !cut->IsSelected(obj)) return kFALSE; } return kTRUE; } //_____________________________________________________________________________ void AliCFManager::FillQABeforeParticleCuts(Int_t isel, TObject *obj) const{ // // Fill QA histos before cuts at particle selection level isel are applied // if(isel>=kNPartSel){ AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNPartSel)); return; } if(!fPartCutList[isel])return; TObjArrayIter iter(fPartCutList[isel]); AliCFCutBase *cut = 0; while ( (cut = (AliCFCutBase*)iter.Next()) ) { if(cut->IsQAOn())cut->FillHistogramsBeforeCuts(obj); } } //_____________________________________________________________________________ void AliCFManager::FillQAAfterParticleCuts(Int_t isel, TObject *obj) const{ // // Fill QA histos after cuts at particle selection level isel are applied // if(isel>=kNPartSel){ AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNPartSel)); return; } if(!fPartCutList[isel])return; TObjArrayIter iter(fPartCutList[isel]); AliCFCutBase *cut = 0; while ( (cut = (AliCFCutBase*)iter.Next()) ) { if(cut->IsQAOn())cut->FillHistogramsAfterCuts(obj); } } //_____________________________________________________________________________ void AliCFManager::FillQABeforeEventCuts(Int_t isel, TObject *obj) const{ // // Fill QA histos before cuts at event selection level isel are applied // if(isel>=kNEvtSel){ AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNEvtSel)); return; } if(!fEvtCutList[isel])return; TObjArrayIter iter(fEvtCutList[isel]); AliCFCutBase *cut = 0; while ( (cut = (AliCFCutBase*)iter.Next()) ) { if(cut->IsQAOn())cut->FillHistogramsBeforeCuts(obj); } } //_____________________________________________________________________________ void AliCFManager::FillQAAfterEventCuts(Int_t isel, TObject *obj) const{ // // Fill QA histos after cuts at event selection level isel are applied // if(isel>=kNEvtSel){ AliWarning(Form("Selection index out of Range! isel=%i, max. number of selections= %i", isel,kNEvtSel)); return; } if(!fEvtCutList[isel])return; TObjArrayIter iter(fEvtCutList[isel]); AliCFCutBase *cut = 0; while ( (cut = (AliCFCutBase*)iter.Next()) ) { if(cut->IsQAOn())cut->FillHistogramsAfterCuts(obj); } } //_____________________________________________________________________________ void AliCFManager::AddQAHistosToList(TList *list) const { // // Add to list the full list of QA histograms to be written to the output // for(Int_t isel=0;iselIsQAOn())cut->AddQAHistograms(list); } } //Event-level cuts QA for(Int_t isel=0;iselIsQAOn())cut->AddQAHistograms(list); } } } //_____________________________________________________________________________ TBits* AliCFManager::GetQAParticleSelBits(Int_t isel, TObject *obj) { // // Get the full list of QA histograms to be written to the output // fhQABits->Clear(); //reset the list //Particle-level cuts QA if(fPartCutList[isel]){ TObjArrayIter iter(fPartCutList[isel]); AliCFCutBase *cut = 0; while ( (cut = (AliCFCutBase*)iter.Next()) ) { if(cut->IsQAOn()){ TBits *qalist=new TBits(0); cut->GetBitMap(obj,qalist); for(UInt_t icut=0;icutGetNbits();icut++){ fhQABits->SetBitNumber(icut,qalist->TestBitNumber(icut)); } delete qalist; } } } return fhQABits; } //_____________________________________________________________________________ void AliCFManager::SetEventInfo(TObject *obj) const { //Particle level cuts for(Int_t isel=0;iselSetEvtInfo(obj); } } //Event level cuts for(Int_t isel=0;iselSetEvtInfo(obj); } } } //_____________________________________________________________________________ void AliCFManager::InitQAHistos() const { //Particle level cuts for(Int_t isel=0;iselIsQAOn())cut->Init(); } } //Event level cuts for(Int_t isel=0;iselIsQAOn())cut->Init(); } } } //_____________________________________________________________________________ Bool_t AliCFManager::CompareStrings(const TString &cutname,const TString &selcuts) const{ // // compare two strings // if(selcuts.Contains("all"))return kTRUE; if ( selcuts.CompareTo(cutname) == 0 || selcuts.BeginsWith(cutname+" ") || selcuts.EndsWith(" "+cutname) || selcuts.Contains(" "+cutname+" ")) return kTRUE; return kFALSE; }