]>
Commit | Line | Data |
---|---|---|
6e34b293 | 1 | // $Id$ |
5f2721d5 | 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 Øvrebekk <st05886@alf.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 AliHLTITSClusterFinderSPDComponent.cxx | |
19 | @author Gaute Øvrebekk <st05886@alf.uib.no> | |
20 | @date | |
21 | @brief Component to run offline clusterfinder for SPD | |
22 | */ | |
23 | ||
24 | #if __GNUC__>= 3 | |
25 | using namespace std; | |
26 | #endif | |
27 | ||
28 | #include "AliHLTITSClusterFinderSPDComponent.h" | |
29 | ||
30 | #include "AliCDBEntry.h" | |
31 | #include "AliCDBManager.h" | |
32 | #include "AliHLTDataTypes.h" | |
33 | #include "AliITSgeomTGeo.h" | |
34 | #include "AliITSRecPoint.h" | |
c0b68f8e | 35 | #include "AliHLTITSSpacePointData.h" |
36 | #include "AliHLTITSClusterDataFormat.h" | |
b3ac448a | 37 | #include <AliHLTDAQ.h> |
5f2721d5 | 38 | |
39 | #include <cstdlib> | |
40 | #include <cerrno> | |
41 | #include "TString.h" | |
42 | #include "TObjString.h" | |
43 | #include <sys/time.h> | |
44 | ||
45 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
46 | ClassImp(AliHLTITSClusterFinderSPDComponent); | |
47 | ||
48 | AliHLTITSClusterFinderSPDComponent::AliHLTITSClusterFinderSPDComponent() | |
49 | : | |
b3ac448a | 50 | fNModules(AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1) + AliITSgeomTGeo::GetNDetectors(2)*AliITSgeomTGeo::GetNLadders(2)/*240*/), |
5f2721d5 | 51 | fClusterFinder(NULL), |
52 | fRawReader(NULL), | |
53 | fDettype(NULL), | |
54 | fClusters(NULL), | |
5f2721d5 | 55 | fgeom(NULL), |
6e34b293 | 56 | fgeomInit(NULL), |
57 | fSeg(NULL) | |
58 | { | |
5f2721d5 | 59 | // see header file for class documentation |
60 | // or | |
61 | // refer to README to build package | |
62 | // or | |
63 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
6e34b293 | 64 | |
65 | // AliITSDetTypeRec::fgkDefaultNModulesSPD private for the moment | |
66 | // if (AliITSDetTypeRec::fgkDefaultNModulesSPD!=240) { | |
67 | // HLTWarning("Number of modules has changed (AliITSDetTypeRec::fgkDefaultNModulesSPD)"); | |
68 | // } | |
5f2721d5 | 69 | } |
70 | ||
71 | AliHLTITSClusterFinderSPDComponent::~AliHLTITSClusterFinderSPDComponent() { | |
72 | // see header file for class documentation | |
73 | } | |
74 | ||
75 | // Public functions to implement AliHLTComponent's interface. | |
76 | // These functions are required for the registration process | |
77 | ||
78 | const char* AliHLTITSClusterFinderSPDComponent::GetComponentID() | |
79 | { | |
80 | // see header file for class documentation | |
81 | ||
82 | return "ITSClusterFinderSPD"; | |
83 | } | |
84 | ||
85 | void AliHLTITSClusterFinderSPDComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
86 | // see header file for class documentation | |
87 | list.clear(); | |
88 | list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD ); | |
89 | ||
90 | } | |
91 | ||
92 | AliHLTComponentDataType AliHLTITSClusterFinderSPDComponent::GetOutputDataType() { | |
93 | // see header file for class documentation | |
c0b68f8e | 94 | return kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD; |
5f2721d5 | 95 | } |
96 | ||
97 | void AliHLTITSClusterFinderSPDComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
98 | // see header file for class documentation | |
99 | ||
100 | constBase = 0; | |
b3ac448a | 101 | inputMultiplier = 100; |
5f2721d5 | 102 | } |
103 | ||
104 | AliHLTComponent* AliHLTITSClusterFinderSPDComponent::Spawn() { | |
105 | // see header file for class documentation | |
106 | return new AliHLTITSClusterFinderSPDComponent(); | |
107 | } | |
108 | ||
109 | Int_t AliHLTITSClusterFinderSPDComponent::DoInit( int /*argc*/, const char** /*argv*/ ) { | |
110 | // see header file for class documentation | |
111 | ||
112 | if ( fClusterFinder ) | |
b3ac448a | 113 | return -EINPROGRESS; |
5f2721d5 | 114 | |
115 | fClusters = new TClonesArray*[fNModules]; | |
116 | for (Int_t iModule = 0; iModule < fNModules; iModule++) { | |
117 | fClusters[iModule] = NULL; | |
118 | } | |
119 | ||
5f2721d5 | 120 | //fgeomInit = new AliITSInitGeometry(kvSPD02,2); |
121 | fgeomInit = new AliITSInitGeometry(kvPPRasymmFMD,2); | |
b3ac448a | 122 | //fgeomInit->InitAliITSgeom(fgeom); |
5f2721d5 | 123 | fgeom = fgeomInit->CreateAliITSgeom(); |
124 | ||
125 | //set dettype | |
126 | fDettype = new AliITSDetTypeRec(); | |
127 | fDettype->SetITSgeom(fgeom); | |
6e34b293 | 128 | fDettype->SetReconstructionModel(0,fClusterFinder); |
129 | fDettype->SetDefaultClusterFindersV2(kTRUE); | |
b3ac448a | 130 | fDettype->SetDefaults(); |
131 | //fDettype->GetCalibration(); | |
132 | //fSeg = new AliITSsegmentationSPD(); | |
133 | //fDettype->SetSegmentationModel(0,fSeg); | |
5f2721d5 | 134 | |
135 | fClusterFinder = new AliITSClusterFinderV2SPD(fDettype); | |
6e34b293 | 136 | fClusterFinder->InitGeometry(); |
5f2721d5 | 137 | |
138 | if ( fRawReader ) | |
b3ac448a | 139 | return -EINPROGRESS; |
5f2721d5 | 140 | |
141 | fRawReader = new AliRawReaderMemory(); | |
142 | ||
143 | return 0; | |
144 | } | |
145 | ||
146 | Int_t AliHLTITSClusterFinderSPDComponent::DoDeinit() { | |
147 | // see header file for class documentation | |
148 | ||
149 | if ( fRawReader ) | |
150 | delete fRawReader; | |
151 | fRawReader = NULL; | |
152 | ||
153 | if ( fClusterFinder ) | |
154 | delete fClusterFinder; | |
155 | fClusterFinder = NULL; | |
156 | ||
6e34b293 | 157 | if ( fDettype ) |
158 | delete fDettype; | |
159 | fDettype = NULL; | |
160 | ||
161 | for (Int_t iModule = 0; iModule < fNModules; iModule++) { | |
162 | if (fClusters[iModule]) delete fClusters[iModule]; | |
163 | fClusters[iModule] = NULL; | |
164 | } | |
165 | ||
166 | if ( fgeomInit ) | |
167 | delete fgeomInit; | |
168 | fgeomInit = NULL; | |
169 | ||
5f2721d5 | 170 | return 0; |
171 | } | |
172 | ||
173 | Int_t AliHLTITSClusterFinderSPDComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/) | |
174 | { // see header file for class documentation | |
175 | ||
176 | // -- Iterator over Data Blocks -- | |
177 | const AliHLTComponentBlockData* iter = NULL; | |
178 | ||
179 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){ | |
180 | return 0; | |
181 | } | |
182 | ||
183 | if (!IsDataEvent()) return 0; | |
184 | ||
185 | if ( evtData.fBlockCnt<=0 ) | |
186 | { | |
187 | Logging( kHLTLogWarning, "HLT::ITSClusterFinderSPD::DoEvent", "DoEvent", "no blocks in event" ); | |
188 | return 0; | |
189 | } | |
190 | ||
191 | // -- Loop over blocks | |
192 | for ( iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD); iter != NULL; iter = GetNextInputBlock() ) { | |
193 | ||
194 | // -- Debug output of datatype -- | |
195 | HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
196 | evtData.fEventID, evtData.fEventID, | |
197 | DataType2Text(iter->fDataType).c_str(), | |
198 | DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD).c_str()); | |
199 | ||
200 | // -- Check for the correct data type | |
6e34b293 | 201 | if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD) ) |
5f2721d5 | 202 | continue; |
203 | ||
5f2721d5 | 204 | // -- Get equipment ID out of specification |
205 | AliHLTUInt32_t spec = iter->fSpecification; | |
206 | ||
207 | if(spec>0x00040000){ | |
208 | HLTDebug("The Spec is to high for ITS SPD"); | |
209 | } | |
b3ac448a | 210 | |
5f2721d5 | 211 | Int_t id = 0; |
b3ac448a | 212 | for ( Int_t ii = 0; ii < AliHLTDAQ::NumberOfDdls("ITSSPD") ; ii++ ) { //number of ddl's |
5f2721d5 | 213 | if ( spec & 0x00000001 ) { |
214 | id += ii; | |
215 | break; | |
216 | } | |
217 | spec = spec >> 1 ; | |
218 | } | |
219 | ||
220 | // -- Set equipment ID to the raw reader | |
6e34b293 | 221 | |
5f2721d5 | 222 | if(!fRawReader->AddBuffer((UChar_t*) iter->fPtr, iter->fSize, id)){ |
223 | HLTWarning("Could not add buffer"); | |
224 | } | |
225 | ||
226 | fClusterFinder->RawdataToClusters(fRawReader,fClusters); | |
c0b68f8e | 227 | |
228 | UInt_t nClusters=0; | |
5f2721d5 | 229 | for(int i=0;i<fNModules;i++){ |
230 | if(fClusters[i] != NULL){ | |
c0b68f8e | 231 | nClusters += fClusters[i]->GetEntries(); |
5f2721d5 | 232 | } |
233 | } | |
c0b68f8e | 234 | |
235 | UInt_t bufferSize = nClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData); | |
236 | AliHLTUInt8_t *buffer = new AliHLTUInt8_t[bufferSize]; | |
237 | AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(buffer); | |
238 | outputClusters->fSpacePointCnt=nClusters; | |
6e34b293 | 239 | |
c0b68f8e | 240 | int clustIdx=0; |
5f2721d5 | 241 | for(int i=0;i<fNModules;i++){ |
242 | if(fClusters[i] != NULL){ | |
c0b68f8e | 243 | for(int j=0;j<fClusters[i]->GetEntries();j++){ |
244 | AliITSRecPoint *recpoint = (AliITSRecPoint*) fClusters[i]->At(j); | |
245 | outputClusters->fSpacePoints[clustIdx].fY=recpoint->GetY(); | |
246 | outputClusters->fSpacePoints[clustIdx].fZ=recpoint->GetZ(); | |
247 | outputClusters->fSpacePoints[clustIdx].fSigmaY2=recpoint->GetSigmaY2(); | |
248 | outputClusters->fSpacePoints[clustIdx].fSigmaZ2=recpoint->GetSigmaZ2(); | |
249 | outputClusters->fSpacePoints[clustIdx].fSigmaYZ=recpoint->GetSigmaYZ(); | |
250 | outputClusters->fSpacePoints[clustIdx].fQ=recpoint->GetQ(); | |
251 | outputClusters->fSpacePoints[clustIdx].fNy=recpoint->GetNy(); | |
252 | outputClusters->fSpacePoints[clustIdx].fNz=recpoint->GetNz(); | |
253 | outputClusters->fSpacePoints[clustIdx].fLayer=recpoint->GetLayer(); | |
254 | outputClusters->fSpacePoints[clustIdx].fIndex=recpoint->GetDetectorIndex();// | recpoint->GetPindex() | recpoint->GetNindex(); | |
255 | outputClusters->fSpacePoints[clustIdx].fTracks[0]=recpoint->GetLabel(0); | |
256 | outputClusters->fSpacePoints[clustIdx].fTracks[1]=recpoint->GetLabel(1); | |
257 | outputClusters->fSpacePoints[clustIdx].fTracks[2]=recpoint->GetLabel(2); | |
258 | ||
259 | clustIdx++; | |
5f2721d5 | 260 | } |
6e34b293 | 261 | } |
262 | } | |
5f2721d5 | 263 | |
c0b68f8e | 264 | PushBack(buffer,bufferSize,kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD,iter->fSpecification); |
265 | ||
6e34b293 | 266 | for (Int_t iModule = 0; iModule < fNModules; iModule++) { |
267 | if(fClusters[iModule]){delete fClusters[iModule];} | |
5f2721d5 | 268 | fClusters[iModule] = NULL; |
269 | } | |
6e34b293 | 270 | |
b3ac448a | 271 | delete buffer; |
272 | ||
5f2721d5 | 273 | fRawReader->ClearBuffers(); |
274 | ||
275 | } // for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) { | |
276 | ||
5f2721d5 | 277 | return 0; |
278 | } | |
c0b68f8e | 279 |