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 //-----------------------------------------------------------------------------
42 ClassImp(AliMUONLogger)
45 //_____________________________________________________________________________
46 AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries)
48 fMaxNumberOfEntries(maxNumberOfEntries),
49 fLog(new AliMUONStringIntMap)
51 /// ctor. After maxNumberOfEntries, the log is printed and reset
54 //_____________________________________________________________________________
55 AliMUONLogger::~AliMUONLogger()
61 //_____________________________________________________________________________
63 AliMUONLogger::Log(const char* message)
67 if ( fMaxNumberOfEntries >0 && fLog->GetNofItems() >= fMaxNumberOfEntries )
69 AliWarning(Form("Reached max number of entries (%d over %d). Printing and resetting.",
70 fLog->GetNofItems(),fMaxNumberOfEntries));
75 Int_t i = fLog->Get(message);
77 fLog->Set(message,i+1);
82 //_____________________________________________________________________________
84 AliMUONLogger::Clear(Option_t* /*option*/)
86 /// reset logger spool
91 //_____________________________________________________________________________
93 AliMUONLogger::Print(Option_t* opt) const
95 /// Print the entire log
96 if ( fLog->GetNofItems() )
102 cout << "No message" << endl;
106 //_____________________________________________________________________________
108 AliMUONLogger::Print(TString& key, ofstream& out) const
110 /// print out into a given streamer with a key word in front of the message
111 fLog->Print(key, out);
116 //_____________________________________________________________________________
118 AliMUONLogger::ResetItr()
120 /// call reset iterator method
125 //_____________________________________________________________________________
127 AliMUONLogger::Next(TString& msg, Int_t& occurance)
129 /// call next iterator method
130 return fLog->Next(msg, occurance);
134 //_____________________________________________________________________________
136 AliMUONLogger::NumberOfEntries() const
138 /// Get the number of logs we have so far
139 return fLog->GetNofItems();