ATLAS Offline Software
Functions
ISF_HitAnalysis.cxx File Reference
#include "ISF_FastCaloSimParametrization/ISF_HitAnalysis.h"
#include "ISF_FastCaloSimEvent/TFCSTruthState.h"
#include "ISF_FastCaloSimEvent/TFCSExtrapolationState.h"
#include "LArSimEvent/LArHitContainer.h"
#include "CaloDetDescr/CaloDetDescrElement.h"
#include "AthenaPoolUtilities/AthenaAttributeList.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/LArEM_ID.h"
#include "CaloIdentifier/LArFCAL_ID.h"
#include "CaloIdentifier/LArHEC_ID.h"
#include "TileConditions/TileInfo.h"
#include "TileDetDescr/TileDetDescrManager.h"
#include "CaloIdentifier/TileID.h"
#include "TileIdentifier/TileHWID.h"
#include "TileSimEvent/TileHit.h"
#include "TileSimEvent/TileHitVector.h"
#include "TrackRecord/TrackRecordCollection.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloEvent/CaloClusterCellLinkContainer.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "xAODCaloEvent/CaloCluster.h"
#include "GaudiKernel/MsgStream.h"
#include "ISF_FastCaloSimEvent/FCS_StepInfoCollection.h"
#include "TTree.h"
#include "TFile.h"
#include "TString.h"
#include "TVector3.h"
#include <sstream>
#include "GeneratorObjects/McEventCollection.h"
#include "CaloDetDescr/CaloDepthTool.h"
#include "TrkParameters/TrackParameters.h"
#include "TrkSurfaces/CylinderSurface.h"
#include "TrkSurfaces/DiscSurface.h"
#include "TrkSurfaces/DiscBounds.h"
#include "TrkExInterfaces/IExtrapolator.h"
#include "TrkMaterialOnTrack/EnergyLoss.h"
#include "TrkGeometry/TrackingGeometry.h"
#include "GaudiKernel/IPartPropSvc.h"
#include "HepPDT/ParticleData.hh"
#include "HepPDT/ParticleDataTable.hh"
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>

Go to the source code of this file.

Functions

StatusCode ISF_HitAnalysis::initialize ATLAS_NOT_THREAD_SAFE ()
 Install fatal handler with default options. More...
 

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

StatusCode ISF_HitAnalysis::initialize ATLAS_NOT_THREAD_SAFE ( )
inline

Install fatal handler with default options.

This is meant to be easy to call from python via ctypes.

Install fatal handler with default options.

getLorentzAngle() Read LorentzAngle from HIST and write out into local DB

getBSErrors() Read BSErrors from Monitoring HIST and write out into local DB

getEfficiency() Read Efficiency from Monitoring HIST and write out into local DB

getRawOccupancy() Read RawOccupancy from Monitoring HIST and write out into local DB

getNoiseOccupancy() Read NoiseOccupancy from HIST and write out into local DB

getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats

now add branches and leaves to the tree

now add branches and leaves to the tree

Definition at line 127 of file ISF_HitAnalysis.cxx.

128 {
129  ATH_MSG_VERBOSE( "Initializing ISF_HitAnalysis" );
130  //
131  // Register the callback(s):
132  //
133  ATH_CHECK(m_geoModel.retrieve());
134  ATH_CHECK(detStore()->retrieve(m_tileMgr));
135  ATH_CHECK(detStore()->retrieve(m_tileID));
136 
137  const CaloIdManager* caloIdManager{nullptr};
138  ATH_CHECK(detStore()->retrieve(caloIdManager));
139  m_larEmID=caloIdManager->getEM_ID();
140  if(m_larEmID==nullptr)
141  throw std::runtime_error("ISF_HitAnalysis: Invalid LAr EM ID helper");
142  m_larFcalID=caloIdManager->getFCAL_ID();
143  if(m_larFcalID==nullptr)
144  throw std::runtime_error("ISF_HitAnalysis: Invalid FCAL ID helper");
145  m_larHecID=caloIdManager->getHEC_ID();
146  if(m_larHecID==nullptr)
147  throw std::runtime_error("ISF_HitAnalysis: Invalid HEC ID helper");
148  m_tileID=caloIdManager->getTileID();
149  if(m_tileID==nullptr)
150  throw std::runtime_error("ISF_HitAnalysis: Invalid Tile ID helper");
151 
152  ATH_CHECK( m_fSamplKey.initialize() );
153 
154  ATH_CHECK(detStore()->retrieve(m_tileHWID));
155  ATH_CHECK( m_tileSamplingFractionKey.initialize() );
156 
157  ATH_CHECK( m_tileCablingSvc.retrieve() );
158  m_tileCabling = m_tileCablingSvc->cablingService();
159 
160  ATH_CHECK(m_caloMgrKey.initialize());
161 
162  // Get TimedExtrapolator ***************************************************************************************************
163  if (!m_extrapolator.empty() && m_extrapolator.retrieve().isFailure()) {
164  return StatusCode::FAILURE;
165  }
166  ATH_MSG_DEBUG("Extrapolator retrieved "<< m_extrapolator);
167 
168  ATH_CHECK(m_calo_tb_coord.retrieve());
169  ATH_MSG_VERBOSE("retrieved " << m_calo_tb_coord);
170 
171  if( detStore()->contains< AthenaAttributeList >( m_MC_DIGI_PARAM ) )
172  {
174  if( detStore()->regFcn( &ISF_HitAnalysis::updateMetaData, this, aptr,m_MC_DIGI_PARAM, true ).isFailure() )
175  {
176  ATH_MSG_ERROR( "Could not register callback for "<< m_MC_DIGI_PARAM );
177  return StatusCode::FAILURE;
178  }
179  }
180  else
181  {
182  ATH_MSG_WARNING( "MetaData not found for "<< m_MC_DIGI_PARAM );
183  }
184 
185  if(detStore()->contains< AthenaAttributeList >( m_MC_SIM_PARAM ) )
186  {
188  if( detStore()->regFcn( &ISF_HitAnalysis::updateMetaData, this, aptr,m_MC_SIM_PARAM, true ).isFailure() )
189  {
190  ATH_MSG_ERROR( "Could not register callback for "<< m_MC_SIM_PARAM );
191  return StatusCode::FAILURE;
192  }
193  }
194  else {
195  ATH_MSG_WARNING( "MetaData not found for "<< m_MC_SIM_PARAM );
196  }
197 
198  // Get FastCaloSimCaloExtrapolation
199  ATH_CHECK (m_FastCaloSimCaloExtrapolation.retrieve());
200 
201  // Grab the Ntuple and histogramming service for the tree
202  ATH_CHECK(m_thistSvc.retrieve());
203 
204  //#########################
205  IPartPropSvc* p_PartPropSvc = nullptr;
206  ATH_CHECK(service("PartPropSvc",p_PartPropSvc));
207 
208  m_particleDataTable = (HepPDT::ParticleDataTable*) p_PartPropSvc->PDT();
209  if(m_particleDataTable == nullptr)
210  {
211  ATH_MSG_ERROR("PDG table not found");
212  return StatusCode::FAILURE;
213  }
214  //#########################
215  std::unique_ptr<TFile> dummyFile = std::unique_ptr<TFile>(TFile::Open("dummyFile.root", "RECREATE")); //This is added to suppress the error messages about memory-resident trees
216  m_tree = new TTree("FCS_ParametrizationInput", "FCS_ParametrizationInput");
217  std::string fullNtupleName = "/"+m_ntupleFileName+"/"+m_ntupleTreeName;
218  StatusCode sc = m_thistSvc->regTree(fullNtupleName, m_tree);
219  if (sc.isFailure() || !m_tree )
220  {
221  ATH_MSG_ERROR("Unable to register TTree: " << fullNtupleName);
222  return StatusCode::FAILURE;
223  }
224 
226  if (m_tree)
227  {
228  ATH_MSG_INFO("Successfull registered TTree: " << fullNtupleName);
229  //initialize the variables before creating the branches
230  m_hit_x = new std::vector<float>;
231  m_hit_y = new std::vector<float>;
232  m_hit_z = new std::vector<float>;
233  m_hit_energy = new std::vector<float>;
234  m_hit_time = new std::vector<float>;
235  m_hit_identifier = new std::vector<Long64_t>;
236  m_hit_cellidentifier = new std::vector<Long64_t>;
237  m_islarbarrel = new std::vector<bool>;
238  m_islarendcap = new std::vector<bool>;
239  m_islarhec = new std::vector<bool>;
240  m_islarfcal = new std::vector<bool>;
241  m_istile = new std::vector<bool>;
242  m_hit_sampling = new std::vector<int>;
243  m_hit_samplingfraction = new std::vector<float>;
244 
245  m_truth_energy = new std::vector<float>;
246  m_truth_px = new std::vector<float>;
247  m_truth_py = new std::vector<float>;
248  m_truth_pz = new std::vector<float>;
249  m_truth_pdg = new std::vector<int>;
250  m_truth_barcode = new std::vector<int>;
251  m_truth_vtxbarcode = new std::vector<int>;
252 
253  m_cluster_energy = new std::vector<float>;
254  m_cluster_eta = new std::vector<float>;
255  m_cluster_phi = new std::vector<float>;
256  m_cluster_size = new std::vector<unsigned>;
257  m_cluster_cellID = new std::vector<std::vector<Long64_t > >;
258 
259  m_cell_identifier = new std::vector<Long64_t>;
260  m_cell_energy = new std::vector<float>;
261  m_cell_sampling = new std::vector<int>;
262 
263  m_g4hit_energy = new std::vector<float>;
264  m_g4hit_time = new std::vector<float>;
265  m_g4hit_identifier = new std::vector<Long64_t>;
266  m_g4hit_cellidentifier = new std::vector<Long64_t>;
267  m_g4hit_samplingfraction = new std::vector<float>;
268  m_g4hit_sampling = new std::vector<int>;
269 
270  m_total_cell_e = 0;
271  m_total_hit_e = 0;
272  m_total_g4hit_e = 0;
273 
274  m_final_cell_energy = new std::vector<Float_t>;
275  m_final_hit_energy = new std::vector<Float_t>;
276  m_final_g4hit_energy = new std::vector<Float_t>;
277 
278  m_newTTC_entrance_eta = new std::vector<std::vector<float> >;
279  m_newTTC_entrance_phi = new std::vector<std::vector<float> >;
280  m_newTTC_entrance_r = new std::vector<std::vector<float> >;
281  m_newTTC_entrance_z = new std::vector<std::vector<float> >;
282  m_newTTC_entrance_detaBorder = new std::vector<std::vector<float> >;
283  m_newTTC_entrance_OK = new std::vector<std::vector<bool> >;
284  m_newTTC_back_eta = new std::vector<std::vector<float> >;
285  m_newTTC_back_phi = new std::vector<std::vector<float> >;
286  m_newTTC_back_r = new std::vector<std::vector<float> >;
287  m_newTTC_back_z = new std::vector<std::vector<float> >;
288  m_newTTC_back_detaBorder = new std::vector<std::vector<float> >;
289  m_newTTC_back_OK = new std::vector<std::vector<bool> >;
290  m_newTTC_mid_eta = new std::vector<std::vector<float> >;
291  m_newTTC_mid_phi = new std::vector<std::vector<float> >;
292  m_newTTC_mid_r = new std::vector<std::vector<float> >;
293  m_newTTC_mid_z = new std::vector<std::vector<float> >;
294  m_newTTC_mid_detaBorder = new std::vector<std::vector<float> >;
295  m_newTTC_mid_OK = new std::vector<std::vector<bool> >;
296  m_newTTC_IDCaloBoundary_eta = new std::vector<float>;
297  m_newTTC_IDCaloBoundary_phi = new std::vector<float>;
298  m_newTTC_IDCaloBoundary_r = new std::vector<float>;
299  m_newTTC_IDCaloBoundary_z = new std::vector<float>;
300  m_newTTC_Angle3D = new std::vector<float>;
301  m_newTTC_AngleEta = new std::vector<float>;
302 
303  m_MuonEntryLayer_E = new std::vector<float>;
304  m_MuonEntryLayer_px = new std::vector<float>;
305  m_MuonEntryLayer_py = new std::vector<float>;
306  m_MuonEntryLayer_pz = new std::vector<float>;
307  m_MuonEntryLayer_x = new std::vector<float>;
308  m_MuonEntryLayer_y = new std::vector<float>;
309  m_MuonEntryLayer_z = new std::vector<float>;
310  m_MuonEntryLayer_pdg = new std::vector<int>;
311 
312  // Optional branches
313  if(m_saveAllBranches){
314  m_tree->Branch("HitX", &m_hit_x);
315  m_tree->Branch("HitY", &m_hit_y);
316  m_tree->Branch("HitZ", &m_hit_z);
317  m_tree->Branch("HitE", &m_hit_energy);
318  m_tree->Branch("HitT", &m_hit_time);
319  m_tree->Branch("HitIdentifier", &m_hit_identifier);
320  m_tree->Branch("HitCellIdentifier", &m_hit_cellidentifier);
321  m_tree->Branch("HitIsLArBarrel", &m_islarbarrel);
322  m_tree->Branch("HitIsLArEndCap", &m_islarendcap);
323  m_tree->Branch("HitIsHEC", &m_islarhec);
324  m_tree->Branch("HitIsFCAL", &m_islarfcal);
325  m_tree->Branch("HitIsTile", &m_istile);
326  m_tree->Branch("HitSampling", &m_hit_sampling);
327  m_tree->Branch("HitSamplingFraction", &m_hit_samplingfraction);
328 
329  m_tree->Branch("CellIdentifier", &m_cell_identifier);
330  m_tree->Branch("CellE", &m_cell_energy);
331  m_tree->Branch("CellSampling", &m_cell_sampling);
332 
333  m_tree->Branch("G4HitE", &m_g4hit_energy);
334  m_tree->Branch("G4HitT", &m_g4hit_time);
335  m_tree->Branch("G4HitIdentifier", &m_g4hit_identifier);
336  m_tree->Branch("G4HitCellIdentifier", &m_g4hit_cellidentifier);
337  m_tree->Branch("G4HitSamplingFraction",&m_g4hit_samplingfraction);
338  m_tree->Branch("G4HitSampling", &m_g4hit_sampling);
339  }
340 
341  //CaloHitAna output variables
342  m_tree->Branch("TruthE", &m_truth_energy);
343  m_tree->Branch("TruthPx", &m_truth_px);
344  m_tree->Branch("TruthPy", &m_truth_py);
345  m_tree->Branch("TruthPz", &m_truth_pz);
346  m_tree->Branch("TruthPDG", &m_truth_pdg);
347  m_tree->Branch("TruthBarcode", &m_truth_barcode);
348  m_tree->Branch("TruthVtxBarcode", &m_truth_vtxbarcode);
349 
350  if(m_doClusterInfo){
351  m_tree->Branch("ClusterE", &m_cluster_energy);
352  m_tree->Branch("ClusterEta", &m_cluster_eta);
353  m_tree->Branch("ClusterPhi", &m_cluster_phi);
354  m_tree->Branch("ClusterSize", &m_cluster_size);
355  m_tree->Branch("ClusterCellID", &m_cluster_cellID);
356  }
357 
358  m_oneeventcells = new FCS_matchedcellvector;
359  if(m_doAllCells){
360  m_tree->Branch("AllCells", &m_oneeventcells);
361  }
362 
363  //write cells per layer
364  if(m_doLayers){
365  for (Int_t i = 0; i < MAX_LAYER; i++)
366  {
367  TString branchname = "Sampling_";
368  branchname += i;
369  m_layercells[i] = new FCS_matchedcellvector;
370  m_tree->Branch(branchname, &m_layercells[i]);
371  }
372  }
373 
374  if(m_doLayerSums){
375  //write also energies per layer:
376  m_tree->Branch("cell_energy", &m_final_cell_energy);
377  m_tree->Branch("hit_energy", &m_final_hit_energy);
378  m_tree->Branch("g4hit_energy", &m_final_g4hit_energy);
379 
380  //This is a duplicate of cell_energy[25]
381  m_tree->Branch("total_cell_energy", &m_total_cell_e);
382  m_tree->Branch("total_hit_energy", &m_total_hit_e);
383  m_tree->Branch("total_g4hit_energy", &m_total_g4hit_e);
384  }
385 
386  m_tree->Branch("newTTC_back_eta",&m_newTTC_back_eta);
387  m_tree->Branch("newTTC_back_phi",&m_newTTC_back_phi);
388  m_tree->Branch("newTTC_back_r",&m_newTTC_back_r);
389  m_tree->Branch("newTTC_back_z",&m_newTTC_back_z);
390  m_tree->Branch("newTTC_back_detaBorder",&m_newTTC_back_detaBorder);
391  m_tree->Branch("newTTC_back_OK",&m_newTTC_back_OK);
392  m_tree->Branch("newTTC_entrance_eta",&m_newTTC_entrance_eta);
393  m_tree->Branch("newTTC_entrance_phi",&m_newTTC_entrance_phi);
394  m_tree->Branch("newTTC_entrance_r",&m_newTTC_entrance_r);
395  m_tree->Branch("newTTC_entrance_z",&m_newTTC_entrance_z);
396  m_tree->Branch("newTTC_entrance_detaBorder",&m_newTTC_entrance_detaBorder);
397  m_tree->Branch("newTTC_entrance_OK",&m_newTTC_entrance_OK);
398  m_tree->Branch("newTTC_mid_eta",&m_newTTC_mid_eta);
399  m_tree->Branch("newTTC_mid_phi",&m_newTTC_mid_phi);
400  m_tree->Branch("newTTC_mid_r",&m_newTTC_mid_r);
401  m_tree->Branch("newTTC_mid_z",&m_newTTC_mid_z);
402  m_tree->Branch("newTTC_mid_detaBorder",&m_newTTC_mid_detaBorder);
403  m_tree->Branch("newTTC_mid_OK",&m_newTTC_mid_OK);
404  m_tree->Branch("newTTC_IDCaloBoundary_eta",&m_newTTC_IDCaloBoundary_eta);
405  m_tree->Branch("newTTC_IDCaloBoundary_phi",&m_newTTC_IDCaloBoundary_phi);
406  m_tree->Branch("newTTC_IDCaloBoundary_r",&m_newTTC_IDCaloBoundary_r);
407  m_tree->Branch("newTTC_IDCaloBoundary_z",&m_newTTC_IDCaloBoundary_z);
408  m_tree->Branch("newTTC_Angle3D",&m_newTTC_Angle3D);
409  m_tree->Branch("newTTC_AngleEta",&m_newTTC_AngleEta);
410 
411  m_tree->Branch("MuonEntryLayer_E",&m_MuonEntryLayer_E);
412  m_tree->Branch("MuonEntryLayer_px",&m_MuonEntryLayer_px);
413  m_tree->Branch("MuonEntryLayer_py",&m_MuonEntryLayer_py);
414  m_tree->Branch("MuonEntryLayer_pz",&m_MuonEntryLayer_pz);
415  m_tree->Branch("MuonEntryLayer_x",&m_MuonEntryLayer_x);
416  m_tree->Branch("MuonEntryLayer_y",&m_MuonEntryLayer_y);
417  m_tree->Branch("MuonEntryLayer_z",&m_MuonEntryLayer_z);
418  m_tree->Branch("MuonEntryLayer_pdg",&m_MuonEntryLayer_pdg);
419  }
420  dummyFile->Close();
421  return StatusCode::SUCCESS;
422 } //initialize
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
RTTAlgmain.branchname
string branchname
Definition: RTTAlgmain.py:60
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition: CaloIdManager.h:45
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FCS_matchedcellvector
Definition: FCS_Cell.h:73
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
DataHandle< AthenaAttributeList >
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ISF_HitAnalysis::updateMetaData
StatusCode updateMetaData(IOVSVC_CALLBACK_ARGS)
Definition: ISF_HitAnalysis.cxx:85