]>
Commit | Line | Data |
---|---|---|
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 | ||
313c3f0c | 18 | #include "AliLog.h" |
f3d288ab | 19 | #include "AliMpConstants.h" |
313c3f0c | 20 | |
8c0b5e70 | 21 | #include "TH1F.h" |
f3d288ab | 22 | #include "TFile.h" |
70b4a8d6 | 23 | |
313c3f0c | 24 | #include <fstream> |
25 | #include <cassert> | |
70b4a8d6 | 26 | |
f3d288ab | 27 | #include "AliMUONTriggerEfficiencyCells.h" |
28 | ||
29 | ||
3d1463c8 | 30 | //----------------------------------------------------------------------------- |
5398f946 | 31 | /// \class AliMUONTriggerEfficiencyCells |
f3d288ab | 32 | /// A class to store and give access to the numerator and denominator |
33 | /// histograms for the trigger chamber efficiency calculation. | |
5398f946 | 34 | /// |
f3d288ab | 35 | /// \author Diego Stocco; Subatech, Nantes |
3d1463c8 | 36 | //----------------------------------------------------------------------------- |
70b4a8d6 | 37 | |
5398f946 | 38 | /// \cond CLASSIMP |
70b4a8d6 | 39 | ClassImp(AliMUONTriggerEfficiencyCells) |
5398f946 | 40 | /// \endcond |
70b4a8d6 | 41 | |
42 | //__________________________________________________________________________ | |
43 | AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells() | |
44 | : | |
311d0691 | 45 | TObject(), |
46 | fCountHistoList(0x0), | |
96079e17 | 47 | fNoCountHistoList(0x0), |
f3d288ab | 48 | fFiredStrips(0x0) |
70b4a8d6 | 49 | { |
5398f946 | 50 | /// Default constructor. |
313c3f0c | 51 | CheckConstants(); |
f3d288ab | 52 | ResetHistos(); |
70b4a8d6 | 53 | } |
54 | ||
55 | //__________________________________________________________________________ | |
f3d288ab | 56 | AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename, |
57 | const Char_t* listname) | |
70b4a8d6 | 58 | : |
311d0691 | 59 | TObject(), |
60 | fCountHistoList(0x0), | |
96079e17 | 61 | fNoCountHistoList(0x0), |
f3d288ab | 62 | fFiredStrips(0x0) |
70b4a8d6 | 63 | { |
5398f946 | 64 | /// Constructor using an ASCII file. |
313c3f0c | 65 | CheckConstants(); |
f3d288ab | 66 | ResetHistos(); |
2236b58a | 67 | ReadFile(filename, listname); |
70b4a8d6 | 68 | } |
69 | ||
a4342473 | 70 | //__________________________________________________________________________ |
f3d288ab | 71 | AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList) |
311d0691 | 72 | : |
73 | TObject(), | |
74 | fCountHistoList(countHistoList), | |
f3d288ab | 75 | fNoCountHistoList(0x0), |
76 | fFiredStrips(0x0) | |
311d0691 | 77 | { |
a4342473 | 78 | /// Constructor using a list of histograms with counts. |
311d0691 | 79 | CheckConstants(); |
f3d288ab | 80 | ResetHistos(); |
311d0691 | 81 | } |
82 | ||
83 | //_____________________________________________________________________________ | |
84 | AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other) | |
85 | : | |
86 | TObject(other), | |
87 | fCountHistoList(other.fCountHistoList), | |
96079e17 | 88 | fNoCountHistoList(other.fNoCountHistoList), |
f3d288ab | 89 | fFiredStrips(other.fFiredStrips) |
311d0691 | 90 | { |
91 | /// Copy constructor | |
92 | ||
93 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ | |
311d0691 | 94 | fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath]; |
95 | fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath]; | |
96 | } | |
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other) | |
101 | { | |
102 | /// Asignment operator | |
103 | // check assignement to self | |
104 | if (this == &other) | |
105 | return *this; | |
106 | ||
107 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ | |
311d0691 | 108 | fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath]; |
109 | fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath]; | |
110 | } | |
111 | ||
112 | fCountHistoList = other.fCountHistoList; | |
113 | fNoCountHistoList = other.fNoCountHistoList; | |
96079e17 | 114 | fFiredStrips = other.fFiredStrips; |
96079e17 | 115 | |
311d0691 | 116 | return *this; |
117 | } | |
70b4a8d6 | 118 | |
119 | //__________________________________________________________________________ | |
120 | AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells() | |
121 | { | |
311d0691 | 122 | /// Destructor. |
f3d288ab | 123 | //delete [] fBoardEfficiency; |
124 | //delete [] fSlatEfficiency; | |
125 | ResetHistos(kTRUE); | |
126 | delete fCountHistoList; | |
127 | delete fNoCountHistoList; | |
128 | delete fFiredStrips; | |
70b4a8d6 | 129 | } |
70b4a8d6 | 130 | |
131 | ||
f3d288ab | 132 | //_____________________________________________________________________________ |
133 | void AliMUONTriggerEfficiencyCells::CheckConstants() const | |
70b4a8d6 | 134 | { |
f3d288ab | 135 | /// Check consistence of redefined constants |
70b4a8d6 | 136 | |
f3d288ab | 137 | assert(fgkNcathodes == AliMpConstants::NofCathodes()); |
138 | assert(fgkNchambers == AliMpConstants::NofTriggerChambers()); | |
139 | assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes); | |
081d3361 | 140 | } |
141 | ||
70b4a8d6 | 142 | |
143 | //__________________________________________________________________________ | |
f3d288ab | 144 | void |
145 | AliMUONTriggerEfficiencyCells::ResetHistos(Bool_t deleteObjects) | |
70b4a8d6 | 146 | { |
f3d288ab | 147 | /// Sets our internal array contents to zero. |
081d3361 | 148 | |
f3d288ab | 149 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ |
150 | if ( deleteObjects ) { | |
151 | delete fBoardEfficiency[chCath]; | |
152 | delete fSlatEfficiency[chCath]; | |
081d3361 | 153 | } |
f3d288ab | 154 | fBoardEfficiency[chCath] = 0x0; |
155 | fSlatEfficiency[chCath] = 0x0; | |
156 | } | |
081d3361 | 157 | } |
70b4a8d6 | 158 | |
8c0b5e70 | 159 | |
160 | //__________________________________________________________________________ | |
f3d288ab | 161 | void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename, const Char_t* listname) |
8c0b5e70 | 162 | { |
313c3f0c | 163 | /// Structure of file (.root) containing local board efficency |
8c0b5e70 | 164 | TFile *file = new TFile(filename, "read"); |
a4342473 | 165 | if(!file || !file->IsOpen()) { |
166 | AliError(Form("Can't read file %s",filename)); | |
167 | return; | |
8c0b5e70 | 168 | } |
a4342473 | 169 | |
2236b58a | 170 | if ( ! fCountHistoList ) { |
171 | fCountHistoList = new TList(); | |
172 | fCountHistoList->SetOwner(); | |
173 | } | |
683cb6c5 | 174 | |
175 | TH1F *histo = 0x0; | |
f3d288ab | 176 | const Char_t* histoName; |
2236b58a | 177 | |
178 | TList* listInFile = 0x0; | |
179 | TString listNameString(listname); | |
180 | if ( ! listNameString.IsNull() ) | |
07b360b5 | 181 | listInFile = (TList*)file->FindObjectAny(listname); |
683cb6c5 | 182 | |
f3d288ab | 183 | for ( Int_t ide=0; ide<=kHchamberCount; ide++){ |
184 | for(Int_t ich=0; ich<fgkNchambers; ich++){ | |
185 | ||
186 | // Efficiency per chamber is provided by 1 histogram only | |
187 | if ( ide == kHchamberCount ) ich = fgkNchambers; | |
683cb6c5 | 188 | |
f3d288ab | 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); | |
192 | if ( ! histo ) { | |
193 | AliWarning(Form("Cannot find %s in file. Skip histogram", histoName)); | |
194 | continue; | |
195 | } | |
2236b58a | 196 | histo->SetDirectory(0); |
f3d288ab | 197 | fCountHistoList->Add(histo); |
198 | ||
199 | AliDebug(5,Form("Adding histogram %s\n",histoName)); | |
200 | ||
201 | // Do not fill efficiency per chamber histos | |
202 | if ( ide == kHchamberCount ) | |
203 | continue; | |
204 | ||
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; | |
215 | ||
216 | AliDebug(5,Form("Creating histogram %s\n",auxHisto->GetName())); | |
217 | } | |
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); | |
224 | } | |
225 | } | |
226 | } // loop on count types | |
227 | } // loop on chambers | |
228 | } // loop on detection element type | |
683cb6c5 | 229 | |
2236b58a | 230 | file->Close(); |
70b4a8d6 | 231 | } |
232 | ||
233 | ||
70b4a8d6 | 234 | //__________________________________________________________________________ |
f3d288ab | 235 | const Char_t* |
236 | AliMUONTriggerEfficiencyCells::GetHistoName(Int_t histoType, Int_t countType, | |
237 | Int_t chamber) | |
96079e17 | 238 | { |
239 | // | |
f3d288ab | 240 | /// Return the name of the histogram for efficiency calculation |
96079e17 | 241 | // |
f3d288ab | 242 | TString histoTypeName[kNcounts] = {"bendPlane", "nonBendPlane", "bothPlanes", "allTracks"}; |
243 | ||
244 | switch ( histoType ) { | |
245 | case kHchamberCount: | |
246 | return Form("%sCountChamber", histoTypeName[countType].Data()); | |
247 | case kHslatCount: | |
248 | return Form("%sCountSlatCh%i", histoTypeName[countType].Data(), 11+chamber); | |
249 | case kHboardCount: | |
250 | return Form("%sCountBoardCh%i", histoTypeName[countType].Data(), 11+chamber); | |
311d0691 | 251 | } |
252 | ||
f3d288ab | 253 | return 0x0; |
70b4a8d6 | 254 | } |
255 | ||
311d0691 | 256 | //__________________________________________________________________________ |
f3d288ab | 257 | TH1F* AliMUONTriggerEfficiencyCells::GetOldEffHisto(Int_t histoType, |
258 | Int_t ich, Int_t icath) | |
a4342473 | 259 | { |
260 | // | |
f3d288ab | 261 | /// Compatibility with old class |
262 | /// Gets the efficiency from the array | |
263 | /// (which are empty in the new implementation) | |
264 | ||
265 | switch ( histoType ) { | |
266 | case kHboardCount: | |
267 | return fBoardEfficiency[fgkNchambers*icath+ich]; | |
268 | case kHslatCount: | |
269 | return fSlatEfficiency[fgkNchambers*icath+ich]; | |
a4342473 | 270 | } |
f3d288ab | 271 | return 0x0; |
a4342473 | 272 | } |