ATLAS Offline Software
Loading...
Searching...
No Matches
testTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8#include "xAODJet/Jet.h"
14
18
19#ifdef ROOTCORE
22#endif // ROOTCORE
23
24int main (int argc, char* argv[])
25{
26 bool isLargeR = false;
27 if (argc == 2)
28 isLargeR = TString(argv[1]).EqualTo("true",TString::kIgnoreCase) || TString(argv[1]).EqualTo("largeR",TString::kIgnoreCase) || TString(argv[1]).EqualTo("large-R",TString::kIgnoreCase);
29
30 StatusCode::enableFailure();
31
32 JetUncertaintiesTool* tool = new JetUncertaintiesTool("JESprov");
33 //tool->msg().setLevel(MSG::DEBUG);
34 if (!isLargeR && tool->setProperty("JetDefinition","AntiKt4EMTopo").isFailure())
35 exit(1);
36 if (isLargeR && tool->setProperty("JetDefinition","AntiKt10LCTopoTrimmedPtFrac5SmallR20").isFailure())
37 exit(1);
38
39 if (tool->setProperty("MCType","MC15").isFailure())
40 exit(1);
41
42 //if (!isLargeR && tool->setProperty("ConfigFile","JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config").isFailure())
43 if (!isLargeR && tool->setProperty("ConfigFile","JES_2015/Moriond2016/JES2015_AllNuisanceParameters.config").isFailure())
44 exit(1);
45 //if (isLargeR && tool->setProperty("ConfigFile","UJ_2015/Prerec/Prerec2015_WZTagging.config").isFailure())
46 if (isLargeR && tool->setProperty("ConfigFile","UJ_2015/Moriond2016/UJ2015_WZTagging_medium.config").isFailure())
47 exit(1);
48
49 if (tool->setScaleToGeV().isFailure())
50 exit(1);
51 if (tool->initialize().isFailure())
52 exit(1);
53
54
55 // Build a jet container and a jet for us to manipulate later
56 xAOD::TEvent event;
57 xAOD::TStore store;
59 jets->setStore(new xAOD::JetAuxContainer());
60 jets->push_back(new xAOD::Jet());
61 xAOD::Jet* jet = jets->at(0);
62
63 // Build an EventInfo object for us to manipulate later
65 eInfos->setStore(new xAOD::EventInfoAuxContainer());
66 eInfos->push_back(new xAOD::EventInfo());
67 xAOD::EventInfo* eInfo = eInfos->at(0);
68
69
70
71 // General tests
72
73 // Print the list of affecting systematics
74 //CP::SystematicSet affectingSystematics = tool->affectingSystematics();
75 //for (CP::SystematicSet::iterator iter = affectingSystematics.begin(); iter != affectingSystematics.end(); ++iter)
76 // std::cout << iter->basename() << std::endl;
77
78
79 // Get the active categories and print components per category
80 std::vector<std::string> categories = tool->getComponentCategories();
81 for (size_t iCat = 0; iCat < categories.size(); ++iCat)
82 {
83 printf("Category %s:\n",categories.at(iCat).c_str());
84 std::vector<std::string> compInCategory = tool->getComponentNamesInCategory(categories.at(iCat));
85 for (size_t iComp = 0; iComp < compInCategory.size(); ++iComp)
86 printf("\t\t%s\n",compInCategory.at(iComp).c_str());
87 }
88
89 // Get the list of recommended systematics
90 // https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInROOT
92 const CP::SystematicSet& recommendedSystematics = registry.recommendedSystematics();
93 std::vector<CP::SystematicSet> sysList = CP::make_systematics_vector(recommendedSystematics);
94 printf("\nRecommended systematics (%zux2+1=%zu%s):\n",recommendedSystematics.size(),sysList.size(),recommendedSystematics.size()*2+1==sysList.size()?"":" FAILED");
95 for (size_t iSyst = 0; iSyst < sysList.size(); ++iSyst)
96 if (sysList.at(iSyst).name() == "")
97 printf("\t%40s\n","NOMINAL");
98 else
99 printf("\t%40s%s",sysList.at(iSyst).name().c_str(),iSyst%2==0?"\n":"");
100 printf("\n");
101
102
103 // small-R tests
104 if (!isLargeR)
105 {
106
107 // Confirm that the systematic recognition is working
108 printf("Recognizes JET_Flavor_Response__continuous: %s\n",tool->isAffectedBySystematic(CP::SystematicVariation("JET_Flavor_Response__continuous"))?"true":"false");
109 printf("Recognizes JET_Flavor_Response: %s\n",tool->isAffectedBySystematic(CP::SystematicVariation("JET_Flavor_Response"))?"true":"false");
110
111 //printf("Full: %s, base: %s\n",CP::SystematicVariation("JET_Flavor_Response__continuous",-1.5).name().c_str(),CP::SystematicVariation("JET_Flavor_Response__continuous",-1.5).basename().c_str());
112 //printf("Full: %s, base: %s\n",CP::SystematicVariation("JET_Flavor_Response",-1.5).name().c_str(),CP::SystematicVariation("JET_Flavor_Response",-1.5).basename().c_str());
113
114
115 // Add Nsegments information
116 // 25 segments is about average for jets receiving a correction
117 SG::AuxElement::Accessor<int> Nsegments("GhostMuonSegmentCount");
118 SG::AuxElement::Accessor<char> IsBjet("IsBjet");
119 Nsegments(*jet) = 0;
120 IsBjet(*jet) = false;
121
122 // Add mu and NPV information
123 SG::AuxElement::Accessor<float> mu("averageInteractionsPerCrossing");
125 mu(*eInfo) = 22;
126 NPV(*eInfo) = 11;
127
128
129
130 // Specify which systematics to vary
131 printf("Trying (Flavor_Response)x(-1.5) + (PunchThrough_MC15)x(+1.5)\n");
133 syst->insert(CP::SystematicVariation("JET_Flavor_Response",-1.5));
134 syst->insert(CP::SystematicVariation("JET_PunchThrough_MC15",+1.5));
135 if (tool->applySystematicVariation(*syst) != StatusCode::SUCCESS)
136 exit(2);
137
138 // Try below eta boundary of flavour
139 jet->setJetP4(xAOD::JetFourMom_t(100,-4.5,0.,0.));
140 printf("%20s: (pT,eta) = (%.0f,%.1f)","below eta boundary",jet->pt(),jet->eta());
141 if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
142 exit(3);
143 printf(" --> (%.0f,%.1f)\n",jet->pt(),jet->eta());
144
145 // Now try with opposite shift
146 delete syst;
147 syst = new CP::SystematicSet();
148 syst->insert(CP::SystematicVariation("JET_Flavor_Response",+1.5));
149 syst->insert(CP::SystematicVariation("JET_PunchThrough_MC15",+1.5));
150 if (tool->applySystematicVariation(*syst) != StatusCode::SUCCESS)
151 exit(2);
152
153 // Re-try below eta boundary of flavour
154 jet->setJetP4(xAOD::JetFourMom_t(100,-4.5,0.,0.));
155 printf("%20s: (pT,eta) = (%.0f,%.1f)","(Flavor)x(+1.5)",jet->pt(),jet->eta());
156 if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
157 exit(3);
158 printf(" --> (%.0f,%.1f)\n",jet->pt(),jet->eta());
159
160 // Try exact eta boundary of flavour
161 jet->setJetP4(xAOD::JetFourMom_t(100,-4.4,0.,0.));
162 printf("%20s: (pT,eta) = (%.0f,%.1f)","exact eta boundary",jet->pt(),jet->eta());
163 if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
164 exit(3);
165 printf(" --> (%.0f,%.1f)\n",jet->pt(),jet->eta());
166
167 // Try Nseg value without punch-through
168 jet->setJetP4(xAOD::JetFourMom_t(500,1.7,0.,0.));
169 printf("%20s: (pT,eta) = (%.0f,%.1f)","Nsegments=0",jet->pt(),jet->eta());
170 if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
171 exit(3);
172 printf(" --> (%.0f,%.1f)\n",jet->pt(),jet->eta());
173
174 // Try Nseg value with punch-through
175 jet->setJetP4(xAOD::JetFourMom_t(500,1.7,0.,0.));
176 Nsegments(*jet) = 20;
177 printf("%20s: (pT,eta) = (%.0f,%.1f)","Nsegments=20",jet->pt(),jet->eta());
178 if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
179 exit(3);
180 Nsegments(*jet) = 0;
181 printf(" --> (%.0f,%.1f)\n",jet->pt(),jet->eta());
182 }
183 // large-R tests
184 else
185 {
186 // Confirm that the systematic recognition is working
187 printf("Recognizes JET_Rtrk_Baseline__continuous: %s\n",tool->isAffectedBySystematic(CP::SystematicVariation("JET_Rtrk_Baseline__continuous"))?"true":"false");
188 printf("Recognizes JET_Rtrk_Baseline: %s\n",tool->isAffectedBySystematic(CP::SystematicVariation("JET_Rtrk_Baseline"))?"true":"false");
189 //printf("Recognizes JET_WZ_Run1__continuous: %s\n",tool->isAffectedBySystematic(CP::SystematicVariation("JET_WZ_Run1__continuous"))?"true":"false");
190 //printf("Recognizes JET_WZ_Run1: %s\n",tool->isAffectedBySystematic(CP::SystematicVariation("JET_WZ_Run1"))?"true":"false");
191
192 // Specify which systematics to vary
193 printf("Trying (Rtrk_Baseline)x(-1.5) + (Rtrk_Modelling)x(+1.5)\n");
195 syst->insert(CP::SystematicVariation("JET_Rtrk_Baseline",-1.5));
196 syst->insert(CP::SystematicVariation("JET_Rtrk_Modelling",+1.5));
197 if (tool->applySystematicVariation(*syst) != StatusCode::SUCCESS)
198 exit(2);
199
200 // Add D2 information
201 // 25 segments is about average for jets receiving a correction
203 accD2(*jet) = 1.;
204
205 // Try a normal high pT W/Z boson
206 jet->setJetP4(xAOD::JetFourMom_t(1000,1.0,0.,85));
207 printf("%20s: (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f)","Normal W/Z jet",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
208 if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
209 exit(3);
210 printf(" --> (%.0f,%.1f,%.1f,%.0f,%0.1f)\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
211
212 // Try outside of validity
213 //jet->setJetP4(xAOD::JetFourMom_t(4000,1.0,0.,85));
214 //printf("%20s: (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f)","Too high of pT",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
215 //if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
216 // exit(3);
217 //printf(" --> (%.0f,%.1f,%.1f,%.0f,%0.1f)\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
218
219 //jet->setJetP4(xAOD::JetFourMom_t(2000,3.0,0.,85));
220 //printf("%20s: (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f)","Too high of eta",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
221 //if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
222 // exit(3);
223 //printf(" --> (%.0f,%.1f,%.1f,%.0f,%0.1f)\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
224
225
226 // Try validity borders
227 printf("\n");
228 jet->setJetP4(xAOD::JetFourMom_t(3000,2,0,0));
229 printf("Validity of (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f) : %s\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet), (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::Ok) ? "ok" : (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::OutOfValidityRange) ? "invalid" : "ERROR");
230 jet->setJetP4(xAOD::JetFourMom_t(2999,2,0,0));
231 printf("Validity of (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f) : %s\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet), (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::Ok) ? "ok" : (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::OutOfValidityRange) ? "invalid" : "ERROR");
232 jet->setJetP4(xAOD::JetFourMom_t(2999,1.99,0,0));
233 printf("Validity of (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f) : %s\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet), (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::Ok) ? "ok" : (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::OutOfValidityRange) ? "invalid" : "ERROR");
234 jet->setJetP4(xAOD::JetFourMom_t(3000,1.99,0,0));
235 printf("Validity of (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f) : %s\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet), (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::Ok) ? "ok" : (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::OutOfValidityRange) ? "invalid" : "ERROR");
236 jet->setJetP4(xAOD::JetFourMom_t(500,0,0,0.79*500));
237 printf("Validity of (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f) : %s\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet), (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::Ok) ? "ok" : (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::OutOfValidityRange) ? "invalid" : "ERROR");
238 jet->setJetP4(xAOD::JetFourMom_t(500,0,0,0.81*500));
239 printf("Validity of (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f) : %s\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet), (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::Ok) ? "ok" : (tool->applyCorrection(*jet,*eInfo) == CP::CorrectionCode::OutOfValidityRange) ? "invalid" : "ERROR");
240
241
242 // Border of validity
243 //jet->setJetP4(xAOD::JetFourMom_t(3000,2,0,0));
244 //printf("%20s: (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f)","Validity borders 1",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
245 //if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
246 // exit(3);
247 //printf(" --> (%.0f,%.1f,%.1f,%.0f,%0.1f)\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
248 //
249 //jet->setJetP4(xAOD::JetFourMom_t(150,0,0,150));
250 //printf("%20s: (pT,eta,phi,m,D2) = (%.0f,%.1f,%.1f,%.0f,%.1f)","Validity borders 2",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
251 //if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok)
252 // exit(3);
253 //printf(" --> (%.0f,%.1f,%.1f,%.0f,%0.1f)\n",jet->pt(),jet->eta(),jet->phi(),jet->m(),accD2(*jet));
254 }
255
256 return 0;
257}
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
const SystematicSet & recommendedSystematics() const
returns: the recommended set of systematics
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
size_t size() const
returns: size of the set
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
Tool for accessing xAOD files outside of Athena.
A relatively simple transient store for objects created in analysis.
Definition TStore.h:45
int main()
Definition hello.cxx:18
std::vector< CP::SystematicSet > make_systematics_vector(const SystematicSet &systematics)
utility functions for working with systematics
Jet_v1 Jet
Definition of the current "jet version".
EventInfoContainer_v1 EventInfoContainer
Define the latest version of the container.
EventInfo_v1 EventInfo
Definition of the latest event info version.
EventInfoAuxContainer_v1 EventInfoAuxContainer
Define the latest version of the auxiliary container.
JetAuxContainer_v1 JetAuxContainer
Definition of the current jet auxiliary container.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17