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