]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/TRD/AliHLTTRDEsdWriterComponent.cxx
AliTRDtrackerHLT removed as obsolete. All tracking done with offline code. New AliHLT...
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDEsdWriterComponent.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
6 * for The ALICE HLT Project. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/** @file AliHLTTRDEsdWriterComponent.cxx
18 @author Mateusz Ploskon
19 @date
20 @brief Writer component to store tracks of the HLT TRD
21
22 */
23#include "AliHLTTRDEsdWriterComponent.h"
24#include "AliESDEvent.h"
25#include "AliESDtrack.h"
26#include "TTree.h"
27#include "AliHLTTRDDefinitions.h"
28
29/** global instance for component registration */
30AliHLTTRDEsdWriterComponent gTRDEsdWriter;
31
32/** ROOT macro for the implementation of ROOT specific class methods */
33ClassImp(AliHLTTRDEsdWriterComponent)
34
35AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent()
36 :
37 fTree(NULL),
38 fESD(NULL)
39{
40 // see header file for class documentation
41 // or
42 // refer to README to build package
43 // or
44 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
45}
46
47AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent(const AliHLTTRDEsdWriterComponent&)
48 :
49 fTree(NULL),
50 fESD(NULL)
51{
52}
53
54AliHLTTRDEsdWriterComponent& AliHLTTRDEsdWriterComponent::operator=(const AliHLTTRDEsdWriterComponent&)
55{
56 return *this;
57}
58
59void AliHLTTRDEsdWriterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
60{
61 // Get the list of input data
62 list.clear(); // We do not have any requirements for our input data type(s).
63 list.push_back( AliHLTTRDDefinitions::fgkTRDSATracksDataType );
64}
65
66AliHLTTRDEsdWriterComponent::~AliHLTTRDEsdWriterComponent()
67{
68 // see header file for class documentation
69}
70
71int AliHLTTRDEsdWriterComponent::InitWriter()
72{
73 // see header file for class documentation
74 int iResult=0;
75 fESD = new AliESDEvent;
76 if (fESD) {
77 fESD->CreateStdContent();
78 fTree = new TTree("esdTree", "Tree with HLT ESD objects");
79 if (fTree) {
80 fESD->WriteToTree(fTree);
81 }
82 }
83 if (fTree==NULL) {
84 iResult=-ENOMEM;
85 }
86 return iResult;
87}
88
89int AliHLTTRDEsdWriterComponent::CloseWriter()
90{
91 // see header file for class documentation
92 int iResult=0;
93 if (fTree) {
94 WriteObject(kAliHLTVoidEventID, fTree);
95 TTree* pTree=fTree;
96 fTree=NULL;
97 delete pTree;
98 } else {
99 HLTWarning("not initialized");
100 }
101 iResult=AliHLTRootFileWriterComponent::CloseWriter();
102 return iResult;
103}
104
105int AliHLTTRDEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
106 const AliHLTComponentBlockData* blocks,
107 AliHLTComponentTriggerData& trigData )
108{
109 // see header file for class documentation
110 int iResult=0;
111 TTree* pTree=fTree;
112
113 AliHLTUInt32_t fDblock_Specification = 0;
114
115 //implement a usage of the following
116 // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
117 // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
118 // void *triggerData = trigData.fData;
119 Logging( kHLTLogDebug, "HLT::TRDEsdWriter::DumpEvent", "Trigger data received",
120 "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
121
122 //AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkTRDSAEsdDataType );
123 AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkTRDSATracksDataType );
124 if (dblock != 0)
125 {
126 fDblock_Specification = dblock->fSpecification;
127 }
128 else
129 {
130 Logging( kHLTLogWarning, "HLT::TRDEsdWriter::DumpEvent", "DATAIN", "First Input Block not found! 0x%x", dblock);
131 return -1;
132 }
133
134 int ibForce = 1;
135 TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkTRDSATracksDataType, "AliESDtrack", ibForce);
136 Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "1stBLOCK", "Pointer = 0x%x", tobjin);
137
138 AliESDtrack* track = (AliESDtrack *)tobjin;
139 if (!track)
140 {
141 Logging( kHLTLogWarning, "HLT::TRDEsdWriter::DumpEvent", "DATAIN", "First Input Block not a ESDtrack! 0x%x", tobjin);
142 return -1;
143 }
144
145 Int_t nTracks = 0;
146 while (tobjin != 0)
147 {
148 if (track != 0)
149 {
150 //Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "Track found", "0x%x", track);
151 Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "DONE", "Track %d 0x%x Pt %1.2f", nTracks, track, track->Pt());
152 fESD->AddTrack(track);
153 nTracks++;
154 }
155
156 track = 0;
157 tobjin = 0;
158 tobjin = (TObject *)GetNextInputObject( ibForce );
159 //Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "nextBLOCK", "Pointer = 0x%x", tobjin);
160 track = (AliESDtrack *)tobjin;
161 }
162
163 Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "Fill", "Ntracks: %d", nTracks);
164 pTree->Fill();
165 fESD->Reset();
166
167 return iResult;
168}
169
170int AliHLTTRDEsdWriterComponent::ScanArgument(int argc, const char** argv)
171{
172 // see header file for class documentation
173 int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
174 return iResult;
175}