Skip to content
Snippets Groups Projects
Commit 580d8ad8 authored by Adam Edward Barton's avatar Adam Edward Barton :speech_balloon:
Browse files

Merge branch 'rtSmearingMaster' into 'master'

Sweep r-t smearing functionality to master from 21.3

See merge request atlas/athena!20189
parents d46de52f 640fe85e
No related branches found
No related tags found
No related merge requests found
Showing
with 936 additions and 124 deletions
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
// IShiftMapTools.h
// Header file for class IShiftMapTools
///////////////////////////////////////////////////////////////////
// (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
// der.andi@cern.ch
///////////////////////////////////////////////////////////////////
#ifndef ISHIFTMAPTOOLS_H
#define ISHIFTMAPTOOLS_H
// Include files
// from Gaudi
#include "GaudiKernel/IService.h"
// forward declarations
class Identifier;
namespace MuonCalib {
/**
@class IShiftMapTools
Interface for the ShiftMapTools inheriting from MdtCalibrationShiftMapBase
@author der.andi@cern.ch
*/
class IShiftMapTools : virtual public IService {
public:
IShiftMapTools() { ; }
virtual ~IShiftMapTools() { ; }
/* Creates the InterfaceID and interfaceID() method */
DeclareInterfaceID(IShiftMapTools, 1, 0);
/* get shift value */
virtual float getValue(const Identifier& id) = 0;
};
} // namespace MuonCalib
#endif
......@@ -12,6 +12,8 @@ atlas_depends_on_subdirs( PUBLIC
DetectorDescription/GeoPrimitives
DetectorDescription/Identifier
GaudiKernel
MuonSpectrometer/MuonCablings/MuonMDT_Cabling
MuonSpectrometer/MuonCablings/MuonCablingData
MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData
MuonSpectrometer/MuonCalib/MuonCalibIdentifier
MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData
......@@ -21,7 +23,8 @@ atlas_depends_on_subdirs( PUBLIC
MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibInterfaces
MuonSpectrometer/MuonCalib/MuonCalibEvent
MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry
MuonSpectrometer/MuonIdHelpers )
MuonSpectrometer/MuonIdHelpers
Tools/PathResolver )
# External dependencies:
find_package( Eigen )
......@@ -31,14 +34,15 @@ atlas_add_library( MdtCalibSvcLib
src/*.cxx
PUBLIC_HEADERS MdtCalibSvc
INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS}
LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives Identifier GaudiKernel MdtCalibData MuonCalibIdentifier MuonPrepRawData StoreGateLib SGtests MuonIdHelpersLib
LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives Identifier GaudiKernel MuonMDT_CablingLib MdtCalibData MuonCalibIdentifier MuonPrepRawData StoreGateLib SGtests MuonIdHelpersLib PathResolver
PRIVATE_LINK_LIBRARIES MagFieldInterfaces MuonCalibEvent MuonReadoutGeometry )
atlas_add_component( MdtCalibSvc
src/components/*.cxx
INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS}
LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives Identifier GaudiKernel MdtCalibData MuonCalibIdentifier MuonPrepRawData StoreGateLib SGtests MagFieldInterfaces MuonCalibEvent MuonReadoutGeometry MuonIdHelpersLib MdtCalibSvcLib )
LINK_LIBRARIES MdtCalibSvcLib )
# Install files from the package:
atlas_install_runtime( share/DC2_t0.dat share/DC2_rt.dat )
atlas_install_joboptions( share/*.py )
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MDTCALIBSVC_MDTCALIBRATIONSHIFTMAPBASE_H
#define MDTCALIBSVC_MDTCALIBRATIONSHIFTMAPBASE_H
/*
*
* Author Andreas Hoenle (der.andi@cern.ch)
*
*/
#include <map>
// Framework includes
#include "AthenaBaseComps/AthService.h"
// MDT interfaces
#include "MdtCalibInterfaces/IShiftMapTools.h"
// MDT includes
#include "MuonMDT_Cabling/MuonMDT_CablingSvc.h"
class Identifier;
class TTree;
/**
@class MdtCalibrationShiftMapBase
Provides the base class for the per-tube shifting tools, like
MdtCalibT0ShiftTool & MdtCalibTMaxShiftTool.
@author Andreas Hoenle
*/
class MdtCalibrationShiftMapBase
: public extends<AthService, MuonCalib::IShiftMapTools> {
public:
/* constructor */
MdtCalibrationShiftMapBase(const std::string& name, ISvcLocator* pSvcLocator);
/* destructor */
~MdtCalibrationShiftMapBase();
/* get shift value, override from IShiftMapTools */
float getValue(const Identifier& id) override;
/*
* initialization of map cannot happen before first event
* special function required
* we need the cabling service to be ready first
*/
virtual StatusCode initializeMap();
/* dump the map in binary file, given a path */
StatusCode dumpMapAsFile();
/* load the map from a binary file, given a path */
StatusCode loadMapFromFile();
protected:
ServiceHandle<MuonMDT_CablingSvc> m_cablingSvc;
std::map<Identifier, float> m_shiftValues;
bool m_mapIsInitialized;
/* Make map configurable in job options */
std::string m_mapFileName;
float m_centralValue;
float m_sigma;
bool m_forceMapRecreate;
private:
};
#endif
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MDTCALIBSVC_MDTCALIBRATIONT0SHIFTSVC_H
#define MDTCALIBSVC_MDTCALIBRATIONT0SHIFTSVC_H
/*
*
* Author Andreas Hoenle (der.andi@cern.ch)
*
*/
#include <map>
#include "AthenaBaseComps/AthService.h"
#include "MdtCalibSvc/MdtCalibrationShiftMapBase.h"
class Identifier;
class TTree;
/**
@class MdtCalibrationT0ShiftSvc
Provides a per-tube smearing of the T0 value.
@author Andreas Hoenle
*/
class MdtCalibrationT0ShiftSvc : virtual public MdtCalibrationShiftMapBase {
public:
/** constructor */
MdtCalibrationT0ShiftSvc(const std::string &name, ISvcLocator* pSvcLocator);
/** destructor */
~MdtCalibrationT0ShiftSvc();
/*
* initalization of map cannot happen before first event
* special function required
*/
StatusCode initializeMap() override;
private:
};
#endif
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MDTCALIBSVC_MDTCALIBRATIONTMAXSHIFTSVC_H
#define MDTCALIBSVC_MDTCALIBRATIONTMAXSHIFTSVC_H
/*
*
* Author Andreas Hoenle (der.andi@cern.ch)
*
*/
#include <map>
#include "AthenaBaseComps/AthService.h"
#include "MdtCalibSvc/MdtCalibrationShiftMapBase.h"
class Identifier;
/*
@class MdtCalibrationTMaxShiftSvc
Provides a per-tube shifting of the TMax value.
@author Andreas Hoenle
*/
class MdtCalibrationTMaxShiftSvc : virtual public MdtCalibrationShiftMapBase {
public:
/* constructor */
MdtCalibrationTMaxShiftSvc(const std::string &name, ISvcLocator* pSvcLocator);
/* destructor */
~MdtCalibrationTMaxShiftSvc();
/*
* initalization of map cannot happen before first event
* special function required
*/
StatusCode initializeMap() override;
StatusCode setTUpper(float tUpper);
float getTUpper() { return m_tUpper; }
private:
float m_tUpper;
};
#endif
# example configuration of MdtCalibT0ShiftSvc and MdtCalibTMaxShiftSvc
# in this example the 0ns shift maps are loaded, which means that the
# modification code runs, but it does not change anything
"""
NEVER recreate the shift maps when you're running multiple jobs.
If you want to recreate, run a single job to create the map and configure the
jobs to load the new map when submitting them.
It's all just random numbers and you cannot be sure that the tubes will get the
same shifts in all jobs.
(Yes, the RNGs are seeded, but what if someone changes this later?)
"""
from MdtCalibT0ShiftSvc.MdtCalibT0ShiftSvcConf import MdtCalibrationT0ShiftSvc
ServiceMgr += MdtCalibrationT0ShiftSvc()
ServiceMgr.MdtCalibrationT0ShiftSvc.MapFile = 'shift_t0_0ns.dat' # which shift map to load / how to save it if not existing (in the package's share folder)
ServiceMgr.MdtCalibrationT0ShiftSvc.CentralValue = 0 # central value of Gaussian RNG - only relevant if you recreate the map
ServiceMgr.MdtCalibrationT0ShiftSvc.Sigma = 0 # sigma value of Gaussian RNG - only relevant if you recreate the map
ServiceMgr.MdtCalibrationT0ShiftSvc.ForceMapRecreate = False # force recreation of map - never do this when submitting multiple jobs
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
// std
#include <sys/stat.h>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
// other packages
#include "GaudiKernel/GaudiException.h"
#include "GaudiKernel/MsgStream.h"
#include "Identifier/Identifier.h"
#include "MuonCablingData/MuonMDT_CablingMap.h"
#include "MuonIdHelpers/MdtIdHelper.h"
#include "PathResolver/PathResolver.h"
#include "StoreGate/DataHandle.h"
#include "StoreGate/StoreGateSvc.h"
// this package
#include "MdtCalibSvc/MdtCalibrationShiftMapBase.h"
#include "TTree.h"
// TRandom3 for random shifting
// should later be replaced with std
#include "TRandom3.h"
//
// private helper functions
//
MdtCalibrationShiftMapBase::MdtCalibrationShiftMapBase(const std::string &name,
ISvcLocator *pSvcLocator)
: base_class(name, pSvcLocator),
m_cablingSvc("MuonMDT_CablingSvc", name),
m_mapIsInitialized(false),
m_mapFileName(""),
m_centralValue(0),
m_sigma(10),
m_forceMapRecreate(false) {
declareProperty("MapFile", m_mapFileName);
declareProperty("CentralValue", m_centralValue = 0);
declareProperty("Sigma", m_sigma = 10);
declareProperty("ForceMapRecreate", m_forceMapRecreate = false);
}
MdtCalibrationShiftMapBase::~MdtCalibrationShiftMapBase() { ; }
// return failure if not overloaded
StatusCode MdtCalibrationShiftMapBase::initializeMap() {
return StatusCode::FAILURE;
}
StatusCode MdtCalibrationShiftMapBase::dumpMapAsFile() {
/* initialize map if it's not there */
if (!m_mapIsInitialized) {
initializeMap();
}
/* write the map to a file */
{
std::ofstream file(m_mapFileName.c_str(), std::ios::out | std::ios::trunc);
/* see if opening the file was successful */
if (!file.is_open()) {
ATH_MSG_FATAL(
"Cannot open map output file for writing. Tried accessing file at "
"\"./"
<< m_mapFileName.c_str() << "\"");
return StatusCode::FAILURE;
}
/* write header, comments can start with '#' or '//' */
file << "# This file contains shift values for MDT tubes\n";
file << "# Each Identifier is mapped to a float\n";
file << "# Below are comma separated values with formatting\n";
file << "# Identifier.get_compact(),float\n";
file << "# ------------------------------------------------\n";
/* dump map contents */
for (auto shift : m_shiftValues) {
Identifier::value_type identifierCompact = shift.first.get_compact();
float shiftValue = shift.second;
file << identifierCompact;
file << ",";
file << shiftValue;
file << "\n";
}
} // '}' flushes file
return StatusCode::SUCCESS;
}
StatusCode MdtCalibrationShiftMapBase::loadMapFromFile() {
/* check if map was already initialized */
if (m_mapIsInitialized) {
ATH_MSG_WARNING("Map already initialized, won't overwrite it.");
return StatusCode::SUCCESS;
}
/* resolve path */
std::string fileWithPath = PathResolver::find_file(m_mapFileName, "DATAPATH");
if (fileWithPath == "") {
ATH_MSG_ERROR("Cannot find file " << m_mapFileName << " in $DATAPATH");
return StatusCode::FAILURE;
}
/* check if the file exists */
struct stat buffer;
if (stat(fileWithPath.c_str(), &buffer) != 0) {
ATH_MSG_ERROR("Cannot stat the file \""
<< fileWithPath.c_str()
<< "\" -> map can not be initialized from this file.");
return StatusCode::FAILURE;
}
/* check if the map is already stored */
std::ifstream fin(fileWithPath.c_str(), std::ios::in);
std::string line;
bool initializedWithWarnings = false;
// get all lines in file
while (std::getline(fin, line)) {
// check if file is empty, begins with '#', or '//'
if (line.empty() || line.compare(0, 1, "#") == 0 ||
line.compare(0, 2, "//")) {
continue;
}
// need a stringstream for readline
std::stringstream lineStream(line);
// get all csv tokens in line
std::string token;
std::vector<std::string> tokenVector;
while (std::getline(lineStream, token, ',')) {
tokenVector.push_back(token);
}
// expect exactly two tokens: identifier and value
if (tokenVector.size() == 2) {
// we are careful about the type here
// watch out for compiler warnings warning about casting ull to value_type
// they might occur of Identifier::value_type is changed at some point
Identifier::value_type identifierCompact = std::stoull(tokenVector[0]);
Identifier id(identifierCompact);
float shift = std::stof(tokenVector[1]);
m_shiftValues[id] = shift;
} else {
ATH_MSG_WARNING("Unexpected input format in shift map file "
<< fileWithPath.c_str());
ATH_MSG_WARNING("Expected 2 tokens, got " << tokenVector.size());
ATH_MSG_WARNING("Broken line: \"" << line.c_str() << "\"");
initializedWithWarnings = true;
}
}
m_mapIsInitialized = true;
if (initializedWithWarnings) {
ATH_MSG_WARNING("Initialized shift map WITH WARNINGS from file \""
<< fileWithPath.c_str() << "\"");
} else {
ATH_MSG_INFO("Successfully initialized shift map from file \""
<< fileWithPath.c_str() << "\"");
}
return StatusCode::SUCCESS;
}
float MdtCalibrationShiftMapBase::getValue(const Identifier &id) {
if (!m_mapIsInitialized) {
StatusCode sc = initializeMap();
if (sc.isFailure()) {
ATH_MSG_FATAL("Could not initialize the shift map.");
throw GaudiException("Cannot run without shift map.", "", sc);
}
}
return m_shiftValues[id];
}
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
// std
#include <fstream>
#include <string>
#include <iostream>
#include <cstring>
#include <sys/stat.h>
// other packages
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/GaudiException.h"
#include "Identifier/Identifier.h"
#include "StoreGate/DataHandle.h"
#include "StoreGate/StoreGateSvc.h"
#include "MuonCablingData/MuonMDT_CablingMap.h"
#include "MuonIdHelpers/MdtIdHelper.h"
// this package
#include "TTree.h"
#include "MdtCalibSvc/MdtCalibrationShiftMapBase.h"
#include "MdtCalibSvc/MdtCalibrationT0ShiftSvc.h"
// TRandom3 for random smearing
// should later be replaced with std
#include "TRandom3.h"
//
// private helper functions
//
MdtCalibrationT0ShiftSvc::MdtCalibrationT0ShiftSvc(const std::string &name,
ISvcLocator* pSvcLocator)
: MdtCalibrationShiftMapBase(name, pSvcLocator) {}
MdtCalibrationT0ShiftSvc::~MdtCalibrationT0ShiftSvc() {}
StatusCode MdtCalibrationT0ShiftSvc::initializeMap()
{
if (m_mapIsInitialized) {
ATH_MSG_WARNING("Map already initalized. Multiple calls of initalizeMap should not happen.");
return StatusCode::SUCCESS;
}
/* First try loading the map from its default location */
if (!m_forceMapRecreate) {
ATH_CHECK(loadMapFromFile());
return StatusCode::SUCCESS;
}
/* map was not found as a file or needs to be recreated */
// TODO: What if multiple jobs started in parallel?
// (DataRace on MapFile because of parallel jobs)
/* initialize random number generator that creates the shift values */
TRandom3 rng(/*seed*/ 20120704);
/* idHelper to retrieve channel Identifiers */
const MdtIdHelper *idhelper = nullptr;
const ServiceHandle<StoreGateSvc> detStore("StoreGateSvc/DetectorStore", "detStore");
ATH_CHECK( detStore->retrieve(idhelper, "MDTIDHELPER") );
// Cabling Map (part of cablingSvc) must be retrieved AFTER the first event
// i.e. this can NOT happen in initialize
/* initialize cabling from which IDs are read */
ATH_CHECK( m_cablingSvc.retrieve() );
/* Get ROBs */
std::vector<uint32_t> robVector = m_cablingSvc->getAllROBId();
std::map<uint8_t, MdtSubdetectorMap*> *listOfSubdet;
std::map<uint8_t, MdtSubdetectorMap*>::const_iterator it_sub;
std::map<uint8_t, MdtRODMap*> *listOfROD;
std::map<uint8_t, MdtRODMap*>::const_iterator it_rod;
std::map<uint8_t, MdtCsmMap*> *listOfCsm;
std::map<uint8_t, MdtCsmMap*>::const_iterator it_csm;
std::map<uint8_t, MdtAmtMap*> *listOfAmt;
std::map<uint8_t, MdtAmtMap*>::const_iterator it_amt;
DataHandle<MuonMDT_CablingMap> cablingMap = m_cablingSvc->getCablingMap();
listOfSubdet = cablingMap->getListOfElements();
int subdetectorId, rodId, csmId, amtId;
int stationName, stationEta, stationPhi, multiLayer, layer, tube;
for (it_sub = listOfSubdet->begin(); it_sub != listOfSubdet->end(); ++it_sub) {
subdetectorId = it_sub->first;
listOfROD = it_sub->second->getListOfElements();
for (it_rod = listOfROD->begin(); it_rod != listOfROD->end(); ++it_rod) {
rodId = it_rod->first;
listOfCsm = it_rod->second->getListOfElements();
for (it_csm = listOfCsm->begin(); it_csm != listOfCsm->end(); ++it_csm) {
csmId = it_csm->first;
listOfAmt = it_csm->second->getListOfElements();
for (it_amt = listOfAmt->begin(); it_amt != listOfAmt->end(); ++it_amt) {
amtId = it_amt->first;
// amtId = it_amt->second->moduleId();
for (int tubeId = 0; tubeId < 24; ++tubeId) {
/* Get the offline ID, given the current detector element */
if (!m_cablingSvc->getOfflineId(
subdetectorId, rodId, csmId, amtId, tubeId, stationName,
stationEta, stationPhi, multiLayer, layer, tube)) {
std::ostringstream ss;
ss << "Trying to initialize non-existing tube with\n";
ss << " subdetectorId " << subdetectorId << "\n";
ss << " rodId " << rodId << "\n";
ss << " csmId " << csmId << "\n";
ss << " amtId " << amtId << "\n";
ss << " tubeId " << tubeId;
ATH_MSG_WARNING(ss.str());
continue;
}
bool isValid = false;
const Identifier channelIdentifier =
idhelper->channelID(stationName, stationEta, stationPhi,
multiLayer, layer, tube, true, &isValid);
// this debug msg can be removed eventually
std::ostringstream ss;
ss << "Trying to set from online IDs\n";
ss << " subdetectorId " << subdetectorId << "\n";
ss << " rodId " << rodId << "\n";
ss << " csmId " << csmId << "\n";
ss << " amtId " << amtId << "\n";
ss << " tubeId " << tubeId << "\n";
ss << " .. that are converted to offline IDs\n";
ss << " stationName " << stationName << "\n";
ss << " stationEta " << stationEta << "\n";
ss << " stationPhi " << stationPhi << "\n";
ss << " multiLayer " << multiLayer << "\n";
ss << " layer " << layer << "\n";
ss << " tube " << tube << "\n";
ss << " .. with channelID\n";
ss << " Identifier " << channelIdentifier << "\n";
ss << " Identifier32 " << channelIdentifier.get_identifier32();
ATH_MSG_DEBUG( ss.str() );
if (!isValid) {
ATH_MSG_FATAL( ss.str() );
ATH_MSG_FATAL("Conversion to Identifier is NOT valid.");
return StatusCode::FAILURE;
}
float rn = rng.Gaus(m_centralValue, m_sigma);
// Fatal if entry exists
if (m_shiftValues.find(channelIdentifier) != m_shiftValues.end()) {
ATH_MSG_FATAL("Double counting in initialization of map");
return StatusCode::FAILURE;
}
m_shiftValues[channelIdentifier] = rn;
}
}
}
}
}
/* initalization was successful */
m_mapIsInitialized = true;
/* write map to the default location */
ATH_CHECK( dumpMapAsFile() );
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
// std
#include <sys/stat.h>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
// other packages
#include "GaudiKernel/GaudiException.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/ServiceHandle.h"
#include "Identifier/Identifier.h"
#include "MuonCablingData/MuonMDT_CablingMap.h"
#include "MuonIdHelpers/MdtIdHelper.h"
#include "StoreGate/DataHandle.h"
#include "StoreGate/StoreGateSvc.h"
// this package
#include "MdtCalibSvc/MdtCalibrationShiftMapBase.h"
#include "MdtCalibSvc/MdtCalibrationTMaxShiftSvc.h"
// TRandom2 for random smearing
// should later be replaced with std
#include "TRandom2.h"
// temporary
#include "TCanvas.h"
#include "TH1D.h"
//
// private helper functions
//
MdtCalibrationTMaxShiftSvc::MdtCalibrationTMaxShiftSvc(const std::string &name,
ISvcLocator *pSvcLocator)
: MdtCalibrationShiftMapBase(name, pSvcLocator), m_tUpper(688.1818) {}
MdtCalibrationTMaxShiftSvc::~MdtCalibrationTMaxShiftSvc() { ; }
StatusCode MdtCalibrationTMaxShiftSvc::initializeMap() {
if (m_mapIsInitialized) {
ATH_MSG_WARNING(
"Map already initalized. Multiple calls of initalizeMap "
"should not happen.");
return StatusCode::SUCCESS;
}
/* First try loading the map from its default location */
if (!m_forceMapRecreate) {
ATH_CHECK(loadMapFromFile());
return StatusCode::SUCCESS;
}
/* map was not found as a file */
// TODO: What if multiple jobs started in parallel?
// (DataRace on MapFile because of parallel jobs)
/* initialize random number generator that creates the shift values */
TRandom2 rng(/*seed*/ 20160211);
/* idHelper to retrieve channel Identifiers */
const MdtIdHelper *idhelper = nullptr;
const ServiceHandle<StoreGateSvc> detStore("StoreGateSvc/DetectorStore",
"detStore");
ATH_CHECK(detStore->retrieve(idhelper, "MDTIDHELPER"));
// Cabling Map (part of cablingSvc) must be retrieved AFTER the first event
// i.e. this can NOT happen in initialize
/* initialize cabling from which IDs are read */
ATH_CHECK(m_cablingSvc.retrieve());
/* Get ROBs */
std::vector<uint32_t> robVector = m_cablingSvc->getAllROBId();
std::map<uint8_t, MdtSubdetectorMap *> *listOfSubdet;
std::map<uint8_t, MdtSubdetectorMap *>::const_iterator it_sub;
std::map<uint8_t, MdtRODMap *> *listOfROD;
std::map<uint8_t, MdtRODMap *>::const_iterator it_rod;
std::map<uint8_t, MdtCsmMap *> *listOfCsm;
std::map<uint8_t, MdtCsmMap *>::const_iterator it_csm;
std::map<uint8_t, MdtAmtMap *> *listOfAmt;
std::map<uint8_t, MdtAmtMap *>::const_iterator it_amt;
DataHandle<MuonMDT_CablingMap> cablingMap = m_cablingSvc->getCablingMap();
listOfSubdet = cablingMap->getListOfElements();
int subdetectorId, rodId, csmId, amtId;
int stationName, stationEta, stationPhi, multiLayer, layer, tube;
for (it_sub = listOfSubdet->begin(); it_sub != listOfSubdet->end();
++it_sub) {
subdetectorId = it_sub->first;
listOfROD = it_sub->second->getListOfElements();
for (it_rod = listOfROD->begin(); it_rod != listOfROD->end(); ++it_rod) {
rodId = it_rod->first;
listOfCsm = it_rod->second->getListOfElements();
for (it_csm = listOfCsm->begin(); it_csm != listOfCsm->end(); ++it_csm) {
csmId = it_csm->first;
listOfAmt = it_csm->second->getListOfElements();
for (it_amt = listOfAmt->begin(); it_amt != listOfAmt->end();
++it_amt) {
amtId = it_amt->first;
amtId = it_amt->second->moduleId();
for (int tubeId = 0; tubeId < 24; ++tubeId) {
/* Get the offline ID, given the current detector element */
if (!m_cablingSvc->getOfflineId(
subdetectorId, rodId, csmId, amtId, tubeId, stationName,
stationEta, stationPhi, multiLayer, layer, tube)) {
std::ostringstream ss;
ss << "Trying to initialize non-existing tube with\n";
ss << " subdetectorId " << subdetectorId << "\n";
ss << " rodId " << rodId << "\n";
ss << " csmId " << csmId << "\n";
ss << " amtId " << amtId << "\n";
ss << " tubeId " << tubeId;
ATH_MSG_WARNING(ss.str());
continue;
}
bool isValid = false;
const Identifier channelIdentifier =
idhelper->channelID(stationName, stationEta, stationPhi,
multiLayer, layer, tube, true, &isValid);
// this debug msg can be removed eventually
std::ostringstream ss;
ss << "Trying to set from online IDs\n";
ss << " subdetectorId " << subdetectorId << "\n";
ss << " rodId " << rodId << "\n";
ss << " csmId " << csmId << "\n";
ss << " amtId " << amtId << "\n";
ss << " tubelId " << tubeId << "\n";
ss << " .. that are converted to offline IDs\n";
ss << " stationName " << stationName << "\n";
ss << " stationEta " << stationEta << "\n";
ss << " stationPhi " << stationPhi << "\n";
ss << " multiLayer " << multiLayer << "\n";
ss << " layer " << layer << "\n";
ss << " tube " << tube << "\n";
ss << " .. with channelID\n";
ss << " Identifier " << channelIdentifier << "\n";
ss << " Identifier32 " << channelIdentifier.get_identifier32();
ATH_MSG_DEBUG(ss.str());
// Throw fatal msg if entry exists
if (!isValid) {
ATH_MSG_FATAL(ss.str());
ATH_MSG_FATAL("Conversion to Identifier is NOT valid.");
return StatusCode::FAILURE;
}
if (m_shiftValues.find(channelIdentifier) != m_shiftValues.end()) {
ATH_MSG_FATAL("Double counting in initilization of map");
return StatusCode::FAILURE;
}
float rn = rng.Gaus(m_centralValue, m_sigma);
float shift =
rn / m_tUpper; // store relative variation: Delta_t / t
m_shiftValues[channelIdentifier] = shift;
}
}
}
}
}
/* initalization was successful */
m_mapIsInitialized = true;
/* write map to the default location */
ATH_CHECK(dumpMapAsFile());
return StatusCode::SUCCESS;
}
StatusCode MdtCalibrationTMaxShiftSvc::setTUpper(float tUpper) {
if (m_mapIsInitialized) {
ATH_MSG_FATAL("You cannot change m_tUpper once the map is initialized.");
return StatusCode::FAILURE;
}
m_tUpper = tUpper;
return StatusCode::SUCCESS;
}
#include "MdtCalibSvc/MdtCalibrationSvc.h"
#include "MdtCalibSvc/MdtCalibrationRegionSvc.h"
#include "MdtCalibSvc/MdtCalibrationDbSvc.h"
#include "MdtCalibSvc/MdtCalibrationT0ShiftSvc.h"
#include "MdtCalibSvc/MdtCalibrationTMaxShiftSvc.h"
DECLARE_COMPONENT( MdtCalibrationSvc )
DECLARE_COMPONENT( MdtCalibrationRegionSvc )
DECLARE_COMPONENT( MdtCalibrationDbSvc )
DECLARE_COMPONENT( MdtCalibrationT0ShiftSvc )
DECLARE_COMPONENT( MdtCalibrationTMaxShiftSvc )
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