1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //////////////////////////////////////////////////////////////////////////
20 Allow to monitor how many tracks,pair,events pass the selection criterion
21 in any of the cuts added to the corresponding filters. All you need to
22 add to your config is the following:
24 dielectron->SetCutQA();
29 //////////////////////////////////////////////////////////////////////////
31 #include "AliDielectronCutQA.h"
34 #include <TCollection.h>
36 #include "AliDielectronCutGroup.h"
37 #include "AliAnalysisCuts.h"
39 #include "AliVEvent.h"
40 #include "AliVParticle.h"
41 #include "AliVTrack.h"
42 #include "AliDielectronPair.h"
45 ClassImp(AliDielectronCutQA)
48 AliDielectronCutQA::AliDielectronCutQA() :
53 // Default constructor
55 for(Int_t itype=0; itype<kNtypes; itype++) {
58 for(Int_t i=0; i<20; i++) {
59 fCutNames[i][itype]="";
62 fTypeKeys[kTrack] = "Track";
63 fTypeKeys[kPair] = "Pair";
64 fTypeKeys[kEvent] = "Event";
65 fQAHistArray.SetOwner();
68 //_____________________________________________________________________
69 AliDielectronCutQA::AliDielectronCutQA(const char* name, const char* title) :
76 for(Int_t itype=0; itype<kNtypes; itype++) {
79 for(Int_t i=0; i<20; i++) {
80 fCutNames[i][itype]="";
83 fTypeKeys[kTrack] = "Track";
84 fTypeKeys[kPair] = "Pair";
85 fTypeKeys[kEvent] = "Event";
86 fQAHistArray.SetOwner();
89 //_____________________________________________________________________
90 AliDielectronCutQA::~AliDielectronCutQA()
95 fQAHistArray.Delete();
98 //_____________________________________________________________________
99 void AliDielectronCutQA::Init()
102 fQAHistArray.SetName(Form("%s",GetName()));
104 // loop over all types
105 for(Int_t itype=0; itype<kNtypes; itype++) {
106 // printf("\n type: %d\n",itype);
107 fCutNames[0][itype]="no cuts";
109 // create histogram based on added cuts
110 fCutQA[itype] = new TH1F(fTypeKeys[itype],
111 Form("%sQA;cuts;# passed %ss",fTypeKeys[itype],fTypeKeys[itype]),
112 fNCuts[itype],0,fNCuts[itype]);
113 // loop over all cuts
114 for(Int_t i=0; i<fNCuts[itype]; i++) {
115 fCutQA[itype]->GetXaxis()->SetBinLabel(i+1,fCutNames[i][itype]);
116 // printf(" %s \n",fCutNames[i][itype]);
118 fQAHistArray.AddLast(fCutQA[itype]);
123 //_____________________________________________________________________
124 void AliDielectronCutQA::AddTrackFilter(AliAnalysisFilter *trackFilter)
127 // add track filter cuts to the qa histogram
131 TIter listIterator(trackFilter->GetCuts());
132 while (AliAnalysisCuts *thisCut = (AliAnalysisCuts*) listIterator()) {
135 // add new cut class to the array
137 fCutNames[fNCuts[kTrack]][kTrack]=thisCut->GetTitle();
138 // printf("add cut %s to %d \n",thisCut->GetTitle(),fNCuts[kTrack]);
142 } // pair filter loop
147 //_____________________________________________________________________
148 void AliDielectronCutQA::AddPairFilter(AliAnalysisFilter *pairFilter)
151 // add track filter cuts to the qa histogram
155 TIter listIterator(pairFilter->GetCuts());
156 while (AliAnalysisCuts *thisCut = (AliAnalysisCuts*) listIterator()) {
159 // add new cut class to the array
161 fCutNames[fNCuts[kPair]][kPair]=thisCut->GetTitle();
162 // printf("add cut %s to %d \n",thisCut->GetTitle(),fNCuts[kPair]);
170 //_____________________________________________________________________
171 void AliDielectronCutQA::AddEventFilter(AliAnalysisFilter *eventFilter)
174 // add track filter cuts to the qa histogram
178 TIter listIterator(eventFilter->GetCuts());
179 while (AliAnalysisCuts *thisCut = (AliAnalysisCuts*) listIterator()) {
182 // add new cut class to the array
184 fCutNames[fNCuts[kEvent]][kEvent]=thisCut->GetTitle();
185 // printf("add cut %s to %d \n",thisCut->GetTitle(),fNCuts[kEvent]);
193 //_____________________________________________________________________
194 void AliDielectronCutQA::Fill(UInt_t mask, TObject *obj)
197 // fill the corresponding step in the qa histogram
200 UInt_t idx = GetObjIndex(obj);
203 for (Int_t iCut=0; iCut<fNCuts[idx]-1;++iCut) {
204 // UInt_t cutMask=1<<iCut; // for each cut
205 UInt_t cutMask=(1<<(iCut+1))-1; // increasing cut match
207 if ((mask&cutMask)==cutMask) {
208 fCutQA[idx]->Fill(cutstep);
216 //_____________________________________________________________________
217 void AliDielectronCutQA::FillAll(TObject *obj)
220 // fill the corresponding step in the qa histogram
223 UInt_t idx = GetObjIndex(obj);
224 fCutQA[idx]->Fill(0);
228 //______________________________________________________________________
229 UInt_t AliDielectronCutQA::GetObjIndex(TObject *obj)
232 // return the corresponding idex
234 // printf("INFO: object type is a %s \n", obj->IsA()->GetName());
235 if(obj->InheritsFrom(AliDielectronPair::Class())) return kPair;
236 if(obj->InheritsFrom(AliVTrack::Class()) ) return kTrack;
237 if(obj->InheritsFrom(AliVParticle::Class()) ) return kTrack;
238 if(obj->InheritsFrom(AliVEvent::Class()) ) return kEvent;
239 printf("FATAL: object type %s not yet supported, please let the author know\n", obj->IsA()->GetName());