4 #include <EVENT/LCCollection.h>
5 #include <IMPL/ParticleIDImpl.h>
6 #include <IMPL/ReconstructedParticleImpl.h>
7 #include <UTIL/PIDHandler.h>
9 #include "TLorentzVector.h"
18 : Processor(
"LikelihoodPIDProcessor") {
21 _description =
"Particle ID code using Bayesian Classifier" ;
23 std::vector< std::string > xmlfiles;
24 xmlfiles.push_back(
"TMVAClassification_BDTG_02GeVP_clusterinfo.weights.xml" );
25 xmlfiles.push_back(
"TMVAClassification_BDTG_03GeVP_clusterinfo.weights.xml" );
26 xmlfiles.push_back(
"TMVAClassification_BDTG_04GeVP_clusterinfo.weights.xml" );
27 xmlfiles.push_back(
"TMVAClassification_BDTG_05GeVP_clusterinfo.weights.xml" );
28 xmlfiles.push_back(
"TMVAClassification_BDTG_06GeVP_clusterinfo.weights.xml" );
29 xmlfiles.push_back(
"TMVAClassification_BDTG_07GeVP_clusterinfo.weights.xml" );
30 xmlfiles.push_back(
"TMVAClassification_BDTG_08GeVP_clusterinfo.weights.xml" );
31 xmlfiles.push_back(
"TMVAClassification_BDTG_09GeVP_clusterinfo.weights.xml" );
32 xmlfiles.push_back(
"TMVAClassification_BDTG_10GeVP_clusterinfo.weights.xml" );
33 xmlfiles.push_back(
"TMVAClassification_BDTG_11GeVP_clusterinfo.weights.xml" );
34 xmlfiles.push_back(
"TMVAClassification_BDTG_12GeVP_clusterinfo.weights.xml" );
35 xmlfiles.push_back(
"TMVAClassification_BDTG_13GeVP_clusterinfo.weights.xml" );
36 xmlfiles.push_back(
"TMVAClassification_BDTG_14GeVP_clusterinfo.weights.xml" );
37 xmlfiles.push_back(
"TMVAClassification_BDTG_15GeVP_clusterinfo.weights.xml" );
38 xmlfiles.push_back(
"TMVAClassification_BDTG_16GeVP_clusterinfo.weights.xml" );
39 xmlfiles.push_back(
"TMVAClassification_BDTG_17GeVP_clusterinfo.weights.xml" );
40 xmlfiles.push_back(
"TMVAClassification_BDTG_18GeVP_clusterinfo.weights.xml" );
41 xmlfiles.push_back(
"TMVAClassification_BDTG_19GeVP_clusterinfo.weights.xml" );
42 xmlfiles.push_back(
"TMVAClassification_BDTG_20GeVP_clusterinfo.weights.xml" );
44 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
45 "RecoParticleCollection" ,
46 "Input collection of Reconstrcuted Particle",
48 std::string(
"PandoraPFOs"));
50 registerProcessorParameter(
"EnergyBoundaries" ,
51 "Boundaries for energy",
53 EVENT::FloatVec(0,1.0
e+07));
55 registerProcessorParameter(
"FilePDFName" ,
58 std::string(
"pdf_ParticleID_ok.root") );
60 registerProcessorParameter(
"FileWeightFormupiSeparationName" ,
61 "weight file for low momentum mu pi separation",
65 std::vector< float > parselectron,parsmuon,parspion,parskaon,parsproton;
66 parselectron.push_back(-2.40638
e-03);
67 parselectron.push_back(7.10337
e-01);
68 parselectron.push_back(2.87718
e-01);
69 parselectron.push_back(-1.71591
e+00);
70 parselectron.push_back(0.0);
71 registerProcessorParameter(
"dEdxParameter_electron" ,
72 "dEdx Parameters for electron",
76 parsmuon.push_back(8.11408
e-02);
77 parsmuon.push_back(9.92207
e-01);
78 parsmuon.push_back(7.58509
e+05);
79 parsmuon.push_back(-1.70167
e-01);
80 parsmuon.push_back(4.63670
e-04);
81 registerProcessorParameter(
"dEdxParameter_muon" ,
82 "dEdx Parameters for muon",
86 parspion.push_back(8.10756
e-02);
87 parspion.push_back(-1.45051
e+06);
88 parspion.push_back(-3.09843
e+04);
89 parspion.push_back(2.84056
e-01);
90 parspion.push_back(3.38131
e-04);
91 registerProcessorParameter(
"dEdxParameter_pion" ,
92 "dEdx Parameters for pion",
96 parskaon.push_back(7.96117
e-02);
97 parskaon.push_back(4.13335
e+03);
98 parskaon.push_back(1.13577
e+06);
99 parskaon.push_back(1.80555
e-01);
100 parskaon.push_back(-3.15083
e-04);
101 registerProcessorParameter(
"dEdxParameter_kaon" ,
102 "dEdx Parameters for Kaon",
106 parsproton.push_back(7.78772
e-02);
107 parsproton.push_back(4.49300
e+04);
108 parsproton.push_back(9.13778
e+04);
109 parsproton.push_back(1.50088
e-01);
110 parsproton.push_back(-6.64184
e-04);
111 registerProcessorParameter(
"dEdxParameter_proton" ,
112 "dEdx Parameters for proton",
116 registerProcessorParameter(
"dEdxNormalization" ,
117 "dEdx Normalization",
121 registerProcessorParameter(
"dEdxErrorFactor" ,
126 registerProcessorParameter(
"UseBayesian" ,
127 "PID is based on Bayesian or Likelihood",
131 std::vector< float > costmat;
132 costmat.push_back(0.0);
133 costmat.push_back(1.0);
134 costmat.push_back(1.0);
135 costmat.push_back(1.0);
136 costmat.push_back(1.0);
138 costmat.push_back(1.0);
139 costmat.push_back(0.0);
140 costmat.push_back(9.0);
141 costmat.push_back(1.0);
142 costmat.push_back(1.0);
144 costmat.push_back(1.0);
145 costmat.push_back(1.0);
146 costmat.push_back(0.0);
147 costmat.push_back(1.0);
148 costmat.push_back(1.0);
150 costmat.push_back(1.0);
151 costmat.push_back(1.0);
152 costmat.push_back(30.0);
153 costmat.push_back(0.0);
154 costmat.push_back(1.0);
156 costmat.push_back(1.0);
157 costmat.push_back(1.0);
158 costmat.push_back(1.0);
159 costmat.push_back(10.0);
160 costmat.push_back(0.0);
162 registerProcessorParameter(
"CostMatrix" ,
163 "cost matrix for risk based bayesian classifier",
168 registerProcessorParameter(
"UseLowMomentumMuPiSeparation" ,
169 "MVA mu/pi separation should be used or not",
174 std::vector< std::string > methods_to_run;
175 methods_to_run.push_back(
"BasicVariablePID" );
176 methods_to_run.push_back(
"LowMomMuID" );
177 methods_to_run.push_back(
"ShowerShapesPID" );
178 methods_to_run.push_back(
"dEdxPID" );
179 methods_to_run.push_back(
"LikelihoodPID" );
181 registerProcessorParameter(
"PIDMethodsToRun" ,
182 "methods to be run, default: BasicVariablePID LowMomMuID ShowerShapesPID dEdxPID LikelihoodPID",
187 std::string methods_to_run_version=
"";
188 registerProcessorParameter(
"PIDMethodsToRun_version" ,
189 "version of the methods (for rerunning purposes)",
191 methods_to_run_version );
196 streamlog_out(DEBUG) <<
" init called " << std::endl ;
242 _dEdxNames.push_back(
"MVAOutput_mupiSeparation");
249 _dEdxNames.push_back(
"electron_dEdxdistance");
264 bool allnamecorrect=
false;
271 ||
_methodstorun.at(i).compare(
"LikelihoodPID")==0 ) allnamecorrect=
true;
273 if(allnamecorrect==
false) {
274 throw EVENT::Exception(
_methodstorun.at(i) + std::string(
" is not in the list of valid methods: BasicVariablePID LowMomMuID ShowerShapesPID dEdxPID LikelihoodPID"));
276 allnamecorrect=
false;
288 int npfo =
_pfoCol->getNumberOfElements();
297 for (
int i = 0; i < npfo; i++ ) {
298 ReconstructedParticleImpl* part =
dynamic_cast<ReconstructedParticleImpl*
>(
_pfoCol->getElementAt(i) );
300 if(part->getCharge()==0)
continue;
302 EVENT::ClusterVec clu=part->getClusters();
303 lcio::Track* trk = part->getTracks()[0];
304 TLorentzVector pp(part->getMomentum()[0],
305 part->getMomentum()[1],
306 part->getMomentum()[2],
316 Float_t MVAoutput = -100.0;
353 if(parttype<0) parttype=2;
356 Float_t MVAoutput = -100.0;
357 if((parttype==1 || parttype==2) && (
_UseMVA && pp.P()<2.0 && clu.size()!=0)){
423 std::vector<float> likelihoodProb;
425 if(pidh.getAlgorithmName(algoID).find(
"LowMomMuID") == std::string::npos){
426 for(
int j=0;j<6;j++) likelihoodProb.push_back(likelihood[j]);
427 likelihoodProb.push_back(MVAoutput);
428 for(
int j=0;j<6;j++) likelihoodProb.push_back(posterior[j]);
430 for(
int j=0;j<6;j++) likelihoodProb.push_back(999.0);
431 likelihoodProb.push_back(MVAoutput);
432 for(
int j=0;j<6;j++) likelihoodProb.push_back(0.0);
433 for(
int j=0;j<6;j++){
440 if(pidh.getAlgorithmName(algoID).find(
"dEdxPID")!= std::string::npos || pidh.getAlgorithmName(algoID).find(
"LikelihoodPID")!= std::string::npos){
450 likelihoodProb.push_back((
float)0.0);
451 likelihoodProb.push_back((
float)0.0);
452 likelihoodProb.push_back((
float)0.0);
453 likelihoodProb.push_back((
float)0.0);
454 likelihoodProb.push_back((
float)0.0);
465 if(pidh.getAlgorithmName(algoID).find(
"dEdxPID")!= std::string::npos || pidh.getAlgorithmName(algoID).find(
"LikelihoodPID")!= std::string::npos)
466 pidh.setParticleID(part, 0,
_pdgTable[parttype], (
float)likelihood[parttype], algoID, likelihoodProb);
468 int tmppart=parttype;
469 parttype = std::min(2,parttype);
470 if(parttype==2) tmppart=5;
471 pidh.setParticleID(part, 0,
_pdgTable[parttype], (
float)likelihood[tmppart], algoID, likelihoodProb);
std::vector< float > _dEdxParamsMuon
double get_dEdxDist(int parttype)
std::string _methodstorun_version
virtual void processEvent(LCEvent *evt)
virtual void processRunHeader(LCRunHeader *run)
std::vector< std::string > _methodstorun
std::vector< float > _dEdxParamsPion
LikelihoodPIDProcessor aLikelihoodPIDProcessor
void setBasicFlg(bool flg)
std::vector< std::string > _dEdxNames
std::vector< float > _dEdxParamsProton
void setdEdxFlg(bool flg)
void setShowerShapesFlg(bool flg)
std::vector< float > _dEdxParamsKaon
std::vector< float > _dEdxParamsElectron
std::vector< float > _cost
std::vector< std::string > _particleNames
int Classification(TLorentzVector pp, EVENT::Track *trk, EVENT::ClusterVec &cluvec)
virtual void check(LCEvent *evt)
LowMomentumMuPiSeparationPID_BDTG * _mupiPID
void createParticleIDClass(int parttype, ReconstructedParticle *part, PIDHandler &pidh, int algoID, float MVAoutput)
std::string _inputPFOsCollection
EVENT::FloatVec _energyBoundary
std::vector< int > _pdgTable
Int_t MuPiSeparation(TLorentzVector pp, EVENT::Track *trk, EVENT::ClusterVec &cluvec)
std::vector< std::string > _weightFileName