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 /// \class AliMUONLogger
26 /// A logger that keeps track of the number of times a message appeared.
28 /// Typically used to print all messages to screen at once, e.g. in the
29 /// dtor of a worker class.
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.
35 /// \author Laurent Aphecetche
38 ClassImp(AliMUONLogger)
41 //_____________________________________________________________________________
42 AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries)
44 fMaxNumberOfEntries(maxNumberOfEntries),
45 fLog(new AliMUONStringIntMap)
47 /// ctor. After maxNumberOfEntries, the log is printed and reset
50 //_____________________________________________________________________________
51 AliMUONLogger::~AliMUONLogger()
57 //_____________________________________________________________________________
59 AliMUONLogger::Log(const char* message)
62 if ( fLog->GetNofItems() >= fMaxNumberOfEntries )
64 AliWarning("Reached max number of entries. Printing and resetting.");
69 Int_t i = fLog->Get(message);
71 fLog->Set(message,i+1);
76 //_____________________________________________________________________________
78 AliMUONLogger::Print(Option_t* opt) const
80 /// Print the entire log
81 if ( fLog->GetNofItems() )
87 cout << "No message" << endl;