// $Id$ // // File: JEventProcessor_pidmon.cc // Created: Thu Oct 15 04:41:09 PM EDT 2026 // Creator: staylor (on Linux ifarm2401.jlab.org 5.14.0-611.55.1.el9_7.x86_64 x86_64) // /// For more information on the syntax changes between JANA1 and JANA2, visit: https://jeffersonlab.github.io/JANA2/#/jana1to2/jana1-to-jana2 #include "JEventProcessor_pidmon.h" #include #include #include #include #include #include #include // Routine used to create our JEventProcessor #include extern "C"{ void InitPlugin(JApplication *app){ InitJANAPlugin(app); app->Add(new JEventProcessor_pidmon()); } } // "C" //------------------ // JEventProcessor_pidmon (Constructor) //------------------ JEventProcessor_pidmon::JEventProcessor_pidmon() { SetTypeName(NAME_OF_THIS); // Provide JANA with this class's name // Parameters and Services should be accessed from Init() instead of here! } //------------------ // ~JEventProcessor_pidmon (Destructor) //------------------ JEventProcessor_pidmon::~JEventProcessor_pidmon() { } //------------------ // Init //------------------ void JEventProcessor_pidmon::Init() { // This is called once at program startup. auto app = GetApplication(); // lockService should be initialized here like this lockService = app->GetService(); lockService->CreateLock("pidlock"); lockService->RootWriteLock(); mapparticleNames; for (auto particle:particles){ switch(particle){ case 2: case 3: case 14: case 15: sprintf(particleNames[particle],"%s",ParticleType(particle)); break; case 8: sprintf(particleNames[particle],"%s","Pip"); break; case 9: sprintf(particleNames[particle],"%s","Pim"); break; case 11: sprintf(particleNames[particle],"%s","Kp"); break; case 12: sprintf(particleNames[particle],"%s","Km"); break; default: break; } } gDirectory->mkdir("Reactions")->cd(); Hepemg=new TH1F("Hepemg",";M(e^{+}e^{-}#gamma) [GeV]",1000,0,1); HepemgKF=new TH1F("HepemgKF",";M(e^{+}e^{-}#gamma) [GeV]",1000,0,1); HKpKm=new TH1F("HKpKm",";M(K^{+}K^{-}) [GeV]",1600,0.5,4.5); HKpKmKF=new TH1F("HKpKmKF",";M(K^{+}K^{-}) [GeV]",1600,0.5,4.5); HpKm=new TH1F("HpKm",";M(pK^{-}) [GeV]",1600,1,5); HpKmKF=new TH1F("HpKmKF",";M(pK^{-}) [GeV]",1600,1.,5); gDirectory->cd("../"); gDirectory->mkdir("Photons")->cd(); HEpred_vs_Ecluster_ECAL=new TH2F("HEpred_vs_Ecluster_ECAL",";E(cluster) [GeV];E(pred)[GeV]",300,0,6,300,0,6); gDirectory->cd("../"); gDirectory->mkdir("Timing")->cd(); char hname[80],htitle[100]; for (auto particle:particles){ sprintf(hname,"HTofDt_%s",particleNames[particle]); sprintf(htitle,"%s TOF time difference; p [GeV/c]; #Deltat [ns]", particleNames[particle]); HTofDt[particle]=new TH2F(hname,htitle,100,0,10,100,-2,2); sprintf(hname,"HBcalDt_%s",particleNames[particle]); sprintf(htitle,"%s BCAL time difference; p [GeV/c]; #Deltat [ns]", particleNames[particle]); HBcalDt[particle]=new TH2F(hname,htitle,100,0,10,100,-2,2); sprintf(hname,"HEcalDt_%s",particleNames[particle]); sprintf(htitle,"%s ECAL time difference; p [GeV/c]; #Deltat [ns]", particleNames[particle]); HEcalDt[particle]=new TH2F(hname,htitle,100,0,10,100,-2,2); sprintf(hname,"HFcalDt_%s",particleNames[particle]); sprintf(htitle,"%s FCAL time difference; p [GeV/c]; #Deltat [ns]", particleNames[particle]); HFcalDt[particle]=new TH2F(hname,htitle,100,0,10,100,-2,2); } gDirectory->mkdir("Cut")->cd(); HBcalDt_dEdx_cut=new TH2F("HBcalDt_dEdx_cut","Proton BCAL time difference, CDC dE/dx cut; p [GeV/c]; #Deltat [ns]",100,0,10,100,-2,2); HBcalDt_Phi_cut=new TH2F("HBcalDt_Phi_cut","K^{-} BCAL time difference, Phi cut; p [GeV/c]; #Deltat [ns]",100,0,10,100,-2,2); HBcalDt_Lambda_cut=new TH2F("HBcalDt_Lambda_cut","K^{-} BCAL time difference, Lambda cut; p [GeV/c]; #Deltat [ns]",100,0,10,100,-2,2); HTofDt_Phi_cut=new TH2F("HTofDt_Phi_cut","K^{-} TOF time difference, Phi cut; p [GeV/c]; #Deltat [ns]",100,0,10,100,-2,2); HFcalDt_Phi_cut=new TH2F("HFcalDt_Phi_cut","K^{-} FCAL time difference, Phi cut; p [GeV/c]; #Deltat [ns]",100,0,10,100,-2,2); HBcalDtPull_dEdx_cut=new TH2F("HBcalDtPull_dEdx_cut","Proton BCAL time difference pull, CDC dE/dx cut; p [GeV/c]; #Deltat/#sigmat",100,0,10,100,-2,2); gDirectory->cd("../"); gDirectory->mkdir("Pulls")->cd(); for (auto particle:particles){ sprintf(hname,"HTofDtPull_%s",particleNames[particle]); sprintf(htitle,"%s TOF time pull; p [GeV/c]; #Deltat/#sigmat", particleNames[particle]); HTofDtPull[particle]=new TH2F(hname,htitle,100,0,10,100,-2,2); sprintf(hname,"HBcalDtPull_%s",particleNames[particle]); sprintf(htitle,"%s BCAL time pull; p [GeV/c]; #Deltat/#sigmat", particleNames[particle]); HBcalDtPull[particle]=new TH2F(hname,htitle,100,0,10,100,-2,2); sprintf(hname,"HEcalDtPull_%s",particleNames[particle]); sprintf(htitle,"%s ECAL time pull; p [GeV/c]; #Deltat/#sigmat", particleNames[particle]); HEcalDtPull[particle]=new TH2F(hname,htitle,100,0,10,100,-2,2); sprintf(hname,"HFcalDtPull_%s",particleNames[particle]); sprintf(htitle,"%s FCAL time pull; p [GeV/c]; #Deltat/#sigmat", particleNames[particle]); HFcalDtPull[particle]=new TH2F(hname,htitle,100,0,10,100,-2,2); } gDirectory->cd("../"); gDirectory->cd("../"); gDirectory->mkdir("EnergyLoss")->cd(); mapbetagamma_max; for (auto particle:particles){ switch(particle){ case Electron: case Positron: betagamma_max[particle]=10000.; break; case PiPlus: case PiMinus: betagamma_max[particle]=80.; break; case KPlus: case KMinus: betagamma_max[particle]=40.; break; default: betagamma_max[particle]=6.; break; } sprintf(hname,"HCDCdEdx_%s",particleNames[particle]); sprintf(htitle,"%s energy loss in CDC; #gamma#beta; dE/dx [keV/cm]", particleNames[particle]); HCDCdEdx[particle]=new TH2F(hname,htitle,1000,0,betagamma_max[particle],120,0,30.); sprintf(hname,"HFDCdEdx_%s",particleNames[particle]); sprintf(htitle,"%s energy loss in FDC; #gamma#beta; dE/dx [keV/cm]", particleNames[particle]); HFDCdEdx[particle]=new TH2F(hname,htitle,1000,0,betagamma_max[particle],120,0,30.); } HScdEdx=new TH2F("HScdEdx","Proton energy loss in SC;#gamma#beta;dE/dx [MeV/cm]",100,0,10,120,0,15); HTofdEdx1=new TH2F("HTofdEdx1","Proton energy loss in TOF plane 1;#gamma#beta;dE/dx [MeV/cm]",100,0,10,120,0,15); HTofdEdx2=new TH2F("HTofdEdx2","Proton energy loss in TOF plane 2;#gamma#beta;dE/dx [MeV/cm]",100,0,10,120,0,15); gDirectory->mkdir("Diffs")->cd(); for (auto particle:particles){ sprintf(hname,"HCDCdEdxDiff_%s",particleNames[particle]); sprintf(htitle,"%s energy loss in CDC; #gamma#beta;#Delta(dE/dx) [keV/cm]", particleNames[particle]); HCDCdEdxDiff[particle]=new TH2F(hname,htitle,1000,0,betagamma_max[particle],100,-5,5.); sprintf(hname,"HFDCdEdxDiff_%s",particleNames[particle]); sprintf(htitle,"%s energy loss in FDC; #gamma#beta; #Delta(dE/dx) [keV/cm]", particleNames[particle]); HFDCdEdxDiff[particle]=new TH2F(hname,htitle,1000,0,betagamma_max[particle],100,-5,5.); } HScdEdxDiff=new TH2F("HScdEdxDiff","Proton energy loss in SC;#gamma#beta;#Delta(dE/dx) [MeV/cm]",100,0,10,100,-5,5); HTofdEdx1Diff=new TH2F("HTofdEdx1Diff","Proton energy loss in TOF plane 1;#gamma#beta;#Delta(dE/dx) [MeV/cm]",100,0,10,100,-5,5); HTofdEdx2Diff=new TH2F("HTofdEdx2Diff","Proton energy loss in TOF plane 2;#gamma#beta;#Delta(dE/dx) [MeV/cm]",100,0,10,100,-5,5); gDirectory->cd("../"); gDirectory->mkdir("Pulls")->cd(); for (auto particle:particles){ sprintf(hname,"HCDCdEdxPull_%s",particleNames[particle]); sprintf(htitle,"%s energy loss in CDC; #gamma#beta;#Delta(dE/dx)/#sigma(dE/dx)", particleNames[particle]); HCDCdEdxPull[particle]=new TH2F(hname,htitle,1000,0,betagamma_max[particle],100,-5,5.); sprintf(hname,"HFDCdEdxPull_%s",particleNames[particle]); sprintf(htitle,"%s energy loss in FDC; #gamma#beta; #Delta(dE/dx)/#sigma(dE/dx)", particleNames[particle]); HFDCdEdxPull[particle]=new TH2F(hname,htitle,1000,0,betagamma_max[particle],100,-5,5.); } HScdEdxPull=new TH2F("HScdEdxPull","Proton energy loss in SC;#gamma#beta;#Delta(dE/dx)/#sigma(dE/dx)",100,0,10,100,-5,5); HTofdEdx1Pull=new TH2F("HTofdEdx1Pull","Proton energy loss in TOF plane 1;#gamma#beta;#Delta(dE/dx)/#sigma(dE/dx)",100,0,10,100,-5,5); HTofdEdx2Pull=new TH2F("HTofdEdx2Pull","Proton energy loss in TOF plane 2;#gamma#beta;#Delta(dE/dx)/#sigma(dE/dx)",100,0,10,100,-5,5); gDirectory->cd("../"); gDirectory->mkdir("Cut")->cd(); HFDCdEdx_Phi_cut=new TH2F("HFDCdEdx_Phi_cut","K^{-} energy loss in FDC, Phi cut;#gamma#beta;dE/dx [MeV/cm]",1000,0,10,120,0,30); HCDCdEdx_Phi_cut=new TH2F("HCDCdEdx_Phi_cut","K^{-} energy loss in CDC, Phi cut;#gamma#beta;dE/dx [MeV/cm]",1000,0,10,120,0,30); HCDCdEdx_Lambda_cut=new TH2F("HCDCdEdx_Lambda_cut","K^{-} energy loss in CDC, Lambda cut;#gamma#beta;dE/dx [MeV/cm]",1000,0,10,120,0,30); HFDCdEdx_pi0_cut=new TH2F("HFDCdEdx_pi0_cut","electron energy loss in FDC, pi0 cut;#gamma#beta;dE/dx [MeV/cm]",1000,0,10,120,0,30); HCDCdEdx_pi0_cut=new TH2F("HCDCdEdx_pi0_cut","electron energy loss in CDC, pi0 cut;#gamma#beta;dE/dx [MeV/cm]",1000,0,10,120,0,30); HScdEdx_BCALcut=new TH2F("HScdEdx_BCALcut","Proton energy loss in SC, BCAL timing cut;#gamma#beta;dE/dx [MeV/cm]",100,0,10,120,0,15); HScdEdxDiff_BCALcut=new TH2F("HScdEdxDiff_BCALcut","Proton energy loss in SC, BCAL timing cut;#gamma#beta;#Delta(dE/dx) [MeV/cm]",100,0,10,120,-7.5,7.5); HScdEdxPull_BCALcut=new TH2F("HScdEdxPull_BCALcut","Proton energy loss in SC, BCAL timing cut;#gamma#beta;#Delta(dE/dx)/#sigma(dE/dx)",100,0,10,100,-5,5); HCDCdEdx_BCALcut=new TH2F("HCDCdEdx_BCALcut","Proton energy loss in CDC, BCAL timing cut;#gamma#beta;dE/dx [MeV/cm]",1000,0,10,120,0,30); HCDCdEdxDiff_BCALcut=new TH2F("HCDCdEdxDiff_BCALcut","Proton energy loss in CDC, BCAL timing cut;#gamma#beta;#Delta(dE/dx) [MeV/cm]",1000,0,10,120,-15,15); HCDCdEdxPull_BCALcut=new TH2F("HCDCdEdxPull_BCALcut","Proton energy loss in CDC, BCAL timing cut;#gamma#beta;#Delta(dE/dx)/#sigma(dE/dx)",1000,0,10,100,-5,5); HFDCdEdx_TOFcut=new TH2F("HFDCdEdx_TOFcut","Proton energy loss in FDC, TOF timing cut;#gamma#beta;dE/dx [MeV/cm]",1000,0,10,120,0,30); HFDCdEdxDiff_TOFcut=new TH2F("HFDCdEdxDiff_TOFcut","Proton energy loss in FDC, TOF timing cut;#gamma#beta;#Delta(dE/dx) [MeV/cm]",1000,0,10,120,-15,15); HFDCdEdxPull_TOFcut=new TH2F("HFDCdEdxPull_TOFcut","Proton energy loss in FDC, TOF timing cut;#gamma#beta;#Delta(dE/dx)/#sigma(dE/dx)",1000,0,10,100,-5,5); gDirectory->cd("../"); gDirectory->cd("../"); gDirectory->mkdir("E_over_p")->cd(); vectorleptons={Electron,Positron}; gDirectory->mkdir("Cut")->cd(); HBcalEOverP_pi0_cut=new TH2F("HBcalEOverP_pi0_cut","Electron E/p with cut; p [GeV/c]; E/p",100,0,10,100,0,2); HFcalEOverP_pi0_cut=new TH2F("HFcalEOverP_pi0_cut","Electron E/p with cut; p [GeV/c]; E/p",100,0,10,100,0,2); gDirectory->cd("../"); gDirectory->mkdir("Diff")->cd(); for (auto particle:leptons){ sprintf(hname,"HBcalEoverPDiff_%s",particleNames[particle]); sprintf(htitle,"%s BCAL E/p; p [GeV/c];#Delta(E/p)", particleNames[particle]); HBcalEoverPDiff[particle]=new TH2F(hname,htitle,100,0,10,100,-1,1); sprintf(hname,"HEcalEoverPDiff_%s",particleNames[particle]); sprintf(htitle,"%s ECAL E/p; p [GeV/c]; #Delta(E/p)", particleNames[particle]); HEcalEoverPDiff[particle]=new TH2F(hname,htitle,100,0,10,100,-1,1); sprintf(hname,"HFcalEoverPDiff_%s",particleNames[particle]); sprintf(htitle,"%s FCAL E/p; p [GeV/c]; #Delta(E/p)", particleNames[particle]); HFcalEoverPDiff[particle]=new TH2F(hname,htitle,100,0,10,100,-1,1); } gDirectory->cd("../"); gDirectory->mkdir("Pull")->cd(); for (auto particle:leptons){ sprintf(hname,"HBcalEoverPPull_%s",particleNames[particle]); sprintf(htitle,"%s BCAL E/p; p [GeV/c]; #Delta(E/p)/#sigma(E/p)", particleNames[particle]); HBcalEoverPPull[particle]=new TH2F(hname,htitle,100,0,10,100,-5,5); sprintf(hname,"HEcalEoverPPull_%s",particleNames[particle]); sprintf(htitle,"%s ECAL E/p; p [GeV/c]; #Delta(E/p)/#sigma(E/p)", particleNames[particle]); HEcalEoverPPull[particle]=new TH2F(hname,htitle,100,0,10,100,-5,5); sprintf(hname,"HFcalEoverPPull_%s",particleNames[particle]); sprintf(htitle,"%s FCAL E/p; p [GeV/c];#Delta(E/p)/#sigma(E/p)", particleNames[particle]); HFcalEoverPPull[particle]=new TH2F(hname,htitle,100,0,10,100,-5,5); } gDirectory->cd("../"); for (auto particle:leptons){ sprintf(hname,"HBcalEoverP_%s",particleNames[particle]); sprintf(htitle,"%s BCAL E/p; p [GeV/c]; E/p", particleNames[particle]); HBcalEoverP[particle]=new TH2F(hname,htitle,100,0,10,100,0,2); sprintf(hname,"HEcalEoverP_%s",particleNames[particle]); sprintf(htitle,"%s ECAL E/p; p [GeV/c]; E/p", particleNames[particle]); HEcalEoverP[particle]=new TH2F(hname,htitle,100,0,10,100,0,2); sprintf(hname,"HFcalEoverP_%s",particleNames[particle]); sprintf(htitle,"%s FCAL E/p; p [GeV/c]; E/p", particleNames[particle]); HFcalEoverP[particle]=new TH2F(hname,htitle,100,0,10,100,0,2); } gDirectory->cd("../"); gDirectory->cd("../.."); lockService->RootUnLock(); } //------------------ // BeginRun //------------------ void JEventProcessor_pidmon::BeginRun(const std::shared_ptr &event) { // This is called whenever the run number changes } //------------------ // Process //------------------ void JEventProcessor_pidmon::Process(const std::shared_ptr &event) { auto ctracks=event->Get(); if (ctracks.size()==0) return; auto neutrals=event->Get(); auto beamphotons=event->Get(); const DParticleID *mypid_algorithm; event->GetSingle(mypid_algorithm); double t0_rf=ctracks[0]->Get_BestTrackingFOM()->t0(); auto vertex=ctracks[0]->Get_BestTrackingFOM()->position(); double got_phi=false,got_pi0=false,got_lambda1520=false; if (ctracks.size()==3){ int numPos=0; int negIndex=0,posIndex[2]={0,0}; for (unsigned int i=0;iGet_Charge()>0){ if (numPos<2) posIndex[numPos]=i; numPos++; } else { negIndex=i; } } if (numPos==2){ vectorinTimeBeamPhotons; for(auto &beamphoton:beamphotons){ if (fabs(beamphoton->time()-t0_rf)<2.0){ inTimeBeamPhotons.push_back(beamphoton); } } if (inTimeBeamPhotons.size()>0){ lockService->WriteLock("pidmonlock"); DKinFitUtils_GlueX *kinFitUtils = new DKinFitUtils_GlueX(event); DKinFitter *kinFitter = new DKinFitter(kinFitUtils); kinFitUtils->Reset_NewEvent(); kinFitter->Reset_NewEvent(); map>chargedParticles; auto KmHyp=ctracks[negIndex]->Get_Hypothesis(KMinus); if (KmHyp!=nullptr){ vectorgammaParticles; const DChargedTrackHypothesis *protonHyp=nullptr; for (int i=0;i<2;i++){ auto KpHyp=ctracks[posIndex[i]]->Get_Hypothesis(KPlus); if (i==0) protonHyp=ctracks[posIndex[1]]->Get_Hypothesis(Proton); else protonHyp=ctracks[posIndex[0]]->Get_Hypothesis(Proton); if (KpHyp!=nullptr && protonHyp!=nullptr){ auto kpkm=KpHyp->lorentzMomentum()+KmHyp->lorentzMomentum(); auto pkm=protonHyp->lorentzMomentum()+KmHyp->lorentzMomentum(); HpKm->Fill(pkm.M()); HKpKm->Fill(kpkm.M()); chargedParticles.clear(); chargedParticles[KPlus].push_back(KpHyp->Get_TrackTimeBased()); chargedParticles[KMinus].push_back(KmHyp->Get_TrackTimeBased()); chargedParticles[Proton].push_back(protonHyp->Get_TrackTimeBased()); for (auto& beamphoton:inTimeBeamPhotons){ if (DoKinematicFit(t0_rf,vertex,beamphoton,chargedParticles, gammaParticles,kinFitUtils,kinFitter)){ double CL=kinFitter->Get_ConfidenceLevel(); if (CL>0.01){ DLorentzVector beam_kf; map>final_kf; GetKF4vectors(kinFitter,beam_kf,final_kf); auto kp4=final_kf[KPlus][0]; auto km4=final_kf[KMinus][0]; auto p4=final_kf[Proton][0]; kpkm=kp4+km4; pkm=p4+km4; HpKmKF->Fill(pkm.M()); HKpKmKF->Fill(kpkm.M()); if (fabs(kpkm.M()-1.02)<0.01) got_phi=true; if (pkm.M()>1.5 && pkm.M()<1.535) got_lambda1520=true; } } } } } } if (neutrals.size()==1){ auto gammaHyp=neutrals[0]->Get_Hypothesis(Gamma); auto electronHyp=ctracks[negIndex]->Get_Hypothesis(Electron); if (gammaHyp!=nullptr && electronHyp!=nullptr){ vectorgammaParticles; gammaParticles.push_back(*gammaHyp); auto emg=electronHyp->lorentzMomentum()+gammaHyp->lorentzMomentum(); for (int i=0;i<2;i++){ auto positronHyp=ctracks[posIndex[i]]->Get_Hypothesis(Positron); auto protonHyp=ctracks[posIndex[(i==1)?0:1]]->Get_Hypothesis(Proton); if (positronHyp!=nullptr && protonHyp!=nullptr){ auto pi0=emg+positronHyp->lorentzMomentum(); double pi0mass=pi0.M(); Hepemg->Fill(pi0mass); double CLbest=0.; chargedParticles.clear(); chargedParticles[Electron].push_back(electronHyp->Get_TrackTimeBased()); chargedParticles[Positron].push_back(positronHyp->Get_TrackTimeBased()); chargedParticles[Proton].push_back(protonHyp->Get_TrackTimeBased()); for (auto& beamphoton:inTimeBeamPhotons){ if (DoKinematicFit(t0_rf,vertex,beamphoton,chargedParticles, gammaParticles,kinFitUtils,kinFitter)){ double CL=kinFitter->Get_ConfidenceLevel(); if (CL>0.01){ DLorentzVector beam_kf; map>final_kf; GetKF4vectors(kinFitter,beam_kf,final_kf); auto em4=final_kf[Electron][0]; auto ep4=final_kf[Positron][0]; auto g4=final_kf[Gamma][0]; auto pi0_4=em4+ep4+g4; HepemgKF->Fill(pi0_4.M()); if (fabs(pi0_4.M()-ParticleMass(Pi0))<0.015){ got_pi0=true; auto neutralShower=gammaParticles[0].Get_NeutralShower(); if (neutralShower!=nullptr){ if (neutralShower->dDetectorSystem==SYS_ECAL){ const DECALShower *ecalshower=dynamic_cast(neutralShower->dBCALFCALShower); if (ecalshower!=nullptr){ auto ecalcluster=ecalshower->GetSingle(); if (ecalcluster!=nullptr){ HEpred_vs_Ecluster_ECAL->Fill(ecalcluster->E, g4.E()); } } } } } } } } } } } } delete kinFitter; delete kinFitUtils; lockService->Unlock("pidmonlock"); } } } lockService->RootFillLock(this); for (auto &ctrack:ctracks){ for (auto particle:particles){ auto hyp=ctrack->Get_Hypothesis(particle); if (hyp!=nullptr){ const DTrackTimeBased *track=hyp->Get_TrackTimeBased(); auto pvec=hyp->momentum(); double p=pvec.Mag(); double beta=p/hyp->lorentzMomentum().E(); double betagamma=p/ParticleMass(particle); double dEdx_cdc=1e6*hyp->Get_dEdx_CDC_amp(); double dEdx_fdc=1e6*track->ddEdx_FDC; double dedx_mean=0.; // from model double dEdx_CDC_diff=1e6,dEdx_FDC_diff=1e6,dEdx_SC_diff=1e6; double dEdx_CDC_pull=1e6,dEdx_FDC_pull=1e6,dEdx_SC_pull=1e6; if (dEdx_fdc>0.){ HFDCdEdx[particle]->Fill(betagamma,dEdx_fdc); if (mypid_algorithm->GetdEdxMean_FDC(beta,0,dedx_mean,particle) ==NOERROR){ dEdx_FDC_diff=dEdx_fdc-1e6*dedx_mean; unsigned int n_dedx=track->dNumHitsUsedFordEdx_FDC; double dedx_sigma=0.; // printf("%f ", dedx_sigma); mypid_algorithm->GetdEdxSigma_FDC(beta,n_dedx,dedx_sigma,particle); dedx_sigma*=1e6; dEdx_FDC_pull=dEdx_FDC_diff/dedx_sigma; HFDCdEdxDiff[particle]->Fill(betagamma,dEdx_FDC_diff); HFDCdEdxPull[particle]->Fill(betagamma,dEdx_FDC_pull); if (particle==KMinus && got_phi){ HFDCdEdx_Phi_cut->Fill(betagamma,dEdx_fdc); } if (particle==Electron && got_pi0){ HFDCdEdx_pi0_cut->Fill(betagamma,dEdx_fdc); } } } if (dEdx_cdc>0.){ HCDCdEdx[particle]->Fill(betagamma,dEdx_cdc); if (mypid_algorithm->GetdEdxMean_CDC(beta,0,dedx_mean,particle) ==NOERROR){ dEdx_CDC_diff=dEdx_cdc-1e6*dedx_mean; unsigned int n_dedx=track->dNumHitsUsedFordEdx_CDC; double dedx_sigma=0.; // printf("%f ", dedx_sigma); mypid_algorithm->GetdEdxSigma_CDC(beta,n_dedx,dedx_sigma,particle); dedx_sigma*=1e6; dEdx_CDC_pull=dEdx_CDC_diff/dedx_sigma; HCDCdEdxDiff[particle]->Fill(betagamma,dEdx_CDC_diff); HCDCdEdxPull[particle]->Fill(betagamma,dEdx_CDC_pull); if (particle==KMinus && got_phi){ HCDCdEdx_Phi_cut->Fill(betagamma,dEdx_cdc); } if (particle==KMinus && got_lambda1520){ HCDCdEdx_Lambda_cut->Fill(betagamma,dEdx_cdc); } if (particle==Electron && got_pi0){ HCDCdEdx_pi0_cut->Fill(betagamma,dEdx_cdc); } } } auto scparms=hyp->Get_SCHitMatchParams(); if (scparms!=nullptr){ HScdEdx->Fill(betagamma,1000.*scparms->dEdx); double dEdxmean=mypid_algorithm->GetProtondEdxMean_SC(beta); double dEdxsig=1000.*mypid_algorithm->GetProtondEdxSigma_SC(beta); dEdx_SC_diff=1000.*(scparms->dEdx-dEdxmean); dEdx_SC_pull=dEdx_SC_diff/dEdxsig; HScdEdxDiff->Fill(betagamma,dEdx_SC_diff); HScdEdxPull->Fill(betagamma,dEdx_SC_pull); } auto tofparms=hyp->Get_TOFHitMatchParams(); if (tofparms!=nullptr){ double dt=tofparms->dHitTime-tofparms->dFlightTime-t0_rf; HTofDt[particle]->Fill(p,dt); if (got_phi && particle==KMinus){ HTofDt_Phi_cut->Fill(p,dt); } if (particle==Proton && fabs(dt)<0.25){ if (tofparms->dEdx1>0 && tofparms->dEdx2>0){ HTofdEdx1->Fill(betagamma,1000.*tofparms->dEdx1); HTofdEdx2->Fill(betagamma,1000.*tofparms->dEdx2); double dedx_tof=mypid_algorithm->GetProtondEdxMean_TOF(beta); double dedx_tof_diff1=1000.*(tofparms->dEdx1-dedx_tof); double dedx_tof_diff2=1000.*(tofparms->dEdx2-dedx_tof); double dedx_tof_sigma=1000.*mypid_algorithm->GetProtondEdxSigma_TOF(beta); HTofdEdx1Diff->Fill(betagamma,dedx_tof_diff1); HTofdEdx2Diff->Fill(betagamma,dedx_tof_diff2); HTofdEdx1Pull->Fill(betagamma,dedx_tof_diff1/dedx_tof_sigma); HTofdEdx2Pull->Fill(betagamma,dedx_tof_diff2/dedx_tof_sigma); } HFDCdEdx_TOFcut->Fill(betagamma,dEdx_fdc); HFDCdEdxDiff_TOFcut->Fill(betagamma,dEdx_FDC_diff); HFDCdEdxPull_TOFcut->Fill(betagamma,dEdx_FDC_pull); } } auto bcalparms=hyp->Get_BCALShowerMatchParams(); if (bcalparms!=nullptr){ double E_over_p=bcalparms->dBCALShower->E/p; double dt=bcalparms->dBCALShower->t-bcalparms->dFlightTime-t0_rf; HBcalDt[particle]->Fill(p,dt); if (particle==Electron || particle==Positron){ HBcalEoverP[particle]->Fill(p,E_over_p); if (fabs(dt)<0.5){ double E_over_p_mean=mypid_algorithm->GetEOverPMean(SYS_BCAL,p); double E_over_p_diff=E_over_p-E_over_p_mean; double E_over_p_sigma=mypid_algorithm->GetEOverPSigma(SYS_BCAL,p); HBcalEoverPDiff[particle]->Fill(p,E_over_p_diff); HBcalEoverPPull[particle]->Fill(p,E_over_p_diff/E_over_p_sigma); if (particle==Electron && got_pi0){ HBcalEOverP_pi0_cut->Fill(p,E_over_p); } } } double sigma_t=sqrt(mypid_algorithm->GetTimeVariance(SYS_BCAL,particle,p)); double dt_corr=dt-mypid_algorithm->GetTimeMean(SYS_BCAL,particle,p); double pull=dt_corr/sigma_t; HBcalDtPull[particle]->Fill(p,pull); if (got_phi && particle==KMinus){ HBcalDt_Phi_cut->Fill(p,dt); } if (got_lambda1520 && particle==KMinus){ HBcalDt_Lambda_cut->Fill(p,dt); } if (particle==Proton){ if (scparms!=nullptr){ double sc_dedx=1000.*scparms->dEdx; if (fabs(dt)<0.5){ HScdEdx_BCALcut->Fill(betagamma,sc_dedx); HCDCdEdx_BCALcut->Fill(betagamma,dEdx_cdc); HScdEdxDiff_BCALcut->Fill(betagamma,dEdx_SC_diff); HCDCdEdxDiff_BCALcut->Fill(betagamma,dEdx_CDC_diff); HScdEdxPull_BCALcut->Fill(betagamma,dEdx_SC_pull); HCDCdEdxPull_BCALcut->Fill(betagamma,dEdx_CDC_pull); } if (dEdx_cdc>1.33/(betagamma*betagamma)+0.0694/betagamma+1. && sc_dedx>0.5/(betagamma*betagamma)+0.3/betagamma+0.8 ){ HBcalDt_dEdx_cut->Fill(p,dt); HBcalDtPull_dEdx_cut->Fill(p,pull); } } } } auto ecalparms=hyp->Get_ECALShowerMatchParams(); if (ecalparms!=nullptr){ double E_over_p=ecalparms->dECALShower->E/p; double dt=ecalparms->dECALShower->t-ecalparms->dFlightTime-t0_rf; HEcalDt[particle]->Fill(p,dt); if (particle==Electron || particle==Positron){ HEcalEoverP[particle]->Fill(p,E_over_p); } } auto fcalparms=hyp->Get_FCALShowerMatchParams(); if (fcalparms!=nullptr){ double E_over_p=fcalparms->dFCALShower->getEnergy()/p; double dt=fcalparms->dFCALShower->getTime()-fcalparms->dFlightTime-t0_rf; HFcalDt[particle]->Fill(p,dt); if (got_phi && particle==KMinus){ HFcalDt_Phi_cut->Fill(p,dt); } if (particle==Electron || particle==Positron){ HFcalEoverP[particle]->Fill(p,E_over_p); if (tofparms!=nullptr){ double dt_tof=tofparms->dHitTime-tofparms->dFlightTime-t0_rf; if (fabs(dt_tof)<0.25){ double E_over_p_mean=mypid_algorithm->GetEOverPMean(SYS_FCAL,p); double E_over_p_diff=E_over_p-E_over_p_mean; double E_over_p_sigma=mypid_algorithm->GetEOverPSigma(SYS_FCAL,p); HFcalEoverPDiff[particle]->Fill(p,E_over_p_diff); HFcalEoverPPull[particle]->Fill(p,E_over_p_diff/E_over_p_sigma); if (particle==Electron && got_pi0){ HFcalEOverP_pi0_cut->Fill(p,E_over_p); } } } } } } } } lockService->RootFillUnLock(this); } //------------------ // EndRun //------------------ void JEventProcessor_pidmon::EndRun() { // This is called whenever the run number changes, before it is // changed to give you a chance to clean up before processing // events from the next run number. } //------------------ // Finish //------------------ void JEventProcessor_pidmon::Finish() { // Called before program exit after event processing is finished. } // Run the kinematic fitter requiring energy and momentum conservation bool JEventProcessor_pidmon::DoKinematicFit(double t0_rf,const DVector3 &vertex, const DBeamPhoton *beamphoton, map >&chargedParticles, vector&gammaParticles, DKinFitUtils_GlueX *dKinFitUtils, DKinFitter *dKinFitter ) const { set> InitialParticles, FinalParticles; dKinFitter->Reset_NewFit(); shared_ptrmyBeam=dKinFitUtils->Make_BeamParticle(beamphoton); shared_ptrmyTarget=dKinFitUtils->Make_TargetParticle(Proton); InitialParticles.insert(myBeam); InitialParticles.insert(myTarget); // Vertex info DLorentzVector vert4; vert4.SetVect(vertex); vert4.SetT(t0_rf); // Charged particles for (auto& chargedParticle:chargedParticles){ for (auto& track:chargedParticle.second){ shared_ptrmyParticle=dKinFitUtils->Make_DetectedParticle(track); FinalParticles.insert(myParticle); } } // Final state photons for (unsigned int k=0;kmyGamma=dKinFitUtils->Make_DetectedParticle(22,0,0.,vert4,gammaHyp.momentum(),0.,gammaHyp.errorMatrix()); FinalParticles.insert(myGamma); } // make constraint shared_ptrlocP4Constraint = dKinFitUtils->Make_P4Constraint(InitialParticles, FinalParticles); // set constraint dKinFitter->Add_Constraint(locP4Constraint); // PERFORM THE KINEMATIC FIT return dKinFitter->Fit_Reaction(); } void JEventProcessor_pidmon::GetKF4vectors(DKinFitter *dKinFitter, DLorentzVector &beam_kf, map>&final_kf) const{ set>myParticles=dKinFitter->Get_KinFitParticles(); set>::iterator locParticleIterator=myParticles.begin(); for(; locParticleIterator != myParticles.end(); ++locParticleIterator){ if ((*locParticleIterator)->Get_KinFitParticleType()==d_BeamParticle){ beam_kf=(*locParticleIterator)->Get_P4(); } else if ((*locParticleIterator)->Get_KinFitParticleType()==d_DetectedParticle){ Particle_t myPID=PDGtoPType((*locParticleIterator)->Get_PID()); final_kf[myPID].push_back((*locParticleIterator)->Get_P4()); } } }