ATLAS Offline Software
Functions
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 }

◆ 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 }

◆ 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);
37  jet.setAttribute<int>(xAOD::JetAttribute::FracSamplingMaxIndex,12);
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 }
setJetToDefault
void setJetToDefault(xAOD::Jet &jet)
Definition: TestJetCleaningTool.cxx:26
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::JetAttribute::LArQuality
@ LArQuality
Definition: JetAttributes.h:83
xAOD::JetAttribute::FracSamplingMax
@ FracSamplingMax
Definition: JetAttributes.h:116
JetCleaningTool
Class for selecting jets that pass cleaning cuts.
Definition: JetCleaningTool.h:40
parseResult
const char * parseResult(const asg::AcceptData &result, const char *selection="Cleaning")
Definition: TestJetCleaningTool.cxx:21
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
xAOD::JetAttribute::HECQuality
@ HECQuality
Definition: JetAttributes.h:80
xAOD::JetAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: JetAuxContainer_v1.h:37
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
xAOD::JetAttribute::EMFrac
@ EMFrac
Definition: JetAttributes.h:112
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
selection
std::string selection
Definition: fbtTestBasics.cxx:73
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
calibdata.exit
exit
Definition: calibdata.py:236
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
xAOD::JetAttribute::AverageLArQF
@ AverageLArQF
Definition: JetAttributes.h:85
xAOD::JetAttribute::SumPtTrkPt500
@ SumPtTrkPt500
Definition: JetAttributes.h:108
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
xAOD::JetAttribute::HECFrac
@ HECFrac
Definition: JetAttributes.h:113
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
xAOD::JetAttribute::FracSamplingMaxIndex
@ FracSamplingMaxIndex
Definition: JetAttributes.h:117
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
xAOD::JetAttribute::NegativeE
@ NegativeE
Definition: JetAttributes.h:84