]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQualAssChecker.cxx
New QA classes (Yves)
[u/mrichter/AliRoot.git] / STEER / AliQualAssChecker.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 //                                                                           //
20 // class for running the Quality Assurance Checker
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include "AliLog.h"
25 #include "AliModule.h" 
26 #include "AliRun.h"
27 #include "AliRunLoader.h"
28 #include "AliQualAss.h"
29 #include "AliQualAssChecker.h"
30
31 #include <TObjArray.h>
32 #include <TStopwatch.h> 
33 #include <TString.h> 
34
35
36 ClassImp(AliQualAssChecker)
37
38   TFile * AliQualAssChecker::fgOutFile = 0x0 ; 
39   TString AliQualAssChecker::fgOutDir("/RUN/") ; 
40   TString AliQualAssChecker::fgOutName("QA.root") ; 
41   TString AliQualAssChecker::fgRefDir("/QA/Ref/") ; 
42   TString AliQualAssChecker::fgRefName("QA.root") ; 
43
44 //_____________________________________________________________________________
45 AliQualAssChecker::AliQualAssChecker(const char* name, const char* title) :
46   TNamed(name, title),
47   fGAliceFileName("galice.root"),
48   fStopOnError(kFALSE)
49 {
50   // create simulation object with default parameters
51
52   SetGAliceFile("galice.root");
53 }
54
55 //_____________________________________________________________________________
56 AliQualAssChecker::AliQualAssChecker(const AliQualAssChecker& qac) :
57   TNamed(qac),
58   fGAliceFileName(qac.fGAliceFileName),
59   fStopOnError(qac.fStopOnError)
60 {
61 // copy constructor
62 }
63
64 //_____________________________________________________________________________
65 AliQualAssChecker& AliQualAssChecker::operator = (const AliQualAssChecker& qac)
66 {
67 // assignment operator
68
69   this->~AliQualAssChecker();
70   new(this) AliQualAssChecker(qac);
71   return *this;
72 }
73
74 //_____________________________________________________________________________
75 AliQualAssChecker::~AliQualAssChecker()
76 {
77 // clean up
78   fgOutFile->Close() ; 
79   delete fgOutFile ;
80 }
81
82 //_____________________________________________________________________________
83 TFile * AliQualAssChecker:: GetOutFile() 
84 {
85   // Check if file to store QA exists, if not create it
86
87   if (fgOutFile) { 
88     if (fgOutFile->IsOpen()){
89       fgOutFile->Close() ; 
90       fgOutFile = 0x0 ; 
91     }
92   }   
93   fgOutName.Prepend(fgOutDir) ;
94   TString opt("") ; 
95   if ( !gSystem->AccessPathName(fgOutName) )
96     opt = "UPDATE" ; 
97   else 
98     opt = "NEW" ; 
99   fgOutFile = TFile::Open(fgOutName, opt) ;   
100   
101   return fgOutFile ; 
102 }
103
104 //_____________________________________________________________________________
105 AliRunLoader* AliQualAssChecker::LoadRun(const char* mode) const
106 {
107 // delete existing run loaders, open a new one and load gAlice
108   while (AliRunLoader::GetRunLoader()) 
109     delete AliRunLoader::GetRunLoader();
110   AliRunLoader* runLoader = 
111     AliRunLoader::Open(fGAliceFileName.Data(), 
112                        AliConfig::GetDefaultEventFolderName(), mode);
113   if (!runLoader) {
114     AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
115     return NULL;
116   }
117   runLoader->LoadgAlice();
118   gAlice = runLoader->GetAliRun();
119   if (!gAlice) {
120     AliError(Form("no gAlice object found in file %s", 
121                   fGAliceFileName.Data()));
122     return NULL;
123   }
124   return runLoader;
125 }
126
127 //_____________________________________________________________________________
128 Bool_t AliQualAssChecker::Run()
129 {
130  // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, recpoints, tracksegments, recparticles and ESDs
131
132   Bool_t rv = kFALSE ; 
133
134   TStopwatch stopwatch;
135   stopwatch.Start();
136
137   AliRunLoader* runLoader = LoadRun("READ");
138   if (!runLoader) 
139     return rv ;
140
141   TObjArray* detArray = runLoader->GetAliRun()->Detectors();
142   for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) {
143     AliModule* det = (AliModule*) detArray->At(iDet);
144     if (!det || !det->IsActive()) 
145       continue;
146       AliInfo(Form("QA checking %s", det->GetName()));
147       det->CheckQA();
148     }
149
150   delete runLoader;
151
152   AliInfo(Form("Execution time for QA: R:%.2fs C:%.2fs", stopwatch.RealTime(),stopwatch.CpuTime()));
153
154   return rv;
155 }
156
157 //_____________________________________________________________________________
158 void AliQualAssChecker::SetGAliceFile(const char* fileName)
159 {
160 // set the name of the galice file
161 // the path is converted to an absolute one if it is relative
162
163   fGAliceFileName = fileName;
164   if (!gSystem->IsAbsoluteFileName(fGAliceFileName)) {
165     char* absFileName = gSystem->ConcatFileName(gSystem->WorkingDirectory(),
166                                                 fGAliceFileName);
167     fGAliceFileName = absFileName;
168     delete[] absFileName;
169   }
170
171   AliDebug(2, Form("galice file name set to %s", fileName));
172 }
173
174 //_____________________________________________________________________________
175 void AliQualAssChecker::SetOutDir(const char * outDir)
176 {
177   // Set the root directory where to store the QA status object
178
179   fgOutDir.Prepend(outDir) ; 
180   AliInfo(Form("QA results are in  %s", fgOutDir.Data())) ;
181   if ( fgOutDir.Contains("local://")) 
182     fgOutDir.ReplaceAll("local:/", "") ;  
183 }
184
185 //_____________________________________________________________________________
186 void AliQualAssChecker::SetRefDir(const char * refDir)
187 {
188   // Set the root directory of reference data
189
190   fgRefDir.Prepend(refDir) ; 
191   fgRefDir.Append(fgRefName) ; 
192   AliInfo(Form("Reference data are taken from %s", fgRefDir.Data())) ;
193   if ( fgRefDir.Contains("local://")) 
194     fgRefDir.ReplaceAll("local:/", "") ; 
195 }
196
197
198
199
200