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