1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
15 /************************************************************************
17 * Extra cuts implemented by the ALICE Heavy Flavour Electron Group *
20 * - TPC cluster ratio *
24 * Markus Fasel <M.Fasel@gsi.de> *
26 ************************************************************************/
34 #include "AliESDtrack.h"
36 #include "AliMCParticle.h"
38 #include "AliHFEextraCuts.h"
40 ClassImp(AliHFEextraCuts)
42 //______________________________________________________
43 AliHFEextraCuts::AliHFEextraCuts(const Char_t *name, const Char_t *title):
44 AliCFCutBase(name, title),
53 // Default Constructor
55 memset(fImpactParamCut, 0, sizeof(Float_t) * 4);
58 //______________________________________________________
59 AliHFEextraCuts::AliHFEextraCuts(const AliHFEextraCuts &c):
61 fCutCorrelation(c.fCutCorrelation),
62 fRequirements(c.fRequirements),
63 fClusterRatioTPC(c.fClusterRatioTPC),
64 fMinTrackletsTRD(c.fMinTrackletsTRD),
65 fPixelITS(c.fPixelITS),
70 // Performs a deep copy
72 memcpy(fImpactParamCut, c.fImpactParamCut, sizeof(Float_t) * 4);
75 fQAlist = dynamic_cast<TList *>(c.fQAlist->Clone());
80 //______________________________________________________
81 AliHFEextraCuts &AliHFEextraCuts::operator=(const AliHFEextraCuts &c){
83 // Assignment operator
86 AliCFCutBase::operator=(c);
87 fCutCorrelation = c.fCutCorrelation;
88 fRequirements = c.fRequirements;
89 fClusterRatioTPC = c.fClusterRatioTPC;
90 fMinTrackletsTRD = c.fMinTrackletsTRD;
91 fPixelITS = c.fPixelITS;
93 memcpy(fImpactParamCut, c.fImpactParamCut, sizeof(Float_t) * 4);
96 fQAlist = dynamic_cast<TList *>(c.fQAlist->Clone());
103 //______________________________________________________
104 AliHFEextraCuts::~AliHFEextraCuts(){
114 //______________________________________________________
115 Bool_t AliHFEextraCuts::IsSelected(TObject *o){
117 // Steering function for the track selection
119 if(TString(o->IsA()->GetName()).CompareTo("AliESDtrack") == 0){
120 return CheckESDCuts(dynamic_cast<AliESDtrack *>(o));
122 return CheckMCCuts(dynamic_cast<AliMCParticle *>(o));
125 //______________________________________________________
126 Bool_t AliHFEextraCuts::CheckESDCuts(AliESDtrack *track){
128 // Checks cuts on reconstructed tracks
129 // returns true if track is selected
130 // QA histograms are filled before track selection and for
131 // selected tracks after track selection
133 ULong64_t survivedCut = 0; // Bitmap for cuts which are passed by the track, later to be compared with fRequirements
134 if(IsQAOn()) FillQAhistosESD(track, kBeforeCuts);
136 Float_t impact_r, impact_z, ratioTPC;
137 track->GetImpactParameters(impact_r, impact_z);
138 // printf("Check TPC findable clusters: %d, found Clusters: %d\n", track->GetTPCNclsF(), track->GetTPCNcls());
139 ratioTPC = track->GetTPCNclsF() > 0. ? static_cast<Float_t>(track->GetTPCNcls())/static_cast<Float_t>(track->GetTPCNclsF()) : 1.;
140 UChar_t trdTracklets;
142 trdTracklets = track->GetTRDntrackletsPID();
144 trdTracklets = track->GetTRDpidQuality();
146 UChar_t itsPixel = track->GetITSClusterMap();
147 if(TESTBIT(fRequirements, kMinImpactParamR)){
148 // cut on min. Impact Parameter in Radial direction
149 if(impact_r >= fImpactParamCut[0]) SETBIT(survivedCut, kMinImpactParamR);
151 if(TESTBIT(fRequirements, kMinImpactParamZ)){
152 // cut on min. Impact Parameter in Z direction
153 if(impact_z >= fImpactParamCut[1]) SETBIT(survivedCut, kMinImpactParamZ);
155 if(TESTBIT(fRequirements, kMaxImpactParamR)){
156 // cut on max. Impact Parameter in Radial direction
157 if(impact_r <= fImpactParamCut[2]) SETBIT(survivedCut, kMaxImpactParamR);
159 if(TESTBIT(fRequirements, kMaxImpactParamZ)){
160 // cut on max. Impact Parameter in Z direction
161 if(impact_z <= fImpactParamCut[3]) SETBIT(survivedCut, kMaxImpactParamZ);
163 if(TESTBIT(fRequirements, kClusterRatioTPC)){
164 // cut on min ratio of found TPC clusters vs findable TPC clusters
165 if(ratioTPC >= fClusterRatioTPC) SETBIT(survivedCut, kClusterRatioTPC);
167 if(TESTBIT(fRequirements, kMinTrackletsTRD)){
168 // cut on minimum number of TRD tracklets
169 if(trdTracklets >= fMinTrackletsTRD) SETBIT(survivedCut, kMinTrackletsTRD);
171 if(TESTBIT(fRequirements, kPixelITS)){
172 // cut on ITS pixel layers
173 if(fPixelITS == kFirst)
175 case kFirst: if(itsPixel & BIT(0)) SETBIT(survivedCut, kPixelITS);
177 case kSecond: if(itsPixel & BIT(1)) SETBIT(survivedCut, kPixelITS);
179 case kBoth: if((itsPixel & BIT(0)) && (itsPixel & BIT(1))) SETBIT(survivedCut, kPixelITS);
181 case kAny: if((itsPixel & BIT(0)) || (itsPixel & BIT(1))) SETBIT(survivedCut, kPixelITS);
186 if(fRequirements == survivedCut){
190 if(IsQAOn()) FillQAhistosESD(track, kAfterCuts);
193 if(IsQAOn()) FillCutCorrelation(survivedCut);
197 //______________________________________________________
198 Bool_t AliHFEextraCuts::CheckMCCuts(AliMCParticle */*track*/){
200 // Checks cuts on Monte Carlo tracks
201 // returns true if track is selected
202 // QA histograms are filled before track selection and for
203 // selected tracks after track selection
205 return kTRUE; // not yet implemented
208 //______________________________________________________
209 void AliHFEextraCuts::FillQAhistosESD(AliESDtrack *track, UInt_t when){
211 // Fill the QA histograms for ESD tracks
212 // Function can be called before cuts or after cut application (second argument)
214 TList *container = dynamic_cast<TList *>(fQAlist->At(when));
215 Float_t impact_r, impact_z;
216 track->GetImpactParameters(impact_r, impact_z);
217 (dynamic_cast<TH1F *>(container->At(0)))->Fill(impact_r);
218 (dynamic_cast<TH1F *>(container->At(1)))->Fill(impact_z);
219 // printf("TPC findable clusters: %d, found Clusters: %d\n", track->GetTPCNclsF(), track->GetTPCNcls());
220 (dynamic_cast<TH1F *>(container->At(2)))->Fill(track->GetTPCNclsF() > 0. ? static_cast<Float_t>(track->GetTPCNcls())/static_cast<Float_t>(track->GetTPCNclsF()) : 1.);
222 (dynamic_cast<TH1F *>(container->At(3)))->Fill(track->GetTRDntrackletsPID());
224 (dynamic_cast<TH1F *>(container->At(3)))->Fill(track->GetTRDpidQuality());
226 UChar_t itsPixel = track->GetITSClusterMap();
227 TH1 *pixelHist = dynamic_cast<TH1F *>(container->At(4));
228 Int_t firstEntry = pixelHist->GetXaxis()->GetFirst();
229 if(!((itsPixel & BIT(0)) || (itsPixel & BIT(1))))
230 pixelHist->Fill(firstEntry + 3);
232 if(itsPixel & BIT(0)){
233 pixelHist->Fill(firstEntry);
234 if(itsPixel & BIT(1)) pixelHist->Fill(firstEntry + 2);
235 else pixelHist->Fill(firstEntry + 4);
237 if(itsPixel & BIT(1)){
238 pixelHist->Fill(firstEntry + 1);
239 if(!(itsPixel & BIT(0))) pixelHist->Fill(firstEntry + 5);
244 // //______________________________________________________
245 // void AliHFEextraCuts::FillQAhistosMC(AliMCParticle *track, UInt_t when){
247 // // Fill the QA histograms for MC tracks
248 // // Function can be called before cuts or after cut application (second argument)
249 // // Not yet implemented
253 //______________________________________________________
254 void AliHFEextraCuts::FillCutCorrelation(ULong64_t survivedCut){
256 // Fill cut correlation histograms for tracks that didn't pass cuts
258 TH2 *correlation = dynamic_cast<TH2F *>(fQAlist->At(2));
259 for(Int_t icut = 0; icut < kNcuts; icut++){
260 if(!TESTBIT(fRequirements, icut)) continue;
261 for(Int_t jcut = icut; jcut < kNcuts; jcut++){
262 if(!TESTBIT(fRequirements, jcut)) continue;
263 if(TESTBIT(survivedCut, icut) && TESTBIT(survivedCut, jcut))
264 correlation->Fill(icut, jcut);
269 //______________________________________________________
270 void AliHFEextraCuts::AddQAHistograms(TList *qaList){
273 // For each cut a histogram before and after track cut is created
274 // Histos before respectively after cut are stored in different lists
275 // Additionally a histogram with the cut correlation is created and stored
276 // in the top directory
281 histos[0] = new TList();
282 histos[0]->SetName("BeforeCut");
283 histos[0]->SetOwner();
284 histos[1] = new TList();
285 histos[1]->SetName("AfterCut");
286 histos[1]->SetOwner();
287 TString cutstr[2] = {"before", "after"};
288 for(Int_t icond = 0; icond < 2; icond++){
289 histos[icond]->AddAt((histo1D = new TH1F(Form("impactParamR%s", cutstr[icond].Data()), "Radial Impact Parameter", 100, 0, 10)), 0);
290 histo1D->GetXaxis()->SetTitle("Impact Parameter");
291 histo1D->GetYaxis()->SetTitle("Number of Tracks");
292 histos[icond]->AddAt((histo1D = new TH1F(Form("impactParamZ%s", cutstr[icond].Data()), "Z Impact Parameter", 200, 0, 20)), 1);
293 histo1D->GetXaxis()->SetTitle("Impact Parameter");
294 histo1D->GetYaxis()->SetTitle("Number of Tracks");
295 histos[icond]->AddAt((histo1D = new TH1F(Form("tpcClr%s", cutstr[icond].Data()), "Cluster Ratio TPC", 10, 0, 1)), 2);
296 histo1D->GetXaxis()->SetTitle("Cluster Ratio TPC");
297 histo1D->GetYaxis()->SetTitle("Number of Tracks");
298 histos[icond]->AddAt((histo1D = new TH1F(Form("trdTracklets%s", cutstr[icond].Data()), "Number of TRD tracklets", 7, 0, 7)), 3);
299 histo1D->GetXaxis()->SetTitle("Number of TRD Tracklets");
300 histo1D->GetYaxis()->SetTitle("Number of Tracks");
301 histos[icond]->AddAt((histo1D = new TH1F(Form("itsPixel%s", cutstr[icond].Data()), "ITS Pixel Hits", 6, 0, 6)), 4);
302 histo1D->GetXaxis()->SetTitle("ITS Pixel");
303 histo1D->GetYaxis()->SetTitle("Number of Tracks");
304 Int_t first = histo1D->GetXaxis()->GetFirst();
305 TString binNames[6] = { "First", "Second", "Both", "None", "Exclusive First", "Exclusive Second"};
306 for(Int_t ilabel = 0; ilabel < 6; ilabel++)
307 histo1D->GetXaxis()->SetBinLabel(first + ilabel, binNames[ilabel].Data());
309 fQAlist = new TList();
311 fQAlist->SetName("HFelectronExtraCuts");
312 fQAlist->AddAt(histos[0], 0);
313 fQAlist->AddAt(histos[1], 1);
314 // Add cut correlation
315 fQAlist->AddAt((histo2D = new TH2F("cutcorrellation", "Cut Correlation", kNcuts, 0, kNcuts - 1, kNcuts, 0, kNcuts -1)), 2);
316 TString labels[kNcuts] = {"MinImpactParamR", "MaxImpactParamR", "MinImpactParamZ", "MaxImpactParamZ", "ClusterRatioTPC", "MinTrackletsTRD", "ITSpixel"};
317 Int_t firstx = histo2D->GetXaxis()->GetFirst(), firsty = histo2D->GetYaxis()->GetFirst();
318 for(Int_t icut = 0; icut < kNcuts; icut++){
319 histo2D->GetXaxis()->SetBinLabel(firstx + icut, labels[icut].Data());
320 histo2D->GetYaxis()->SetBinLabel(firsty + icut, labels[icut].Data());
322 qaList->AddLast(fQAlist);