1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
6 * for The ALICE HLT Project. *
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 **************************************************************************/
17 /** @file AliHLTTRDEsdWriterComponent.cxx
18 @author Mateusz Ploskon
20 @brief Writer component to store tracks of the HLT TRD
23 #include "AliHLTTRDEsdWriterComponent.h"
24 #include "AliESDEvent.h"
25 #include "AliESDtrack.h"
27 #include "AliHLTTRDDefinitions.h"
28 #include "AliHLTTRDUtils.h" \
30 /** global instance for component registration */
31 AliHLTTRDEsdWriterComponent gTRDEsdWriter;
33 /** ROOT macro for the implementation of ROOT specific class methods */
34 ClassImp(AliHLTTRDEsdWriterComponent)
36 AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent()
38 AliHLTRootFileWriterComponent(),
40 fOutputPercentage(100),
43 // see header file for class documentation
45 // refer to README to build package
47 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
50 AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent(const AliHLTTRDEsdWriterComponent&)
52 AliHLTRootFileWriterComponent(),
54 fOutputPercentage(100),
59 AliHLTTRDEsdWriterComponent& AliHLTTRDEsdWriterComponent::operator=(const AliHLTTRDEsdWriterComponent&)
64 void AliHLTTRDEsdWriterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
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 );
71 AliHLTTRDEsdWriterComponent::~AliHLTTRDEsdWriterComponent()
73 // see header file for class documentation
76 int AliHLTTRDEsdWriterComponent::InitWriter()
78 // see header file for class documentation
80 fESD = new AliESDEvent;
82 fESD->CreateStdContent();
83 fTree = new TTree("esdTree", "Tree with HLT ESD objects");
85 fESD->WriteToTree(fTree);
94 int AliHLTTRDEsdWriterComponent::CloseWriter()
96 // see header file for class documentation
99 WriteObject(kAliHLTVoidEventID, fTree);
104 HLTWarning("not initialized");
106 iResult=AliHLTRootFileWriterComponent::CloseWriter();
110 int AliHLTTRDEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
111 const AliHLTComponentBlockData* blocks,
112 AliHLTComponentTriggerData& /*trigData*/ )
116 for ( unsigned long iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ )
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);*/
124 TClonesArray* tracksArray = NULL;
125 const AliHLTComponentBlockData &block = blocks[iBlock];
126 tracksArray = new TClonesArray("AliTRDtrackV1");
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
130 AliHLTTRDUtils::ReadTracks(tracksArray, block.fPtr, block.fSize);
132 // give out number of tracklets in tracksArray
133 Int_t nbEntries = tracksArray->GetEntries();
134 HLTInfo(" %i TRDtracks in tracksArray", nbEntries);
138 /* AliESDtrack* track = (AliESDtrack *)tobjin;
141 Logging( kHLTLogWarning, "HLT::TRDEsdWriter::DumpEvent", "DATAIN", "First Input Block not a ESDtrack! 0x%x", tobjin);
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);
158 tobjin = (TObject *)GetNextInputObject( ibForce );
159 //Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "nextBLOCK", "Pointer = 0x%x", tobjin);
160 track = (AliESDtrack *)tobjin;
163 Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "Fill", "Ntracks: %d", nTracks);
170 // int AliHLTTRDEsdWriterComponent::ScanArgument(int argc, const char** argv)
172 // // see header file for class documentation
173 // int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
177 int 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*/)
184 HLTDebug("ignor me");
189 Int_t AliHLTTRDEsdWriterComponent::ScanArgument( int argc, const char** argv )
191 // perform initialization. We check whether our relative output size is specified in the arguments.
194 HLTDebug("argv[%d] == %s", i, argv[i] );
195 if ( !strcmp( argv[i], "output_percentage" ) )
199 HLTError("Missing output_percentage parameter");
202 HLTDebug("argv[%d+1] == %s", i, argv[i+1] );
203 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
206 HLTError("Cannot convert output_percentage parameter '%s'", argv[i+1] );
209 HLTInfo("Output percentage set to %lu %%", fOutputPercentage );
212 //AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
218 void AliHLTTRDEsdWriterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
220 // Get the output data size
222 inputMultiplier = ((double)fOutputPercentage)/100.0;