ATLAS Offline Software
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"
9 #include "xAODJet/JetContainer.h"
14 
18 
19 #ifdef ROOTCORE
20 # include "xAODRootAccess/TEvent.h"
21 # include "xAODRootAccess/TStore.h"
22 #endif // ROOTCORE
23 
24 int 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 
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
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");
132  CP::SystematicSet* syst = new CP::SystematicSet();
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");
194  CP::SystematicSet* syst = new CP::SystematicSet();
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 }
python.Dso.registry
registry
Definition: Control/AthenaServices/python/Dso.py:159
SGTest::store
TestStore store
Definition: TestStore.cxx:23
Jet.h
CP::make_systematics_vector
std::vector< CP::SystematicSet > make_systematics_vector(const SystematicSet &systematics)
utility functions for working with systematics
Definition: SystematicsUtil.cxx:25
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
CP::SystematicSet::size
size_t size() const
returns: size of the set
Definition: SystematicSet.h:71
EventInfoAuxContainer.h
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
xAOD::EventInfoContainer
EventInfoContainer_v1 EventInfoContainer
Define the latest version of the container.
Definition: EventInfoContainer.h:17
CP::SystematicVariation
Definition: SystematicVariation.h:47
EventInfoContainer.h
Helpers.h
main
int main(int argc, char *argv[])
Definition: testTool.cxx:24
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
xAOD::JetAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: JetAuxContainer_v1.h:37
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
SystematicRegistry.h
JetUncertaintiesTool
Definition: JetUncertaintiesTool.h:44
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
TEvent.h
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
calibdata.exit
exit
Definition: calibdata.py:236
xAOD::EventInfoAuxContainer_v1
Auxiliary information about the pileup events.
Definition: EventInfoAuxContainer_v1.h:31
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
CP::SystematicSet::insert
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Definition: SystematicSet.cxx:88
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
mergePhysValFiles.categories
list categories
Definition: PhysicsAnalysis/JetTagging/JetTagValidation/JetTagDQA/scripts/mergePhysValFiles.py:18
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
JetContainer.h
CP::SystematicRegistry
This module implements the central registry for handling systematic uncertainties with CP tools.
Definition: SystematicRegistry.h:25
JetAuxContainer.h
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition: JetContainer.h:17
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
SystematicVariation.h
TStore.h
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
CP::SystematicRegistry::getInstance
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Definition: SystematicRegistry.cxx:25
JetUncertaintiesTool.h
SystematicsUtil.h