Commit 447d0c43 authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

AthenaBaseComps migration. (CaloCellCorrection-00-00-35)

	* Tagging CaloCellCorrection-00-00-35.
	* AthenaBaseComps migration.

2014-11-17 Walter Lampl <walter.lampl@ cern.ch>
	* CaloCellPedestalCorr: Use hash from CaloDDE. Use AthAlgTool base-class.
	* tag CaloCellCorrection-00-00-34
parent 5ed6c799
......@@ -5,7 +5,7 @@
#ifndef CALOREC_CALOCELLNEIGHBORSAVERAGECORR_H
#define CALOREC_CALOCELLNEIGHBORSAVERAGECORR_H
#include "GaudiKernel/AlgTool.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "CaloInterface/ICaloCellMakerTool.h"
#include "AthenaKernel/IOVSvcDefs.h"
......@@ -17,7 +17,7 @@ class CaloCell_ID;
class TileID;
//inspiration from http://alxr.usatlas.bnl.gov/lxr-stb3/source/atlas/Calorimeter/CaloRec/CaloRec/CaloCellCopyTool.h#032
class CaloCellNeighborsAverageCorr : public AlgTool,
class CaloCellNeighborsAverageCorr : public AthAlgTool,
virtual public ICaloCellMakerTool
{
......
......@@ -34,7 +34,7 @@ CaloCellNeighborsAverageCorr::CaloCellNeighborsAverageCorr(
const std::string& type,
const std::string& name,
const IInterface* parent)
:AlgTool(type, name, parent)
:AthAlgTool(type, name, parent)
{
declareInterface<ICaloCellMakerTool>(this);
declareProperty("testMode",m_testMode=false,"test mode");
......@@ -49,39 +49,26 @@ CaloCellNeighborsAverageCorr::CaloCellNeighborsAverageCorr(
StatusCode CaloCellNeighborsAverageCorr::initialize()
{
MsgStream log(msgSvc(),name());
log << MSG::INFO << " in CaloCellNeighborsAverageCorr::initialize() " << endreq;
ATH_MSG_INFO ( " in CaloCellNeighborsAverageCorr::initialize() " );
if (m_testMode)
log << MSG::DEBUG << " Running in Test Mode. " << endreq;
ATH_MSG_DEBUG ( " Running in Test Mode. " );
// don't need to check status of the drawer if all dead cells are ignored
if (m_skipDeadTile && m_skipDeadDrawer) {
log << MSG::WARNING << "Please, don't set skipDeadDrawer and skipDeadTile to True at the same time" << endreq;
log << MSG::WARNING << "Setting skipDeadDrawer=False" << endreq;
ATH_MSG_WARNING ( "Please, don't set skipDeadDrawer and skipDeadTile to True at the same time" );
ATH_MSG_WARNING ( "Setting skipDeadDrawer=False" );
m_skipDeadDrawer=false;
}
log << MSG::INFO << "Skip Dead Feb = " << ((m_skipDeadFeb)?"true":"false") << endreq;
log << MSG::INFO << "Skip Dead LAr = " << ((m_skipDeadLAr)?"true":"false") << endreq;
log << MSG::INFO << "Skip Dead Drawer = " << ((m_skipDeadDrawer)?"true":"false") << endreq;
log << MSG::INFO << "Skip Dead Tile = " << ((m_skipDeadTile)?"true":"false") << endreq;
ATH_MSG_INFO ( "Skip Dead Feb = " << ((m_skipDeadFeb)?"true":"false") );
ATH_MSG_INFO ( "Skip Dead LAr = " << ((m_skipDeadLAr)?"true":"false") );
ATH_MSG_INFO ( "Skip Dead Drawer = " << ((m_skipDeadDrawer)?"true":"false") );
ATH_MSG_INFO ( "Skip Dead Tile = " << ((m_skipDeadTile)?"true":"false") );
StoreGateSvc* detStore;
if (service("DetectorStore", detStore).isFailure()) {
log << MSG::ERROR << "Unable to access DetectoreStore" << endreq ;
return StatusCode::FAILURE;
}
const IGeoModelSvc *geoModel=0;
StatusCode sc = service("GeoModelSvc", geoModel);
if(sc.isFailure())
{
log << MSG::ERROR << "Could not locate GeoModelSvc" << endreq;
return sc;
}
CHECK( service("GeoModelSvc", geoModel) );
// dummy parameters for the callback:
int dummyInt=0;
......@@ -93,18 +80,13 @@ StatusCode CaloCellNeighborsAverageCorr::initialize()
}
else
{
sc = detStore->regFcn(&IGeoModelSvc::geoInit,
geoModel,
&CaloCellNeighborsAverageCorr::geoInit,this);
if(sc.isFailure())
{
log << MSG::ERROR << "Could not register geoInit callback" << endreq;
return sc;
}
CHECK( detStore()->regFcn(&IGeoModelSvc::geoInit,
geoModel,
&CaloCellNeighborsAverageCorr::geoInit,this) );
}
log << MSG::INFO << "CaloCellNeighborsAverageCorr initialize() end" << endreq;
ATH_MSG_INFO ( "CaloCellNeighborsAverageCorr initialize() end" );
return StatusCode::SUCCESS;
}
......@@ -114,8 +96,7 @@ StatusCode CaloCellNeighborsAverageCorr::initialize()
StatusCode
CaloCellNeighborsAverageCorr::geoInit(IOVSVC_CALLBACK_ARGS)
{
MsgStream log(msgSvc(),name());
log << MSG::INFO << " in geoInit " << endreq;
ATH_MSG_INFO ( " in geoInit " );
m_calo_dd_man = CaloDetDescrManager::instance();
m_calo_id = m_calo_dd_man->getCaloCell_ID();
m_tile_id = m_calo_id->tile_idHelper();
......@@ -127,9 +108,7 @@ CaloCellNeighborsAverageCorr::geoInit(IOVSVC_CALLBACK_ARGS)
StatusCode CaloCellNeighborsAverageCorr::process(CaloCellContainer* theCont)
{
MsgStream log(msgSvc(),name());
bool lVerbose = (log.level()<=MSG::VERBOSE);
if (lVerbose) log << MSG::VERBOSE << " in process " << endreq;
ATH_MSG_VERBOSE ( " in process " );
//inspired from Calorimeter/CaloRec/src/CaloTopoClusterMaker.cxx
// (to be moved such that can be jobOptions configurable )
......@@ -170,7 +149,7 @@ StatusCode CaloCellNeighborsAverageCorr::process(CaloCellContainer* theCont)
++nGoodCellsPerDrawer[part][module];
}
}
if (lVerbose) {
if (msgLvl(MSG::VERBOSE)) {
// 1-1 2-1 1+1 2+1
const char * name[4] = {"LBC","EBC","LBA","EBA"};
for (int part=0; part<4; ++part) {
......@@ -180,7 +159,7 @@ StatusCode CaloCellNeighborsAverageCorr::process(CaloCellContainer* theCont)
// << ( ( nGoodCellsPerDrawer[part][module] < 2 ) ? " bad drawer" : "")
// << endreq;
if ( nGoodCellsPerDrawer[part][module] < 2 ) {
log << MSG::VERBOSE << "Bad drawer " << name[part] << module+1 << endreq;
ATH_MSG_VERBOSE ( "Bad drawer " << name[part] << module+1 );
}
}
}
......@@ -202,7 +181,7 @@ StatusCode CaloCellNeighborsAverageCorr::process(CaloCellContainer* theCont)
if (isTile) {
if (m_skipDeadTile) {
if (lVerbose) log << MSG::VERBOSE << " skipping Tile hash " << m_calo_id->calo_cell_hash(aCell->ID()) << endreq;
ATH_MSG_VERBOSE ( " skipping Tile hash " << m_calo_id->calo_cell_hash(aCell->ID()) );
continue;
} else if (m_skipDeadDrawer) {
......@@ -210,7 +189,7 @@ StatusCode CaloCellNeighborsAverageCorr::process(CaloCellContainer* theCont)
int part = std::min(m_tile_id->section(id),2)+m_tile_id->side(id);
int module = m_tile_id->module(id);
if ( nGoodCellsPerDrawer[part][module] < 2 ) {
if (lVerbose) log << MSG::VERBOSE << " skipping Tile drawer hash " << m_calo_id->calo_cell_hash(aCell->ID()) << endreq;
ATH_MSG_VERBOSE ( " skipping Tile drawer hash " << m_calo_id->calo_cell_hash(aCell->ID()) );
continue;
}
}
......@@ -218,10 +197,10 @@ StatusCode CaloCellNeighborsAverageCorr::process(CaloCellContainer* theCont)
} else {
if (m_skipDeadLAr) {
if (lVerbose) log << MSG::VERBOSE << " skipping LAr hash " << m_calo_id->calo_cell_hash(aCell->ID()) << endreq;
ATH_MSG_VERBOSE ( " skipping LAr hash " << m_calo_id->calo_cell_hash(aCell->ID()) );
continue;
} else if (m_skipDeadFeb && ((aCell->provenance() & 0x0200) == 0x0200) ) {
if (lVerbose) log << MSG::VERBOSE << " skipping LAr Feb hash " << m_calo_id->calo_cell_hash(aCell->ID()) << endreq;
ATH_MSG_VERBOSE ( " skipping LAr Feb hash " << m_calo_id->calo_cell_hash(aCell->ID()) );
continue;
}
}
......@@ -232,7 +211,7 @@ StatusCode CaloCellNeighborsAverageCorr::process(CaloCellContainer* theCont)
Identifier theCellID = aCell->ID();
IdentifierHash theCellHashID = m_calo_id->calo_cell_hash(theCellID);
if (lVerbose) log << MSG::VERBOSE << " correcting " << ((isTile)?"Tile":"LAr") << " hash " << theCellHashID << endreq;
ATH_MSG_VERBOSE ( " correcting " << ((isTile)?"Tile":"LAr") << " hash " << theCellHashID );
//Find now the neighbors around theCell, and store them in theNeighbors vector.
m_calo_id->get_neighbours(theCellHashID,m_nOption,theNeighbors);
......
......@@ -54,32 +54,19 @@ CaloCellPedestalCorr::CaloCellPedestalCorr(
StatusCode CaloCellPedestalCorr::initialize()
{
MsgStream log(msgSvc(),name());
log << MSG::INFO << " in CaloCellPedestalCorr::initialize() " << endreq;
StoreGateSvc* detStore;
StatusCode sc = service ( "DetectorStore" , detStore ) ;
if (sc.isFailure()) {
log << MSG::ERROR << " Unable to get DetectorStore " << endreq;
return StatusCode::FAILURE;
}
sc=detStore->retrieve(m_cellId, "CaloCell_ID");
if (sc.isFailure()) {
log << MSG::ERROR << " Unable to get CaloCell_ID" << endreq;
return StatusCode::FAILURE;
}
msg(MSG::INFO) << " in CaloCellPedestalCorr::initialize() " << endreq;
ATH_CHECK(detStore()->retrieve(m_cellId, "CaloCell_ID"));
if (m_lumi0<0) {
if (detStore->contains<CondAttrListCollection>(m_lumiFolderName)) {
if (detStore()->contains<CondAttrListCollection>(m_lumiFolderName)) {
const DataHandle<CondAttrListCollection> lumiData;
sc = detStore->regFcn(&CaloCellPedestalCorr::updateLumi, this , lumiData, m_lumiFolderName, true);
StatusCode sc = detStore()->regFcn(&CaloCellPedestalCorr::updateLumi, this , lumiData, m_lumiFolderName, true);
if (sc.isFailure()) {
log << MSG::ERROR << " cannot register callback for luminosity " << endreq;
msg(MSG::ERROR) << " cannot register callback for luminosity " << endreq;
return StatusCode::FAILURE;
}
log << MSG::INFO << " Registered a callback for " << m_lumiFolderName << " Cool folder " << endreq;
msg(MSG::INFO) << " Registered a callback for " << m_lumiFolderName << " Cool folder " << endreq;
}
m_lumi0=0;
}
......@@ -87,29 +74,21 @@ StatusCode CaloCellPedestalCorr::initialize()
if (!m_isMC) {
//=== Register callback for this data handle
sc=detStore->regFcn(&CaloCellPedestalCorr::updateMap, this, m_noiseAttrListColl, m_folderName);
StatusCode sc=detStore()->regFcn(&CaloCellPedestalCorr::updateMap, this, m_noiseAttrListColl, m_folderName);
if (sc.isFailure()) {
log << MSG::ERROR << " cannot register callback " << endreq;
msg(MSG::ERROR) << " cannot register callback " << endreq;
return StatusCode::FAILURE;
}
log << MSG::INFO << " registered a callback for " << m_folderName << " folder " << endreq;
msg(MSG::INFO) << " registered a callback for " << m_folderName << " folder " << endreq;
sc = m_caloCoolIdTool.retrieve();
if (sc.isFailure()) {
log << MSG::ERROR << " cannot retrieve CaloCoolIdTool" << endreq;
return StatusCode::FAILURE;
}
ATH_CHECK(m_caloCoolIdTool.retrieve());
}
if (!m_caloLumiBCIDTool.empty() ) {
sc = m_caloLumiBCIDTool.retrieve();
if (sc.isFailure()) {
log <<MSG::ERROR << " cannot retrieve LumiBCIDTool" << endreq;
return StatusCode::FAILURE;
}
ATH_CHECK(m_caloLumiBCIDTool.retrieve());
}
log << MSG::INFO << "CaloCellPedestalCorr initialize() end" << endreq;
msg(MSG::INFO) << "CaloCellPedestalCorr initialize() end" << endreq;
return StatusCode::SUCCESS;
......@@ -119,46 +98,35 @@ StatusCode CaloCellPedestalCorr::initialize()
StatusCode
CaloCellPedestalCorr::updateLumi( IOVSVC_CALLBACK_ARGS )
{
MsgStream log(msgSvc(), name());
log << MSG::INFO << " in updateLumi() " << endreq;
StoreGateSvc* detStore;
StatusCode sc = service ( "DetectorStore" , detStore ) ;
if (sc.isFailure()) {
log << MSG::ERROR << " Unable to get DetectorStore " << endreq;
return StatusCode::FAILURE;
}
msg(MSG::INFO) << " in updateLumi() " << endreq;
const CondAttrListCollection* attrListColl = 0;
sc = detStore->retrieve(attrListColl, m_lumiFolderName);
if (sc.isFailure() || !attrListColl) {
log << MSG::WARNING << "attrrListColl not found for " << m_lumiFolderName << endreq;
return StatusCode::SUCCESS;
}
ATH_CHECK(detStore()->retrieve(attrListColl, m_lumiFolderName));
// Loop over collection
CondAttrListCollection::const_iterator first = attrListColl->begin();
CondAttrListCollection::const_iterator last = attrListColl->end();
for (; first != last; ++first) {
if ((*first).first == 0) {
std::ostringstream attrStr1;
(*first).second.toOutputStream( attrStr1 );
log << MSG::DEBUG << "ChanNum " << (*first).first <<
" Attribute list " << attrStr1.str() << endreq;
const coral::AttributeList& attrList = (*first).second;
if (attrList["LBAvInstLumi"].isNull()) {
log << MSG::WARNING << " NULL Luminosity information in database ... set it to 0 " << endreq;
m_lumi0 = 0.;
} else {
m_lumi0 = attrList["LBAvInstLumi"].data<float>() *1e-3; // luminosity (from 10**30 units in db to 10*33 units)
}
break;
if (msgLvl(MSG::DEBUG)) {
std::ostringstream attrStr1;
(*first).second.toOutputStream( attrStr1 );
msg(MSG::DEBUG) << "ChanNum " << (*first).first << " Attribute list " << attrStr1.str() << endreq;
}
const coral::AttributeList& attrList = (*first).second;
if (attrList["LBAvInstLumi"].isNull()) {
msg(MSG::WARNING) << " NULL Luminosity information in database ... set it to 0 " << endreq;
m_lumi0 = 0.;
} else {
m_lumi0 = attrList["LBAvInstLumi"].data<float>() *1e-3; // luminosity (from 10**30 units in db to 10*33 units)
}
break;
}
}
if ( !(m_lumi0 == m_lumi0) ) {
log << MSG::WARNING << " Luminosity not a number ? m_lumi0 " << m_lumi0 << " ... set it to 0 " << endreq;
m_lumi0 = 0.;
msg(MSG::WARNING) << " Luminosity not a number ? m_lumi0 " << m_lumi0 << " ... set it to 0 " << endreq;
m_lumi0 = 0.;
}
log << MSG::INFO << " Luminosity " << m_lumi0 << endreq;
msg(MSG::INFO) << " Luminosity " << m_lumi0 << endreq;
return StatusCode::SUCCESS;
}
......@@ -168,15 +136,12 @@ CaloCellPedestalCorr::updateLumi( IOVSVC_CALLBACK_ARGS )
StatusCode CaloCellPedestalCorr::updateMap(IOVSVC_CALLBACK_ARGS_K(keys) )
{
MsgStream log(msgSvc(),name());
log << MSG::INFO << " in updateMap ";
msg(MSG::INFO) << " in updateMap ";
std::list<std::string>::const_iterator itr;
for (itr=keys.begin(); itr!=keys.end(); ++itr) {
log << *itr << " ";
msg() << *itr << " ";
}
log << endreq;
msg() << endreq;
//=== loop over collection (all cool channels)
CondAttrListCollection::const_iterator iColl = m_noiseAttrListColl->begin();
......@@ -208,11 +173,11 @@ StatusCode CaloCellPedestalCorr::updateMap(IOVSVC_CALLBACK_ARGS_K(keys) )
void CaloCellPedestalCorr::MakeCorrection(CaloCell* theCell)
{
const unsigned int cellHash=m_cellId->calo_cell_hash(theCell->ID());
float pedestal=0.;
if (!m_isMC) {
const unsigned int cellHash=theCell->caloDDE()->calo_hash();
unsigned int subHash;
const unsigned int iCool = m_caloCoolIdTool->getCoolChannelId(cellHash,subHash);
//std::cout << "Got iCool=" << iCool << " subhash=" << subHash << std::endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment