]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TRD/AliHLTTRDEsdWriterComponent.cxx
Adding new component for TRD monitoring (Theodor)
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDEsdWriterComponent.cxx
CommitLineData
808618f5 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"
dc2e6604 28#include "AliHLTTRDUtils.h" \
808618f5 29
30/** global instance for component registration */
31AliHLTTRDEsdWriterComponent gTRDEsdWriter;
32
33/** ROOT macro for the implementation of ROOT specific class methods */
34ClassImp(AliHLTTRDEsdWriterComponent)
35
36AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent()
37 :
d76bc02a 38 AliHLTRootFileWriterComponent(),
808618f5 39 fTree(NULL),
dc2e6604 40 fOutputPercentage(100),
808618f5 41 fESD(NULL)
42{
43 // see header file for class documentation
44 // or
45 // refer to README to build package
46 // or
47 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
48}
49
50AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent(const AliHLTTRDEsdWriterComponent&)
51 :
d76bc02a 52 AliHLTRootFileWriterComponent(),
808618f5 53 fTree(NULL),
dc2e6604 54 fOutputPercentage(100),
808618f5 55 fESD(NULL)
56{
57}
58
59AliHLTTRDEsdWriterComponent& AliHLTTRDEsdWriterComponent::operator=(const AliHLTTRDEsdWriterComponent&)
60{
61 return *this;
62}
63
64void AliHLTTRDEsdWriterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
65{
66 // Get the list of input data
67 list.clear(); // We do not have any requirements for our input data type(s).
68 list.push_back( AliHLTTRDDefinitions::fgkTRDSATracksDataType );
69}
70
71AliHLTTRDEsdWriterComponent::~AliHLTTRDEsdWriterComponent()
72{
73 // see header file for class documentation
74}
75
76int AliHLTTRDEsdWriterComponent::InitWriter()
77{
78 // see header file for class documentation
79 int iResult=0;
80 fESD = new AliESDEvent;
81 if (fESD) {
82 fESD->CreateStdContent();
83 fTree = new TTree("esdTree", "Tree with HLT ESD objects");
84 if (fTree) {
85 fESD->WriteToTree(fTree);
86 }
87 }
88 if (fTree==NULL) {
89 iResult=-ENOMEM;
90 }
91 return iResult;
92}
93
94int AliHLTTRDEsdWriterComponent::CloseWriter()
95{
96 // see header file for class documentation
97 int iResult=0;
98 if (fTree) {
99 WriteObject(kAliHLTVoidEventID, fTree);
100 TTree* pTree=fTree;
101 fTree=NULL;
102 delete pTree;
103 } else {
104 HLTWarning("not initialized");
105 }
106 iResult=AliHLTRootFileWriterComponent::CloseWriter();
107 return iResult;
108}
109
dc2e6604 110int AliHLTTRDEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
111 const AliHLTComponentBlockData* blocks,
112 AliHLTComponentTriggerData& /*trigData*/ )
808618f5 113{
dc2e6604 114int result=0;
808618f5 115
dc2e6604 116for ( unsigned long iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ )
808618f5 117 {
dc2e6604 118 // HLTDebug("i am a debug message"); // y does it not print out debug messages???
119 /*HLTInfo("Block # %i/%i; Event 0x%08LX (%Lu)",
120 iBlock, evtData.fBlockCnt,
121 evtData.fEventID, evtData.fEventID);*/
122
123
124 TClonesArray* tracksArray = NULL;
125 const AliHLTComponentBlockData &block = blocks[iBlock];
126 tracksArray = new TClonesArray("AliTRDtrackV1");
127
128 //HLTInfo("BLOCK fPtr 0x%x, fOffset %i, fSize %i, fSpec 0x%x, fDataType %s", block.fPtr, block.fOffset, block.fSize, block.fSpecification, DataType2Text(block.fDataType).c_str()); //HLTInfo instead of HLTDebug, because debug gives no output... -> strange
129
130 AliHLTTRDUtils::ReadTracks(tracksArray, block.fPtr, block.fSize);
131
132 // give out number of tracklets in tracksArray
133 Int_t nbEntries = tracksArray->GetEntries();
134 HLTInfo(" %i TRDtracks in tracksArray", nbEntries);
135
808618f5 136 }
808618f5 137
dc2e6604 138 /* AliESDtrack* track = (AliESDtrack *)tobjin;
808618f5 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();
dc2e6604 165 fESD->Reset(); */
808618f5 166
dc2e6604 167 return result;
808618f5 168}
169
dc2e6604 170// int 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// }
176
177int AliHLTTRDEsdWriterComponent::DoEvent( const AliHLTComponent_EventData& /*evtData*/,
178 const AliHLTComponent_BlockData* /*blocks*/,
179 AliHLTComponent_TriggerData& /*trigData*/,
180 AliHLTUInt8_t* /*outputPtr*/,
181 AliHLTUInt32_t& /*size*/,
182 vector<AliHLTComponent_BlockData>& /*outputBlocks*/)
808618f5 183{
dc2e6604 184HLTDebug("ignor me");
185return 0;
186
187}
188
189Int_t AliHLTTRDEsdWriterComponent::ScanArgument( int argc, const char** argv )
190{
191 // perform initialization. We check whether our relative output size is specified in the arguments.
192 int i = 0;
193 char* cpErr;
194 HLTDebug("argv[%d] == %s", i, argv[i] );
195 if ( !strcmp( argv[i], "output_percentage" ) )
196 {
197 if ( i+1>=argc )
198 {
199 HLTError("Missing output_percentage parameter");
200 return ENOTSUP;
201 }
202 HLTDebug("argv[%d+1] == %s", i, argv[i+1] );
203 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
204 if ( *cpErr )
205 {
206 HLTError("Cannot convert output_percentage parameter '%s'", argv[i+1] );
207 return EINVAL;
208 }
209 HLTInfo("Output percentage set to %lu %%", fOutputPercentage );
210
211 }
212 //AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
213
214 return 0;
215}
216
217
218void AliHLTTRDEsdWriterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
219{
220 // Get the output data size
221 constBase = 0;
222 inputMultiplier = ((double)fOutputPercentage)/100.0;
808618f5 223}