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
37 ClassImp(AliMUONLogger)
39 //_____________________________________________________________________________
40 AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries)
42 fMaxNumberOfEntries(maxNumberOfEntries),
43 fLog(new AliMUONStringIntMap)
45 /// ctor. After maxNumberOfEntries, the log is printed and reset
48 //_____________________________________________________________________________
49 AliMUONLogger::~AliMUONLogger()
55 //_____________________________________________________________________________
57 AliMUONLogger::Log(const char* message)
60 if ( fLog->GetNofItems() >= fMaxNumberOfEntries )
62 AliWarning("Reached max number of entries. Printing and resetting.");
67 Int_t i = fLog->Get(message);
69 fLog->Set(message,i+1);
74 //_____________________________________________________________________________
76 AliMUONLogger::Print(Option_t* opt) const
78 /// Print the entire log
79 if ( fLog->GetNofItems() )
85 cout << "No message" << endl;