]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCClusterDumpComponent.cxx
78463c05176df51bda73972f7a61810fcfc5f8a3
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterDumpComponent.cxx
1 // $Id$
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project        * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary Authors: Kenneth Aamodt <Kenneth.Aamodt@cern.ch>               *
7 //*                  for The ALICE HLT Project.                            *
8 //*                                                                        *
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 //**************************************************************************
17
18 /** @file   AliHLTTPCClusterDumpComponent.cxx
19     @author Kenneth Aamodt
20     @date   
21     @brief  Special file writer converting TPC clusters input to readable
22             ASCII format. 
23 */
24
25 #include <cassert>
26 #include "AliHLTTPCClusterDumpComponent.h"
27 #include "AliHLTTPCDefinitions.h"
28 #include "AliHLTTPCSpacePointData.h"
29 #include "AliHLTTPCClusterDataFormat.h"
30
31 /** ROOT macro for the implementation of ROOT specific class methods */
32 ClassImp(AliHLTTPCClusterDumpComponent)
33
34   AliHLTTPCClusterDumpComponent::AliHLTTPCClusterDumpComponent()
35     :
36     AliHLTFileWriter(),
37     fDirectory("")
38 {
39   // see header file for class documentation
40   // or
41   // refer to README to build package
42   // or
43   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
44 }
45
46 AliHLTTPCClusterDumpComponent::~AliHLTTPCClusterDumpComponent()
47 {
48   // see header file for class documentation
49 }
50
51 const char* AliHLTTPCClusterDumpComponent::GetComponentID()
52 {
53   // see header file for class documentation
54   return "TPCClusterDump";
55 }
56
57 void AliHLTTPCClusterDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
58 {
59   // see header file for class documentation
60   list.clear();
61   list.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
62 }
63
64 AliHLTComponent* AliHLTTPCClusterDumpComponent::Spawn()
65 {
66   // see header file for class documentation
67   return new AliHLTTPCClusterDumpComponent;
68 }
69
70 int AliHLTTPCClusterDumpComponent::InitWriter()
71 {
72   // see header file for class documentation
73   return 0;
74 }
75
76 int AliHLTTPCClusterDumpComponent::ScanArgument(int argc, const char** argv)
77 {
78   // see header file for class documentation
79
80   TString argument="";
81   bool bMissingParam=0;
82   int i=0;
83   do {
84     if (i>=argc || (argument=argv[i]).IsNull()) continue;
85     
86     // -directory
87     if (argument.CompareTo("-directory")==0) {
88       if ((bMissingParam=(++i>=argc))) break;
89       fDirectory=argv[i];
90       break;
91     }
92   }while(0);
93
94   HLTWarning("AliHLTTPCClusterDumpComponent does not have any arguments at this time");
95   return 0;
96 }
97
98 int AliHLTTPCClusterDumpComponent::CloseWriter()
99 {
100   // see header file for class documentation
101   return 0;
102 }
103
104 int AliHLTTPCClusterDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
105                                               const AliHLTComponentBlockData* /*blocks*/, 
106                                               AliHLTComponentTriggerData& /*trigData*/ )
107 {
108   // see header file for class documentation
109
110   HLTDebug("Entering DumpEvent");
111
112   int iResult=0;
113   int blockno=0;
114   const AliHLTComponentBlockData* pDesc=NULL;
115
116   Int_t spacePointCounter=0;
117
118   //building the filename
119   fCurrentFileName="";
120   ios::openmode filemode=(ios::openmode)0;
121   if (!fDirectory.IsNull()) {
122     fCurrentFileName+=fDirectory;
123   }
124   fCurrentFileName+="TPCClusterDump_Event";
125   fCurrentFileName+=Form("_%d", GetEventCount());
126   ofstream dump(fCurrentFileName.Data(), filemode);
127
128   for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
129     HLTDebug("event %Lu block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, pDesc->fSize);
130
131     if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){continue;}
132  
133      if (dump.good()) {
134        iResult=1;
135        const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) pDesc->fPtr;
136        Int_t nSpacepoints = (Int_t) clusterData->fSpacePointCnt;
137        AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) &clusterData->fSpacePoints;
138        
139        for(int i=0;i<nSpacepoints;i++){
140          dump << "" << endl;
141          dump << "ClusterNumber: " << spacePointCounter << endl;
142          dump << "Slice:         " << clusters[i].fUsed    << endl;//quick fix to get the partiion and slice numbers to the clusterdump
143          dump << "Partition:     " << clusters[i].fTrackN  << endl;//quick fix to get the partiion and slice numbers to the clusterdump
144          dump << "X:             " << clusters[i].fX       << endl;
145          dump << "Y:             " << clusters[i].fY       << endl;
146          dump << "Z:             " << clusters[i].fZ       << endl;
147          dump << "ID:            " << clusters[i].fID      << endl;
148          dump << "Pad row:       " << clusters[i].fPadRow << endl;
149          dump << "fSigmaY2:      " << clusters[i].fSigmaY2 << endl;
150          dump << "fSigmaZ2:      " << clusters[i].fSigmaZ2 << endl;
151          dump << "Charge:        " << clusters[i].fCharge << endl;
152          dump << "Q Max:         " << clusters[i].fMaxQ << endl;
153          spacePointCounter++;
154        }
155        
156      }
157      else {
158        HLTError("can not open file %s for writing", fCurrentFileName.Data());
159        iResult=-EBADF;
160      }
161
162     dump.close();
163   }
164   return iResult;
165 }