Skip to content
Snippets Groups Projects
Commit a722f058 authored by Peter Alan Steinberg's avatar Peter Alan Steinberg Committed by Graeme Stewart
Browse files

'small change to adapt to xAOD changes (zdcModule)' (ZdcRec-00-02-08)

parent 46e5bcd9
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/*
* ZdcRecChannelToolV2.h
*
* Two steps:
* 1. Convert the towers to ZdcModules
* 2. Process the ZdcModules and add Energy/time info
* Created on: September 27, 2015
* Author: steinber
*/
#ifndef ZDCRECCHANNELTOOLV2_H_
#define ZDCRECCHANNELTOOLV2_H_
#include <string>
#include <map>
//#include "AthenaBaseComps/AthAlgTool.h"
#include "AsgTools/AsgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "xAODTrigL1Calo/TriggerTowerContainer.h"
#include "xAODTrigL1Calo/TriggerTowerAuxContainer.h"
#include "xAODForward/ZdcModuleContainer.h"
#include "xAODForward/ZdcModuleAuxContainer.h"
class StatusCode;
class Identifier;
class ZdcID ;
class ZdcRecChannelToolV2: public asg::AsgTool, virtual public IIncidentListener
{
ASG_TOOL_INTERFACE(ZdcRecChannelToolV2)
ASG_TOOL_CLASS0(ZdcRecChannelToolV2)
public:
ZdcRecChannelToolV2(const std::string& name);
virtual ~ZdcRecChannelToolV2() {};
virtual StatusCode initialize();
virtual StatusCode finalize();
virtual void handle( const Incident& );
int convertTT2ZM(const xAOD::TriggerTowerContainer* ttCollection, xAOD::ZdcModuleContainer* zdcModules);
int makeRawFromDigits(xAOD::ZdcModuleContainer& zdcModules); // NOT const -- we're going to modify the objects to add signal processing
int makeWaveformFromDigits(xAOD::ZdcModule& module);
int splitWaveform(std::map<int,float>& waveform, std::vector<float>& times, std::vector<float>& adcs);
int getPeakProperties(std::vector<float>& times, std::vector<float>& adcs, float& time, float& amp, float& qual);
private:
unsigned int m_nsamples;
float m_sample_time;
int m_delta; // A number to check for signal
int m_zeroSupress;
int m_saturation; // saturation level (absolute ADC)
static int s_ppmChannel;
const ZdcID* m_zdcId;
};
#endif /* ZDCRECCHANNELTOOLV2_H_ */
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// ZdcRec.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef ZDCRECV2_H
#define ZDCRECV2_H
#include <string>
#include <map>
//which one ???
#include "AthenaBaseComps/AthAlgorithm.h"
//#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
//#include "ZdcRec/ZdcRecNoiseTool.h"
//#include "ZdcRec/ZdcRecChannelTool.h"
class ISvcLocator;
class StatusCode;
class Identifier;
class StoreGateSvc;
class ZdcRecChannelToolV2;
#include "xAODTrigL1Calo/TriggerTowerContainer.h"
#include "xAODForward/ZdcModuleContainer.h"
#include "xAODForward/ZdcModuleAuxContainer.h"
/** @class ZdcRec
Class definition for the ZDC Reconstruction class
@author Brian Cole and Peter Steinberg, bcole@cern.ch, peter.steinberg@bnl.gov
and M. Leite leite@cern.ch
*/
class ZdcRecV2 : public AthAlgorithm
{
public:
ZdcRecV2(const std::string& name, ISvcLocator* pSvcLocator);
~ZdcRecV2();
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
private:
/** class member version of retrieving StoreGate */
//StoreGateSvc* m_storeGate;
ServiceHandle<StoreGateSvc> m_storeGate;
/** Does the collection own it's objects ? **/
int m_ownPolicy;
/** Digits data container name */
std::string m_ttContainerName;
/** Raw data object name */
std::string m_zdcModuleContainerName;
std::string m_zdcModuleAuxContainerName;
/** Pointer to Zdc input "digits" data */
const xAOD::TriggerTowerContainer* m_ttContainer;
int m_eventCount;
bool m_complainContain;
bool m_complainRetrieve;
//Include here all tools to do the job. They will be called by the algorithm execute method
//Another option is to use ToolHandleArray<IZdcRecTool>, where IZdcRecTool is the factory for
//the tools
ToolHandle<ZdcRecChannelToolV2> m_ChannelTool;
};
#endif
package ZdcRec
author Peter Steinberg <peter.steinberg@bnl.gov>
author Marco Leite <leite@cern.ch>
public
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
apply_pattern declare_joboptions files="*.py"
#library ZdcRec *.cxx components/*.cxx
#apply_pattern component_library
apply_pattern dual_use_library files="*.cxx"
apply_pattern declare_joboptions files="*.py"
apply_pattern declare_python_modules files="*.py"
use AthenaBaseComps AthenaBaseComps-* Control
use DataCollection DataCollection-* External
use AtlasGSL AtlasGSL-* External
use ZdcEvent ZdcEvent-* ForwardDetectors/ZDC
use AthenaBaseComps AthenaBaseComps-* Control
use DataCollection DataCollection-* External
use AsgTools AsgTools-* Control/AthToolSupport
use AtlasGSL AtlasGSL-* External
use ZdcEvent ZdcEvent-* ForwardDetectors/ZDC
use xAODTrigL1Calo xAODTrigL1Calo-* Event/xAOD
use xAODForward xAODForward-* Event/xAOD
private
use ZdcIdentifier ZdcIdentifier-* ForwardDetectors/ZDC
use ZdcConditions ZdcConditions-* ForwardDetectors/ZDC
use ZdcConditions ZdcConditions-* ForwardDetectors/ZDC
use StoreGate StoreGate-* Control
use AtlasROOT AtlasROOT-* External
public
apply_pattern dual_use_library files=*.cxx
apply_pattern declare_joboptions files="*.py"
apply_pattern declare_python_modules files="*.py"
apply_tag ROOTBasicLibs
apply_tag ROOTMathLibs
apply_tag ROOTSTLDictLibs
apply_tag ROOTGraphicsLibs
apply_tag ROOTTableLibs
use AtlasROOT AtlasROOT-* External
private
use AtlasReflex AtlasReflex-* External -no_auto_imports
use ZdcByteStream ZdcByteStream-* ForwardDetectors/ZDC/ZdcCnv
#apply_pattern lcgdict dict=ZdcRec selectionfile=selection.xml headerfiles="../ZdcRecStream/ZdcRecDict.h"
#public
#apply_pattern dual_use_library files=*.cxx
#apply_pattern declare_joboptions files="*.py"
#apply_pattern declare_python_modules files="*.py"
#apply_tag ROOTBasicLibs
#apply_tag ROOTMathLibs
#apply_tag ROOTSTLDictLibs
#apply_tag ROOTGraphicsLibs
#apply_tag ROOTTableLibs
end_private
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# specifies egamma"standard"
from AthenaCommon.Logging import logging
from RecExConfig.Configured import Configured
class ZdcModuleGetter ( Configured ) :
_outputType = "xAOD::ZdcModuleContainer"
_output = { _outputType: ["ZdcModules" ]}
def preconfigure (self):
mlog = logging.getLogger ('ZdcModuleGetter.py::preconfigure:')
mlog.info('entering')
preconfigureBase = super (ZdcModuleGetter,self).preconfigure()
if not preconfigureBase:
return False
#mlog = logging.getLogger( 'Configured::preconfigure:%s:' % self.__class__.__name__.replace( ".", '_' ) )
#mlog.debug("Output= %s" % self.output() )
#
#if self.checkExistingOutput ():
# return False
# a bit unusual: check if input exist before scheduling the alg. Will nt report ERROR in input does not exist
from RecExConfig.ObjKeyStore import objKeyStore
if not objKeyStore.isInInput("xAOD::TriggerTowerContainer","ZdcTriggerTowers"):
mlog.info("no ZdcTriggerTowers: Quit.")
return False
return True
def configure(self):
mlog = logging.getLogger ('ZdcModuleGetter.py::configure:')
mlog.info('entering')
from AthenaCommon.DetFlags import DetFlags
if not DetFlags.detdescr.ZDC_on():
mlog.info("not DetFlags.detdescr.Zdc_on : Quit.")
return False
if not DetFlags.makeRIO.ZDC_on():
mlog.info("not DetFlags.makeRIO.Zdc_on : Quit.")
return False
try:
from ZdcRec.ZdcRecConf import ZdcRecV2
mlog.info("got ZdcRecV2")
self._zdcRecHandle = ZdcRecV2()
except Exception:
mlog.error("could not get handle to ZdcRecV2")
print traceback.format_exc()
return False
# output to ESD:
from RecExConfig.ObjKeyStore import objKeyStore
objKeyStore.addManyTypesStreamESD(self.output())
# output to AOD:
objKeyStore.addManyTypesStreamAOD(self.output())
# add to topsequence
mlog.info("now adding to topSequence")
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
topSequence += self.zdcRecHandle()
mlog.info("added ZdcRecV2")
return True
def zdcRecHandle(self):
return self._zdcRecHandle
def outputKey(self) :
return self._output[self._outputType]
def outputType(self):
return self._outputType
def outputTypeKey(self) :
return str(self.outputType()+"#"+self.outputKey())
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
def AppendOutputList(HIAODItemList) :
"""Adds HIGlobalAODOutputList to the list passed in as an argument"""
HIAODItemList+= ["xAOD::TriggerTowerContainer#ZdcTriggerTowers",
"xAOD::TriggerTowerAuxContainer#ZdcTriggerTowersAux.",
"xAOD::ZdcModuleContainer#ZdcModules",
"xAOD::ZdcModuleAuxContainer#ZdcModulesAux."]
......@@ -5,9 +5,9 @@
#=======================================================================
__version__ = '1.0.0'
__author__ = 'David Rousseau '
__all__ = [ 'ZdcRawChannelGetter']
__all__ = [ 'ZdcModuleGetter']
__doc__ =""" - Python modules for the ATLAS Reconstruction -
ZdcRawChannelGetter - build from ZdcRawChannelContainer from ZdcDigitsCollection>
ZdcModuleGetter - build ZdcModuleContainer from ZdcTriggerTowers>
"""
__description__ ='Python interface for ATLAS reconstruction '
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/*
* ZdcRecChannelTool.cxx
*
* Created on: Nov 24, 2009
* Author: leite
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <math.h>
#include "TMath.h"
#include "GaudiKernel/IInterface.h"
#include "GaudiKernel/MsgStream.h"
#include "xAODTrigL1Calo/TriggerTowerContainer.h"
#include "xAODTrigL1Calo/TriggerTowerAuxContainer.h"
#include "xAODForward/ZdcModuleToString.h"
#include "xAODForward/ZdcModuleContainer.h"
#include "xAODForward/ZdcModuleAuxContainer.h"
#include "ZdcRec/ZdcRecChannelToolV2.h"
#include "ZdcRec/ZdcSignalSinc.h"
#include "ZdcByteStream/ZdcToString.h"
//#include "ZdcIdentifier/ZdcID.h"
#include "ZdcIdentifier/ZdcID.h"
#include "ZdcConditions/ZdcCablingService.h"
const int slink2ppmChannel[64] =
{0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60,
3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63,
1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61,
2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62 };
//==================================================================================================
ZdcRecChannelToolV2::ZdcRecChannelToolV2(const std::string& name):
AsgTool(name),
m_nsamples(7),
m_sample_time(25.)
{
//Declare properties here...
declareInterface<ZdcRecChannelToolV2>(this);
declareProperty("ZeroSuppress", m_zeroSupress = 0,"Supress channels with only 0");
declareProperty("DeltaPeak", m_delta = 5,"Minimum difference between min and max to be considered a signal");
declareProperty("SaturationADC",m_saturation = 1000,"ADC value above which a HG channel is considered saturated");
}
//==================================================================================================
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "unknown"
#endif
void ZdcRecChannelToolV2::handle( const Incident& inc )
{
if ( inc.type() == IncidentType::EndEvent) {
}
}
//==================================================================================================
StatusCode ZdcRecChannelToolV2::initialize()
{
msg(MSG::INFO) << "Initializing " << name() << endreq;
//Get the pedestal information for the channels.
//For now, this is a file; later on it will be moved to a database
// NONE
const ZdcID* zdcId = 0;
if (detStore()->retrieve( zdcId ).isFailure() ) {
msg(MSG::ERROR) << "execute: Could not retrieve ZdcID object from the detector store" << endreq;
return StatusCode::FAILURE;
}
else {
msg(MSG::DEBUG) << "execute: retrieved ZdcID" << endreq;
}
m_zdcId = zdcId;
ZdcCablingService::getInstance()->setZdcID(m_zdcId);
msg(MSG::DEBUG) << "--> ZDC : END OF MODIFICATION 0" << endreq ;
return StatusCode::SUCCESS;
ServiceHandle<IIncidentSvc> incidentSvc("IncidentSvc", name());
CHECK(incidentSvc.retrieve());
incidentSvc->addListener(this, IncidentType::EndEvent);
}
//==================================================================================================
//==================================================================================================
StatusCode ZdcRecChannelToolV2::finalize()
{
msg(MSG::INFO) << "Finalizing " << name() << endreq;
return StatusCode::SUCCESS;
}
//==================================================================================================
int ZdcRecChannelToolV2::convertTT2ZM(const xAOD::TriggerTowerContainer* ttCollection, xAOD::ZdcModuleContainer* zdcModules )
{
//typedef std::map<uint64_t,xAOD::ZdcModule*> hashmapType;
typedef std::map<uint32_t,xAOD::ZdcModule*> hashmapType;
hashmapType digits_map;
Identifier chan_id;
xAOD::TriggerTowerContainer::const_iterator tt_itr = ttCollection->begin();
xAOD::TriggerTowerContainer::const_iterator tt_end = ttCollection->end();
//std::cout << "Zdc TT's have " << ttCollection->size() << " towers" << std::endl;
for (;tt_itr != tt_end;tt_itr++)
{
//std::cout << "ZdcTT coolId = " << (*tt_itr)->coolId() << std::endl;
//std::cout << ZdcToString(*(*tt_itr)) << std::endl;
uint32_t coolId = (*tt_itr)->coolId();
uint32_t pin = (coolId>>8) & 0xf;
uint32_t asic = coolId & 0xf;
uint32_t slinkChannel = asic*16 + pin;
uint32_t ppmChannel = slink2ppmChannel[slinkChannel];
uint32_t module = (coolId>>16) & 0xf;
ATH_MSG_DEBUG( "--> ZCS: " << ZdcCablingService::getInstance() << " mod=" << module << " slinkC=" << slinkChannel << " ppmC=" << ppmChannel );
chan_id = ZdcCablingService::getInstance()->h2s_channel_id(module, ppmChannel);
const uint32_t chan_hash = chan_id.get_identifier32().get_compact();
//const uint64_t chan_hash = chan_id.get_identifier32().get_compact();
// std::cout << "Trying to get gain_delay" << std::endl;
int gain = ZdcCablingService::getInstance()->hwid2gain(module,ppmChannel);
int delay = ZdcCablingService::getInstance()->hwid2delay(module,ppmChannel);
ATH_MSG_DEBUG("Trying to find chan_hash " << chan_hash << " g" << gain << "d" << delay);
//std::cout << "Trying to make map" << std::endl;
hashmapType::iterator iter = digits_map.find(chan_hash);
if (iter == digits_map.end())
{
ATH_MSG_DEBUG("new channel for " << chan_id);
xAOD::ZdcModule* new_mod = new xAOD::ZdcModule();
zdcModules->push_back(new_mod);
digits_map.insert(std::pair<uint32_t,xAOD::ZdcModule*>(chan_hash,new_mod));
iter = digits_map.find(chan_hash);
}
if (iter != digits_map.end())
{
ATH_MSG_DEBUG("new elementlinks for " << chan_id);
//std::cout << "Trying to set properties of " << chan_id << std::endl;
(*iter).second->setId(chan_hash);
//std::cout << "Set id=" << std::hex << chan_hash << std::endl;
(*iter).second->setSide(m_zdcId->side(chan_id));
(*iter).second->setZdcModule(m_zdcId->module(chan_id));
(*iter).second->setType(m_zdcId->type(chan_id));
(*iter).second->setChannel(m_zdcId->channel(chan_id));
//std::cout << "Trying to set element links of " << chan_id << std::dec << std::endl;
if (gain==0&&delay==0) (*iter).second->setTTg0d0Link( ElementLink<xAOD::TriggerTowerContainer_v2> ((*tt_itr),*ttCollection ) );
if (gain==0&&delay==1) (*iter).second->setTTg0d1Link( ElementLink<xAOD::TriggerTowerContainer_v2> ((*tt_itr),*ttCollection ) );
if (gain==1&&delay==0) (*iter).second->setTTg1d0Link( ElementLink<xAOD::TriggerTowerContainer_v2> ((*tt_itr),*ttCollection ) );
if (gain==1&&delay==1) (*iter).second->setTTg1d1Link( ElementLink<xAOD::TriggerTowerContainer_v2> ((*tt_itr),*ttCollection ) );
}
}
//std::unique_ptr< xAOD::ZdcModuleContainer > zdcModules( new xAOD::ZdcModuleContainer() );
//std::unique_ptr< xAOD::ZdcModuleAuxContainer > zdcModulesAux( new xAOD::ZdcModuleAuxContainer() );
//zdcModules->setStore( zdcModulesAux.get() );
hashmapType::iterator iter = digits_map.begin();
hashmapType::iterator iter_end = digits_map.end();
for (;iter != iter_end;iter++)
{
makeWaveformFromDigits( *((*iter).second) );
}
return 0;
}
int ZdcRecChannelToolV2::makeWaveformFromDigits(xAOD::ZdcModule& module)
{
const size_t nsamp = 5;
const float gain = 10;
std::map<int,float> waveform; // using int so i can do direct tests on whether a time exists.
std::map<int,float> waveformG0; // using int so i can do direct tests on whether a time exists.
std::map<int,float> waveformG1; // using int so i can do direct tests on whether a time exists.
float amp=0;
float ampL=0; // low gain
float rawamp=0;
float rawampL=0; // low gain
for (size_t isamp = 0;isamp<nsamp;isamp++)
{
if ( module.TTg1d0Link().isValid() )
{
if ( (*module.TTg1d0Link())->adc().size())
{
rawamp = (*module.TTg1d0Link())->adc().at(isamp);
amp = rawamp - (*module.TTg1d0Link())->adc().at(0);
waveform[isamp*250] = amp;
waveformG1[isamp*250] = amp;
}
}
if ( module.TTg0d0Link().isValid() )
{
if ( (*module.TTg0d0Link())->adc().size())
{
rawampL = (*module.TTg0d0Link())->adc().at(isamp);
ampL = rawampL - (*module.TTg0d0Link())->adc().at(0);
waveformG0[isamp*250] = ampL;
if (rawamp > m_saturation) // i.e. if high gain defined for D0 saturates
{
waveform[isamp*250] = ampL * gain;
}
}
}
if ( module.TTg1d1Link().isValid() )
{
if ( (*module.TTg1d1Link())->adc().size())
{
rawamp = (*module.TTg1d1Link())->adc().at(isamp);
amp = rawamp - (*module.TTg1d1Link())->adc().at(0);
waveform[isamp*250-125] = amp;
waveformG1[isamp*250-125] = amp;
}
}
if ( module.TTg0d1Link().isValid() )
{
if ((*module.TTg0d1Link())->adc().size())
{
rawampL = (*module.TTg0d1Link())->adc().at(isamp);
ampL = rawampL - (*module.TTg0d1Link())->adc().at(0);
waveformG0[isamp*250-125] = ampL;
if (rawamp > m_saturation) // i.e. if high gain defined for D1 saturates
{
waveform[isamp*250-125] = ampL * gain;
}
}
}
}
// copy constructed waveform into module for subsequent processing
// also add summary information on amplitude, time, qual
std::vector<float> times;
std::vector<float> adcs;
float peak_amp=0, peak_time=0, peak_qual=0;
splitWaveform(waveform,times,adcs);
getPeakProperties(times,adcs,peak_time,peak_amp,peak_qual);
// copy them to the module
module.setWaveformTime(times);
module.setWaveformADC(adcs);
module.setAmplitude(peak_amp);
module.setTime(peak_time);
module.setQual(peak_qual);
splitWaveform(waveformG0,times,adcs);
getPeakProperties(times,adcs,peak_time,peak_amp,peak_qual);
// copy them to the module
module.setWaveformTimeG0(times);
module.setWaveformADCG0(adcs);
module.setAmplitudeG0(peak_amp);
module.setTimeG0(peak_time);
module.setQualG0(peak_qual);
splitWaveform(waveformG1,times,adcs);
getPeakProperties(times,adcs,peak_time,peak_amp,peak_qual);
// copy them to the module
module.setWaveformTimeG1(times);
module.setWaveformADCG1(adcs);
module.setAmplitudeG1(peak_amp);
module.setTimeG1(peak_time);
module.setQualG1(peak_qual);
return 0;
}
//Returns a pointer to a RawChannel Collection with energy and time
//==================================================================================================
int ZdcRecChannelToolV2::makeRawFromDigits(xAOD::ZdcModuleContainer& m_ChannelCollection)
{
Identifier id;
msg(MSG::DEBUG) << "--> ZDC : ZdcRecChannelToolV2 m_ChannelCollection size " << m_ChannelCollection.size() << endreq ;
return 0;
}
int ZdcRecChannelToolV2::splitWaveform(std::map<int,float>& waveform, std::vector<float>& times, std::vector<float>& adcs)
{
times.clear();
adcs.clear();
std::map<int,float>::const_iterator wf_it = waveform.begin();
std::map<int,float>::const_iterator wf_end = waveform.end();
for (;wf_it != wf_end;wf_it++)
{
//std::cout << iwf++ << "t=" << (*wf_it).first << " a=" << (*wf_it).second << std::endl;
times.push_back((*wf_it).first / 10. ); // convert back to ns
adcs.push_back((*wf_it).second );
}
return 1;
}
int ZdcRecChannelToolV2::getPeakProperties(std::vector<float>& times, std::vector<float>& adcs, float& time, float& amp, float& qual)
{
if (times.size() != adcs.size())
{
msg(MSG::WARNING) << "times and ADCs inconsistent!" << endreq;
return 0;
}
float max_adc = -999;
float max_time = -999;
float max_qual = 0;
for (size_t i = 0;i<times.size();i++)
{
if (adcs.at(i) > max_adc)
{
max_adc = adcs.at(i);
max_time = times.at(i);
max_qual = 1.;
}
}
time = max_time;
amp = max_adc;
qual = max_qual;
return 1;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/*
* ZdcRecV2.cxx
*
* Created on: Nov 24, 2009
* Author: leite
*/
#include <memory>
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/StatusCode.h"
#include "StoreGate/StoreGateSvc.h"
//#include "Identifier/Identifier.h"
#include "xAODForward/ZdcModuleAuxContainer.h"
#include "xAODForward/ZdcModuleContainer.h"
#include "ZdcRec/ZdcRecV2.h"
#include "ZdcRec/ZdcRecChannelToolV2.h"
#include "xAODForward/ZdcModuleToString.h"
#include "ZdcByteStream/ZdcToString.h"
//==================================================================================================
ZdcRecV2::ZdcRecV2(const std::string& name, ISvcLocator* pSvcLocator) :
AthAlgorithm(name, pSvcLocator),
m_storeGate("StoreGateSvc", name),
m_ownPolicy(static_cast<int> (SG::OWN_ELEMENTS)),
m_ttContainerName("ZdcTriggerTowers"),
m_zdcModuleContainerName("ZdcModules"),
m_zdcModuleAuxContainerName("ZdcModulesAux."),
m_ttContainer(0),
m_eventCount(0),
m_complainContain(1),
m_complainRetrieve(1)
{
declareProperty("OwnPolicy",m_ownPolicy) ;
declareProperty("DigitsContainerName", m_ttContainerName, "ZdcTriggerTowers");
declareProperty("ZdcModuleContainerName", m_zdcModuleContainerName, "ZdcModules");
declareProperty("ZdcModuleAuxContainerName", m_zdcModuleAuxContainerName, "ZdcModulesAux.");
}
//==================================================================================================
//==================================================================================================
ZdcRecV2::~ZdcRecV2() {}
//==================================================================================================
//==================================================================================================
StatusCode ZdcRecV2::initialize()
{
MsgStream mLog(msgSvc(), name());
// Look up the Storegate service
StatusCode sc = m_storeGate.retrieve();
if (sc.isFailure())
{
mLog << MSG::FATAL << "--> ZDC: Unable to retrieve pointer to StoreGateSvc" << endreq;
return sc;
}
// Reconstruction Tool
StatusCode scTool = m_ChannelTool.retrieve();
if (scTool.isFailure())
{
mLog << MSG::WARNING << "--> ZDC: Could not retrieve " << m_ChannelTool << endreq;
return StatusCode::FAILURE;
}
mLog << MSG::DEBUG << "--> ZDC: SUCCESS retrieving " << m_ChannelTool << endreq;
// Container output name
//TODO: change MESSAGE !!
mLog << MSG::DEBUG << " Output Container Name " << m_zdcModuleContainerName << endreq;
if (m_ownPolicy == SG::OWN_ELEMENTS)
mLog << MSG::DEBUG << "...will OWN its cells." << endreq;
else
mLog << MSG::DEBUG << "...will VIEW its cells." << endreq;
mLog << MSG::DEBUG << "--> ZDC: ZdcRecV2 initialization complete" << endreq;
return StatusCode::SUCCESS;
}
//==================================================================================================
//==================================================================================================
StatusCode ZdcRecV2::execute()
{
MsgStream mLog(msgSvc(), name());
mLog << MSG::DEBUG
<< "--> ZDC: ZdcRecV2 execute starting on "
<< m_eventCount
<< "th event"
<< endreq;
m_eventCount++;
//Look for the container presence
bool dg = m_storeGate->contains<xAOD::TriggerTowerContainer>( m_ttContainerName);
if (!dg) {
if (m_complainContain) mLog << MSG::WARNING << "--> ZDC: StoreGate does not contain " << m_ttContainerName << endreq;
m_complainContain = 0;
return StatusCode::SUCCESS;
}
// Look up the Digits "TriggerTowerContainer" in Storegate
StatusCode digitsLookupSC = m_storeGate->retrieve(m_ttContainer, m_ttContainerName);
if (digitsLookupSC.isFailure())
{
if (m_complainRetrieve)
mLog << MSG::WARNING
<< "--> ZDC: Could not retrieve "
<< m_ttContainerName
<< " from StoreGate"
<< endreq;
m_complainRetrieve = 0;
return StatusCode::SUCCESS;
}
if (digitsLookupSC.isSuccess() && !m_ttContainer)
{
mLog << MSG::ERROR
<< "--> ZDC: Storegate returned zero pointer for "
<< m_ttContainerName
<< endreq;
return StatusCode::SUCCESS;
}
//mLog << MSG::DEBUG << ZdcToString( *m_ttContainer ) << endreq;
//Create the containers to hold the reconstructed information (you just pass the pointer and the converter does the work)
std::unique_ptr<xAOD::ZdcModuleContainer> moduleContainer( new xAOD::ZdcModuleContainer());
std::unique_ptr<xAOD::ZdcModuleAuxContainer> moduleAuxContainer( new xAOD::ZdcModuleAuxContainer() );
moduleContainer->setStore( moduleAuxContainer.get() );
int ncha = m_ChannelTool->convertTT2ZM(m_ttContainer, moduleContainer.get() );
msg( MSG::DEBUG ) << "Channel tool returns " << ncha << endreq;
msg( MSG::DEBUG ) << ZdcModuleToString(*moduleContainer) << endreq;
//msg( MSG::INFO ) << ZdcModuleToString(*moduleContainer) << endreq;
ATH_CHECK( evtStore()->record( std::move(moduleContainer), m_zdcModuleContainerName) );
ATH_CHECK( evtStore()->record( std::move(moduleAuxContainer), m_zdcModuleAuxContainerName) );
return StatusCode::SUCCESS;
}
//==================================================================================================
//==================================================================================================
StatusCode ZdcRecV2::finalize()
{
MsgStream mLog(msgSvc(),name());
mLog << MSG::DEBUG
<< "--> ZDC: ZdcRecV2 finalize complete"
<< endreq;
return StatusCode::SUCCESS;
}
//==================================================================================================
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "ZdcRec/ZdcRec.h"
#include "ZdcRec/ZdcRecV2.h"
#include "ZdcRec/ZdcRecChannelTool.h"
#include "ZdcRec/ZdcRecChannelToolV2.h"
#include "ZdcRec/ZdcRecNoiseTool.h"
#include "ZdcRec/ZdcSignalSinc.h"
DECLARE_ALGORITHM_FACTORY (ZdcRec)
DECLARE_ALGORITHM_FACTORY (ZdcRecV2)
DECLARE_TOOL_FACTORY (ZdcRecChannelTool)
DECLARE_TOOL_FACTORY (ZdcRecChannelToolV2)
DECLARE_TOOL_FACTORY (ZdcRecNoiseTool)
DECLARE_FACTORY_ENTRIES (ZdcRec) {
DECLARE_TOOL (ZdcRecChannelTool)
DECLARE_TOOL (ZdcRecChannelToolV2)
DECLARE_TOOL (ZdcRecNoiseTool)
DECLARE_ALGORITHM (ZdcRec)
DECLARE_ALGORITHM (ZdcRecV2)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment