]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/ITS/AliHLTITSQAComponent.cxx
d877f57dc71c758f0006c903ddc5437e949b30eb
[u/mrichter/AliRoot.git] / HLT / ITS / AliHLTITSQAComponent.cxx
1 // $Id$
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project        * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary Authors: Piergiorgio Cerello <cerello@to.infn.it>              *
7 //*                  for The ALICE HLT Project.                            *
8 //*                                                                        *
9 //* Permission to use, copy, modify and distribute this software and its   *
10 //* documentation strictly for non-commercial purposes is hereby granted   *
11 //* without fee, provided that the above copyright notice appears in all   *
12 //* copies and that both the copyright notice and this permission notice   *
13 //* appear in the supporting documentation. The authors make no claims     *
14 //* about the suitability of this software for any purpose. It is          *
15 //* provided "as is" without express or implied warranty.                  *
16 //**************************************************************************
17
18 /// @file   AliHLTITSQHistoComponent.cxx
19 /// @author Piergiorgio Cerello cerello@to.infn.it
20 /// @date   2009-07-03
21 /// @brief  Interface component to the ITS QA
22
23 #include "AliHLTITSQAComponent.h"
24 #include "AliHLTITSClusterDataFormat.h"
25 #include "AliCDBEntry.h"
26 #include "AliCDBManager.h"
27 #include "AliITSRecPoint.h"
28 #include <TFile.h>
29 #include <TString.h>
30 #include "TObjString.h"
31 #include "TObjArray.h"
32
33 //#include <stdlib.h>
34 //#include <cerrno>
35
36 using namespace std;
37
38 /** ROOT macro for the implementation of ROOT specific class methods */
39 ClassImp(AliHLTITSQAComponent)
40
41 AliHLTITSQAComponent::AliHLTITSQAComponent()
42 :
43 fAliITSQADataMakerRec(NULL)
44 {
45   // see header file for class documentation
46   // or
47   // refer to README to build package
48   // or
49   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
50
51 }
52
53 AliHLTITSQAComponent::~AliHLTITSQAComponent()
54 {
55   // see header file for class documentation
56 }
57
58 // Public functions to implement AliHLTComponent's interface.
59 // These functions are required for the registration process
60
61 const char* AliHLTITSQAComponent::GetComponentID()
62 {
63   // see header file for class documentation
64   
65   return "ITSClusterQA";
66 }
67
68 void AliHLTITSQAComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
69 {
70   // see header file for class documentation
71   list.clear();
72   list.push_back( kAliHLTDataTypeTObjArray );
73 }
74
75 AliHLTComponentDataType AliHLTITSQAComponent::GetOutputDataType()
76 {
77   // see header file for class documentation
78   return kAliHLTDataTypeHistogram;
79
80 }
81
82 void AliHLTITSQAComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
83 {
84   // see header file for class documentation
85   // XXX TODO: Find more realistic values.
86   constBase = 80000;
87   inputMultiplier = 10;
88 }
89
90 AliHLTComponent* AliHLTITSQAComponent::Spawn()
91 {
92   // see header file for class documentation
93   return new AliHLTITSQAComponent;
94 }
95
96 int AliHLTITSQAComponent::DoInit( int argc, const char** argv )
97 {
98 // add AliITSQADataMakerRec constructor
99   fAliITSQADataMakerRec = new AliITSQADataMakerRec();
100   int iResult=0;
101   TString configuration="";
102   TString argument="";
103   for (int i=0; i<argc && iResult>=0; i++) {
104     argument=argv[i];
105     if (!configuration.IsNull()) configuration+=" ";
106     configuration+=argument;
107   }
108   
109   if (!configuration.IsNull()) {
110     iResult=Configure(configuration.Data());
111   }  
112
113   return iResult; 
114 }
115   
116 int AliHLTITSQAComponent::DoDeinit()
117 {
118   // see header file for class documentation
119 // add AliITSQADataMakerRec destruction
120   if(fAliITSQADataMakerRec) delete fAliITSQADataMakerRec;
121   return 0;
122 }
123
124 int AliHLTITSQAComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
125 {
126   
127   int TotalSpacePoint = 0;
128   
129   const AliHLTComponentBlockData* iter = NULL;
130   
131   if(!IsDataEvent())
132     return 0;
133   
134   static Int_t rp = 1; 
135   // Check id histograms already created for this Event Specie
136   if ( rp ) { fAliITSQADataMakerRec->InitRecPoints(); rp = 0; }
137   for ( iter = GetFirstInputBlock(kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD); iter != NULL; iter = GetNextInputBlock() ) {
138     
139     const AliHLTITSClusterData* clusterData = (const AliHLTITSClusterData*) iter->fPtr;
140     Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
141     TotalSpacePoint += nSpacepoint;
142     AliHLTITSSpacePointData *clusters = (AliHLTITSSpacePointData*) clusterData->fSpacePoints;
143
144     for(int i=0;i<nSpacepoint;i++){
145       Int_t lab[4]={0,0,0,0};
146       Float_t hit[6]={0,0,0,0,0,0};
147       Int_t info[3]={0,0,0};
148       
149       lab[0]=clusters[i].fTracks[0];
150       lab[1]=clusters[i].fTracks[1];
151       lab[2]=clusters[i].fTracks[2];
152       lab[3]=clusters[i].fIndex;
153       hit[0]=clusters[i].fY;
154       hit[1]=clusters[i].fZ;
155       hit[2]=clusters[i].fSigmaY2;
156       hit[3]=clusters[i].fSigmaZ2;
157       hit[4]=clusters[i].fQ;
158       hit[5]=clusters[i].fSigmaYZ;
159       info[0]=clusters[i].fNy;
160       info[1]=clusters[i].fNz;
161       info[2]=clusters[i].fLayer;
162
163       AliITSRecPoint recpoint(lab,hit,info);
164       fAliITSQADataMakerRec->FillRecPoint(recpoint);
165     }
166   }
167         for(Int_t i=0; i<6; i++) {
168                 //if(fPlotCharge){
169                 AliHLTUInt32_t specification = 0x0;
170                 PushBack( (TObject*) fAliITSQADataMakerRec->GetITSGlobalHisto(i),kAliHLTDataTypeHistogram,specification);
171                 //}
172         }
173         HLTInfo("ITSClusterHisto found %d Total Spacepoints", TotalSpacePoint);
174   
175   return 0;
176 }
177
178 int AliHLTITSQAComponent::Configure(const char* arguments)
179 {
180   
181   int iResult=0;
182   
183   if (!arguments) return iResult;
184   
185   TString allArgs=arguments;
186   TString argument;
187   
188   TObjArray* pTokens=allArgs.Tokenize(" ");
189   
190   if (pTokens) {
191     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
192       argument=((TObjString*)pTokens->At(i))->GetString();
193       if (argument.IsNull()) continue;
194 /*      
195       if (argument.CompareTo("-plot-all")==0) {
196         HLTInfo("Ploting all historgams");
197         fPlotXY = kTRUE;
198         fPlotXYZ = kTRUE;
199         fPlotCharge = kTRUE;
200         continue;
201       }
202       else if (argument.CompareTo("-plot-xy")==0) {
203         HLTInfo("Ploting Global XY");
204         fPlotXY = kTRUE;
205         continue;
206       }
207
208       else if (argument.CompareTo("-plot-xyz")==0) {
209         HLTInfo("Ploting Global XYZ");
210         //fPlotXYZ = kTRUE;
211         continue;
212       }
213       else if (argument.CompareTo("-plot-charge")==0) {
214         HLTInfo("Ploting charge of clusters");
215         fPlotCharge = kTRUE;
216         continue;
217       }
218 */
219       else {
220         HLTError("unknown argument %s", argument.Data());
221         iResult=-EINVAL;
222         break;
223       }
224     }
225     delete pTokens;
226   }
227   
228   return iResult;
229 }
230
231 int AliHLTITSQAComponent::Reconfigure(const char* cdbEntry, const char* chainId)
232 {
233   // see header file for class documentation
234   int iResult=0;
235   
236   const char* path="HLT/ConfigITS/HistoComponent";
237   const char* defaultNotify="";
238   if (cdbEntry) {
239     path=cdbEntry;
240     defaultNotify=" (default)";
241   }
242   if (path) {
243     HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
244     AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
245     if (pEntry) {
246       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
247       if (pString) {
248         HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
249         iResult=Configure(pString->GetString().Data());
250       } else {
251         HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
252       }
253     } else {
254       HLTError("can not fetch object \"%s\" from CDB", path);
255     }
256   }
257   
258   return iResult;
259 }