ATLAS Offline Software
Functions | Variables
dumpRings.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 "xAODCaloEvent/CaloClusterContainer.h"
#include "xAODEventInfo/EventInfo.h"
#include "TChain.h"
#include "TError.h"
#include "TFile.h"
#include "TH1F.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 = "dumpRings"
 

Function Documentation

◆ getChain()

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

Definition at line 199 of file dumpRings.cxx.

200 {
201  if (argc < 2) {
202  ::Error(APP_NAME, "Usage: %s <xAOD file> [xAOD file2]...", APP_NAME);
203  return nullptr;
204  }
205 
206  auto chain = new TChain( chainName );
207  for (int i = 1; i < argc; i++) {
208  chain->Add(argv[i]);
209  }
210 
211  return chain;
212 }

◆ main()

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

Definition at line 41 of file dumpRings.cxx.

41  {
42 
43  // Initialize (as done for all xAOD standalone programs!)
45 
46  auto chain = getChain(argc, argv,"CollectionTree");
47  if (chain == nullptr) {
48  return 1;
49  }
50 
51  const auto& ringsReader = getCaloRingsReader();
52 
53  //
54  // Add initialization code for tools here
55  //
56 
57  // The TEvent object
58  TEvent event(TEvent::kClassAccess);
60 
62  //auto outputFile = TFile::Open(OUTPUT_FILE, "RECREATE");
63  //if (outputFile == nullptr || !outputFile->IsOpen()) {
64  // return 1;
65  //}
66 
67  //auto hEventCounter = new TH1F("eventCounter", "Number of Events Processed", 1, 0.0, 1.0);
68 
69  const xAOD::CaloRingsContainer *electronCaloRings(nullptr);
70  const xAOD::ElectronContainer *electronCont(nullptr);
71 
72  // Run the files
73  size_t nEntries = chain->GetEntries();
74  for (size_t entry = 0; entry < nEntries; entry++) {
75 
76  event.getEntry(entry);
77  std::cout << " :: Entry :: " << entry << std::endl;
78 
79  const xAOD::EventInfo* event_info = 0;
80  RETURN_CHECK( APP_NAME, event.retrieve( event_info, "EventInfo" ) );
81 
82  if ( event.retrieve(electronCont, "Electrons").isSuccess() ){
83  std::cout << "The electron size is : " << electronCont->size() << std::endl;
84  for ( const xAOD::Electron *electron : *electronCont ){
85  std::cout << "----------------- CaloRings info ------------------- " << std::endl;
86  std::cout << "isAvailable is : " << ringsReader.isAvailable(*electron) << std::endl;
87  std::cout << "(eta,phi) is : (" << electron->eta() << "," << electron->phi() << ") | cluster pt is : " << electron->caloCluster()->pt() << std::endl;
88  if ( ringsReader.isAvailable(*electron) ) {
89  //std::cout << "isAvailableWritable is : " << ringsReader->isAvailableWritable(*electron) << std::endl;
90  const xAOD::CaloRingsLinks &caloRingsELVec = ringsReader(*electron);
91  std::cout << "The vectorEL size is : " << caloRingsELVec.size() << std::endl;
92  for ( const ElementLink<xAOD::CaloRingsContainer> &clRingsEL : caloRingsELVec ){
93  if ( clRingsEL.isValid() ) {
94  (*clRingsEL)->print(std::cout);
95  } else {
96  std::cout << "Retrieved invalid link!" << std::endl;
97  }
98  }
99  const xAOD::CaloRingsLinks vec = electron->auxdata< xAOD::CaloRingsLinks >("caloRingsLinks");
100  std::cout << "The vector size is : " << vec.size() << std::endl;
101  }
102  std::cout << "----------------- Testing cluster ------------------- " << std::endl;
103  SG::AuxElement::ConstAccessor<char> looseDec("ToolSvc.ElectronRingerSelector_TestLoose");
104  if ( looseDec.isAvailable( *electron) ){
105  bool dec = looseDec( *electron );
106  std::cout << "Loose Decision is: " << std::boolalpha
107  << dec << std::noboolalpha << std::endl;
108  SG::AuxElement::ConstAccessor<char> mediumDec("ToolSvc.ElectronRingerSelector_TestMedium");
109  dec = mediumDec( *electron );
110  std::cout << "Medium Decision is: " << std::boolalpha
111  << dec << std::noboolalpha << std::endl;
112  SG::AuxElement::ConstAccessor<char> tightDec("ToolSvc.ElectronRingerSelector_TestTight");
113  dec = tightDec( *electron );
114  std::cout << "Tight Decision is: " << std::boolalpha
115  << dec << std::noboolalpha << std::endl;
116  SG::AuxElement::ConstAccessor<float> looseOutput("ToolSvc.ElectronRingerSelector_TestLoose_output");
117  float output = looseOutput( *electron );
118  std::cout << "Loose Output is: " << output << std::endl;
119  SG::AuxElement::ConstAccessor<float> mediumOutput("ToolSvc.ElectronRingerSelector_TestMedium_output");
120  output = mediumOutput( *electron );
121  std::cout << "Medium Output is: " << output << std::endl;
122  SG::AuxElement::ConstAccessor<float> tightOutput("ToolSvc.ElectronRingerSelector_TestTight_output");
123  output = tightOutput( *electron );
124  std::cout << "Tight Output is: " << output << std::endl;
125  }
126  }
127  } else {
128  std::cout << "Could not retrieve electrons container" << std::endl;
129  }
130 
131  std::cout << "----------------- Reading directly from ElectronCaloRings ------------------- " << std::endl;
132 
133  if ( event.retrieve(electronCaloRings,"ElectronCaloRings").isSuccess() ){
134  //unsigned int counter = 0;
135  for ( const xAOD::CaloRings *rings : *electronCaloRings ){
136  rings->print(std::cout);
137  }
138  } else {
139  std::cout << "ElectronCaloRings. nao funciona" << std::endl;
140  }
141  }
142 
143  auto metaChain = getChain(argc, argv,"MetaData");
144 
145  std::cout << "MetaEvent:" << std::endl;
146  metaChain->Print();
147 
149  TEvent metaEvent( TEvent::kClassAccess );
150  RETURN_CHECK( APP_NAME, metaEvent.readFrom(metaChain));
151 
152  const xAOD::RingSetConfContainer *electronRingSetConf, *photonRingSetConf;
153 
154  size_t nEntriesMeta = metaChain->GetEntries();
155  for (size_t entry = 0; entry < nEntriesMeta; entry++) {
156  metaEvent.getEntry(entry);
157  std::cout << " :: Entry :: " << entry << "/" << nEntriesMeta << std::endl;
158  std::cout << "----------------- Reading RingSetConfs ------------------- " << std::endl;
159  if ( metaEvent.retrieve(electronRingSetConf,"ElectronRingSetsConf").isSuccess() ){
160  try {
161  for ( const xAOD::RingSetConf *ringsConf : *electronRingSetConf ){
162  ringsConf->print(std::cout);
163  }
164  std::cout << "----------------- Printing its RawConfCollection ------------------- " << std::endl;
166  xAOD::RingSetConf::getRawConfCol( rawConfCol, electronRingSetConf );
167  xAOD::RingSetConf::print( rawConfCol, std::cout );
168  } catch (const std::runtime_error &e) {
169  std::cout << "Coudln't read RingSetConfs, reason: " << e.what() << std::endl;
170  }
171  } else {
172  std::cout << "ElectronRingSetsConf not available." << std::endl;
173  }
174  if ( metaEvent.retrieve(photonRingSetConf,"PhotonRingSetsConf").isSuccess() ){
175  try {
176  for ( const xAOD::RingSetConf *ringsConf : *photonRingSetConf ){
177  ringsConf->print(std::cout);
178  }
179  std::cout << "----------------- Printing its RawConfCollection ------------------- " << std::endl;
181  xAOD::RingSetConf::getRawConfCol( rawConfCol, photonRingSetConf );
182  xAOD::RingSetConf::print( rawConfCol, std::cout );
183  } catch (const std::runtime_error &e) {
184  std::cout << "Coudln't read RingSetConfs, reason: " << e.what() << std::endl;
185  }
186  } else {
187  std::cout << "PhotonRingSetsConf not available." << std::endl;
188  }
189  }
190 
191  std::cout << "before close " << std::endl;
192 
193  //outputFile->Write();
194  //outputFile->Close();
195 
196  std::cout << "Finishing..." << std::endl;
197 }

Variable Documentation

◆ APP_NAME

const char* APP_NAME = "dumpRings"

Definition at line 35 of file dumpRings.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::RingSetConf_v1::RawConfCollection
std::vector< RawConf > RawConfCollection
typedef The raw configuration structure data holder
Definition: RingSetConf_v1.h:124
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
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
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:132
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:92
xAOD::CaloRings_v1
Class summarizing the particle interaction throughout the Calorimeter (its shower shape).
Definition: CaloRings_v1.h:51
APP_NAME
const char * APP_NAME
Definition: dumpRings.cxx:35
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
merge.output
output
Definition: merge.py:17
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
getChain
TChain * getChain(int argc, char *argv[], const char *chainName="CollectionTree")
Definition: dumpRings.cxx:199
xAOD::Electron_v1
Definition: Electron_v1.h:34
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
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