]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EMCAL/AliHLTEMCALRawHistoMakerComponent.cxx
introducing adaptive output size estimator for ITSClusterFinder on digits
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALRawHistoMakerComponent.cxx
CommitLineData
fdf6f4e9 1
2
3/**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * All rights reserved. *
6 * INFN, Laboratori Nazionali di Frascati *
7 * Primary Authors: Federico Ronchetti *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18#include "AliHLTEMCALRawHistoMakerComponent.h"
19#include "AliHLTEMCALRawHistoMaker.h"
20
21#include "AliHLTCaloChannelDataHeaderStruct.h"
22#include "AliHLTCaloChannelDataStruct.h"
23
24// root stuff
25#include "TFile.h"
26#include "TProfile2D.h"
27#include "TH1F.h"
28#include "TH2F.h"
29#include <sys/stat.h>
30#include <sys/types.h>
31
32#include "AliCDBEntry.h"
33#include "AliCDBManager.h"
34#include "AliCDBPath.h"
35/**
36 * @file AliHLTEMCALRawHistoMakerComponent.cxx
37 * @author Federico Ronchetti
38 * @date
39 * @brief A component to pusk back histograms for EMCAL HLT
40 */
41
42//FIXME
43AliHLTEMCALRawHistoMakerComponent gAliHLTEMCALRawHistoMakerComponent;
44
45AliHLTEMCALRawHistoMakerComponent::AliHLTEMCALRawHistoMakerComponent() :
46 AliHLTCaloProcessor(),
47 fRawHistoMakerPtr(0),
48 fPushFraction(10),
49 fLocalEventCount(0),
fb43b5cd 50 fRootFileName("histofile_local.root"),
51 fBeVerbose(0)
fdf6f4e9 52{
53 //see header file for documentation
54}
55
56
57AliHLTEMCALRawHistoMakerComponent::~AliHLTEMCALRawHistoMakerComponent()
58{
59 //see header file for documentation
60}
61
62int
63AliHLTEMCALRawHistoMakerComponent::Deinit()
64{
65 //see header file for documentation
66 if(fRawHistoMakerPtr)
67 {
68 delete fRawHistoMakerPtr;
69 fRawHistoMakerPtr = 0;
70 }
71
72 return 0;
73}
74
75const char*
76AliHLTEMCALRawHistoMakerComponent::GetComponentID()
77{
78 //see header file for documentation
fb43b5cd 79 return "EmcalRawHistoMaker";
fdf6f4e9 80}
81
82
83void
84AliHLTEMCALRawHistoMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
85{
86 //see header file for documentation
87 list.clear();
88 list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
89}
90
91AliHLTComponentDataType
92AliHLTEMCALRawHistoMakerComponent::GetOutputDataType()
93{
94 //see header file for documentation
95 return kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL;
96}
97
98void
99AliHLTEMCALRawHistoMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
100{
101 //see header file for documentation
102 constBase = 0;
103 // to be reviewed later
104 inputMultiplier = 100;
105}
106
107int
108AliHLTEMCALRawHistoMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
109 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
110 std::vector<AliHLTComponentBlockData>& outputBlocks)
111{
112 //see header file for documentation
113 UInt_t mysize = 0;
114 Int_t ret = 0;
115
116
117 AliHLTUInt8_t* outBPtr;
118 outBPtr = outputPtr;
119 const AliHLTComponentBlockData* iter = 0;
120 unsigned long ndx;
121
122 UInt_t specification = 0;
123 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
124
fb43b5cd 125
fdf6f4e9 126 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
127 {
128 iter = blocks+ndx;
fb43b5cd 129
130 if (fBeVerbose) {
131 PrintComponentDataTypeInfo(iter->fDataType);
132 cout << "I-RAWHISTOMAKERCOMPONENT: verbose mode enabled: " << fBeVerbose << endl;
133 }
fdf6f4e9 134
135 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
136 {
fb43b5cd 137
138 if (fBeVerbose)
139 HLTWarning("I-RAWHISTOMAKERCOMPONENT: Data block is not of type fgkChannelDataType");
140 else
141 HLTDebug("I-RAWHISTOMAKERCOMPONENT: Data block is not of type fgkChannelDataType");
fdf6f4e9 142
143 continue;
144 }
145
146 specification |= iter->fSpecification;
147 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
148
fb43b5cd 149 if (fBeVerbose)
150 HLTWarning ("I-RAWHISTOMAKERCOMPONENT: channel number %d",tmpChannelData->fNChannels);
fdf6f4e9 151
fb43b5cd 152 ret = fRawHistoMakerPtr->MakeHisto(tmpChannelData, iter, outputPtr, size, fBeVerbose);
fdf6f4e9 153
154 //if(ret == -1)
155 //{
156 // HLTError("Trying to write over buffer size");
157 // return -ENOBUFS;
158 //}
159 //digitCount += ret;
160 }
161
162 fLocalEventCount++;
163
fdf6f4e9 164 TFile rootHistFile(fRootFileName,"recreate");
165
166 fRawHistoMakerPtr->GetHistograms()->Write();
167
168 if (fLocalEventCount%fPushFraction == 0) {
fb43b5cd 169
170 if (fBeVerbose)
171 cout << "I-RAWHISTOMAKERCOMPONENT: pushback done at " << fLocalEventCount << " events " << endl;
fdf6f4e9 172
173 PushBack(fRawHistoMakerPtr->GetHistograms(), kAliHLTDataTypeTObjArray | kAliHLTDataOriginEMCAL , specification);
174 }
175
176 size = mysize;
177
178 return 0;
179}
180
181
182int
183AliHLTEMCALRawHistoMakerComponent::DoInit(int argc, const char** argv )
184{
185 //see header file for documentation
186
187 fRawHistoMakerPtr = new AliHLTEMCALRawHistoMaker();
188
189 for(int i = 0; i < argc; i++)
190 {
191 if(!strcmp("-roothistofilename", argv[i]))
fdf6f4e9 192 fRootFileName = argv[i+1];
193
fdf6f4e9 194 if(!strcmp("-pushfraction", argv[i]))
fdf6f4e9 195 fPushFraction = atoi(argv[i+1]);
fb43b5cd 196
197 if(!strcmp("-beverbose", argv[i]))
198 fBeVerbose = atoi(argv[i+1]);
199
fdf6f4e9 200 }
201
fb43b5cd 202 if (fBeVerbose)
203 cout << "I-RAWHISTOMAKERCOMPONENT: local root file name is: " << fRootFileName << endl;
fdf6f4e9 204
205 return 0;
206}
207
208
209AliHLTComponent*
210AliHLTEMCALRawHistoMakerComponent::Spawn()
211{
212 //see header file for documentation
213 return new AliHLTEMCALRawHistoMakerComponent();
214}