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)
65 if ( fMaxNumberOfEntries >0 && fLog->GetNofItems() >= fMaxNumberOfEntries )
67 AliWarning(Form("Reached max number of entries (%d over %d). Printing and resetting.",
68 fLog->GetNofItems(),fMaxNumberOfEntries));
73 Int_t i = fLog->Get(message);
75 fLog->Set(message,i+1);
80 //_____________________________________________________________________________
82 AliMUONLogger::Clear(Option_t* /*option*/)
84 /// reset logger spool
89 //_____________________________________________________________________________
91 AliMUONLogger::Print(Option_t* opt) const
93 /// Print the entire log
94 if ( fLog->GetNofItems() )
100 cout << "No message" << endl;
104 //_____________________________________________________________________________
106 AliMUONLogger::Print(TString& key, ofstream& out) const
108 /// print out into a given streamer with a key word in front of the message
109 fLog->Print(key, out);
114 //_____________________________________________________________________________
116 AliMUONLogger::ResetItr()
118 /// call reset iterator method
123 //_____________________________________________________________________________
125 AliMUONLogger::Next(TString& msg, Int_t& occurance)
127 /// call next iterator method
128 return fLog->Next(msg, occurance);
132 //_____________________________________________________________________________
134 AliMUONLogger::NumberOfEntries() const
136 /// Get the number of logs we have so far
137 return fLog->GetNofItems();