Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LArPhysWaveFromTuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
11 
12 #include "TFile.h"
13 #include "TBranch.h"
14 #include "TTree.h"
15 #include "TChain.h"
16 
17 #include <vector>
18 #include <iostream>
19 #include <fstream>
20 #include <string>
21 
22 
23 LArPhysWaveFromTuple::LArPhysWaveFromTuple (const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
24 {
25 }
26 
28 = default;
29 
31 {
32  return StatusCode::SUCCESS ;
33 }
34 
35 
37 {
38  ATH_MSG_INFO ( "... in stop()" );
39 
40  // get LArOnlineID helper
41  const LArOnlineID* onlineHelper = nullptr;
42  ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
43 
44  TChain* outfit = new TChain(m_ntuple_name.value().c_str());
45  outfit->Add(m_root_file_name.value().c_str());
46 
47  // This algorithm assumes the input NTuple in contains less than 2000
48  // points. If the NTuple contains less than 2000 points, the
49  // remaining points are automatically initialized to 0.
50  // Catch potential array index out of range error.
51  if ( m_NPoints > 2000 ) {
52  ATH_MSG_WARNING ( " Too many points specified vs the expected content of the ntuple ! " );
53  ATH_MSG_WARNING ( " Only 2000 will be used !");
54  m_NPoints = 2000;
55  }
56 
57  // variable names as in the Ntuple
58  Int_t channelId;
59  UInt_t tIndex;
60  Double_t Amplitude[2000];
61  Double_t Time[2000];
62  outfit->SetBranchAddress("channelId", &channelId);
63  outfit->SetBranchAddress("timeIndex", &tIndex);
64  outfit->SetBranchAddress("Amplitude", Amplitude);
65  outfit->SetBranchAddress("Time", Time);
66 
67  // Create new LArPhysWaveContainer
68  LArPhysWaveContainer* larPhysWaveContainerNew = new LArPhysWaveContainer();
69  ATH_CHECK ( larPhysWaveContainerNew->setGroupingType(m_groupingType, msg()) );
70  ATH_CHECK ( larPhysWaveContainerNew->initialize() );
71 
72  // loop over entries in the Tuple, one entry = one channel
73  Long64_t nentries = outfit->GetEntries();
74  std::vector<double> wave(m_NPoints);
75  for ( Long64_t i = 0; i < nentries; i++ )
76  {
77  outfit->GetEvent(i);
79  ATH_MSG_INFO ( std::hex << id << std::dec );
80 
81  for ( unsigned int i = 0; i < m_NPoints; i++ ) wave[i]=0.;
82  unsigned int skipped = 0;
83  unsigned int limit = tIndex<m_NPoints.value() ? tIndex : m_NPoints.value();
84  if ( m_skipPoints < m_prefixPoints ) limit = m_NPoints.value() + m_skipPoints.value() - m_prefixPoints.value();
85  double dt=Time[1]-Time[0];
86  for ( unsigned int i = 0; i < limit; i++ )
87  {
88  if(i>1 && Time[i] - Time[i-1] != dt) {
89  ATH_MSG_ERROR("No equidistant time, could not process....");
90  return StatusCode::FAILURE;
91  }
92  if ( skipped >= m_skipPoints )
93  {
94  wave[i-m_skipPoints+m_prefixPoints]=Amplitude[i];
95  }
96  else skipped++;
97  }
98 
99  LArPhysWave newLArPhysWave(wave, dt, m_flag);
100 
101  // Add physics wave to container
102  larPhysWaveContainerNew->setPdata(id, newLArPhysWave, (CaloGain::CaloGain)m_gain.value());
103  }
104 
105  ATH_CHECK( detStore()->record(larPhysWaveContainerNew,m_store_key) );
106  ATH_MSG_INFO ( "LArPhysWaveFromTuple finalized!" );
107  return StatusCode::SUCCESS;
108 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArPhysWaveFromTuple::~LArPhysWaveFromTuple
~LArPhysWaveFromTuple()
LArConditionsContainer::setPdata
void setPdata(const HWIdentifier id, const T &payload, unsigned int gain=0)
put payload in persistent data
LArPhysWaveFromTuple::m_gain
Gaudi::Property< int > m_gain
Definition: LArPhysWaveFromTuple.h:58
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArPhysWaveContainer.h
LArPhysWaveFromTuple::m_groupingType
Gaudi::Property< std::string > m_groupingType
Grouping type. Default is Feedthrough.
Definition: LArPhysWaveFromTuple.h:56
LArPhysWave.h
HWIdentifier
Definition: HWIdentifier.h:13
LArPhysWaveFromTuple::m_store_key
Gaudi::Property< std::string > m_store_key
key of the PhysWave collection in Storegate
Definition: LArPhysWaveFromTuple.h:54
LArPhysWave
Definition: LArPhysWave.h:14
LArPhysWaveContainer
Liquid Argon Physics Wave Container.
Definition: LArPhysWaveContainer.h:23
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArPhysWaveFromTuple::m_flag
Gaudi::Property< unsigned int > m_flag
flag for the PhysWave container
Definition: LArPhysWaveFromTuple.h:48
PlotCalibFromCool.nentries
nentries
Definition: PlotCalibFromCool.py:798
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArPhysWaveFromTuple::stop
StatusCode stop()
Definition: LArPhysWaveFromTuple.cxx:36
CaloNoise_fillDB.dt
dt
Definition: CaloNoise_fillDB.py:58
LArPhysWaveFromTuple::m_root_file_name
Gaudi::Property< std::string > m_root_file_name
input file name
Definition: LArPhysWaveFromTuple.h:50
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
AthAlgorithm
Definition: AthAlgorithm.h:47
LArPhysWaveFromTuple::m_ntuple_name
Gaudi::Property< std::string > m_ntuple_name
ntuple name
Definition: LArPhysWaveFromTuple.h:52
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArOnlineID
Definition: LArOnlineID.h:20
LArPhysWaveFromTuple.h
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArConditionsContainer::initialize
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArPhysWaveFromTuple::m_prefixPoints
Gaudi::Property< unsigned int > m_prefixPoints
make a PhysWave with the first m_prefixPoints as zeros
Definition: LArPhysWaveFromTuple.h:46
LArPhysWaveFromTuple::m_NPoints
Gaudi::Property< unsigned int > m_NPoints
max number of points of the waveform in the ntuple
Definition: LArPhysWaveFromTuple.h:42
LArPhysWaveFromTuple::m_skipPoints
Gaudi::Property< unsigned int > m_skipPoints
the first m_skipPoints points of the waveform in the ntuple are skipped
Definition: LArPhysWaveFromTuple.h:44
CaloGain.h
updateCoolNtuple.limit
int limit
Definition: updateCoolNtuple.py:45
LArPhysWaveFromTuple::initialize
StatusCode initialize()
Definition: LArPhysWaveFromTuple.cxx:30
LArOnlineID.h
LArPhysWaveFromTuple::LArPhysWaveFromTuple
LArPhysWaveFromTuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArPhysWaveFromTuple.cxx:23