]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONLogger.cxx
fixing compilation problem
[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 //-----------------------------------------------------------------------------
25 /// \class AliMUONLogger
26 ///
27 /// A logger that keeps track of the number of times a message appeared.
28 ///
29 /// Typically used to print all messages to screen at once, e.g. in the
30 /// dtor of a worker class.
31 ///
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.
35 ///
36 /// \author Laurent Aphecetche
37 //-----------------------------------------------------------------------------
38
39 /// \cond CLASSIMP
40 ClassImp(AliMUONLogger)
41 /// \endcond
42
43 //_____________________________________________________________________________
44 AliMUONLogger::AliMUONLogger(Int_t maxNumberOfEntries) 
45 : TObject(), 
46   fMaxNumberOfEntries(maxNumberOfEntries),
47   fLog(new AliMUONStringIntMap)
48 {
49     /// ctor. After maxNumberOfEntries, the log is printed and reset
50 }
51
52 //_____________________________________________________________________________
53 AliMUONLogger::~AliMUONLogger()
54 {
55   /// dtor
56   delete fLog;
57 }
58
59 //_____________________________________________________________________________
60 Int_t 
61 AliMUONLogger::Log(const char* message)
62 {
63   /// Log a message
64   if ( fLog->GetNofItems() >= fMaxNumberOfEntries ) 
65   {
66     AliWarning("Reached max number of entries. Printing and resetting.");
67     Print();
68     fLog->Clear();
69   }
70   
71   Int_t i = fLog->Get(message);
72   
73   fLog->Set(message,i+1);
74   
75   return i+1;
76 }
77
78 //_____________________________________________________________________________
79 void   
80 AliMUONLogger::Clear(Option_t* /*option*/) 
81 {  
82   /// reset logger spool
83
84   fLog->Clear();
85 }
86
87 //_____________________________________________________________________________
88 void 
89 AliMUONLogger::Print(Option_t* opt) const
90 {
91   /// Print the entire log
92   if ( fLog->GetNofItems() )
93   {
94     fLog->Print(opt);
95   }
96   else
97   {
98     cout << "No message" << endl;
99   }
100 }
101   
102 //_____________________________________________________________________________
103 void
104 AliMUONLogger::Print(TString& key, ofstream& out) const
105 {
106   /// print out into a given streamer with a key word in front of the message
107   fLog->Print(key, out); 
108
109       
110 }
111    
112 //_____________________________________________________________________________
113 void 
114 AliMUONLogger::ResetItr()
115 {
116   /// call reset iterator method
117   fLog->ResetItr();
118      
119 }
120  
121 //_____________________________________________________________________________
122 Bool_t 
123 AliMUONLogger::Next(TString& msg, Int_t& occurance)
124 {
125   /// call next iterator method
126   return fLog->Next(msg, occurance);
127      
128 }
129     
130     
131