]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/ESD/AliRawDataErrorLog.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / STEER / ESD / AliRawDataErrorLog.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 /////////////////////////////////////////////////////////////////////
17 //   Implementation of AliRawDataErrorLog class                    //
18 //                                                                 //
19 // class AliRawDataErrorLog                                        //
20 // This is a class for logging raw-data related errors.            //
21 // It is used to record and retrieve of the errors                 //
22 // during the reading and reconstruction of raw-data and ESD       //
23 // analysis.                                                       //
24 // Further description of the methods and functionality are given  //
25 // inline.                                                         //
26 //                                                                 //
27 // cvetan.cheshkov@cern.ch                                         //
28 //                                                                 //
29 /////////////////////////////////////////////////////////////////////
30
31 #include "AliRawDataErrorLog.h"
32
33 #include <Riostream.h>
34
35 using std::endl;
36 using std::cout;
37 ClassImp(AliRawDataErrorLog)
38
39 //_____________________________________________________________________________
40 AliRawDataErrorLog::AliRawDataErrorLog() :
41   TNamed(),
42   fEventNumber(-1),
43   fDdlID(-1),
44   fErrorLevel(AliRawDataErrorLog::kMinor),
45   fErrorCode(0),
46   fCount(0)
47 {
48   // Default constructor
49 }
50
51 //_____________________________________________________________________________
52 AliRawDataErrorLog::AliRawDataErrorLog(Int_t eventNumber, Int_t ddlId,
53                                        ERawDataErrorLevel errorLevel,
54                                        Int_t errorCode,
55                                        const char *message) :
56   TNamed(message,""),
57   fEventNumber(eventNumber),
58   fDdlID(ddlId),
59   fErrorLevel(errorLevel),
60   fErrorCode(errorCode),
61   fCount(1)
62 {
63   // Constructor that specifies
64   // the event number, ddl id, error type and
65   // custom message related to the error
66 }
67
68 //___________________________________________________________________________
69 AliRawDataErrorLog::AliRawDataErrorLog(const AliRawDataErrorLog & source) :
70   TNamed(source),
71   fEventNumber(source.fEventNumber),
72   fDdlID(source.fDdlID),
73   fErrorLevel(source.fErrorLevel),
74   fErrorCode(source.fErrorCode),
75   fCount(source.fCount)
76 {
77   // Copy constructor
78 }
79
80 //___________________________________________________________________________
81 AliRawDataErrorLog & AliRawDataErrorLog::operator=(const AliRawDataErrorLog &source)
82 {
83   // assignment operator
84   if (this != &source) {
85     TNamed::operator=(source);
86
87     fEventNumber = source.GetEventNumber();
88     fDdlID       = source.GetDdlID();
89     fErrorLevel  = source.GetErrorLevel();
90     fErrorCode   = source.GetErrorCode();
91     fCount       = source.GetCount();
92   }
93   return *this;
94 }
95
96 void AliRawDataErrorLog::Copy(TObject &obj) const {
97   
98   // this overwrites the virtual TOBject::Copy()
99   // to allow run time copying without casting
100   // in AliESDEvent
101
102   if(this==&obj)return;
103   AliRawDataErrorLog *robj = dynamic_cast<AliRawDataErrorLog*>(&obj);
104   if(!robj)return; // not an AliRawDataErrorLog
105   *robj = *this;
106
107 }
108
109 //_____________________________________________________________________________
110 Int_t AliRawDataErrorLog::Compare(const TObject *obj) const
111 {
112   // Compare the event numbers and DDL IDs
113   // of two error log objects.
114   // Used in the sorting of raw data error logs
115   // during the raw data reading and reconstruction
116   Int_t eventNumber = ((AliRawDataErrorLog*)obj)->GetEventNumber();
117   Int_t ddlID = ((AliRawDataErrorLog*)obj)->GetDdlID();
118
119   if (fEventNumber == eventNumber) {
120     if (fDdlID == ddlID)
121       return 0;
122     else
123       return ((fDdlID > ddlID) ? 1 : -1);
124   }
125   else
126     return ((fEventNumber > eventNumber) ? 1 : -1);
127 }
128
129 //_____________________________________________________________________________
130 const char*
131 AliRawDataErrorLog::GetErrorLevelAsString() const
132 {
133   switch ( GetErrorLevel() )
134   {
135     case kMinor:
136       return "MINOR";
137       break;
138     case kMajor:
139       return "MAJOR";
140       break;
141     case kFatal:
142       return "FATAL";
143       break;
144     default:
145       return "INVALID";
146       break;
147   }
148   
149 }
150
151 //_____________________________________________________________________________
152 void
153 AliRawDataErrorLog::Print(Option_t*) const
154 {
155   cout << Form("EventNumber %10d DdlID %5d ErrorLevel %10s ErrorCode %4d Occurence %5d",
156                GetEventNumber(),GetDdlID(),
157                GetErrorLevelAsString(),
158                GetErrorCode(),
159                GetCount()) << endl;
160   cout << "    " << GetMessage() << endl;
161 }