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 201 of file dumpRings.cxx.

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

◆ 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  static const SG::ConstAccessor caloRingsLinksAcc("caloRingsLinks");
73 
74  // Run the files
75  size_t nEntries = chain->GetEntries();
76  for (size_t entry = 0; entry < nEntries; entry++) {
77 
78  event.getEntry(entry);
79  std::cout << " :: Entry :: " << entry << std::endl;
80 
81  const xAOD::EventInfo* event_info = 0;
82  RETURN_CHECK( APP_NAME, event.retrieve( event_info, "EventInfo" ) );
83 
84  if ( event.retrieve(electronCont, "Electrons").isSuccess() ){
85  std::cout << "The electron size is : " << electronCont->size() << std::endl;
86  for ( const xAOD::Electron *electron : *electronCont ){
87  std::cout << "----------------- CaloRings info ------------------- " << std::endl;
88  std::cout << "isAvailable is : " << ringsReader.isAvailable(*electron) << std::endl;
89  std::cout << "(eta,phi) is : (" << electron->eta() << "," << electron->phi() << ") | cluster pt is : " << electron->caloCluster()->pt() << std::endl;
90  if ( ringsReader.isAvailable(*electron) ) {
91  //std::cout << "isAvailableWritable is : " << ringsReader->isAvailableWritable(*electron) << std::endl;
92  const xAOD::CaloRingsLinks &caloRingsELVec = ringsReader(*electron);
93  std::cout << "The vectorEL size is : " << caloRingsELVec.size() << std::endl;
94  for ( const ElementLink<xAOD::CaloRingsContainer> &clRingsEL : caloRingsELVec ){
95  if ( clRingsEL.isValid() ) {
96  (*clRingsEL)->print(std::cout);
97  } else {
98  std::cout << "Retrieved invalid link!" << std::endl;
99  }
100  }
101  const xAOD::CaloRingsLinks vec = caloRingsLinksAcc(*electron);
102  std::cout << "The vector size is : " << vec.size() << std::endl;
103  }
104  std::cout << "----------------- Testing cluster ------------------- " << std::endl;
105  SG::AuxElement::ConstAccessor<char> looseDec("ToolSvc.ElectronRingerSelector_TestLoose");
106  if ( looseDec.isAvailable( *electron) ){
107  bool dec = looseDec( *electron );
108  std::cout << "Loose Decision is: " << std::boolalpha
109  << dec << std::noboolalpha << std::endl;
110  SG::AuxElement::ConstAccessor<char> mediumDec("ToolSvc.ElectronRingerSelector_TestMedium");
111  dec = mediumDec( *electron );
112  std::cout << "Medium Decision is: " << std::boolalpha
113  << dec << std::noboolalpha << std::endl;
114  SG::AuxElement::ConstAccessor<char> tightDec("ToolSvc.ElectronRingerSelector_TestTight");
115  dec = tightDec( *electron );
116  std::cout << "Tight Decision is: " << std::boolalpha
117  << dec << std::noboolalpha << std::endl;
118  SG::AuxElement::ConstAccessor<float> looseOutput("ToolSvc.ElectronRingerSelector_TestLoose_output");
119  float output = looseOutput( *electron );
120  std::cout << "Loose Output is: " << output << std::endl;
121  SG::AuxElement::ConstAccessor<float> mediumOutput("ToolSvc.ElectronRingerSelector_TestMedium_output");
122  output = mediumOutput( *electron );
123  std::cout << "Medium Output is: " << output << std::endl;
124  SG::AuxElement::ConstAccessor<float> tightOutput("ToolSvc.ElectronRingerSelector_TestTight_output");
125  output = tightOutput( *electron );
126  std::cout << "Tight Output is: " << output << std::endl;
127  }
128  }
129  } else {
130  std::cout << "Could not retrieve electrons container" << std::endl;
131  }
132 
133  std::cout << "----------------- Reading directly from ElectronCaloRings ------------------- " << std::endl;
134 
135  if ( event.retrieve(electronCaloRings,"ElectronCaloRings").isSuccess() ){
136  //unsigned int counter = 0;
137  for ( const xAOD::CaloRings *rings : *electronCaloRings ){
138  rings->print(std::cout);
139  }
140  } else {
141  std::cout << "ElectronCaloRings. nao funciona" << std::endl;
142  }
143  }
144 
145  auto metaChain = getChain(argc, argv,"MetaData");
146 
147  std::cout << "MetaEvent:" << std::endl;
148  metaChain->Print();
149 
151  TEvent metaEvent( TEvent::kClassAccess );
152  RETURN_CHECK( APP_NAME, metaEvent.readFrom(metaChain));
153 
154  const xAOD::RingSetConfContainer *electronRingSetConf, *photonRingSetConf;
155 
156  size_t nEntriesMeta = metaChain->GetEntries();
157  for (size_t entry = 0; entry < nEntriesMeta; entry++) {
158  metaEvent.getEntry(entry);
159  std::cout << " :: Entry :: " << entry << "/" << nEntriesMeta << std::endl;
160  std::cout << "----------------- Reading RingSetConfs ------------------- " << std::endl;
161  if ( metaEvent.retrieve(electronRingSetConf,"ElectronRingSetsConf").isSuccess() ){
162  try {
163  for ( const xAOD::RingSetConf *ringsConf : *electronRingSetConf ){
164  ringsConf->print(std::cout);
165  }
166  std::cout << "----------------- Printing its RawConfCollection ------------------- " << std::endl;
168  xAOD::RingSetConf::getRawConfCol( rawConfCol, electronRingSetConf );
169  xAOD::RingSetConf::print( rawConfCol, std::cout );
170  } catch (const std::runtime_error &e) {
171  std::cout << "Coudln't read RingSetConfs, reason: " << e.what() << std::endl;
172  }
173  } else {
174  std::cout << "ElectronRingSetsConf not available." << std::endl;
175  }
176  if ( metaEvent.retrieve(photonRingSetConf,"PhotonRingSetsConf").isSuccess() ){
177  try {
178  for ( const xAOD::RingSetConf *ringsConf : *photonRingSetConf ){
179  ringsConf->print(std::cout);
180  }
181  std::cout << "----------------- Printing its RawConfCollection ------------------- " << std::endl;
183  xAOD::RingSetConf::getRawConfCol( rawConfCol, photonRingSetConf );
184  xAOD::RingSetConf::print( rawConfCol, std::cout );
185  } catch (const std::runtime_error &e) {
186  std::cout << "Coudln't read RingSetConfs, reason: " << e.what() << std::endl;
187  }
188  } else {
189  std::cout << "PhotonRingSetsConf not available." << std::endl;
190  }
191  }
192 
193  std::cout << "before close " << std::endl;
194 
195  //outputFile->Write();
196  //outputFile->Close();
197 
198  std::cout << "Finishing..." << std::endl;
199 }

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
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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:55
xAOD::RingSetConf_v1::getRawConfCol
static void getRawConfCol(RawConfCollection &rawConfCol, const RingSetConfContainer_v1 *container)
Retrieve RawConfCollection from RingSetConf container.
Definition: RingSetConf_v1.cxx:380
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:133
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
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:794
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:201
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
POOL::TEvent::retrieve
StatusCode retrieve(const T *&obj)
Definition: PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h:74
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
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:84
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31