]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TRD/AliHLTTRDEsdWriterComponent.cxx
adding new library dependencies for TRD and MUON to configuration and cleaning up...
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDEsdWriterComponent.cxx
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 */
30 AliHLTTRDEsdWriterComponent gTRDEsdWriter;
31
32 /** ROOT macro for the implementation of ROOT specific class methods */
33 ClassImp(AliHLTTRDEsdWriterComponent)
34
35 AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent()
36   :
37   AliHLTRootFileWriterComponent(),
38   fTree(NULL),
39   fESD(NULL)
40 {
41   // see header file for class documentation
42   // or
43   // refer to README to build package
44   // or
45   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46 }
47
48 AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent(const AliHLTTRDEsdWriterComponent&)
49   :
50   AliHLTRootFileWriterComponent(),
51   fTree(NULL),
52   fESD(NULL)
53 {
54 }
55
56 AliHLTTRDEsdWriterComponent& AliHLTTRDEsdWriterComponent::operator=(const AliHLTTRDEsdWriterComponent&)
57 {
58   return *this;
59 }
60
61 void AliHLTTRDEsdWriterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
62 {
63   // Get the list of input data  
64   list.clear(); // We do not have any requirements for our input data type(s).
65   list.push_back( AliHLTTRDDefinitions::fgkTRDSATracksDataType );
66 }
67
68 AliHLTTRDEsdWriterComponent::~AliHLTTRDEsdWriterComponent()
69 {
70   // see header file for class documentation
71 }
72
73 int AliHLTTRDEsdWriterComponent::InitWriter()
74 {
75   // see header file for class documentation
76   int iResult=0;
77   fESD = new AliESDEvent;
78   if (fESD) {
79     fESD->CreateStdContent();
80     fTree = new TTree("esdTree", "Tree with HLT ESD objects");
81     if (fTree) {
82       fESD->WriteToTree(fTree);
83     }
84   }
85   if (fTree==NULL) {
86     iResult=-ENOMEM;
87   }
88   return iResult;
89 }
90
91 int AliHLTTRDEsdWriterComponent::CloseWriter()
92 {
93   // see header file for class documentation
94   int iResult=0;
95   if (fTree) {
96     WriteObject(kAliHLTVoidEventID, fTree);
97     TTree* pTree=fTree;
98     fTree=NULL;
99     delete pTree;
100   } else {
101     HLTWarning("not initialized");
102   }
103   iResult=AliHLTRootFileWriterComponent::CloseWriter();
104   return iResult;
105 }
106
107 int AliHLTTRDEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
108                                             const AliHLTComponentBlockData* /*blocks*/, 
109                                             AliHLTComponentTriggerData& trigData )
110 {
111   // see header file for class documentation
112   int iResult=0;
113   TTree* pTree=fTree;
114
115   AliHLTUInt32_t fDblock_Specification = 0;
116
117   //implement a usage of the following
118   //   AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
119   //   AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
120   //   void *triggerData = trigData.fData;
121   Logging( kHLTLogDebug, "HLT::TRDEsdWriter::DumpEvent", "Trigger data received", 
122            "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
123
124   //AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkTRDSAEsdDataType );
125   AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkTRDSATracksDataType );
126   if (dblock != 0)
127     {
128       fDblock_Specification = dblock->fSpecification;
129     }
130   else
131     {
132       Logging( kHLTLogWarning, "HLT::TRDEsdWriter::DumpEvent", "DATAIN", "First Input Block not found! 0x%x", dblock);
133       return -1;
134     }
135
136   int ibForce = 1;
137   TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkTRDSATracksDataType, "AliESDtrack", ibForce);
138   Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "1stBLOCK", "Pointer = 0x%x", tobjin);
139
140   AliESDtrack* track = (AliESDtrack *)tobjin;
141   if (!track)
142     {
143       Logging( kHLTLogWarning, "HLT::TRDEsdWriter::DumpEvent", "DATAIN", "First Input Block not a ESDtrack! 0x%x", tobjin);
144       return -1;
145     }
146
147   Int_t nTracks = 0;
148   while (tobjin != 0)
149     {
150       if (track != 0)
151         {
152           //Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "Track found", "0x%x", track);          
153           Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "DONE", "Track %d 0x%x Pt %1.2f", nTracks, track, track->Pt());
154           fESD->AddTrack(track);
155           nTracks++;
156         }
157
158       track = 0;
159       tobjin = 0;
160       tobjin = (TObject *)GetNextInputObject( ibForce );
161       //Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "nextBLOCK", "Pointer = 0x%x", tobjin);
162       track = (AliESDtrack *)tobjin;
163     }
164
165   Logging( kHLTLogInfo, "HLT::TRDEsdWriter::DumpEvent", "Fill", "Ntracks: %d", nTracks);          
166   pTree->Fill();
167   fESD->Reset();
168
169   return iResult;
170 }
171
172 int AliHLTTRDEsdWriterComponent::ScanArgument(int argc, const char** argv)
173 {
174   // see header file for class documentation
175   int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
176   return iResult;
177 }