Corrected Doxygen warnings:
[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
24/// \class AliMUONLogger
25///
26/// A logger that keeps track of the number of times a message appeared.
27///
28/// Typically used to print all messages to screen at once, e.g. in the
29/// dtor of a worker class.
30///
31/// For instance, it is used in AliMUONDigitizerV3, to note which channels
32/// are disabled, and this information is printed in a condensed form
33/// only once when DigitizerV3 is destroyed.
34///
78649106 35/// \author Laurent Aphecetche
48beade4 36
37ClassImp(AliMUONLogger)
38
39//_____________________________________________________________________________
40AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries)
41: TObject(),
42 fMaxNumberOfEntries(maxNumberOfEntries),
43 fLog(new AliMUONStringIntMap)
44{
45 /// ctor. After maxNumberOfEntries, the log is printed and reset
46}
47
48//_____________________________________________________________________________
49AliMUONLogger::~AliMUONLogger()
50{
51 /// dtor
52 delete fLog;
53}
54
55//_____________________________________________________________________________
56Int_t
57AliMUONLogger::Log(const char* message)
58{
59 /// Log a message
60 if ( fLog->GetNofItems() >= fMaxNumberOfEntries )
61 {
62 AliWarning("Reached max number of entries. Printing and resetting.");
63 Print();
64 fLog->Clear();
65 }
66
67 Int_t i = fLog->Get(message);
68
69 fLog->Set(message,i+1);
70
71 return i+1;
72}
73
74//_____________________________________________________________________________
75void
76AliMUONLogger::Print(Option_t* opt) const
77{
78 /// Print the entire log
79 if ( fLog->GetNofItems() )
80 {
81 fLog->Print(opt);
82 }
83 else
84 {
85 cout << "No message" << endl;
86 }
87}
88