3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTTPCClusterConverterComponent.cxx
20 @author Kalliopi Kanaki
22 @brief The TPC cluster format conversion component.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
35 #include "AliHLTTPCClusterConverterComponent.h"
36 #include "AliHLTTPCOfflineCluster.h"
37 #include "AliTPCclusterMI.h"
39 #include "AliHLTTPCClusterDataFormat.h"
41 #include "AliHLTTPCTrackSegmentData.h"
42 #include "AliHLTTPCTrackletDataFormat.h"
44 #include "AliCDBEntry.h"
45 #include "AliCDBManager.h"
47 #include "AliHLTTPCMemHandler.h"
48 #include "AliHLTTPCDefinitions.h"
51 #include "TObjString.h"
52 #include "TObjArray.h"
53 //#include "AliHLTTPC.h"
57 /** ROOT macro for the implementation of ROOT specific class methods */
58 ClassImp(AliHLTTPCClusterConverterComponent)
60 AliHLTTPCClusterConverterComponent::AliHLTTPCClusterConverterComponent()
65 { // see header file for class documentation
67 // refer to README to build package
69 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
72 AliHLTTPCClusterConverterComponent::~AliHLTTPCClusterConverterComponent(){
73 // see header file for class documentation
76 // Public functions to implement AliHLTComponent's interface.
77 // These functions are required for the registration process
79 const char* AliHLTTPCClusterConverterComponent::GetComponentID(){
80 // see header file for class documentation
81 return "TPCClusterConverter";
84 void AliHLTTPCClusterConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
85 // see header file for class documentation
88 list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType);
91 AliHLTComponentDataType AliHLTTPCClusterConverterComponent::GetOutputDataType(){
92 // see header file for class documentation
93 return kAliHLTDataTypeTObject;
96 int AliHLTTPCClusterConverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
97 // see header file for class documentation
100 tgtList.push_back(kAliHLTDataTypeTObject);
101 return tgtList.size();
104 void AliHLTTPCClusterConverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
105 // see header file for class documentation
111 AliHLTComponent* AliHLTTPCClusterConverterComponent::Spawn(){
112 // see header file for class documentation
113 return new AliHLTTPCClusterConverterComponent;
117 int AliHLTTPCClusterConverterComponent::DoInit( int argc, const char** argv ){
118 // see header file for class documentation
124 TString configuration = "";
125 TString argument = "";
127 for (int i=0; i<argc && iResult>=0; i++) {
129 if (!configuration.IsNull()) configuration+=" ";
130 configuration+=argument;
133 if (!configuration.IsNull()) {
134 iResult=Configure(configuration.Data());
136 iResult=Reconfigure(NULL, NULL);
140 // while ( i < argc ) {
141 // if (!strcmp( argv[i], "-apply-noisemap")) {
142 // fApplyNoiseMap = strtoul( argv[i+1], &cpErr ,0);
145 // HLTError("Cannot convert apply-noisemap specifier '%s'.", argv[i+1]);
152 // if (!strcmp( argv[i], "-plot-side-a")) {
153 // fPlotSideA = strtoul( argv[i+1], &cpErr ,0);
156 // HLTError("Cannot convert plot-side-a specifier '%s'.", argv[i+1]);
163 // if (!strcmp( argv[i], "-plot-side-c")) {
164 // fPlotSideC = strtoul( argv[i+1], &cpErr ,0);
167 // HLTError("Cannot convert plot-side-c specifier '%s'.", argv[i+1]);
174 // if (!strcmp( argv[i], "-reset-histograms")) {
175 // fResetHistograms = strtoul( argv[i+1], &cpErr ,0);
178 // HLTError("Cannot convert reset-histograms specifier '%s'.", argv[i+1]);
185 // Logging(kHLTLogError, "HLT::TPCNoiseMap::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
193 int AliHLTTPCClusterConverterComponent::DoDeinit(){
194 // see header file for class documentation
198 int AliHLTTPCClusterConverterComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/){
199 // see header file for class documentation
201 //Logging(kHLTLogDebug, "HLT::TPCClusterConverter::DoEvent", "DoEvent", "DoEvent()");
202 HLTInfo("--- Entering DoEvent() in TPCClusterConverter ---");
204 if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;
206 Int_t numOfTotalTracks = 0;
207 Int_t numOfTotalSpacePoints = 0 ;
208 const AliHLTComponentBlockData *iter = NULL;
211 // ========== LOOP OVER CLUSTER DATA =====================//
213 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
214 //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
215 //AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
217 const AliHLTTPCClusterData *clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
218 numOfTotalSpacePoints+= (Int_t)clusterData->fSpacePointCnt;
220 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
222 for(Int_t i=0; i<(Int_t)clusterData->fSpacePointCnt; i++){ fClusters.push_back(clusters[i]); }
228 // // ========== LOOP OVER TRACKS =====================//
230 // for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock()){
231 // AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
232 // AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
234 // const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*)iter->fPtr;
235 // numOfTotalTracks += (Int_t)trackData->fTrackletCnt;
237 // AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*)trackData->fTracklets;
239 // for(int i=0;i<(Int_t)trackData->fTrackletCnt;i++){ fTracks.push_back(tracks[i]); }
244 // ========== LOOP OVER TRACK SEGMENTS =====================//
246 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock()){
248 HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
249 evtData.fEventID, evtData.fEventID,
250 DataType2Text(iter->fDataType).c_str(),
251 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC).c_str());
253 if(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType && GetEventCount()<2){
254 HLTWarning("data type %s is depricated, use %s (fgkTrackSegmentsDataType)!",
255 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType).c_str(),
256 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC).c_str());
259 if(iter->fDataType != (AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC)) continue;
261 if(iter->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){
262 HLTDebug("Data block type is not of type AliHLTTPCDefinitions::fgkTrackSegmentsDataType"); continue;
265 const AliHLTTPCTrackletData *trackData = (const AliHLTTPCTrackletData*)iter->fPtr;
266 numOfTotalTracks += (Int_t)trackData->fTrackletCnt;
268 AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*)trackData->fTracklets;
269 for(Int_t i=0; i<(Int_t)trackData->fTrackletCnt; i++){ fTracks.push_back(tracks[i]); }
271 } // end of loop over track segments
275 // ========== TRIPLE LOOP FOR SETTING THE fUsed CLUSTERS =====================//
277 Int_t nClustersUsed = 0;
278 for(Int_t tr=0; tr<numOfTotalTracks; tr++){
279 Int_t nHits = fTracks[tr].fNPoints;
280 UInt_t *hitnum = fTracks[tr].fPointIDs;
281 //HLTInfo("Hits %d ", nHits);
283 for(Int_t h=0; h<nHits; h++){
284 UInt_t idTrack = hitnum[h];
285 Int_t sliceTrack = AliHLTTPCSpacePointData::GetSlice(idTrack);
286 Int_t partitionTrack = AliHLTTPCSpacePointData::GetPatch(idTrack);
287 UInt_t posTrack = AliHLTTPCSpacePointData::GetNumber(idTrack);
290 for(Int_t cl=0; cl<numOfTotalSpacePoints; cl++){
291 UInt_t idCluster = fClusters[cl].fID;
292 Int_t sliceCluster = AliHLTTPCSpacePointData::GetSlice(idCluster);
293 Int_t partitionCluster = AliHLTTPCSpacePointData::GetPatch(idCluster);
294 UInt_t posCluster = AliHLTTPCSpacePointData::GetNumber(idCluster);
297 if(sliceCluster==sliceTrack && partitionCluster==partitionTrack && posCluster==posTrack){
298 fClusters[cl].fUsed = kTRUE;
299 fClusters[cl].fTrackN = tr;
301 fOffArray->Add(new AliHLTTPCOfflineCluster(fClusters[cl]));
303 } // end for clusters
304 PushBack((TObject*)fOffArray, kAliHLTDataTypeTObject, 0);
306 } // end for loop over track segments
310 int AliHLTTPCClusterConverterComponent::Configure(const char* arguments){
311 // see header file for class documentation
314 if (!arguments) return iResult;
315 HLTInfo("parsing configuration string \'%s\'", arguments);
317 TString allArgs=arguments;
321 TObjArray* pTokens = allArgs.Tokenize(" ");
323 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
324 argument=((TObjString*)pTokens->At(i))->GetString();
325 if (argument.IsNull()) continue;
327 if (argument.CompareTo("-apply-noisemap")==0) {
328 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
329 HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
332 else if (argument.CompareTo("-plot-side-c")==0) {
333 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
334 HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
337 else if (argument.CompareTo("-plot-side-a")==0) {
338 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
339 HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
343 HLTError("unknown argument %s", argument.Data());
354 HLTError("missing parameter for argument %s", argument.Data());
360 int AliHLTTPCClusterConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId){
361 // see header file for class documentation
364 const char* path="HLT/ConfigTPC/ClusterConverterComponent";
365 const char* defaultNotify="";
368 defaultNotify=" (default)";
371 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
372 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
374 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
376 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
377 iResult=Configure(pString->GetString().Data());
379 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
382 HLTError("can not fetch object \"%s\" from CDB", path);