2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Kenneth Aamodt <Kenneth.Aamodt@cern.ch> *
7 //* for The ALICE HLT Project. *
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 //**************************************************************************
18 /** @file AliHLTTPCClusterDumpComponent.cxx
19 @author Kenneth Aamodt
21 @brief Special file writer converting TPC clusters input to readable
26 #include "AliHLTTPCClusterDumpComponent.h"
27 #include "AliHLTTPCDefinitions.h"
28 #include "AliHLTTPCSpacePointData.h"
29 #include "AliHLTTPCClusterDataFormat.h"
30 #include "AliHLTTPCTransform.h"
32 /** ROOT macro for the implementation of ROOT specific class methods */
33 ClassImp(AliHLTTPCClusterDumpComponent)
35 AliHLTTPCClusterDumpComponent::AliHLTTPCClusterDumpComponent()
40 // see header file for class documentation
42 // refer to README to build package
44 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
47 AliHLTTPCClusterDumpComponent::~AliHLTTPCClusterDumpComponent()
49 // see header file for class documentation
52 const char* AliHLTTPCClusterDumpComponent::GetComponentID()
54 // see header file for class documentation
55 return "TPCClusterDump";
58 void AliHLTTPCClusterDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
60 // see header file for class documentation
62 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
65 AliHLTComponent* AliHLTTPCClusterDumpComponent::Spawn()
67 // see header file for class documentation
68 return new AliHLTTPCClusterDumpComponent;
71 int AliHLTTPCClusterDumpComponent::InitWriter()
73 // see header file for class documentation
77 int AliHLTTPCClusterDumpComponent::ScanArgument(int argc, const char** argv)
79 // see header file for class documentation
85 if (bMissingParam) iResult=-EPROTO;
86 else if (iResult>=0) iResult=i;
91 int AliHLTTPCClusterDumpComponent::CloseWriter()
93 // see header file for class documentation
97 int AliHLTTPCClusterDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
98 AliHLTComponentTriggerData& /*trigData*/ )
100 // see header file for class documentation
102 HLTDebug("Entering DumpEvent");
106 const AliHLTComponentBlockData* pDesc=NULL;
108 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
111 Int_t spacePointCounter=0;
113 for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
115 iResult=BuildFileName(evtData.fEventID, 0, pDesc->fDataType, 0, filename);
116 ios::openmode filemode=(ios::openmode)0;
117 if (fCurrentFileName.CompareTo(filename)==0) {
120 fCurrentFileName=filename;
124 ofstream dump(fCurrentFileName.Data(), filemode);
127 if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){continue;}
129 //if (dump.good() || 1) {//the || 1 is there since dump.good() will return false( EOF )
131 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) pDesc->fPtr;
132 Int_t nSpacepoints = (Int_t) clusterData->fSpacePointCnt;
133 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) &clusterData->fSpacePoints;
135 for(int i=0;i<nSpacepoints;i++){
136 UInt_t idCluster = clusters[i].fID;
137 Int_t slice = (idCluster>>25) & 0x7f;
138 Int_t patch = (idCluster>>22) & 0x7;
141 dump << "ClusterNumber: " << spacePointCounter << endl;
142 dump << "Slice: " << slice << endl;
143 dump << "Partition: " << patch << endl;
144 dump << "[X,Y,Z]: [" << clusters[i].fX<<" , "<<clusters[i].fY<<" , "<<clusters[i].fZ <<"]"<< endl;
145 Float_t xyz[3]={clusters[i].fX,clusters[i].fY,clusters[i].fZ};
146 AliHLTTPCTransform::LocHLT2Raw(xyz,(Int_t)(clusters[i].fID/10),(Int_t)(clusters[i].fID%10));
147 dump << "[R,P,T]: [" << xyz[0]<<" , "<<xyz[1]<<" , "<<xyz[2] <<"]"<< endl;
148 dump << "Total Charge: " << clusters[i].fCharge << endl;
149 dump << "Q Max: " << clusters[i].fQMax << endl;
154 HLTError("can not open file %s for writing", fCurrentFileName.Data());