Partial redesign of identification bits and coding rule corrections
[u/mrichter/AliRoot.git] / PHOS / AliPHOSQAChecker.cxx
CommitLineData
66f72ab4 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//_________________________________________________________________________
19// Base class for a QA checker, to be instanciated as a container of user
20// defined tasks
21//*-- Author : Yves Schutz (SUBATECH)
22//////////////////////////////////////////////////////////////////////////////
23
24// --- ROOT system ---
25#include "TROOT.h"
66f72ab4 26
27// --- Standard library ---
28
66f72ab4 29// --- AliRoot header files ---
30
31#include "AliPHOSQAChecker.h"
32#include "AliPHOSQAVirtualCheckable.h"
33
34ClassImp(AliPHOSQAChecker)
35
36
37//____________________________________________________________________________
38 AliPHOSQAChecker::AliPHOSQAChecker(const char * name, const char * title) : TTask(name,title)
39{
40 // ctor
7a9d98f9 41 // stores checkers in the PHOS QA TTask folder //Folders/Task/QA
42 TTask * aliceQA = (TTask*)gROOT->FindObjectAny("Folders/Tasks/QA") ;
66f72ab4 43 TTask * phosQA = (TTask*)aliceQA->GetListOfTasks()->FindObject("PHOS") ;
66f72ab4 44 if (phosQA) // PHOS QA Tasks container exists
9688c1dd 45 phosQA->Add(this) ;
7a9d98f9 46 else // create //Folders/Task/QA/PHOS
9688c1dd 47 aliceQA->Add(this) ;
a1d3d38a 48
2685bf00 49 fCheckablesList = new TList() ;
50 fCheckable = 0;
66f72ab4 51}
52
53//____________________________________________________________________________
54 AliPHOSQAChecker::~AliPHOSQAChecker()
55{
56 // dtor remove the checker from the task list of the associated checker
57
58 TIter next(fCheckablesList) ;
59 AliPHOSQAVirtualCheckable * checkable ;
60 while ( (checkable = (AliPHOSQAVirtualCheckable*)next()) )
61 checkable->RemoveChecker(this) ;
62 ExecuteTasks("D") ;
63}
64
65//____________________________________________________________________________
66 void AliPHOSQAChecker::CheckIt(AliPHOSQAVirtualCheckable *ca)
67{
68 // does the check for the given checkable
69
70 SetCheckable(ca) ;
71 TList * l = GetListOfTasks() ;
72 TIter next(l) ;
73 AliPHOSQAChecker * checker ;
74 while ( (checker = (AliPHOSQAChecker*)next()) )
75 checker->SetCheckable(ca) ;
76 ExecuteTask("") ;
77 fCheckable = 0 ;
78}
79
80//____________________________________________________________________________
81 void AliPHOSQAChecker::CheckIt()
82{
83 // does the check for all attached chekables
84 if ( fCheckablesList->IsEmpty() )
85 ExecuteTask("C") ;
86 else {
87 TIter next( fCheckablesList ) ;
88 AliPHOSQAVirtualCheckable * checkable ;
89 while ( (checkable = (AliPHOSQAVirtualCheckable*)next() ) ) {
90 fCheckable = checkable ;
91 ExecuteTask("") ;
92 }
93 }
94}
95
96//____________________________________________________________________________
97 void AliPHOSQAChecker::Exec(Option_t *option)
98{
99 // Performs various tasks as indicated by option
100 // P --> Print
101 // S --> Status
102 // C --> does the comparison on all the checkables declared
103 // --> does the comparison on only one checkable (the one which asks CheckMe() )
104 // A --> list the alarms raised in the associated checkables
105 // R --> reset the alarms
106 // D --> calls the dtor
107
108 if ( !(strcmp(option,"P")) )
109 Print() ;
110
111 else if ( !(strcmp(option,"S")) )
112 Status() ;
113
114 else if ( !(strcmp(option,"C")) ) {
115 TIter next( fCheckablesList ) ;
116 AliPHOSQAVirtualCheckable * checkable ;
117 while ( (checkable = (AliPHOSQAVirtualCheckable*)next() ) ) {
118 fCheckable = checkable ;
119 TString message = CheckingOperation();
120 if ( !message.IsNull() ) {
121 TDatime dt ;
122 TString time(dt.AsSQLString()) ;
123 message = time + message ;
124 fCheckable->RaiseAlarm(dt.AsSQLString(), fCheckable->GetName(), GetName(), message.Data()) ;
125 }
126 }
127 }
128
129 else if ( !(strcmp(option,"R")) ) {
130 TIter next( fCheckablesList ) ;
131 AliPHOSQAVirtualCheckable * checkable ;
132 while ( (checkable = (AliPHOSQAVirtualCheckable*)next() ) ) {
133 fCheckable = checkable ;
134 fCheckable->ResetAlarms() ;
135 }
136 }
137
138 else if ( !(strcmp(option,"")) ) {
139 TString message = CheckingOperation();
140 if ( !message.IsNull() ) {
141 TDatime dt ;
142 TString time(dt.AsSQLString()) ;
143 message = time + message ;
144 fCheckable->RaiseAlarm(dt.AsSQLString(), fCheckable->GetName(), GetName(), message.Data()) ;
145 }
146 }
147
148 else if ( !(strcmp(option,"A")) )
149 PrintAlarms() ;
150
151 else if ( !(strcmp(option,"D")) )
152 Delete() ;
153}
154
155//____________________________________________________________________________
156 void AliPHOSQAChecker::Print()
157{
158 // print the checker and sub-checkers, if any, name.
159
21cd0c07 160 Info("Print", "Checker : %s", GetName()) ;
66f72ab4 161
162}
163
164//____________________________________________________________________________
165 void AliPHOSQAChecker::PrintAlarms()
166{
167 // Prints the alarms of all attached checkables
21cd0c07 168 Info("PrintAlarms", "Checker name : %s", GetName()) ;
66f72ab4 169 if ( !(fCheckablesList->IsEmpty() ) ) {
170 TIter next( fCheckablesList ) ;
171 AliPHOSQAVirtualCheckable * checkable ;
172 while ( (checkable = (AliPHOSQAVirtualCheckable *)next() ) )
173 checkable->Alarms() ;
174 }
175}
176
177//____________________________________________________________________________
178 void AliPHOSQAChecker::Status()
179{
180 // Prints the checkables attached to this checker
181 if ( fCheckablesList->IsEmpty() )
21cd0c07 182 Info("Status", "No checkables are checked by %s", GetName()) ;
66f72ab4 183 else {
21cd0c07 184 Info("Status", "The following checkables are checked by %s", GetName()) ;
66f72ab4 185 TIter next(fCheckablesList) ;
186 AliPHOSQAVirtualCheckable * checkable ;
187 while ( (checkable = (AliPHOSQAVirtualCheckable*)next() ) )
188 checkable->Print() ;
189 }
190}