]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TRD/AliHLTTRDClusterHistoComponent.cxx
cleanup of HLTTRDCalibration component, fixing bug in calibration: dQdl (Theodor)
[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
93ce7d1b 26#include <time.h>
27
c1a93a7b 28#include "AliHLTTRDClusterHistoComponent.h"
29#include "AliHLTTRDDefinitions.h"
30#include "AliHLTTRDCluster.h"
31#include "AliTRDcluster.h"
32#include "AliCDBEntry.h"
33#include "AliCDBManager.h"
34#include <TFile.h>
35#include <TString.h>
36#include "TObjString.h"
9772d58a 37#include "TClonesArray.h"
93ce7d1b 38#include "TTimeStamp.h"
9772d58a 39#include "AliHLTTRDUtils.h"
93ce7d1b 40#include "TH2F.h"
c1a93a7b 41
42//#include "AliHLTTRD.h"
43//#include <stdlib.h>
44//#include <cerrno>
45
46/** ROOT macro for the implementation of ROOT specific class methods */
47ClassImp(AliHLTTRDClusterHistoComponent)
48
49AliHLTTRDClusterHistoComponent::AliHLTTRDClusterHistoComponent()
93ce7d1b 50: AliHLTProcessor(),
51 fOutputSize(100000),
52 fClusterArray(NULL),
df3ef345 53 fNClsDet(NULL),
54 fClsAmp(NULL),
55 fClsAmpDrift(NULL),
56 fClsTB(NULL),
57 fClsAmpDist(NULL),
93ce7d1b 58 fSClsDist(NULL),
59 fNScls(NULL),
60 fClusterDist(NULL),
61 fClusterCandCharge(NULL)
c1a93a7b 62{
63 // see header file for class documentation
64 // or
65 // refer to README to build package
66 // or
67 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
68
69}
70
71AliHLTTRDClusterHistoComponent::~AliHLTTRDClusterHistoComponent()
72{
73 // see header file for class documentation
74}
75
76// Public functions to implement AliHLTComponent's interface.
77// These functions are required for the registration process
78
79const char* AliHLTTRDClusterHistoComponent::GetComponentID()
80{
81 // see header file for class documentation
82
83 return "TRDClusterHisto";
84}
85
86void AliHLTTRDClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
87{
88 // see header file for class documentation
89 list.clear();
90 list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
91}
92
93AliHLTComponentDataType AliHLTTRDClusterHistoComponent::GetOutputDataType()
94{
95 // see header file for class documentation
df3ef345 96 return kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD;
c1a93a7b 97
98}
99
100void AliHLTTRDClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
101{
102 // see header file for class documentation
93ce7d1b 103 constBase = fOutputSize;
104 inputMultiplier = 0;
c1a93a7b 105}
106
107AliHLTComponent* AliHLTTRDClusterHistoComponent::Spawn()
108{
109 // see header file for class documentation
110 return new AliHLTTRDClusterHistoComponent;
111}
112
93ce7d1b 113int AliHLTTRDClusterHistoComponent::DoInit(int argc, const char** argv)
c1a93a7b 114{
115 // Initialize histograms
93ce7d1b 116 int iResult=0;
117
118 TString configuration="";
119 TString argument="";
120 for (int i=0; i<argc && iResult>=0; i++) {
121 argument=argv[i];
122 if (!configuration.IsNull()) configuration+=" ";
123 configuration+=argument;
124 }
125
126 if (!configuration.IsNull()) {
127 iResult=Configure(configuration.Data());
128 }
c1a93a7b 129
df3ef345 130 fClusterArray = new TClonesArray("AliTRDcluster");
131
c1a93a7b 132 fNClsDet = new TH1D("trdClsDet", ";detector", 540, -0.5, 539.5);
df3ef345 133 fClsAmp = new TH1D("trdClsAmp", ";amplitude", 200, -0.5, 1999.5);
c1a93a7b 134 fClsAmpDrift = new TH1D("trdClsAmpDrift", ";amplitude", 200, -0.5, 199.5) ;
135 fClsTB = new TH1D("trdClsTB", ";time bin", 35, -0.5, 34.5);
df3ef345 136 fClsAmpDist = new TH1D("trdClsAmpDist", "mean amplitude", 200, 0, 1000);
137 fSClsDist = new TH1D("sclsdist", "Super cluster spectrum", 200, 0, 8000);
93ce7d1b 138 fNScls = new TH1D("nscls", "No. of Kr clusters per event", 540, 0, 540);
139 fClusterDist = new TH2F("cldist", "Cluster distribution;padrow;padcol", 16*5, -0.5, 79.5, 8*6*18, -0.5, 863.5);
140 fClusterCandCharge = new TH1D("qClsCand", "Cluster candidate charge;charge (ADC counts);counts", 200, 0, 8000);
c1a93a7b 141
93ce7d1b 142 for(int i=0; i<540; i++) {
c1a93a7b 143 fClsAmpDriftDet[i] = new TH1D(Form("trdClsDriftDet_%d",i), "", 200, -0.5, 199.5);
93ce7d1b 144 fSlidingWindow[i].SetBins(9, -0.5, 8.5, 17, -0.5, 16.5);
145 }
146
147 return 0;
c1a93a7b 148}
149
150int AliHLTTRDClusterHistoComponent::DoDeinit()
151{
152 // see header file for class documentation
153
df3ef345 154 fClusterArray->Delete();
155 delete fClusterArray;
156
c1a93a7b 157 // delete histograms
158 if (fNClsDet) delete fNClsDet;
159 if (fClsAmp) delete fClsAmp;
160 if (fClsAmpDrift) delete fClsAmpDrift;
161 if (fClsTB) delete fClsTB;
162 if (fClsAmpDist) delete fClsAmpDist;
df3ef345 163 if (fSClsDist) delete fSClsDist;
93ce7d1b 164 if (fClusterDist) delete fClusterDist;
165 if (fClusterCandCharge) delete fClusterCandCharge;
166 if (fNScls) delete fNScls;
c1a93a7b 167
168 for(int i=0; i<540; i++)
169 if (fClsAmpDriftDet[i]) delete fClsAmpDriftDet[i];
170
171 return 0;
172}
173
93ce7d1b 174int AliHLTTRDClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
c1a93a7b 175 AliHLTComponentTriggerData& /*trigData*/)
176{
177
93ce7d1b 178 // if (GetFirstInputBlock(kAliHLTDataTypeSOR)) return 0;
179 // else if (GetFirstInputBlock(kAliHLTDataTypeEOR))
180 // {
181 // TString fileName="/tmp/ClusterHistoDump_run";
182 // fileName+=AliCDBManager::Instance()->GetRun();
183 // fileName+=".root";
184 // HLTInfo("Dumping Histogram file to %s",fileName.Data());
185 // TFile* file = TFile::Open(fileName, "RECREATE");
186 // fNClsDet->Write();
187 // fClsAmp->Write();
188 // fClsAmpDrift->Write();
189 // fClsTB->Write();
190 // fClsAmpDist->Write();
191 // fSClsDist->Write();
192 // fNScls->Write();
193 // fClusterDist->Write();
194 // fClusterCandCharge->Write();
195 // file->Close();
196 // HLTInfo("Histogram file dumped");
197 // return 0;
198 // }
199
df3ef345 200 if (GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;
93ce7d1b 201
c1a93a7b 202 const AliHLTComponentBlockData* iter = NULL;
c1a93a7b 203
df3ef345 204 Float_t sClusterCharge[540] = { 0 };
93ce7d1b 205 for (Int_t iDet = 0; iDet < 540; iDet++) {
206 fSlidingWindow[iDet].Reset();
207 }
df3ef345 208
c1a93a7b 209 for ( iter = GetFirstInputBlock(AliHLTTRDDefinitions::fgkClusterDataType);
210 iter != NULL; iter = GetNextInputBlock() ) {
9772d58a 211
212 HLTDebug("We get the right data type: Block Ptr: 0x%x; Block Size: %i",
213 iter->fPtr, iter->fSize);
214
df3ef345 215 AliHLTTRDUtils::ReadClusters(fClusterArray, iter->fPtr, iter->fSize);
216 HLTDebug("TClonesArray of clusters: nbEntries = %i", fClusterArray->GetEntriesFast());
9772d58a 217
218 AliTRDcluster *cls;
df3ef345 219
c1a93a7b 220 // loop over clusters
df3ef345 221 for(int i=0;i<fClusterArray->GetEntriesFast();i++) {
9772d58a 222
df3ef345 223 cls=(AliTRDcluster*)fClusterArray->At(i);
c1a93a7b 224
225 fNClsDet->Fill(cls->GetDetector());
226 fClsAmp->Fill(cls->GetQ());
227
228 int tb = cls->GetPadTime();
229 fClsTB->Fill(tb);
230 if (tb > 5 && tb <25)
231 fClsAmpDrift->Fill(cls->GetQ());
232
233 fClsAmpDriftDet[cls->GetDetector()]->Fill(cls->GetQ());
93ce7d1b 234
235 Int_t det = cls->GetDetector();
236 sClusterCharge[det] += cls->GetQ();
237
238 fSlidingWindow[det].Fill((cls->GetPadCol() / 18), cls->GetPadRow(), cls->GetQ());
239 fSlidingWindow[det].Fill((cls->GetPadCol() / 18), cls->GetPadRow() + 1, cls->GetQ());
240 fSlidingWindow[det].Fill((cls->GetPadCol() / 18) + 1, cls->GetPadRow(), cls->GetQ());
241 fSlidingWindow[det].Fill((cls->GetPadCol() / 18) + 1, cls->GetPadRow() + 1, cls->GetQ());
c1a93a7b 242 }
27b3ec3e 243
df3ef345 244 fClusterArray->Delete();
27b3ec3e 245
c1a93a7b 246 }
c1a93a7b 247
248 fClsAmpDist->Reset();
93ce7d1b 249 Int_t nSClusters = 0;
df3ef345 250 for(int det=0; det<540; det++) {
c1a93a7b 251 if (fClsAmpDriftDet[det]->GetSum() > 0)
252 fClsAmpDist->Fill(fClsAmpDriftDet[det]->GetMean());
df3ef345 253 fSClsDist->Fill(sClusterCharge[det]);
93ce7d1b 254
255 Int_t xmax;
256 Int_t ymax;
257 Int_t zmax;
258 fSlidingWindow[det].GetMaximumBin(xmax, ymax, zmax);
259 Float_t charge = fSlidingWindow[det].GetBinContent(xmax, ymax);
260 fClusterCandCharge->Fill(charge);
261 if (charge > 2000. && charge < 6500.) {
262 nSClusters++;
263 fClusterDist->Fill((ymax-1) + 16 * ((det % 30) / 6), (det / 30) * 48 + 8 * (det % 6) + (xmax-1));
264 }
df3ef345 265 }
c1a93a7b 266
93ce7d1b 267 fNScls->Fill(nSClusters);
268
d132a324 269 PushBack((TObject*)fNClsDet, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
270 PushBack((TObject*)fClsAmp, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
271 // PushBack((TObject*)fClsAmpDrift, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
272 // PushBack((TObject*)fClsTB, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
273 // PushBack((TObject*)fClsAmpDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
274 PushBack((TObject*)fNScls, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
275 PushBack((TObject*)fSClsDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
276 PushBack((TObject*)fClusterDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
277 PushBack((TObject*)fClusterCandCharge, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
278
c1a93a7b 279 return 0;
280}
93ce7d1b 281
282int AliHLTTRDClusterHistoComponent::Configure(const char* arguments){
283 int iResult=0;
284 if (!arguments) return iResult;
285
286 TString allArgs=arguments;
287 TString argument;
288 int bMissingParam=0;
289
290 TObjArray* pTokens=allArgs.Tokenize(" ");
291 if (pTokens) {
292 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
293 argument=((TObjString*)pTokens->At(i))->GetString();
294 if (argument.IsNull()) continue;
295
296 if (argument.CompareTo("output_size")==0) {
297 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
298 HLTInfo("Setting output size to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
299 fOutputSize=((TObjString*)pTokens->At(i))->GetString().Atoi();
300 continue;
301 }
302 if (argument.CompareTo("-everyNevent")==0) {
303 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
d132a324 304 HLTInfo("Option -everyNevent depreceated");
93ce7d1b 305 continue;
306 }
307 else {
308 HLTError("unknown argument: %s", argument.Data());
309 iResult=-EINVAL;
310 break;
311 }
312 }
313 delete pTokens;
314 }
315 if (bMissingParam) {
316 HLTError("missing parameter for argument %s", argument.Data());
317 iResult=-EINVAL;
318 }
319 return iResult;
320}