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()
60 // see header file for class documentation
62 // refer to README to build package
64 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
68 AliHLTTRDClusterHistoComponent::~AliHLTTRDClusterHistoComponent()
70 // see header file for class documentation
73 // Public functions to implement AliHLTComponent's interface.
74 // These functions are required for the registration process
76 const char* AliHLTTRDClusterHistoComponent::GetComponentID()
78 // see header file for class documentation
80 return "TRDClusterHisto";
83 void AliHLTTRDClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
85 // see header file for class documentation
87 list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
90 AliHLTComponentDataType AliHLTTRDClusterHistoComponent::GetOutputDataType()
92 // see header file for class documentation
93 return kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD;
97 void AliHLTTRDClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
99 // see header file for class documentation
100 constBase = fOutputSize;
104 AliHLTComponent* AliHLTTRDClusterHistoComponent::Spawn()
106 // see header file for class documentation
107 return new AliHLTTRDClusterHistoComponent;
110 int AliHLTTRDClusterHistoComponent::DoInit(int argc, const char** argv)
112 // Initialize histograms
115 TString configuration="";
117 for (int i=0; i<argc && iResult>=0; i++) {
119 if (!configuration.IsNull()) configuration+=" ";
120 configuration+=argument;
123 if (!configuration.IsNull()) {
124 iResult=Configure(configuration.Data());
127 fClusterArray = new TClonesArray("AliTRDcluster");
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);
136 fEvSize = new TH1F("TrdClEvSize", "Clusters size per event per ddl in kbyte", 512, 0, 512);
138 for(int i=0; i<540; i++) {
139 fClsAmpDriftDet[i] = new TH1F(Form("trdClsDriftDet_%d",i), "", 200, -0.5, 199.5);
145 int AliHLTTRDClusterHistoComponent::DoDeinit()
147 // see header file for class documentation
149 fClusterArray->Delete();
150 delete fClusterArray;
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;
158 if (fSClsDist) delete fSClsDist;
159 if (fNScls) delete fNScls;
160 if (fEvSize) delete fEvSize;
162 for(int i=0; i<540; i++){
163 if (fClsAmpDriftDet[i]) delete fClsAmpDriftDet[i];
169 int AliHLTTRDClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
170 AliHLTComponentTriggerData& /*trigData*/)
173 // if (GetFirstInputBlock(kAliHLTDataTypeSOR)) return 0;
174 // else if (GetFirstInputBlock(kAliHLTDataTypeEOR))
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();
183 // fClsAmpDrift->Write();
185 // fClsAmpDist->Write();
186 // fSClsDist->Write();
189 // HLTInfo("Histogram file dumped");
193 if(!IsDataEvent())return 0;
195 const AliHLTComponentBlockData* iter = NULL;
196 Bool_t gotData = kFALSE;
198 for ( iter = GetFirstInputBlock(AliHLTTRDDefinitions::fgkClusterDataType);
199 iter != NULL; iter = GetNextInputBlock() ) {
201 fEvSize->Fill((iter->fSize+0.5f)/1024);
202 AliHLTTRDUtils::ReadClusters(fClusterArray, iter->fPtr, iter->fSize);
203 HLTDebug("TClonesArray of clusters: nbEntries = %i", fClusterArray->GetEntriesFast());
205 fSpec |= iter->fSpecification;
208 if(!gotData) return 0;
210 Float_t sClusterCharge[540] = { 0 };
213 // loop over clusters
214 for(int i=0;i<fClusterArray->GetEntriesFast();i++) {
216 cls=(AliTRDcluster*)fClusterArray->At(i);
218 fNClsDet->Fill(cls->GetDetector());
219 fClsAmp->Fill(cls->GetQ());
221 int tb = cls->GetPadTime();
223 if (tb > 5 && tb <25){
224 fClsAmpDrift->Fill(cls->GetQ());
227 //fClsAmpDriftDet[cls->GetDetector()]->Fill(cls->GetQ());
229 Int_t det = cls->GetDetector();
230 sClusterCharge[det] += cls->GetQ();
234 fClusterArray->Delete();
236 //fClsAmpDist->Reset();
237 //Int_t nSClusters = 0;
238 for(int det=0; det<540; det++) {
239 // if (fClsAmpDriftDet[det]->GetSum() > 0)
240 // fClsAmpDist->Fill(fClsAmpDriftDet[det]->GetMean());
241 if(sClusterCharge[det])
242 fSClsDist->Fill(sClusterCharge[det]);
245 //fNScls->Fill(nSClusters);
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);
259 int AliHLTTRDClusterHistoComponent::Configure(const char* arguments){
261 if (!arguments) return iResult;
263 TString allArgs=arguments;
267 TObjArray* pTokens=allArgs.Tokenize(" ");
269 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
270 argument=((TObjString*)pTokens->At(i))->GetString();
271 if (argument.IsNull()) continue;
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();
280 HLTError("unknown argument: %s", argument.Data());
288 HLTError("missing parameter for argument %s", argument.Data());