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);
63 list.push_back(AliHLTTPCDefinitions::fgkAlterClustersDataType);
66 AliHLTComponent* AliHLTTPCClusterDumpComponent::Spawn()
68 // see header file for class documentation
69 return new AliHLTTPCClusterDumpComponent;
72 int AliHLTTPCClusterDumpComponent::InitWriter()
74 // see header file for class documentation
78 int AliHLTTPCClusterDumpComponent::ScanArgument(int /*argc*/, const char** /*argv*/)
80 // see header file for class documentation
86 if (bMissingParam) iResult=-EPROTO;
87 else if (iResult>=0) iResult=i;
92 int AliHLTTPCClusterDumpComponent::CloseWriter()
94 // see header file for class documentation
98 int AliHLTTPCClusterDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
99 AliHLTComponentTriggerData& /*trigData*/ )
101 // see header file for class documentation
103 HLTDebug("Entering DumpEvent");
107 const AliHLTComponentBlockData* pDesc=NULL;
109 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
112 Int_t spacePointCounter=0;
114 for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
116 iResult=BuildFileName(evtData.fEventID, 0, pDesc->fDataType, 0, filename);
117 ios::openmode filemode=(ios::openmode)0;
118 if (fCurrentFileName.CompareTo(filename)==0) {
121 fCurrentFileName=filename;
125 ofstream dump(fCurrentFileName.Data(), filemode);
128 if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){continue;}
130 //if (dump.good() || 1) {//the || 1 is there since dump.good() will return false( EOF )
132 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) pDesc->fPtr;
133 Int_t nSpacepoints = (Int_t) clusterData->fSpacePointCnt;
134 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) &clusterData->fSpacePoints;
136 for(int i=0;i<nSpacepoints;i++){
137 UInt_t idCluster = clusters[i].fID;
138 Int_t slice = AliHLTTPCSpacePointData::GetSlice(idCluster);
139 Int_t patch = AliHLTTPCSpacePointData::GetPatch(idCluster);
142 dump << "ClusterNumber: " << spacePointCounter << endl;
143 dump << "Slice: " << slice << endl;
144 dump << "Partition: " << patch << endl;
145 dump << "[X,Y,Z]: [" << clusters[i].fX<<" , "<<clusters[i].fY<<" , "<<clusters[i].fZ <<"]"<< endl;
146 //Float_t xyz[3]={clusters[i].fX,clusters[i].fY,clusters[i].fZ};
147 //AliHLTTPCTransform::LocHLT2Raw(xyz,(Int_t)(clusters[i].fID/10),(Int_t)(clusters[i].fID%10));
148 //dump << "[R,P,T]: [" << xyz[0]<<" , "<<xyz[1]<<" , "<<xyz[2] <<"]"<< endl;
149 dump << "Total Charge: " << clusters[i].fCharge << endl;
150 dump << "Q Max: " << clusters[i].fQMax << endl;
155 HLTError("can not open file %s for writing", fCurrentFileName.Data());
162 for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkAlterClustersDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
164 iResult=BuildFileName(evtData.fEventID, 0, pDesc->fDataType, 0, filename);
165 ios::openmode filemode=(ios::openmode)0;
166 if (fCurrentFileName.CompareTo(filename)==0) {
169 fCurrentFileName=filename;
173 ofstream dump(fCurrentFileName.Data(), filemode);
176 if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkAlterClustersDataType){continue;}
178 //if (dump.good() || 1) {//the || 1 is there since dump.good() will return false( EOF )
180 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) pDesc->fPtr;
181 Int_t nSpacepoints = (Int_t) clusterData->fSpacePointCnt;
182 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) &clusterData->fSpacePoints;
184 for(int i=0;i<nSpacepoints;i++){
185 UInt_t idCluster = clusters[i].fID;
186 Int_t slice = AliHLTTPCSpacePointData::GetSlice(idCluster);
187 Int_t patch = AliHLTTPCSpacePointData::GetPatch(idCluster);
190 dump << "ClusterNumber: " << spacePointCounter << endl;
191 dump << "Slice: " << slice << endl;
192 dump << "Partition: " << patch << endl;
193 dump << "[X,Y,Z]: [" << clusters[i].fX<<" , "<<clusters[i].fY<<" , "<<clusters[i].fZ <<"]"<< endl;
194 //Float_t xyz[3]={clusters[i].fX,clusters[i].fY,clusters[i].fZ};
195 //AliHLTTPCTransform::LocHLT2Raw(xyz,(Int_t)(clusters[i].fID/10),(Int_t)(clusters[i].fID%10));
196 //dump << "[R,P,T]: [" << xyz[0]<<" , "<<xyz[1]<<" , "<<xyz[2] <<"]"<< endl;
197 dump << "Total Charge: " << clusters[i].fCharge << endl;
198 dump << "Q Max: " << clusters[i].fQMax << endl;
203 HLTError("can not open file %s for writing", fCurrentFileName.Data());