]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSTreeMakerComponent.cxx
AliMC::BeginEvent gets run number from CDB manager
[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
30const AliHLTComponentDataType AliHLTPHOSTreeMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
31
32AliHLTPHOSTreeMakerComponent gAliHLTPHOSTreeMakerComponent;
33
34AliHLTPHOSTreeMakerComponent::AliHLTPHOSTreeMakerComponent() :
35 AliHLTPHOSProcessor(),
36 fDigitTreePtr(0),
37 fEventCount(0),
38 fWriteInterval(1000)
39{
ab38011b 40 //comment
f3ab4848 41}
42
43AliHLTPHOSTreeMakerComponent::~AliHLTPHOSTreeMakerComponent()
44{
ab38011b 45 //comment
f3ab4848 46}
47
48int
49AliHLTPHOSTreeMakerComponent::Deinit()
50{
ab38011b 51 //comment
f3ab4848 52 cout << "Printing file...";
53 char filename [50];
54 sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval));
55 TFile *outfile = new TFile(filename,"recreate");
56 fDigitTreePtr->Write();
57 delete outfile;
58 outfile = 0;
59 cout << "Done!\n";
60 if(fDigitTreePtr)
61 {
62 delete fDigitTreePtr;
63 fDigitTreePtr = 0;
64 }
65 return 0;
66}
67
68
69
70const char*
71AliHLTPHOSTreeMakerComponent::GetComponentID()
72{
ab38011b 73 //comment
f3ab4848 74 return "PhosTreeMaker";
75}
76
77void
78AliHLTPHOSTreeMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
79{
ab38011b 80 //comment
f3ab4848 81 //Get datatypes for input
82 const AliHLTComponentDataType* pType=fgkInputDataTypes;
83 while (pType->fID!=0) {
84 list.push_back(*pType);
85 pType++;
86 }
87}
88
89AliHLTComponentDataType
90AliHLTPHOSTreeMakerComponent::GetOutputDataType()
91{
ab38011b 92 //comment
f3ab4848 93 return AliHLTPHOSDefinitions::fgkAliHLTRootTreeDataType;
94}
95
96void
97AliHLTPHOSTreeMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
98{
ab38011b 99 //comment
f3ab4848 100 constBase = 30;
101 inputMultiplier = 1;
102}
103
104int
105AliHLTPHOSTreeMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
106 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
107 std::vector<AliHLTComponentBlockData>& outputBlocks)
108
109{
110 //Do event
111
112 Bool_t digitEvent;
113 Int_t nDigits = 0;
114 Int_t totalDigits = 0;
115
116 const AliHLTComponentBlockData* iter = 0;
117 unsigned long ndx;
118
119 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
120 {
121 iter = blocks + ndx;
122
123 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTDigitDataType )
124
125 {
126 digitEvent == true;
127 nDigits = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
128 totalDigits += nDigits;
129 //cout << totalDigits << endl;
130 continue;
131 }
132 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTClusterDataType )
133 {
134 //
135 }
136 }
137 fEventCount++;
138 fTreeMakerPtr->FillDigitTree();
139
140 if(fEventCount%fWriteInterval == 0)
141 {
142 Write();
143 ResetTrees();
144 }
145
146return 0;
147
148}
149
150int
151AliHLTPHOSTreeMakerComponent::DoInit ( int argc, const char** argv )
152{
ab38011b 153 //comment
f3ab4848 154 fTreeMakerPtr = new AliHLTPHOSTreeMaker();
155 fDigitTreePtr = new TTree ( "digitTree", "Digits tree" );
156 fDirectory = new char[50];
157
158 for ( int i = 0; i < argc; i++ )
159 {
160 if ( !strcmp ( "-path", argv[i] ) )
161 {
162 strcpy ( fDirectory, argv[i+1] );
163 }
164 if ( !strcmp ( "-writeinterval", argv[i] ) )
165 {
166 fWriteInterval = atoi(argv[i+1]);
167 }
168 }
169
170 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
171
172 fstream runNbFile;
173 Int_t newRunNb;
174 runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
175 runNbFile >> fRunNb;
176 runNbFile.close();
177 /* newRunNb = fRunNb + 1;
178 runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
179 runNbFile << newRunNb;
180 runNbFile.close();*/
181
182 cout << endl << "Run number is: " << fRunNb << " -- Check that this is correct!!!\n";
183
184 return 0;
185
186}
187
188
189AliHLTComponent*
190AliHLTPHOSTreeMakerComponent::Spawn()
191{
ab38011b 192 //comment
f3ab4848 193 return new AliHLTPHOSTreeMakerComponent();
194}
195
196void
197AliHLTPHOSTreeMakerComponent::Write()
198{
ab38011b 199 //comment
f3ab4848 200 cout << "Writing file...";
48b962f0 201 char filename [256];
f3ab4848 202 sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval - 1));
203 TFile *outfile = new TFile(filename,"recreate");
204 fDigitTreePtr->Write();
205 delete outfile;
206 outfile = 0;
207 cout << "Done!\n";
208}
209
210void
211AliHLTPHOSTreeMakerComponent::ResetTrees()
212{
ab38011b 213 //comment
f3ab4848 214 delete fDigitTreePtr;
215 fDigitTreePtr = new TTree("digitTree", "Digits tree");
216 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
217}
218
219
220
221
222
223
224
225
226
227