ATLAS Offline Software
Loading...
Searching...
No Matches
TestJetCleaningTool.cxx File Reference
#include "JetSelectorTools/JetCleaningTool.h"
#include "JetSelectorTools/Helpers.h"
#include "xAODJet/Jet.h"
#include "xAODJet/JetContainer.h"
#include "xAODJet/JetAuxContainer.h"
#include "TString.h"
#include "TSystem.h"
Include dependency graph for TestJetCleaningTool.cxx:

Go to the source code of this file.

Functions

const char * parseResult (const asg::AcceptData &result, const char *selection="Cleaning")
void setJetToDefault (xAOD::Jet &jet)
int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 76 of file TestJetCleaningTool.cxx.

77{
78 // Arguments and default values
79 TString cutLevel = "LooseBad";
80 TString doUgly = "true";
81 TString hotCells = Form("%s/data/JetSelectorTools/HotCells2012.config",gSystem->Getenv("ROOTCOREBIN"));
82 if (argc > 1)
83 cutLevel = argv[1];
84 if (argc > 2)
85 doUgly = argv[2];
86 if (argc > 3)
87 hotCells = argv[3];
88
89 // Create and set the cleaning tool
90 JetCleaningTool* tool = new JetCleaningTool("MyCleaningTool");
91 if (tool->setProperty("CutLevel",cutLevel.Data()).isFailure())
92 {
93 printf("Failed to set CutLevel\n");
94 exit(1);
95 }
96 if (tool->setProperty("DoUgly",doUgly.EqualTo("true",TString::kIgnoreCase)?true:false).isFailure())
97 {
98 printf("Failed to set DoUgly\n");
99 exit(2);
100 }
101 if (tool->setProperty("HotCellsFile",hotCells.Data()).isFailure())
102 {
103 printf("Failed to set HotCellsFile\n");
104 exit(3);
105 }
106 if (tool->initialize().isFailure())
107 {
108 printf("Failed to initialize the tool\n");
109 exit(4);
110 }
111
112 // Prepare to build some jets to test the tool
116 jets->setStore(new xAOD::JetAuxContainer());
117 jets->push_back(new xAOD::Jet());
118 jets->push_back(new xAOD::Jet());
119 xAOD::Jet* jet = jets->at(0);
120
121 // Confirm that the default jet passes
123 printf("Test jet <default pass> : %s\n",parseResult(tool->accept(*jet)));
124
125
126 // Test the isUgly criterion
127 jet->setAttribute<int>(xAOD::JetAttribute::FracSamplingMaxIndex,17);
128 printf("Test jet <isUgly fail> : %s\n",parseResult(tool->accept(*jet)));
129
130 // Test hot cells criterion
131 jet->setAttribute<int>(xAOD::JetAttribute::FracSamplingMaxIndex,13);
132 jet->setJetP4(xAOD::JetFourMom_t(100.,-0.15,2.7,0));
133 printf("Test jet <hot cell fail> : %s\n",tool->containsHotCells(*jet,202660)==true?"false":"true");
134
135
136
137
138
139 return 0;
140}
void setJetToDefault(xAOD::Jet &jet)
const char * parseResult(const asg::AcceptData &result, const char *selection="Cleaning")
Class for selecting jets that pass cleaning cuts.
Tool for accessing xAOD files outside of Athena.
A relatively simple transient store for objects created in analysis.
Definition TStore.h:45
TestStore store
Definition TestStore.cxx:23
Jet_v1 Jet
Definition of the current "jet version".
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

◆ parseResult()

const char * parseResult ( const asg::AcceptData & result,
const char * selection = "Cleaning" )

Definition at line 21 of file TestJetCleaningTool.cxx.

22{
23 return result.getCutResult(selection)==true?"true":"false";
24}
const std::string selection

◆ setJetToDefault()

void setJetToDefault ( xAOD::Jet & jet)

Definition at line 26 of file TestJetCleaningTool.cxx.

27{
28 jet.setJetP4(xAOD::JetFourMom_t(100.e3,0.,0.,0.));
29
30 jet.setAttribute<float>(xAOD::JetAttribute::EMFrac,0.1);
31 jet.setAttribute<float>(xAOD::JetAttribute::HECFrac,0.1);
32 jet.setAttribute<float>(xAOD::JetAttribute::LArQuality,0.1);
33 jet.setAttribute<float>(xAOD::JetAttribute::HECQuality,0.1);
34 jet.setAttribute<float>(xAOD::JetAttribute::FracSamplingMax,0.7);
35 jet.setAttribute<float>(xAOD::JetAttribute::NegativeE,0);
36 jet.setAttribute<float>(xAOD::JetAttribute::AverageLArQF,0);
38
39 // for sumPtTrk
40 std::vector<float> sumPtTrkvec;
41 sumPtTrkvec.push_back(50.e3);
42 jet.setAttribute(xAOD::JetAttribute::SumPtTrkPt500,sumPtTrkvec);
43
44
45 // for EnergyPerSampling
46 const float jetE = jet.e();
47 std::vector<float> ePerS;
48 ePerS.push_back( 0 * jetE ); // 0 : PreSamplerB
49 ePerS.push_back( 0.1 * jetE ); // 1 : EMB1
50 ePerS.push_back( 0.1 * jetE ); // 2 : EMB2
51 ePerS.push_back( 0.1 * jetE ); // 3 : EMB3
52 ePerS.push_back( 0 * jetE ); // 4 : PreSamplerE
53 ePerS.push_back( 0 * jetE ); // 5 : EME1
54 ePerS.push_back( 0 * jetE ); // 6 : EME2
55 ePerS.push_back( 0 * jetE ); // 7 : EME3
56 ePerS.push_back( 0 * jetE ); // 8 : HEC0
57 ePerS.push_back( 0 * jetE ); // 9 : HEC1
58 ePerS.push_back( 0 * jetE ); // 10 : HEC2
59 ePerS.push_back( 0 * jetE ); // 11 : HEC3
60 ePerS.push_back( 0.7 * jetE ); // 12 : TileBar0
61 ePerS.push_back( 0 * jetE ); // 13 : TileBar1
62 ePerS.push_back( 0 * jetE ); // 14 : TileBar2
63 ePerS.push_back( 0 * jetE ); // 15 : TileGap1
64 ePerS.push_back( 0 * jetE ); // 16 : TileGap2
65 ePerS.push_back( 0 * jetE ); // 17 : TileGap3
66 ePerS.push_back( 0 * jetE ); // 18 : TileExt0
67 ePerS.push_back( 0 * jetE ); // 19 : TileExt1
68 ePerS.push_back( 0 * jetE ); // 20 : TileExt2
69 ePerS.push_back( 0 * jetE ); // 21 : FCAL0
70 ePerS.push_back( 0 * jetE ); // 22 : FCAL1
71 ePerS.push_back( 0 * jetE ); // 23 : FCAL2
72 jet.setAttribute("EnergyPerSampling",ePerS);
73}