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 **************************************************************************/
19 #include "AliMpConstants.h"
27 #include "AliMUONTriggerEfficiencyCells.h"
30 //-----------------------------------------------------------------------------
31 /// \class AliMUONTriggerEfficiencyCells
32 /// A class to store and give access to the numerator and denominator
33 /// histograms for the trigger chamber efficiency calculation.
35 /// \author Diego Stocco; Subatech, Nantes
36 //-----------------------------------------------------------------------------
39 ClassImp(AliMUONTriggerEfficiencyCells)
42 //__________________________________________________________________________
43 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
47 fNoCountHistoList(0x0),
50 /// Default constructor.
55 //__________________________________________________________________________
56 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename,
57 const Char_t* listname)
61 fNoCountHistoList(0x0),
64 /// Constructor using an ASCII file.
67 ReadFile(filename, listname);
70 //__________________________________________________________________________
71 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList)
74 fCountHistoList(countHistoList),
75 fNoCountHistoList(0x0),
78 /// Constructor using a list of histograms with counts.
83 //_____________________________________________________________________________
84 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other)
87 fCountHistoList(other.fCountHistoList),
88 fNoCountHistoList(other.fNoCountHistoList),
89 fFiredStrips(other.fFiredStrips)
93 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
94 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
95 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
99 //_____________________________________________________________________________
100 AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other)
102 /// Asignment operator
103 // check assignement to self
107 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
108 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
109 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
112 fCountHistoList = other.fCountHistoList;
113 fNoCountHistoList = other.fNoCountHistoList;
114 fFiredStrips = other.fFiredStrips;
119 //__________________________________________________________________________
120 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
123 //delete [] fBoardEfficiency;
124 //delete [] fSlatEfficiency;
126 delete fCountHistoList;
127 delete fNoCountHistoList;
132 //_____________________________________________________________________________
133 void AliMUONTriggerEfficiencyCells::CheckConstants() const
135 /// Check consistence of redefined constants
137 assert(fgkNcathodes == AliMpConstants::NofCathodes());
138 assert(fgkNchambers == AliMpConstants::NofTriggerChambers());
139 assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes);
143 //__________________________________________________________________________
145 AliMUONTriggerEfficiencyCells::ResetHistos(Bool_t deleteObjects)
147 /// Sets our internal array contents to zero.
149 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
150 if ( deleteObjects ) {
151 delete fBoardEfficiency[chCath];
152 delete fSlatEfficiency[chCath];
154 fBoardEfficiency[chCath] = 0x0;
155 fSlatEfficiency[chCath] = 0x0;
160 //__________________________________________________________________________
161 void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename, const Char_t* listname)
163 /// Structure of file (.root) containing local board efficency
164 TFile *file = new TFile(filename, "read");
165 if(!file || !file->IsOpen()) {
166 AliError(Form("Can't read file %s",filename));
170 if ( ! fCountHistoList ) {
171 fCountHistoList = new TList();
172 fCountHistoList->SetOwner();
176 const Char_t* histoName;
178 TList* listInFile = 0x0;
179 TString listNameString(listname);
180 if ( ! listNameString.IsNull() )
181 listInFile = (TList*)file->FindObjectAny(listname);
183 for ( Int_t ide=0; ide<=kHchamberCount; ide++){
184 for(Int_t ich=0; ich<fgkNchambers; ich++){
186 // Efficiency per chamber is provided by 1 histogram only
187 if ( ide == kHchamberCount ) ich = fgkNchambers;
189 for(Int_t hType=0; hType<kNcounts; hType++){
190 histoName = GetHistoName(ide, hType, ich);
191 histo = ( listInFile ) ? (TH1F*)listInFile->FindObject(histoName) : (TH1F*)file->Get(histoName);
193 AliWarning(Form("Cannot find %s in file. Skip histogram", histoName));
196 histo->SetDirectory(0);
197 fCountHistoList->Add(histo);
199 AliDebug(5,Form("Adding histogram %s\n",histoName));
201 // Do not fill efficiency per chamber histos
202 if ( ide == kHchamberCount )
205 // Fill old historgrams for consistency
206 if ( hType < kBothPlanesEff ){
207 TString newName = histoName;
208 newName.ReplaceAll("Counts","Eff");
209 TH1F* auxHisto = (TH1F*)histo->Clone(newName.Data());
210 auxHisto->SetDirectory(0);
211 if ( ide == kHboardCount )
212 fBoardEfficiency[fgkNchambers*hType+ich] = auxHisto;
213 else if ( ide == kHslatCount )
214 fSlatEfficiency[fgkNchambers*hType+ich] = auxHisto;
216 AliDebug(5,Form("Creating histogram %s\n",auxHisto->GetName()));
218 else if ( hType == kAllTracks ){
219 for ( Int_t icath=0; icath<2; icath++){
220 if ( ide == kHboardCount )
221 fBoardEfficiency[fgkNchambers*icath+ich]->Divide(histo);
222 else if ( ide == kHslatCount )
223 fSlatEfficiency[fgkNchambers*icath+ich]->Divide(histo);
226 } // loop on count types
227 } // loop on chambers
228 } // loop on detection element type
234 //__________________________________________________________________________
236 AliMUONTriggerEfficiencyCells::GetHistoName(Int_t histoType, Int_t countType,
240 /// Return the name of the histogram for efficiency calculation
242 TString histoTypeName[kNcounts] = {"bendPlane", "nonBendPlane", "bothPlanes", "allTracks"};
244 switch ( histoType ) {
246 return Form("%sCountChamber", histoTypeName[countType].Data());
248 return Form("%sCountSlatCh%i", histoTypeName[countType].Data(), 11+chamber);
250 return Form("%sCountBoardCh%i", histoTypeName[countType].Data(), 11+chamber);
256 //__________________________________________________________________________
257 TH1F* AliMUONTriggerEfficiencyCells::GetOldEffHisto(Int_t histoType,
258 Int_t ich, Int_t icath) const
261 /// Compatibility with old class
262 /// Gets the efficiency from the array
263 /// (which are empty in the new implementation)
265 switch ( histoType ) {
267 return fBoardEfficiency[fgkNchambers*icath+ich];
269 return fSlatEfficiency[fgkNchambers*icath+ich];