1 //**************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project *
3 //* ALICE Experiment at CERN, All rights reserved. *
5 //* Primary Authors: Sylwester Radomski radomski@physi.uni-heidelberg.de *
6 //* for The ALICE HLT Project. *
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 //**************************************************************************
17 /** @file AliHLTTRDClusterHistoComponent.cxx
18 @author Sylwester Radomski
19 @brief Component for ploting charge in clusters
28 #include "TObjString.h"
29 #include "TClonesArray.h"
32 #include "AliHLTTRDClusterHistoComponent.h"
33 #include "AliHLTTRDDefinitions.h"
34 #include "AliTRDcluster.h"
35 #include "AliCDBEntry.h"
36 #include "AliCDBManager.h"
37 #include "AliHLTTRDUtils.h"
39 //#include "AliHLTTRD.h"
43 /** ROOT macro for the implementation of ROOT specific class methods */
44 ClassImp(AliHLTTRDClusterHistoComponent)
46 AliHLTTRDClusterHistoComponent::AliHLTTRDClusterHistoComponent()
59 // see header file for class documentation
61 // refer to README to build package
63 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
67 AliHLTTRDClusterHistoComponent::~AliHLTTRDClusterHistoComponent()
69 // see header file for class documentation
72 // Public functions to implement AliHLTComponent's interface.
73 // These functions are required for the registration process
75 const char* AliHLTTRDClusterHistoComponent::GetComponentID()
77 // see header file for class documentation
79 return "TRDClusterHisto";
82 void AliHLTTRDClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
84 // see header file for class documentation
86 list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
89 AliHLTComponentDataType AliHLTTRDClusterHistoComponent::GetOutputDataType()
91 // see header file for class documentation
92 return kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD;
96 void AliHLTTRDClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
98 // see header file for class documentation
99 constBase = fOutputSize;
103 AliHLTComponent* AliHLTTRDClusterHistoComponent::Spawn()
105 // see header file for class documentation
106 return new AliHLTTRDClusterHistoComponent;
109 int AliHLTTRDClusterHistoComponent::DoInit(int argc, const char** argv)
111 // Initialize histograms
114 TString configuration="";
116 for (int i=0; i<argc && iResult>=0; i++) {
118 if (!configuration.IsNull()) configuration+=" ";
119 configuration+=argument;
122 if (!configuration.IsNull()) {
123 iResult=Configure(configuration.Data());
126 fClusterArray = new TClonesArray("AliTRDcluster");
128 fNClsDet = new TH1F("trdClsDet", ";detector", 540, -0.5, 539.5);
129 fClsAmp = new TH1F("trdClsAmp", ";amplitude", 200, -0.5, 1999.5);
130 fClsAmpDrift = new TH1F("trdClsAmpDrift", ";amplitude", 200, -0.5, 199.5) ;
131 fClsTB = new TH1F("trdClsTB", ";time bin", 35, -0.5, 34.5);
132 fClsAmpDist = new TH1F("trdClsAmpDist", "mean amplitude", 200, 0, 1000);
133 fSClsDist = new TH1F("sclsdist", "Super cluster spectrum", 200, 0, 8000);
134 fNScls = new TH1F("nscls", "No. of Kr clusters per event", 540, 0, 540);
135 fEvSize = new TH1F("TrdClEvSize", "Clusters size per event per ddl in kbyte", 512, 0, 512);
137 for(int i=0; i<540; i++) {
138 fClsAmpDriftDet[i] = new TH1F(Form("trdClsDriftDet_%d",i), "", 200, -0.5, 199.5);
144 int AliHLTTRDClusterHistoComponent::DoDeinit()
146 // see header file for class documentation
148 fClusterArray->Delete();
149 delete fClusterArray;
152 if (fNClsDet) delete fNClsDet;
153 if (fClsAmp) delete fClsAmp;
154 if (fClsAmpDrift) delete fClsAmpDrift;
155 if (fClsTB) delete fClsTB;
156 if (fClsAmpDist) delete fClsAmpDist;
157 if (fSClsDist) delete fSClsDist;
158 if (fNScls) delete fNScls;
159 if (fEvSize) delete fEvSize;
161 for(int i=0; i<540; i++){
162 if (fClsAmpDriftDet[i]) delete fClsAmpDriftDet[i];
168 int AliHLTTRDClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
169 AliHLTComponentTriggerData& /*trigData*/)
172 // if (GetFirstInputBlock(kAliHLTDataTypeSOR)) return 0;
173 // else if (GetFirstInputBlock(kAliHLTDataTypeEOR))
175 // TString fileName="/tmp/ClusterHistoDump_run";
176 // fileName+=AliCDBManager::Instance()->GetRun();
177 // fileName+=".root";
178 // HLTInfo("Dumping Histogram file to %s",fileName.Data());
179 // TFile* file = TFile::Open(fileName, "RECREATE");
180 // fNClsDet->Write();
182 // fClsAmpDrift->Write();
184 // fClsAmpDist->Write();
185 // fSClsDist->Write();
188 // HLTInfo("Histogram file dumped");
192 if(!IsDataEvent())return 0;
194 const AliHLTComponentBlockData* iter = NULL;
195 Bool_t gotData = kFALSE;
196 AliHLTUInt32_t spec = 0;
198 for ( iter = GetFirstInputBlock(AliHLTTRDDefinitions::fgkClusterDataType);
199 iter != NULL; iter = GetNextInputBlock() ) {
201 HLTDebug("TClonesArray of clusters: nbEntries = %i", fClusterArray->GetEntriesFast());
203 fEvSize->Fill((iter->fSize+0.5f)/1024);
204 AliHLTTRDUtils::ReadClusters(fClusterArray, iter->fPtr, iter->fSize);
206 spec = iter->fSpecification;
209 if(!gotData) return 0;
211 Float_t sClusterCharge[540] = { 0 };
214 // loop over clusters
215 for(int i=0;i<fClusterArray->GetEntriesFast();i++) {
217 cls=(AliTRDcluster*)fClusterArray->At(i);
219 fNClsDet->Fill(cls->GetDetector());
220 fClsAmp->Fill(cls->GetQ());
222 int tb = cls->GetPadTime();
224 if (tb > 5 && tb <25){
225 fClsAmpDrift->Fill(cls->GetQ());
228 //fClsAmpDriftDet[cls->GetDetector()]->Fill(cls->GetQ());
230 Int_t det = cls->GetDetector();
231 sClusterCharge[det] += cls->GetQ();
235 fClusterArray->Delete();
237 //fClsAmpDist->Reset();
238 //Int_t nSClusters = 0;
239 for(int det=0; det<540; det++) {
240 // if (fClsAmpDriftDet[det]->GetSum() > 0)
241 // fClsAmpDist->Fill(fClsAmpDriftDet[det]->GetMean());
242 if(sClusterCharge[det])
243 fSClsDist->Fill(sClusterCharge[det]);
246 //fNScls->Fill(nSClusters);
248 PushBack((TObject*)fNClsDet, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, spec);
249 PushBack((TObject*)fClsAmp, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, spec);
250 PushBack((TObject*)fClsAmpDrift, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, spec);
251 PushBack((TObject*)fClsTB, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, spec);
252 //PushBack((TObject*)fClsAmpDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, spec);
253 //PushBack((TObject*)fNScls, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, spec);
254 PushBack((TObject*)fSClsDist, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, spec);
255 PushBack((TObject*)fEvSize, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, spec);
260 int AliHLTTRDClusterHistoComponent::Configure(const char* arguments){
262 if (!arguments) return iResult;
264 TString allArgs=arguments;
268 TObjArray* pTokens=allArgs.Tokenize(" ");
270 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
271 argument=((TObjString*)pTokens->At(i))->GetString();
272 if (argument.IsNull()) continue;
274 if (argument.CompareTo("output_size")==0) {
275 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
276 HLTInfo("Setting output size to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
277 fOutputSize=((TObjString*)pTokens->At(i))->GetString().Atoi();
281 HLTError("unknown argument: %s", argument.Data());
289 HLTError("missing parameter for argument %s", argument.Data());