ATLAS Offline Software
Functions | Variables
ringsHist.cxx File Reference
#include "xAODRootAccess/Init.h"
#include "xAODRootAccess/tools/ReturnCheck.h"
#include "xAODRootAccess/TEvent.h"
#include "xAODCaloRings/RingSetContainer.h"
#include "xAODCaloRings/CaloRingsContainer.h"
#include "xAODCaloRings/RingSetConfContainer.h"
#include "xAODCaloRings/RingSetConfAuxContainer.h"
#include "xAODCaloRings/tools/getCaloRingsDecorator.h"
#include "RingerSelectorTools/tools/cxx/errorcheck.h"
#include "xAODEgamma/ElectronContainer.h"
#include "xAODEgamma/EgammaEnums.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "xAODEventInfo/EventInfo.h"
#include "TChain.h"
#include "TError.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TH1F.h"
#include "TH2F.h"
#include <iostream>

Go to the source code of this file.

Functions

TChain * getChain (int argc, char *argv[], const char *chainName="CollectionTree")
 
int main (int argc, char *argv[])
 

Variables

const char * APP_NAME = "ringsHist"
 
const char * OUTPUT_FILE = "histRings.root"
 

Function Documentation

◆ getChain()

TChain* getChain ( int  argc,
char *  argv[],
const char *  chainName = "CollectionTree" 
)

Definition at line 167 of file ringsHist.cxx.

168 {
169  if (argc < 2) {
170  ::Error(APP_NAME, "Usage: %s <xAOD file> [xAOD file2]...", APP_NAME);
171  return nullptr;
172  }
173 
174  auto chain = new TChain( chainName );
175  for (int i = 1; i < argc; i++) {
176  chain->Add(argv[i]);
177  }
178 
179  return chain;
180 }

◆ main()

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

Definition at line 44 of file ringsHist.cxx.

44  {
45 
46  // Initialize (as done for all xAOD standalone programs!)
48 
49  auto chain = getChain(argc, argv,"CollectionTree");
50  if (chain == nullptr) {
51  return 1;
52  }
53 
54  const auto& ringsReader = getCaloRingsReader();
55 
56  //
57  // Add initialization code for tools here
58  //
59 
60  // The TEvent object
61  TEvent event(TEvent::kClassAccess);
63 
64  // Get an output file open, book events.
65  auto outputFile = TFile::Open(OUTPUT_FILE, "RECREATE");
66  if (outputFile == nullptr || !outputFile->IsOpen()) {
67  return 1;
68  }
69 
70  auto hRingsE = new TH1F("RingsE", "Rings energy dist", 30, 0.0, 1.0);
71  hRingsE->GetXaxis()->SetCanExtend(kTRUE);
72  hRingsE->SetStats(false);
73 
74  auto hOutput = new TH1F("NeuralRingerOffline", "Neural Ringer Offline", 30, -1.0, 1.0);
75  hOutput->SetStats(false);
76 
77  auto hNNvrEta = new TH2F("NNOutput vs rEta",
78  "NNOutput w.r.t rEta;rEta;NNOutput",
79  50, 0, 1.2, 50, -1.00, 1.00);
80  hNNvrEta->SetOption("COLZ");
81  hNNvrEta->SetStats(false);
82 
83  const xAOD::ElectronContainer *electronCont;
84 
85  std::vector<float> ringsE;
86 
87  // Run the files
88  size_t nEntries = chain->GetEntries();
89  for (size_t entry = 0; entry < nEntries; entry++) {
90 
91  event.getEntry(entry);
92 
93  const xAOD::EventInfo* event_info = 0;
94  RETURN_CHECK( APP_NAME, event.retrieve( event_info, "EventInfo" ) );
95 
96  if ( event.retrieve(electronCont, "Electrons").isSuccess() ){
97  for ( const Electron *electron : *electronCont ){
98  const xAOD::CaloRingsLinks &caloRingsELVec = ringsReader(*electron);
99  for ( const ElementLink<xAOD::CaloRingsContainer> &clRingsEL : caloRingsELVec ){
100  (*clRingsEL)->exportRingsTo(ringsE);
101  for ( auto ringE : ringsE ){
102  hRingsE->Fill( ringE );
103  }
104  }
105  // Loose Output = Medium Output = Tight Output
106  SG::AuxElement::ConstAccessor<float> looseOutput("ToolSvc.ElectronRingerSelector_TestLoose_output");
107  float output = looseOutput( *electron );
108  hOutput->Fill( output );
109  hNNvrEta->Fill( electron->showerShapeValue( EgammaParameters::Reta ) ,
110  output );
111  }
112  } else {
113  std::cout << "Could not retrieve electrons container" << std::endl;
114  }
115  }
116 
117  auto metaChain = getChain(argc, argv,"MetaData");
118 
120  TEvent metaEvent( TEvent::kBranchAccess );
121  RETURN_CHECK( APP_NAME, metaEvent.readFrom(metaChain));
122 
123  const xAOD::RingSetConfContainer *electronRingSetConf;
124 
125  size_t nEntriesMeta = metaChain->GetEntries();
126  for (size_t entry = 0; entry < nEntriesMeta; entry++) {
127  metaEvent.getEntry(entry);
128  std::cout << " :: Entry :: " << entry << "/" << nEntriesMeta << std::endl;
129  std::cout << "----------------- Reading RingSetConfs ------------------- " << std::endl;
130  if ( metaEvent.retrieve(electronRingSetConf,"ElectronRingSetsConf").isSuccess() ){
131  try {
132  for ( const xAOD::RingSetConf *ringsConf : *electronRingSetConf ){
133  ringsConf->print(std::cout);
134  }
135  std::cout << "----------------- Printing its RawConfCollection ------------------- " << std::endl;
137  xAOD::RingSetConf::getRawConfCol( rawConfCol, electronRingSetConf );
138  xAOD::RingSetConf::print( rawConfCol, std::cout );
139  } catch (const std::runtime_error &e) {
140  std::cout << "Coudln't read RingSetConfs, reason: " << e.what() << std::endl;
141  }
142  } else {
143  std::cout << "ElectronRingSetsConf not available." << std::endl;
144  }
145  }
146 
147  // Draw
148  auto canvas = new TCanvas("RingsEnergyHist");
149  hRingsE->Draw();
150  canvas->SaveAs( "ringsE.gif");
151  canvas->SaveAs( "ringsE.eps");
152  canvas = new TCanvas("NNOutput");
153  hOutput->Draw();
154  canvas->SaveAs( "nnOutput.gif");
155  canvas->SaveAs( "nnOutput.eps");
156  canvas = new TCanvas("NNOutVsReta");
157  hNNvrEta->Draw();
158  canvas->SaveAs( "nnWrtReta.gif");
159  canvas->SaveAs( "nnWrtReta.eps");
160 
161  outputFile->Write();
162  outputFile->Close();
163 
164 }

Variable Documentation

◆ APP_NAME

const char* APP_NAME = "ringsHist"

Definition at line 38 of file ringsHist.cxx.

◆ OUTPUT_FILE

const char* OUTPUT_FILE = "histRings.root"

Definition at line 39 of file ringsHist.cxx.

xAOD::RingSetConf_v1
Class holding the RingSet configuration used for the Reconstruction.
Definition: RingSetConf_v1.h:35
xAOD::RingSetConf_v1::print
static void print(const RawConf &raw, std::ostream &stream)
Prints rawConf.
Definition: RingSetConf_v1.cxx:206
RETURN_CHECK
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition: ReturnCheck.h:26
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
xAOD::EgammaParameters::Reta
@ Reta
e237/e277
Definition: EgammaEnums.h:154
xAOD::RingSetConf_v1::RawConfCollection
std::vector< RawConf > RawConfCollection
typedef The raw configuration structure data holder
Definition: RingSetConf_v1.h:124
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
xAOD::RingSetConf_v1::getRawConfCol
static void getRawConfCol(RawConfCollection &rawConfCol, const RingSetConfContainer_v1 *container)
Retrieve RawConfCollection from RingSetConf container.
Definition: RingSetConf_v1.cxx:380
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
OUTPUT_FILE
const char * OUTPUT_FILE
Definition: ringsHist.cxx:39
compareGeometries.outputFile
string outputFile
Definition: compareGeometries.py:25
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:132
getChain
TChain * getChain(int argc, char *argv[], const char *chainName="CollectionTree")
Definition: ringsHist.cxx:167
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:92
DeMoAtlasDataLoss.canvas
dictionary canvas
Definition: DeMoAtlasDataLoss.py:187
APP_NAME
const char * APP_NAME
Definition: ringsHist.cxx:38
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
Electron
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
merge.output
output
Definition: merge.py:17
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::getCaloRingsReader
const caloRingsReader_t & getCaloRingsReader()
Get CaloRings accessor with read only permissions.
Definition: getCaloRingsDecorator.cxx:11
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
POOL::TEvent::retrieve
StatusCode retrieve(const T *&obj)
Definition: PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h:73
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:353
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
xAOD::CaloRingsLinks
std::vector< ElementLink< CaloRingsContainer > > CaloRingsLinks
ElementLink type pointing at such objects.
Definition: Event/xAOD/xAODCaloRings/xAODCaloRings/CaloRingsContainer.h:24
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31