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