adding map include file to solve compilation issue (bug https://savannah.cern.ch...
[u/mrichter/AliRoot.git] / HLT / ITS / AliHLTITSClusterHistoComponent.cxx
CommitLineData
c0b68f8e 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: Gaute Ovrebekk <ovrebekk@ift.uib.no> *
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 AliHLTITSClusterHistoComponent.cxx
19 @author Gaute Ovrebekk
f44c9362 20 @brief Component for plotting charge in clusters
c0b68f8e 21*/
22
23#if __GNUC__>= 3
24using namespace std;
25#endif
26
27#include "AliHLTITSClusterHistoComponent.h"
28#include "AliHLTITSClusterDataFormat.h"
29#include "AliCDBEntry.h"
30#include "AliCDBManager.h"
f44c9362 31#include "AliGeomManager.h"
c0b68f8e 32#include "AliITSRecPoint.h"
91edcbad 33#include "TMath.h"
c0b68f8e 34#include <TFile.h>
35#include <TString.h>
36#include "TObjString.h"
37#include "TObjArray.h"
38
c0b68f8e 39/** ROOT macro for the implementation of ROOT specific class methods */
40ClassImp(AliHLTITSClusterHistoComponent)
41
42AliHLTITSClusterHistoComponent::AliHLTITSClusterHistoComponent()
f44c9362 43 :
44 fXY(NULL),
91edcbad 45 fPhieta(NULL),
c0b68f8e 46 fCharge(NULL),
47 fPlotCharge(kFALSE),
59918cb1 48 fPlotXYPhiEta(kTRUE),
618f422f 49 fOutputSize(20000)
c0b68f8e 50{
51 // see header file for class documentation
52 // or
53 // refer to README to build package
54 // or
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
c0b68f8e 56}
57
f44c9362 58AliHLTITSClusterHistoComponent::~AliHLTITSClusterHistoComponent(){
c0b68f8e 59 // see header file for class documentation
60}
61
62// Public functions to implement AliHLTComponent's interface.
63// These functions are required for the registration process
64
f44c9362 65const char* AliHLTITSClusterHistoComponent::GetComponentID(){
c0b68f8e 66 // see header file for class documentation
c0b68f8e 67 return "ITSClusterHisto";
68}
69
f44c9362 70void AliHLTITSClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
c0b68f8e 71 // see header file for class documentation
72 list.clear();
8ce2efb0 73 list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD );
74 list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD );
75 list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD );
618f422f 76 list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITS );
c0b68f8e 77}
78
f44c9362 79AliHLTComponentDataType AliHLTITSClusterHistoComponent::GetOutputDataType(){
c0b68f8e 80 // see header file for class documentation
81 return kAliHLTDataTypeHistogram;
c0b68f8e 82}
83
f44c9362 84void AliHLTITSClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
c0b68f8e 85 // see header file for class documentation
86 // XXX TODO: Find more realistic values.
59918cb1 87 constBase = fOutputSize;
618f422f 88 inputMultiplier = 20;
c0b68f8e 89}
90
f44c9362 91AliHLTComponent* AliHLTITSClusterHistoComponent::Spawn(){
c0b68f8e 92 // see header file for class documentation
93 return new AliHLTITSClusterHistoComponent;
94}
95
f44c9362 96int AliHLTITSClusterHistoComponent::DoInit( int argc, const char** argv ){
97 // see header file for class documentation
98
99 if(AliGeomManager::GetGeometry()==NULL){
100 AliGeomManager::LoadGeometry();
101 }
102
103 fPlotCharge = kFALSE;
104 fPlotXYPhiEta = kTRUE;
c0b68f8e 105
f44c9362 106 if(fPlotCharge) fCharge = new TH1F("fCharge","Total Charge of clusters",2000,0,2000);
0b26a583 107 if(fPlotXYPhiEta){
f44c9362 108 fXY = new TH2F("fXY","Global XY of ITS clusters",1600,-80,80,1600,-80,80);
109 Char_t name[50];
110 Char_t title[50];
111 fPhieta = new TH2F*[6];
112 for (Int_t iLay=0;iLay<6;iLay++){
113 sprintf(name,"Phi_vs_Eta_ITS_Layer%d",iLay+1);
114 sprintf(title,"Phi vs Eta - ITS Layer %d",iLay+1);
115 fPhieta[iLay]=new TH2F(name,title,60,-1.5,1.5,60,0.,2*TMath::Pi());
116 fPhieta[iLay]->GetXaxis()->SetTitle("Pseudorapidity");
117 fPhieta[iLay]->GetYaxis()->SetTitle("#varphi [rad]");
118 }
0b26a583 119 }
c0b68f8e 120
121 int iResult=0;
122 TString configuration="";
123 TString argument="";
f44c9362 124
125 for(int i=0; i<argc && iResult>=0; i++){
c0b68f8e 126 argument=argv[i];
127 if (!configuration.IsNull()) configuration+=" ";
128 configuration+=argument;
129 }
130
f44c9362 131 if(!configuration.IsNull()){
c0b68f8e 132 iResult=Configure(configuration.Data());
133 }
134
135 return iResult;
136}
137
f44c9362 138int AliHLTITSClusterHistoComponent::DoDeinit(){
c0b68f8e 139 // see header file for class documentation
140 if(fCharge!=NULL) delete fCharge;
0b26a583 141 if(fXY!=NULL) {
f44c9362 142 delete fXY;
143 for(Int_t i=0;i<6;i++) delete fPhieta[5-i];
0b26a583 144 }
c0b68f8e 145 return 0;
146}
147
f44c9362 148int AliHLTITSClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
149 // see header file for class documentation
150
0b26a583 151 static Int_t event = 0;
152 event++;
c0b68f8e 153 int TotalSpacePoint = 0;
154
155 const AliHLTComponentBlockData* iter = NULL;
156
59918cb1 157 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
158 if(!IsDataEvent(&eventType) && eventType!=gkAliEventTypeEndOfRun) {
159 // publish the histograms at the end of run
160 return 0;
161 }
f44c9362 162
59918cb1 163 for(iter = GetFirstInputBlock(kAliHLTDataTypeClusters); eventType!=gkAliEventTypeEndOfRun && iter != NULL; iter = GetNextInputBlock()){
c0b68f8e 164
f44c9362 165 if(iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSPD) &&
166 iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSDD) &&
618f422f 167 iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSSD) &&
168 iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITS))
f44c9362 169 continue;
8ce2efb0 170
f44c9362 171 const AliHLTITSClusterData* clusterData = (const AliHLTITSClusterData*) iter->fPtr;
172 Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
173 TotalSpacePoint += nSpacepoint;
174 AliHLTITSSpacePointData *clusters = (AliHLTITSSpacePointData*) clusterData->fSpacePoints;
c0b68f8e 175
f44c9362 176 for(int i=0;i<nSpacepoint;i++){
177
178 Int_t lab[4] = {0,0,0,0};
179 Float_t hit[6] = {0,0,0,0,0,0};
180 Int_t info[3] = {0,0,0};
181
182 lab[0] = clusters[i].fTracks[0];
183 lab[1] = clusters[i].fTracks[1];
184 lab[2] = clusters[i].fTracks[2];
185 lab[3] = clusters[i].fIndex;
186 hit[0] = clusters[i].fY;
187 hit[1] = clusters[i].fZ;
188 hit[2] = clusters[i].fSigmaY2;
189 hit[3] = clusters[i].fSigmaZ2;
190 hit[4] = clusters[i].fQ;
191 hit[5] = clusters[i].fSigmaYZ;
192 info[0] = clusters[i].fNy;
193 info[1] = clusters[i].fNz;
194 info[2] = clusters[i].fLayer;
195
196 Float_t xyz[3];
197 AliITSRecPoint recpoint(lab,hit,info);
198 recpoint.GetGlobalXYZ(xyz);
199 Int_t layer = recpoint.GetLayer();
200
201 if(fPlotXYPhiEta){
202 fXY->Fill(xyz[0],xyz[1]);
203 Float_t rad=TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
204 Float_t theta=TMath::ATan2(rad,xyz[2]);
205 Float_t eta=-1*TMath::Log(TMath::Tan(theta/2.0));
206 Float_t phi=TMath::ATan2(xyz[1],xyz[0]);
207 if(phi<0.0){phi=2 * TMath::Pi() - TMath::Abs(phi);}
208 fPhieta[layer]->Fill(eta,phi);
209 }
210 if(fPlotCharge) fCharge->Fill(recpoint.GetQ());
c0b68f8e 211 }
212 }
213
214 if(fPlotCharge){
f44c9362 215 AliHLTUInt32_t fSpecification = 0x0;
59918cb1 216 if (PushBack( (TObject*) fCharge,kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification)==-ENOSPC) {
217 fOutputSize+=GetLastObjectSize();
218 }
c0b68f8e 219 }
0b26a583 220 if(fPlotXYPhiEta){
f44c9362 221 AliHLTUInt32_t fSpecification = 0x0;
59918cb1 222 if (PushBack( (TObject*) fXY,kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification)==-ENOSPC) {
223 fOutputSize+=GetLastObjectSize();
224 }
225 for(Int_t ii=0;ii<6;ii++)
226 if (PushBack( (TObject*) fPhieta[ii],kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification)==-ENOSPC) {
227 fOutputSize+=GetLastObjectSize();
228 }
c0b68f8e 229 }
230
f44c9362 231 HLTDebug("ITSClusterHisto found %d Total Spacepoints", TotalSpacePoint);
c0b68f8e 232
233 return 0;
234}
235
f44c9362 236int AliHLTITSClusterHistoComponent::Configure(const char* arguments){
237 // see header file for class documentation
238
c0b68f8e 239 int iResult=0;
240
241 if (!arguments) return iResult;
242
243 TString allArgs=arguments;
244 TString argument;
245
246 TObjArray* pTokens=allArgs.Tokenize(" ");
247
248 if (pTokens) {
249 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
250 argument=((TObjString*)pTokens->At(i))->GetString();
251 if (argument.IsNull()) continue;
252
253 if (argument.CompareTo("-plot-all")==0) {
254 HLTInfo("Ploting all historgams");
0b26a583 255 fPlotXYPhiEta = kTRUE;
c0b68f8e 256 fPlotCharge = kTRUE;
257 continue;
258 }
259
260 else if (argument.CompareTo("-plot-xy")==0) {
261 HLTInfo("Ploting Global XY");
0b26a583 262 fPlotXYPhiEta = kTRUE;
c0b68f8e 263 continue;
264 }
265
c0b68f8e 266 else if (argument.CompareTo("-plot-charge")==0) {
267 HLTInfo("Ploting charge of clusters");
268 fPlotCharge = kTRUE;
269 continue;
270 }
271
272 else {
273 HLTError("unknown argument %s", argument.Data());
274 iResult=-EINVAL;
275 break;
276 }
277 }
278 delete pTokens;
279 }
280
91edcbad 281 if(!fCharge && fPlotCharge){fCharge = new TH1F("fCharge","Total Charge of clusters",2000,0,2000);}
0b26a583 282 if(!fXY && fPlotXYPhiEta){
283 fXY = new TH2F("fXY","Global XY of ITS clusters",1600,-80,80,1600,-80,80);
284 Char_t name[50];
285 Char_t title[50];
286 fPhieta = new TH2F*[6];
287 for (Int_t iLay=0;iLay<6;iLay++) {
288 sprintf(name,"Phi_vs_Eta_ITS_Layer%d",iLay+1);
289 sprintf(title,"Phi vs Eta - ITS Layer %d",iLay+1);
290 fPhieta[iLay]=new TH2F(name,title,30,-1.5,1.5,200,0.,2*TMath::Pi());
291 fPhieta[iLay]->GetXaxis()->SetTitle("Pseudorapidity");
292 fPhieta[iLay]->GetYaxis()->SetTitle("#varphi [rad]");
293 }
294 }
c0b68f8e 295
296 return iResult;
297}
298
f44c9362 299int AliHLTITSClusterHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId){
c0b68f8e 300 // see header file for class documentation
301 int iResult=0;
302
303 const char* path="HLT/ConfigITS/HistoComponent";
304 const char* defaultNotify="";
305 if (cdbEntry) {
306 path=cdbEntry;
307 defaultNotify=" (default)";
308 }
309 if (path) {
310 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
311 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
312 if (pEntry) {
313 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
314 if (pString) {
315 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
316 iResult=Configure(pString->GetString().Data());
317 } else {
318 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
319 }
320 } else {
321 HLTError("can not fetch object \"%s\" from CDB", path);
322 }
323 }
324
325 return iResult;
326}