1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONLogger.h"
20 #include "AliMUONStringIntMap.h"
22 #include "Riostream.h"
24 //-----------------------------------------------------------------------------
25 /// \class AliMUONLogger
27 /// A logger that keeps track of the number of times a message appeared.
29 /// Typically used to print all messages to screen at once, e.g. in the
30 /// dtor of a worker class.
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.
36 /// \author Laurent Aphecetche
37 //-----------------------------------------------------------------------------
40 ClassImp(AliMUONLogger)
43 //_____________________________________________________________________________
44 AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries)
46 fMaxNumberOfEntries(maxNumberOfEntries),
47 fLog(new AliMUONStringIntMap)
49 /// ctor. After maxNumberOfEntries, the log is printed and reset
52 //_____________________________________________________________________________
53 AliMUONLogger::~AliMUONLogger()
59 //_____________________________________________________________________________
61 AliMUONLogger::Log(const char* message)
64 if ( fLog->GetNofItems() >= fMaxNumberOfEntries )
66 AliWarning("Reached max number of entries. Printing and resetting.");
71 Int_t i = fLog->Get(message);
73 fLog->Set(message,i+1);
78 //_____________________________________________________________________________
80 AliMUONLogger::Clear(Option_t* /*option*/)
82 /// reset logger spool
87 //_____________________________________________________________________________
89 AliMUONLogger::Print(Option_t* opt) const
91 /// Print the entire log
92 if ( fLog->GetNofItems() )
98 cout << "No message" << endl;
102 //_____________________________________________________________________________
104 AliMUONLogger::Print(TString& key, ofstream& out) const
106 /// print out into a given streamer with a key word in front of the message
107 fLog->Print(key, out);
112 //_____________________________________________________________________________
114 AliMUONLogger::ResetItr()
116 /// call reset iterator method
121 //_____________________________________________________________________________
123 AliMUONLogger::Next(TString& msg, Int_t& occurance)
125 /// call next iterator method
126 return fLog->Next(msg, occurance);