]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSTreeMakerComponent.cxx
Coding conventions and removal of obsolete files
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSTreeMakerComponent.cxx
CommitLineData
f3ab4848 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
4 * *
5 * Primary Authors: Oystein Djuvsland *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17
18#include "AliHLTPHOSTreeMakerComponent.h"
19#include "AliHLTPHOSTreeMaker.h"
20#include "AliHLTPHOSProcessor.h"
21#include "AliHLTPHOSDigitDataStruct.h"
22#include "TTree.h"
23#include "TClonesArray.h"
24#include "TObject.h"
25#include <fstream>
26#include "TFile.h"
27#include <sys/stat.h>
28#include <sys/types.h>
29
2374af72 30/**
31 * Tree maker component for PHOS HLT
32 *
33 * @file AliHLTPHOSTreeMakerComponent.cxx
34 * @author Oystein Djuvsland
35 * @date
36 * @brief A tree maker component for PHOS HLT
37*/
38
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
f3ab4848 46const AliHLTComponentDataType AliHLTPHOSTreeMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
47
48AliHLTPHOSTreeMakerComponent gAliHLTPHOSTreeMakerComponent;
49
50AliHLTPHOSTreeMakerComponent::AliHLTPHOSTreeMakerComponent() :
51 AliHLTPHOSProcessor(),
52 fDigitTreePtr(0),
2374af72 53 fTreeMakerPtr(0),
54 fDirectory(0),
f3ab4848 55 fWriteInterval(1000)
56{
2374af72 57 //See header file for documentation
f3ab4848 58}
59
60AliHLTPHOSTreeMakerComponent::~AliHLTPHOSTreeMakerComponent()
61{
2374af72 62 //See header file for documentation
f3ab4848 63}
64
65int
66AliHLTPHOSTreeMakerComponent::Deinit()
67{
2374af72 68 //See header file for documentation
69 cout << "Writing file...";
f3ab4848 70 char filename [50];
939c67e7 71
2374af72 72 sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNumber,(fPhosEventCount/fWriteInterval));
73
f3ab4848 74 TFile *outfile = new TFile(filename,"recreate");
75 fDigitTreePtr->Write();
76 delete outfile;
77 outfile = 0;
78 cout << "Done!\n";
79 if(fDigitTreePtr)
80 {
81 delete fDigitTreePtr;
82 fDigitTreePtr = 0;
83 }
84 return 0;
85}
86
87
88
89const char*
90AliHLTPHOSTreeMakerComponent::GetComponentID()
91{
2374af72 92 //See header file for documentation
f3ab4848 93 return "PhosTreeMaker";
94}
95
96void
97AliHLTPHOSTreeMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
98{
2374af72 99 //See header file for documentation
f3ab4848 100 //Get datatypes for input
101 const AliHLTComponentDataType* pType=fgkInputDataTypes;
102 while (pType->fID!=0) {
103 list.push_back(*pType);
104 pType++;
105 }
106}
107
108AliHLTComponentDataType
109AliHLTPHOSTreeMakerComponent::GetOutputDataType()
110{
2374af72 111 //See header file for documentation
f3ab4848 112 return AliHLTPHOSDefinitions::fgkAliHLTRootTreeDataType;
113}
114
115void
116AliHLTPHOSTreeMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
117{
2374af72 118 //See header file for documentation
f3ab4848 119 constBase = 30;
120 inputMultiplier = 1;
121}
122
123int
124AliHLTPHOSTreeMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
1804b020 125 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/, //TODO: I think size should be set to zero when returning from this method if not data was written to the output buffer.
126 std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
f3ab4848 127
128{
129 //Do event
2374af72 130 //See header file for documentation
f3ab4848 131 Bool_t digitEvent;
132 Int_t nDigits = 0;
133 Int_t totalDigits = 0;
134
135 const AliHLTComponentBlockData* iter = 0;
136 unsigned long ndx;
137
138 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
139 {
140 iter = blocks + ndx;
141
142 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTDigitDataType )
143
144 {
1804b020 145 digitEvent = true;
f3ab4848 146 nDigits = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
147 totalDigits += nDigits;
148 //cout << totalDigits << endl;
149 continue;
150 }
151 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTClusterDataType )
152 {
153 //
154 }
155 }
939c67e7 156
157 fPhosEventCount++;
158
f3ab4848 159 fTreeMakerPtr->FillDigitTree();
160
939c67e7 161 if( (fPhosEventCount%fWriteInterval == 0 ) && (fPhosEventCount != 0))
f3ab4848 162 {
163 Write();
164 ResetTrees();
165 }
166
167return 0;
168
169}
170
171int
172AliHLTPHOSTreeMakerComponent::DoInit ( int argc, const char** argv )
173{
2374af72 174 //See header file for documentation
f3ab4848 175 fTreeMakerPtr = new AliHLTPHOSTreeMaker();
176 fDigitTreePtr = new TTree ( "digitTree", "Digits tree" );
177 fDirectory = new char[50];
178
179 for ( int i = 0; i < argc; i++ )
180 {
181 if ( !strcmp ( "-path", argv[i] ) )
182 {
183 strcpy ( fDirectory, argv[i+1] );
184 }
185 if ( !strcmp ( "-writeinterval", argv[i] ) )
186 {
187 fWriteInterval = atoi(argv[i+1]);
188 }
189 }
190
191 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
939c67e7 192 cout << endl << "Run number is: " << fRunNumber << " -- Check that this is correct!!!\n" << endl;
193
194 // fRunNumber
f3ab4848 195
196 return 0;
197
198}
199
200
201AliHLTComponent*
202AliHLTPHOSTreeMakerComponent::Spawn()
203{
2374af72 204 //See header file for documentation
f3ab4848 205 return new AliHLTPHOSTreeMakerComponent();
206}
207
208void
209AliHLTPHOSTreeMakerComponent::Write()
210{
2374af72 211 //See header file for documentation
f3ab4848 212 cout << "Writing file...";
48b962f0 213 char filename [256];
2374af72 214
939c67e7 215 sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNumber,(fPhosEventCount/fWriteInterval - 1));
216
f3ab4848 217 TFile *outfile = new TFile(filename,"recreate");
218 fDigitTreePtr->Write();
219 delete outfile;
220 outfile = 0;
221 cout << "Done!\n";
222}
223
224void
225AliHLTPHOSTreeMakerComponent::ResetTrees()
226{
2374af72 227 //See header file for documentation
f3ab4848 228 delete fDigitTreePtr;
229 fDigitTreePtr = new TTree("digitTree", "Digits tree");
230 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
231}
2374af72 232
f3ab4848 233
234
235
236
237
238
239
240