]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMaker.cxx
expert QA data are written on demand only. The cycles array has been extended to...
[u/mrichter/AliRoot.git] / STEER / AliQADataMaker.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
17 /* $Id$ */
18
19 //
20 //  Base Class
21 //  Produces the data needed to calculate the quality assurance. 
22 //  All data must be mergeable objects.
23 //  Y. Schutz CERN July 2007
24 //
25
26 // --- ROOT system ---
27 #include <TSystem.h> 
28 #include <TFile.h>
29 #include <TList.h> 
30 #include <TTree.h>
31 #include <TClonesArray.h>
32 #include <TParameter.h>
33
34 // --- Standard library ---
35
36 // --- AliRoot header files ---
37 #include "AliLog.h"
38 #include "AliQADataMaker.h"
39 #include "AliQAChecker.h"
40 #include "AliESDEvent.h"
41 #include "AliRawReader.h"
42
43 ClassImp(AliQADataMaker)
44              
45 //____________________________________________________________________________ 
46 AliQADataMaker::AliQADataMaker(const char * name, const char * title) : 
47   TNamed(name, title), 
48   fOutput(0x0),
49   fDetectorDir(0x0),
50   fDetectorDirName(""), 
51   fCurrentCycle(0), 
52   fCycle(9999999), 
53   fCycleCounter(0), 
54   fWriteExpert(kFALSE),
55   fParameterList(0x0), 
56   fRun(0)
57 {
58   // ctor
59   fDetectorDirName = GetName() ; 
60 }
61
62 //____________________________________________________________________________ 
63 AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
64   TNamed(qadm.GetName(), qadm.GetTitle()),
65   fOutput(qadm.fOutput),
66   fDetectorDir(qadm.fDetectorDir),
67   fDetectorDirName(qadm.fDetectorDirName),
68   fCurrentCycle(qadm.fCurrentCycle), 
69   fCycle(qadm.fCycle), 
70   fCycleCounter(qadm.fCycleCounter), 
71   fWriteExpert(qadm.fWriteExpert),
72   fParameterList(qadm.fParameterList),  
73   fRun(qadm.fRun)
74 {
75   //copy ctor
76   fDetectorDirName = GetName() ; 
77 }
78
79 //____________________________________________________________________________
80 Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray * list, const Bool_t expert, const Bool_t saveForCorr) 
81
82         // Set histograms memory resident and add to the list
83         // Maximm allowed is 10000
84         TString className(hist->ClassName()) ;
85         if( ! className.BeginsWith("T") ) {
86                 AliError(Form("QA data Object must be a generic ROOT object and not %s", className.Data())) ; 
87 //              return -1 ;
88         }
89         if ( index > 10000 ) {
90                 AliError("Max number of authorized QA objects is 10000") ; 
91                 return -1 ; 
92         } else {
93                 hist->SetDirectory(0) ; 
94     if (expert) {
95       TString name(hist->GetTitle()) ; 
96       name.Append(AliQA::GetExpert()) ; 
97       hist->SetTitle(name) ;
98     }
99                 list->AddAtAndExpand(hist, index) ; 
100     char * name = Form("%s_%s", list->GetName(), hist->GetName()) ;  
101     TParameter<double> * p = new TParameter<double>(name, 9999.9999) ;
102     if(saveForCorr) {  
103       if ( ! fParameterList )
104         fParameterList = new TList() ; 
105       fParameterList->Add(p) ;
106     }
107     return list->GetLast() ;
108   }
109 }
110
111 //____________________________________________________________________________
112 void AliQADataMaker::DefaultEndOfDetectorCycle(AliQA::TASKINDEX_t task) 
113 {
114         // this method must be oveloaded by detectors
115         // sets the QA result to Fatal
116         AliQA::Instance(AliQA::GetDetIndex(GetName())) ;
117         AliQA * qa = AliQA::Instance(task) ;
118         qa->Set(AliQA::kFATAL) ; 
119         AliQA::GetQAResultFile()->cd() ; 
120         qa->Write(AliQA::GetQAName(), kWriteDelete) ;   
121         AliQA::GetQAResultFile()->Close() ; 
122 }
123
124 //____________________________________________________________________________ 
125 void AliQADataMaker::Finish() const 
126
127         // write to the output File
128         if (fOutput) 
129                 fOutput->Close() ; 
130
131
132 //____________________________________________________________________________ 
133 TObject * AliQADataMaker::GetData(TObjArray * list, const Int_t index)  
134
135         // Returns the QA object at index. Limit is 100. 
136         if (list) {
137                 if ( index > 10000 ) {
138                         AliError("Max number of authorized QA objects is 10000") ; 
139                         return NULL ; 
140                 } else {
141                         return list->At(index) ; 
142                 }       
143         } else {
144                 AliError("Data list is NULL !!") ; 
145                 return NULL ;           
146         }
147 }