FairRoot/PandaRoot
Public Member Functions | Private Member Functions | List of all members
PndPidEmcAssociatorTask Class Reference

#include <PndPidEmcAssociatorTask.h>

Inheritance diagram for PndPidEmcAssociatorTask:
PndPidMvaAssociatorTask

Public Member Functions

 PndPidEmcAssociatorTask ()
 
 PndPidEmcAssociatorTask (char const *name)
 
virtual ~PndPidEmcAssociatorTask ()
 Destructor. More...
 
virtual void Exec (Option_t *option)
 
virtual InitStatus Init ()
 
void Register ()
 
void Reset ()
 
void SetVerbose (Bool_t verb)
 
virtual void SetParContainers ()
 
virtual void Finish ()
 
void SetClassNames (std::vector< std::string > const &clNames)
 
void SetWeightFileName (std::string const &wFileName)
 
void SetClassifier (Mva_MethodType const &methodT)
 
void SetClassifier (std::string const &methodName)
 
void SetNumNeigh (size_t val)
 
void SetKnnEventParams (float scFact, double weight)
 

Private Member Functions

 PndPidEmcAssociatorTask (PndPidMvaAssociatorTask const &other)
 
PndPidEmcAssociatorTaskoperator= (PndPidMvaAssociatorTask const &other)
 
void SetVarNames (std::vector< std::string > const &vNames)
 Set Variables to use. More...
 
std::vector< std::string > const * SetEmcParNames () const
 Set Emc related variable names. More...
 
 ClassDef (PndPidEmcAssociatorTask, 0)
 

Detailed Description

Definition at line 16 of file PndPidEmcAssociatorTask.h.

Constructor & Destructor Documentation

PndPidEmcAssociatorTask::PndPidEmcAssociatorTask ( )

Default Constructor.

Definition at line 19 of file PndPidEmcAssociatorTask.cxx.

References SetEmcParNames(), and SetVarNames().

20  : PndPidMvaAssociatorTask("PndPidMvaAssociatorTaskSTD")
21 {
22  std::vector<std::string> const* vNames = SetEmcParNames();
23  SetVarNames(*vNames);
24  delete vNames;
25 }
std::vector< std::string > const * SetEmcParNames() const
Set Emc related variable names.
void SetVarNames(std::vector< std::string > const &vNames)
Set Variables to use.
PndPidEmcAssociatorTask::PndPidEmcAssociatorTask ( char const *  name)

Constructor.

Definition at line 31 of file PndPidEmcAssociatorTask.cxx.

References SetEmcParNames(), and SetVarNames().

33 {
34  std::vector<std::string> const* vNames = SetEmcParNames();
35  SetVarNames(*vNames);
36  delete vNames;
37 }
std::vector< std::string > const * SetEmcParNames() const
Set Emc related variable names.
TString name
void SetVarNames(std::vector< std::string > const &vNames)
Set Variables to use.
PndPidEmcAssociatorTask::~PndPidEmcAssociatorTask ( )
virtual

Destructor.

Destructor.

Definition at line 40 of file PndPidEmcAssociatorTask.cxx.

41 {}
PndPidEmcAssociatorTask::PndPidEmcAssociatorTask ( PndPidMvaAssociatorTask const &  other)
private

Member Function Documentation

PndPidEmcAssociatorTask::ClassDef ( PndPidEmcAssociatorTask  ,
 
)
private
void PndPidMvaAssociatorTask::Exec ( Option_t *  option)
virtualinherited

Execute the method.

Definition at line 323 of file PndPidMvaAssociatorTask.cxx.

References PndPidMvaAssociatorTask::DoPidMatch(), PndPidMvaAssociatorTask::fPidChargedCand, PndPidMvaAssociatorTask::fPidChargedProb, fVerbose, PndPidCandidate::GetLorentzVector(), and i.

324 {
325  std::cout << option << '\n';
326 
327  if (fPidChargedProb->GetEntriesFast() != 0)
328  {
329  fPidChargedProb->Delete();
330  }
331 
332 #if ( PIDMVA_ASSOCIATORT_DEBUG != 0 )
333  std::cout << "<INFO> Call to Exec with options = " << option
334  << "___\n";
335 #endif
336 
337  if(fVerbose > 1)
338  {
339  std::cout << "-I- Start PndPidMvaAssociatorTask.\n";
340  }
341 
342  // Charged Candidates Loop
343  for(int i = 0; i < fPidChargedCand->GetEntriesFast(); i++)
344  {
346  TClonesArray& pidRef = *fPidChargedProb;
347 
348  // initializes with zeros
349  PndPidProbability* prob = new(pidRef[i]) PndPidProbability();
350 
351  if(fVerbose > 1)
352  {
353  std::cout << "-I- PndPidMVAAssociatorTask Ch BEFORE "
354  << pidcand->GetLorentzVector().M()
355  << '\n';
356  }
357  // Classify
358  DoPidMatch(*pidcand, *prob);
359 
360  if(fVerbose > 1)
361  {
362  std::cout << "-I- PndPidMVAAssociatorTask Ch AFTER "
363  << pidcand->GetLorentzVector().M()
364  << '\n';
365  }
366  }
367 
368  // Get the Neutral Candidates
369  /*
370  for(int i = 0; i < fPidNeutralCand->GetEntriesFast(); i++)
371  {
372  PndPidCandidate* pidcand = (PndPidCandidate*)fPidNeutralCand->At(i);
373  TClonesArray& pidRef = *fPidNeutralProb;
374  // initializes with zeros
375  PndPidProbability* prob = new(pidRef[i]) PndPidProbability();
376  // Classify
377  DoPidMatch(*pidcand, *prob);
378  }
379  */
380 }
int fVerbose
Definition: poormantracks.C:24
Int_t i
Definition: run_full.C:25
TLorentzVector GetLorentzVector() const
TClonesArray * fPidChargedProb
PndPidCandidate TCA for charged particles.
void DoPidMatch(PndPidCandidate &pidcand, PndPidProbability &prob)
void PndPidMvaAssociatorTask::Finish ( )
virtualinherited

Definition at line 564 of file PndPidMvaAssociatorTask.cxx.

565 {}
InitStatus PndPidMvaAssociatorTask::Init ( )
virtualinherited

Initialize the method. Called by runner.

Definition at line 156 of file PndPidMvaAssociatorTask.cxx.

References PndPidMvaAssociatorTask::fClassifier, PndPidMvaAssociatorTask::fClassNames, PndPidMvaAssociatorTask::fManager, PndPidMvaAssociatorTask::fMethodName, PndPidMvaAssociatorTask::fMethodType, PndPidMvaAssociatorTask::fNumNeigh, PndPidMvaAssociatorTask::fPidChargedCand, PndPidMvaAssociatorTask::fScFact, PndPidMvaAssociatorTask::fVarNames, PndPidMvaAssociatorTask::fWeight, PndPidMvaAssociatorTask::fWeightsFileName, PndMvaClassifier::Initialize(), PndMultiClassMlpClassify::Initialize(), PndMultiClassBdtClassify::Initialize(), PndKnnClassify::Initialize(), KNN, LVQ, PndPidMvaAssociatorTask::Register(), PndKnnClassify::SetEvtParam(), PndKnnClassify::SetKnn(), TMVA_BDT, and TMVA_MLP.

157 {
158  std::cout << "<-I-> InitStatus PndPidMvaAssociatorTask::Init()\n";
159 
160  fManager = FairRootManager::Instance();
161  if( !fManager ) {
162  std::cerr << "<ERROR> PndPidMvaAssociatorTask::Init:\n"
163  << "\t Could not init FairRootManager."
164  << std::endl;
165 
166  return kERROR;
167  }
168 
169  // Get charged candidates.
170  fPidChargedCand = (TClonesArray *)fManager->GetObject("PidChargedCand");
171  if ( !fPidChargedCand) {
172  std::cerr << "<ERROR> PndPidMvaAssociatorTask::Init: No PidChargedCand there!"
173  << std::endl;
174  return kERROR;
175  }
176 
177  // Get Neutral candidates.
178  /*
179  fPidNeutralCand = (TClonesArray *)fManager->GetObject("PidNeutralCand");
180  if ( ! fPidNeutralCand)
181  {
182  std::cerr << "<ERROR> PndPidMvaAssociatorTask::Init: No PidNeutralCand there!"
183  << std::endl;
184  return kERROR;
185  }
186  */
187 
188  std::cout << "<INFO> Using weight file " << fWeightsFileName
189  << '\n';
190 
191  // Init Classifier object
192  switch(fMethodType)
193  {
194  case TMVA_MLP:// Multi label MLP classifier from TMVA.
195  {
196  PndMultiClassMlpClassify* TmvaMlpCls = new PndMultiClassMlpClassify(fWeightsFileName, fClassNames,
197  fVarNames);
198  if(!TmvaMlpCls)
199  {
200  std::cerr << "<Error> Failed to initialize TMVA_MLP classifier."
201  << std::endl;
202  return kERROR;
203  }
204  // Init
205  TmvaMlpCls->Initialize();
206 
207  //fClassifier = dynamic_cast<PndMultiClassMlpClassify*>(TmvaMlpCls);
208  fClassifier = TmvaMlpCls;
209  std::cout << "<INFO> TMVA_MLP initialized using " << fWeightsFileName << '\n';
210 
211  fMethodName = "TMVAMLP";
212  }
213  break;
214 
215  case TMVA_BDT:// Multi label BDT classifier from TMVA.
216  {
217  PndMultiClassBdtClassify* TmvaBdtCls = new PndMultiClassBdtClassify(fWeightsFileName, fClassNames,
218  fVarNames);
219  if(!TmvaBdtCls)
220  {
221  std::cerr << "<Error> Failed to initialize TMVA_BDT classifier."
222  << std::endl;
223  return kERROR;
224  }
225  // INIT
226  TmvaBdtCls->Initialize();
227 
228  //fClassifier = dynamic_cast<PndMultiClassBdtClassify*>(TmvaBdtCls);
229  fClassifier = TmvaBdtCls;
230  std::cout << "<INFO> TMVA_BDT initialized using " << fWeightsFileName << '\n';
231 
232  fMethodName = "TMVABDT";
233  }
234  break;
235 
236  case LVQ:
237  {
238  PndLVQClassify* LvqCls = new PndLVQClassify(fWeightsFileName, fClassNames, fVarNames);
239 
240  if(!LvqCls)
241  {
242  std::cerr << "<Error> Failed to initialize LVQ classifier."
243  << std::endl;
244  return kERROR;
245  }
246  // Init
247  LvqCls->Initialize();
248 
249  //fClassifier = dynamic_cast<PndMvaClassifier*>(LvqCls);
250  fClassifier = LvqCls;
251  std::cout << "<INFO> LVQ initialized using " << fWeightsFileName << '\n';
252 
253  fMethodName = "LVQ";
254  }
255  break;
256 
257  case KNN:
258  default:
259  {
260  PndKnnClassify* KnnCls = new PndKnnClassify(fWeightsFileName, fClassNames, fVarNames);
261 
262  if(!KnnCls)
263  {
264  std::cerr << "<Error> Failed to initialize KNN classifier."
265  << std::endl;
266  return kERROR;
267  }
268 
269  // Set parameters.
270  KnnCls->SetEvtParam(fScFact, fWeight);
271  KnnCls->SetKnn(fNumNeigh);
272  KnnCls->Initialize();
273 
274  //fClassifier = dynamic_cast<PndMvaClassifier*>(KnnCls);
275  fClassifier = KnnCls;
276  std::cout << "<INFO> KNN initialized using " << fWeightsFileName << '\n';
277 
278  fMethodName = "KNN";
279  }
280  break;
281  }// End of switch(fMethodType)
282 
283  // Register objects in the output chain
284  Register();
285 
286  std::cout << "<INFO> PndPidMvaAssociatorTask::Init: Success!\n";
287  return kSUCCESS;
288 }
PndMvaClassifier * fClassifier
MVA classifier object.
!< Type definition of the neighbour list.
std::string fMethodName
Monte-Carlo Truth track TCA.
void SetEvtParam(float const scFact, double const weight)
std::vector< std::string > fVarNames
Variable names container.
void SetKnn(size_t const N)
Set the number of neighbours.
size_t fNumNeigh
Number of neighbors.
virtual void Initialize()
std::vector< std::string > fClassNames
Class names container.
Interface definition of the LVQ classifier.
std::string fWeightsFileName
Path to the file holding weights (proto-types, examples, ...)
virtual void Initialize()
Mva_MethodType fMethodType
MVA Method name.
PndPidEmcAssociatorTask& PndPidEmcAssociatorTask::operator= ( PndPidMvaAssociatorTask const &  other)
private
void PndPidMvaAssociatorTask::Register ( )
inherited

Definition at line 555 of file PndPidMvaAssociatorTask.cxx.

References PndPidMvaAssociatorTask::fMethodName, and PndPidMvaAssociatorTask::fPidChargedProb.

Referenced by PndPidMvaAssociatorTask::Init().

556 {
557  std::string tcaName = fMethodName + "MvaProb";
558  //---
559  FairRootManager::Instance()->Register(tcaName.c_str(),"Pid", fPidChargedProb, kTRUE);
560  // FairRootManager::Instance()->Register("MvaNeutralProb","Pid", fPidNeutralProb, kTRUE);
561 }
TClonesArray * fPidChargedProb
PndPidCandidate TCA for charged particles.
std::string fMethodName
Monte-Carlo Truth track TCA.
void PndPidMvaAssociatorTask::Reset ( )
inherited

Definition at line 567 of file PndPidMvaAssociatorTask.cxx.

568 {}
void PndPidMvaAssociatorTask::SetClassifier ( Mva_MethodType const &  methodT)
inlineinherited

Set the classifier type.

Parameters
methodTThe method to be used.

Definition at line 201 of file PndPidMvaAssociatorTask.h.

References PndPidMvaAssociatorTask::fMethodType.

202 {
203  fMethodType = methodT;
204 };
Mva_MethodType fMethodType
MVA Method name.
void PndPidMvaAssociatorTask::SetClassifier ( std::string const &  methodName)
inherited

Set the classifier type.

Parameters
methodNameThe method to be used.

Definition at line 294 of file PndPidMvaAssociatorTask.cxx.

References PndPidMvaAssociatorTask::fMethodName, PndPidMvaAssociatorTask::fMethodType, KNN, LVQ, TMVA_BDT, and TMVA_MLP.

295 {
296  if(methodNameStr == "KNN")
297  {
298  fMethodType = KNN;
299  fMethodName = "KNN";
300  }
301  else if(methodNameStr == "LVQ")
302  {
303  fMethodType = LVQ;
304  fMethodName = "LVQ";
305  }
306  else if(methodNameStr == "TMVA_MLP")
307  {
309  fMethodName = "TMVAMLP";
310  }
311  else if(methodNameStr == "TMVA_BDT")
312  {
314  fMethodName = "TMVABDT";
315  }
316  else
317  {
318  std::cerr << "<ERROR> Unknown Method."
319  << std::endl;
320  }
321 };
std::string fMethodName
Monte-Carlo Truth track TCA.
Mva_MethodType fMethodType
MVA Method name.
void PndPidMvaAssociatorTask::SetClassNames ( std::vector< std::string > const &  clNames)
inlineinherited
Parameters
clNamesInput class names.

Definition at line 186 of file PndPidMvaAssociatorTask.h.

References PndPidMvaAssociatorTask::fClassNames.

187 {
188  fClassNames = clNames;
189 };
std::vector< std::string > fClassNames
Class names container.
std::vector< std::string > const * PndPidEmcAssociatorTask::SetEmcParNames ( ) const
private

Set Emc related variable names.

Definition at line 52 of file PndPidEmcAssociatorTask.cxx.

Referenced by PndPidEmcAssociatorTask().

53 {
54  std::vector<std::string>* VarNames = new std::vector<std::string>();
55  VarNames->push_back("emc");
56  VarNames->push_back("lat");
57  VarNames->push_back("z20");
58  VarNames->push_back("z53");
59  VarNames->push_back("e1");
60  VarNames->push_back("e9");
61  VarNames->push_back("e25");
62 
63  return VarNames;
64 }
void PndPidMvaAssociatorTask::SetKnnEventParams ( float  scFact,
double  weight 
)
inlineinherited

Set the scale factor and the event weight for KNN classifier.

Parameters
scFactScale factor.
weightEvents weight.

Definition at line 206 of file PndPidMvaAssociatorTask.h.

References PndPidMvaAssociatorTask::fScFact, and PndPidMvaAssociatorTask::fWeight.

207 {
208  fScFact = scFact;
209  fWeight = weight;
210 };
void PndPidMvaAssociatorTask::SetNumNeigh ( size_t  val)
inlineinherited
Parameters
valnNumber of neighbors to be uset for KNN classifier.

Definition at line 196 of file PndPidMvaAssociatorTask.h.

References PndPidMvaAssociatorTask::fNumNeigh, and val.

197 {
198  fNumNeigh = val;
199 };
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
size_t fNumNeigh
Number of neighbors.
void PndPidMvaAssociatorTask::SetParContainers ( )
virtualinherited

Set parameter containers

Definition at line 291 of file PndPidMvaAssociatorTask.cxx.

292 {}
void PndPidEmcAssociatorTask::SetVarNames ( std::vector< std::string > const &  vNames)
privatevirtual

Set Variables to use.

Reimplemented from PndPidMvaAssociatorTask.

Definition at line 44 of file PndPidEmcAssociatorTask.cxx.

References PndPidMvaAssociatorTask::SetVarNames().

Referenced by PndPidEmcAssociatorTask().

45 {
46  std::cout<< "<INFO> Filling EMC related Variable names.\n";
47 
49 }
virtual void SetVarNames(std::vector< std::string > const &vNames)
void PndPidMvaAssociatorTask::SetVerbose ( Bool_t  verb)
inlineinherited

Definition at line 176 of file PndPidMvaAssociatorTask.h.

References fVerbose.

177 {
178  fVerbose = verb;
179 };
int fVerbose
Definition: poormantracks.C:24
void PndPidMvaAssociatorTask::SetWeightFileName ( std::string const &  wFileName)
inlineinherited
Parameters
wFileNameInput weight file. If not specified the standard file from the standard location is loaded.

Definition at line 191 of file PndPidMvaAssociatorTask.h.

References PndPidMvaAssociatorTask::fWeightsFileName.

192 {
193  fWeightsFileName = wFileName;
194 };
std::string fWeightsFileName
Path to the file holding weights (proto-types, examples, ...)

The documentation for this class was generated from the following files: