Line data Source code
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 AliHLTTRDTrackHistoComponent.cxx
18 : @author Raphaelle and Theodor
19 : @brief Component for ploting charge in clusters
20 : */
21 :
22 : #include <time.h>
23 :
24 : #include "AliHLTTRDTrackHistoComponent.h"
25 : #include "AliHLTTRDDefinitions.h"
26 : #include "AliCDBEntry.h"
27 : #include "AliCDBManager.h"
28 : #include <TFile.h>
29 : #include <TString.h>
30 : #include "TObjString.h"
31 : #include "TClonesArray.h"
32 : #include "TTimeStamp.h"
33 : #include "AliHLTTRDUtils.h"
34 : #include "TH1F.h"
35 : #include "AliTRDcluster.h"
36 : #include "AliTRDtrackV1.h"
37 : #include "AliTRDseedV1.h"
38 :
39 : //#include "AliHLTTRD.h"
40 : //#include <stdlib.h>
41 : //#include <cerrno>
42 :
43 : using namespace std;
44 :
45 : /** ROOT macro for the implementation of ROOT specific class methods */
46 6 : ClassImp(AliHLTTRDTrackHistoComponent)
47 :
48 : AliHLTTRDTrackHistoComponent::AliHLTTRDTrackHistoComponent()
49 3 : : AliHLTProcessor(),
50 3 : fOutputSize(100000),
51 3 : fSpec(0),
52 3 : fTracksArray(NULL),
53 3 : fClPerTrkl(NULL),
54 3 : fTrklPerTrk(NULL),
55 3 : fEvSize(NULL),
56 3 : fEtaDistrib(NULL),
57 3 : fPhiDistrib(NULL),
58 3 : fPtDistrib(NULL)
59 15 : {
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 6 : }
67 :
68 : AliHLTTRDTrackHistoComponent::~AliHLTTRDTrackHistoComponent()
69 12 : {
70 : // see header file for class documentation
71 12 : }
72 :
73 : // Public functions to implement AliHLTComponent's interface.
74 : // These functions are required for the registration process
75 :
76 : const char* AliHLTTRDTrackHistoComponent::GetComponentID()
77 : {
78 : // see header file for class documentation
79 :
80 120 : return "TRDTrackHisto";
81 : }
82 :
83 : void AliHLTTRDTrackHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
84 : {
85 : // see header file for class documentation
86 0 : list.clear();
87 0 : list.push_back( AliHLTTRDDefinitions::fgkTracksDataType );
88 0 : }
89 :
90 : AliHLTComponentDataType AliHLTTRDTrackHistoComponent::GetOutputDataType()
91 : {
92 : // see header file for class documentation
93 0 : return kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD;
94 :
95 : }
96 :
97 : void AliHLTTRDTrackHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
98 : {
99 : // see header file for class documentation
100 0 : constBase = fOutputSize;
101 0 : inputMultiplier = 0;
102 0 : }
103 :
104 : AliHLTComponent* AliHLTTRDTrackHistoComponent::Spawn()
105 : {
106 : // see header file for class documentation
107 0 : return new AliHLTTRDTrackHistoComponent;
108 0 : }
109 :
110 : int AliHLTTRDTrackHistoComponent::DoInit(int argc, const char** argv)
111 : {
112 : // Initialize histograms
113 : int iResult=0;
114 :
115 0 : TString configuration="";
116 0 : TString argument="";
117 0 : for (int i=0; i<argc && iResult>=0; i++) {
118 0 : argument=argv[i];
119 0 : if (!configuration.IsNull()) configuration+=" ";
120 0 : configuration+=argument;
121 : }
122 :
123 0 : if (!configuration.IsNull()) {
124 0 : iResult=Configure(configuration.Data());
125 0 : }
126 :
127 0 : fTracksArray = new TClonesArray("AliTRDtrackV1");
128 :
129 0 : fClPerTrkl = new TH1F("TrdClPerTrkl","Clusters per Tracklet", AliTRDseedV1::kNtb, -0.5, AliTRDseedV1::kNtb - 0.5);
130 0 : fTrklPerTrk = new TH1F("TrdTrklPerTrk","Tracklets per Track", 7, -0.5, 6.5);
131 0 : fEvSize = new TH1F("TrdTrEvSize", "Tracks size per event per ddl in kbyte", 512, 0, 512);
132 0 : fEtaDistrib = new TH1F("TrdTrEtaDistrib", "Eta distribution of tracks", 51, -1, 1);
133 0 : fPhiDistrib = new TH1F("TrdTrPhiDistrib", "Phi distribution of tracks", 63, 0, 6.3);
134 0 : fPtDistrib = new TH1F("TrdTrPtDistrib", "Pt distribution of tracks", 101, 0, 10);
135 : return 0;
136 0 : }
137 :
138 : int AliHLTTRDTrackHistoComponent::DoDeinit()
139 : {
140 : // see header file for class documentation
141 :
142 0 : fTracksArray->Delete();
143 0 : delete fTracksArray;
144 :
145 : // delete histograms
146 0 : if (fClPerTrkl) delete fClPerTrkl;
147 0 : if (fTrklPerTrk) delete fTrklPerTrk;
148 :
149 0 : return 0;
150 : }
151 :
152 : int AliHLTTRDTrackHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
153 : AliHLTComponentTriggerData& /*trigData*/)
154 : {
155 :
156 : // if (GetFirstInputBlock(kAliHLTDataTypeSOR)) return 0;
157 : // else if (GetFirstInputBlock(kAliHLTDataTypeEOR))
158 : // {
159 : // TString fileName="/tmp/TracksHistoDump_run";
160 : // fileName+=AliCDBManager::Instance()->GetRun();
161 : // fileName+=".root";
162 : // HLTInfo("Dumping Histogram file to %s",fileName.Data());
163 : // TFile* file = TFile::Open(fileName, "RECREATE");
164 : // fClPerTrkl->Write();
165 : // fTrklPerTrk->Write();
166 : // file->Close();
167 : // HLTInfo("Histogram file dumped");
168 : // return 0;
169 : // }
170 :
171 0 : if(!IsDataEvent())return 0;
172 :
173 : const AliHLTComponentBlockData* iter = NULL;
174 : Bool_t gotData = kFALSE;
175 :
176 0 : for(iter = GetFirstInputBlock(AliHLTTRDDefinitions::fgkTracksDataType);
177 0 : iter != NULL; iter = GetNextInputBlock() ) {
178 :
179 0 : fEvSize->Fill((iter->fSize+0.5f)/1024);
180 0 : AliHLTTRDUtils::ReadTracks(fTracksArray, iter->fPtr, iter->fSize);
181 : HLTDebug("TClonesArray of tracks: nbEntries = %i", fTracksArray->GetEntriesFast());
182 : gotData=kTRUE;
183 0 : fSpec |= iter->fSpecification;
184 : }
185 :
186 0 : if(!gotData) return 0;
187 :
188 : AliTRDtrackV1 *trk;
189 :
190 : // loop over tracks
191 0 : for(int i=0;i<fTracksArray->GetEntriesFast();i++) {
192 0 : trk=(AliTRDtrackV1*)fTracksArray->At(i);
193 0 : fEtaDistrib->Fill(trk->Eta());
194 0 : fPhiDistrib->Fill(trk->Phi());
195 0 : fPtDistrib->Fill(trk->Pt());
196 : Int_t nrOfTrkls=0;
197 0 : for(int seedNr=0; seedNr<6; seedNr++){
198 0 : AliTRDseedV1* seed = trk->GetTracklet(seedNr);
199 0 : if(!seed)continue;
200 0 : nrOfTrkls++;
201 : Int_t nrOfCls=0;
202 0 : for(int clsNr=0; clsNr<AliTRDseedV1::kNtb; clsNr++)
203 0 : if(seed->GetClusters(clsNr))nrOfCls++;
204 0 : fClPerTrkl->Fill(nrOfCls);
205 0 : }
206 0 : fTrklPerTrk->Fill(nrOfTrkls);
207 : }
208 :
209 0 : fTracksArray->Delete();
210 :
211 0 : PushBack((TObject*)fClPerTrkl, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
212 0 : PushBack((TObject*)fTrklPerTrk, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
213 0 : PushBack((TObject*)fEvSize, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
214 0 : PushBack((TObject*)fEtaDistrib, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
215 0 : PushBack((TObject*)fPhiDistrib, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
216 0 : PushBack((TObject*)fPtDistrib, kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, fSpec);
217 :
218 : return 0;
219 0 : }
220 :
221 : int AliHLTTRDTrackHistoComponent::Configure(const char* arguments){
222 : int iResult=0;
223 0 : if (!arguments) return iResult;
224 :
225 0 : TString allArgs=arguments;
226 0 : TString argument;
227 : int bMissingParam=0;
228 :
229 0 : TObjArray* pTokens=allArgs.Tokenize(" ");
230 0 : if (pTokens) {
231 0 : for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
232 0 : argument=((TObjString*)pTokens->At(i))->GetString();
233 0 : if (argument.IsNull()) continue;
234 :
235 0 : if (argument.CompareTo("output_size")==0) {
236 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
237 0 : HLTInfo("Setting output size to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
238 0 : fOutputSize=((TObjString*)pTokens->At(i))->GetString().Atoi();
239 0 : continue;
240 : }
241 0 : if (argument.CompareTo("-everyNevent")==0) {
242 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
243 0 : HLTInfo("Option -everyNevent depreceated");
244 : continue;
245 : }
246 : else {
247 0 : HLTError("unknown argument: %s", argument.Data());
248 : iResult=-EINVAL;
249 0 : break;
250 : }
251 : }
252 0 : delete pTokens;
253 : }
254 0 : if (bMissingParam) {
255 0 : HLTError("missing parameter for argument %s", argument.Data());
256 : iResult=-EINVAL;
257 0 : }
258 : return iResult;
259 0 : }
|