ATLAS Offline Software
LArShapeCompleteMaker.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
10 #include "GaudiKernel/MsgStream.h"
14 #include "LArCafJobs/DataStore.h"
16 #include "LArSamplesMon/History.h"
17 #include "LArCafJobs/EventData.h"
19 
20 using namespace LArSamples;
21 
22 LArShapeCompleteMaker::LArShapeCompleteMaker(const std::string & name, ISvcLocator * pSvcLocator) :
23  AthAlgorithm(name, pSvcLocator),
24  m_template(nullptr),
25  m_dumperTool("LArShapeDumperTool")
26 {
27  declareProperty("NSamples", m_nSamples = 5);
28  declareProperty("NPhases", m_nPhases = 17);
29  declareProperty("IPhase", m_iPhase = 8);
30  declareProperty("ShapeErrorFileName", m_shapeErrorFileName);
31  declareProperty("OutputFileName", m_outputFileName);
32  declareProperty("OutputTemplateFileName", m_outputTemplateFileName);
33  declareProperty("StoreGateKey", m_sgKey = "LArResiduals");
34  declareProperty("MinNPulses", m_minNPulses = 0);
35  declareProperty("GroupingType", m_groupingType = "ExtendedSubDetector");
36 }
37 
38 
40 {
41 }
42 
43 
45 {
46 
47  ATH_CHECK(detStore()->retrieve(m_onlineHelper, "LArOnlineID"));
48 
50 
51  return StatusCode::SUCCESS;
52 }
53 
54 
56 {
57  if (m_template) return StatusCode::SUCCESS;
58  m_template = new DataStore();
59 
61 
62  if (lsc->setGroupingType(m_groupingType, msg()).isFailure() || lsc->initialize().isFailure()) {
63  ATH_MSG_ERROR("Unable to initialize LArShapeComplete");
64  return StatusCode::FAILURE;
65  };
66 
68 
70 
71  for (unsigned int k = 0; k < LArSamples::Definitions::nChannels; k++) {
72 
73  HWIdentifier channelID = m_onlineHelper->channel_Id((IdentifierHash)k);
74  const Identifier id = onOffMap->cnvToIdentifier(channelID);
75  if (id.get_compact() == 0xffffffff) {
76  ATH_MSG_WARNING( "Skipping invalid hash = " << k << "." );
77  continue;
78  }
79 
80  CellInfo* info = m_dumperTool->makeCellInfo(channelID, id);
81  if (!info) {
82  ATH_MSG_ERROR("Problem making cell info for hash = " << k << ", terminating...");
83  return StatusCode::FAILURE;
84  }
85 
87  std::vector<const EventData*> events;
88  for (unsigned int g = 0; g < 3; g++) {
89  DataContainer* data = new DataContainer((CaloGain::CaloGain)g, std::vector<short>(), 0, 0, 0, -1, std::vector<float>());
90  events.push_back(new EventData(-1,-1,-1,-1));
91  histCont->add(data);
92  }
93  History* history = new History(*histCont, events, k, errorGetter);
94 
95  for (unsigned int g = 0; g < 3; g++) {
97  const LArSamples::ShapeErrorData* sed = nullptr;
98  if (history) sed = history->shapeErrorData(gain, LArSamples::BestShapeError);
99 
100  // The containers
101  std::vector<std::vector<float> > deltaVal, deltaDer;
102 
103  // Fill them with 0's to start with
104  std::vector<float> phaseVect(m_nSamples);
105  for (unsigned int j = 0; j < m_nSamples; j++) phaseVect[j] = 0;
106  for (unsigned int i = 0; i < m_nPhases; i++) {
107  deltaVal.push_back(phaseVect);
108  deltaDer.push_back(phaseVect);
109  }
110 
111  if (sed && sed->n() > m_minNPulses) {
112  ATH_MSG_DEBUG("--> Setting channel " << k << ", id = " << channelID << ", gain = " << gain << ", size = "
113  << deltaVal.size() << " " << deltaDer.size());
114  for (unsigned int i = 0; i < m_nSamples; i++) {
115  deltaVal[m_iPhase][i] = sed->xi()(i);
116  deltaDer[m_iPhase][i] = sed->xip()(i);
117  ATH_MSG_DEBUG(" xi[" << i << " ] = " << deltaVal[m_iPhase][i]);
118  }
119  }
120  else {
121  ATH_MSG_DEBUG("--> No information for channel " << k<< ", id = " << channelID << ", gain = " << gain);
122  }
123  lsc->set(channelID, gain, deltaVal, deltaDer);
124  }
125  delete history;
126  }
127 
128  ATH_MSG_INFO("Writing LArShapeComplete output to " << m_outputFileName );
129  //TFile* out = TFile::Open(m_outputFileName.c_str(), "RECREATE");
130  //out->WriteObjectAny(lsc, "LArShapeComplete", "LArShape");
131  //delete out;
132  if (detStore()->record(lsc, m_sgKey).isFailure()) {
133  ATH_MSG_ERROR("Unable to write LArShapeComplete");
134  return StatusCode::FAILURE;
135  };
136 
137  ATH_MSG_INFO( "Done!");
138 
139  return StatusCode::SUCCESS;
140 }
141 
142 
144 {
145  ATH_MSG_INFO( "Writing template..." );
147  ATH_MSG_INFO("done..." );
148  return StatusCode::SUCCESS;
149 }
grepfile.info
info
Definition: grepfile.py:38
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TreeShapeErrorGetter.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
LArShapeCompleteMaker::m_outputTemplateFileName
std::string m_outputTemplateFileName
Definition: LArShapeCompleteMaker.h:54
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArShapeCompleteMaker::m_minNPulses
int m_minNPulses
Definition: LArShapeCompleteMaker.h:53
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArShapeCompleteMaker::m_nSamples
unsigned int m_nSamples
Definition: LArShapeCompleteMaker.h:52
DataStore.h
LArShapeCompleteMaker::execute
virtual StatusCode execute() override
Definition: LArShapeCompleteMaker.cxx:55
LArSamples::History
Definition: History.h:40
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArShapeComplete
This class implements the ILArShape interface.
Definition: LArShapeComplete.h:26
LArShapeCompleteMaker::m_iPhase
unsigned int m_iPhase
Definition: LArShapeCompleteMaker.h:52
LArShapeCompleteMaker::m_template
LArSamples::DataStore * m_template
Definition: LArShapeCompleteMaker.h:48
LArSamples
Definition: AbsShape.h:24
LArShapeCompleteMaker::initialize
virtual StatusCode initialize() override
Definition: LArShapeCompleteMaker.cxx:44
LArShapeCompleteMaker::m_nPhases
unsigned int m_nPhases
Definition: LArShapeCompleteMaker.h:52
LArShapeCompleteMaker::m_dumperTool
ToolHandle< ILArShapeDumperTool > m_dumperTool
Definition: LArShapeCompleteMaker.h:50
LArShapeComplete.h
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
LArShapeCompleteMaker::m_shapeErrorFileName
std::string m_shapeErrorFileName
Definition: LArShapeCompleteMaker.h:54
ReadCondHandle.h
LArShapeCompleteMaker::LArShapeCompleteMaker
LArShapeCompleteMaker(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArShapeCompleteMaker.cxx:22
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
LArShapeCompleteMaker::m_outputFileName
std::string m_outputFileName
Definition: LArShapeCompleteMaker.h:54
LArSamples::ShapeErrorData::xip
const TVectorD & xip() const
Definition: ShapeErrorData.h:41
DataContainer.h
LArShapeCompleteMaker::m_sgKey
std::string m_sgKey
Definition: LArShapeCompleteMaker.h:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArSamples::Definitions::nChannels
static const unsigned int nChannels
Definition: Definitions.h:14
lumiFormat.i
int i
Definition: lumiFormat.py:92
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
LArShapeCompleteMaker::finalize
virtual StatusCode finalize() override
Definition: LArShapeCompleteMaker.cxx:143
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
LArOnlineID_Base::channel_Id
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Definition: LArOnlineID_Base.cxx:1569
LArSamples::BestShapeError
@ BestShapeError
Definition: Definitions.h:25
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ITk::EventData
InDet::SiSpacePointsSeedMakerEventData EventData
Definition: ITkSiSpacePointsSeedMaker.h:63
LArShapeCompleteMaker::~LArShapeCompleteMaker
~LArShapeCompleteMaker()
Definition: LArShapeCompleteMaker.cxx:39
EventData.h
AthAlgorithm
Definition: AthAlgorithm.h:47
LArShapeCompleteMaker::m_onOffMapKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffMapKey
Definition: LArShapeCompleteMaker.h:58
LArSamples::ShapeErrorData::n
int n() const
Definition: ShapeErrorData.h:54
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArShapeComplete::set
void set(const HWIdentifier &CellID, int gain, const std::vector< std::vector< float > > &vShape, const std::vector< std::vector< float > > &vShapeDer, float timeOffset=0, float timeBinWidth=25./24.)
Definition: LArShapeComplete.cxx:17
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArSamples::TreeShapeErrorGetter
Definition: TreeShapeErrorGetter.h:31
LArSamples::DataStore
storage of the time histories of all the cells
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:32
LArSamples::CellInfo
Definition: CellInfo.h:31
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArSamples::DataContainer
Definition: DataContainer.h:25
LArSamples::History::shapeErrorData
const ShapeErrorData * shapeErrorData(CaloGain::CaloGain gain, ShapeErrorType shapeErrorType=BestShapeError, const Residual *res=0) const
Definition: History.cxx:299
LArShapeCompleteMaker::m_groupingType
std::string m_groupingType
Definition: LArShapeCompleteMaker.h:55
LArSamples::HistoryContainer
Definition: HistoryContainer.h:29
LArOnOffIdMapping::cnvToIdentifier
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
Definition: LArOnOffIdMapping.h:116
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
LArSamples::HistoryContainer::add
void add(const DataContainer *data)
append data (takes ownership)
Definition: HistoryContainer.h:46
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArShapeCompleteMaker::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: LArShapeCompleteMaker.h:46
ShapeErrorData.h
LArSamples::ShapeErrorData
Definition: ShapeErrorData.h:19
History.h
LArShapeCompleteMaker.h
LArSamples::ShapeErrorData::xi
const TVectorD & xi() const
Definition: ShapeErrorData.h:40
LArSamples::FitterData::sed
const ScaledErrorData * sed
Definition: ShapeFitter.cxx:26
StoreGateSvc.h
LArSamples::DataStore::writeTrees
bool writeTrees(const char *fileName)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:110
fitman.k
k
Definition: fitman.py:528
LArOnlineID.h
LArSamples::DataStore::makeNewHistory
HistoryContainer * makeNewHistory(const IdentifierHash &hash, CellInfo *info)
append data (takes ownership of everything)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:38