Skip to content
Snippets Groups Projects
Commit 6535f75c authored by Christian Sander's avatar Christian Sander
Browse files

- Converted remaining sevives to tools:

  - SCT_CalibEvtInfo
  - SCT_CalibModuleListTool
  - SCT_CalibWriteTool

- code is compiling, but still has to be tested and validated

- Removed the old svc .cxx and .h files

- automatic re-indentation of the .cxx and .h files
parent 85ad0495
No related branches found
No related tags found
No related merge requests found
Showing
with 1211 additions and 1591 deletions
......@@ -14,6 +14,7 @@
#define ISCT_CalibEvtInfo_H
//Gaudi includes
#include "GaudiKernel/IAlgTool.h"
#include "GaudiKernel/IInterface.h"
#include <vector>
#include <string>
......@@ -23,7 +24,7 @@
* Interface to class to deal with run/event information for SCTCalib
**/
class ISCT_CalibEvtInfo: virtual public IInterface{
class ISCT_CalibEvtInfo: virtual public IAlgTool{
public:
/// no-op c/tor
ISCT_CalibEvtInfo(){}
......@@ -60,7 +61,6 @@ class ISCT_CalibEvtInfo: virtual public IInterface{
};
inline const InterfaceID & ISCT_CalibEvtInfo::interfaceID(){
static const InterfaceID IID("ISCT_CalibEvtInfo",1,0);
return IID;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file ISCT_CalibHistoSvc.h
* Header file to interface class for histograms in the SCT_CalibAlgs package
* @author Shaun Roe
**/
#ifndef ISCT_CalibHistoSvc_h
#define ISCT_CalibHistoSvc_h
//Gaudi includes
#include "GaudiKernel/IInterface.h"
#include "StoreGate/StoreGateSvc.h"
#include "GaudiKernel/ServiceHandle.h"
#include <vector>
#include <string>
#include <utility>
class TH1F;
class TH2F;
class TH1I;
class ITHistSvc;
class SCT_ID;
class ISCT_CalibHistoSvc: virtual public IInterface{
public:
ISCT_CalibHistoSvc();
/// no-op destructor
virtual ~ISCT_CalibHistoSvc(){}
/// interfaceID re-implemented from IInterface
static const InterfaceID & interfaceID();
/// book histograms
virtual bool book()=0;
/// read histograms
virtual bool read(const std::string & fileName)=0;
/// fill histograms from simulation
virtual bool fill(const bool fromData=false)=0;
/// fill histograms from data
virtual bool fillFromData()=0;
/// get number of events in a specific bin
virtual int getNumberOfEventsInBin(const int nbin);
/// get total number of entries in the number of events histo
int size();
/// get bin content for bin in specific histogram
double getBinForHistogramIndex(const int bin, const int histogramIndex);
/// get the number of entries in a given histogram
int size(const int histogramIndex);
void binHistograms(const int nLbMerged);
/// set number of lumiblocks
static void setNumberOfLb(const int nLb);
/// get number of lumiblocks
static int numberOfLb();
/// set number of lumiblocks
static void setLbToMerge(const int nLbMerge);
/// get number of lumiblocks
static int LbToMerge();
protected:
std::vector<TH1F *> m_phistoVector;
std::vector<TH2F *> m_phistoVector2D;
TH1I * m_numberOfEventsHisto;
ITHistSvc * m_thistSvc;
//need to implement retrieval for these
//ServiceHandle<StoreGateSvc> m_detStore;
//ServiceHandle<StoreGateSvc> m_evtStore;
const SCT_ID* m_pSCTHelper;
static int m_nLb;
static int m_nLbMerge;
//
bool init();
template<class S>
std::pair<std::string, bool> retrievedService(S & service){
if (service.retrieve().isFailure() ) return std::make_pair(std::string("Unable to retrieve ")+service.name(), false);
return std::make_pair("",true);
}
};
inline const InterfaceID & ISCT_CalibHistoSvc::interfaceID(){
static const InterfaceID IID("ISCT_CalibHistoSvc",1,0);
return IID;
}
#endif
......@@ -12,7 +12,7 @@
#define ISCT_CalibHistoTool_h
//Gaudi includes
//#include "GaudiKernel/IInterface.h"
#include "GaudiKernel/IInterface.h"
#include "GaudiKernel/IAlgTool.h"
#include "StoreGate/StoreGateSvc.h"
#include "GaudiKernel/ToolHandle.h"
......@@ -61,7 +61,7 @@ class ISCT_CalibHistoTool: virtual public IAlgTool {
std::vector<TH1F *> m_phistoVector;
std::vector<TH2F *> m_phistoVector2D;
TH1I * m_numberOfEventsHisto;
ITHistSvc * m_thisSvc;
ITHistSvc * m_thistSvc;
//need to implement retrieval for these
//ServiceHandle<StoreGateSvc> m_detStore;
//ServiceHandle<StoreGateSvc> m_evtStore;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file SCT_CalibModuleListSvc.h
* Header file for the SCT_CalibModuleListSvc class
* @author Shaun Roe
**/
#ifndef ISCT_CalibModuleListSvc_h
#define ISCT_CalibModuleListSvc_h
// STL and boost headers
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include "GaudiKernel/IInterface.h"
#include "GaudiKernel/ServiceHandle.h"
#include "Identifier/Identifier.h"
class ISCT_CalibModuleListSvc:virtual public IInterface{
public:
//@name Service methods, reimplemented
//@{
ISCT_CalibModuleListSvc(){/**nop**/};
virtual ~ISCT_CalibModuleListSvc(){/**nop**/};
virtual StatusCode initialize()=0;
virtual StatusCode finalize()=0;
static const InterfaceID & interfaceID();
//@}
virtual StatusCode readModuleList( std::map< Identifier, std::set<Identifier> >& moduleList )=0;
protected:
template<class S>
std::pair<std::string, bool> retrievedService(S & service){
if (service.retrieve().isFailure() ) return std::make_pair(std::string("Unable to retrieve ")+service.name(), false);
return std::make_pair("",true);
}
};
inline const InterfaceID & ISCT_CalibModuleListSvc::interfaceID(){
static const InterfaceID IID("ISCT_CalibModuleListSvc",1,0);
return IID;
}
#endif
......@@ -23,7 +23,7 @@
#include "GaudiKernel/ToolHandle.h"
#include "Identifier/Identifier.h"
class ISCT_CalibModuleListTool:virtual public IAlgTool {
class ISCT_CalibModuleListTool : virtual public IAlgTool {
public:
//@name Service methods, reimplemented
//@{
......
......@@ -19,11 +19,10 @@
#define SCTCalib_H
// Local
#include "SCT_CalibAlgs/ISCT_CalibHistoSvc.h"
#include "SCT_CalibAlgs/ISCT_CalibHistoTool.h"
#include "SCT_CalibAlgs/ISCT_CalibEvtInfo.h"
#include "SCT_CalibAlgs/ISCT_CalibModuleListSvc.h"
#include "SCT_CalibAlgs/SCTCalibWriteSvc.h" //template parameter
#include "SCT_CalibAlgs/ISCT_CalibModuleListTool.h"
#include "SCT_CalibAlgs/SCTCalibWriteTool.h" //template parameter
//Athena
#include "AthenaBaseComps/AthAlgorithm.h" //baseclass
......@@ -102,19 +101,16 @@ class SCTCalib : public AthAlgorithm {
SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"};
SG::ReadHandleKey<EventInfo> m_eventInfoKey;
ServiceHandle<SCTCalibWriteSvc> m_pCalibWriteSvc;
ToolHandle<SCTCalibWriteTool> m_pCalibWriteTool{this, "SCTCalibWriteTool", "SCTCalibWriteTool", "Tool to write out data from calibration loop"};
ToolHandle<ISCT_ConfigurationConditionsTool> m_ConfigurationConditionsTool{this, "SCT_ConfigurationConditionsTool", "SCT_ConfigurationConditionsTool/InDetSCT_ConfigurationConditionsTool", "Tool to retrieve SCT Configuration"};
ToolHandle<ISCT_ReadCalibDataTool> m_ReadCalibDataTool{this, "SCT_ReadCalibDataTool", "SCT_ReadCalibDataTool/InDetSCT_ReadCalibDataTool", "Tool to retrieve SCT calibration data"};
ToolHandle<ISCT_DetectorLevelConditionsTool> m_MajorityConditionsTool{this, "SCT_MajorityConditionsTool", "SCT_MajorityConditionsTool", "Tool to retrieve the majority conditions of SCT"};
ToolHandle<ISCT_CablingTool> m_CablingTool{this, "SCT_CablingTool", "SCT_CablingTool", "Tool to retrieve SCT Cabling"};
ToolHandle<ISCT_CalibHistoTool> m_calibHitmapTool;
//shaun added
//ServiceHandle<ISCT_CalibHistoSvc> m_calibHitmapSvc; //convert to Tool
ServiceHandle<ISCT_CalibHistoSvc> m_calibBsErrSvc;
ServiceHandle<ISCT_CalibHistoSvc> m_calibLbSvc;
ServiceHandle<ISCT_CalibModuleListSvc> m_calibModuleListSvc;
ServiceHandle<ISCT_CalibEvtInfo> m_calibEvtInfoSvc;
ToolHandle<ISCT_CalibHistoTool> m_calibHitmapTool{this, "SCT_CalibHitMapTool", "SCT_CalibHitMapTool", "Tool for reading and writing HitMap histograms"};
ToolHandle<ISCT_CalibHistoTool> m_calibLbTool{this, "SCT_CalibLbTool", "SCT_CalibLbTool", "Tool for reading and writing Lb dependent HitMap histograms"};
ToolHandle<ISCT_CalibHistoTool> m_calibBsErrTool{this, "SCT_CalibBsErrTool", "SCT_CalibBsErrTool", "Tool for reading and writing BS error histograms"};
ToolHandle<ISCT_CalibModuleListTool> m_calibModuleListTool{this, "SCT_CalibModuleListTool", "SCT_CalibModuleListTool", "Tool for handling list of modules"};
ToolHandle<ISCT_CalibEvtInfo> m_calibEvtInfoTool{this, "SCT_CalibEvtInfo", "SCT_CalibEvtInfo", "Tool for handling event info"};
// Book histograms
......@@ -219,7 +215,7 @@ class SCTCalib : public AthAlgorithm {
BooleanProperty m_doBSErrorDB;
BooleanProperty m_doLorentzAngle;
BooleanProperty m_writeToCool;
//reinstated 21 May, sroe
BooleanProperty m_noisyUpdate;
BooleanProperty m_noisyUploadTest;
FloatProperty m_noisyModuleAverageInDB; // Average number of modules with at least 1 noisy strip in COOL
......@@ -387,8 +383,7 @@ class SCTCalib : public AthAlgorithm {
const std::map< Identifier, std::set<Identifier> >& moduleListNew,
const std::map< Identifier, std::set<Identifier> >& moduleListRef,
const std::string& badStripsFile) const;
/* StatusCode */
/* noisyStripsToSummaryXmlFake( const std::string& badStripsFile) const; */
std::set<int>
getNoisyChips( const std::set<Identifier>& stripIdList ) const;
//
......
/** -*- c++ -*- */
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/*
* @file SCTCalibWriteSvc.h
*
* @brief Header file for the SCTCalibWriteSvc class
*
* @author Jose E. Garcia
**/
#ifndef SCTCalibWriteSvc_H
#define SCTCalibWriteSvc_H
//STL
#include <string>
#include <map>
#include <set>
#include <list>
// Gaudi includes
#include "AthenaBaseComps/AthService.h"
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/StatusCode.h"
#include "GaudiKernel/ClassID.h"
#include "StoreGate/StoreGate.h"
#include "StoreGate/ReadHandleKey.h"
#include "CoralBase/AttributeListSpecification.h"
#include "AthenaPoolUtilities/AthenaAttributeList.h"
// Athena includes
#include "Identifier/Identifier.h"
// local includes
#include "InDetConditionsSummaryService/InDetHierarchy.h"
//forward declarations
class ISvcLocator;
class IdentifierHash;
class SCT_ID;
class EventInfo;
class IIOVRegistrationSvc;
class IAthenaOutputStreamTool;
class CondAttrListCollection;
class StoreGateSvc;
/**
** Algorithm to test writing conditions data and reading them back.
**/
class SCTCalibWriteSvc: public AthService {
friend class SvcFactory<SCTCalibWriteSvc>;
public:
// Constructor
SCTCalibWriteSvc(const std::string &name, ISvcLocator *pSvcLocator) ;
// Destructor
~SCTCalibWriteSvc();
// overloading functions
virtual StatusCode initialize();
virtual StatusCode finalize();
static const InterfaceID& interfaceID() {
static const InterfaceID IID_SCTCalibWriteSvc("SCTCalibWriteSvc", 1, 0);
return IID_SCTCalibWriteSvc;
}
virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIF);
///Manually get the data in the structure before proceding
virtual StatusCode fillData();
//I'm going to fill this from job options, so the callback version of fillData is not needed.
virtual StatusCode fillData(int& /*i */, std::list<std::string>& /*l*/) { //comment out unused parameters to prevent compiler warning
return StatusCode::FAILURE;
}
std::string
addDefect(const std::string& defectlist,const int defectBeginChannel,const int defectEndChannel) const;
std::string
addNumber(const std::string numStr,const unsigned long long number) const;
std::string
createDefectString(const int defectBeginChannel,const int defectEndChannel) const;
StatusCode
createCondObjects( const Identifier& wafer_id,const SCT_ID* m_sctId,const int samplesize,const std::string& defectType,const float threshold,const std::string& defectList ) const;
StatusCode createListStrip( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const std::string& defectType,
const float threshold,
const std::string& defectList ) const;
StatusCode createListChip( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const std::string& defectType,
const float threshold,
const std::string& defectList ) const;
StatusCode createListEff( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const float eff ) const;
StatusCode createListNO( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const float noise_occ ) const;
StatusCode createListRawOccu( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const float raw_occu ) const;
StatusCode createListBSErr(const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const std::string & errorList,
const std::string & probList) const ;
//StatusCode createListBSErr( const Identifier& wafer_id,
// const unsigned long long n_events,
// const std::string& BSErrorType,
// const std::string& Ratio ) const;
// StatusCode createListLA(const Identifier& wafer_id,const SCT_ID* m_sctId,const int samplesize, const int module, const float lorentz, const float MCW ) const;
StatusCode createListLA(const Identifier& wafer_id,const SCT_ID* m_sctId,const int samplesize, const int module, const float lorentz, const float err_lorentz, const float chisq, const float fitParam_a, const float err_a, const float fitParam_b, const float err_b, const float fitParam_sigma, const float err_sigma, const float MCW, const float err_MCW ) const;
/* StatusCode createListLA( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const float lorentz,
const float MCW ) const;
*/
StatusCode wrapUpNoisyChannel();
StatusCode wrapUpDeadStrips();
StatusCode wrapUpDeadChips();
StatusCode wrapUpEfficiency();
StatusCode wrapUpNoiseOccupancy();
StatusCode wrapUpRawOccupancy();
StatusCode wrapUpBSErrors();
StatusCode wrapUpLorentzAngle();
private:
StoreGateSvc* m_detStore;
SG::ReadHandleKey<EventInfo> m_eventInfoKey;
StatusCode registerIOV(const CLID& clid);
int stringToInt(const std::string& s) const;
StatusCode streamOutCondObjects(const std::string & foldername);
StatusCode streamOutCondObjectsWithErrMsg(const std::string & foldername);
StatusCode registerCondObjects(const std::string & foldername,const std::string & tagname);
StatusCode recordAndStream(const CondAttrListCollection* pCollection,const std::string & foldername, bool & flag);
StatusCode registerCondObjectsWithErrMsg(const std::string& foldername,const std::string& tagname);
//
coral::AttributeListSpecification* createBasicDbSpec(const bool capsFormat) const;
void setBasicValues(coral::AttributeList & attrList, const Identifier& wafer_id, const int samplesize,const SCT_ID* m_sctId, const bool capsFormat) const;
// small helper function
unsigned int computeIstrip4moncond(const Identifier& elementId) const;
const CondAttrListCollection* getAttrListCollectionByFolder(const std::string&) const;
// would it make sense to change the strings to properties?
// that would be a fairly simple fix
static std::string s_separator;
static std::string s_defectFolderName;
static std::string s_deadStripFolderName;
static std::string s_deadChipFolderName;
static std::string s_effFolderName;
static std::string s_noFolderName;
static std::string s_RawOccuFolderName;
static std::string s_BSErrFolderName;
static std::string s_LAFolderName;
// cache for the Collections, access by foldername
mutable std::map<const std::string, const CondAttrListCollection*> m_attrListCollectionMap;
CondAttrListCollection* m_attrListColl;
CondAttrListCollection* m_attrListColl_deadStrip;
CondAttrListCollection* m_attrListColl_deadChip;
CondAttrListCollection* m_attrListColl_eff;
CondAttrListCollection* m_attrListColl_no;
CondAttrListCollection* m_attrListColl_RawOccu;
CondAttrListCollection* m_attrListColl_BSErr;
CondAttrListCollection* m_attrListColl_LA;
BooleanProperty m_writeCondObjs;
BooleanProperty m_regIOV;
BooleanProperty m_readWriteCool;
BooleanProperty m_twoStepWriteReg;
BooleanProperty m_manualiov;
/*IntegerProperty m_regTime;*/
IntegerProperty m_version;
/*IntegerProperty m_nhits_noisychip;*/
/*IntegerProperty m_nhits_noisywafer;*/
/*IntegerProperty m_nhits_noisymodule;*/
IntegerProperty m_beginRun;
IntegerProperty m_endRun;
StringProperty m_streamName;
std::string m_tagID4NoisyStrips;
std::string m_tagID4DeadStrips;
std::string m_tagID4DeadChips;
std::string m_tagID4Efficiency;
std::string m_tagID4NoiseOccupancy;
std::string m_tagID4RawOccupancy;
std::string m_tagID4BSErrors;
std::string m_tagID4LorentzAngle;
IIOVRegistrationSvc* m_regSvc;
//IAthenaOutputStreamTool* m_streamer;
ToolHandle<IAthenaOutputStreamTool> m_streamer;
//StringArrayProperty m_badElements; unused list of bad detector elements (= module sides)
std::set<Identifier> m_badIds;
bool m_defectRecorded;
bool m_deadStripRecorded;
bool m_deadChipRecorded;
bool m_effRecorded;
bool m_noRecorded;
bool m_RawOccuRecorded;
bool m_BSErrRecorded;
bool m_LARecorded;
const SCT_ID* m_pHelper;
// FIXME: this caches only the last call of getList.
// creating a hash of _all_ calls may be faster, but wastes a lot of memory
mutable std::string m_currentDefectList;
};
#endif // SCTCalibWriteSvc.h
/** -*- c++ -*- */
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/*
* @file SCTCalibWriteTool.h
*
* @brief Header file for the SCTCalibWriteTool class
*
* @author Jose E. Garcia
**/
#ifndef SCTCalibWriteTool_H
#define SCTCalibWriteTool_H
//STL
#include <string>
#include <map>
#include <set>
#include <list>
// Gaudi includes
#include "GaudiKernel/IInterface.h"
#include "GaudiKernel/IAlgTool.h"
//#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/StatusCode.h"
#include "GaudiKernel/ClassID.h"
#include "StoreGate/StoreGate.h"
#include "StoreGate/ReadHandleKey.h"
#include "CoralBase/AttributeListSpecification.h"
#include "AthenaPoolUtilities/AthenaAttributeList.h"
#include "AthenaBaseComps/AthAlgTool.h"
// Athena includes
#include "Identifier/Identifier.h"
// local includes
#include "InDetConditionsSummaryService/InDetHierarchy.h"
//forward declarations
class IdentifierHash;
class SCT_ID;
class EventInfo;
class IIOVRegistrationSvc;
class IAthenaOutputStreamTool;
class CondAttrListCollection;
class StoreGateSvc;
/**
** Algorithm to test writing conditions data and reading them back.
**/
class SCTCalibWriteTool : public AthAlgTool {
public:
// Constructor
SCTCalibWriteTool(const std::string& type, const std::string& name, const IInterface* parent);
// Destructor
~SCTCalibWriteTool() {};
// overloading functions
virtual StatusCode initialize();
virtual StatusCode finalize();
static const InterfaceID & interfaceID();
virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIF);
///Manually get the data in the structure before proceding
virtual StatusCode fillData();
//I'm going to fill this from job options, so the callback version of fillData is not needed.
virtual StatusCode fillData(int& /*i */, std::list<std::string>& /*l*/) { //comment out unused parameters to prevent compiler warning
return StatusCode::FAILURE;
}
std::string
addDefect(const std::string& defectlist,const int defectBeginChannel,const int defectEndChannel) const;
std::string
addNumber(const std::string numStr,const unsigned long long number) const;
std::string
createDefectString(const int defectBeginChannel,const int defectEndChannel) const;
StatusCode
createCondObjects( const Identifier& wafer_id,const SCT_ID* m_sctId,const int samplesize,const std::string& defectType,const float threshold,const std::string& defectList ) const;
StatusCode createListStrip( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const std::string& defectType,
const float threshold,
const std::string& defectList ) const;
StatusCode createListChip( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const std::string& defectType,
const float threshold,
const std::string& defectList ) const;
StatusCode createListEff( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const float eff ) const;
StatusCode createListNO( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const float noise_occ ) const;
StatusCode createListRawOccu( const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const float raw_occu ) const;
StatusCode createListBSErr(const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const std::string & errorList,
const std::string & probList) const ;
StatusCode createListLA(const Identifier& wafer_id,
const SCT_ID* m_sctId,
const int samplesize,
const int module,
const float lorentz,
const float err_lorentz,
const float chisq,
const float fitParam_a,
const float err_a,
const float fitParam_b,
const float err_b,
const float fitParam_sigma,
const float err_sigma,
const float MCW,
const float err_MCW ) const;
StatusCode wrapUpNoisyChannel();
StatusCode wrapUpDeadStrips();
StatusCode wrapUpDeadChips();
StatusCode wrapUpEfficiency();
StatusCode wrapUpNoiseOccupancy();
StatusCode wrapUpRawOccupancy();
StatusCode wrapUpBSErrors();
StatusCode wrapUpLorentzAngle();
private:
StoreGateSvc* m_detStore;
SG::ReadHandleKey<EventInfo> m_eventInfoKey;
StatusCode registerIOV(const CLID& clid);
int stringToInt(const std::string& s) const;
StatusCode streamOutCondObjects(const std::string & foldername);
StatusCode streamOutCondObjectsWithErrMsg(const std::string & foldername);
StatusCode registerCondObjects(const std::string & foldername,const std::string & tagname);
StatusCode recordAndStream(const CondAttrListCollection* pCollection,const std::string & foldername, bool & flag);
StatusCode registerCondObjectsWithErrMsg(const std::string& foldername,const std::string& tagname);
coral::AttributeListSpecification* createBasicDbSpec(const bool capsFormat) const;
void setBasicValues(coral::AttributeList & attrList, const Identifier& wafer_id, const int samplesize,const SCT_ID* m_sctId, const bool capsFormat) const;
// small helper function
unsigned int computeIstrip4moncond(const Identifier& elementId) const;
const CondAttrListCollection* getAttrListCollectionByFolder(const std::string&) const;
// would it make sense to change the strings to properties?
// that would be a fairly simple fix
static std::string s_separator;
static std::string s_defectFolderName;
static std::string s_deadStripFolderName;
static std::string s_deadChipFolderName;
static std::string s_effFolderName;
static std::string s_noFolderName;
static std::string s_RawOccuFolderName;
static std::string s_BSErrFolderName;
static std::string s_LAFolderName;
// cache for the Collections, access by foldername
mutable std::map<const std::string, const CondAttrListCollection*> m_attrListCollectionMap;
CondAttrListCollection* m_attrListColl;
CondAttrListCollection* m_attrListColl_deadStrip;
CondAttrListCollection* m_attrListColl_deadChip;
CondAttrListCollection* m_attrListColl_eff;
CondAttrListCollection* m_attrListColl_no;
CondAttrListCollection* m_attrListColl_RawOccu;
CondAttrListCollection* m_attrListColl_BSErr;
CondAttrListCollection* m_attrListColl_LA;
BooleanProperty m_writeCondObjs;
BooleanProperty m_regIOV;
BooleanProperty m_readWriteCool;
BooleanProperty m_twoStepWriteReg;
BooleanProperty m_manualiov;
/*IntegerProperty m_regTime;*/
IntegerProperty m_version;
/*IntegerProperty m_nhits_noisychip;*/
/*IntegerProperty m_nhits_noisywafer;*/
/*IntegerProperty m_nhits_noisymodule;*/
IntegerProperty m_beginRun;
IntegerProperty m_endRun;
StringProperty m_streamName;
std::string m_tagID4NoisyStrips;
std::string m_tagID4DeadStrips;
std::string m_tagID4DeadChips;
std::string m_tagID4Efficiency;
std::string m_tagID4NoiseOccupancy;
std::string m_tagID4RawOccupancy;
std::string m_tagID4BSErrors;
std::string m_tagID4LorentzAngle;
IIOVRegistrationSvc* m_regSvc;
IAthenaOutputStreamTool* m_streamer;
//ToolHandle<IAthenaOutputStreamTool> m_streamer;
//StringArrayProperty m_badElements; unused list of bad detector elements (= module sides)
std::set<Identifier> m_badIds;
bool m_defectRecorded;
bool m_deadStripRecorded;
bool m_deadChipRecorded;
bool m_effRecorded;
bool m_noRecorded;
bool m_RawOccuRecorded;
bool m_BSErrRecorded;
bool m_LARecorded;
const SCT_ID* m_pHelper;
// FIXME: this caches only the last call of getList.
// creating a hash of _all_ calls may be faster, but wastes a lot of memory
mutable std::string m_currentDefectList;
};
inline const InterfaceID & SCTCalibWriteTool::interfaceID() {
static const InterfaceID IID("SCTCalibWriteTool",1,0);
return IID;
}
#endif // SCTCalibWriteTool.h
......@@ -7,21 +7,19 @@
#include "TMath.h"
Double_t
LA_func(Double_t *x, Double_t *par){
const Int_t n = 1000; // number of integration step
const Double_t xmin = x[0] - 5.0*par[3];
const Double_t xmax = x[0] + 5.0*par[3];
const Double_t h = (xmax - xmin)/(n - 1);
const Double_t pi = 3.14159265;
Double_t sum = 0;
Double_t x_ = xmin;
Double_t LA_sum = 0;
for (Int_t i=1; i<n; i++) {
LA_sum= par[0]*TMath::Abs(TMath::Tan(x_*pi/180)-TMath::Tan(par[1]*pi/180))+par[2];
sum += LA_sum * 0.017455/TMath::Sqrt(2*pi)/(par[3]*pi/180)*TMath::Exp(-(x[0]*pi/180 - x_*pi/180 )*(x[0]*pi/180 - x_*pi/180 )/(2*par[3]*pi/180*par[3]*pi/180))*h;
x_ += h;
}
return sum;
LA_func(Double_t *x, Double_t *par) {
const Int_t n = 1000; // number of integration step
const Double_t xmin = x[0] - 5.0*par[3];
const Double_t xmax = x[0] + 5.0*par[3];
const Double_t h = (xmax - xmin)/(n - 1);
const Double_t pi = 3.14159265;
Double_t sum = 0;
Double_t x_ = xmin;
Double_t LA_sum = 0;
for (Int_t i=1; i<n; i++) {
LA_sum= par[0]*TMath::Abs(TMath::Tan(x_*pi/180)-TMath::Tan(par[1]*pi/180))+par[2];
sum += LA_sum * 0.017455/TMath::Sqrt(2*pi)/(par[3]*pi/180)*TMath::Exp(-(x[0]*pi/180 - x_*pi/180 )*(x[0]*pi/180 - x_*pi/180 )/(2*par[3]*pi/180*par[3]*pi/180))*h;
x_ += h;
}
return sum;
}
......@@ -8,39 +8,38 @@
*/
#include "IElementStreamer.h"
namespace SCT_CalibAlgs {
unsigned int IElementStreamer::m_depth=0;
unsigned int IElementStreamer::m_nodeIndex=0;
namespace SCT_CalibAlgs{
unsigned int IElementStreamer::m_depth=0;
unsigned int IElementStreamer::m_nodeIndex=0;
IElementStreamer::IElementStreamer(const std::string & name, const std::map<std::string, std::string> & attributeMap, std::ostream & os):
m_name(name), m_os(os),m_nodeId(m_nodeIndex){
std::map<std::string, std::string>::const_iterator i(attributeMap.begin());
std::map<std::string, std::string>::const_iterator end(attributeMap.end());
for(;i!=end;++i){
m_attributeNames.push_back(i->first);
m_attributeValues.push_back(i->second);
}
++m_depth;
++m_nodeIndex;
m_name(name), m_os(os),m_nodeId(m_nodeIndex) {
std::map<std::string, std::string>::const_iterator i(attributeMap.begin());
std::map<std::string, std::string>::const_iterator end(attributeMap.end());
for(; i!=end; ++i) {
m_attributeNames.push_back(i->first);
m_attributeValues.push_back(i->second);
}
++m_depth;
++m_nodeIndex;
}
IElementStreamer::IElementStreamer(const std::string & name, const std::vector<std::string> & attributeNames, const std::vector<std::string> & attributeValues, std::ostream & os):
m_name(name), m_attributeNames(attributeNames), m_attributeValues(attributeValues),m_os(os),m_nodeId(m_nodeIndex){
++m_depth;
++m_nodeIndex;
m_name(name), m_attributeNames(attributeNames), m_attributeValues(attributeValues),m_os(os),m_nodeId(m_nodeIndex) {
++m_depth;
++m_nodeIndex;
}
IElementStreamer::IElementStreamer(const std::string & name, const std::string & attributeName, const std::string & attributeValue, std::ostream & os):m_name(name),m_os(os), m_nodeId(m_nodeIndex){
m_attributeNames.push_back(attributeName);
m_attributeValues.push_back(attributeValue);
++m_depth;
++m_nodeIndex;
}
IElementStreamer::~IElementStreamer(){
--m_depth;
IElementStreamer::IElementStreamer(const std::string & name, const std::string & attributeName, const std::string & attributeValue, std::ostream & os):m_name(name),m_os(os), m_nodeId(m_nodeIndex) {
m_attributeNames.push_back(attributeName);
m_attributeValues.push_back(attributeValue);
++m_depth;
++m_nodeIndex;
}
}
IElementStreamer::~IElementStreamer() {
--m_depth;
}
}
......@@ -12,28 +12,29 @@
#include <string>
#include <map>
#include <vector>
namespace SCT_CalibAlgs{
class IElementStreamer{
protected:
std::string m_name;
std::vector<std::string> m_attributeNames;
std::vector<std::string> m_attributeValues;
std::ostream & m_os;
static unsigned int m_depth;
static unsigned int m_nodeIndex;
unsigned int m_nodeId;
public:
IElementStreamer(const std::string & name, const std::map<std::string, std::string> & attributeMap, std::ostream & os=std::cout);
IElementStreamer(const std::string & name, const std::string & attributeName, const std::string & attributeValue, std::ostream & os=std::cout);
IElementStreamer(const std::string & name, const std::vector<std::string> & attributeNames, const std::vector<std::string> & attributeValues, std::ostream & os=std::cout);
~IElementStreamer();
template<class T>
void value(const T & v){
m_os<<v;
}
namespace SCT_CalibAlgs {
class IElementStreamer {
protected:
std::string m_name;
std::vector<std::string> m_attributeNames;
std::vector<std::string> m_attributeValues;
std::ostream & m_os;
static unsigned int m_depth;
static unsigned int m_nodeIndex;
unsigned int m_nodeId;
public:
IElementStreamer(const std::string & name, const std::map<std::string, std::string> & attributeMap, std::ostream & os=std::cout);
IElementStreamer(const std::string & name, const std::string & attributeName, const std::string & attributeValue, std::ostream & os=std::cout);
IElementStreamer(const std::string & name, const std::vector<std::string> & attributeNames, const std::vector<std::string> & attributeValues, std::ostream & os=std::cout);
~IElementStreamer();
template<class T>
void value(const T & v) {
m_os<<v;
}
};
}
#endif
......@@ -18,7 +18,7 @@
int ISCT_CalibHistoTool::m_nLb=0;
int ISCT_CalibHistoTool::m_nLbMerge=0;
ISCT_CalibHistoTool::ISCT_CalibHistoTool():m_numberOfEventsHisto(0),m_thisSvc(0),m_pSCTHelper(0) {
ISCT_CalibHistoTool::ISCT_CalibHistoTool():m_numberOfEventsHisto(0),m_thistSvc(0),m_pSCTHelper(0) {
//std::cout<<"Instantiation of ISCT_CalibHistoTool"<<std::endl;
//nop
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file SCT_CalibBsErrorSvc.cxx
* Implementation file for the SCT_CalibBsErrorSvc class
* @author Shaun Roe
**/
#include "SCT_CalibBsErrorSvc.h"
#include "SCT_CalibUtilities.h"
#include "SCT_CalibNumbers.h"
//Inner detector includes
#include <set>
#include "Identifier/Identifier.h"
#include "Identifier/IdentifierHash.h"
#include "GaudiKernel/ITHistSvc.h"
#include "TH1I.h"
// RAW data access
#include "InDetRawData/InDetRawDataCLASS_DEF.h"
#include "InDetRawData/SCT3_RawData.h"
using namespace std;
using namespace SCT_CalibAlgs;
const static string pathRoot("/BSErrors/");
const static string detectorPaths[]={"SCTEC/", "SCTB/","SCTEA/"};
const static string detectorNames[] = { "negativeEndcap", "barrel", "positiveEndcap" };
const static int n_BSErrorType = 15;
const static int firstBSErrorType = 0;
const static int lastBSErrorType = 14;
static int MAXHASH(0);
SCT_CalibBsErrorSvc::SCT_CalibBsErrorSvc(const std::string &name, ISvcLocator * svc):
AthService(name,svc),
m_detStore("DetectorStore", name),
m_evtStore("StoreGateSvc", name),
m_pSCTHelper(0),
m_scterr_bec(0),
m_scterr_layer(0),
m_scterr_eta(0),
m_scterr_phi(0),
m_scterr_side(0),
m_scterr_rodid(0),
m_scterr_channel(0),
m_scterr_type(0)
{
}
StatusCode
SCT_CalibBsErrorSvc::initialize(){
if ( service( "THistSvc", m_thistSvc ).isFailure() ) return msg( MSG::ERROR) << "Unable to retrieve pointer to THistSvc" << endmsg, StatusCode::FAILURE;
if ( m_detStore->retrieve( m_pSCTHelper, "SCT_ID").isFailure()) return msg( MSG::ERROR) << "Unable to retrieve SCTHelper" << endmsg, StatusCode::FAILURE;
if ( m_bytestreamErrorsTool.retrieve().isFailure()) return msg( MSG::ERROR) << "Unable to retrieve BS Error Tool" << endmsg, StatusCode::FAILURE;
//
MAXHASH=m_pSCTHelper->wafer_hash_max();
m_waferItrBegin = m_pSCTHelper->wafer_begin();
m_waferItrEnd = m_pSCTHelper->wafer_end();
return StatusCode::SUCCESS;
}
StatusCode
SCT_CalibBsErrorSvc::finalize(){
msg( MSG::INFO)<<"Finalize of SCT_CalibBsErrorSvc"<<endmsg;
return StatusCode::SUCCESS;
}
StatusCode
SCT_CalibBsErrorSvc::queryInterface(const InterfaceID & riid, void** ppvInterface ){
if ( ISCT_CalibHistoSvc::interfaceID().versionMatch(riid) ) {
*ppvInterface = dynamic_cast<ISCT_CalibHistoSvc*>(this);
} else {
return AthService::queryInterface(riid, ppvInterface);
}
addRef();
return StatusCode::SUCCESS;
}
bool
SCT_CalibBsErrorSvc::book(){
bool result(true);
m_phistoVector.clear();
string histoName=pathRoot+"GENERAL/";
//histogram for numbers of events
m_numberOfEventsHisto=new TH1I("events","Events",1,0.5,1.5);
if( m_thistSvc->regHist( histoName.c_str(), m_numberOfEventsHisto ).isFailure() ) {
msg( MSG::ERROR ) << "Error in booking BSErrors histogram" << endmsg;
}
//--- BSErrors for each wafer
SCT_ID::const_id_iterator waferItr = m_waferItrBegin;
SCT_ID::const_id_iterator waferItrE = m_waferItrEnd;
for( ; waferItr not_eq waferItrE; ++waferItr ) {
Identifier waferId = *waferItr;
const int bec( m_pSCTHelper->barrel_ec( waferId ) );
const string formattedPosition( formatPosition(waferId, m_pSCTHelper));
std::string histotitle = string( "SCT " ) + detectorNames[ bec2Index(bec) ] + string( " BSErrors : plane " ) + formattedPosition;
const std::string name=pathRoot+detectorPaths[bec2Index(m_pSCTHelper->barrel_ec( waferId ))] + formattedPosition;
TH1F* hitmapHisto_tmp = new TH1F( TString( formattedPosition ), TString( histotitle ), n_BSErrorType, firstBSErrorType-0.5, lastBSErrorType+0.5 );
if( m_thistSvc->regHist( name.c_str(), hitmapHisto_tmp ).isFailure() ) msg( MSG::ERROR ) << "Error in booking BSErrors histogram" << endmsg;
m_phistoVector.push_back( hitmapHisto_tmp );
}
return result;
}
bool
SCT_CalibBsErrorSvc::read(const std::string & fileName){
msg( MSG::ERROR ) << "Reding BsError histograms from " << fileName.c_str() << " is not supported!" << endmsg;
return false;
}
bool
SCT_CalibBsErrorSvc::fill(const bool fromData){
if (fromData){
return fillFromData();
}
bool result(true);
//--- Number of event
m_numberOfEventsHisto->Fill( 1 );
//--- Fill BSErrors
const int maxEntry = m_scterr_type->size();
for( int i = 0; i != maxEntry; ++i ) {
int bec = (*m_scterr_bec)[i];
int layer = (*m_scterr_layer)[i];
int phi = (*m_scterr_phi)[i];
int eta = (*m_scterr_eta)[i];
int side = (*m_scterr_side)[i];
int type = (*m_scterr_type)[i];
Identifier waferId = m_pSCTHelper->wafer_id( bec, layer, phi, eta, side );
fillBsErrorsForWafer(waferId, type);
}
return result;
}
bool
SCT_CalibBsErrorSvc::fillFromData(){
bool result(true);
//--- Number of event
m_numberOfEventsHisto->Fill( 1 );
//--- Loop over BSErrors
for ( int type = 0; type < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++type ) {
const std::set<IdentifierHash>* errorSet = m_bytestreamErrorsTool->getErrorSet( type );
if ( errorSet != 0 ) {
std::set<IdentifierHash>::const_iterator it = errorSet->begin();
std::set<IdentifierHash>::const_iterator itE = errorSet->end();
for ( ; it != itE; ++it ) {
Identifier waferId = m_pSCTHelper->wafer_id( *it );
fillBsErrorsForWafer(waferId, type);
}
}
}
return result;
}
void
SCT_CalibBsErrorSvc::fillBsErrorsForWafer(const Identifier & waferId, const int type){
int iWaferHash = (int) m_pSCTHelper->wafer_hash( waferId );
const string osWafer=formatPosition(waferId, m_pSCTHelper,".");
//--- Protection for wrong waferID
if ( iWaferHash < 0 || iWaferHash >= MAXHASH ) {
msg( MSG::WARNING ) << "WaferHash " << iWaferHash << " is out of range : [ bec.layer.eta.phi.side, BSErrorType ] = [ " << osWafer << ", " << type << " ]" << endmsg;
} else {
if (msgLvl(MSG::DEBUG)) msg( MSG::DEBUG ) << "BSError : [ bec.layer.eta.phi.side, Type ] = [ " << osWafer<< ", " << type << " ]"<< endmsg;
m_phistoVector[ iWaferHash ]->Fill( type );
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file SCT_CalibBsErrorSvc.h
* Header file for the SCT_CalibBsErrorSvc class
* @author Shaun Roe
**/
#ifndef SCT_CalibBsErrorSvc_h
#define SCT_CalibBsErrorSvc_h
//STL includes
#include <string>
//Athena includes
#include "AthenaBaseComps/AthService.h"
#include "StoreGate/StoreGateSvc.h"
#include "GaudiKernel/ServiceHandle.h"
#include "InDetIdentifier/SCT_ID.h"
#include "SCT_ConditionsTools/ISCT_ByteStreamErrorsTool.h"
//local includes
#include "SCT_CalibAlgs/ISCT_CalibHistoSvc.h"
//fwd declarations
template <class TYPE> class SvcFactory;
class StatusCode;
class ISvcLocator;
class SCT_CalibBsErrorSvc:virtual public ISCT_CalibHistoSvc, public AthService{
friend class SvcFactory<SCT_CalibBsErrorSvc>;
public:
//@name Service methods, reimplemented
//@{
SCT_CalibBsErrorSvc(const std::string &name, ISvcLocator * svc);
virtual ~SCT_CalibBsErrorSvc(){}
virtual StatusCode initialize();
virtual StatusCode finalize();
//interfaceID() implementation is in the baseclass
virtual StatusCode queryInterface(const InterfaceID & riid, void** ppvInterface );
//@}
//@name ISCT_CalibHistoSvc methods, reimplemented
//@{
virtual bool book();
virtual bool read(const std::string & fileName);
virtual bool fill(const bool fromData=false);
virtual bool fillFromData();
//@}
private:
ServiceHandle<StoreGateSvc> m_detStore;
ServiceHandle<StoreGateSvc> m_evtStore;
ToolHandle<ISCT_ByteStreamErrorsTool> m_bytestreamErrorsTool{this, "SCT_ByteStreamErrorsTool", "SCT_ByteStreamErrorsTool", "Tool to retrieve SCT ByteStream Errors"};
const SCT_ID* m_pSCTHelper;
// SCT specific numbers
SCT_ID::const_id_iterator m_waferItrBegin;
SCT_ID::const_id_iterator m_waferItrEnd;
typedef std::vector<int> VecInt;
VecInt *m_scterr_bec;
VecInt *m_scterr_layer;
VecInt *m_scterr_eta;
VecInt *m_scterr_phi;
VecInt *m_scterr_side;
VecInt *m_scterr_rodid;
VecInt *m_scterr_channel;
VecInt *m_scterr_type;
//
void
fillBsErrorsForWafer(const Identifier & waferId, const int type);
};
#endif
......@@ -37,7 +37,7 @@ class SCT_CalibBsErrorTool : public extends<AthAlgTool, ISCT_CalibHistoTool>
public:
//@name Tool methods, reimplemented
//@{
SCT_CalibBsErrorTool(const std::string& type, const std::string& name, const IInterface* parent);
SCT_CalibBsErrorTool(const std::string&, const std::string&, const IInterface*);
virtual ~SCT_CalibBsErrorTool() {};
virtual StatusCode initialize();
virtual StatusCode finalize();
......
......@@ -7,14 +7,15 @@
* Implementation file for the SCT_CalibEventInfo class
* @author Shaun Roe
**/
#include <limits>
//STL, boost
#include "SCT_CalibEventInfo.h"
#include "SCT_CalibUtilities.h"
#include "EventInfo/EventInfo.h"
#include "EventInfo/EventInfo.h"
#include "EventInfo/EventID.h"
//coral/cool
#include "CoralBase/TimeStamp.h"
namespace {
......@@ -23,7 +24,8 @@ const int INTMAX(std::numeric_limits<int>::max());
const long long oneBillion(1000000000LL);
}
SCT_CalibEventInfo::SCT_CalibEventInfo(const std::string &name, ISvcLocator * svc):AthService(name,svc),
SCT_CalibEventInfo::SCT_CalibEventInfo(const std::string& type, const std::string& name, const IInterface* parent) :
base_class(type, name, parent),
m_timeStampBegin(INTMAX),
m_tsBeginString(""),
m_tsEndString(""),
......@@ -59,7 +61,7 @@ SCT_CalibEventInfo::queryInterface(const InterfaceID & riid, void** ppvInterface
if ( ISCT_CalibEvtInfo::interfaceID().versionMatch(riid) ) {
*ppvInterface = dynamic_cast<ISCT_CalibEvtInfo*>(this);
} else {
return AthService::queryInterface(riid, ppvInterface);
return AthAlgTool::queryInterface(riid, ppvInterface);
}
addRef();
return StatusCode::SUCCESS;
......@@ -106,18 +108,22 @@ SCT_CalibEventInfo::setLumiBlock(const int begin, const int end) {
m_LBEnd=end;
m_numLB=end-begin+1;
}
void
SCT_CalibEventInfo::setLumiBlock(const int lb) {
m_lumiBlock=lb;
}
void
SCT_CalibEventInfo::setSource(const std::string source) {
m_source=source;
}
void
SCT_CalibEventInfo::setRunNumber(const int rn) {
m_runNumber=rn;
m_runNumber=rn;
}
void
SCT_CalibEventInfo::setBunchCrossing(const int bc) {
m_bunchCrossing=bc;
......
......@@ -10,8 +10,10 @@
#ifndef SCT_CalibEventInfo_h
#define SCT_CalibEventInfo_h
#include "AthenaBaseComps/AthService.h" //baseclass
#include "GaudiKernel/ServiceHandle.h" //member
//#include "AthenaBaseComps/AthService.h" //baseclass
//#include "GaudiKernel/ServiceHandle.h" //member
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h" //member
#include "SCT_CalibAlgs/ISCT_CalibEvtInfo.h"
#include <string>
......@@ -20,12 +22,12 @@ class StatusCode;
class ISvcLocator;
class InterfaceID;
class SCT_CalibEventInfo: virtual public ISCT_CalibEvtInfo, public AthService {
friend class SvcFactory<SCT_CalibEventInfo>;
class SCT_CalibEventInfo: public extends<AthAlgTool, ISCT_CalibEvtInfo>
{
public:
//@name Service methods, reimplemented
//@{
SCT_CalibEventInfo(const std::string &name, ISvcLocator * svc);
SCT_CalibEventInfo(const std::string&, const std::string&, const IInterface*);
virtual ~SCT_CalibEventInfo() {}
virtual StatusCode initialize();
virtual StatusCode finalize();
......
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