Line data Source code
1 : // $Id$
2 :
3 : //**************************************************************************
4 : //* This file is property of and copyright by the ALICE HLT Project *
5 : //* ALICE Experiment at CERN, All rights reserved. *
6 : //* *
7 : //* Primary Authors: Per-Ivar Lønne <ploenne@cern.ch> *
8 : //* for The ALICE HLT Project. *
9 : //* *
10 : //* Permission to use, copy, modify and distribute this software and its *
11 : //* documentation strictly for non-commercial purposes is hereby granted *
12 : //* without fee, provided that the above copyright notice appears in all *
13 : //* copies and that both the copyright notice and this permission notice *
14 : //* appear in the supporting documentation. The authors make no claims *
15 : //* about the suitability of this software for any purpose. It is *
16 : //* provided "as is" without express or implied warranty. *
17 : //**************************************************************************/
18 :
19 : /// @file AliHLTTPCdEdxMonitoringComponent.cxx
20 : /// @author Per-Ivar Lønne, Jochen Thaeder, Matthias Richter, Alexander Kalweit
21 : /// @date 21.08.2011
22 : /// @brief Component for reading ESD from chain and produce a dEdx monitoring plot
23 : ///
24 :
25 : #include "TSystem.h"
26 : #include "AliESDtrackCuts.h"
27 : #include <AliHLTDAQ.h>
28 : #include "AliESDEvent.h"
29 : #include "AliESDtrack.h"
30 : #include "AliLog.h"
31 : #include "TMap.h"
32 : #include "TObjString.h"
33 : #include "AliHLTDataTypes.h"
34 : #include "AliHLTComponentBenchmark.h"
35 : #include "TROOT.h"
36 : #include "TStyle.h"
37 : #include "TColor.h"
38 : #include "TH2F.h"
39 :
40 : #include "AliHLTTPCdEdxMonitoringComponent.h"
41 :
42 : using namespace std;
43 :
44 : /** ROOT macro for the implementation of ROOT specific class methods */
45 6 : ClassImp( AliHLTTPCdEdxMonitoringComponent )
46 :
47 : AliHLTTPCdEdxMonitoringComponent::AliHLTTPCdEdxMonitoringComponent()
48 : :
49 3 : AliHLTProcessor(),
50 3 : fESDTrackCuts(NULL),
51 3 : fHist(),
52 3 : fxbins(),
53 3 : fxmin(),
54 3 : fxmax(),
55 3 : fybins(),
56 3 : fymin(),
57 3 : fymax()
58 15 : {
59 : //Constructor
60 6 : }
61 :
62 : AliHLTTPCdEdxMonitoringComponent::~AliHLTTPCdEdxMonitoringComponent()
63 12 : {
64 : //Destructor
65 12 : }
66 :
67 : // ######################################################################### //
68 : const char* AliHLTTPCdEdxMonitoringComponent::GetComponentID()
69 : {
70 : // get component id
71 522 : return "TPCdEdxMonitoring";
72 : }
73 :
74 : // ######################################################################### //
75 : void AliHLTTPCdEdxMonitoringComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
76 : {
77 : // get list of input data types
78 0 : list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginAny);
79 0 : }
80 :
81 : // ######################################################################### //
82 : AliHLTComponentDataType AliHLTTPCdEdxMonitoringComponent::GetOutputDataType()
83 : {
84 : // get the output data size
85 0 : return kAliHLTDataTypeHistogram|kAliHLTDataOriginHLT;
86 : }
87 :
88 : // ######################################################################### //
89 : void AliHLTTPCdEdxMonitoringComponent::GetOutputDataSize( unsigned long& constBase, Double_t& inputMultiplier )
90 : {
91 : // get output size estimator
92 0 : constBase = 4096;
93 0 : inputMultiplier = 0;
94 0 : }
95 :
96 : // ######################################################################### //
97 : void AliHLTTPCdEdxMonitoringComponent::GetOCDBObjectDescription( TMap* const targetMap)
98 : {
99 : // Get a list of OCDB object description.
100 : // The list of objects is provided in a TMap
101 : // - key: complete OCDB path, e.g. GRP/GRP/Data
102 : // - value: short description why the object is needed
103 : // Key and value objects created inside this class go into ownership of
104 : // target TMap.
105 :
106 0 : if (!targetMap) return;
107 0 : targetMap->Add(new TObjString("HLT/ConfigTPC/TPCdEdxMonitoring"),
108 0 : new TObjString("configuration object"));
109 0 : targetMap->Add(new TObjString("GRP/GRP/Data"),
110 0 : new TObjString("GRP object"));
111 :
112 0 : }
113 :
114 : // ######################################################################### //
115 : AliHLTComponent* AliHLTTPCdEdxMonitoringComponent::Spawn()
116 : {
117 : // Spawn function, return new class instance
118 0 : return new AliHLTTPCdEdxMonitoringComponent;
119 0 : }
120 :
121 : // ######################################################################### //
122 : Int_t AliHLTTPCdEdxMonitoringComponent::DoInit( Int_t argc, const char** argv )
123 : {
124 : // init the component
125 : Int_t iResult=0;
126 0 : fESDTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","HLT");
127 :
128 0 : fxbins=Int_t(300);
129 0 : fxmin=Double_t(-2);
130 0 : fxmax=Double_t(2);
131 0 : fybins=Int_t(500);
132 0 : fymin=Double_t(0);
133 0 : fymax=Double_t(500);
134 :
135 0 : if (!fESDTrackCuts)
136 : {
137 : iResult=-ENOMEM;
138 0 : }
139 :
140 0 : if (iResult<0)
141 : {
142 0 : if (fESDTrackCuts)
143 0 : delete fESDTrackCuts;
144 0 : fESDTrackCuts = NULL;
145 0 : }
146 :
147 0 : if (iResult>=0)
148 : {
149 0 : SetDefaultConfiguration();
150 0 : TString cdbPath="HLT/ConfigTPC/";
151 0 : cdbPath+=GetComponentID();
152 0 : iResult=ConfigureFromCDBTObjString(cdbPath);
153 :
154 :
155 0 : if (iResult>=0)
156 : {
157 0 : iResult=ConfigureFromArgumentString(argc, argv);
158 0 : }
159 0 : }
160 :
161 0 : if (iResult>=0) {
162 0 : HLTInfo("ESD track cuts : %s",fESDTrackCuts->GetTitle() );
163 : }
164 0 : fHist = new TH2F("hHLT", "HLT", fxbins, fxmin, fxmax, fybins, fymin, fymax);
165 0 : fHist->GetXaxis()->SetTitle("momentum/charge #frac{p}{z} (GeV/c)");
166 0 : fHist->GetYaxis()->SetTitle("dE/dx in TPC (a.u.)");
167 0 : Plotstyle();
168 0 : return iResult;
169 0 : }
170 :
171 :
172 : // ######################################################################### //
173 : Int_t AliHLTTPCdEdxMonitoringComponent::DoDeinit()
174 : {
175 : // component cleanup, delete all instances of helper classes here
176 0 : if (fESDTrackCuts)
177 0 : delete fESDTrackCuts;
178 0 : fESDTrackCuts = NULL;
179 0 : if (fHist)
180 0 : delete fHist;
181 0 : fHist=NULL;
182 0 : return 0;
183 : }
184 :
185 :
186 : // ######################################################################### //
187 : Int_t AliHLTTPCdEdxMonitoringComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
188 : AliHLTComponentTriggerData& /*trigData*/)
189 : {
190 : // event processing function
191 : float sig;
192 : Double_t ptot;
193 :
194 : // check if this is a data event, there are a couple of special events
195 : // which should be ignored for normal processing
196 0 : if (!IsDataEvent()) return 0;
197 :
198 0 : const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
199 :
200 : // input objects are not supposed to be changed by the component, so they
201 : // are defined const. However, the implementation of AliESDEvent does not
202 : // support this and we need the const_cast
203 0 : AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
204 0 : if (esd != NULL) {
205 0 : esd->GetStdContent();
206 0 : for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
207 0 : AliESDtrack* track = esd->GetTrack(i);
208 0 : sig=track->GetTPCsignal();
209 0 : if(!fESDTrackCuts->AcceptTrack(track)) continue;
210 0 : if (!track->GetInnerParam()) continue;
211 0 : ptot = track->GetInnerParam()->GetP()*track->GetSign();
212 0 : fHist->Fill(ptot, sig);
213 0 : }
214 0 : }
215 : // publish the histogram
216 0 : PushBack(fHist, kAliHLTDataTypeHistogram | kAliHLTDataOriginHLT);
217 :
218 : return 0;
219 0 : }
220 :
221 : // ######################################################################### //
222 : Int_t AliHLTTPCdEdxMonitoringComponent::ScanConfigurationArgument(Int_t argc, const char** argv)
223 : {
224 : // Scan configuration arguments
225 : // Return the number of processed arguments
226 : // -EPROTO if argument format error (e.g. number expected but not found)
227 : //
228 : // The AliHLTComponent base class implements a parsing loop for argument strings and
229 : // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
230 : // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
231 :
232 0 : if (argc<=0) return 0;
233 : Int_t ii =0;
234 0 : TString argument=argv[ii];
235 :
236 0 : if (argument.IsNull()) return 0;
237 :
238 0 : if( !fESDTrackCuts){
239 0 : HLTError("No ESD track cuts availible");
240 0 : return -ENOMEM;
241 : }
242 :
243 :
244 : //**********************************//
245 : // Histogram Binning //
246 : //**********************************//
247 :
248 :
249 : // -xbins
250 0 : if (argument.CompareTo("-xbins")==0)
251 : {
252 0 : if (++ii>=argc) return -EPROTO;
253 0 : argument=argv[ii];
254 :
255 0 : fxbins = argument.Atoi();
256 :
257 0 : return 2;
258 : }
259 :
260 : // -xmin
261 0 : if (argument.CompareTo("-xmin")==0)
262 : {
263 0 : if (++ii>=argc) return -EPROTO;
264 0 : argument=argv[ii];
265 :
266 0 : fxmin = argument.Atoi();
267 :
268 0 : return 2;
269 : }
270 :
271 0 : if (argument.CompareTo("-xmax")==0)
272 : {
273 0 : if (++ii>=argc) return -EPROTO;
274 0 : argument=argv[ii];
275 :
276 0 : fxmax = argument.Atoi();
277 :
278 0 : return 2;
279 : }
280 :
281 : // -xbins
282 0 : if (argument.CompareTo("-ybins")==0)
283 : {
284 0 : if (++ii>=argc) return -EPROTO;
285 0 : argument=argv[ii];
286 :
287 0 : fybins = argument.Atoi();
288 :
289 0 : return 2;
290 : }
291 :
292 : // -xmin
293 0 : if (argument.CompareTo("-ymin")==0)
294 : {
295 0 : if (++ii>=argc) return -EPROTO;
296 0 : argument=argv[ii];
297 :
298 0 : fymin = argument.Atoi();
299 :
300 0 : return 2;
301 : }
302 :
303 0 : if (argument.CompareTo("-ymax")==0)
304 : {
305 0 : if (++ii>=argc) return -EPROTO;
306 0 : argument=argv[ii];
307 :
308 0 : fymax = argument.Atoi();
309 :
310 0 : return 2;
311 : }
312 :
313 :
314 : //**********************************//
315 : // Track Cuts //
316 : //**********************************//
317 :
318 : // -maxpt
319 0 : if (argument.CompareTo("-maxpt")==0) {
320 0 : if (++ii>=argc) return -EPROTO;
321 0 : argument=argv[ii];
322 :
323 0 : Float_t minPt, maxPt;
324 0 : fESDTrackCuts->GetPtRange(minPt,maxPt);
325 0 : maxPt = argument.Atof();
326 0 : fESDTrackCuts->SetPtRange(minPt,maxPt);
327 :
328 0 : TString title = fESDTrackCuts->GetTitle();
329 0 : if (!title.CompareTo("No track cuts")) title = "";
330 0 : else title += " && ";
331 0 : title += Form("p_t < %f", maxPt);
332 0 : fESDTrackCuts->SetTitle(title);
333 : return 2;
334 0 : }
335 :
336 : // -minpt
337 0 : if (argument.CompareTo("-minpt")==0) {
338 0 : if (++ii>=argc) return -EPROTO;
339 0 : argument=argv[ii];
340 :
341 0 : Float_t minPt, maxPt;
342 0 : fESDTrackCuts->GetPtRange(minPt,maxPt);
343 0 : minPt = argument.Atof();
344 0 : fESDTrackCuts->SetPtRange(minPt,maxPt);
345 :
346 0 : TString title = fESDTrackCuts->GetTitle();
347 0 : if (!title.CompareTo("No track cuts")) title = "";
348 0 : else title += " && ";
349 0 : title += Form("p_t > %f", minPt);
350 0 : fESDTrackCuts->SetTitle(title);
351 : return 2;
352 0 : }
353 :
354 : // -min-ldca
355 : // minimum longitudinal dca to vertex
356 0 : if (argument.CompareTo("-min-ldca")==0) {
357 0 : if (++ii>=argc) return -EPROTO;
358 0 : argument=argv[ii];
359 :
360 0 : fESDTrackCuts->SetMinDCAToVertexZ(argument.Atof());
361 0 : TString title = fESDTrackCuts->GetTitle();
362 0 : if (!title.CompareTo("No track cuts")) title = "";
363 0 : else title += " && ";
364 0 : title += Form("DCAz > %f", argument.Atof());
365 0 : fESDTrackCuts->SetTitle(title);
366 : return 2;
367 0 : }
368 :
369 : // -max-ldca
370 : // maximum longitudinal dca to vertex
371 0 : if (argument.CompareTo("-max-ldca")==0) {
372 0 : if (++ii>=argc) return -EPROTO;
373 0 : argument=argv[ii];
374 :
375 0 : fESDTrackCuts->SetMaxDCAToVertexZ(argument.Atof());
376 0 : TString title = fESDTrackCuts->GetTitle();
377 0 : if (!title.CompareTo("No track cuts")) title = "";
378 0 : else title += " && ";
379 0 : title += Form("DCAz < %f", argument.Atof());
380 0 : fESDTrackCuts->SetTitle(title);
381 : return 2;
382 0 : }
383 :
384 : // -min-tdca
385 : // minimum transverse dca to vertex
386 0 : if (argument.CompareTo("-min-tdca")==0) {
387 0 : if (++ii>=argc) return -EPROTO;
388 0 : argument=argv[ii];
389 :
390 0 : fESDTrackCuts->SetMinDCAToVertexXY(argument.Atof());
391 0 : TString title = fESDTrackCuts->GetTitle();
392 0 : if (!title.CompareTo("No track cuts")) title = "";
393 0 : else title += " && ";
394 0 : title += Form("DCAr > %f", argument.Atof());
395 0 : fESDTrackCuts->SetTitle(title);
396 : return 2;
397 0 : }
398 :
399 : // -max-tdca
400 : // maximum transverse dca to vertex
401 0 : if (argument.CompareTo("-max-tdca")==0) {
402 0 : if (++ii>=argc) return -EPROTO;
403 0 : argument=argv[ii];
404 :
405 0 : fESDTrackCuts->SetMaxDCAToVertexXY(argument.Atof());
406 0 : TString title = fESDTrackCuts->GetTitle();
407 0 : if (!title.CompareTo("No track cuts")) title = "";
408 0 : else title += " && ";
409 0 : title += Form("DCAr < %f", argument.Atof());
410 0 : fESDTrackCuts->SetTitle(title);
411 : return 2;
412 0 : }
413 :
414 : // -etarange
415 : // +/- eta
416 0 : if (argument.CompareTo("-etarange")==0) {
417 0 : if (++ii>=argc) return -EPROTO;
418 0 : argument=argv[ii];
419 0 : Float_t eta = argument.Atof();
420 :
421 0 : fESDTrackCuts->SetEtaRange(-eta,eta);
422 0 : TString title = fESDTrackCuts->GetTitle();
423 0 : if (!title.CompareTo("No track cuts")) title = "";
424 0 : else title += " && ";
425 0 : title += Form("Eta[%f,%f]", argument.Atof(),argument.Atof());
426 0 : fESDTrackCuts->SetTitle(title);
427 : return 2;
428 0 : }
429 :
430 : // -minNClsTPC
431 : // minimum clusters in TPC
432 0 : if (argument.CompareTo("-minNClsTPC")==0) {
433 0 : if (++ii>=argc) return -EPROTO;
434 0 : argument=argv[ii];
435 :
436 : Int_t ncls;
437 0 : ncls = Int_t(argument.Atof());
438 0 : fESDTrackCuts->SetMinNClustersTPC(ncls);
439 :
440 0 : TString title = fESDTrackCuts->GetTitle();
441 0 : if (!title.CompareTo("No track cuts")) title = "";
442 0 : else title += " && ";
443 0 : title += Form("minNClsTPC < %i", ncls);
444 0 : fESDTrackCuts->SetTitle(title);
445 : return 2;
446 0 : }
447 :
448 :
449 :
450 : // unknown argument
451 0 : return -EINVAL;
452 :
453 : return 0;
454 :
455 0 : }
456 :
457 : // ######################################################################### //
458 : Int_t AliHLTTPCdEdxMonitoringComponent::Reconfigure(const char* cdbEntry, const char* chainId)
459 : {
460 : // reconfigure the component from the specified CDB entry, or default CDB entry
461 0 : HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
462 :
463 : Int_t iResult=0;
464 0 : TString cdbPath;
465 0 : if (cdbEntry)
466 : {
467 0 : cdbPath=cdbEntry;
468 : } else {
469 0 : cdbPath="HLT/ConfigTPC/";
470 0 : cdbPath+=GetComponentID();
471 : }
472 :
473 0 : iResult=ConfigureFromCDBTObjString(cdbPath); //// Or use return 0, and skip this line?
474 :
475 : return iResult;
476 0 : }
477 :
478 : // ######################################################################### //
479 : Int_t AliHLTTPCdEdxMonitoringComponent::ReadPreprocessorValues(const char* modules)
480 : {
481 : // read the preprocessor values for the detectors in the modules list
482 : Int_t iResult=0;
483 0 : TString detectors(modules!=NULL?modules:"");
484 0 : HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
485 : return iResult; //Done differently in AliHLTMultiplicityCorrelationsComponent...
486 0 : }
487 :
488 :
489 :
490 : // ######################################################################### //
491 : void AliHLTTPCdEdxMonitoringComponent::SetDefaultConfiguration()
492 : {
493 0 : if (fESDTrackCuts)
494 : {
495 : //fESDTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
496 0 : fESDTrackCuts->SetEtaRange(-0.8,+0.8);
497 0 : fESDTrackCuts->SetPtRange(0.15,1e10);
498 : // 2011-10-28 investigation by Per Ivar and Alexander
499 : // the following cuts are not needed
500 : /*
501 : fESDTrackCuts->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2); // BEWARE STANDARD VALUES ARE: 2, 2, 0.5, 0.5, 2
502 : fESDTrackCuts->SetMaxNsigmaToVertex(3);
503 : fESDTrackCuts->SetRequireSigmaToVertex(kTRUE);
504 : */
505 0 : fESDTrackCuts->SetAcceptKinkDaughters(kFALSE);
506 0 : fESDTrackCuts->SetMinNClustersTPC(70);
507 0 : fESDTrackCuts->SetMaxChi2PerClusterTPC(4);
508 0 : fESDTrackCuts->SetMaxDCAToVertexXY(3);
509 0 : fESDTrackCuts->SetMaxDCAToVertexZ(3);
510 0 : fESDTrackCuts->SetRequireTPCRefit(kTRUE);
511 : //fESDTrackCuts->SetRequireITSRefit(kTRUE); //Kills HLT simulated reconstructions?
512 : // 2011-10-28 investigation by Per Ivar and Alexander
513 : // those cuts remove all data points because the filling is different in the
514 : // HLT, needs further investigation
515 : /*
516 : fESDTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); //TEMPORARY <-> REMOVE
517 : fESDTrackCuts->SetMinNClustersITS(3);
518 : */
519 :
520 0 : }
521 0 : fxbins=300;
522 0 : fxmin=-2;
523 0 : fxmax=2;
524 0 : fybins=500;
525 0 : fymin=0;
526 0 : fymax=500;
527 0 : return;
528 : }
529 :
530 :
531 :
532 : // ######################################################################### //
533 : void AliHLTTPCdEdxMonitoringComponent::Plotstyle()
534 : {
535 0 : gROOT->SetStyle("Plain");
536 :
537 0 : gStyle->SetCanvasBorderMode(0);
538 0 : gStyle->SetCanvasColor(10);
539 0 : gStyle->SetCanvasDefH(550);
540 0 : gStyle->SetCanvasDefW(575);
541 0 : gStyle->SetPadBorderMode(0);
542 0 : gStyle->SetPadColor(10);
543 0 : gStyle->SetPadTickX(1);
544 0 : gStyle->SetPadTickY(1);
545 0 : gStyle->SetStatColor(10);
546 0 : gStyle->SetFrameFillColor(10);
547 0 : gStyle->SetPalette(1,0);
548 :
549 : //
550 :
551 : //gStyle->SetStatX(0.7);
552 : //gStyle->SetStatW(0.2);
553 : //gStyle->SetLabelOffset(1.2);
554 : //gStyle->SetLabelFont(72);
555 : //gStyle->SetLabelSize(0.6);
556 : //gStyle->SetTitleOffset(1.2);
557 0 : gStyle->SetTitleFontSize(0.04);
558 :
559 :
560 0 : gStyle->SetOptStat(10);
561 0 : gStyle->SetLineWidth(2);
562 0 : gStyle->SetMarkerSize(1.0);
563 0 : gStyle->SetTextSize(0.04);
564 0 : gStyle->SetTitleSize(0.04,"xyz");
565 0 : gStyle->SetLabelSize(0.04,"xyz");
566 0 : gStyle->SetLabelOffset(0.02,"xyz");
567 0 : gStyle->SetLabelFont(42,"xyz");
568 0 : gStyle->SetTitleOffset(1.3,"x");
569 0 : gStyle->SetTitleOffset(1.6,"y");
570 0 : gStyle->SetTitleOffset(1.6,"z");
571 0 : gStyle->SetTitleFont(42,"xyz");
572 0 : gStyle->SetTitleColor(1,"xyz");
573 : //gStyle->SetPadTopMargin(0.1);
574 : //gStyle->SetPadRightMargin(0.1);
575 0 : gStyle->SetPadBottomMargin(0.2);
576 0 : gStyle->SetPadLeftMargin(0.2);
577 :
578 :
579 : const Int_t NCont=255;
580 : const Int_t NRGBs = 5;
581 0 : Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
582 0 : Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
583 0 : Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
584 0 : Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
585 0 : TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
586 0 : gStyle->SetNumberContours(NCont);
587 0 : }
|