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
31 #include "AliHLTTPCClusterConverterComponent.h"
32 #include "AliHLTTPCOfflineCluster.h"
33 #include "AliTPCclusterMI.h"
35 #include "AliHLTTPCClusterDataFormat.h"
37 #include "AliHLTTPCTrackSegmentData.h"
38 #include "AliHLTTPCTrackletDataFormat.h"
40 #include "AliCDBEntry.h"
41 #include "AliCDBManager.h"
43 #include "AliHLTTPCMemHandler.h"
44 #include "AliHLTTPCDefinitions.h"
47 #include "TObjString.h"
48 #include "TObjArray.h"
49 //#include "AliHLTTPC.h"
55 /** ROOT macro for the implementation of ROOT specific class methods */
56 ClassImp(AliHLTTPCClusterConverterComponent)
58 AliHLTTPCClusterConverterComponent::AliHLTTPCClusterConverterComponent()
63 { // see header file for class documentation
65 // refer to README to build package
67 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70 AliHLTTPCClusterConverterComponent::~AliHLTTPCClusterConverterComponent(){
71 // see header file for class documentation
74 // Public functions to implement AliHLTComponent's interface.
75 // These functions are required for the registration process
77 const char* AliHLTTPCClusterConverterComponent::GetComponentID(){
78 // see header file for class documentation
79 return "TPCClusterConverter";
82 void AliHLTTPCClusterConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
83 // see header file for class documentation
86 list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType);
89 AliHLTComponentDataType AliHLTTPCClusterConverterComponent::GetOutputDataType(){
90 // see header file for class documentation
91 return kAliHLTDataTypeTObject;
94 int AliHLTTPCClusterConverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
95 // see header file for class documentation
98 tgtList.push_back(kAliHLTDataTypeTObject);
99 return tgtList.size();
102 void AliHLTTPCClusterConverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
103 // see header file for class documentation
109 AliHLTComponent* AliHLTTPCClusterConverterComponent::Spawn(){
110 // see header file for class documentation
111 return new AliHLTTPCClusterConverterComponent;
115 int AliHLTTPCClusterConverterComponent::DoInit( int argc, const char** argv ){
116 // see header file for class documentation
122 TString configuration = "";
123 TString argument = "";
125 for (int i=0; i<argc && iResult>=0; i++) {
127 if (!configuration.IsNull()) configuration+=" ";
128 configuration+=argument;
131 if (!configuration.IsNull()) {
132 iResult=Configure(configuration.Data());
134 iResult=Reconfigure(NULL, NULL);
138 // while ( i < argc ) {
139 // if (!strcmp( argv[i], "-apply-noisemap")) {
140 // fApplyNoiseMap = strtoul( argv[i+1], &cpErr ,0);
143 // HLTError("Cannot convert apply-noisemap specifier '%s'.", argv[i+1]);
150 // if (!strcmp( argv[i], "-plot-side-a")) {
151 // fPlotSideA = strtoul( argv[i+1], &cpErr ,0);
154 // HLTError("Cannot convert plot-side-a specifier '%s'.", argv[i+1]);
161 // if (!strcmp( argv[i], "-plot-side-c")) {
162 // fPlotSideC = strtoul( argv[i+1], &cpErr ,0);
165 // HLTError("Cannot convert plot-side-c specifier '%s'.", argv[i+1]);
172 // if (!strcmp( argv[i], "-reset-histograms")) {
173 // fResetHistograms = strtoul( argv[i+1], &cpErr ,0);
176 // HLTError("Cannot convert reset-histograms specifier '%s'.", argv[i+1]);
183 // Logging(kHLTLogError, "HLT::TPCNoiseMap::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
191 int AliHLTTPCClusterConverterComponent::DoDeinit(){
192 // see header file for class documentation
196 int AliHLTTPCClusterConverterComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/){
197 // see header file for class documentation
199 //Logging(kHLTLogDebug, "HLT::TPCClusterConverter::DoEvent", "DoEvent", "DoEvent()");
200 HLTInfo("--- Entering DoEvent() in TPCClusterConverter ---");
202 if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;
204 Int_t numOfTotalTracks = 0;
205 Int_t numOfTotalSpacePoints = 0 ;
206 const AliHLTComponentBlockData *iter = NULL;
209 // ========== LOOP OVER CLUSTER DATA =====================//
211 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
212 //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
213 //AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
215 const AliHLTTPCClusterData *clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
216 numOfTotalSpacePoints+= (Int_t)clusterData->fSpacePointCnt;
218 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
220 for(Int_t i=0; i<(Int_t)clusterData->fSpacePointCnt; i++){ fClusters.push_back(clusters[i]); }
226 // // ========== LOOP OVER TRACKS =====================//
228 // for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); iter != NULL; iter = GetNextInputBlock()){
229 // AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
230 // AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
232 // const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*)iter->fPtr;
233 // numOfTotalTracks += (Int_t)trackData->fTrackletCnt;
235 // AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*)trackData->fTracklets;
237 // for(int i=0;i<(Int_t)trackData->fTrackletCnt;i++){ fTracks.push_back(tracks[i]); }
242 // ========== LOOP OVER TRACK SEGMENTS =====================//
244 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); iter != NULL; iter = GetNextInputBlock()){
246 HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
247 evtData.fEventID, evtData.fEventID,
248 DataType2Text(iter->fDataType).c_str(),
249 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC).c_str());
251 if(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType && GetEventCount()<2){
252 HLTWarning("data type %s is depricated, use %s (fgkTrackSegmentsDataType)!",
253 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType).c_str(),
254 DataType2Text(AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC).c_str());
257 if(iter->fDataType != (AliHLTTPCDefinitions::fgkTrackSegmentsDataType | kAliHLTDataOriginTPC)) continue;
259 if(iter->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){
260 HLTDebug("Data block type is not of type AliHLTTPCDefinitions::fgkTrackSegmentsDataType"); continue;
263 const AliHLTTPCTrackletData *trackData = (const AliHLTTPCTrackletData*)iter->fPtr;
264 numOfTotalTracks += (Int_t)trackData->fTrackletCnt;
266 AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*)trackData->fTracklets;
267 for(Int_t i=0; i<(Int_t)trackData->fTrackletCnt; i++){ fTracks.push_back(tracks[i]); }
269 } // end of loop over track segments
273 // ========== TRIPLE LOOP FOR SETTING THE fUsed CLUSTERS =====================//
275 Int_t nClustersUsed = 0;
276 for(Int_t tr=0; tr<numOfTotalTracks; tr++){
277 Int_t nHits = fTracks[tr].fNPoints;
278 UInt_t *hitnum = fTracks[tr].fPointIDs;
279 //HLTInfo("Hits %d ", nHits);
281 for(Int_t h=0; h<nHits; h++){
282 UInt_t idTrack = hitnum[h];
283 Int_t sliceTrack = AliHLTTPCSpacePointData::GetSlice(idTrack);
284 Int_t partitionTrack = AliHLTTPCSpacePointData::GetPatch(idTrack);
285 UInt_t posTrack = AliHLTTPCSpacePointData::GetNumber(idTrack);
288 for(Int_t cl=0; cl<numOfTotalSpacePoints; cl++){
289 UInt_t idCluster = fClusters[cl].fID;
290 Int_t sliceCluster = AliHLTTPCSpacePointData::GetSlice(idCluster);
291 Int_t partitionCluster = AliHLTTPCSpacePointData::GetPatch(idCluster);
292 UInt_t posCluster = AliHLTTPCSpacePointData::GetNumber(idCluster);
295 if(sliceCluster==sliceTrack && partitionCluster==partitionTrack && posCluster==posTrack){
296 fClusters[cl].fUsed = kTRUE;
297 fClusters[cl].fTrackN = tr;
299 fOffArray->Add(new AliHLTTPCOfflineCluster(fClusters[cl]));
301 } // end for clusters
302 PushBack((TObject*)fOffArray, kAliHLTDataTypeTObject, 0);
304 } // end for loop over track segments
308 int AliHLTTPCClusterConverterComponent::Configure(const char* arguments){
309 // see header file for class documentation
312 if (!arguments) return iResult;
313 HLTInfo("parsing configuration string \'%s\'", arguments);
315 TString allArgs=arguments;
319 TObjArray* pTokens = allArgs.Tokenize(" ");
321 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
322 argument=((TObjString*)pTokens->At(i))->GetString();
323 if (argument.IsNull()) continue;
325 if (argument.CompareTo("-apply-noisemap")==0) {
326 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
327 HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
330 else if (argument.CompareTo("-plot-side-c")==0) {
331 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
332 HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
335 else if (argument.CompareTo("-plot-side-a")==0) {
336 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
337 HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
341 HLTError("unknown argument %s", argument.Data());
352 HLTError("missing parameter for argument %s", argument.Data());
358 int AliHLTTPCClusterConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId){
359 // see header file for class documentation
362 const char* path="HLT/ConfigTPC/ClusterConverterComponent";
363 const char* defaultNotify="";
366 defaultNotify=" (default)";
369 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
370 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
372 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
374 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
375 iResult=Configure(pString->GetString().Data());
377 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
380 HLTError("can not fetch object \"%s\" from CDB", path);