]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EMCAL/AliHLTEMCALRawHistoMakerComponent.cxx
modification(by Levente) to solve the problem in the QA mentioned in the bug report...
[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),
50 fRootFileName("histo_local_dump.root")
51{
52 //see header file for documentation
53}
54
55
56AliHLTEMCALRawHistoMakerComponent::~AliHLTEMCALRawHistoMakerComponent()
57{
58 //see header file for documentation
59}
60
61int
62AliHLTEMCALRawHistoMakerComponent::Deinit()
63{
64 //see header file for documentation
65 if(fRawHistoMakerPtr)
66 {
67 delete fRawHistoMakerPtr;
68 fRawHistoMakerPtr = 0;
69 }
70
71 return 0;
72}
73
74const char*
75AliHLTEMCALRawHistoMakerComponent::GetComponentID()
76{
77 //see header file for documentation
78 return "EMCALRawHistoMaker";
79}
80
81
82void
83AliHLTEMCALRawHistoMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
84{
85 //see header file for documentation
86 list.clear();
87 list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
88}
89
90AliHLTComponentDataType
91AliHLTEMCALRawHistoMakerComponent::GetOutputDataType()
92{
93 //see header file for documentation
94 return kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL;
95}
96
97void
98AliHLTEMCALRawHistoMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
99{
100 //see header file for documentation
101 constBase = 0;
102 // to be reviewed later
103 inputMultiplier = 100;
104}
105
106int
107AliHLTEMCALRawHistoMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
108 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
109 std::vector<AliHLTComponentBlockData>& outputBlocks)
110{
111 //see header file for documentation
112 UInt_t mysize = 0;
113 Int_t ret = 0;
114
115
116 AliHLTUInt8_t* outBPtr;
117 outBPtr = outputPtr;
118 const AliHLTComponentBlockData* iter = 0;
119 unsigned long ndx;
120
121 UInt_t specification = 0;
122 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
123
124 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
125 {
126 iter = blocks+ndx;
127 //cout << " into do event and into to for loop !!! " << endl;
128 //PrintComponentDataTypeInfo(iter->fDataType);
129
130 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
131 {
132 HLTDebug("Data block is not of type fgkChannelDataType");
133
134 continue;
135 }
136
137 specification |= iter->fSpecification;
138 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
139
140 //HLTWarning (" channel number %d",tmpChannelData->fNChannels);
141
142 ret = fRawHistoMakerPtr->MakeHisto(tmpChannelData, iter, outputPtr, size);
143
144 //if(ret == -1)
145 //{
146 // HLTError("Trying to write over buffer size");
147 // return -ENOBUFS;
148 //}
149 //digitCount += ret;
150 }
151
152 fLocalEventCount++;
153
154 // fRawHistoMakerPtr->Reset();
155
156 TFile rootHistFile(fRootFileName,"recreate");
157
158 fRawHistoMakerPtr->GetHistograms()->Write();
159
160 if (fLocalEventCount%fPushFraction == 0) {
161 cout << "pushback done at " << fLocalEventCount << " events " << endl;
162
163 PushBack(fRawHistoMakerPtr->GetHistograms(), kAliHLTDataTypeTObjArray | kAliHLTDataOriginEMCAL , specification);
164 }
165
166 size = mysize;
167
168 return 0;
169}
170
171
172int
173AliHLTEMCALRawHistoMakerComponent::DoInit(int argc, const char** argv )
174{
175 //see header file for documentation
176
177 fRawHistoMakerPtr = new AliHLTEMCALRawHistoMaker();
178
179 for(int i = 0; i < argc; i++)
180 {
181 if(!strcmp("-roothistofilename", argv[i]))
182 {
183 fRootFileName = argv[i+1];
184
185 }
186 if(!strcmp("-pushfraction", argv[i]))
187 {
188 fPushFraction = atoi(argv[i+1]);
189 }
190 }
191
192 // cout << rootFileName << endl;
193
194 return 0;
195}
196
197
198AliHLTComponent*
199AliHLTEMCALRawHistoMakerComponent::Spawn()
200{
201 //see header file for documentation
202 return new AliHLTEMCALRawHistoMakerComponent();
203}