]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/QA/AliHLTQADataMakerRec.cxx
correct warnings
[u/mrichter/AliRoot.git] / HLT / QA / AliHLTQADataMakerRec.cxx
1 // $Id$
2
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project        * 
5 //* ALICE Experiment at CERN, All rights reserved.                         *
6 //*                                                                        *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8 //*                  for The ALICE HLT Project.                            *
9 //*                                                                        *
10 //* Permission to use, copy, modify and distribute this software and its   *
11 //* documentation strictly for non-commercial purposes is hereby granted   *
12 //* without fee, provided that the above copyright notice appears in all   *
13 //* copies and that both the copyright notice and this permission notice   *
14 //* appear in the supporting documentation. The authors make no claims     *
15 //* about the suitability of this software for any purpose. It is          *
16 //* provided "as is" without express or implied warranty.                  *
17 //**************************************************************************
18
19 /** @file   AliHLTQADataMakerRec.cxx
20     @author Matthias Richter
21     @date   2010-03-10
22     @brief  Steering class for the HLT offline QA
23 */
24 #include "AliHLTQADataMakerRec.h"
25 #include "AliHLTMisc.h"
26 #include "AliHLTModuleAgent.h"
27 #include "AliRecoParam.h"
28 #include <iostream>
29 #include "TString.h"
30 #include "TObjString.h"
31 #include "TObjArray.h"
32
33 using namespace std;
34
35 /** ROOT macro for the implementation of ROOT specific class methods */
36 ClassImp(AliHLTQADataMakerRec)
37
38 AliHLTQADataMakerRec::AliHLTQADataMakerRec()
39   : AliHLTQADataMakerBase()
40   , fPlugins()
41   , fFlags(0)
42 {
43   // see header file for class documentation
44   // or
45   // refer to README to build package
46   // or
47   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
48
49   LoadAgents();
50 }
51
52 AliHLTQADataMakerRec::~AliHLTQADataMakerRec()
53 {
54   // see header file for class documentation
55 }
56
57 int AliHLTQADataMakerRec::LoadAgents()
58 {
59   // iterate over available agents and query class names of plugins
60   TString plugins;
61   for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); 
62        pAgent!=NULL;
63        pAgent=AliHLTModuleAgent::GetNextAgent()) {
64     const char* modulePlugins=pAgent->GetQAPlugins();
65     if (!modulePlugins || !modulePlugins[0]) continue;
66     if (!plugins.IsNull() && !plugins.EndsWith(" ")) plugins+=" ";
67     plugins+=modulePlugins;
68   }
69   if (!plugins.IsNull()) return LoadPlugins(plugins);
70   return 0;
71 }
72
73 int AliHLTQADataMakerRec::LoadPlugins(const char* plugins)
74 {
75   // load plugins from list of blank separated class names
76   int iResult=0;
77   TString strPlugins=plugins;
78   TObjArray* tokens=strPlugins.Tokenize(" ");
79   if (tokens) {
80     TIter next(tokens);
81     TObject* obj=NULL;
82     while ((obj=next())) {
83       if (obj->IsA()!=TObjString::Class()) continue;
84       AliHLTQADataMakerBase* plugin=AliHLTMisc::LoadInstance((AliHLTQADataMakerBase*)0,
85                                                              dynamic_cast<TObjString*>(obj)->GetString().Data());
86       if (!plugin) continue;
87       AliInfo(Form("using HLT QA plugin %s", plugin->IsA()->GetName()));
88       fPlugins.Add(plugin);
89     }
90     delete tokens;
91   }
92   return iResult;
93 }
94
95 void AliHLTQADataMakerRec::StartOfDetectorCycle()
96 {
97   // see header file for class documentation
98   
99   // this function is called multiple times by the framework, actually for every QA task
100   // however, here we don't have any argument for the task
101   // this class is initialized right before StartOfDetectorCycle is called, and depending
102   // on the availibility of thr histogram arrays one can tell where we are ;-)
103   unsigned init=0;
104   if (fDigitsQAList!=NULL && (fFlags&kDigitsListInit)==0) {
105     init|=kDigitsListInit; // indicate that plugins should be initialized for that task
106     fFlags|=kDigitsListInit; // indicate that it was initialized
107   }
108   if (fESDsQAList!=NULL && (fFlags&kESDsListInit)==0) {
109     init|=kESDsListInit; // indicate that plugins should be initialized for that task
110     fFlags|=kESDsListInit; // indicate that it was initialized
111   }
112   if (fRawsQAList!=NULL && (fFlags&kRawsListInit)==0) {
113     init|=kRawsListInit; // indicate that plugins should be initialized for that task
114     fFlags|=kRawsListInit; // indicate that it was initialized
115   }
116   if (fRecPointsQAList!=NULL && (fFlags&kRecPointsListInit)==0) {
117     init|=kRecPointsListInit; // indicate that plugins should be initialized for that task
118     fFlags|=kRecPointsListInit; // indicate that it was initialized
119   }
120
121   TIter next(&fPlugins);
122   TObject* obj=NULL;
123   while ((obj=next())) {
124     AliHLTQADataMakerBase* plugin=dynamic_cast<AliHLTQADataMakerBase*>(obj);
125     if (!plugin) continue;
126     // transfer the properties set in AliQAManager::GetQADataMaker to the plugin
127     plugin->SetName(GetName());
128     plugin->SetUniqueID(GetUniqueID());
129     if (init&kDigitsListInit) plugin->Init(AliQAv1::GetTaskIndex("Digits"), 0);
130     if (init&kESDsListInit) plugin->Init(AliQAv1::GetTaskIndex("ESDs"), 0);
131     if (init&kRawsListInit) plugin->Init(AliQAv1::GetTaskIndex("Raws"), 0);
132     if (init&kRecPointsListInit) plugin->Init(AliQAv1::GetTaskIndex("RecPoints"), 0);
133     plugin->StartOfDetectorCycle();
134   }
135 }
136
137 void AliHLTQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** list)
138 {
139   // see header file for class documentation
140   TIter next(&fPlugins);
141   TObject* obj=NULL;
142   while ((obj=next())) {
143     AliHLTQADataMakerBase* plugin=dynamic_cast<AliHLTQADataMakerBase*>(obj);
144     if (!plugin) continue;
145     plugin->SetEventSpecie(GetEventSpecie());
146
147     TObjArray** pluginList=NULL;
148     if (task==AliQAv1::kESDS) {
149       pluginList=plugin->GetESDsQAList();
150     } else if (task==AliQAv1::kRECPOINTS) {
151       pluginList=plugin->GetRecPointsQAList();
152     } else if (task==AliQAv1::kDIGITS) {
153       pluginList=plugin->GetDigitsQAList();
154     } else if (task==AliQAv1::kRAWS) {
155       pluginList=plugin->GetRawsQAList();
156     }
157
158     if (pluginList) {
159       plugin->EndOfDetectorCycle(task, pluginList);
160       for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
161         if (!pluginList[specie]) continue;
162         TIter nextentry(pluginList[specie]);
163         TObject* entry=NULL;
164         while ((entry=nextentry())) {
165           AliInfo(Form("cloning histogram %s for specie %d", entry->GetName(), specie));
166           list[specie]->Add(entry->Clone());
167         }
168       }
169     }
170   }
171   
172 }
173
174 void AliHLTQADataMakerRec::MakeRaws(AliRawReader * rawReader)
175 {
176   // see header file for class documentation
177   if (!rawReader) return;
178
179   TIter next(&fPlugins);
180   TObject* obj=NULL;
181   while ((obj=next())) {
182     AliHLTQADataMakerBase* plugin=dynamic_cast<AliHLTQADataMakerBase*>(obj);
183     if (!plugin) continue;
184     plugin->SetEventSpecie(GetEventSpecie());
185     plugin->MakeRaws(rawReader);
186   }
187 }
188
189 void AliHLTQADataMakerRec::MakeESDs(AliESDEvent * esd, AliESDEvent* hltesd)
190 {
191   // HLT QA on ESDs
192   TIter next(&fPlugins);
193   TObject* obj=NULL;
194   while ((obj=next())) {
195     AliHLTQADataMakerBase* plugin=dynamic_cast<AliHLTQADataMakerBase*>(obj);
196     if (!plugin) continue;
197     plugin->SetEventSpecie(GetEventSpecie());
198     plugin->MakeESDs(esd, hltesd);
199   }
200 }