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()
41 // see header file for class documentation
43 // refer to README to build package
45 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
48 AliHLTTPCClusterDumpComponent::~AliHLTTPCClusterDumpComponent()
50 // see header file for class documentation
53 const char* AliHLTTPCClusterDumpComponent::GetComponentID()
55 // see header file for class documentation
56 return "TPCClusterDump";
59 void AliHLTTPCClusterDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
61 // see header file for class documentation
63 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
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 (i>=argc || (argument=argv[i]).IsNull()) continue;
89 if (argument.CompareTo("-directory-clusterdump")==0) {
90 if ((bMissingParam=(++i>=argc))) break;
95 if (argument.CompareTo("-slice")==0) {
96 if ((bMissingParam=(++i>=argc))) break;
103 HLTWarning("AliHLTTPCClusterDumpComponent does not have any arguments at this time");
107 int AliHLTTPCClusterDumpComponent::CloseWriter()
109 // see header file for class documentation
113 int AliHLTTPCClusterDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
114 const AliHLTComponentBlockData* /*blocks*/,
115 AliHLTComponentTriggerData& /*trigData*/ )
117 // see header file for class documentation
119 HLTDebug("Entering DumpEvent");
123 const AliHLTComponentBlockData* pDesc=NULL;
125 Int_t spacePointCounter=0;
127 //building the filename
129 if (!fDirectory.IsNull()) {
130 fCurrentFileName+=fDirectory;
132 fCurrentFileName+="ClusterDump";
133 fCurrentFileName+=Form("_RunNo-%d",GetRunNo());
135 fCurrentFileName+=Form("_Slice-%d", fSlice);
137 fCurrentFileName+=Form("_Event-%d", GetEventCount());
140 dump.open(fCurrentFileName.Data());
142 for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
143 HLTDebug("event %Lu block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, pDesc->fSize);
145 if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){continue;}
147 if (dump.good() || 1) {//the || 1 is there since dump.good() will return false( EOF )
149 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) pDesc->fPtr;
150 Int_t nSpacepoints = (Int_t) clusterData->fSpacePointCnt;
151 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) &clusterData->fSpacePoints;
153 for(int i=0;i<nSpacepoints;i++){
155 dump << "ClusterNumber: " << spacePointCounter << endl;
156 dump << "Slice: " << (Int_t)(clusters[i].fID/10) << endl;//quick fix to get the partiion and slice numbers to the clusterdump
157 dump << "Partition: " << (Int_t)(clusters[i].fID%10) << endl;//quick fix to get the partiion and slice numbers to the clusterdump
158 dump << "[X,Y,Z]: [" << clusters[i].fX<<" , "<<clusters[i].fY<<" , "<<clusters[i].fZ <<"]"<< endl;
159 Float_t xyz[3]={clusters[i].fX,clusters[i].fY,clusters[i].fZ};
160 AliHLTTPCTransform::LocHLT2Raw(xyz,(Int_t)(clusters[i].fID/10),(Int_t)(clusters[i].fID%10));
161 dump << "[R,P,T]: [" << xyz[0]<<" , "<<xyz[1]<<" , "<<xyz[2] <<"]"<< endl;
162 dump << "Total Charge: " << clusters[i].fCharge << endl;
163 dump << "Q Max: " << clusters[i].fMaxQ << endl;
169 HLTError("can not open file %s for writing", fCurrentFileName.Data());