]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONLogger.cxx
Updated documentation
[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
cdf15cc5 78//_____________________________________________________________________________
79void
80AliMUONLogger::Clear(Option_t* /*option*/)
81{
82 /// reset logger spool
83
84 fLog->Clear();
85}
86
48beade4 87//_____________________________________________________________________________
88void
89AliMUONLogger::Print(Option_t* opt) const
90{
91 /// Print the entire log
92 if ( fLog->GetNofItems() )
93 {
94 fLog->Print(opt);
95 }
96 else
97 {
98 cout << "No message" << endl;
99 }
100}
38b84fe8 101
102//_____________________________________________________________________________
103void
104AliMUONLogger::Print(TString& key, ofstream& out) const
105{
106 /// print out into a given streamer with a key word in front of the message
107 fLog->Print(key, out);
108
109
110}
111
112//_____________________________________________________________________________
113void
114AliMUONLogger::ResetItr()
115{
116 /// call reset iterator method
117 fLog->ResetItr();
118
119}
120
121//_____________________________________________________________________________
122Bool_t
123AliMUONLogger::Next(TString& msg, Int_t& occurance)
124{
125 /// call next iterator method
126 return fLog->Next(msg, occurance);
127
128}
129
130
48beade4 131