3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Per-Ivar Lønne <ploenne@cern.ch> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************/
19 /// @file AliHLTTPCdEdxMonitoringComponent.cxx
20 /// @author Per-Ivar Lønne, Jochen Thaeder, Matthias Richter, Alexander Kalweit
22 /// @brief Component for reading ESD from chain and produce a dEdx monitoring plot
26 #include "AliESDtrackCuts.h"
27 #include <AliHLTDAQ.h>
28 #include "AliESDEvent.h"
29 #include "AliESDtrack.h"
32 #include "TObjString.h"
33 #include "AliHLTDataTypes.h"
34 #include "AliHLTComponentBenchmark.h"
40 #include "AliHLTTPCdEdxMonitoringComponent.h"
44 /** ROOT macro for the implementation of ROOT specific class methods */
45 ClassImp( AliHLTTPCdEdxMonitoringComponent )
47 AliHLTTPCdEdxMonitoringComponent::AliHLTTPCdEdxMonitoringComponent()
62 AliHLTTPCdEdxMonitoringComponent::~AliHLTTPCdEdxMonitoringComponent()
67 // ######################################################################### //
68 const char* AliHLTTPCdEdxMonitoringComponent::GetComponentID()
71 return "TPCdEdxMonitoring";
74 // ######################################################################### //
75 void AliHLTTPCdEdxMonitoringComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
77 // get list of input data types
78 list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginAny);
81 // ######################################################################### //
82 AliHLTComponentDataType AliHLTTPCdEdxMonitoringComponent::GetOutputDataType()
84 // get the output data size
85 return kAliHLTDataTypeHistogram|kAliHLTDataOriginHLT;
88 // ######################################################################### //
89 void AliHLTTPCdEdxMonitoringComponent::GetOutputDataSize( unsigned long& constBase, Double_t& inputMultiplier )
91 // get output size estimator
96 // ######################################################################### //
97 void AliHLTTPCdEdxMonitoringComponent::GetOCDBObjectDescription( TMap* const targetMap)
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
106 if (!targetMap) return;
107 targetMap->Add(new TObjString("HLT/ConfigTPC/TPCdEdxMonitoring"),
108 new TObjString("configuration object"));
109 targetMap->Add(new TObjString("GRP/GRP/Data"),
110 new TObjString("GRP object"));
114 // ######################################################################### //
115 AliHLTComponent* AliHLTTPCdEdxMonitoringComponent::Spawn()
117 // Spawn function, return new class instance
118 return new AliHLTTPCdEdxMonitoringComponent;
121 // ######################################################################### //
122 Int_t AliHLTTPCdEdxMonitoringComponent::DoInit( Int_t argc, const char** argv )
124 // init the component
126 fESDTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","HLT");
143 delete fESDTrackCuts;
144 fESDTrackCuts = NULL;
149 SetDefaultConfiguration();
150 TString cdbPath="HLT/ConfigTPC/";
151 cdbPath+=GetComponentID();
152 iResult=ConfigureFromCDBTObjString(cdbPath);
157 iResult=ConfigureFromArgumentString(argc, argv);
162 HLTInfo("ESD track cuts : %s",fESDTrackCuts->GetTitle() );
164 fHist = new TH2F("hHLT", "HLT", fxbins, fxmin, fxmax, fybins, fymin, fymax);
165 fHist->GetXaxis()->SetTitle("momentum/charge #frac{p}{z} (GeV/c)");
166 fHist->GetYaxis()->SetTitle("dE/dx in TPC (a.u.)");
172 // ######################################################################### //
173 Int_t AliHLTTPCdEdxMonitoringComponent::DoDeinit()
175 // component cleanup, delete all instances of helper classes here
177 delete fESDTrackCuts;
178 fESDTrackCuts = NULL;
186 // ######################################################################### //
187 Int_t AliHLTTPCdEdxMonitoringComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
188 AliHLTComponentTriggerData& /*trigData*/)
190 // event processing function
194 // check if this is a data event, there are a couple of special events
195 // which should be ignored for normal processing
196 if (!IsDataEvent()) return 0;
198 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
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 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
205 esd->GetStdContent();
206 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
207 AliESDtrack* track = esd->GetTrack(i);
208 sig=track->GetTPCsignal();
209 if(!fESDTrackCuts->AcceptTrack(track)) continue;
210 if (!track->GetInnerParam()) continue;
211 ptot = track->GetInnerParam()->GetP()*track->GetSign();
212 fHist->Fill(ptot, sig);
215 // publish the histogram
216 PushBack(fHist, kAliHLTDataTypeHistogram | kAliHLTDataOriginHLT);
221 // ######################################################################### //
222 Int_t AliHLTTPCdEdxMonitoringComponent::ScanConfigurationArgument(Int_t argc, const char** argv)
224 // Scan configuration arguments
225 // Return the number of processed arguments
226 // -EPROTO if argument format error (e.g. number expected but not found)
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.
232 if (argc<=0) return 0;
234 TString argument=argv[ii];
236 if (argument.IsNull()) return 0;
239 HLTError("No ESD track cuts availible");
244 //**********************************//
245 // Histogram Binning //
246 //**********************************//
250 if (argument.CompareTo("-xbins")==0)
252 if (++ii>=argc) return -EPROTO;
255 fxbins = argument.Atoi();
261 if (argument.CompareTo("-xmin")==0)
263 if (++ii>=argc) return -EPROTO;
266 fxmin = argument.Atoi();
271 if (argument.CompareTo("-xmax")==0)
273 if (++ii>=argc) return -EPROTO;
276 fxmax = argument.Atoi();
282 if (argument.CompareTo("-ybins")==0)
284 if (++ii>=argc) return -EPROTO;
287 fybins = argument.Atoi();
293 if (argument.CompareTo("-ymin")==0)
295 if (++ii>=argc) return -EPROTO;
298 fymin = argument.Atoi();
303 if (argument.CompareTo("-ymax")==0)
305 if (++ii>=argc) return -EPROTO;
308 fymax = argument.Atoi();
314 //**********************************//
316 //**********************************//
319 if (argument.CompareTo("-maxpt")==0) {
320 if (++ii>=argc) return -EPROTO;
323 Float_t minPt, maxPt;
324 fESDTrackCuts->GetPtRange(minPt,maxPt);
325 maxPt = argument.Atof();
326 fESDTrackCuts->SetPtRange(minPt,maxPt);
328 TString title = fESDTrackCuts->GetTitle();
329 if (!title.CompareTo("No track cuts")) title = "";
330 else title += " && ";
331 title += Form("p_t < %f", maxPt);
332 fESDTrackCuts->SetTitle(title);
337 if (argument.CompareTo("-minpt")==0) {
338 if (++ii>=argc) return -EPROTO;
341 Float_t minPt, maxPt;
342 fESDTrackCuts->GetPtRange(minPt,maxPt);
343 minPt = argument.Atof();
344 fESDTrackCuts->SetPtRange(minPt,maxPt);
346 TString title = fESDTrackCuts->GetTitle();
347 if (!title.CompareTo("No track cuts")) title = "";
348 else title += " && ";
349 title += Form("p_t > %f", minPt);
350 fESDTrackCuts->SetTitle(title);
355 // minimum longitudinal dca to vertex
356 if (argument.CompareTo("-min-ldca")==0) {
357 if (++ii>=argc) return -EPROTO;
360 fESDTrackCuts->SetMinDCAToVertexZ(argument.Atof());
361 TString title = fESDTrackCuts->GetTitle();
362 if (!title.CompareTo("No track cuts")) title = "";
363 else title += " && ";
364 title += Form("DCAz > %f", argument.Atof());
365 fESDTrackCuts->SetTitle(title);
370 // maximum longitudinal dca to vertex
371 if (argument.CompareTo("-max-ldca")==0) {
372 if (++ii>=argc) return -EPROTO;
375 fESDTrackCuts->SetMaxDCAToVertexZ(argument.Atof());
376 TString title = fESDTrackCuts->GetTitle();
377 if (!title.CompareTo("No track cuts")) title = "";
378 else title += " && ";
379 title += Form("DCAz < %f", argument.Atof());
380 fESDTrackCuts->SetTitle(title);
385 // minimum transverse dca to vertex
386 if (argument.CompareTo("-min-tdca")==0) {
387 if (++ii>=argc) return -EPROTO;
390 fESDTrackCuts->SetMinDCAToVertexXY(argument.Atof());
391 TString title = fESDTrackCuts->GetTitle();
392 if (!title.CompareTo("No track cuts")) title = "";
393 else title += " && ";
394 title += Form("DCAr > %f", argument.Atof());
395 fESDTrackCuts->SetTitle(title);
400 // maximum transverse dca to vertex
401 if (argument.CompareTo("-max-tdca")==0) {
402 if (++ii>=argc) return -EPROTO;
405 fESDTrackCuts->SetMaxDCAToVertexXY(argument.Atof());
406 TString title = fESDTrackCuts->GetTitle();
407 if (!title.CompareTo("No track cuts")) title = "";
408 else title += " && ";
409 title += Form("DCAr < %f", argument.Atof());
410 fESDTrackCuts->SetTitle(title);
416 if (argument.CompareTo("-etarange")==0) {
417 if (++ii>=argc) return -EPROTO;
419 Float_t eta = argument.Atof();
421 fESDTrackCuts->SetEtaRange(-eta,eta);
422 TString title = fESDTrackCuts->GetTitle();
423 if (!title.CompareTo("No track cuts")) title = "";
424 else title += " && ";
425 title += Form("Eta[%f,%f]", argument.Atof(),argument.Atof());
426 fESDTrackCuts->SetTitle(title);
431 // minimum clusters in TPC
432 if (argument.CompareTo("-minNClsTPC")==0) {
433 if (++ii>=argc) return -EPROTO;
437 ncls = Int_t(argument.Atof());
438 fESDTrackCuts->SetMinNClustersTPC(ncls);
440 TString title = fESDTrackCuts->GetTitle();
441 if (!title.CompareTo("No track cuts")) title = "";
442 else title += " && ";
443 title += Form("minNClsTPC < %i", ncls);
444 fESDTrackCuts->SetTitle(title);
457 // ######################################################################### //
458 Int_t AliHLTTPCdEdxMonitoringComponent::Reconfigure(const char* cdbEntry, const char* chainId)
460 // reconfigure the component from the specified CDB entry, or default CDB entry
461 HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
469 cdbPath="HLT/ConfigTPC/";
470 cdbPath+=GetComponentID();
473 iResult=ConfigureFromCDBTObjString(cdbPath); //// Or use return 0, and skip this line?
478 // ######################################################################### //
479 Int_t AliHLTTPCdEdxMonitoringComponent::ReadPreprocessorValues(const char* modules)
481 // read the preprocessor values for the detectors in the modules list
483 TString detectors(modules!=NULL?modules:"");
484 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
485 return iResult; //Done differently in AliHLTMultiplicityCorrelationsComponent...
490 // ######################################################################### //
491 void AliHLTTPCdEdxMonitoringComponent::SetDefaultConfiguration()
495 //fESDTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
496 fESDTrackCuts->SetEtaRange(-0.8,+0.8);
497 fESDTrackCuts->SetPtRange(0.15,1e10);
498 // 2011-10-28 investigation by Per Ivar and Alexander
499 // the following cuts are not needed
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);
505 fESDTrackCuts->SetAcceptKinkDaughters(kFALSE);
506 fESDTrackCuts->SetMinNClustersTPC(70);
507 fESDTrackCuts->SetMaxChi2PerClusterTPC(4);
508 fESDTrackCuts->SetMaxDCAToVertexXY(3);
509 fESDTrackCuts->SetMaxDCAToVertexZ(3);
510 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
516 fESDTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); //TEMPORARY <-> REMOVE
517 fESDTrackCuts->SetMinNClustersITS(3);
532 // ######################################################################### //
533 void AliHLTTPCdEdxMonitoringComponent::Plotstyle()
535 gROOT->SetStyle("Plain");
537 gStyle->SetCanvasBorderMode(0);
538 gStyle->SetCanvasColor(10);
539 gStyle->SetCanvasDefH(550);
540 gStyle->SetCanvasDefW(575);
541 gStyle->SetPadBorderMode(0);
542 gStyle->SetPadColor(10);
543 gStyle->SetPadTickX(1);
544 gStyle->SetPadTickY(1);
545 gStyle->SetStatColor(10);
546 gStyle->SetFrameFillColor(10);
547 gStyle->SetPalette(1,0);
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 gStyle->SetTitleFontSize(0.04);
560 gStyle->SetOptStat(10);
561 gStyle->SetLineWidth(2);
562 gStyle->SetMarkerSize(1.0);
563 gStyle->SetTextSize(0.04);
564 gStyle->SetTitleSize(0.04,"xyz");
565 gStyle->SetLabelSize(0.04,"xyz");
566 gStyle->SetLabelOffset(0.02,"xyz");
567 gStyle->SetLabelFont(42,"xyz");
568 gStyle->SetTitleOffset(1.3,"x");
569 gStyle->SetTitleOffset(1.6,"y");
570 gStyle->SetTitleOffset(1.6,"z");
571 gStyle->SetTitleFont(42,"xyz");
572 gStyle->SetTitleColor(1,"xyz");
573 //gStyle->SetPadTopMargin(0.1);
574 //gStyle->SetPadRightMargin(0.1);
575 gStyle->SetPadBottomMargin(0.2);
576 gStyle->SetPadLeftMargin(0.2);
579 const Int_t NCont=255;
580 const Int_t NRGBs = 5;
581 Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
582 Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
583 Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
584 Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
585 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
586 gStyle->SetNumberContours(NCont);