4 #include <marlin/Global.h>
5 #include "DD4hep/Detector.h"
6 #include "DDRec/Vector3D.h"
7 #include "DD4hep/DD4hepUnits.h"
9 #include "EVENT/ReconstructedParticle.h"
10 #include "EVENT/LCRelation.h"
11 #include "EVENT/MCParticle.h"
12 #include "IMPL/ClusterImpl.h"
22 : Processor(
"CreatePDFProcessor") {
28 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
30 "Input collection of Reconstrcuted Particle",
32 std::string(
"pdf_standard_v01.root"));
34 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
35 "RecoParticleCollection" ,
36 "Input collection of Reconstrcuted Particle",
38 std::string(
"PandoraPFOs"));
40 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
41 "MCTruthLinkCollection" ,
42 "Input collection of Reconstrcuted Particle",
44 std::string(
"RecoMCTruthLink"));
46 std::vector< float > parselectron,parsmuon,parspion,parskaon,parsproton;
47 parselectron.push_back(-2.40638
e-03);
48 parselectron.push_back(7.10337
e-01);
49 parselectron.push_back(2.87718
e-01);
50 parselectron.push_back(-1.71591
e+00);
51 parselectron.push_back(0.0);
52 registerProcessorParameter(
"dEdxParameter_electron" ,
53 "dEdx Parameters for electron",
57 parsmuon.push_back(8.11408
e-02);
58 parsmuon.push_back(9.92207
e-01);
59 parsmuon.push_back(7.58509
e+05);
60 parsmuon.push_back(-1.70167
e-01);
61 parsmuon.push_back(4.63670
e-04);
62 registerProcessorParameter(
"dEdxParameter_muon" ,
63 "dEdx Parameters for muon",
67 parspion.push_back(8.10756
e-02);
68 parspion.push_back(-1.45051
e+06);
69 parspion.push_back(-3.09843
e+04);
70 parspion.push_back(2.84056
e-01);
71 parspion.push_back(3.38131
e-04);
72 registerProcessorParameter(
"dEdxParameter_pion" ,
73 "dEdx Parameters for pion",
77 parskaon.push_back(7.96117
e-02);
78 parskaon.push_back(4.13335
e+03);
79 parskaon.push_back(1.13577
e+06);
80 parskaon.push_back(1.80555
e-01);
81 parskaon.push_back(-3.15083
e-04);
82 registerProcessorParameter(
"dEdxParameter_kaon" ,
83 "dEdx Parameters for Kaon",
87 parsproton.push_back(7.78772
e-02);
88 parsproton.push_back(4.49300
e+04);
89 parsproton.push_back(9.13778
e+04);
90 parsproton.push_back(1.50088
e-01);
91 parsproton.push_back(-6.64184
e-04);
92 registerProcessorParameter(
"dEdxParameter_proton" ,
93 "dEdx Parameters for proton",
97 registerProcessorParameter(
"dEdxNormalization" ,
102 registerProcessorParameter(
"dEdxErrorFactor" ,
122 std::string histtxt,labeltxt;
123 for(
int i=0;i<6;i++){
124 for(
int j=0;j<21;j++){
128 histtxt=
"hmomentum" +
itos(i+1);
130 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",50,0.0,250.0);
135 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
136 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
141 histtxt=
"hep" +
itos(i+1);
143 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",40,0.0,2.0);
148 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
149 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
154 histtxt=
"hehad" +
itos(i+1);
155 labeltxt=
"ECAL/(ECAL+HCAL)";
156 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",50,0.0,1.0);
161 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
162 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
167 histtxt=
"hphotonEnergy" +
itos(i+1);
168 labeltxt=
"E(photon) (GeV)";
169 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",50,0.0,50.0);
174 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
175 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
180 histtxt=
"hmucal" +
itos(i+1);
181 labeltxt=
"MuCAL (GeV)";
182 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",100,0.0,20.0);
187 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
188 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
193 histtxt=
"hchi2" +
itos(i+1);
195 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",104,-2.0,50.0);
200 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
201 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
206 histtxt=
"hldiscrepancy" +
itos(i+1);
207 labeltxt=
"ShowerMax/EM ShowerMax";
208 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",65,-30.0,100.0);
213 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
214 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
219 histtxt=
"htdiscrepancy" +
itos(i+1);
220 labeltxt=
"absorption Length/Rm";
221 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",100,0.0,2.0);
226 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
227 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
232 histtxt=
"hxl20" +
itos(i+1);
234 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",100,0.0,100.0);
240 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
241 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
246 histtxt=
"hlikeliele" +
itos(i+1);
247 labeltxt=
"Log(likelihood) (electron)";
248 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",200,-100.0,0.0);
254 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
255 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
260 histtxt=
"hlikelimuo" +
itos(i+1);
261 labeltxt=
"Log(likelihood) (#mu)";
262 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",200,-100.0,0.0);
268 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
269 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
274 histtxt=
"hlikelipi" +
itos(i+1);
275 labeltxt=
"Log(likelihood) (#pi)";
276 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",200,-100.0,0.0);
282 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
283 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
288 histtxt=
"hlikelik" +
itos(i+1);
289 labeltxt=
"Log(likelihood) (K)";
290 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",200,-100.0,0.0);
296 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
297 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
302 histtxt=
"hlikelip" +
itos(i+1);
303 labeltxt=
"Log(likelihood) (p)";
304 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",200,-100.0,0.0);
310 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
311 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
316 histtxt=
"hlikelikpi" +
itos(i+1);
317 labeltxt=
"Log(likelihood(K)/likelihood(#pi))";
318 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",160,-50.0,30.0);
324 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
325 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
330 histtxt=
"hlikelipk" +
itos(i+1);
331 labeltxt=
"Log(likelihood(p)/likelihood(K))";
332 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",160,-50.0,30.0);
338 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
339 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
344 histtxt=
"hdeltax" +
itos(i+1);
345 labeltxt=
"#Deltax#timesQ";
346 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",200,-5.0,5.0);
351 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
352 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
357 histtxt=
"hdeltaz" +
itos(i+1);
359 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",200,-5.0,5.0);
364 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
365 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
370 histtxt=
"hcludepth" +
itos(i+1);
371 labeltxt=
"cluster depth";
372 pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",200,1500.0,3500.0);
377 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
378 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
383 histtxt=
"hhitmean" +
itos(i+1);
385 if(i==0)
pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",100,0.0,2500.0);
386 if(i!=0)
pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",100,0.0,1000.0);
391 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
392 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
397 histtxt=
"hhitrms" +
itos(i+1);
399 if(i==0)
pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",100,0.0,2500.0);
400 if(i!=0)
pidvariable[i][j]=
new TH1F(histtxt.c_str(),
"",100,0.0,1000.0);
405 pidvariable[i][j]->GetYaxis()->SetTitle(
"Normalized Events");
406 pidvariable[i][j]->GetXaxis()->SetTitle(labeltxt.c_str());
423 dd4hep::Detector& lcdd = dd4hep::Detector::getInstance();
424 lcdd.field().magneticField({0.0,0.0,0.0}, bfield);
425 _bfield = (float)bfield[2]/dd4hep::tesla;
436 int npfo =
_PFOCol->getNumberOfElements();
437 int nln =
_LinkCol->getNumberOfElements();
439 std::map<int, int> pid;
440 pid.insert(std::map<int, int>::value_type(11, 0));
441 pid.insert(std::map<int, int>::value_type(13, 1));
442 pid.insert(std::map<int, int>::value_type(211, 2));
443 pid.insert(std::map<int, int>::value_type(321, 3));
444 pid.insert(std::map<int, int>::value_type(2212, 4));
446 for(
int i=0;i<npfo;i++){
447 ReconstructedParticle* part = (ReconstructedParticle*)
_PFOCol->getElementAt(i);
448 if(part->getCharge()==0)
continue;
450 EVENT::Track* trk = part->getTracks()[0];
451 EVENT::ClusterVec cluvec = part->getClusters();
453 TVector3 pp = part->getMomentum();
456 double ecal=0.0,hcal=0.0,mucal=0.0;
457 if(cluvec.size()!=0){
458 for(
unsigned int i=0;i<cluvec.size();i++){
459 ecal+=cluvec[i]->getSubdetectorEnergies()[0];
460 hcal+=cluvec[i]->getSubdetectorEnergies()[1];
461 mucal+=cluvec[i]->getSubdetectorEnergies()[2];
467 for(
int j=0;j< nln;j++){
468 LCRelation* plc = (LCRelation*)
_LinkCol->getElementAt( j );
469 ReconstructedParticle* fp = (ReconstructedParticle*) plc->getFrom();
472 MCParticle* partmc = (MCParticle*) plc->getTo();
473 int mcpdg = fabs(partmc->getPDG());
474 if(mcpdg!=11 && mcpdg!=13 && mcpdg!=211 && mcpdg!=321 && mcpdg!=2212)
continue;
476 if(pdfid==1 && mucal==0.0) pdfid=5;
481 if(pdfid<0)
continue;
487 if(cluvec.size()!=0){
493 FloatVec shapes=cluvec[0]->getShape();
496 pidvariable[pdfid][7]->Fill(fabs(shapes[3+4])/shapes[6+4]);
497 pidvariable[pdfid][8]->Fill(fabs(shapes[15+4])/7.00);
500 if(pp.Mag()>0.3 && pp.Mag()<6.0){
508 double dedx = trk->getdEdx();
509 double dedxerr = trk->getdEdxError();
522 pidvariable[pdfid][14]->Fill(std::log(exp(khypo)/exp(pihypo)));
523 pidvariable[pdfid][15]->Fill(std::log(exp(phypo)/exp(khypo)));
526 float delpos[3]={0.0,0.0,0.0};
527 if(cluvec.size()!=0){
543 for(
int i=0;i<6;i++){
544 for(
int j=0;j<21;j++){
558 double prphi=sqrt(pow(p[0],2)+pow(p[1],2));
562 double radius=prphi/(0.3*
_bfield);
564 double tanlam=p[2]/prphi;
572 calcalpos[0]=calpos[0]/1000.0;
573 calcalpos[1]=calpos[1]/1000.0;
574 calcalpos[2]=calpos[2]/1000.0;
578 double rradius=sqrt(pow(calcalpos[0],2)+pow(calcalpos[1],2));
585 cc[0]=-charge*p[1]*prphi/(0.3*
_bfield);
586 cc[1]=charge*p[0]*prphi/(0.3*
_bfield);
590 double sintheta=charge*rradius/(2*radius);
591 double costheta=sqrt(1-sintheta*sintheta);
592 double sin2theta=2*sintheta*costheta;
593 double cos2theta=costheta*costheta-sintheta*sintheta;
596 calpos2[2]=rradius*tanlam;
597 calpos2[0]=cc[0]*(1-cos2theta)+cc[1]*sin2theta;
598 calpos2[1]=-cc[0]*sin2theta+cc[1]*(1-cos2theta);
602 delpos[0]=charge*fabs(calcalpos[0]-calpos2[0]);
603 delpos[1]=charge*fabs(calcalpos[1]-calpos2[1]);
604 delpos[2]=fabs(calcalpos[2]-calpos2[2]);
std::vector< float > _dEdxParamsMuon
std::vector< float > _dEdxParamsProton
double get_dEdxChi2(int parttype, TVector3 p, float hit, double dEdx)
std::vector< float > _dEdxParamsElectron
double get_dEdxFactor(int parttype, TVector3 p, float hit, double dEdx)
void CalculateDeltaPosition(float charge, TVector3 &p, const float *caylpos, float *delpos)
TH1F * pidvariable[6][21]
std::vector< float > _dEdxParamsKaon
std::vector< float > _dEdxParamsPion
virtual void check(LCEvent *evt)
virtual void processEvent(LCEvent *evt)
std::string _LinkCollection
CreatePDFProcessor aCreatePDFProcessor
virtual void processRunHeader(LCRunHeader *run)
std::string _PfoCollection