27 using iplink_t = ElementLink<xAOD::IParticleContainer>;
48 ATH_MSG_ERROR(
"failed to properly add softTrk affecting systematics " );
49 return StatusCode::FAILURE;
58 ATH_MSG_ERROR(
"failed to properly add softCalo affecting systematics " );
59 return StatusCode::FAILURE;
65 ATH_MSG_ERROR(
"failed to properly add jetTrk affecting systematics " );
66 return StatusCode::FAILURE;
75 ATH_MSG_DEBUG(
"These systematics are set based on your config files: " );
80 return StatusCode::SUCCESS;
93 if (lastchar !=
'/') {
99 m_configJetTrkFile.empty() )
ATH_MSG_WARNING(
"you have initialized the METSystematicsTool with no configuration file. The tool will do nothing. Please set the configuration file properties.");
110 ATH_MSG_INFO(
"Doing SoftCalo systematics initialization. THIS IS FOR SOFTWARE DEVELOPMENT ONLY.");
111 ATH_MSG_INFO(
"CST IS NOT YET RECOMMENDED OR SUPPORTED BY THE MET GROUP.");
113 std::string histfile =
"";
114 std::string systpath =
"";
115 std::string histpath =
"";
116 std::string suffix =
"";
120 TFile infile(histpath.c_str());
128 ATH_MSG_ERROR(
"Could not get all calo histos from the config file:" << histfile );
129 return StatusCode::FAILURE;
137 return StatusCode::SUCCESS;
145 std::string histfile =
"";
146 std::string gsystpath =
"";
147 std::string configdir =
"";
148 std::string blank =
"";
152 TFile infile((configdir).c_str());
157 ATH_MSG_ERROR(
"Could not get jet track histo from the config file:" << histfile);
158 return StatusCode::FAILURE;
164 return StatusCode::SUCCESS;
171 std::string histfile =
"";
172 std::string psystpath =
"";
173 std::string histpath =
"";
174 std::string suffix =
"";
178 TFile infile(histpath.c_str());
187 ATH_MSG_ERROR(
"Could not get all track histos from the config file:" << histfile );
188 return StatusCode::FAILURE;
196 return StatusCode::SUCCESS;
205 if( systSet.
empty() ) {
207 return StatusCode::SUCCESS;
208 }
else if( systSet.
size() > 1 ) {
209 ATH_MSG_WARNING(
"Tool does not support multiple systematics, returning unsupported" );
210 return StatusCode::FAILURE;
228 return StatusCode::FAILURE;
233 return StatusCode::SUCCESS;
244 ATH_MSG_WARNING(
"event info is empty, returning without applying correction");
249 ATH_MSG_WARNING(
"This tool should be applied to MC only. Return without changing the input MET object");
256 if(METcont ==
nullptr){
257 ATH_MSG_WARNING(
"MissingET object not owned by a container. Returning without applying correction" );
266 if( helper.map() ==
nullptr) {
267 ATH_MSG_WARNING(
"The MissingETAssociationMap for the given MissingETAssociationHelper is null. Returning without applying correction ");
274 ATH_MSG_WARNING(
"METSystematicsTool received a MissingET object it can't correct. You should only pass soft MET terms or jet track MET terms.");
284 if(outputmet !=
nullptr ){
285 ATH_MSG_WARNING(
"Please pass a nullptr to the 2nd argument of correctedCopy to fill the output pointer");
297 ATH_MSG_WARNING(
"This tool should be applied to MC only. Return without changing the input MET object");
304 if(METcont ==
nullptr){
305 ATH_MSG_WARNING(
"MissingET object not owned by a container. Unable to apply correction, returning output MET object as null" );
312 outputmet =
nullptr;
delete copy;
318 if( helper.map() ==
nullptr) {
319 ATH_MSG_WARNING(
"MissingETAssociationHelper contained a null MissingETAssociationMap pointer");
320 outputmet =
nullptr;
delete copy;
326 outputmet =
nullptr;
delete copy;
344 ATH_MSG_ERROR(
"not soft met, cannot apply soft term correction to this MET");
352 <<
", met = " << softMet.
met()
354 <<
", do syst? " << doSyst);
358 <<
", met = " << softMet.
met()
360 <<
", do syst? " << doSyst);
371 softMetStruct.
mpx = softMet.
mpx();
372 softMetStruct.
mpy = softMet.
mpy();
374 softMetStruct.
name = softMet.
name();
377 if(METcont ==
nullptr){
378 ATH_MSG_WARNING(
"failed to retrieve MET container from passed object");
383 double const ptHardMet = std::sqrt( ptHard.
mpx * ptHard.
mpx +
384 ptHard.
mpy * ptHard.
mpy ) ;
391 int phbin = std::as_const(*shiftHist)->GetXaxis()->FindBin( ptHardMet ) ;
392 if(phbin>(*shiftHist)->GetNbinsX()) phbin = (*shiftHist)->GetNbinsX();
394 int const jetbin = std::as_const(*shiftHist)->GetYaxis()->FindBin(njet);
396 double const scalePara = (*shiftHist)->GetBinContent(phbin,jetbin,mubin);
399 double smearPara(0), smearPerp(0);
408 softMetStruct =
variedSoftTerm(softMetStruct, ptHard, scalePara, 0.);
412 softMetStruct =
variedSoftTerm(softMetStruct, ptHard, -1.*scalePara, 0.);
416 softMetStruct =
variedSoftTerm(softMetStruct, ptHard, smearPara, 0.);
420 softMetStruct =
variedSoftTerm(softMetStruct, ptHard, 0., smearPerp);
425 softMetStruct =
variedSoftTerm(softMetStruct, ptHard, smearPara, smearPerp);
429 softMetStruct =
variedSoftTerm(softMetStruct, ptHard, smearPara, 0.);
433 softMetStruct =
variedSoftTerm(softMetStruct, ptHard, 0., smearPerp);
438 softMetStruct =
variedSoftTerm(softMetStruct, ptHard, smearPara, smearPerp);
441 ATH_MSG_DEBUG(
"No systematic applied, returning nominal MET term");
452 <<
", met = " << softMet.
met() );
463 ATH_MSG_ERROR(
"jet track systematics histogram not initialized properly.") ;
493 jettrkmet.
setMpx ( jettrkmet.
mpx() - trkvec.
cpx() * uncert);
494 jettrkmet.
setMpy ( jettrkmet.
mpy() - trkvec.
cpy() * uncert);
505 ATH_MSG_ERROR(
"jet track systematics histogram not initialized properly.") ;
515 std::vector<const xAOD::Jet*> jets;
518 ATH_MSG_ERROR(
"Invalid object of type " << (*jetlink)->type() <<
" in jet term");
521 jets.push_back(
static_cast<const xAOD::Jet*
>(*jetlink));
523 bool originalInputs = jets.empty() ? false : !
acc_originalObject.isAvailable(*jets.front());
534 if(std::abs(
jet->eta())<=2.5){
545 uncert = std::sqrt(uncert*uncert+uncert_frac*uncert_frac);
555 jettrkmet.
setMpx ( jettrkmet.
mpx()*(1 + uncert/(std::abs(jettrkmet.
mpx())*std::sqrt(2))));
556 jettrkmet.
setMpy ( jettrkmet.
mpy()*(1 + uncert/(std::abs(jettrkmet.
mpy())*std::sqrt(2))));
568 ATH_MSG_ERROR(
"MissingETAssociationMap null, error calculating jet track systematics.");
581 double const varPara,
582 double const varPerp)
const{
585 projection.
mpx += varPara;
586 projection.
mpy += varPerp;
593 double const ptHardMet = std::sqrt( ptHard.
mpx * ptHard.
mpx +
594 ptHard.
mpy * ptHard.
mpy );
596 double const ux = ptHard.
mpx/ptHardMet;
597 double const uy = ptHard.
mpy/ptHardMet;
598 double const projL = ux*softTerms.
mpx + uy*softTerms.
mpy;
599 double const projT = uy*softTerms.
mpx - ux*softTerms.
mpy;
619 if(truthiter == truthCont->end()){
626 ptHard.
mpx = truthmet.
mpx();
627 ptHard.
mpy = truthmet.
mpy();
636 ptHard.
mpx -= (*iMET)->mpx();
637 ptHard.
mpy -= (*iMET)->mpy();
638 ptHard.
sumet += (*iMET)->sumet();
642 if( ptHard.
sumet < 0 ) {
643 ATH_MSG_ERROR(
"PtHard has a negative sumet, returning ptHart = 0");
652 if(ptHard.
sumet<1.0e-6){
662 std::string & systpath ,
663 std::string & histpath,
664 std::string & suffix ,
670 std::string configpath =
"";
671 std::string configfile =
"";
684 default : configpath =
"";
687 ATH_MSG_INFO(
"Searching for configFile: " << configfile);
689 ATH_MSG_DEBUG(
"CALIBPATH: " << gSystem->Getenv(
"CALIBPATH") );
691 if(configpath.empty() || configfile.empty() ){
693 return StatusCode::FAILURE;
696 if( reader.ReadFile(configpath.c_str(),EEnvLevel(0)) < 0) {
698 return StatusCode::FAILURE;
701 ATH_MSG_INFO(
"Configuring from file : " << configpath );
706 histfile = reader.GetValue(
"Conf.InputFile" ,
"");
707 systpath = reader.GetValue(
"GlobalSyst.sourcedir" ,
"" );
710 histfile = reader.GetValue(
"Conf.InputFile" ,
"");
711 systpath = reader.GetValue(
"PtHardSyst.sourcedir" ,
"" );
712 suffix = reader.GetValue(
"PtHardSyst.suffix" ,
"" );
715 histfile = reader.GetValue(
"JetTrkSyst.InputFile" ,
"");
724 std::string
const units_string = reader.GetValue(
"Units",
"" );
728 if(units_string !=
"GeV"){
729 ATH_MSG_ERROR(
"initialized the different systematics using two config files that conflict on units");
730 return StatusCode::FAILURE;
734 if( (!units_string.empty()) && (units_string !=
"MeV")){
735 ATH_MSG_ERROR(
"initialized the different systematics using two config files that conflict on units");
736 return StatusCode::FAILURE;
741 if( (units_string.empty()) || (units_string ==
"MeV") ){
743 }
else if(units_string ==
"GeV"){
746 ATH_MSG_ERROR(
"You specified an incorrect 'Units' value. Please specify MeV , GeV , or leave it blank for MeV");
747 return StatusCode::FAILURE;
750 ATH_MSG_INFO(
"Will read histograms from : " << histfile );
753 ATH_MSG_INFO(
"Extracted histogram path : " << histpath);
755 if(histfile.empty() || systpath.empty() || histpath.empty() ){
756 ATH_MSG_ERROR(
"Failed to correctly set histfile path, or path to histograms inside of the histfile" );
757 return StatusCode::FAILURE;
762 ATH_MSG_ERROR(
"Something is wrong with your units initialization. Please contact the developers (you should never get here).");
763 return StatusCode::FAILURE;
766 return StatusCode::SUCCESS;
777 ATH_MSG_ERROR(
"Failed to retrieve default EventInfo object");
787 ATH_MSG_ERROR(
"Failed to retrieve default NPV value from PrimaryVertices");
793 for (itr = vertices->begin(); itr != vertices->end(); ++itr)
802 random =
new TRandom3();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
Class to wrap a set of SystematicVariations.
bool empty() const
returns: whether the set is empty
const_iterator begin() const
description: const iterator to the beginning of the set
size_t size() const
returns: size of the set
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
SG::ConstAccessor< T, ALLOC > ConstAccessor
const SG::AuxVectorData * container() const
Return the container holding this element.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
@ IS_SIMULATION
true: simulation, false: data
Class providing the definition of the 4-vector interface.
float sumpt() const
Returns sum of component pt.
float cpx() const
Returns .
float cpy() const
Returns .
ConstVec overlapTrkVec(const MissingETAssociationHelper &helper) const
Retrieve total track-based vector to be subtracted from the jet.
ConstVec jetTrkVec() const
Get track constituent vector for the reference jet.
const_iterator find(const std::string &name) const
Find non-modifiable MET object by name.
void setMpy(float value)
Set the component.
float sumet() const
Returns.
MissingETBase::Types::bitmask_t source() const
MET object source tag.
void setSource(MissingETBase::Types::bitmask_t src)
Set the source of the MET object.
float met() const
Returns .
void setMpx(float value)
Set the component.
const std::string & name() const
Identifier getters.
float mpx() const
Returns .
void setName(const std::string &name)
Set the name of the MET object.
float mpy() const
Returns .
void setSumet(float value)
Set .
xAOD::MissingETAssociation_v1::ConstVec constvec_t
Type for constituent vector.
static const CP::SystematicVariation MET_JetTrk_ScaleDown("MET_JetTrk_Scale__1down")
static const CP::SystematicVariation MET_JetTrk_ScaleUp("MET_JetTrk_Scale__1up")
static const CP::SystematicVariation MET_SoftCalo_ResoPara("MET_SoftCalo_ResoPara")
static const CP::SystematicVariation MET_SoftCalo_ResoPerp("MET_SoftCalo_ResoPerp")
static const CP::SystematicVariation MET_SoftCalo_ScaleUp("MET_SoftCalo_Scale__1up")
static const CP::SystematicVariation MET_SoftCalo_ScaleDown("MET_SoftCalo_Scale__1down")
static const CP::SystematicVariation MET_SoftCalo_ResoCorr("MET_SoftCalo_ResoCorr")
static const CP::SystematicVariation MET_SoftTrk_ResoPara("MET_SoftTrk_ResoPara")
static const CP::SystematicVariation MET_SoftTrk_ResoPerp("MET_SoftTrk_ResoPerp")
static const CP::SystematicVariation MET_SoftTrk_ResoCorr("MET_SoftTrk_ResoCorr")
static const CP::SystematicVariation MET_SoftTrk_ScaleDown("MET_SoftTrk_Scale__1down")
static const CP::SystematicVariation MET_SoftTrk_ScaleUp("MET_SoftTrk_Scale__1up")
ElementLink< xAOD::IParticleContainer > iplink_t
static const SG::AuxElement::ConstAccessor< iplink_t > acc_originalObject("originalObjectLink")
static const SG::AuxElement::ConstAccessor< std::vector< iplink_t > > acc_constitObjLinks("ConstitObjectLinks")
@ Jet
The object is a jet.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
Jet_v1 Jet
Definition of the current "jet version".
MissingETAssociation_v1 MissingETAssociation
Version control by type definition.
EventInfo_v1 EventInfo
Definition of the latest event info version.
MissingET_v1 MissingET
Version control by type defintion.
MissingETContainer_v1 MissingETContainer
MissingETAssociationMap_v1 MissingETAssociationMap
Version control by type defintion.
static Types::bitmask_t jet(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed jets.
static bool isSoftTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static bool isTrackTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static Types::bitmask_t truthNonInt()
Standard bit pattern indicating genuine true MET.
static bool isTotalTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static bool isJetTerm(Types::bitmask_t bits, Region reg=Region::FullAcceptance)
static const MissingETAssociation * getAssociation(const MissingETAssociationMap *pMap, const Jet *pJet)
MissingETBase::Types::bitmask_t source