diff --git a/Trigger/EFTracking/EFTrackingEmulation/python/EFTrackingSmearingConfig.py b/Trigger/EFTracking/EFTrackingEmulation/python/EFTrackingSmearingConfig.py index 344a29491953aa2a42a0f0498b22d81ef7f8d61c..f98dfac95b5fdfb6ddc01b66a38eb5f404448399 100644 --- a/Trigger/EFTracking/EFTrackingEmulation/python/EFTrackingSmearingConfig.py +++ b/Trigger/EFTracking/EFTrackingEmulation/python/EFTrackingSmearingConfig.py @@ -20,10 +20,14 @@ def EFTrackingSmearingCfg(flags, name = "EFTrackingSmearingAlg", **kwargs): SmearTruthParticle = kwargs['smearTruthParticle'], OutputTracksPtCutGeV = kwargs['trkpTCut'], EnableMonitoring = kwargs['EnableMonitoring'], - RootStreamName = name, + RootStreamName = name, RootDirName = "/EFTSmearing/" ) + if 'parameterizedTrackEfficiency_LRT' in kwargs: + alg.ParameterizedTrackEfficiency_LRT = kwargs['parameterizedTrackEfficiency_LRT'] + alg.SmearedTrackEfficiency_d0low_LRT = kwargs['smearedTrackEfficiency_d0low_LRT'] + alg.SmearedTrackEfficiency_d0high_LRT= kwargs['smearedTrackEfficiency_d0high_LRT'] if kwargs['smearTruthParticle']: alg.OutputTruthParticleContainer = "TruthParticle_smeared_SF"+str(kwargs['smearFactor']) @@ -62,17 +66,20 @@ if __name__ == "__main__": acc.merge(AddDecoratorCfg(flags)) TestsmearFactor = 2 - # example to smear the track particles with smearing factor =2 and efficiency 90% + TestEfficiencyFactor=1 + # example to smear the track particles smearerTrack = EFTrackingSmearingCfg(flags, name="testTrack", trkpTCut=1, smearFactor=TestsmearFactor, InputTrackParticle="InDetTrackParticles", - trackEfficiency=0.9, parameterizeEfficiency=False, smearTruthParticle=False, + trackEfficiency=TestEfficiencyFactor, parameterizeEfficiency=False, smearTruthParticle=False, EnableMonitoring=True, OutputLevel=INFO) acc.merge(smearerTrack) - # example to smear the truth particles with smearing factor =2 and efficiency 90% + # example to smear the truth particles smearerTruth = EFTrackingSmearingCfg(flags, name="testTruth", trkpTCut=1, smearFactor=TestsmearFactor, InputTruthParticle="TruthParticles", - trackEfficiency=0.9, parameterizeEfficiency=False, ParameterizedTrackEfficiencyLRT = True, smearTruthParticle=True, - EnableMonitoring=True, OutputLevel=INFO) + trackEfficiency=TestEfficiencyFactor, parameterizeEfficiency=False, + parameterizedTrackEfficiency_LRT = True, smearTruthParticle=True, + smearedTrackEfficiency_d0low_LRT=.001, smearedTrackEfficiency_d0high_LRT=400., + EnableMonitoring=True, OutputLevel=2) acc.merge(smearerTruth) diff --git a/Trigger/EFTracking/EFTrackingEmulation/src/EFTrackingSmearingAlg.cxx b/Trigger/EFTracking/EFTrackingEmulation/src/EFTrackingSmearingAlg.cxx index e0cb8499efdaf3b306bcdfc20f227f696f5770df..42f99fe561877abf40c8f052b19f775e15bd3585 100644 --- a/Trigger/EFTracking/EFTrackingEmulation/src/EFTrackingSmearingAlg.cxx +++ b/Trigger/EFTracking/EFTrackingEmulation/src/EFTrackingSmearingAlg.cxx @@ -123,7 +123,9 @@ StatusCode EFTrackingSmearingAlg::initialize() { ATH_MSG_INFO("------- SmearingSigma: "<<m_SigmaScaleFactor); ATH_MSG_INFO("------- trackEfficiency: "<<m_smearedTrackEfficiency); ATH_MSG_INFO("------- parameterizedEfficiency: "<<m_parameterizedTrackEfficiency); - ATH_MSG_INFO("------- parameterizedEfficiency LRT: "<<m_parameterizedTrackEfficiency_LRT); + ATH_MSG_INFO("------- parameterizedEfficiency LRT: "<<m_parameterizedTrackEfficiency_LRT); + ATH_MSG_INFO("------- parameterizedEfficiency LRT high d0 cut: "<<m_smearedTrackEfficiency_d0high_LRT ); + ATH_MSG_INFO("------- parameterizedEfficiency LRT low d0 cut: "<<m_smearedTrackEfficiency_d0low_LRT ); ATH_MSG_INFO("------- UseResolutionPtCutOff: "<<m_UseResolutionPtCutOff); ATH_MSG_INFO("------- SetResolutionPtCutOff: "<<m_SetResolutionPtCutOff); ATH_MSG_INFO("------- EnableMonitoring:" <<m_enableMonitoring); @@ -152,7 +154,10 @@ StatusCode EFTrackingSmearingAlg::initialize() { ((FakeTrackSmearer *) m_mySmearer)->SetOutputTracksPtCut(m_outputTracksPtCut); ((FakeTrackSmearer *) m_mySmearer)->SetTrackingEfficiency(m_smearedTrackEfficiency); ((FakeTrackSmearer *) m_mySmearer)->SetParameterizedEfficiency(m_parameterizedTrackEfficiency); - ((FakeTrackSmearer *) m_mySmearer)->SetParameterizedEfficiency_LRT(m_parameterizedTrackEfficiency_LRT); + ((FakeTrackSmearer *) m_mySmearer)->SetParameterizedEfficiency_LRT(m_parameterizedTrackEfficiency_LRT); + ((FakeTrackSmearer *) m_mySmearer)->SetParameterizedEfficiency_highd0_LRT(m_smearedTrackEfficiency_d0high_LRT); + ((FakeTrackSmearer *) m_mySmearer)->SetParameterizedEfficiency_lowd0_LRT(m_smearedTrackEfficiency_d0low_LRT); + ((FakeTrackSmearer *) m_mySmearer)->SetSigmaScaleFactor(m_SigmaScaleFactor.value()); ((FakeTrackSmearer *) m_mySmearer)->UseResolutionPtCutOff(m_UseResolutionPtCutOff.value()); ((FakeTrackSmearer *) m_mySmearer)->SetResolutionPtCutOff(m_SetResolutionPtCutOff.value()); @@ -170,18 +175,22 @@ StatusCode EFTrackingSmearingAlg::initialize() { TF1 *d0res_pt = ((FakeTrackSmearer *) m_mySmearer)->d0res_pt; TF1 *z0res_pt = ((FakeTrackSmearer *) m_mySmearer)->z0res_pt; TF1 *curvres_pt = ((FakeTrackSmearer *) m_mySmearer)->curvres_pt; - CHECK(book(new TH1F("d0res_function_vs_eta","#eta of track (p_T=10GeV);#eta",100, 0.0,4.0))); - CHECK(book(new TH1F("z0res_function_vs_eta","#eta of track (p_T=10GeV);#eta",100, 0.0,4.0))); - CHECK(book(new TH1F("curvres_function_vs_eta","#eta of track (p_T=10GeV);#eta",100, 0.0,4.0))); - CHECK(book(new TH1F("d0res_function_vs_pt","#pt of track (#eta=1);p_T [GeV]",100, 1.0,200.0))); - CHECK(book(new TH1F("z0res_function_vs_pt","#pt of track (#eta=1);p_T [GeV]",100, 1.0,200.0))); - CHECK(book(new TH1F("curvres_function_vs_pt","#pt of track (#eta=1);p_T [GeV]",100, 1.0,200.0))); + TF1 *effLRT_d0 = ((FakeTrackSmearer *) m_mySmearer)->effLRT_d0; + + CHECK(book(new TH1F("d0res_function_vs_eta","#eta of track (p_{T}=10GeV);#eta",100, 0.0,4.0))); + CHECK(book(new TH1F("z0res_function_vs_eta","#eta of track (p_{T}=10GeV);#eta",100, 0.0,4.0))); + CHECK(book(new TH1F("curvres_function_vs_eta","#eta of track (p_{T}=10GeV);#eta",100, 0.0,4.0))); + CHECK(book(new TH1F("d0res_function_vs_pt","p_{T} of track (#eta=1);p_{T} [GeV]",100, 1.0,200.0))); + CHECK(book(new TH1F("z0res_function_vs_pt","p_{T} of track (#eta=1);p_{T} [GeV]",100, 1.0,200.0))); + CHECK(book(new TH1F("curvres_function_vs_pt","p_{T} of track (#eta=1);p_{T} [GeV]",100, 1.0,200.0))); + CHECK(book(new TH1F("effLRT_function_vs_d0","d_{0} of track;d_{0} [mm]",100, 0.001,600.0))); hist("d0res_function_vs_eta")->Add(d0res_eta); hist("z0res_function_vs_eta")->Add(z0res_eta); hist("curvres_function_vs_eta")->Add(curvres_eta); hist("d0res_function_vs_pt")->Add(d0res_pt); hist("z0res_function_vs_pt")->Add(z0res_pt); hist("curvres_function_vs_pt")->Add(curvres_pt); + hist("effLRT_function_vs_d0")->Add(effLRT_d0); // book historgams CHECK(book_histograms()); } @@ -267,13 +276,16 @@ StatusCode EFTrackingSmearingAlg::smearTruthParticles(const EventContext& ctx) { xAOD::TruthParticle * newtrk = new xAOD::TruthParticle(*part); outputTruth->push_back(newtrk); *newtrk = *part; - // set the decorators - d0Decorator(*newtrk) = otrack.d0(); - z0Decorator(*newtrk) = otrack.z0(); - ptDecorator(*newtrk) = otrack.pt()*1000.; - //TrackParticle has already ::pt(), so the smeared value is in the decorator - // and can be accessed by - auto newpt = newtrk->auxdata<float>("pt"); + auto newpt = part->pt(); + if (m_SigmaScaleFactor !=0) { + // set the decorators + d0Decorator(*newtrk) = otrack.d0(); + z0Decorator(*newtrk) = otrack.z0(); + ptDecorator(*newtrk) = otrack.pt()*1000.; //MeV + //TrackParticle has already ::pt(), so the smeared value is in the decorator + // and can be accessed by + newpt = newtrk->auxdata<float>("pt"); + } if (newpt==0.) continue; ATH_MSG_DEBUG ("Smeared Truth: " <<" curv=" << 1./newpt diff --git a/Trigger/EFTracking/EFTrackingEmulation/src/EFTrackingSmearingAlg.h b/Trigger/EFTracking/EFTrackingEmulation/src/EFTrackingSmearingAlg.h index cb2b9e264e86ea84a4ba0807c562be6837ae4984..3e09c8df7153016d71a7a7da7d2cb4261575ccc5 100644 --- a/Trigger/EFTracking/EFTrackingEmulation/src/EFTrackingSmearingAlg.h +++ b/Trigger/EFTracking/EFTrackingEmulation/src/EFTrackingSmearingAlg.h @@ -52,11 +52,14 @@ class EFTrackingSmearingAlg: public ::AthHistogramAlgorithm { DoubleProperty m_inputTracksPtCut {this, "InputTracksPtCutGeV", 0.0, "Set input track pT cut"}; DoubleProperty m_outputTracksPtCut {this, "OutputTracksPtCutGeV", 1.0, "Set the output track pT cut"}; DoubleProperty m_smearedTrackEfficiency{this, "SmearedTrackEfficiency", 1.0, "Set track efficiency for smearing"}; - BooleanProperty m_parameterizedTrackEfficiency{this, "ParameterizedTrackEfficiency", false, "Enable parameterized efficiency for smearing"}; - BooleanProperty m_parameterizedTrackEfficiency_LRT{this, "ParameterizedTrackEfficiencyLRT", false, "Enable parameterized efficiency for LRT smearing"}; + BooleanProperty m_parameterizedTrackEfficiency{this, "ParameterizedTrackEfficiency", false, "Enable parameterized efficiency for smearing"}; BooleanProperty m_enableMonitoring {this, "EnableMonitoring", false, "Enable debugging monitoring of the algorithm"}; BooleanProperty m_smearTruthParticle {this, "SmearTruthParticle", false, "Enable smearing on truth particles, disabling the track smearing"}; - + // this is for LRT + BooleanProperty m_parameterizedTrackEfficiency_LRT{this, "ParameterizedTrackEfficiency_LRT", false, "Enable parameterized efficiency for LRT smearing"}; + DoubleProperty m_smearedTrackEfficiency_d0high_LRT{this, "SmearedTrackEfficiency_d0high_LRT", 1.0, "Set high d0 value for smeared track efficiency LRT"}; + DoubleProperty m_smearedTrackEfficiency_d0low_LRT{this, "SmearedTrackEfficiency_d0low_LRT", 1.0, "Set low d0 value for smeared track efficiency LRT"}; + // these are for fake emulations BooleanProperty m_EnableFakes {this,"IncludeDuplicatesAndFakes",false,"Enable fake track production"}; BooleanProperty m_FakeKillerEnable {this,"FakeKillerEnable",false, "disable inclusion of broad fakes"}; diff --git a/Trigger/EFTracking/EFTrackingEmulation/src/FakeTrackSmearer.h b/Trigger/EFTracking/EFTrackingEmulation/src/FakeTrackSmearer.h index 78f2bbb2f32cb7aec9cd905ec5e9905888e3e8fb..a11d2a59c4f7a9c67affdac101d2d1049ffd03e2 100644 --- a/Trigger/EFTracking/EFTrackingEmulation/src/FakeTrackSmearer.h +++ b/Trigger/EFTracking/EFTrackingEmulation/src/FakeTrackSmearer.h @@ -77,6 +77,11 @@ class FakeTrackSmearer name="z0ref_pt"+m_baseName; z0ref_pt=new TF1(name.c_str(),[&](double*x,double*p){return z0RefFunc(p[0]=1.,x[0],0); },1.0,200.0,1); + name="effLRT_d0"+m_baseName; + m_parameterizedEfficiency_lowd0_LRT = 10.; + m_parameterizedEfficiency_highd0_LRT = 400.; + effLRT_d0=new TF1(name.c_str(),[&](double*x, double*p){p[0]=1.;return effFuncLRT(x[0],0); },0.,600.0,1); + } @@ -144,10 +149,10 @@ double effFunc(double eta,double pt,int verbose) return FitFunctions::getEffParam_N(eta,pt,verbose); } -double effFuncLRT(double eta,double pt, double d0, int verbose) +double effFuncLRT(double d0, int verbose) { // add here other efficiency functions - return FitFunctions::getEffParam_LRT(eta,pt,d0,verbose); + return FitFunctions::getEffParam_LRT(d0, m_parameterizedEfficiency_lowd0_LRT, m_parameterizedEfficiency_highd0_LRT, verbose); } void InitArray(double *a,int n,const double in[]) @@ -185,8 +190,9 @@ double effFuncLRT(double eta,double pt, double d0, int verbose) // input curv is in GeV bool verbose=m_verbose; - double abseta=std::abs(eta); - double abspt=std::abs(1.0/curv); //GeV + double abseta = std::abs(eta); + double abspt = std::abs(1.0/curv); //GeV + double absd0 = std::abs(d0); if (verbose) printf("Smearer::AddTrack: Initial track: curv = %f, phi=%f, eta=%f, d0=%f, z0=%f (pt=%f)\n", curv, phi, eta, d0, z0, abspt); @@ -230,7 +236,7 @@ double effFuncLRT(double eta,double pt, double d0, int verbose) eff = eff * effFunc(abseta,abspt,verbose); } else if (m_parameterizedEfficiency_LRT) { - eff = eff * effFuncLRT(abseta,abspt, d0, verbose); + eff = eff * effFuncLRT( absd0, verbose); } int ntracks=( m_myRandom->Rndm()<eff)?1:0; @@ -341,6 +347,16 @@ double effFuncLRT(double eta,double pt, double d0, int verbose) m_parameterizedEfficiency_LRT=param; } + void SetParameterizedEfficiency_highd0_LRT(double d0) + { + m_parameterizedEfficiency_highd0_LRT = d0; + } + + void SetParameterizedEfficiency_lowd0_LRT(double d0) + { + m_parameterizedEfficiency_lowd0_LRT = d0; + } + std::vector<EFTrackingSmearing::FTS_Track> Tracks; double z0(int idx) {return Tracks[idx].z0();}; double d0(int idx) {return Tracks[idx].d0();}; @@ -365,6 +381,7 @@ double effFuncLRT(double eta,double pt, double d0, int verbose) TF1 *z0ref_pt = nullptr; TF1 *curvres_eta = nullptr; TF1 *curvres_pt = nullptr; + TF1 *effLRT_d0 = nullptr; private: @@ -391,6 +408,9 @@ double effFuncLRT(double eta,double pt, double d0, int verbose) double m_resolutionPtCutOff=0.0; double m_inPtCut = 0.0; double m_outPtCut = 1.0; + double m_parameterizedEfficiency_highd0_LRT = 0.; + double m_parameterizedEfficiency_lowd0_LRT = 0.; + }; diff --git a/Trigger/EFTracking/EFTrackingEmulation/src/FitFunctions/URD/effFitparam_LRT.C b/Trigger/EFTracking/EFTrackingEmulation/src/FitFunctions/URD/effFitparam_LRT.C index a14ed65f16005eed800efa35f78f923ef6ca3ffd..41ff4e7eec742062dc980aaa3315c7918a4e8e38 100644 --- a/Trigger/EFTracking/EFTrackingEmulation/src/FitFunctions/URD/effFitparam_LRT.C +++ b/Trigger/EFTracking/EFTrackingEmulation/src/FitFunctions/URD/effFitparam_LRT.C @@ -4,32 +4,21 @@ #include <cmath> #include <iostream> -double getEffParam_LRT(float abstrketa, float trkpt, double d0, bool debug=false) { +double getEffParam_LRT( double absd0, double lowd0_cut, double highd0_cut, bool debug=false) { - double eff = 1; - if (d0 > 3) eff = 0.1; - if (abstrketa<0.5) { - if (trkpt<2.) - eff = 0.89; - else if (trkpt<3.) - eff = 0.91; - else - eff = 0.92; - } else if (abstrketa<1.5) { - if (trkpt<2.) - eff = 0.87; - else if (trkpt<3.) - eff = 0.90; - else - eff = 0.91; - } else { - if (trkpt<2.) - eff = 0.77; - else if (trkpt<3.) - eff = 0.80; - else - eff = 0.80; - } + double eff = 1.; + + // 100%, 80% and 20% + + // step function example (commented out for now) + /* + if (absd0 > lowd0_cut && absd0 <= highd0_cut) eff = 0.8; + else if (absd0 > highd0_cut) eff = 0.2; + */ + + // can be also: double inverted Fermi can do the job? + + eff= (0.2/(1. + std::exp(0.5*(absd0-lowd0_cut))) + 0.6/(1. + std::exp(0.05*(absd0-highd0_cut))) + 0.2); if (debug) printf("eff = %f\n", eff); return eff;