]>
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 "AliMUONTriggerEfficiencyCells.h" |
19 | #include "AliMpConstants.h" | |
313c3f0c | 20 | |
96079e17 | 21 | // Classes for display |
aef183f7 | 22 | #include "AliMUONTriggerDisplay.h" |
683cb6c5 | 23 | #include "AliCDBManager.h" |
96079e17 | 24 | #include "AliMpDDLStore.h" |
96079e17 | 25 | #include "AliMpLocalBoard.h" |
26 | #include "AliMpPad.h" | |
27 | #include "AliMpVSegmentation.h" | |
28 | #include "AliMpSegmentation.h" | |
29 | ||
313c3f0c | 30 | #include "AliLog.h" |
31 | ||
32 | #include "TRandom.h" | |
70b4a8d6 | 33 | #include "Riostream.h" |
081d3361 | 34 | #include "TSystem.h" |
8c0b5e70 | 35 | #include "TFile.h" |
36 | #include "TH1F.h" | |
311d0691 | 37 | #include "TMath.h" |
38 | ||
39 | #include "TH2F.h" | |
96079e17 | 40 | #include "TH3F.h" |
41 | #include "TF1.h" | |
311d0691 | 42 | #include "TStyle.h" |
43 | #include "TPaveLabel.h" | |
44 | #include "TCanvas.h" | |
70b4a8d6 | 45 | |
313c3f0c | 46 | #include <fstream> |
47 | #include <cassert> | |
70b4a8d6 | 48 | |
3d1463c8 | 49 | //----------------------------------------------------------------------------- |
5398f946 | 50 | /// \class AliMUONTriggerEfficiencyCells |
51 | /// A class to store and give access to the trigger chamber efficiency. | |
52 | /// | |
683cb6c5 | 53 | /// Efficiency is stored per cathode on local boards |
5398f946 | 54 | /// |
55 | /// The main method of this class is IsTriggered(). | |
56 | /// | |
683cb6c5 | 57 | /// $ALICE_ROOT/MUON/data/efficiencyCells.dat contains efficiency |
5398f946 | 58 | /// for each chamber (i.e. DetElement). |
081d3361 | 59 | /// |
60 | /// In the case of local boards, efficiency is stored from left to right | |
61 | /// per increasing board number (from 1 to 234) | |
62 | /// | |
683cb6c5 | 63 | /// The file can be edited in order to change efficiency |
64 | /// in a chosen local board/region of the chamber. | |
081d3361 | 65 | /// |
5398f946 | 66 | /// |
67 | /// But please note that this object is also available from the CDB | |
5398f946 | 68 | /// |
69 | /// \author Diego Stocco; INFN Torino | |
3d1463c8 | 70 | //----------------------------------------------------------------------------- |
70b4a8d6 | 71 | |
5398f946 | 72 | /// \cond CLASSIMP |
70b4a8d6 | 73 | ClassImp(AliMUONTriggerEfficiencyCells) |
5398f946 | 74 | /// \endcond |
70b4a8d6 | 75 | |
76 | //__________________________________________________________________________ | |
77 | AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells() | |
78 | : | |
311d0691 | 79 | TObject(), |
80 | fCountHistoList(0x0), | |
96079e17 | 81 | fNoCountHistoList(0x0), |
82 | fFiredStrips(0x0), | |
83 | fDisplayHistoList(0x0), | |
84 | fBoardLabelList(0x0), | |
85 | fFiredFitHistoList(0x0), | |
86 | fFiredDisplayHistoList(0x0) | |
70b4a8d6 | 87 | { |
5398f946 | 88 | /// Default constructor. |
313c3f0c | 89 | CheckConstants(); |
70b4a8d6 | 90 | Reset(); |
311d0691 | 91 | InitHistos(); |
70b4a8d6 | 92 | } |
93 | ||
94 | //__________________________________________________________________________ | |
96079e17 | 95 | AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename) |
70b4a8d6 | 96 | : |
311d0691 | 97 | TObject(), |
98 | fCountHistoList(0x0), | |
96079e17 | 99 | fNoCountHistoList(0x0), |
100 | fFiredStrips(0x0), | |
101 | fDisplayHistoList(0x0), | |
102 | fBoardLabelList(0x0), | |
103 | fFiredFitHistoList(0x0), | |
104 | fFiredDisplayHistoList(0x0) | |
70b4a8d6 | 105 | { |
5398f946 | 106 | /// Constructor using an ASCII file. |
313c3f0c | 107 | CheckConstants(); |
70b4a8d6 | 108 | Reset(); |
109 | ReadFile(filename); | |
110 | } | |
111 | ||
311d0691 | 112 | AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList, |
113 | TList *noCountHistoList) | |
114 | : | |
115 | TObject(), | |
116 | fCountHistoList(countHistoList), | |
96079e17 | 117 | fNoCountHistoList(noCountHistoList), |
118 | fFiredStrips(0x0), | |
119 | fDisplayHistoList(0x0), | |
120 | fBoardLabelList(0x0), | |
121 | fFiredFitHistoList(0x0), | |
122 | fFiredDisplayHistoList(0x0) | |
311d0691 | 123 | { |
124 | /// Constructor using an ASCII file. | |
125 | CheckConstants(); | |
126 | Reset(); | |
127 | InitHistos(); | |
128 | FillHistosFromList(); | |
129 | } | |
130 | ||
131 | //_____________________________________________________________________________ | |
132 | AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other) | |
133 | : | |
134 | TObject(other), | |
135 | fCountHistoList(other.fCountHistoList), | |
96079e17 | 136 | fNoCountHistoList(other.fNoCountHistoList), |
137 | fFiredStrips(other.fFiredStrips), | |
138 | fDisplayHistoList(other.fDisplayHistoList), | |
139 | fBoardLabelList(other.fBoardLabelList), | |
140 | fFiredFitHistoList(other.fFiredFitHistoList), | |
141 | fFiredDisplayHistoList(other.fFiredDisplayHistoList) | |
311d0691 | 142 | { |
143 | /// Copy constructor | |
144 | ||
145 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ | |
311d0691 | 146 | fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath]; |
147 | fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath]; | |
148 | } | |
149 | } | |
150 | ||
151 | //_____________________________________________________________________________ | |
152 | AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other) | |
153 | { | |
154 | /// Asignment operator | |
155 | // check assignement to self | |
156 | if (this == &other) | |
157 | return *this; | |
158 | ||
159 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ | |
311d0691 | 160 | fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath]; |
161 | fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath]; | |
162 | } | |
163 | ||
164 | fCountHistoList = other.fCountHistoList; | |
165 | fNoCountHistoList = other.fNoCountHistoList; | |
96079e17 | 166 | fFiredStrips = other.fFiredStrips; |
311d0691 | 167 | |
96079e17 | 168 | fDisplayHistoList = other.fDisplayHistoList; |
169 | fBoardLabelList = other.fBoardLabelList; | |
170 | fFiredFitHistoList = other.fFiredFitHistoList; | |
171 | fFiredDisplayHistoList = other.fFiredDisplayHistoList; | |
172 | ||
311d0691 | 173 | return *this; |
174 | } | |
70b4a8d6 | 175 | |
176 | //__________________________________________________________________________ | |
177 | AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells() | |
178 | { | |
311d0691 | 179 | /// Destructor. |
70b4a8d6 | 180 | } |
70b4a8d6 | 181 | |
182 | ||
70b4a8d6 | 183 | //__________________________________________________________________________ |
313c3f0c | 184 | void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t localBoard, Float_t &eff1, Float_t &eff2) const |
70b4a8d6 | 185 | { |
081d3361 | 186 | /// Get the efficiencies of the 2 cathodes at a given local board |
5398f946 | 187 | |
081d3361 | 188 | Int_t chamber = FindChamberIndex(detElemId); |
311d0691 | 189 | Int_t bin = fBoardEfficiency[chamber]->FindBin(localBoard); |
190 | eff1 = fBoardEfficiency[chamber]->GetBinContent(bin); | |
191 | eff2 = fBoardEfficiency[fgkNchambers+chamber]->GetBinContent(bin); | |
70b4a8d6 | 192 | } |
193 | ||
194 | ||
081d3361 | 195 | //__________________________________________________________________________ |
196 | void | |
313c3f0c | 197 | AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t localBoard, Bool_t &trig1, Bool_t &trig2) const |
081d3361 | 198 | { |
199 | /// Whether or not a given local board has a chance to trig, on each cathode. | |
200 | ||
201 | Float_t eff1 = 0.0; | |
202 | Float_t eff2 = 0.0; | |
203 | GetCellEfficiency(detElemId, localBoard, eff1, eff2); | |
204 | trig1 = kTRUE; | |
205 | trig2 = kTRUE; | |
206 | if(gRandom->Rndm()>eff1)trig1 = kFALSE; | |
207 | if(gRandom->Rndm()>eff2)trig2 = kFALSE; | |
208 | } | |
209 | ||
70b4a8d6 | 210 | |
211 | //__________________________________________________________________________ | |
96079e17 | 212 | void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename) |
70b4a8d6 | 213 | { |
5398f946 | 214 | /// Reads a file containing the efficiency map. |
215 | ||
70b4a8d6 | 216 | TString fileName = gSystem->ExpandPathName(filename); |
8c0b5e70 | 217 | if(fileName.EndsWith(".root")){ |
218 | ReadHistoBoards(fileName.Data()); | |
219 | return; | |
220 | } | |
221 | ||
311d0691 | 222 | InitHistos(); |
70b4a8d6 | 223 | ifstream file(fileName.Data()); |
96079e17 | 224 | Char_t dat[50]; |
70b4a8d6 | 225 | if (file.good()){ |
081d3361 | 226 | file >> dat; |
227 | if(!strcmp(dat,"localBoards"))ReadFileBoards(file); | |
683cb6c5 | 228 | else AliWarning("File .dat in wrong format"); |
8c0b5e70 | 229 | file.close(); |
081d3361 | 230 | } else { |
8c0b5e70 | 231 | AliWarning(Form("Can't read file %s",fileName.Data())); |
081d3361 | 232 | } |
233 | } | |
234 | ||
235 | ||
081d3361 | 236 | //__________________________________________________________________________ |
237 | void AliMUONTriggerEfficiencyCells::ReadFileBoards(ifstream &file) | |
238 | { | |
313c3f0c | 239 | /// Structure of file (.dat) containing local board efficency |
311d0691 | 240 | Int_t datInt=0, detEl=0, chamber=0, chCath=0, bin=0; |
081d3361 | 241 | Float_t datFloat=0.0; |
96079e17 | 242 | Char_t dat[50]; |
081d3361 | 243 | |
244 | while (file >> dat) { | |
245 | file >> detEl; | |
246 | chamber = FindChamberIndex(detEl); | |
313c3f0c | 247 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ |
248 | chCath = fgkNchambers*cath + chamber; | |
081d3361 | 249 | file >> dat; |
250 | file >> datInt; | |
311d0691 | 251 | for(Int_t board=1; board<=AliMpConstants::NofLocalBoards(); board++){ |
081d3361 | 252 | file >> datFloat; |
311d0691 | 253 | bin = fBoardEfficiency[chCath]->FindBin(board); |
254 | fBoardEfficiency[chCath]->SetBinContent(bin, datFloat); | |
081d3361 | 255 | } |
256 | } | |
257 | } | |
258 | } | |
70b4a8d6 | 259 | |
8c0b5e70 | 260 | |
261 | //__________________________________________________________________________ | |
96079e17 | 262 | void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename) |
8c0b5e70 | 263 | { |
313c3f0c | 264 | /// Structure of file (.root) containing local board efficency |
8c0b5e70 | 265 | TFile *file = new TFile(filename, "read"); |
266 | if(!file) { | |
267 | AliWarning(Form("Can't read file %s",filename)); | |
268 | return; | |
269 | } | |
aef183f7 | 270 | TString histoName; |
271 | TString cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"}; | |
683cb6c5 | 272 | enum {kAllChEff, kChNonEff, kNumOfHistoTypes}; |
aef183f7 | 273 | TString histoTypeName[2] = {"CountInCh", "NonCountInCh"}; |
311d0691 | 274 | |
683cb6c5 | 275 | if(!fCountHistoList) fCountHistoList = new TList(); |
276 | else fCountHistoList->Delete(); | |
277 | if(!fNoCountHistoList) fNoCountHistoList = new TList(); | |
278 | else fNoCountHistoList->Delete(); | |
279 | ||
280 | TList *currList[2] = {fCountHistoList, fNoCountHistoList}; | |
281 | ||
282 | TH1F *histo = 0x0; | |
283 | ||
284 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
285 | for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){ | |
aef183f7 | 286 | histoName = Form("%sChamber%s", cathCode[cath].Data(), histoTypeName[hType].Data()); |
287 | histo = (TH1F*)file->Get(histoName.Data()); | |
683cb6c5 | 288 | currList[hType]->Add(histo); |
289 | } | |
290 | } | |
291 | ||
292 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
293 | for(Int_t ch=0; ch<fgkNchambers; ch++){ | |
294 | for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){ | |
aef183f7 | 295 | histoName = Form("%sSlat%s%i", cathCode[cath].Data(), histoTypeName[hType].Data(), 11+ch); |
296 | histo = (TH1F*)file->Get(histoName.Data()); | |
683cb6c5 | 297 | currList[hType]->Add(histo); |
8c0b5e70 | 298 | } |
683cb6c5 | 299 | } |
8c0b5e70 | 300 | } |
683cb6c5 | 301 | |
302 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
303 | for(Int_t ch=0; ch<fgkNchambers; ch++){ | |
304 | for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){ | |
aef183f7 | 305 | histoName = Form("%sBoard%s%i", cathCode[cath].Data(), histoTypeName[hType].Data(), 11+ch); |
306 | histo = (TH1F*)file->Get(histoName.Data()); | |
683cb6c5 | 307 | currList[hType]->Add(histo); |
308 | } | |
309 | } | |
310 | } | |
311 | ||
312 | InitHistos(); | |
313 | FillHistosFromList(); | |
8c0b5e70 | 314 | } |
315 | ||
316 | ||
313c3f0c | 317 | //_____________________________________________________________________________ |
318 | void AliMUONTriggerEfficiencyCells::CheckConstants() const | |
319 | { | |
320 | /// Check consistence of redefined constants | |
321 | ||
322 | assert(fgkNcathodes == AliMpConstants::NofCathodes()); | |
323 | assert(fgkNchambers == AliMpConstants::NofTriggerChambers()); | |
324 | assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes); | |
325 | } | |
326 | ||
327 | ||
70b4a8d6 | 328 | //__________________________________________________________________________ |
313c3f0c | 329 | Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId) const |
70b4a8d6 | 330 | { |
5398f946 | 331 | /// From detElemId to chamber number |
42814105 | 332 | |
333 | // Int_t iChamber = AliMpDEManager::GetChamberId(detElemId); | |
334 | Int_t iChamber = detElemId/100 - 1; | |
313c3f0c | 335 | Int_t chamber = iChamber-AliMpConstants::NofTrackingChambers(); |
70b4a8d6 | 336 | return chamber; |
337 | } | |
338 | ||
339 | ||
70b4a8d6 | 340 | //__________________________________________________________________________ |
341 | void | |
342 | AliMUONTriggerEfficiencyCells::Reset() | |
343 | { | |
5398f946 | 344 | /// Sets our internal array contents to zero. |
345 | ||
683cb6c5 | 346 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ |
347 | fBoardEfficiency[chCath] = 0x0; | |
348 | fSlatEfficiency[chCath] = 0x0; | |
349 | } | |
311d0691 | 350 | } |
351 | ||
352 | ||
353 | //__________________________________________________________________________ | |
354 | void | |
355 | AliMUONTriggerEfficiencyCells::InitHistos() | |
356 | { | |
357 | /// Sets our internal array contents to zero. | |
358 | ||
359 | const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards(); | |
683cb6c5 | 360 | const Int_t kNslats = 18; |
311d0691 | 361 | Int_t chCath=0; |
aef183f7 | 362 | TString histoName; |
311d0691 | 363 | |
aef183f7 | 364 | TString cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"}; |
311d0691 | 365 | |
366 | for(Int_t ch=0; ch<fgkNchambers; ch++){ | |
367 | for(Int_t cath=0; cath<fgkNcathodes; cath++){ | |
368 | chCath = fgkNchambers*cath + ch; | |
aef183f7 | 369 | histoName = Form("%sBoardEffChamber%i", cathCode[cath].Data(), 11+ch); |
370 | fBoardEfficiency[chCath] = new TH1F(histoName.Data(), histoName.Data(), kNumOfBoards, 1-0.5, kNumOfBoards+1.-0.5); | |
371 | histoName = Form("%sSlatEffChamber%i", cathCode[cath].Data(), 11+ch); | |
372 | fSlatEfficiency[chCath] = new TH1F(histoName.Data(), histoName.Data(), kNslats, 0-0.5, kNslats-0.5); | |
311d0691 | 373 | } |
374 | } | |
375 | } | |
376 | ||
377 | ||
378 | //__________________________________________________________________________ | |
379 | void | |
380 | AliMUONTriggerEfficiencyCells::FillHistosFromList() | |
381 | { | |
96079e17 | 382 | /// Fills internal histos from list. |
311d0691 | 383 | |
384 | Int_t nHistoBins=0; | |
385 | TH1F *histoNum = 0x0, *histoDen=0x0, *currHisto = 0x0; | |
386 | TString slatName = "Slat", boardName = "Board", histoName; | |
387 | Int_t iHistoBoard = -1, iHistoSlat = -1; | |
388 | Float_t efficiency, efficiencyError; | |
389 | ||
390 | Int_t nentries = fCountHistoList->GetEntries(); | |
391 | ||
392 | for(Int_t iEntry=0; iEntry<nentries; iEntry++){ | |
393 | histoNum = (TH1F*)fCountHistoList->At(iEntry); | |
394 | histoDen = (TH1F*)fNoCountHistoList->At(iEntry); | |
395 | ||
396 | if(!histoNum) { | |
397 | AliWarning("Histogram not found in fCountHistoList. Skip to next"); | |
398 | continue; | |
399 | } | |
400 | if(!histoDen) { | |
401 | AliWarning("Histogram not found in fNoCountHistoList. Skip to next"); | |
402 | continue; | |
403 | } | |
404 | ||
405 | histoName = histoNum->GetName(); | |
406 | nHistoBins = histoNum->GetNbinsX(); | |
407 | ||
408 | if(histoName.Contains(boardName)){ | |
409 | iHistoBoard++; | |
410 | currHisto = fBoardEfficiency[iHistoBoard]; | |
411 | } | |
412 | else if(histoName.Contains(slatName)){ | |
413 | iHistoSlat++; | |
414 | currHisto = fSlatEfficiency[iHistoSlat]; | |
415 | } | |
416 | else continue; | |
417 | ||
418 | for(Int_t iBin=1; iBin<=nHistoBins; iBin++){ | |
419 | CalculateEfficiency((Int_t)histoNum->GetBinContent(iBin), (Int_t)histoNum->GetBinContent(iBin) + (Int_t)histoDen->GetBinContent(iBin), efficiency, efficiencyError, kFALSE); | |
420 | ||
421 | currHisto->SetBinContent(iBin, efficiency); | |
422 | currHisto->SetBinError(iBin, efficiencyError); | |
423 | } | |
424 | } | |
425 | } | |
426 | ||
427 | ||
311d0691 | 428 | //_____________________________________________________________________________ |
429 | void AliMUONTriggerEfficiencyCells::CalculateEfficiency(Int_t trigger44, Int_t trigger34, | |
430 | Float_t &efficiency, Float_t &error, | |
431 | Bool_t failuresAsInput) | |
432 | { | |
433 | // | |
434 | /// Returns the efficiency. | |
435 | // | |
436 | ||
437 | efficiency=-9.; | |
438 | error=0.; | |
439 | if(trigger34>0){ | |
440 | efficiency=(Double_t)trigger44/((Double_t)trigger34); | |
441 | if(failuresAsInput)efficiency=1.-(Double_t)trigger44/((Double_t)trigger34); | |
442 | } | |
443 | Double_t q = TMath::Abs(1-efficiency); | |
444 | if(efficiency<0)error=0.0; | |
445 | else error = TMath::Sqrt(efficiency*q/((Double_t)trigger34)); | |
446 | } | |
447 | ||
96079e17 | 448 | |
311d0691 | 449 | //_____________________________________________________________________________ |
aef183f7 | 450 | void AliMUONTriggerEfficiencyCells::CheckFiredStrips(const Char_t* cdbStorage, |
683cb6c5 | 451 | Int_t runNumber) |
311d0691 | 452 | { |
453 | // | |
96079e17 | 454 | /// Check for fired strips participating to efficiency |
455 | /// calculation (when available). | |
456 | /// Strips inside a local board should be quite homogeneously hit | |
457 | /// If not, this could be a problem of electronics (i.e. ADULT board off). | |
311d0691 | 458 | // |
459 | ||
96079e17 | 460 | if(!fFiredStrips) { |
461 | AliWarning("List of fired pads not present. Check not performable."); | |
462 | return; | |
463 | } | |
464 | ||
aef183f7 | 465 | GetListsForCheck(cdbStorage, runNumber); |
96079e17 | 466 | |
aef183f7 | 467 | TString histoName; |
96079e17 | 468 | |
469 | // Check fired pads (when available) | |
470 | if(fFiredFitHistoList){ | |
471 | TH1F *histo1D = 0x0; | |
472 | TF1 *fitFunc = 0x0; | |
473 | TCanvas *histoFiredCan[20]; | |
474 | Int_t nEntries = fFiredFitHistoList->GetEntries(); | |
475 | for(Int_t iEntry=0; iEntry<nEntries; iEntry++){ | |
476 | histo1D = (TH1F*)fFiredFitHistoList->At(iEntry); | |
477 | printf("Problems found in %s\n", histo1D->GetTitle()); | |
478 | } | |
479 | Int_t nPrintCan = nEntries; | |
480 | if(nPrintCan>20) { | |
481 | AliWarning("Too many boards with problems: only 20 will be shown"); | |
482 | nPrintCan = 20; | |
483 | } | |
484 | for(Int_t iCan=0; iCan<nPrintCan; iCan++){ | |
485 | histo1D = (TH1F*)fFiredFitHistoList->At(iCan); | |
aef183f7 | 486 | histoName = histo1D->GetName(); |
487 | histoName.Append("Can"); | |
488 | histoFiredCan[iCan] = new TCanvas(histoName.Data(), histoName.Data(), 100+10*iCan, 10*iCan, 700, 700); | |
96079e17 | 489 | histoFiredCan[iCan]->SetRightMargin(0.14); |
490 | histoFiredCan[iCan]->SetLeftMargin(0.12); | |
491 | histo1D->Draw("E"); | |
492 | fitFunc = histo1D->GetFunction("pol0"); | |
493 | fitFunc->SetLineColor(2); | |
494 | fitFunc->Draw("same"); | |
495 | } | |
496 | if(nEntries==0){ | |
497 | printf("\nAll local boards seem ok!!\n\n"); | |
498 | } | |
499 | } | |
500 | } | |
501 | ||
502 | ||
503 | //_____________________________________________________________________________ | |
683cb6c5 | 504 | void AliMUONTriggerEfficiencyCells::DisplayEfficiency(Bool_t perSlat, |
683cb6c5 | 505 | const Char_t* cdbStorage, |
506 | Int_t runNumber) | |
96079e17 | 507 | { |
508 | // | |
509 | /// Display calculated efficiency. | |
510 | // | |
311d0691 | 511 | |
512 | Bool_t isInitSlat = kFALSE, isInitBoard = kFALSE; | |
513 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ | |
514 | if(fBoardEfficiency[chCath]->GetEntries()>0) isInitBoard = kTRUE; | |
515 | if(fSlatEfficiency[chCath]->GetEntries()>0) isInitSlat = kTRUE; | |
516 | } | |
517 | ||
518 | if(!isInitBoard){ | |
519 | printf("Trigger efficiency not initialized per board.\nDisplay not yet implemented.\n"); | |
520 | return; | |
521 | } | |
522 | if(!isInitSlat && perSlat){ | |
523 | printf("Trigger efficiency not initialized for slat.\nPlease try option kFALSE.\n"); | |
524 | return; | |
525 | } | |
96079e17 | 526 | |
aef183f7 | 527 | GetListsForCheck(cdbStorage, runNumber); |
96079e17 | 528 | |
aef183f7 | 529 | //const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards(); |
96079e17 | 530 | |
531 | TH2F *histo = 0x0; | |
aef183f7 | 532 | TString histoName, histoTitle; |
96079e17 | 533 | |
534 | // Plot fired strips (when available) | |
535 | if(fFiredDisplayHistoList){ | |
536 | TCanvas *displayFiredCan[fgkNplanes]; | |
537 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ | |
538 | histo = (TH2F*)fFiredDisplayHistoList->At(chCath); | |
aef183f7 | 539 | histoName = Form("%sCan", histo->GetName()); |
540 | histoTitle = Form("%s", histo->GetTitle()); | |
541 | displayFiredCan[chCath] = new TCanvas(histoName.Data(), histoTitle.Data(), 100+10*chCath, 10*chCath, 700, 700); | |
96079e17 | 542 | displayFiredCan[chCath]->SetRightMargin(0.14); |
543 | displayFiredCan[chCath]->SetLeftMargin(0.12); | |
544 | histo->GetYaxis()->SetTitleOffset(1.4); | |
545 | histo->SetStats(kFALSE); | |
546 | histo->Draw("COLZ"); | |
96079e17 | 547 | } |
548 | } | |
549 | ||
550 | // Plot efficiency | |
551 | if(fDisplayHistoList){ | |
552 | TCanvas *can[fgkNplanes]; | |
553 | for(Int_t chCath=0; chCath<fgkNplanes; chCath++){ | |
554 | Int_t currChCath = chCath; | |
555 | if(perSlat==kTRUE) currChCath += fgkNplanes; | |
556 | histo = (TH2F*)fDisplayHistoList->At(currChCath); | |
aef183f7 | 557 | histoName = Form("%sCan", histo->GetName()); |
558 | histoTitle = Form("%s", histo->GetTitle()); | |
559 | can[chCath] = new TCanvas(histoName.Data(), histoTitle.Data(), 100+10*chCath, 10*chCath, 700, 700); | |
96079e17 | 560 | can[chCath]->SetRightMargin(0.14); |
561 | can[chCath]->SetLeftMargin(0.12); | |
562 | histo->GetZaxis()->SetRangeUser(0.,1.); | |
563 | histo->GetYaxis()->SetTitleOffset(1.4); | |
564 | histo->SetStats(kFALSE); | |
565 | histo->Draw("COLZ"); | |
aef183f7 | 566 | if(perSlat==kTRUE) continue; |
567 | histo = (TH2F*)fBoardLabelList->At(currChCath); | |
568 | histo->Draw("textsame"); | |
96079e17 | 569 | } |
570 | } | |
571 | } | |
572 | ||
573 | ||
574 | //__________________________________________________________________________ | |
aef183f7 | 575 | Bool_t AliMUONTriggerEfficiencyCells::GetListsForCheck(const Char_t* cdbStorage, |
683cb6c5 | 576 | Int_t runNumber) |
96079e17 | 577 | { |
3e0aa963 | 578 | // |
579 | /// Getting histograms for efficiency, | |
580 | /// map of fired strips entering efficiency calculations, | |
581 | /// fits for checking switched-off elements in chambers. | |
582 | // | |
96079e17 | 583 | const Float_t kChi2RedMax = 1.5; |
584 | const Float_t kDummyFired = 1e-5; | |
585 | ||
586 | if(fDisplayHistoList || fBoardLabelList || fFiredFitHistoList || fFiredDisplayHistoList) return kTRUE; | |
587 | ||
588 | if(!fDisplayHistoList) fDisplayHistoList = new TList(); | |
589 | if(!fBoardLabelList) fBoardLabelList = new TList(); | |
590 | if(!fFiredFitHistoList && fFiredStrips) fFiredFitHistoList = new TList(); | |
591 | if(!fFiredDisplayHistoList && fFiredStrips) fFiredDisplayHistoList = new TList(); | |
592 | ||
683cb6c5 | 593 | AliCDBManager::Instance()->SetDefaultStorage(cdbStorage); |
594 | AliCDBManager::Instance()->SetRun(runNumber); | |
595 | ||
aef183f7 | 596 | TH3F* padFired = 0x0; |
597 | TH2F* displayHisto = 0x0; | |
598 | TH1F* histoFired[fgkNplanes][234]; | |
599 | TF1* fitFunc = 0x0; | |
96079e17 | 600 | Bool_t isStripOffInBoard[fgkNplanes][234]; |
aef183f7 | 601 | Int_t bin=0; |
602 | TString histoName, histoTitle; | |
603 | TString cathName[fgkNcathodes] = {"bendPlane", "nonBendPlane"}; | |
311d0691 | 604 | |
aef183f7 | 605 | AliMUONTriggerDisplay triggerDisplay; |
96079e17 | 606 | // Book histos |
aef183f7 | 607 | for(Int_t iCath=0; iCath<fgkNcathodes; iCath++){ |
608 | if(fFiredStrips) padFired = (TH3F*)fFiredStrips->At(iCath); | |
609 | for(Int_t iCh=0; iCh<fgkNchambers; iCh++){ | |
610 | Int_t chCath = fgkNchambers*iCath + iCh; | |
611 | Int_t currCh = 11 + iCh; | |
612 | histoName = Form("%sChamber%i", cathName[iCath].Data(), currCh); | |
613 | histoTitle = Form("Chamber %i: efficiency %s", currCh, cathName[iCath].Data()); | |
614 | displayHisto = | |
615 | (TH2F*)triggerDisplay.GetDisplayHistogram(fBoardEfficiency[chCath], histoName, | |
616 | AliMUONTriggerDisplay::kDisplayBoards, | |
617 | iCath,currCh,histoTitle, | |
618 | AliMUONTriggerDisplay::kShowZeroes); | |
619 | fDisplayHistoList->Add(displayHisto); | |
620 | ||
621 | histoName = Form("labels%sChamber%i", cathName[iCath].Data(), currCh); | |
622 | displayHisto = | |
623 | (TH2F*)triggerDisplay.GetBoardNumberHisto(histoName,currCh); | |
624 | fBoardLabelList->Add(displayHisto); | |
96079e17 | 625 | |
626 | if(!fFiredStrips) continue; | |
aef183f7 | 627 | histoName = Form("firedPads%sChamber%i", cathName[iCath].Data(), currCh); |
628 | histoTitle = Form("Chamber %i: Fired pads %s", currCh, cathName[iCath].Data()); | |
629 | bin = padFired->GetXaxis()->FindBin(currCh); | |
630 | padFired->GetXaxis()->SetRange(bin,bin); | |
631 | displayHisto = | |
632 | (TH2F*)triggerDisplay.GetDisplayHistogram(padFired->Project3D("zy"),histoName, | |
633 | AliMUONTriggerDisplay::kDisplayStrips, | |
634 | iCath,currCh,histoTitle); | |
635 | fFiredDisplayHistoList->Add(displayHisto); | |
96079e17 | 636 | |
aef183f7 | 637 | for(Int_t ib=0; ib<AliMpConstants::NofLocalBoards(); ib++){ |
638 | histoName = Form("%sChamber%iBoard%i", cathName[iCath].Data(), currCh, ib+1); | |
639 | histoTitle = Form("Chamber %i: fired pads %s board = %i", currCh, cathName[iCath].Data(), ib+1); | |
640 | histoFired[chCath][ib] = new TH1F(histoName.Data(), histoTitle.Data(), 16, -0.5, 15.5); | |
96079e17 | 641 | histoFired[chCath][ib]->SetXTitle("board"); |
642 | isStripOffInBoard[chCath][ib] = kFALSE; | |
643 | } // loop on board | |
644 | } // loop on chamber | |
645 | } // loop on cathode | |
311d0691 | 646 | |
aef183f7 | 647 | for(Int_t iCath=0; iCath<fgkNcathodes; iCath++){ |
648 | for(Int_t iCh=0; iCh<fgkNchambers; iCh++){ | |
649 | Int_t chCath = fgkNchambers*iCath + iCh; | |
650 | Int_t currCh = 11+iCh; | |
651 | histoName = Form("%sChamber%iSlatEff", cathName[iCath].Data(), currCh); | |
652 | histoTitle = Form("Chamber %i: efficiency %s per slat", currCh, cathName[iCath].Data()); | |
653 | displayHisto = | |
654 | (TH2F*)triggerDisplay.GetDisplayHistogram(fSlatEfficiency[chCath], histoName, | |
655 | AliMUONTriggerDisplay::kDisplaySlats, | |
656 | iCath,currCh,histoTitle); | |
657 | fDisplayHistoList->Add(displayHisto); | |
96079e17 | 658 | } |
311d0691 | 659 | } |
660 | ||
aef183f7 | 661 | if(!fFiredStrips) return kTRUE; |
311d0691 | 662 | |
aef183f7 | 663 | // Check fired pads (when available) |
664 | for(Int_t iLoc = 0; iLoc < AliMpConstants::NofLocalBoards(); iLoc++) { | |
665 | Int_t iBoard = iLoc+1; | |
666 | for(Int_t iCh=0; iCh<AliMpConstants::NofChambers(); iCh++){ | |
667 | Int_t iChamber = iCh + AliMpConstants::NofTrackingChambers(); | |
311d0691 | 668 | |
aef183f7 | 669 | Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromLocalBoard(iBoard, iChamber); |
311d0691 | 670 | |
aef183f7 | 671 | if (!detElemId) continue; |
311d0691 | 672 | |
aef183f7 | 673 | AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(iBoard, kFALSE); |
674 | ||
675 | // skip copy cards | |
676 | if( !localBoard->IsNotified()) | |
677 | continue; | |
678 | ||
679 | for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){ | |
680 | Int_t chCath = fgkNchambers*iCath + iCh; | |
681 | // loop over strips | |
682 | const AliMpVSegmentation* seg = | |
683 | AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(iCath)); | |
684 | Int_t nStrips=0; | |
685 | for (Int_t iStrip = 0; iStrip < 16; ++iStrip) { | |
168e9c4d | 686 | AliMpPad pad = seg->PadByLocation(iBoard,iStrip,kFALSE); |
aef183f7 | 687 | if (!pad.IsValid()) continue; |
688 | nStrips++; | |
689 | padFired = (TH3F*)fFiredStrips->At(iCath); | |
690 | Float_t nFired = padFired->GetBinContent(11+iCh, iBoard, iStrip); | |
691 | if(nFired==0.) nFired = kDummyFired; | |
692 | histoFired[chCath][iLoc]->Fill(iStrip, nFired); | |
693 | } | |
694 | ||
695 | histoFired[chCath][iLoc]->Fit("pol0","Q0R","",0., (Float_t)nStrips-1.); | |
696 | fitFunc = histoFired[chCath][iLoc]->GetFunction("pol0"); | |
697 | Float_t chi2 = fitFunc->GetChisquare(); | |
698 | Float_t ndf = (Float_t)fitFunc->GetNDF(); | |
699 | Float_t reducedChi2 = chi2/ndf; | |
700 | if(reducedChi2>kChi2RedMax) { | |
701 | isStripOffInBoard[chCath][iLoc] = kTRUE; | |
702 | fFiredFitHistoList->Add(histoFired[chCath][iLoc]); | |
703 | } | |
704 | } // loop on cathodes | |
705 | } // loop on chambers | |
706 | } // loop on local boards | |
96079e17 | 707 | |
708 | return kTRUE; | |
70b4a8d6 | 709 | } |
710 | ||
311d0691 | 711 | //__________________________________________________________________________ |
712 | Bool_t AliMUONTriggerEfficiencyCells::SumRunEfficiency(const AliMUONTriggerEfficiencyCells &other) | |
713 | { | |
714 | /// Sums results from different runs and gives the efficiency | |
715 | if(!fCountHistoList || !fNoCountHistoList) { | |
716 | AliWarning("Histograms for efficiency calculations not implemented in object"); | |
717 | return kFALSE; | |
718 | } | |
719 | if(!other.fCountHistoList || !other.fNoCountHistoList) { | |
720 | AliWarning("Histograms for efficiency calculations not implemented in object passed as argument"); | |
721 | return kFALSE; | |
722 | } | |
723 | ||
724 | Int_t nentries = fCountHistoList->GetEntries(); | |
725 | TH1F *currNum = 0x0, *currDen = 0x0, *otherNum = 0x0, *otherDen = 0x0; | |
726 | ||
727 | for(Int_t iEntry=0; iEntry<nentries; iEntry++){ | |
728 | currNum = (TH1F*)fCountHistoList->At(iEntry); | |
729 | currDen = (TH1F*)fNoCountHistoList->At(iEntry); | |
730 | otherNum = (TH1F*)other.fCountHistoList->At(iEntry); | |
731 | otherDen = (TH1F*)other.fNoCountHistoList->At(iEntry); | |
732 | currNum->Add(otherNum); | |
733 | currDen->Add(otherDen); | |
734 | } | |
735 | ||
736 | FillHistosFromList(); | |
96079e17 | 737 | |
738 | if(!fFiredStrips) { | |
739 | AliWarning("Histograms for fired region check not implemented in object"); | |
740 | return kFALSE; | |
741 | } | |
742 | if(!other.fFiredStrips) { | |
743 | AliWarning("Histograms for fired region check not implemented in object passed as argument"); | |
744 | return kFALSE; | |
745 | } | |
746 | ||
747 | TH3F *currFired = 0x0, *otherFired = 0x0; | |
748 | nentries = fFiredStrips->GetEntries(); | |
749 | for(Int_t iEntry=0; iEntry<nentries; iEntry++){ | |
750 | currFired = (TH3F*)fFiredStrips->At(iEntry); | |
751 | otherFired = (TH3F*)fFiredStrips->At(iEntry); | |
752 | currFired->Add(otherFired); | |
753 | } | |
754 | ||
311d0691 | 755 | return kTRUE; |
756 | } |