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 **************************************************************************/
18 #include "AliMUONTriggerEfficiencyCells.h"
21 #include "AliMpConstants.h"
31 //-----------------------------------------------------------------------------
32 /// \class AliMUONTriggerEfficiencyCells
33 /// A class to store and give access to the numerator and denominator
34 /// histograms for the trigger chamber efficiency calculation.
36 /// \author Diego Stocco; Subatech, Nantes
37 //-----------------------------------------------------------------------------
40 ClassImp(AliMUONTriggerEfficiencyCells)
43 //__________________________________________________________________________
44 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
48 fNoCountHistoList(0x0),
51 /// Default constructor.
56 //__________________________________________________________________________
57 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename,
58 const Char_t* listname)
62 fNoCountHistoList(0x0),
65 /// Constructor using an ASCII file.
68 ReadFile(filename, listname);
71 //__________________________________________________________________________
72 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList)
75 fCountHistoList(countHistoList),
76 fNoCountHistoList(0x0),
79 /// Constructor using a list of histograms with counts.
84 //_____________________________________________________________________________
85 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other)
88 fCountHistoList(other.fCountHistoList),
89 fNoCountHistoList(other.fNoCountHistoList),
90 fFiredStrips(other.fFiredStrips)
94 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
95 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
96 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
100 //_____________________________________________________________________________
101 AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other)
103 /// Asignment operator
104 // check assignement to self
108 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
109 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
110 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
113 fCountHistoList = other.fCountHistoList;
114 fNoCountHistoList = other.fNoCountHistoList;
115 fFiredStrips = other.fFiredStrips;
120 //__________________________________________________________________________
121 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
124 //delete [] fBoardEfficiency;
125 //delete [] fSlatEfficiency;
127 delete fCountHistoList;
128 delete fNoCountHistoList;
133 //_____________________________________________________________________________
134 void AliMUONTriggerEfficiencyCells::CheckConstants() const
136 /// Check consistence of redefined constants
138 assert(fgkNcathodes == AliMpConstants::NofCathodes());
139 assert(fgkNchambers == AliMpConstants::NofTriggerChambers());
140 assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes);
144 //__________________________________________________________________________
146 AliMUONTriggerEfficiencyCells::ResetHistos(Bool_t deleteObjects)
148 /// Sets our internal array contents to zero.
150 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
151 if ( deleteObjects ) {
152 delete fBoardEfficiency[chCath];
153 delete fSlatEfficiency[chCath];
155 fBoardEfficiency[chCath] = 0x0;
156 fSlatEfficiency[chCath] = 0x0;
161 //__________________________________________________________________________
162 void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename, const Char_t* listname)
164 /// Structure of file (.root) containing local board efficency
165 TFile *file = TFile::Open(filename);
166 if(!file || !file->IsOpen()) {
167 AliError(Form("Can't read file %s",filename));
171 if ( ! fCountHistoList ) {
172 fCountHistoList = new TList();
173 fCountHistoList->SetOwner();
177 const Char_t* histoName;
179 TList* listInFile = 0x0;
180 TString listNameString(listname);
181 if ( ! listNameString.IsNull() )
182 listInFile = (TList*)file->FindObjectAny(listname);
184 for ( Int_t ide=0; ide<=kHchamberCount; ide++){
185 for(Int_t ich=0; ich<fgkNchambers; ich++){
187 // Efficiency per chamber is provided by 1 histogram only
188 if ( ide == kHchamberCount ) ich = fgkNchambers;
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);
194 AliWarning(Form("Cannot find %s in file. Skip histogram", histoName));
197 histo->SetDirectory(0);
198 fCountHistoList->Add(histo);
200 AliDebug(5,Form("Adding histogram %s\n",histoName));
202 // Do not fill efficiency per chamber histos
203 if ( ide == kHchamberCount )
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;
217 AliDebug(5,Form("Creating histogram %s\n",auxHisto->GetName()));
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);
227 } // loop on count types
228 } // loop on chambers
229 } // loop on detection element type
235 //__________________________________________________________________________
237 AliMUONTriggerEfficiencyCells::GetHistoName(Int_t histoType, Int_t countType,
241 /// Return the name of the histogram for efficiency calculation
243 TString histoTypeName[kNcounts] = {"bendPlane", "nonBendPlane", "bothPlanes", "allTracks"};
245 switch ( histoType ) {
247 return Form("%sCountChamber", histoTypeName[countType].Data());
249 return Form("%sCountSlatCh%i", histoTypeName[countType].Data(), 11+chamber);
251 return Form("%sCountBoardCh%i", histoTypeName[countType].Data(), 11+chamber);
257 //__________________________________________________________________________
258 TH1F* AliMUONTriggerEfficiencyCells::GetOldEffHisto(Int_t histoType,
259 Int_t ich, Int_t icath) const
262 /// Compatibility with old class
263 /// Gets the efficiency from the array
264 /// (which are empty in the new implementation)
266 switch ( histoType ) {
268 return fBoardEfficiency[fgkNchambers*icath+ich];
270 return fSlatEfficiency[fgkNchambers*icath+ich];