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