]>
Commit | Line | Data |
---|---|---|
b658d7e4 | 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 | ||
037219ca | 19 | // @file AliHLTTPCEVE.cxx |
20 | // @author Matthias Richter | |
21 | // @date 2008-11-22 | |
22 | // @brief AliEVE bindings for the HLT TPC. | |
23 | // @note | |
b658d7e4 | 24 | |
25 | #include <cerrno> | |
26 | #include <cassert> | |
27 | #include "AliHLTTPCEVE.h" | |
28 | #include "TEvePointSet.h" | |
29 | #include "TEveElement.h" | |
30 | #include "AliRawReader.h" | |
31 | #include "AliHLTOUT.h" | |
32 | #include "AliHLTTPCDefinitions.h" | |
33 | #include "AliHLTTPCClusterDataFormat.h" | |
34 | #include "AliHLTTPCSpacePointData.h" | |
35 | #include "TSystem.h" | |
36 | #include "TClass.h" | |
37 | #include "TString.h" | |
38 | #include "TMath.h" | |
39 | ||
40 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
41 | ClassImp(AliHLTTPCEVE) | |
42 | ||
43 | AliHLTTPCEVE::AliHLTTPCEVE() | |
44 | : AliHLTLogging() | |
45 | { | |
46 | // see header file for class documentation | |
47 | // or | |
48 | // refer to README to build package | |
49 | // or | |
50 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
51 | } | |
52 | ||
53 | AliHLTTPCEVE::~AliHLTTPCEVE() | |
54 | { | |
55 | // see header file for class documentation | |
56 | } | |
57 | ||
037219ca | 58 | TEvePointSet* AliHLTTPCEVE::MakePointSetFromHLTDigits(const char* path, int eventNo, TEveElement* cont, Float_t maxR) const |
b658d7e4 | 59 | { |
60 | // see header file for class documentation | |
037219ca | 61 | AliHLTOUT* pHLTOUT=AliHLTOUT::New(path, eventNo); |
b658d7e4 | 62 | TEvePointSet* pointSet=MakePointSetFromHLTOUT(pHLTOUT, cont, maxR); |
63 | AliHLTOUT::Delete(pHLTOUT); | |
64 | return pointSet; | |
65 | } | |
66 | ||
67 | TEvePointSet* AliHLTTPCEVE::MakePointSetFromHLTOUT(AliRawReader* pRawReader, TEveElement* cont, Float_t maxR) const | |
68 | { | |
69 | // see header file for class documentation | |
70 | if (!pRawReader) return NULL; | |
71 | AliHLTOUT* pHLTOUT=AliHLTOUT::New(pRawReader); | |
72 | TEvePointSet* pointSet=MakePointSetFromHLTOUT(pHLTOUT, cont, maxR); | |
73 | AliHLTOUT::Delete(pHLTOUT); | |
74 | return pointSet; | |
75 | } | |
76 | ||
77 | TEvePointSet* AliHLTTPCEVE::MakePointSetFromHLTOUT(AliHLTOUT* pHLTOUT, TEveElement* /*cont*/, Float_t maxR) const | |
78 | { | |
79 | // see header file for class documentation | |
80 | if (!pHLTOUT) return NULL; | |
81 | ||
82 | const Int_t kMaxCl=100*160; | |
83 | TEvePointSet* clusters = new TEvePointSet(kMaxCl); | |
84 | if (clusters) { | |
85 | clusters->SetOwnIds(kTRUE); | |
86 | clusters->SetMarkerColor(2); | |
87 | clusters->SetMarkerStyle(5); | |
88 | ||
89 | if (pHLTOUT->Init()>=0) { | |
90 | for (int idx=pHLTOUT->SelectFirstDataBlock(AliHLTTPCDefinitions::fgkClustersDataType); | |
91 | idx>=0; | |
92 | idx=pHLTOUT->SelectNextDataBlock()) { | |
93 | const AliHLTUInt8_t* pBuffer=NULL; | |
94 | AliHLTUInt32_t size=0; | |
95 | AliHLTComponentDataType dt=kAliHLTVoidDataType; | |
96 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec; | |
97 | pHLTOUT->GetDataBlockDescription(dt, spec); | |
98 | ||
99 | if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) { | |
100 | int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec); | |
101 | if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr(spec)) { | |
102 | HLTWarning("cluster data array of multiple TPC slices, can not unambiguously determine phi; skipping data block of specification 0x%08x", spec); | |
103 | continue; | |
104 | } | |
105 | if (size>0 && AddClusters(clusters, reinterpret_cast<const AliHLTTPCClusterData*>(pBuffer), size, slice, maxR)<0) { | |
106 | // action if failed | |
107 | } | |
108 | pHLTOUT->ReleaseDataBuffer(pBuffer); | |
109 | } | |
110 | } | |
111 | } else { | |
112 | HLTError("initialization of HLTOUT handler failed"); | |
113 | } | |
114 | TString name="HLT TPC Clusters"; | |
115 | clusters->SetName(name); | |
116 | name.Form("N=%d", clusters->Size()); | |
117 | clusters->SetTitle(name); | |
118 | } | |
119 | ||
120 | return clusters; | |
121 | } | |
122 | ||
123 | int AliHLTTPCEVE::AddClusters(TEvePointSet* clusters, const AliHLTTPCClusterData* data, unsigned int sizeInByte, int slice, Float_t maxR) const | |
124 | { | |
125 | // see header file for class documentation | |
126 | int iResult=0; | |
127 | if (!clusters || !data) return -EINVAL; | |
128 | Float_t phi = ( slice + 0.5 ) * TMath::Pi() / 9.0; | |
129 | Float_t cos = TMath::Cos( phi ); | |
130 | Float_t sin = TMath::Sin( phi ); | |
131 | Float_t maxRsqr = maxR*maxR; // maxR squared for a simple geometrical cut below | |
132 | ||
133 | for (iResult=0; iResult<(int)data->fSpacePointCnt && iResult>=0; iResult++) { | |
134 | if (reinterpret_cast<const AliHLTUInt8_t*>(data->fSpacePoints)+(iResult+1)*sizeof(AliHLTTPCSpacePointData)>reinterpret_cast<const AliHLTUInt8_t*>(data)+sizeInByte) { | |
135 | HLTError("data missmatch: buffer of size %d does not match size of AliHLTTPCClusterData (%d) + %d tracks x AliHLTTPCSpacePointData (%d)", | |
136 | sizeInByte, sizeof(AliHLTTPCClusterData), data->fSpacePointCnt, sizeof(AliHLTTPCSpacePointData)); | |
137 | iResult=-ENOMSG; | |
138 | break; | |
139 | } | |
140 | const AliHLTTPCSpacePointData* sp=&data->fSpacePoints[iResult]; | |
141 | if (sp->fX*sp->fX+sp->fY*sp->fY<=maxRsqr) { | |
142 | clusters->SetNextPoint(cos*sp->fX - sin*sp->fY, sin*sp->fX + cos*sp->fY, sp->fZ); | |
143 | } | |
144 | } | |
145 | ||
146 | if (iResult<0) { | |
147 | // reset clusters | |
148 | } | |
149 | ||
150 | return iResult; | |
151 | } |