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