]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerEfficiencyCells.cxx
change default max distance R to 0.1
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerEfficiencyCells.cxx
CommitLineData
70b4a8d6 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
bf4d93eb 16// $Id$
17
0a2dcc83 18#include "AliMUONTriggerEfficiencyCells.h"
19
313c3f0c 20#include "AliLog.h"
f3d288ab 21#include "AliMpConstants.h"
313c3f0c 22
0a2dcc83 23#include "TH1.h"
24#include "TList.h"
f3d288ab 25#include "TFile.h"
70b4a8d6 26
313c3f0c 27#include <fstream>
28#include <cassert>
70b4a8d6 29
f3d288ab 30
3d1463c8 31//-----------------------------------------------------------------------------
5398f946 32/// \class AliMUONTriggerEfficiencyCells
f3d288ab 33/// A class to store and give access to the numerator and denominator
34/// histograms for the trigger chamber efficiency calculation.
5398f946 35///
f3d288ab 36/// \author Diego Stocco; Subatech, Nantes
3d1463c8 37//-----------------------------------------------------------------------------
70b4a8d6 38
5398f946 39/// \cond CLASSIMP
70b4a8d6 40ClassImp(AliMUONTriggerEfficiencyCells)
5398f946 41/// \endcond
70b4a8d6 42
43//__________________________________________________________________________
44AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
45:
311d0691 46TObject(),
47fCountHistoList(0x0),
96079e17 48fNoCountHistoList(0x0),
f3d288ab 49fFiredStrips(0x0)
70b4a8d6 50{
5398f946 51/// Default constructor.
313c3f0c 52 CheckConstants();
f3d288ab 53 ResetHistos();
70b4a8d6 54}
55
56//__________________________________________________________________________
f3d288ab 57AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename,
58 const Char_t* listname)
70b4a8d6 59:
311d0691 60TObject(),
61fCountHistoList(0x0),
96079e17 62fNoCountHistoList(0x0),
f3d288ab 63fFiredStrips(0x0)
70b4a8d6 64{
5398f946 65/// Constructor using an ASCII file.
313c3f0c 66 CheckConstants();
f3d288ab 67 ResetHistos();
2236b58a 68 ReadFile(filename, listname);
70b4a8d6 69}
70
a4342473 71//__________________________________________________________________________
f3d288ab 72AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList)
311d0691 73:
74TObject(),
75fCountHistoList(countHistoList),
f3d288ab 76fNoCountHistoList(0x0),
77fFiredStrips(0x0)
311d0691 78{
a4342473 79/// Constructor using a list of histograms with counts.
311d0691 80 CheckConstants();
f3d288ab 81 ResetHistos();
311d0691 82}
83
84//_____________________________________________________________________________
85AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other)
86:
87TObject(other),
88fCountHistoList(other.fCountHistoList),
96079e17 89fNoCountHistoList(other.fNoCountHistoList),
f3d288ab 90fFiredStrips(other.fFiredStrips)
311d0691 91{
92/// Copy constructor
93
94 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
311d0691 95 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
96 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
97 }
98}
99
100//_____________________________________________________________________________
101AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other)
102{
103 /// Asignment operator
104 // check assignement to self
105 if (this == &other)
106 return *this;
107
108 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
311d0691 109 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
110 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
111 }
112
113 fCountHistoList = other.fCountHistoList;
114 fNoCountHistoList = other.fNoCountHistoList;
96079e17 115 fFiredStrips = other.fFiredStrips;
96079e17 116
311d0691 117 return *this;
118}
70b4a8d6 119
120//__________________________________________________________________________
121AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
122{
311d0691 123/// Destructor.
f3d288ab 124 //delete [] fBoardEfficiency;
125 //delete [] fSlatEfficiency;
126 ResetHistos(kTRUE);
127 delete fCountHistoList;
128 delete fNoCountHistoList;
129 delete fFiredStrips;
70b4a8d6 130}
70b4a8d6 131
132
f3d288ab 133//_____________________________________________________________________________
134void AliMUONTriggerEfficiencyCells::CheckConstants() const
70b4a8d6 135{
f3d288ab 136/// Check consistence of redefined constants
70b4a8d6 137
f3d288ab 138 assert(fgkNcathodes == AliMpConstants::NofCathodes());
139 assert(fgkNchambers == AliMpConstants::NofTriggerChambers());
140 assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes);
081d3361 141}
142
70b4a8d6 143
144//__________________________________________________________________________
f3d288ab 145void
146AliMUONTriggerEfficiencyCells::ResetHistos(Bool_t deleteObjects)
70b4a8d6 147{
f3d288ab 148/// Sets our internal array contents to zero.
081d3361 149
f3d288ab 150 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
151 if ( deleteObjects ) {
152 delete fBoardEfficiency[chCath];
153 delete fSlatEfficiency[chCath];
081d3361 154 }
f3d288ab 155 fBoardEfficiency[chCath] = 0x0;
156 fSlatEfficiency[chCath] = 0x0;
157 }
081d3361 158}
70b4a8d6 159
8c0b5e70 160
161//__________________________________________________________________________
f3d288ab 162void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename, const Char_t* listname)
8c0b5e70 163{
313c3f0c 164/// Structure of file (.root) containing local board efficency
5bb523d1 165 TFile *file = TFile::Open(filename);
a4342473 166 if(!file || !file->IsOpen()) {
167 AliError(Form("Can't read file %s",filename));
168 return;
8c0b5e70 169 }
a4342473 170
2236b58a 171 if ( ! fCountHistoList ) {
172 fCountHistoList = new TList();
173 fCountHistoList->SetOwner();
174 }
683cb6c5 175
176 TH1F *histo = 0x0;
f3d288ab 177 const Char_t* histoName;
2236b58a 178
179 TList* listInFile = 0x0;
180 TString listNameString(listname);
181 if ( ! listNameString.IsNull() )
07b360b5 182 listInFile = (TList*)file->FindObjectAny(listname);
683cb6c5 183
f3d288ab 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;
683cb6c5 189
f3d288ab 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 }
2236b58a 197 histo->SetDirectory(0);
f3d288ab 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
683cb6c5 230
2236b58a 231 file->Close();
70b4a8d6 232}
233
234
70b4a8d6 235//__________________________________________________________________________
f3d288ab 236const Char_t*
237AliMUONTriggerEfficiencyCells::GetHistoName(Int_t histoType, Int_t countType,
238 Int_t chamber)
96079e17 239{
240 //
f3d288ab 241 /// Return the name of the histogram for efficiency calculation
96079e17 242 //
f3d288ab 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);
311d0691 252 }
253
f3d288ab 254 return 0x0;
70b4a8d6 255}
256
311d0691 257//__________________________________________________________________________
f3d288ab 258TH1F* AliMUONTriggerEfficiencyCells::GetOldEffHisto(Int_t histoType,
9ee1d6ff 259 Int_t ich, Int_t icath) const
a4342473 260{
261 //
f3d288ab 262 /// Compatibility with old class
263 /// Gets the efficiency from the array
264 /// (which are empty in the new implementation)
265
266 switch ( histoType ) {
267 case kHboardCount:
268 return fBoardEfficiency[fgkNchambers*icath+ich];
269 case kHslatCount:
270 return fSlatEfficiency[fgkNchambers*icath+ich];
a4342473 271 }
f3d288ab 272 return 0x0;
a4342473 273}