]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TRD/AliHLTTRDClusterHistoComponent.cxx
Fix for compiler warning
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDClusterHistoComponent.cxx
CommitLineData
c1a93a7b 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: Sylwester Radomski radomski@physi.uni-heidelberg.de *
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 AliHLTTRDClusterHistoComponent.cxx
18 @author Sylwester Radomski
19 @brief Component for ploting charge in clusters
20*/
21
22#if __GNUC__>= 3
23using namespace std;
24#endif
25
1298a070 26#include "TFile.h"
27#include "TString.h"
28#include "TObjString.h"
29#include "TClonesArray.h"
30#include "TH1F.h"
93ce7d1b 31
c1a93a7b 32#include "AliHLTTRDClusterHistoComponent.h"
33#include "AliHLTTRDDefinitions.h"
c1a93a7b 34#include "AliTRDcluster.h"
35#include "AliCDBEntry.h"
36#include "AliCDBManager.h"
9772d58a 37#include "AliHLTTRDUtils.h"
c1a93a7b 38
39//#include "AliHLTTRD.h"
40//#include <stdlib.h>
41//#include <cerrno>
42
43/** ROOT macro for the implementation of ROOT specific class methods */
44ClassImp(AliHLTTRDClusterHistoComponent)
45
46AliHLTTRDClusterHistoComponent::AliHLTTRDClusterHistoComponent()
93ce7d1b 47: AliHLTProcessor(),
48 fOutputSize(100000),
2d7cea9e 49 fSpec(0),
93ce7d1b 50 fClusterArray(NULL),
df3ef345 51 fNClsDet(NULL),
52 fClsAmp(NULL),
53 fClsAmpDrift(NULL),
54 fClsTB(NULL),
55 fClsAmpDist(NULL),
93ce7d1b 56 fSClsDist(NULL),
1ea1f8e0 57 fNScls(NULL),
58 fEvSize(NULL)
c1a93a7b 59{
60 // see header file for class documentation
61 // or
62 // refer to README to build package
63 // or
64 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
65
66}
67
68AliHLTTRDClusterHistoComponent::~AliHLTTRDClusterHistoComponent()
69{
70 // see header file for class documentation
71}
72
73// Public functions to implement AliHLTComponent's interface.
74// These functions are required for the registration process
75
76const char* AliHLTTRDClusterHistoComponent::GetComponentID()
77{
78 // see header file for class documentation
79
80 return "TRDClusterHisto";
81}
82
83void AliHLTTRDClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
84{
85 // see header file for class documentation
86 list.clear();
87 list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
88}
89
90AliHLTComponentDataType AliHLTTRDClusterHistoComponent::GetOutputDataType()
91{
92 // see header file for class documentation
df3ef345 93 return kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD;
c1a93a7b 94
95}
96
97void AliHLTTRDClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
98{
99 // see header file for class documentation
93ce7d1b 100 constBase = fOutputSize;
101 inputMultiplier = 0;
c1a93a7b 102}
103
104AliHLTComponent* AliHLTTRDClusterHistoComponent::Spawn()
105{
106 // see header file for class documentation
107 return new AliHLTTRDClusterHistoComponent;
108}
109
93ce7d1b 110int AliHLTTRDClusterHistoComponent::DoInit(int argc, const char** argv)
c1a93a7b 111{
112 // Initialize histograms
93ce7d1b 113 int iResult=0;
114
115 TString configuration="";
116 TString argument="";
117 for (int i=0; i<argc && iResult>=0; i++) {
118 argument=argv[i];
119 if (!configuration.IsNull()) configuration+=" ";
120 configuration+=argument;
121 }
122
123 if (!configuration.IsNull()) {
124 iResult=Configure(configuration.Data());
125 }
c1a93a7b 126
df3ef345 127 fClusterArray = new TClonesArray("AliTRDcluster");
128
1298a070 129 fNClsDet = new TH1F("trdClsDet", ";detector", 540, -0.5, 539.5);
130 fClsAmp = new TH1F("trdClsAmp", ";amplitude", 200, -0.5, 1999.5);
131 fClsAmpDrift = new TH1F("trdClsAmpDrift", ";amplitude", 200, -0.5, 199.5) ;
132 fClsTB = new TH1F("trdClsTB", ";time bin", 35, -0.5, 34.5);
133 fClsAmpDist = new TH1F("trdClsAmpDist", "mean amplitude", 200, 0, 1000);
134 fSClsDist = new TH1F("sclsdist", "Super cluster spectrum", 200, 0, 8000);
135 fNScls = new TH1F("nscls", "No. of Kr clusters per event", 540, 0, 540);
ffdc0ab5 136 fEvSize = new TH1F("TrdClEvSize", "Clusters size per event per ddl in kbyte", 512, 0, 512);
c1a93a7b 137
93ce7d1b 138 for(int i=0; i<540; i++) {
1298a070 139 fClsAmpDriftDet[i] = new TH1F(Form("trdClsDriftDet_%d",i), "", 200, -0.5, 199.5);
93ce7d1b 140 }
141
142 return 0;
c1a93a7b 143}
144
145int AliHLTTRDClusterHistoComponent::DoDeinit()
146{
147 // see header file for class documentation
148
df3ef345 149 fClusterArray->Delete();
150 delete fClusterArray;
151
c1a93a7b 152 // delete histograms
153 if (fNClsDet) delete fNClsDet;
154 if (fClsAmp) delete fClsAmp;
155 if (fClsAmpDrift) delete fClsAmpDrift;
156 if (fClsTB) delete fClsTB;
157 if (fClsAmpDist) delete fClsAmpDist;
df3ef345 158 if (fSClsDist) delete fSClsDist;
93ce7d1b 159 if (fNScls) delete fNScls;
1ea1f8e0 160 if (fEvSize) delete fEvSize;
c1a93a7b 161
1298a070 162 for(int i=0; i<540; i++){
c1a93a7b 163 if (fClsAmpDriftDet[i]) delete fClsAmpDriftDet[i];
1298a070 164 }
c1a93a7b 165
166 return 0;
167}
168
93ce7d1b 169int AliHLTTRDClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
c1a93a7b 170 AliHLTComponentTriggerData& /*trigData*/)
171{
172
93ce7d1b 173 // if (GetFirstInputBlock(kAliHLTDataTypeSOR)) return 0;
174 // else if (GetFirstInputBlock(kAliHLTDataTypeEOR))
175 // {
176 // TString fileName="/tmp/ClusterHistoDump_run";
177 // fileName+=AliCDBManager::Instance()->GetRun();
178 // fileName+=".root";
179 // HLTInfo("Dumping Histogram file to %s",fileName.Data());
180 // TFile* file = TFile::Open(fileName, "RECREATE");
181 // fNClsDet->Write();
182 // fClsAmp->Write();
183 // fClsAmpDrift->Write();
184 // fClsTB->Write();
185 // fClsAmpDist->Write();
186 // fSClsDist->Write();
187 // fNScls->Write();
93ce7d1b 188 // file->Close();
189 // HLTInfo("Histogram file dumped");
190 // return 0;
191 // }
192
1ea1f8e0 193 if(!IsDataEvent())return 0;
93ce7d1b 194
c1a93a7b 195 const AliHLTComponentBlockData* iter = NULL;
1298a070 196 Bool_t gotData = kFALSE;
df3ef345 197
c1a93a7b 198 for ( iter = GetFirstInputBlock(AliHLTTRDDefinitions::fgkClusterDataType);
199 iter != NULL; iter = GetNextInputBlock() ) {
9772d58a 200
1ea1f8e0 201 fEvSize->Fill((iter->fSize+0.5f)/1024);
df3ef345 202 AliHLTTRDUtils::ReadClusters(fClusterArray, iter->fPtr, iter->fSize);
2d7cea9e 203 HLTDebug("TClonesArray of clusters: nbEntries = %i", fClusterArray->GetEntriesFast());
1298a070 204 gotData = kTRUE;
2d7cea9e 205 fSpec |= iter->fSpecification;
1298a070 206 }
207
208 if(!gotData) return 0;
209
1298a070 210 Float_t sClusterCharge[540] = { 0 };
9772d58a 211 AliTRDcluster *cls;
df3ef345 212
c1a93a7b 213 // loop over clusters
df3ef345 214 for(int i=0;i<fClusterArray->GetEntriesFast();i++) {
9772d58a 215
df3ef345 216 cls=(AliTRDcluster*)fClusterArray->At(i);
c1a93a7b 217
218 fNClsDet->Fill(cls->GetDetector());
219 fClsAmp->Fill(cls->GetQ());
220
221 int tb = cls->GetPadTime();
222 fClsTB->Fill(tb);
1298a070 223 if (tb > 5 && tb <25){
c1a93a7b 224 fClsAmpDrift->Fill(cls->GetQ());
1298a070 225 }
c1a93a7b 226
1298a070 227 //fClsAmpDriftDet[cls->GetDetector()]->Fill(cls->GetQ());
93ce7d1b 228
229 Int_t det = cls->GetDetector();
230 sClusterCharge[det] += cls->GetQ();
231
c1a93a7b 232 }
27b3ec3e 233
df3ef345 234 fClusterArray->Delete();
27b3ec3e 235
1298a070 236 //fClsAmpDist->Reset();
237 //Int_t nSClusters = 0;
df3ef345 238 for(int det=0; det<540; det++) {
1298a070 239 // if (fClsAmpDriftDet[det]->GetSum() > 0)
240 // fClsAmpDist->Fill(fClsAmpDriftDet[det]->GetMean());
241 if(sClusterCharge[det])
df3ef345 242 fSClsDist->Fill(sClusterCharge[det]);
243 }
c1a93a7b 244
1298a070 245 //fNScls->Fill(nSClusters);
93ce7d1b 246
2d7cea9e 247 PushBack((TObject*)fNClsDet, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
248 PushBack((TObject*)fClsAmp, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
249 PushBack((TObject*)fClsAmpDrift, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
250 PushBack((TObject*)fClsTB, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
251 //PushBack((TObject*)fClsAmpDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
252 //PushBack((TObject*)fNScls, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
253 PushBack((TObject*)fSClsDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
254 PushBack((TObject*)fEvSize, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
d132a324 255
c1a93a7b 256 return 0;
257}
93ce7d1b 258
259int AliHLTTRDClusterHistoComponent::Configure(const char* arguments){
260 int iResult=0;
261 if (!arguments) return iResult;
262
263 TString allArgs=arguments;
264 TString argument;
265 int bMissingParam=0;
266
267 TObjArray* pTokens=allArgs.Tokenize(" ");
268 if (pTokens) {
269 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
270 argument=((TObjString*)pTokens->At(i))->GetString();
271 if (argument.IsNull()) continue;
272
273 if (argument.CompareTo("output_size")==0) {
274 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
275 HLTInfo("Setting output size to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
276 fOutputSize=((TObjString*)pTokens->At(i))->GetString().Atoi();
277 continue;
278 }
93ce7d1b 279 else {
280 HLTError("unknown argument: %s", argument.Data());
281 iResult=-EINVAL;
282 break;
283 }
284 }
285 delete pTokens;
286 }
287 if (bMissingParam) {
288 HLTError("missing parameter for argument %s", argument.Data());
289 iResult=-EINVAL;
290 }
291 return iResult;
292}