]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONLogger.cxx
Added total number of local boards
[u/mrichter/AliRoot.git] / MUON / AliMUONLogger.cxx
CommitLineData
48beade4 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
16// $Id$
17
18#include "AliMUONLogger.h"
19
20#include "AliMUONStringIntMap.h"
21#include "AliLog.h"
22#include "Riostream.h"
23
3d1463c8 24//-----------------------------------------------------------------------------
48beade4 25/// \class AliMUONLogger
26///
27/// A logger that keeps track of the number of times a message appeared.
28///
29/// Typically used to print all messages to screen at once, e.g. in the
30/// dtor of a worker class.
31///
32/// For instance, it is used in AliMUONDigitizerV3, to note which channels
33/// are disabled, and this information is printed in a condensed form
34/// only once when DigitizerV3 is destroyed.
35///
78649106 36/// \author Laurent Aphecetche
3d1463c8 37//-----------------------------------------------------------------------------
48beade4 38
71a2d3aa 39/// \cond CLASSIMP
48beade4 40ClassImp(AliMUONLogger)
71a2d3aa 41/// \endcond
48beade4 42
43//_____________________________________________________________________________
44AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries)
45: TObject(),
46 fMaxNumberOfEntries(maxNumberOfEntries),
47 fLog(new AliMUONStringIntMap)
48{
49 /// ctor. After maxNumberOfEntries, the log is printed and reset
50}
51
52//_____________________________________________________________________________
53AliMUONLogger::~AliMUONLogger()
54{
55 /// dtor
56 delete fLog;
57}
58
59//_____________________________________________________________________________
60Int_t
61AliMUONLogger::Log(const char* message)
62{
63 /// Log a message
64 if ( fLog->GetNofItems() >= fMaxNumberOfEntries )
65 {
66 AliWarning("Reached max number of entries. Printing and resetting.");
67 Print();
68 fLog->Clear();
69 }
70
71 Int_t i = fLog->Get(message);
72
73 fLog->Set(message,i+1);
74
75 return i+1;
76}
77
78//_____________________________________________________________________________
79void
80AliMUONLogger::Print(Option_t* opt) const
81{
82 /// Print the entire log
83 if ( fLog->GetNofItems() )
84 {
85 fLog->Print(opt);
86 }
87 else
88 {
89 cout << "No message" << endl;
90 }
91}
38b84fe8 92
93//_____________________________________________________________________________
94void
95AliMUONLogger::Print(TString& key, ofstream& out) const
96{
97 /// print out into a given streamer with a key word in front of the message
98 fLog->Print(key, out);
99
100
101}
102
103//_____________________________________________________________________________
104void
105AliMUONLogger::ResetItr()
106{
107 /// call reset iterator method
108 fLog->ResetItr();
109
110}
111
112//_____________________________________________________________________________
113Bool_t
114AliMUONLogger::Next(TString& msg, Int_t& occurance)
115{
116 /// call next iterator method
117 return fLog->Next(msg, occurance);
118
119}
120
121
48beade4 122