]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONLogger.cxx
Updated list of MUON libraries
[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
71a2d3aa 37/// \cond CLASSIMP
48beade4 38ClassImp(AliMUONLogger)
71a2d3aa 39/// \endcond
48beade4 40
41//_____________________________________________________________________________
42AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries)
43: TObject(),
44 fMaxNumberOfEntries(maxNumberOfEntries),
45 fLog(new AliMUONStringIntMap)
46{
47 /// ctor. After maxNumberOfEntries, the log is printed and reset
48}
49
50//_____________________________________________________________________________
51AliMUONLogger::~AliMUONLogger()
52{
53 /// dtor
54 delete fLog;
55}
56
57//_____________________________________________________________________________
58Int_t
59AliMUONLogger::Log(const char* message)
60{
61 /// Log a message
62 if ( fLog->GetNofItems() >= fMaxNumberOfEntries )
63 {
64 AliWarning("Reached max number of entries. Printing and resetting.");
65 Print();
66 fLog->Clear();
67 }
68
69 Int_t i = fLog->Get(message);
70
71 fLog->Set(message,i+1);
72
73 return i+1;
74}
75
76//_____________________________________________________________________________
77void
78AliMUONLogger::Print(Option_t* opt) const
79{
80 /// Print the entire log
81 if ( fLog->GetNofItems() )
82 {
83 fLog->Print(opt);
84 }
85 else
86 {
87 cout << "No message" << endl;
88 }
89}
90