AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONTriggerEfficiencyCells.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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 
16 // $Id$
17 
19 
20 #include "AliLog.h"
21 #include "AliMpConstants.h"
22 
23 #include "TH1.h"
24 #include "TList.h"
25 #include "TFile.h"
26 
27 #include <fstream>
28 #include <cassert>
29 
30 
31 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
38 
42 
43 //__________________________________________________________________________
45 :
46 TObject(),
47 fCountHistoList(0x0),
48 fNoCountHistoList(0x0),
49 fFiredStrips(0x0)
50 {
52  CheckConstants();
53  ResetHistos();
54 }
55 
56 //__________________________________________________________________________
58  const Char_t* listname)
59 :
60 TObject(),
61 fCountHistoList(0x0),
62 fNoCountHistoList(0x0),
63 fFiredStrips(0x0)
64 {
67  ResetHistos();
68  ReadFile(filename, listname);
69 }
70 
71 //__________________________________________________________________________
73 :
74 TObject(),
75 fCountHistoList(countHistoList),
76 fNoCountHistoList(0x0),
77 fFiredStrips(0x0)
78 {
81  ResetHistos();
82 }
83 
84 //_____________________________________________________________________________
86 :
87 TObject(other),
88 fCountHistoList(other.fCountHistoList),
89 fNoCountHistoList(other.fNoCountHistoList),
90 fFiredStrips(other.fFiredStrips)
91 {
93 
94  for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
95  fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
96  fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
97  }
98 }
99 
100 //_____________________________________________________________________________
102 {
104  // check assignement to self
105  if (this == &other)
106  return *this;
107 
108  for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
109  fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
110  fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
111  }
112 
115  fFiredStrips = other.fFiredStrips;
116 
117  return *this;
118 }
119 
120 //__________________________________________________________________________
122 {
124  //delete [] fBoardEfficiency;
125  //delete [] fSlatEfficiency;
126  ResetHistos(kTRUE);
127  delete fCountHistoList;
128  delete fNoCountHistoList;
129  delete fFiredStrips;
130 }
131 
132 
133 //_____________________________________________________________________________
135 {
137 
141 }
142 
143 
144 //__________________________________________________________________________
145 void
147 {
149 
150  for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
151  if ( deleteObjects ) {
152  delete fBoardEfficiency[chCath];
153  delete fSlatEfficiency[chCath];
154  }
155  fBoardEfficiency[chCath] = 0x0;
156  fSlatEfficiency[chCath] = 0x0;
157  }
158 }
159 
160 
161 //__________________________________________________________________________
162 void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename, const Char_t* listname)
163 {
165  TFile *file = TFile::Open(filename);
166  if(!file || !file->IsOpen()) {
167  AliError(Form("Can't read file %s",filename));
168  return;
169  }
170 
171  if ( ! fCountHistoList ) {
172  fCountHistoList = new TList();
173  fCountHistoList->SetOwner();
174  }
175 
176  TH1F *histo = 0x0;
177  const Char_t* histoName;
178 
179  TList* listInFile = 0x0;
180  TString listNameString(listname);
181  if ( ! listNameString.IsNull() )
182  listInFile = (TList*)file->FindObjectAny(listname);
183 
184  for ( Int_t ide=0; ide<=kHchamberCount; ide++){
185  for(Int_t ich=0; ich<fgkNchambers; ich++){
186 
187  // Efficiency per chamber is provided by 1 histogram only
188  if ( ide == kHchamberCount ) ich = fgkNchambers;
189 
190  for(Int_t hType=0; hType<kNcounts; hType++){
191  histoName = GetHistoName(ide, hType, ich);
192  histo = ( listInFile ) ? (TH1F*)listInFile->FindObject(histoName) : (TH1F*)file->Get(histoName);
193  if ( ! histo ) {
194  AliWarning(Form("Cannot find %s in file. Skip histogram", histoName));
195  continue;
196  }
197  histo->SetDirectory(0);
198  fCountHistoList->Add(histo);
199 
200  AliDebug(5,Form("Adding histogram %s\n",histoName));
201 
202  // Do not fill efficiency per chamber histos
203  if ( ide == kHchamberCount )
204  continue;
205 
206  // Fill old historgrams for consistency
207  if ( hType < kBothPlanesEff ){
208  TString newName = histoName;
209  newName.ReplaceAll("Counts","Eff");
210  TH1F* auxHisto = (TH1F*)histo->Clone(newName.Data());
211  auxHisto->SetDirectory(0);
212  if ( ide == kHboardCount )
213  fBoardEfficiency[fgkNchambers*hType+ich] = auxHisto;
214  else if ( ide == kHslatCount )
215  fSlatEfficiency[fgkNchambers*hType+ich] = auxHisto;
216 
217  AliDebug(5,Form("Creating histogram %s\n",auxHisto->GetName()));
218  }
219  else if ( hType == kAllTracks ){
220  for ( Int_t icath=0; icath<2; icath++){
221  if ( ide == kHboardCount )
222  fBoardEfficiency[fgkNchambers*icath+ich]->Divide(histo);
223  else if ( ide == kHslatCount )
224  fSlatEfficiency[fgkNchambers*icath+ich]->Divide(histo);
225  }
226  }
227  } // loop on count types
228  } // loop on chambers
229  } // loop on detection element type
230 
231  file->Close();
232 }
233 
234 
235 //__________________________________________________________________________
236 const Char_t*
237 AliMUONTriggerEfficiencyCells::GetHistoName(Int_t histoType, Int_t countType,
238  Int_t chamber)
239 {
240  //
242  //
243  TString histoTypeName[kNcounts] = {"bendPlane", "nonBendPlane", "bothPlanes", "allTracks"};
244 
245  switch ( histoType ) {
246  case kHchamberCount:
247  return Form("%sCountChamber", histoTypeName[countType].Data());
248  case kHslatCount:
249  return Form("%sCountSlatCh%i", histoTypeName[countType].Data(), 11+chamber);
250  case kHboardCount:
251  return Form("%sCountBoardCh%i", histoTypeName[countType].Data(), 11+chamber);
252  }
253 
254  return 0x0;
255 }
256 
257 //__________________________________________________________________________
259  Int_t ich, Int_t icath) const
260 {
261  //
265 
266  switch ( histoType ) {
267  case kHboardCount:
268  return fBoardEfficiency[fgkNchambers*icath+ich];
269  case kHslatCount:
270  return fSlatEfficiency[fgkNchambers*icath+ich];
271  }
272  return 0x0;
273 }
Store and give access to the trigger chamber efficiency.
static const Int_t fgkNplanes
Number of planes.
TList * fNoCountHistoList
list of efficiency denominators (obsolete)
const Char_t * GetHistoName(Int_t histoType, Int_t countType, Int_t chamber=-1)
void ResetHistos(Bool_t deleteObjects=kFALSE)
static const Int_t fgkNcathodes
Number of cathodes.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
static const Int_t fgkNchambers
Number of chambers.
static Int_t NofCathodes()
Return number of cathodes.
AliMUONTriggerEfficiencyCells & operator=(const AliMUONTriggerEfficiencyCells &other)
TList * fCountHistoList
list of histograms for efficiency calculation
void ReadFile(const Char_t *filename, const Char_t *listname)
TH1F * GetOldEffHisto(Int_t hType, Int_t ich, Int_t icath) const
TList * fFiredStrips
list of fired strips for efficiency check (obsolete)
TH1F * fSlatEfficiency[fgkNplanes]
the slats content (obsolete)
TH1F * fBoardEfficiency[fgkNplanes]
the boards content (obsolete)
static Int_t NofTriggerChambers()