]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONLogger.cxx
Various fixes in order to compile the DA source code
[u/mrichter/AliRoot.git] / MUON / AliMUONLogger.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
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 **************************************************************************/
15
16 // $Id$
17
18 #include "AliMUONLogger.h"
19
20 #include "AliMUONStringIntMap.h"
21 #include "AliLog.h"
22 #include "Riostream.h"
23
24 /// \class AliMUONLogger
25 ///
26 /// A logger that keeps track of the number of times a message appeared.
27 ///
28 /// Typically used to print all messages to screen at once, e.g. in the
29 /// dtor of a worker class.
30 ///
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.
34 ///
35 /// \author Laurent Aphecetche
36
37 /// \cond CLASSIMP
38 ClassImp(AliMUONLogger)
39 /// \endcond
40
41 //_____________________________________________________________________________
42 AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries) 
43 : TObject(), 
44   fMaxNumberOfEntries(maxNumberOfEntries),
45   fLog(new AliMUONStringIntMap)
46 {
47     /// ctor. After maxNumberOfEntries, the log is printed and reset
48 }
49
50 //_____________________________________________________________________________
51 AliMUONLogger::~AliMUONLogger()
52 {
53   /// dtor
54   delete fLog;
55 }
56
57 //_____________________________________________________________________________
58 Int_t 
59 AliMUONLogger::Log(const char* message)
60 {
61   /// Log a message
62   if ( fLog->GetNofItems() >= fMaxNumberOfEntries ) 
63   {
64     AliWarning("Reached max number of entries. Printing and resetting.");
65     Print();
66     fLog->Clear();
67   }
68   
69   Int_t i = fLog->Get(message);
70   
71   fLog->Set(message,i+1);
72   
73   return i+1;
74 }
75
76 //_____________________________________________________________________________
77 void 
78 AliMUONLogger::Print(Option_t* opt) const
79 {
80   /// Print the entire log
81   if ( fLog->GetNofItems() )
82   {
83     fLog->Print(opt);
84   }
85   else
86   {
87     cout << "No message" << endl;
88   }
89 }
90