From ea48df40c2d372305dbd644759d3ee3d6dd85b7c Mon Sep 17 00:00:00 2001 From: Walter Lampl <Walter.Lampl@cern.ch> Date: Mon, 7 Jul 2014 11:36:14 +0200 Subject: [PATCH] several changes related to absence of MphysOverMcal for FCAL (LArCalibTools-00-09-34) --- .../LArCalibTools/CaloCellGroup2Ntuple.h | 28 + .../LArCalibTools/CaloCondBlob2Ntuple.h | 24 + .../LArCalibTools/ForceLoadCondObj.h | 39 + .../LArAccumulatedDigits2Ntuple.h | 78 ++ .../LArCalibTools/LArAutoCorr2Ntuple.h | 41 + .../LArCalibTools/LArAverages2Ntuple.h | 82 ++ .../LArCalibTools/LArBlockCorrections.h | 14 + .../LArCalibTools/LArCaliWaves2Ntuple.h | 65 ++ .../LArCalibTools/LArCompleteToFlat.h | 87 ++ .../LArCalibTools/LArCond2NtupleBase.h | 78 ++ .../LArCalibTools/LArDSPThresholds2Ntuple.h | 33 + .../LArCalibTools/LArFEBTemp2Ntuple.h | 30 + .../LArCalibTools/LArFebTimeOffset2Ntuple.h | 32 + .../LArCalibTools/LArGainThresholds2Ntuple.h | 28 + .../LArCalibTools/LArHVScaleCorr2Ntuple.h | 25 + .../LArCalibTools/LArMphysOverMcal2Ntuple.h | 40 + .../LArCalibTools/LArMphysOverMcalFromTuple.h | 58 ++ .../LArCalibTools/LArNoise2Ntuple.h | 25 + .../LArCalibTools/LArOFC2Ntuple.h | 45 + .../LArOFCBin_PhysCaliTdiffFromStdNtuple.h | 49 + .../LArCalibTools/LArParams2Ntuple.h | 142 +++ .../LArCalibTools/LArParamsFromStdNtuple.h | 54 ++ .../LArCalibTools/LArParamsProperties.h | 168 ++++ .../LArCalibTools/LArPedestals2Ntuple.h | 39 + .../LArCalibTools/LArPhysCaliTDiffAlg.h | 35 + .../LArCalibTools/LArPhysWaveFromStdNtuple.h | 56 ++ .../LArCalibTools/LArPhysWaveFromTuple.h | 68 ++ .../LArCalibTools/LArPhysWaves2Ntuple.h | 52 ++ .../LArCalibTools/LArRamps2Ntuple.h | 46 + .../LArCalibTools/LArReadParamsFromFile.h | 152 ++++ .../LArCalibTools/LArReadParamsFromFile.icc | 371 ++++++++ .../LArCalibTools/LArShape2Ntuple.h | 43 + .../LArCalibTools/LArWFParams2Ntuple.h | 44 + .../LArCalibTools/LArWaves2Ntuple.h | 60 ++ .../LArCalibTools/LArfSampl2Ntuple.h | 25 + .../LArCalibTools/LAruA2MeV2Ntuple.h | 37 + LArCalorimeter/LArCalibTools/cmt/requirements | 50 + LArCalorimeter/LArCalibTools/doc/mainpage.h | 63 ++ .../share/CaloCondBlob2Ntuple.py | 86 ++ .../share/ConvertDSPThrePooltoCool.py | 113 +++ .../share/ConvertPoolToCoolInline.py | 134 +++ .../share/LArAverages2Ntuple_jobOptions.py | 85 ++ ...Calib_Delay_OFC_2Ntuple_POOL_jobOptions.py | 163 ++++ .../share/LArCommConditions2Ntuple.py | 396 ++++++++ .../share/LArCondComparionsExample.py | 107 +++ .../share/LArDSPThresholds2Ntuple.py | 84 ++ .../share/LArDelayFromDB2NTuple_jobOptions.py | 217 +++++ .../share/LArFEBTemp2Ntuple_jobOptions.py | 90 ++ .../share/LArGainThresholds2Ntuple.py | 106 +++ .../share/LArMCConditions2Ntuple.py | 184 ++++ .../LArMphysOverMcalFromTuple_jobOptions.py | 101 ++ .../share/LArOFC2Ntuple_POOL_jobOptions.py | 96 ++ ...sCaliTdiffFromStdNtuple2Pool_jobOptions.py | 197 ++++ .../share/LArParams2Ntuple_POOL_jobOptions.py | 141 +++ .../LArParamsFromDB2NTuple_jobOptions.py | 182 ++++ .../LArParamsFromStdNtuple2Pool_jobOptions.py | 184 ++++ .../share/LArPedestal2Ntuple_jobOptions.py | 190 ++++ .../share/LArPhysCaliTDiffAlg.py | 86 ++ .../LArPhysWaveFromDB2NTuple_jobOptions.py | 201 ++++ .../LArPhysWaveFromNTuple2Pool_jobOptions.py | 150 +++ ...ArPhysWaveFromStdNtuple2Pool_jobOptions.py | 167 ++++ .../share/LArPhysWaveFromTuple_jobOptions.py | 91 ++ .../share/LArRamp2Ntuple_POOL_jobOptions.py | 107 +++ .../share/LArRamp2Ntuple_jobOptions.py | 60 ++ .../share/LArRampPool2Ntuple_jobOptions.py | 71 ++ ...ArReadParamsFromFile_CTB2004_jobOptions.py | 184 ++++ .../LArReadParamsFromFile_P3C_jobOptions.py | 250 +++++ .../share/LArShape2Ntuple_POOL_jobOptions.py | 84 ++ .../share/LArWaves2Ntuple_POOL_jobOptions.py | 143 +++ .../share/LAruAMeV2Ntuple_jobOptions.py | 49 + .../LArCalibTools/share/TestCaloCellGroup.py | 60 ++ .../TopOptsExample_ReadParamsFromFile.py | 47 + .../share/TopOptsExample_Shape2Ntuple_POOL.py | 26 + .../share/TopOptsExample_Waves2Ntuple_POOL.py | 31 + .../share/rootMacros/LArPhysWaveCheck.C | 96 ++ .../share/rootMacros/TWave2NTuple.C | 113 +++ .../src/CaloCellGroup2Ntuple.cxx | 85 ++ .../LArCalibTools/src/CaloCondBlob2Ntuple.cxx | 98 ++ .../LArCalibTools/src/ForceLoadCondObj.cxx | 84 ++ .../src/LArAccumulatedDigits2Ntuple.cxx | 314 +++++++ .../LArCalibTools/src/LArAutoCorr2Ntuple.cxx | 86 ++ .../LArCalibTools/src/LArAverages2Ntuple.cxx | 334 +++++++ .../LArCalibTools/src/LArBlockCorrections.cxx | 20 + .../LArCalibTools/src/LArCaliWaves2Ntuple.cxx | 258 ++++++ .../LArCalibTools/src/LArCompleteToFlat.cxx | 664 ++++++++++++++ .../LArCalibTools/src/LArCond2NtupleBase.cxx | 337 +++++++ .../src/LArDSPThresholds2Ntuple.cxx | 117 +++ .../LArCalibTools/src/LArFEBTemp2Ntuple.cxx | 92 ++ .../src/LArFebTimeOffset2Ntuple.cxx | 72 ++ .../src/LArGainThresholds2Ntuple.cxx | 67 ++ .../src/LArHVScaleCorr2Ntuple.cxx | 64 ++ .../src/LArMphysOverMcal2Ntuple.cxx | 87 ++ .../src/LArMphysOverMcalFromTuple.cxx | 117 +++ .../LArCalibTools/src/LArNoise2Ntuple.cxx | 89 ++ .../LArCalibTools/src/LArOFC2Ntuple.cxx | 168 ++++ .../LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx | 157 ++++ .../LArCalibTools/src/LArParams2Ntuple.cxx | 860 ++++++++++++++++++ .../src/LArParamsFromStdNtuple.cxx | 160 ++++ .../LArCalibTools/src/LArParamsProperties.cxx | 168 ++++ .../LArCalibTools/src/LArPedestals2Ntuple.cxx | 89 ++ .../LArCalibTools/src/LArPhysCaliTDiffAlg.cxx | 129 +++ .../src/LArPhysWaveFromStdNtuple.cxx | 164 ++++ .../src/LArPhysWaveFromTuple.cxx | 151 +++ .../LArCalibTools/src/LArPhysWaves2Ntuple.cxx | 131 +++ .../LArCalibTools/src/LArRamps2Ntuple.cxx | 451 +++++++++ .../LArCalibTools/src/LArShape2Ntuple.cxx | 196 ++++ .../LArCalibTools/src/LArWFParams2Ntuple.cxx | 271 ++++++ .../LArCalibTools/src/LArWaves2Ntuple.cxx | 130 +++ .../LArCalibTools/src/LArfSampl2Ntuple.cxx | 76 ++ .../LArCalibTools/src/LAruA2MeV2Ntuple.cxx | 89 ++ .../src/components/LArCalibTools_entries.cxx | 145 +++ .../src/components/LArCalibTools_load.cxx | 3 + 112 files changed, 13801 insertions(+) create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/CaloCellGroup2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/CaloCondBlob2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/ForceLoadCondObj.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArAccumulatedDigits2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArAutoCorr2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArBlockCorrections.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArCaliWaves2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArCompleteToFlat.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArCond2NtupleBase.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArDSPThresholds2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArFEBTemp2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArFebTimeOffset2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArGainThresholds2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArHVScaleCorr2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArMphysOverMcal2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArMphysOverMcalFromTuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArNoise2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArOFC2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArOFCBin_PhysCaliTdiffFromStdNtuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArParams2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArParamsFromStdNtuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArParamsProperties.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArPedestals2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysCaliTDiffAlg.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaveFromStdNtuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaveFromTuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaves2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArRamps2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.icc create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArShape2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArWFParams2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LArWaves2Ntuple.h create mode 100644 LArCalorimeter/LArCalibTools/LArCalibTools/LArfSampl2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/LArCalibTools/LAruA2MeV2Ntuple.h create mode 100755 LArCalorimeter/LArCalibTools/cmt/requirements create mode 100644 LArCalorimeter/LArCalibTools/doc/mainpage.h create mode 100644 LArCalorimeter/LArCalibTools/share/CaloCondBlob2Ntuple.py create mode 100644 LArCalorimeter/LArCalibTools/share/ConvertDSPThrePooltoCool.py create mode 100644 LArCalorimeter/LArCalibTools/share/ConvertPoolToCoolInline.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArAverages2Ntuple_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArCommConditions2Ntuple.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArCondComparionsExample.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArDSPThresholds2Ntuple.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArDelayFromDB2NTuple_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArFEBTemp2Ntuple_jobOptions.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArGainThresholds2Ntuple.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArMCConditions2Ntuple.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArMphysOverMcalFromTuple_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArOFC2Ntuple_POOL_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArOFCBin_PhysCaliTdiffFromStdNtuple2Pool_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArParams2Ntuple_POOL_jobOptions.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArParamsFromDB2NTuple_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArParamsFromStdNtuple2Pool_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArPedestal2Ntuple_jobOptions.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArPhysCaliTDiffAlg.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArPhysWaveFromDB2NTuple_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArPhysWaveFromNTuple2Pool_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArPhysWaveFromStdNtuple2Pool_jobOptions.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArPhysWaveFromTuple_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArRamp2Ntuple_POOL_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArRamp2Ntuple_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArRampPool2Ntuple_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArReadParamsFromFile_CTB2004_jobOptions.py create mode 100644 LArCalorimeter/LArCalibTools/share/LArReadParamsFromFile_P3C_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArShape2Ntuple_POOL_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LArWaves2Ntuple_POOL_jobOptions.py create mode 100755 LArCalorimeter/LArCalibTools/share/LAruAMeV2Ntuple_jobOptions.py create mode 100644 LArCalorimeter/LArCalibTools/share/TestCaloCellGroup.py create mode 100644 LArCalorimeter/LArCalibTools/share/TopOptsExample_ReadParamsFromFile.py create mode 100644 LArCalorimeter/LArCalibTools/share/TopOptsExample_Shape2Ntuple_POOL.py create mode 100644 LArCalorimeter/LArCalibTools/share/TopOptsExample_Waves2Ntuple_POOL.py create mode 100644 LArCalorimeter/LArCalibTools/share/rootMacros/LArPhysWaveCheck.C create mode 100644 LArCalorimeter/LArCalibTools/share/rootMacros/TWave2NTuple.C create mode 100644 LArCalorimeter/LArCalibTools/src/CaloCellGroup2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/CaloCondBlob2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/ForceLoadCondObj.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArAccumulatedDigits2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArAutoCorr2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArBlockCorrections.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArCaliWaves2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArCompleteToFlat.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArDSPThresholds2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArFEBTemp2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArFebTimeOffset2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArGainThresholds2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArHVScaleCorr2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArMphysOverMcal2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArMphysOverMcalFromTuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArNoise2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArOFC2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArParams2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArParamsFromStdNtuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArParamsProperties.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArPedestals2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArPhysCaliTDiffAlg.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArPhysWaveFromStdNtuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArPhysWaveFromTuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArPhysWaves2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArRamps2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArShape2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArWFParams2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LArWaves2Ntuple.cxx create mode 100644 LArCalorimeter/LArCalibTools/src/LArfSampl2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/LAruA2MeV2Ntuple.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/components/LArCalibTools_entries.cxx create mode 100755 LArCalorimeter/LArCalibTools/src/components/LArCalibTools_load.cxx diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/CaloCellGroup2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/CaloCellGroup2Ntuple.h new file mode 100644 index 000000000000..ca5c3a3a723d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/CaloCellGroup2Ntuple.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CaloCellGroup2Ntuple_H +#define CaloCellGroup2Ntuple_H + +#include "LArCalibTools/LArCond2NtupleBase.h" +#include "CaloIdentifier/CaloCellGroup.h" + +class CaloCellGroupList; + +class CaloCellGroup2Ntuple : public LArCond2NtupleBase +{ + public: + CaloCellGroup2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~CaloCellGroup2Ntuple(); + + //standard algorithm methods + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + std::vector<std::string> m_groupInit; + CaloCellGroupList m_cellGroupList; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/CaloCondBlob2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/CaloCondBlob2Ntuple.h new file mode 100644 index 000000000000..62a5e4ce3ae6 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/CaloCondBlob2Ntuple.h @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CaloCondBlob2Ntuple_H +#define CaloCondBlob2Ntuple_H + +#include "LArCalibTools/LArCond2NtupleBase.h" + +class CaloCondBlob2Ntuple : public LArCond2NtupleBase +{ + public: + CaloCondBlob2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~CaloCondBlob2Ntuple(); + + //standard algorithm methods + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + std::string m_folder; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/ForceLoadCondObj.h b/LArCalorimeter/LArCalibTools/LArCalibTools/ForceLoadCondObj.h new file mode 100644 index 000000000000..6137acf37b0a --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/ForceLoadCondObj.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FORCELOADCONDOBJ_H +#define FORCELOADCONDOBJ_H + +// ForceLoadCondObj.h + +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" +#include <vector> +#include <string> + +class StoreGateSvc; +class IClassIDSvc; + +class ForceLoadCondObj: public Algorithm +{ +public: + ForceLoadCondObj(const std::string& name, ISvcLocator* pSvcLocator); + ~ForceLoadCondObj(); + + StatusCode initialize(); + StatusCode execute(); + StatusCode finalize(); + //StatusCode stop(); + +private: + + ServiceHandle<StoreGateSvc> p_detstore; + ServiceHandle<IClassIDSvc> p_clidsvc; + + std::vector<std::string> m_objectList; + +}; + +#endif // REGISTRATIONSVC_OUTPUTCONDALG_H diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArAccumulatedDigits2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAccumulatedDigits2Ntuple.h new file mode 100644 index 000000000000..360857e43072 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAccumulatedDigits2Ntuple.h @@ -0,0 +1,78 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/* + * @author R. Lafaye + * 12. 06. 2008 + * Modifications: +*/ + +#ifndef LARACCUMULATEDDIGITS2NTUPLE_H +#define LARACCUMULATEDDIGITS2NTUPLE_H +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/INTupleSvc.h" +#include "GaudiKernel/NTuple.h" +#include "GaudiKernel/SmartDataPtr.h" +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/IToolSvc.h" +#include "GaudiKernel/ToolHandle.h" + +#include "LArTools/LArCablingService.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "CaloIdentifier/CaloIdManager.h" +#include "LArIdentifier/LArOnlineID.h" + +#include <fstream> +#include <math.h> +#include <string> +#include <map> + +class LArAccumulatedDigits2Ntuple : public Algorithm +{ + public: + LArAccumulatedDigits2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArAccumulatedDigits2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + StatusCode execute() ; + StatusCode finalize(){return StatusCode::SUCCESS;} + private: + StoreGateSvc* m_storeGateSvc; + const LArEM_ID* m_emId; + const LArOnlineID* m_onlineHelper; + + ToolHandle<LArCablingService> m_larCablingSvc; + + std::string m_ntuplePath; + std::string m_contKey; + + unsigned int m_Nsamples; + int m_normalize; + + int m_ipass; + long m_event; + + NTuple::Item<long> region, layer, eta, phi; + NTuple::Item<long> pos_neg, barrel_ec, FT, slot, channel; + NTuple::Item<long> calibLine; + NTuple::Item<long> m_isConnected; + NTuple::Item<long> Ntrigger; + NTuple::Item<long> IEvent; + NTuple::Item<long> Nsamples; + NTuple::Array<long> sum; + NTuple::Array<long> sumsq; + NTuple::Item<float> mean; + NTuple::Item<float> rms; + NTuple::Array<float> covr; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArAutoCorr2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAutoCorr2Ntuple.h new file mode 100755 index 000000000000..8bc8c6972f2a --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAutoCorr2Ntuple.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: LArAutoCorr2Ntuple.h + PACKAGE: offline/LArCalorimeter/LArCalibUtils + + AUTHORS: M. AHARROUCHE + CREATED: Mar. 21, 2004 + + PURPOSE: Create a column-wise ntuple + +********************************************************************/ +#ifndef LARAUTOCORR2NTUPLE_H +#define LARAUTOCORR2NTUPLE_H +#include "LArCalibTools/LArCond2NtupleBase.h" + + +class LArAutoCorr2Ntuple : public LArCond2NtupleBase +{ + public: + LArAutoCorr2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArAutoCorr2Ntuple(); + + //standard algorithm methods + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + + private: + + // Key of the AutocorrComplete object + std::string m_objKey; + + // Number of samples + unsigned m_nsamples; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h new file mode 100755 index 000000000000..1dcdc0328d93 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h @@ -0,0 +1,82 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/* + * @author S. Laplace + * 14. 12. 2005 + * Modifications: +*/ + +#ifndef LARAVERAGES2NTUPLE_H +#define LARAVERAGES2NTUPLE_H +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/INTupleSvc.h" +#include "GaudiKernel/NTuple.h" +#include "GaudiKernel/SmartDataPtr.h" +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/IToolSvc.h" +#include "GaudiKernel/ToolHandle.h" + +#include "LArTools/LArCablingService.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "CaloIdentifier/CaloIdManager.h" +#include "LArIdentifier/LArOnlineID.h" + +#include <fstream> +#include <math.h> +#include <string> +#include <map> + +class LArAverages2Ntuple : public Algorithm +{ + public: + LArAverages2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArAverages2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + StatusCode execute() ; + StatusCode finalize(){return StatusCode::SUCCESS;} + private: + StoreGateSvc* m_storeGateSvc; + StoreGateSvc* m_detStore; + const LArEM_ID* m_emId; + const LArOnlineID* m_onlineHelper; + + ToolHandle<LArCablingService> larCablingSvc; + + std::string ntuplePath; + std::string m_contKey; + + unsigned int m_Nsamples; + bool m_keepPulsed; + + int ipass; + + NTuple::Item<long> region, layer, eta, phi; + NTuple::Item<long> pos_neg, barrel_ec, FT, slot, channel; + NTuple::Item<long> calibLine; + NTuple::Item<long> m_isConnected; + NTuple::Item<long> Nsteps; + NTuple::Item<long> DAC; + NTuple::Item<long> Ntrigger; + NTuple::Item<long> delay; + NTuple::Item<long> Nsamples; + NTuple::Item<long> isPulsed; + + NTuple::Item<unsigned long> StepIndex; + + NTuple::Array<long> Sum; + NTuple::Array<long> SumSq; + NTuple::Array<float> Mean; + NTuple::Array<float> RMS; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArBlockCorrections.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArBlockCorrections.h new file mode 100644 index 000000000000..6b5425b1f64b --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArBlockCorrections.h @@ -0,0 +1,14 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "GaudiKernel/Algorithm.h" + +class LArBlockCorrections:public Algorithm { + public: + LArBlockCorrections(const std::string& name, ISvcLocator* pSvcLocator); + StatusCode initialize(); + StatusCode execute() {return StatusCode::SUCCESS;} + StatusCode finalize() {return StatusCode::SUCCESS;} + +}; diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArCaliWaves2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArCaliWaves2Ntuple.h new file mode 100755 index 000000000000..c08bc517466c --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArCaliWaves2Ntuple.h @@ -0,0 +1,65 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algrithm produces a column-wise NTuple out of a + LArCaliWaveContainer or a LArPhysWaveContainer + * @author M. Delmastro + * 01. 06. 2004 + * Last update: + * - M. Delmastro: 19/4/2008, migrate to LArCond2NtupleBase, + * added computation and storing of Wave-derived information. + * - W. Lampl: 22/9/2008, introduce common base-class LArWaves2Ntuple +*/ + +#ifndef LARCALIWAVES2NTUPLE_H +#define LARCALIWAVES2NTUPLE_H +#include "LArCalibTools/LArWaves2Ntuple.h" + +#include "LArRawConditions/LArCaliWaveContainer.h" + +#include "LArRawConditions/LArWaveHelper.h" + +class LArCaliWaves2Ntuple : public LArWaves2Ntuple +{ + + public: + + LArCaliWaves2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArCaliWaves2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + + private: + bool writeEntry(const HWIdentifier chid, const unsigned gain, const LArCaliWave& wave); + + std::vector<std::string> m_keylist ; + std::string m_ntName; + std::string m_ntFile; + bool m_dacSaturSkip; + bool m_saveJitter; + bool m_addCorrUndo; + bool m_applyCorr; + + std::vector<unsigned> m_dacSaturLayer0; + std::vector<unsigned> m_dacSaturLayer1; + std::vector<unsigned> m_dacSaturLayer2; + std::vector<unsigned> m_dacSaturLayer3; + + // Book specialized leaves + NTuple::Item<long> m_dac; + NTuple::Item<long> m_gain; + NTuple::Item<long> m_nPulsedCalibLines; + NTuple::Array<long> m_pulsedCalibLines; + NTuple::Item<double> m_jitter; + NTuple::Item<long> m_corrUndo; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArCompleteToFlat.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArCompleteToFlat.h new file mode 100644 index 000000000000..5f51f7a59ca0 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArCompleteToFlat.h @@ -0,0 +1,87 @@ +//-*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +#ifndef LARCALIBTOOLS_LARCOMPLETETOFLAT_H +#define LARCALIBTOOLS_LARCOMPLETETOFLAT_H 1 + +#include <string> +#include "AthenaBaseComps/AthAlgorithm.h" +#include "LArRawConditions/LArConditionsContainer.h" +#include "LArRawConditions/LArSingleFloatP.h" +#include "LArTools/LArCablingService.h" +#include "GaudiKernel/ToolHandle.h" + +class LArOnlineID; +class CondAttrListCollection; +class AthenaAttributeList; +class ILArPedestal; +class ILArOFC; +class ILArRamp; +class LArShapeComplete; +class ILArDAC2uA; +class ILAruA2MeV; +class LArDSPThresholdsComplete; + +class LArCompleteToFlat: public AthAlgorithm +{ + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + /// Constructor with parameters: + LArCompleteToFlat( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Destructor: + virtual ~LArCompleteToFlat(); + + // Athena algorithm's Hooks + StatusCode initialize(); + StatusCode execute() {return StatusCode::SUCCESS;} + StatusCode finalize() {return StatusCode::SUCCESS;} + virtual StatusCode stop(); + + private: + /// Default constructor: + LArCompleteToFlat(); + + + CondAttrListCollection* singleFloatFlat(const char* blobName, const LArConditionsContainer<LArSingleFloatP>* input, + const std::string& outputName, const unsigned nGain, const bool withFCAL=true); + CondAttrListCollection* DAC2uAFlat(const ILArDAC2uA* input, const std::string& outputName); + CondAttrListCollection* uA2MeVFlat(const ILAruA2MeV* input, const std::string& outputName); + CondAttrListCollection* pedestalFlat(const ILArPedestal* input, const std::string& outputName); + CondAttrListCollection* rampFlat(const ILArRamp* input, const std::string& outputName); + CondAttrListCollection* ofcFlat(const ILArOFC* input, const std::string& outputName); + CondAttrListCollection* shapeFlat(const LArShapeComplete* input, const std::string& outputName); + AthenaAttributeList* DSPThresholdsFlat(const LArDSPThresholdsComplete* input, const std::string& outputName); + + + void errIfConnected(const HWIdentifier chid, const int gain, const char* objName) const; + + unsigned m_hashMax; + const LArOnlineID* m_onlineID; + + + ToolHandle<LArCablingService> m_cablingSvc; + + ///InputSGKeys + std::string m_uA2MeVInput; + std::string m_DAC2uAInput; + std::string m_HVScaleCorrInput; + std::string m_PedestalInput; + std::string m_RampInput; + std::string m_MphysOverMcalInput; + std::string m_OFCInput; + std::string m_ShapeInput; + std::string m_DSPThresholdsInput; + + bool m_forceStop; + +}; + +#endif //> !LARCALIBTOOLS_LARCOMPLETETOFLAT_H diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArCond2NtupleBase.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArCond2NtupleBase.h new file mode 100644 index 000000000000..1697f49ac466 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArCond2NtupleBase.h @@ -0,0 +1,78 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//Dear emacs, this is -*-c++-*- +#ifndef LARCOND2NTUPLEBASE_H +#define LARCOND2NTUPLEBASE_H + +//#include "GaudiKernel/Algorithm.h" +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/NTuple.h" +#include "GaudiKernel/ToolHandle.h" + +#include "LArRecConditions/ILArBadChanTool.h" +#include "LArTools/LArCablingService.h" +#include "LArTools/LArSuperCellCablingTool.h" +#include "LArElecCalib/ILArFEBTempTool.h" + +class HWIdentifier; +class LArOnlineID_Base; +//class LArCablingService; +//class ILArBadChanTool; +class StoreGateSvc; +class LArEM_Base_ID; +class LArHEC_Base_ID; +class LArFCAL_Base_ID; +class MsgStream; + +class LArCond2NtupleBase : public AthAlgorithm { + + public: + LArCond2NtupleBase(const std::string & name, ISvcLocator * pSvcLocator); + ~LArCond2NtupleBase(); + + //Standard algo methods + StatusCode initialize(); + StatusCode execute() {return StatusCode::SUCCESS;} + //Finalize needs to be implemented by the deriving class + + + //StatusCode initializeBase(const std::string& path, const std::string& name); + bool fillFromIdentifier(const HWIdentifier& id); //returns true if connected + + private: + bool m_initialized; + + protected: + bool m_addBC, m_addFEBTemp; + enum {NOT_VALID = -999}; + + std::string m_ntpath, m_ntTitle; + + //Ntuple pointer + NTuple::Tuple* m_nt; + + //Ntuple variables: + NTuple::Item<long> m_detector, m_region, m_layer, m_eta, m_phi, m_onlChanId, m_oflChanId; + NTuple::Item<long> m_pos_neg, m_barrel_ec, m_FT, m_slot, m_channel; + NTuple::Item<long> m_calibLine,m_badChanWord; + NTuple::Item<long> m_isConnected; + NTuple::Item<float> m_FEBTemp1, m_FEBTemp2; + + MsgStream* m_log; + + StoreGateSvc* m_detStore; + const LArEM_Base_ID* m_emId; + const LArHEC_Base_ID* m_hecId; + const LArFCAL_Base_ID* m_fcalId; + const LArOnlineID_Base* m_onlineId; + LArCablingBase* m_larCablingSvc; + ToolHandle<ILArBadChanTool> m_badChanTool; + ToolHandle<ILArFEBTempTool> m_FEBTempTool; + bool m_isSC; + bool m_isFlat; + bool m_OffId; + +}; +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArDSPThresholds2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArDSPThresholds2Ntuple.h new file mode 100644 index 000000000000..7f38abb162ca --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArDSPThresholds2Ntuple.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARDSPTHRESHOLDS2NTUPLE_H +#define LARDSPTHRESHOLDS2NTUPLE_H + +#include "LArCalibTools/LArCond2NtupleBase.h" + + +class LArDSPThresholds2Ntuple : public LArCond2NtupleBase +{ + public: + LArDSPThresholds2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArDSPThresholds2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + std::string m_ntname; + std::string m_folder; + bool m_doFlat; + + NTuple::Item<float> m_tQThr; + NTuple::Item<float> m_samplesThr; + NTuple::Item<float> m_trigThr; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArFEBTemp2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArFEBTemp2Ntuple.h new file mode 100755 index 000000000000..d08ee5779e3c --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArFEBTemp2Ntuple.h @@ -0,0 +1,30 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algrithm produces a column-wise NTuple + out of a LArFEBTempTool. + * @author Kirill Skovpen +*/ + +#ifndef LARFEBTEMP2NTUPLE_H +#define LARFEBTEMP2NTUPLE_H +#include "LArCalibTools/LArCond2NtupleBase.h" + +class LArFEBTemp2Ntuple : public LArCond2NtupleBase +{ + public: + LArFEBTemp2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArFEBTemp2Ntuple(); + + //standard algorithm methods + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + private: + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArFebTimeOffset2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArFebTimeOffset2Ntuple.h new file mode 100644 index 000000000000..1fa07457e620 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArFebTimeOffset2Ntuple.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// Dear emacs, this is -*-c++-*- +#ifndef LARFEBTIMEOFFSET2NTUPLE_H +#define LARFEBTIMEOFFSET2NTUPLE_H + +//#include "AthenaBaseComps/AthAlgorithm.h" +#include "LArCalibTools/LArCond2NtupleBase.h" + +class LArFebTimeOffset2Ntuple: public LArCond2NtupleBase { + + public: + + LArFebTimeOffset2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + + virtual ~LArFebTimeOffset2Ntuple(); + + StatusCode initialize(); + StatusCode execute() {return StatusCode::SUCCESS;} + StatusCode stop(); //<< Do the work here + StatusCode finalize() {return StatusCode::SUCCESS;} + + + private: + std::string m_inputContainer; + int m_gain; +}; + + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArGainThresholds2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArGainThresholds2Ntuple.h new file mode 100644 index 000000000000..3ee4f9cd7b36 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArGainThresholds2Ntuple.h @@ -0,0 +1,28 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +#ifndef LARGAINTHRESHOLDS2NTUPLE +#define LARGAINTHRESHOLDS2NTUPLE +#include "LArCalibTools/LArCond2NtupleBase.h" +#include "LArElecCalib/ILArFEBConfigReader.h" + +class LArGainThresholds2Ntuple : public LArCond2NtupleBase +{ + public: + LArGainThresholds2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArGainThresholds2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + private: + ToolHandle<ILArFEBConfigReader> m_febConfigReader; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArHVScaleCorr2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArHVScaleCorr2Ntuple.h new file mode 100644 index 000000000000..de1bbc18932d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArHVScaleCorr2Ntuple.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LArHVScaleCorr2Ntuple_H +#define LArHVScaleCorr2Ntuple_H + +#include "LArCalibTools/LArCond2NtupleBase.h" + + +class LArHVScaleCorr2Ntuple : public LArCond2NtupleBase +{ + public: + LArHVScaleCorr2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArHVScaleCorr2Ntuple(); + + //standard algorithm methods + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + private: + + std::string m_contKey; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArMphysOverMcal2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArMphysOverMcal2Ntuple.h new file mode 100644 index 000000000000..ac433526c410 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArMphysOverMcal2Ntuple.h @@ -0,0 +1,40 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algrithm produces a column-wise NTuple + out of a LArMphysOverMcalDB. Only the finalize + method is used, initalize and execute are empty. + The key of the container is given by the jobOption + 'ContainerKey'. + * @author R. Lafaye + * 04. 3. 2004 + + +*/ + +#ifndef LARMPHYSOVERMCAL2NTUPLE_H +#define LARMPHYSOVERMCAL2NTUPLE_H + +#include "LArCalibTools/LArCond2NtupleBase.h" + + +class LArMphysOverMcal2Ntuple : public LArCond2NtupleBase +{ + public: + LArMphysOverMcal2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArMphysOverMcal2Ntuple(); + + //standard algorithm methods + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + private: + + std::string m_contKey; + bool m_isMC; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArMphysOverMcalFromTuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArMphysOverMcalFromTuple.h new file mode 100755 index 000000000000..f8f99b2090d8 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArMphysOverMcalFromTuple.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARMPHYSOVERMCALFROMTuple_H +#define LARMPHYSOVERMCALFROMTuple_H + +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGateSvc.h" + + + +#include <vector> +#include <string> + +/** @class LArMphysOverMcalFromTuple + +This algorithm allows to build a LArMphysOverMcalComplete container from the +content of a root ntuple. + +The root tree should be named "outfit" and contain the following branches : +- BarAC : int: 0 = barrel C 1 = barrel A +- FT : int: feedthrough number (0-31) +- Channel : int: channel number (0-14) +- Slot : int: slot number (1-14) +- PhysOCal : float : value of Mphy/Mcal + */ + + +class LArMphysOverMcalFromTuple : public Algorithm +{ + public: + LArMphysOverMcalFromTuple(const std::string & name, ISvcLocator * pSvcLocator); + + ~LArMphysOverMcalFromTuple(); + + //standard algorithm methods + /// implements IAlgorithm::initialize() + StatusCode initialize() ; + + /// implements IAlgorithm::execute() : Does nothing + StatusCode execute() {return StatusCode::SUCCESS;} + + /// IAlgorithm::finalize() : Where the action takes place... + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + /// list of input ntuple file names + std::vector<std::string> m_root_file_names; + + /// key of the PhysWave collection in StoreGate + std::string m_store_key; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArNoise2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArNoise2Ntuple.h new file mode 100644 index 000000000000..59567422c7a1 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArNoise2Ntuple.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARNOISE2NTUPLE_H +#define LARNOISE2NTUPLE_H + +#include "LArCalibTools/LArCond2NtupleBase.h" + + +class LArNoise2Ntuple : public LArCond2NtupleBase +{ + public: + LArNoise2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArNoise2Ntuple(); + + //standard algorithm methods + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + private: + + std::string m_contKey; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArOFC2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArOFC2Ntuple.h new file mode 100755 index 000000000000..e3e8b82c871d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArOFC2Ntuple.h @@ -0,0 +1,45 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/* + + This algorithm produces a column-wise NTuple out of a LArOFCContainer. + Only the finalize method is used, initalize and execute are empty. + The key of the container is given by the jobOption 'ContainerKey'. + + * @author M. Delmastro + * 30. 3. 2005 + +*/ + +#ifndef LAROFC2NTUPLE_H +#define LAROFC2NTUPLE_H +#include "LArCalibTools/LArCond2NtupleBase.h" +#include "LArElecCalib/ILArOFCTool.h" + +class LArOFC2Ntuple : public LArCond2NtupleBase { + public: + + LArOFC2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArOFC2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + + private: + + //unsigned m_nSamples;// , m_nPhases ; + std::string m_contKey; + std::string m_ntName; + std::string m_ntFile; + bool m_isMC; + ToolHandle<ILArOFCTool> m_OFCTool; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArOFCBin_PhysCaliTdiffFromStdNtuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArOFCBin_PhysCaliTdiffFromStdNtuple.h new file mode 100755 index 000000000000..b04db2053ebd --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArOFCBin_PhysCaliTdiffFromStdNtuple.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LAROFCBIN_PHYSCALITDIFFFROMSTDNTUPLE_H +#define LAROFCBIN_PHYSCALITDIFFFROMSTDNTUPLE_H + +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGateSvc.h" + +#include <vector> +#include <string> + + +class LArOFCBin_PhysCaliTdiffFromStdNtuple : public Algorithm +{ + public: + LArOFCBin_PhysCaliTdiffFromStdNtuple(const std::string & name, ISvcLocator * pSvcLocator); + + ~LArOFCBin_PhysCaliTdiffFromStdNtuple(); + + //standard algorithm methods + /// implements IAlgorithm::initialize() + StatusCode initialize() ; + + /// implements IAlgorithm::execute() : Does nothing + StatusCode execute() {return StatusCode::SUCCESS;} + + /// IAlgorithm::finalize() : Where the action takes place... + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + /// list of input ntuple file names + std::vector<std::string> m_root_file_names; + /// ntuple name + std::string m_ntuple_name; + /// key of the OFCBin collection in Storegate + std::string m_store_key_ofcbin; + bool m_fillofc; + /// key of the PhysCaliTdiff collection in Storegate + std::string m_store_key_tdiff; + bool m_filltdiff; + /// Grouping type. Default is Feedthrough. + std::string m_groupingType; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArParams2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArParams2Ntuple.h new file mode 100755 index 000000000000..ae5e47cc385a --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArParams2Ntuple.h @@ -0,0 +1,142 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algorithm produces a column-wise NTuple + out of several complete structures. Only the finalize + method is used, initalize and execute are empty. + * @author M. Fanti + * 27. 2. 2004 +*/ + +#ifndef LARPARAMS2NTUPLE_H +#define LARPARAMS2NTUPLE_H + +#include "LArCalibTools/LArCond2NtupleBase.h" +#include "LArCalibTools/LArParamsProperties.h" + +using namespace LArParamsProperties ; + +class LArParams2Ntuple : public LArCond2NtupleBase +{ + public: + + LArParams2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArParams2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + StatusCode execute() {return StatusCode::SUCCESS;} + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + //StatusCode ntChannelInfo(HWIdentifier chid,int igain) ; + + private: + + std::vector<std::string> m_classNames ; + std::vector<std::string> m_detStoreKeys ; + std::vector<std::string> m_detStoreJo ; + bool m_allChannels2Ntuple ; + bool m_useAbstractInterface ; + std::string m_ntName; + + static const unsigned m_nClasses; + + class DumpFlags { + private: + std::vector<bool> m_flags ; + public: + DumpFlags() { for ( unsigned i=0 ; i<m_nClasses ; i++ ) m_flags.push_back(false) ; } + void set(unsigned i) { if ( i<m_nClasses ) m_flags[i] = true ; } + void clear(unsigned i) { if ( i<m_nClasses ) m_flags[i] = false ; } + inline bool operator[](unsigned i) const { return (i<m_nClasses) && m_flags[i] ; } + inline const std::vector<bool>& flags() const { return m_flags ; } + } ; + + std::vector<std::string> m_keylist ; + DumpFlags m_dumpFlags ; + std::string m_suffix ; + + std::vector< std::map< HWIdentifier , DumpFlags > > m_dump_flags_map ; + + const LArCaliPulseParamsComplete* m_completeCaliPulseParams ; + const LArDetCellParamsComplete* m_completeDetCellParams ; + const LArPhysCaliTdiffComplete* m_completePhysCaliTdiff ; + const LArTdriftComplete* m_completeTdrift ; + const LArMphysOverMcalComplete* m_completeMphysOverMcal ; + const LArRinjComplete* m_completeRinj ; + const LArTshaperComplete* m_completeTshaper ; + const LArEMEC_CphiComplete* m_completeEMEC_Cphi ; + const LArEMEC_HValphaComplete* m_completeEMEC_HValpha ; + const LArEMEC_HVbetaComplete* m_completeEMEC_HVbeta ; + const LArCableLengthComplete* m_completeCableLength ; + const LArCableAttenuationComplete* m_completeCableAttenuation ; + const LArCaliPulseParamsVsCalib* m_calibCaliPulseParams ; + const LArOFCBinComplete* m_completeOFCBin ; + + + template < class DATA > + StatusCode scanReadoutChannels(const DATA*& data_object) ; + template < class DATA > + StatusCode scanCalibChannels(const DATA*& data_object) ; + template < class DATA > + StatusCode retrieveFromDetStore(const DATA*& data_object) ; + +// inline StatusCode retrieveAbstractInterface(const LArCaliPulseParamsComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArCaliPulseParams*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArCaliPulseParamsVsCalib*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArCaliPulseParams*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArDetCellParamsComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArDetCellParams*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArPhysCaliTdiffComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArPhysCaliTdiff*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArTdriftComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArTdrift*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArMphysOverMcalComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArMphysOverMcal*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArRinjComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArRinj*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArTshaperComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArTshaper*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArEMEC_CphiComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArEMEC_Cphi*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArEMEC_HValphaComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArEMEC_HValpha*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArEMEC_HVbetaComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArEMEC_HVbeta*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArCableLengthComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArCableLength*&>(data_object) ) ; } +// inline StatusCode retrieveAbstractInterface(const LArCableAttenuationComplete*& data_object) +// { return m_detStore->retrieve(dynamic_cast<const ILArCableAttenuation*&>(data_object) ) ; } + + inline StatusCode retrieveAbstractInterface(const LArCaliPulseParamsComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArCaliPulseParamsVsCalib*& data_object); + inline StatusCode retrieveAbstractInterface(const LArDetCellParamsComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArPhysCaliTdiffComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArTdriftComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArMphysOverMcalComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArRinjComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArTshaperComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArEMEC_CphiComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArEMEC_HValphaComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArEMEC_HVbetaComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArCableLengthComplete*& data_object); + inline StatusCode retrieveAbstractInterface(const LArCableAttenuationComplete*& data_object); + StatusCode retrieveAbstractInterface(const LArOFCBinComplete*& /*data_object*/){return StatusCode::SUCCESS;}; + + + + // dump all channel info to text file + //------------------------------------ + //std::string m_dumpAllOnlineChannels ; + //void dumpChannels() ; + //void writeToFile(const HWIdentifier & ch, FILE* f) ; + + // Athena / Gaudi services: +}; + + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArParamsFromStdNtuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArParamsFromStdNtuple.h new file mode 100755 index 000000000000..bd059d9a328e --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArParamsFromStdNtuple.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARPARAMSFROMSTDNTUPLE_H +#define LARPARAMSFROMSTDNTUPLE_H + +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGateSvc.h" + +#include <vector> +#include <string> + +/** @class LArParamsFromStdNtuple + +This algorithm allows to read wave forms from ntuples and builds a +LArCaliPulseParamsComplete and/or LArDetCellParamsComplete . +Version for standard Ntuple, produced by LArCalibTools algos.... + */ + + +class LArParamsFromStdNtuple : public Algorithm +{ + public: + LArParamsFromStdNtuple(const std::string & name, ISvcLocator * pSvcLocator); + + ~LArParamsFromStdNtuple(); + + //standard algorithm methods + /// implements IAlgorithm::initialize() + StatusCode initialize() ; + + /// implements IAlgorithm::execute() : Does nothing + StatusCode execute() {return StatusCode::SUCCESS;} + + /// IAlgorithm::finalize() : Where the action takes place... + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + /// list of input ntuple file names + std::vector<std::string> m_root_file_names; + /// ntuple name + std::string m_ntuple_name; + /// key of the CaliPulseParams collection in Storegate + std::string m_store_key_cali; + /// key of the DetCellParams collection in Storegate + std::string m_store_key_det; + /// Grouping type. Default is Feedthrough. + std::string m_groupingType; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArParamsProperties.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArParamsProperties.h new file mode 100755 index 000000000000..850efc3025e3 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArParamsProperties.h @@ -0,0 +1,168 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This include file contains inline functions describing LAr Parameters properties used in + LArReadParamsFromFile and LArParams2Ntuple. + To use them you must use namespace operator 'LArParamsProperties::' + or put the line 'using LArParamsProperties' + * @author M. Fanti + * 27.02.2006 +*/ +#ifndef LARCALIBTOOLS_LARPARAMSPROPERTIES_H +#define LARCALIBTOOLS_LARPARAMSPROPERTIES_H + +#include "LArRawConditions/LArCaliPulseParamsComplete.h" +#include "LArRawConditions/LArDetCellParamsComplete.h" +#include "LArRawConditions/LArPhysCaliTdiffComplete.h" +#include "LArRawConditions/LArTdriftComplete.h" +#include "LArRawConditions/LArMphysOverMcalComplete.h" +#include "LArRawConditions/LArRinjComplete.h" +#include "LArRawConditions/LArTshaperComplete.h" +#include "LArRawConditions/LArEMEC_CphiComplete.h" +#include "LArRawConditions/LArEMEC_HValphaComplete.h" +#include "LArRawConditions/LArEMEC_HVbetaComplete.h" +#include "LArRawConditions/LArCableLengthComplete.h" +#include "LArRawConditions/LArCableAttenuationComplete.h" +#include "LArRawConditions/LArCaliPulseParamsVsCalib.h" +#include "LArRawConditions/LArOFCBinComplete.h" +#include "LArRawConditions/LArPhysCaliTdiffComplete.h" + +namespace LArParamsProperties { + + //////////////////////////////////////////////////////////////////////////////// + // + // To add a new LAr data class (e.g. LArNewClass) containing payload objects + // (e.g. LArPayload) you must: + // + // (0) overload the 'inline bool isValid()' function with the reference + // to the payload object (e.g. isValid(const LArPayload&) {return(...);}; + // giving a validity criterion + // + // (1) add its sequential number to the enum, before END_OF_LIST + // (call it with the class name without 'LAr', e.g. 'NewClass') + // + // (2) overload the 'inline unsigned getClassIndex()' with the pointer + // to the new class (e.g. getClassIndex(LArNewClass*) {return NewClass;}; + // + // (3) add the properties of the new class to the functions: + // ClassNames(), numberOfParams(unsigned), isGainDependent(unsigned) + // + // all the rest should be self-consistent and does not need any update. + // + //////////////////////////////////////////////////////////////////////////////// + + // validity of payload data ( invalid = empty ) + //---------------------------------------------- + bool isValid(const LArCaliPulseParamsP & p); + bool isValid(const LArDetCellParamsP & p); + bool isValid(const LArPhysCaliTdiffP & p); + bool isValid(const LArTdriftP & p); +#ifdef LARRAWCONDITIONS_LARSINGLEFLOATP + bool isValid(const LArSingleFloatP & p); +#endif +#ifdef LARRAWCONDITIONS_LARMPHYSOVERMCALP1 + bool isValid(const LArMphysOverMcalP1 & p); +#endif + bool isValid(const LArRinjP & p); + bool isValid(const LArTshaperP & p); + bool isValid(const LArEMEC_CphiP & p); + bool isValid(const LArEMEC_HValphaP & p); + bool isValid(const LArEMEC_HVbetaP & p); + bool isValid(const LArCableLengthP & p); + bool isValid(const LArCableAttenuationP & p); + bool isValid(const LArOFCBinP & p); + bool isValid(const LArPhysCaliTdiffP & p); + + // sequential number associated to foreseen data classes + //------------------------------------------------------- + enum ClassNumbering { + CaliPulseParamsComplete = 0 , + DetCellParamsComplete , + PhysCaliTdiffComplete , + TdriftComplete , + MphysOverMcalComplete , + RinjComplete , + TshaperComplete , + EMEC_CphiComplete , + EMEC_HValphaComplete , + EMEC_HVbetaComplete , + CableLengthComplete , + CableAttenuationComplete , + CaliPulseParamsVsCalib , + OFCBinComplete , + END_OF_LIST // used to count allowed data classes + } ; + + // conversion: data class pointer --> class index + //------------------------------------------------ + unsigned getClassIndex(const LArCaliPulseParamsComplete*); + unsigned getClassIndex(const LArDetCellParamsComplete*); + unsigned getClassIndex(const LArPhysCaliTdiffComplete*); + unsigned getClassIndex(const LArTdriftComplete*); + unsigned getClassIndex(const LArMphysOverMcalComplete*); + unsigned getClassIndex(const LArRinjComplete*); + unsigned getClassIndex(const LArTshaperComplete*); + unsigned getClassIndex(const LArEMEC_CphiComplete*); + unsigned getClassIndex(const LArEMEC_HValphaComplete*); + unsigned getClassIndex(const LArEMEC_HVbetaComplete*); + unsigned getClassIndex(const LArCableLengthComplete*); + unsigned getClassIndex(const LArCableAttenuationComplete*); + unsigned getClassIndex(const LArCaliPulseParamsVsCalib*); + unsigned getClassIndex(const LArOFCBinComplete*); + unsigned getClassIndex(const LArPhysCaliTdiffComplete*); + + // vector of class names + //----------------------- + const std::vector< std::string > & ClassNames(); + + // number of parameters hosted in each data class + //------------------------------------------------ + unsigned numberOfParams(unsigned index); + + // gain dependency of data class parameters + //------------------------------------------ + bool isGainDependent(unsigned index); + + ///////////////////////////////////////// + // don't modify anything from now on! + ///////////////////////////////////////// + + // getClassName : from class index and class pointer + //--------------------------------------------------- + const std::string & getClassName(unsigned index); + template <class T> + const std::string & getClassName(const T* p) { return getClassName(getClassIndex(p)) ; } + + // get class index from class name : + //----------------------------------- + unsigned getClassIndex(std::string className); + + // number of parameters contained in each data class + //--------------------------------------------------- + unsigned numberOfParams(std::string className); + + template <class T> + unsigned numberOfParams(const T* p) { return numberOfParams(getClassIndex(p)) ; } + + // gain dependance of data class + //------------------------------- + bool isGainDependent(std::string className); + + template <class T> + bool isGainDependent(const T* p) { return isGainDependent(getClassIndex(p)) ; } + + // keyword for detector store + //---------------------------- + std::string keyword(const std::string& classname); + std::string keyword(unsigned i); + + template < class T > + std::string keyword(const T* p){ return keyword(getClassName(p)) ; } + +} + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArPedestals2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPedestals2Ntuple.h new file mode 100755 index 000000000000..65789549f33d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPedestals2Ntuple.h @@ -0,0 +1,39 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algrithm produces a column-wise NTuple + out of a LArPedestalDB. Only the finalize + method is used, initalize and execute are empty. + The key of the container is given by the jobOption + 'ContainerKey'. + * @author R. Lafaye + * 04. 3. 2004 + + +*/ + +#ifndef LARPEDESTALS2NTUPLE_H +#define LARPEDESTALS2NTUPLE_H + +#include "LArCalibTools/LArCond2NtupleBase.h" + + +class LArPedestals2Ntuple : public LArCond2NtupleBase +{ + public: + LArPedestals2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArPedestals2Ntuple(); + + //standard algorithm methods + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + private: + + std::string m_contKey; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysCaliTDiffAlg.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysCaliTDiffAlg.h new file mode 100644 index 000000000000..d7361e10a827 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysCaliTDiffAlg.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// Dear emacs, this is -*-c++-*- +#ifndef LARPHYSTCALIDIFFALG_H +#define LARPHYSTCALIDIFFALG_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "LArCalibTools/LArCond2NtupleBase.h" + +class LArPhysCaliTDiffAlg: public LArCond2NtupleBase { + + public: + + LArPhysCaliTDiffAlg(const std::string & name, ISvcLocator * pSvcLocator); + + virtual ~LArPhysCaliTDiffAlg(); + + StatusCode initialize(); + StatusCode execute();// {return StatusCode::SUCCESS;} + // StatusCode stop(); //<< Do the work here + StatusCode finalize() {return StatusCode::SUCCESS;} + + + private: + std::string m_inputContainer; + std::string m_outputContainer; + std::string m_fileName; + + +}; + + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaveFromStdNtuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaveFromStdNtuple.h new file mode 100755 index 000000000000..a48bee1e344e --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaveFromStdNtuple.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARPHYSWAVEFROMSTDNTUPLE_H +#define LARPHYSWAVEFROMSTDNTUPLE_H + +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGateSvc.h" + +#include <vector> +#include <string> + +/** @class LArPhysWaveFromStdNtuple + +This algorithm allows to read wave forms from ntuples and builds a +LArPhysWaveContainer containing the corresponding PhysWave. +Version for standard Ntuple, produced by LArCalibTools algos.... + */ + + +class LArPhysWaveFromStdNtuple : public Algorithm +{ + public: + LArPhysWaveFromStdNtuple(const std::string & name, ISvcLocator * pSvcLocator); + + ~LArPhysWaveFromStdNtuple(); + + //standard algorithm methods + /// implements IAlgorithm::initialize() + StatusCode initialize() ; + + /// implements IAlgorithm::execute() : Does nothing + StatusCode execute() {return StatusCode::SUCCESS;} + + /// IAlgorithm::finalize() : Where the action takes place... + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + /// the first m_skipPoints points of the waveform in the ntuple are skipped + unsigned int m_skipPoints; + /// make a PhysWave with the first m_prefixPoints as zeros + unsigned int m_prefixPoints; + /// list of input ntuple file names + std::vector<std::string> m_root_file_names; + /// ntuple name + std::string m_ntuple_name; + /// key of the PhysWave collection in Storegate + std::string m_store_key; + /// Grouping type. Default is Feedthrough. + std::string m_groupingType; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaveFromTuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaveFromTuple.h new file mode 100755 index 000000000000..800061315342 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaveFromTuple.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARPHYSWAVEFROMTuple_H +#define LARPHYSWAVEFROMTuple_H + +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGateSvc.h" + +#include <vector> +#include <string> + +/** @class LArPhysWaveFromTuple + +This algorithm allows to read wave forms from ntuples and builds a +LArPhysWaveContainer conating the corresponding PhysWave. The root tree should +be named "outfit" and contain the following branches : +- BarEC : int: 0 = Barrel 1 = EndCap + for backwards compatibility, a missing BarEC branch assumes all values to + be Barrel. +- Side (or BarAC) : int: 0 = barrel C 1 = barrel A +- FT : int: feedthrough number (0-31) +- Channel : int: channel number (0-127) +- Slot : int: slot number (1-14) +- tphys : float array: waveform + */ + + +class LArPhysWaveFromTuple : public Algorithm +{ + public: + LArPhysWaveFromTuple(const std::string & name, ISvcLocator * pSvcLocator); + + ~LArPhysWaveFromTuple(); + + //standard algorithm methods + /// implements IAlgorithm::initialize() + StatusCode initialize() ; + + /// implements IAlgorithm::execute() : Does nothing + StatusCode execute() {return StatusCode::SUCCESS;} + + /// IAlgorithm::finalize() : Where the action takes place... + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + /// number of points of the waveform in the ntuple + unsigned int m_NPoints; + /// the first m_skipPoints points of the waveform in the ntuple are skipped + unsigned int m_skipPoints; + /// make a PhysWave with the first m_prefixPoints as zeros + unsigned int m_prefixPoints; + /// time step of the the waveform in the ntuple + double m_deltaT; + /// flag for the PhysWave container + unsigned int m_flag; + /// list of input ntuple file names + std::vector<std::string> m_root_file_names; + /// key of the PhysWave collection in Storegate + std::string m_store_key; + /// Grouping type. Default is Feedthrough. + std::string m_groupingType; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaves2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaves2Ntuple.h new file mode 100644 index 000000000000..4faeafac4d47 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArPhysWaves2Ntuple.h @@ -0,0 +1,52 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algrithm produces a column-wise NTuple out of a + LArPhysWaveContainer + * @author M. Delmastro + * 01. 06. 2004 + * Last update: + * - M. Delmastro: 19/4/2008, migrate to LArCond2NtupleBase, + * added computation and storing of Wave-derived information. + * - W. Lampl: 22/9/2008, introduce common base-class LArWaves2Ntuple + */ + +#ifndef LARPHYSWAVES2NTUPLE_H +#define LARPHYSWAVES2NTUPLE_H +#include "LArCalibTools/LArWaves2Ntuple.h" + +#include "LArRawConditions/LArPhysWaveContainer.h" + +#include "LArRawConditions/LArWaveHelper.h" + +class LArPhysWaves2Ntuple : public LArWaves2Ntuple +{ + + public: + + LArPhysWaves2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArPhysWaves2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + + private: + bool writeEntry(const HWIdentifier chid, const unsigned gain, const LArPhysWave& wave); + + std::vector<std::string> m_keylist ; + std::string m_ntName; + bool m_addCorrUndo, m_applyCorr; + + NTuple::Item<long> m_dac; + NTuple::Item<long> m_gain; + NTuple::Item<long> m_corrUndo; + NTuple::Item<float> m_timeOffset; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArRamps2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArRamps2Ntuple.h new file mode 100755 index 000000000000..e64b032d8a0d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArRamps2Ntuple.h @@ -0,0 +1,46 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algrithm produces a column-wise NTuple + out of a LArRawRampContainer. Only the finalize + method is used, initalize and execute are empty. + The key of the container is given by the jobOption + 'ContainerKey'. + * @author W. Lampl + * 25. 2. 2004 + * Modifications: + * - S. Laplace: 10/04: added a few fields (max sample, etc...) + * - S. Laplace: 03/05: added individual samples (on demand, driven by jobOption) +*/ + +#ifndef LARRAMPS2NTUPLE_H +#define LARRAMPS2NTUPLE_H +#include "LArCalibTools/LArCond2NtupleBase.h" + +class LArRamps2Ntuple : public LArCond2NtupleBase +{ + public: + LArRamps2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArRamps2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + + private: + bool m_rawRamp; + bool m_saveAllSamples; + bool m_applyCorr; + bool m_addCorrUndo; + std::vector<std::string> m_contKey; + std::string m_rampKey; + std::string m_ntName; + bool m_isMC; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.h new file mode 100755 index 000000000000..d4fb7c168442 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.h @@ -0,0 +1,152 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algorithm reads an ascii file and fill a paremeters + structure into the detector store. + * @author M. Fanti + * 20.10.2005 + + +*/ + +#ifndef LARREADPARAMSFROMFILE_H +#define LARREADPARAMSFROMFILE_H +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +//#include "GaudiKernel/SmartDataPtr.h" +#include "CaloIdentifier/CaloIdManager.h" + +#include <fstream> +#include <stdio.h> +#include <string> + +#include "StoreGate/StoreGateSvc.h" +#include "LArIdentifier/LArOnlineID.h" + +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/IToolSvc.h" + +#include "LArTools/LArCablingService.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "CaloIdentifier/LArHEC_ID.h" +#include "CaloIdentifier/LArFCAL_ID.h" + +#include "LArCalibTools/LArParamsProperties.h" +using namespace LArParamsProperties ; + +template <class DATA> +class LArReadParamsFromFile : public Algorithm +{ + public: + LArReadParamsFromFile(const std::string & name, ISvcLocator * pSvcLocator); + ~LArReadParamsFromFile(); + + //standard algorithm methods + StatusCode initialize(); + StatusCode execute() {return StatusCode::SUCCESS;} + StatusCode finalize(){return StatusCode::SUCCESS;} + StatusCode stop(); + + private: + StoreGateSvc* m_detStore; + const LArOnlineID* m_onlineHelper; + const LArEM_ID* m_emId; + const LArHEC_ID* m_hecId; + const LArFCAL_ID* m_fcalId; + LArCablingService *m_larCablingSvc; + // LArConditionsContainerBase::GroupingType m_groupingType ; + int m_groupingType ; + std::string m_groupingName ; + + std::string m_file ; + bool m_useOfflineIdentifier , m_useCalibLines ; + std::string m_chIdType ; + std::string m_customKey; + + DATA * m_dataclass ; + + StatusCode readFile() ; + + // define 'set' method for each foreseen data class: + //--------------------------------------------------- + + StatusCode set(LArCaliPulseParamsComplete* complete, HWIdentifier chid, int gain, std::vector<float> data) { + complete->set(chid, gain, data[0], data[1], data[2], data[3], (short)data[4]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArDetCellParamsComplete* complete, HWIdentifier chid, int gain, std::vector<float> data) { + complete->set(chid, gain, data[0], data[1]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArPhysCaliTdiffComplete* complete, HWIdentifier chid, int gain, std::vector<float> data) { + complete->set(chid, gain, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArTdriftComplete* complete, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + complete->set(chid, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArMphysOverMcalComplete* complete, HWIdentifier chid, int gain, std::vector<float> data) { + complete->set(chid, gain, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArRinjComplete* complete, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + complete->set(chid, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArTshaperComplete* complete, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + complete->set(chid, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArEMEC_CphiComplete* complete, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + complete->set(chid, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArEMEC_HValphaComplete* complete, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + complete->set(chid, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArEMEC_HVbetaComplete* complete, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + complete->set(chid, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArCableLengthComplete* complete, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + complete->set(chid, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArCableAttenuationComplete* complete, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + complete->set(chid, data[0]) ; + return StatusCode::SUCCESS ; + } ; + StatusCode set(LArCaliPulseParamsVsCalib* calib, HWIdentifier chid, int /*gain*/, std::vector<float> data) { + calib->set(chid, data[0], data[1], data[2], data[3], (short)data[4]) ; + return StatusCode::SUCCESS ; + } ; + + // define symLink for all classes + //-------------------------------- + + void do_symLink(const LArCaliPulseParamsComplete* data) { m_detStore->symLink(data,(ILArCaliPulseParams*)data) ; } ; + void do_symLink(const LArDetCellParamsComplete* data) { m_detStore->symLink(data,(ILArDetCellParams*)data) ; } ; + void do_symLink(const LArPhysCaliTdiffComplete* data) { m_detStore->symLink(data,(ILArPhysCaliTdiff*)data) ; } ; + void do_symLink(const LArTdriftComplete* data) { m_detStore->symLink(data,(ILArTdrift*)data) ; } ; + void do_symLink(const LArMphysOverMcalComplete* data) { m_detStore->symLink(data,(ILArMphysOverMcal*)data) ; } ; + void do_symLink(const LArRinjComplete* data) { m_detStore->symLink(data,(ILArRinj*)data) ; } ; + void do_symLink(const LArTshaperComplete* data) { m_detStore->symLink(data,(ILArTshaper*)data) ; } ; + void do_symLink(const LArEMEC_CphiComplete* data) { m_detStore->symLink(data,(ILArEMEC_Cphi*)data) ; } ; + void do_symLink(const LArEMEC_HValphaComplete* data) { m_detStore->symLink(data,(ILArEMEC_HValpha*)data) ; } ; + void do_symLink(const LArEMEC_HVbetaComplete* data) { m_detStore->symLink(data,(ILArEMEC_HVbeta*)data) ; } ; + void do_symLink(const LArCableLengthComplete* data) { m_detStore->symLink(data,(ILArCableLength*)data) ; } ; + void do_symLink(const LArCableAttenuationComplete* data){ m_detStore->symLink(data,(ILArCableAttenuation*)data); } ; + void do_symLink(const LArCaliPulseParamsVsCalib* data) { m_detStore->symLink(data,(ILArCaliPulseParams*)data) ; } ; + +}; + +#include "LArCalibTools/LArReadParamsFromFile.icc" + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.icc b/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.icc new file mode 100755 index 000000000000..99d658679429 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.icc @@ -0,0 +1,371 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "LArRawConditions/LArConditionsContainerBase.h" + +#include <iostream> +#include <sstream> +#include <string> + +template<class DATA> +LArReadParamsFromFile<DATA>::LArReadParamsFromFile(const std::string& name, ISvcLocator* pSvcLocator): + Algorithm(name, pSvcLocator), + m_detStore(0), + m_onlineHelper(0), + m_emId(0), + m_hecId(0), + m_fcalId(0), + m_larCablingSvc(0), + m_groupingType(LArConditionsContainerBase::SingleGroup), + m_useCalibLines(false), + m_dataclass(0) + +{ + // file name to be read + declareProperty("File",m_file="") ; + // choose whether use offline ID (default is online) + declareProperty("UseOfflineIdentifier",m_useOfflineIdentifier=false) ; + // assign grouping type (only for LArConditionsContainer-based classes) + declareProperty("GroupingType",m_groupingName="Unknown") ; + declareProperty("ChannelIdType",m_chIdType="UNKNOWN"); + declareProperty("CustomKey",m_customKey=""); +} + +template <class DATA> +LArReadParamsFromFile<DATA>::~LArReadParamsFromFile() +{} + +template <class DATA> +StatusCode LArReadParamsFromFile<DATA>::initialize() { + MsgStream log(msgSvc(), name()); + + log << MSG::DEBUG << "in initialize" << endreq ; + + if ( m_groupingName == "Unknown" ) { + m_groupingType = LArConditionsContainerBase::Unknown ; + } else if ( m_groupingName == "SingleGroup" ) { + m_groupingType = LArConditionsContainerBase::SingleGroup ; + } else if ( m_groupingName == "SubDetectorGrouping" ) { + m_groupingType = LArConditionsContainerBase::SubDetectorGrouping ; + } else if ( m_groupingName == "FeedThroughGrouping" ) { + m_groupingType = LArConditionsContainerBase::FeedThroughGrouping ; + } else if ( m_groupingName == "ExtendedFThGrouping" ) { + m_groupingType = LArConditionsContainerBase::ExtendedFTGrouping ; + } else if ( m_groupingName == "ExtendedSubDetGrouping" ) { + m_groupingType = LArConditionsContainerBase::ExtendedSubDetGrouping ; + } else { + log << MSG::ERROR << "Grouping type " << m_groupingName << " is not foreseen!" << endreq ; + log << MSG::ERROR << "Only \"Unknown\", \"SingleGroup\", \"SubDetectorGrouping\", \"FeedThroughGrouping\" are allowed" << endreq ; + return StatusCode::FAILURE ; + } + + StatusCode sc=service("DetectorStore",m_detStore); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + const CaloIdManager *caloIdMgr=CaloIdManager::instance() ; + m_emId = caloIdMgr->getEM_ID(); + m_hecId = caloIdMgr->getHEC_ID(); + m_fcalId = caloIdMgr->getFCAL_ID(); + if (!m_emId) { + log << MSG::ERROR << "Could not access lar EM ID helper" << endreq; + return StatusCode::FAILURE; + } + if (!m_hecId) { + log << MSG::ERROR << "Could not access lar HEC ID helper" << endreq; + return StatusCode::FAILURE; + } + if (!m_fcalId) { + log << MSG::ERROR << "Could not access lar FCAL ID helper" << endreq; + return StatusCode::FAILURE; + } + + sc = m_detStore->retrieve(m_onlineHelper, "LArOnlineID"); + if (sc.isFailure()) { + log << MSG::ERROR << "Could not get LArOnlineID helper" << endreq; + return sc; + } + + // translate offline ID into online ID + ISvcLocator* svcLoc = Gaudi::svcLocator( ); + IToolSvc* toolSvc; + sc = svcLoc->service( "ToolSvc",toolSvc ); + if(sc.isSuccess()) { + sc = toolSvc->retrieveTool("LArCablingService",m_larCablingSvc); + if(sc.isFailure()){ + log << MSG::ERROR << "Could not retrieve LArCablingService Tool" << endreq; + return StatusCode::FAILURE; + } + } else { + log << MSG::ERROR << "Could not retrieve ToolSvc" << endreq; + return StatusCode::FAILURE; + } + + if ( m_chIdType == std::string("UNKNOWN") ) { + // use jO specification (default=false) for m_useOfflineIdentifier + // and default=false for m_useCalibLines + m_useCalibLines = false ; + } else if ( m_chIdType == std::string("OfflineID") ) { + m_useOfflineIdentifier = true ; + m_useCalibLines = false ; + } else if ( m_chIdType == std::string("OnlineID") ) { + m_useOfflineIdentifier = false ; + m_useCalibLines = false ; + } else if ( m_chIdType == std::string("OnlineCalibID") ) { + m_useOfflineIdentifier = false ; + m_useCalibLines = true ; + } else { + log << MSG::ERROR << "ChannelIdType=" << m_chIdType << " is not valid!" << endreq ; + log << MSG::ERROR << "Allowed options are: OfflineID, OnlineID, OnlineCalibID" << endreq ; + return StatusCode::FAILURE ; + } + + if( m_useOfflineIdentifier ) { + log << MSG::INFO << "Reading parameters using *** offline identifiers ***" << endreq ; + } else if ( m_useCalibLines ) { + log << MSG::INFO << "Reading parameters for *** calibration lines ***" << endreq ; + } else { + log << MSG::INFO << "Reading parameters using *** online identifiers ***" << endreq ; + } + + return StatusCode::SUCCESS; +} + + +template <class DATA> +StatusCode LArReadParamsFromFile<DATA>::stop() +{ + MsgStream log(msgSvc(), name()); + StatusCode sc ; + + log << MSG::DEBUG << "in stop" << endreq ; + + if ( m_file == std::string("") ) { + log << MSG::ERROR << "Input file name was not specified!" << endreq ; + return StatusCode::FAILURE ; + } + + m_dataclass = new DATA ; + if ( m_groupingType != LArConditionsContainerBase::Unknown ) { + m_dataclass->setGroupingType( static_cast<LArConditionsContainerBase::GroupingType>(m_groupingType) ) ; + } + sc = m_dataclass->initialize() ; + + if ( sc.isFailure() ) { + log << MSG::ERROR << "Could not initialize data object - exit!" << endreq ; + return sc ; + } + + std::string classname = LArParamsProperties::getClassName(m_dataclass) ; + std::string key = LArParamsProperties::keyword( classname ) ; + if ( m_customKey != "") key = m_customKey; + + sc = readFile() ; + if ( sc.isFailure() ) { + log << MSG::ERROR << "Could not upload " << classname << " from file" << m_file << endreq ; + return StatusCode::FAILURE ; + } else { + log << MSG::INFO << "Object " << classname << " successfully uploaded from file " << m_file << endreq ; + } + sc = m_detStore->record(m_dataclass,key) ; + if ( sc.isFailure() ) { + log << MSG::ERROR << "Could not record " << classname << " into detStore with key " << key << endreq ; + return StatusCode::FAILURE ; + } else { + log << MSG::INFO << "Object " << classname << " recorded into detStore with key " << key << endreq ; + } + do_symLink(m_dataclass) ; + log << MSG::INFO << "Object " << classname << " symLinked to its abstract interface" << endreq ; + + log << MSG::INFO << "finished!" << endreq; + return StatusCode::SUCCESS; +}// end stop-method. + + +template <class DATA> +StatusCode LArReadParamsFromFile<DATA>::readFile() { + // File format: + // for online ID: barrel_ec posneg FT slot channel parameters... + // for offline ID: det subdet barrel_ec layer region eta phi parameters... + MsgStream log(msgSvc(), name()); + int det, subdet, barrel_ec, posneg, ft, slot, channel, region, layer, eta, phi ; + std::vector<float> pRead ; + HWIdentifier chID ; + + std::ifstream f(m_file.c_str()) ; // open input file + if ( ! f.good() ) { + log << MSG::ERROR << "Could not open file " << m_file << ", are you sure it exists??" << endreq ; + return StatusCode::FAILURE ; + } + log << MSG::DEBUG << "File " << m_file << " opened" << endreq ; + + unsigned nrec = 0 ; + unsigned npar = LArParamsProperties::numberOfParams(m_dataclass) ; + log << MSG::DEBUG << "The file should contain " << npar << " parameters per record" << endreq ; + + while (1) { // read through the file records + + if ( f.eof() ) break ; + std::string s ; + getline(f,s) ; + std::istringstream buffer(s) ; + log << MSG::VERBOSE << "*** Record: '" << s << "'" << endreq ; + + if ( s == std::string("") ) continue ; // skip empty records + + bool good_chID = true ; + + if ( m_useOfflineIdentifier ) { // get HWIdentifier from offline "coordinates" + + buffer >> det ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'det' field for offline identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> subdet ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'subdet' field for offline identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> barrel_ec ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'barrel_ec' field for offline identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> layer ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'layer' field for offline identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> region ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'region' field for offline identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> eta ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'eta' field for offline identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> phi ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'phi' field for offline identifier" << endreq ; + continue ; // skip and go to next record + } + log << MSG::VERBOSE << "Det=" << det << " SubDet=" << subdet << " BarrelEC=" << barrel_ec + << " Sampling=" << layer << " Region=" << region << " Eta=" << eta << " Phi=" << phi << endreq ; + good_chID = true ; + if ( det != 4 ) { + log << MSG::WARNING << "Det=" << det << " is not LArCalorimeter -- cannot handle it!" << endreq ; + good_chID = false ; + } else { + Identifier id ; + if ( subdet == 1 ) { // LArEM + id = m_emId->channel_id(barrel_ec,layer,region,eta,phi) ; + log << MSG::VERBOSE << "LAr EM Identifier=" << id << endreq ; + } else if ( subdet == 2 ) { // LArHEC + id = m_hecId->channel_id(barrel_ec,layer,region,eta,phi) ; + log << MSG::VERBOSE << "LAr HEC Identifier=" << id << endreq ; + } else if ( subdet == 3 ) { // LArFCAL + // id = m_fcalId->channel_id(det,layer,region,eta,phi) ; + // log << MSG::VERBOSE << "LAr FCAL Identifier=" << id << endreq ; + log << MSG::WARNING << "Subdet=" << subdet + << " is LArFCAL -- conversion to online channel not implemented yet!" << endreq ; + good_chID = false ; + } else { + log << MSG::WARNING << "Subdet=" << subdet << " is unknown -- cannot handle it!" << endreq ; + good_chID = false ; + } + if ( good_chID ) { + try { + chID = m_larCablingSvc->createSignalChannelID(id) ; + } catch ( LArID_Exception & except ) { + log << MSG::WARNING << "Could not get HWId for offline Id " << id << endreq ; + good_chID = false ; + } + } + } + if ( ! good_chID ) continue ; // skip and go to next record + + } else { // get HWIdentifier from online "coordinates" + + buffer >> barrel_ec ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'barrel_ec' field for online identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> posneg ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'posneg' field for online identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> ft ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'feedthrough' field for online identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> slot ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'slot' field for online identifier" << endreq ; + continue ; // skip and go to next record + } + buffer >> channel ; + if ( buffer.fail() ) { + log << MSG::WARNING << "Could not read 'channel' field for online identifier" << endreq ; + continue ; // skip and go to next record + } + if ( m_useCalibLines ) { + chID = m_onlineHelper->calib_channel_Id(barrel_ec,posneg,ft,slot,channel) ; + } else { + chID = m_onlineHelper->channel_Id(barrel_ec,posneg,ft,slot,channel) ; + } + + } // here the HWIdentifier is obtained! + + if ( ! good_chID ) continue ; // skip and go to next record + + // + // get parameters + // + pRead.resize(npar) ; + const float defaultValue = -999 ; + for ( unsigned i=0 ; i<npar ; i++ ) pRead[i] = defaultValue ; + for ( unsigned i=0 ; i<npar ; i++ ) { + //if ( buffer.eof() ) { + //log << MSG::DEBUG << "end-of-record reached when reading parameter " << i << " of channel " << chID.get_compact() << endreq ; + //break ; + //} + buffer >> pRead[i] ; + if ( buffer.fail() ) { + log << MSG::WARNING << "failure when reading parameter " << i << " of channel " << chID.get_compact() << endreq ; + break ; + } + } + // store into parameters vector + log << MSG::VERBOSE << "read ch=" << chID.get_compact() ; + for ( unsigned i=0 ; i<npar ; i++ ) log << " par[" << i << "]=" << pRead[i] ; + log << endreq ; + for ( unsigned gain=0 ; gain<3 ; gain++ ) { + try { + StatusCode sc = set(m_dataclass,chID,gain,pRead) ; + if ( sc.isFailure() ) { + log << MSG::WARNING << "Could not set parameters for ch=" << chID.get_compact() << " gain=" << gain << endreq ; + } + } catch ( LArID_Exception & except ) { + log << MSG::WARNING << "Bad HWId " << chID << endreq ; + good_chID = false ; + } + } + + nrec ++ ; + + } // end of while(1) i.e. the loop through all file records + + log << MSG::DEBUG << "end of file reached, read " << nrec << " records" << endreq ; + return StatusCode::SUCCESS ; +} diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArShape2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArShape2Ntuple.h new file mode 100644 index 000000000000..d78ac5227031 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArShape2Ntuple.h @@ -0,0 +1,43 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/* + + This algorithm produces a column-wise NTuple out of a LArShapeContainer. + Only the finalize method is used, initalize and execute are empty. + The key of the container is given by the jobOption 'ContainerKey'. + + * @author M. Delmastro + * 19. 6. 2008 + +*/ + +#ifndef LARShape2NTUPLE_H +#define LARShape2NTUPLE_H +#include "LArCalibTools/LArCond2NtupleBase.h" + +class LArShape2Ntuple : public LArCond2NtupleBase { + public: + + LArShape2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArShape2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + + + private: + std::string m_contKey; + std::string m_ntName; + std::string m_ntFile; + bool m_isMC; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArWFParams2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArWFParams2Ntuple.h new file mode 100755 index 000000000000..9d9d69440977 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArWFParams2Ntuple.h @@ -0,0 +1,44 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algorithm produces a column-wise NTuple + out of a LArWFParamsContainer. Only the finalize + method is used, initalize and execute are empty. + The key of the container is given by the jobOption + 'ContainerKey'. + * @author M. Fanti + * 27. 2. 2004 + + +*/ + +#ifndef LARWFPARAMS2NTUPLE_H +#define LARWFPARAMS2NTUPLE_H + +#include "LArCalibTools/LArCond2NtupleBase.h" + +class LArWFParams2Ntuple : public LArCond2NtupleBase +{ + public: + LArWFParams2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArWFParams2Ntuple(); + + //standard algorithm methods + StatusCode initialize(); + StatusCode execute() {return StatusCode::SUCCESS;} + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + + private: + + // bool m_useContainers , m_useComplete , + bool m_dumpCaliPulseParams , m_dumpDetCellParams , m_dumpPhysCaliTdiff , m_dumpTdrift, m_dumpOFCBin ; + std::string m_caliPulseParamsKey, m_detCellParamsKey, m_physCaliTDiffKey, m_tdriftKey, m_ofcBinKey; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArWaves2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArWaves2Ntuple.h new file mode 100755 index 000000000000..e577ba2aa77a --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArWaves2Ntuple.h @@ -0,0 +1,60 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** Common base-class for wave-to-ntuple algorithms. + * Derives from LArCond2NtupleBase and is a base-class + * for LArCaliWave2Ntuple and LArPhysWave2Ntuple. + * @author W. Lampl + * @author M. Delmastro + * Sept 22, 2008 + */ + +#ifndef LARWAVES2NTUPLE_H +#define LARWAVES2NTUPLE_H +#include "LArCalibTools/LArCond2NtupleBase.h" +#include "LArRawConditions/LArWaveHelper.h" + +//class LArWaveHelper; +class LArWaveCumul; + +class LArWaves2Ntuple : public LArCond2NtupleBase +{ + + public: + + StatusCode initialize(); + + LArWaves2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArWaves2Ntuple(); + + bool fillWave(const HWIdentifier chid, const LArWaveCumul& wave); //returns true if connected + + private: + bool m_saveDerivedInfo; + + NTuple::Item<long> m_flag; + NTuple::Item<long> m_timeIndex; + NTuple::Item<double> m_dt; + NTuple::Array<double> m_time; + NTuple::Array<double> m_ampliPulse; + NTuple::Array<double> m_errorPulse; + NTuple::Array<long> m_triggers; + + // derived information + NTuple::Item<double> m_tmaxAmp; + NTuple::Item<double> m_maxAmp; + NTuple::Item<double> m_baseline; + NTuple::Item<double> m_posLobe; + NTuple::Item<double> m_rT0; + NTuple::Item<double> m_width; + +protected: + LArWaveHelper m_waveHelper; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArfSampl2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArfSampl2Ntuple.h new file mode 100644 index 000000000000..0e35a193b29c --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArfSampl2Ntuple.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARFSAMPL2NTUPLE_H +#define LARFSAMPL2NTUPLE_H + +#include "LArCalibTools/LArCond2NtupleBase.h" + + +class LArfSampl2Ntuple : public LArCond2NtupleBase +{ + public: + LArfSampl2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LArfSampl2Ntuple(); + + //standard algorithm methods + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + private: + + std::string m_contKey; +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LAruA2MeV2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LAruA2MeV2Ntuple.h new file mode 100755 index 000000000000..8a26014bb59b --- /dev/null +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LAruA2MeV2Ntuple.h @@ -0,0 +1,37 @@ +//Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** This algrithm produces a column-wise NTuple + out of a LAruA2MeVDB. Only the finalize + method is used, initalize and execute are empty. + The key of the object is given by the jobOption + 'ContainerKey'. + * @author Walter Lampl + * 11. 8. 2005 + +*/ + +#ifndef LARUA2MEV2NTUPLE_H +#define LARUA2MEV2NTUPLE_H +#include "LArCalibTools/LArCond2NtupleBase.h" + +class LAruA2MeV2Ntuple : public LArCond2NtupleBase +{ + public: + LAruA2MeV2Ntuple(const std::string & name, ISvcLocator * pSvcLocator); + ~LAruA2MeV2Ntuple(); + + //standard algorithm methods + virtual StatusCode stop(); + StatusCode finalize(){return StatusCode::SUCCESS;} + private: + + std::string m_uA2MeVKey, m_DAC2uAKey; + +}; + +#endif diff --git a/LArCalorimeter/LArCalibTools/cmt/requirements b/LArCalorimeter/LArCalibTools/cmt/requirements new file mode 100755 index 000000000000..017797879005 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/cmt/requirements @@ -0,0 +1,50 @@ +package LArCalibTools + +author Marco Delmastro <Marco.Delmastro@cern.ch> + +use AtlasPolicy AtlasPolicy-* +use GaudiInterface GaudiInterface-* External +use StoreGate StoreGate-* Control +use AthenaBaseComps AthenaBaseComps-* Control +use CaloIdentifier CaloIdentifier-* Calorimeter +#use CaloDetDescr CaloDetDescr-* Calorimeter +use LArElecCalib LArElecCalib-* LArCalorimeter +use LArIdentifier LArIdentifier-* LArCalorimeter +use LArRawConditions LArRawConditions-* LArCalorimeter +use LArTools LArTools* LArCalorimeter +use LArRecConditions LArRecConditions-* LArCalorimeter + + +private +use AthenaKernel AthenaKernel* Control +use AtlasROOT AtlasROOT-* External +use LArCondUtils LArCondUtils-* LArCalorimeter +use LArRawEvent LArRawEvent-* LArCalorimeter +use CaloCondBlobObjs CaloCondBlobObjs-* Calorimeter +use AthenaPoolUtilities AthenaPoolUtilities-* Database/AthenaPOOL +use AtlasCORAL AtlasCORAL-* External +use LArCOOLConditions LArCOOLConditions-* LArCalorimeter + +apply_tag ROOTMathLibs +apply_tag ROOTGraphicsLibs +end_private + +library LArCalibTools *.cxx components/*.cxx + +apply_pattern component_library + +apply_pattern declare_joboptions files="*.py" + + +# to be remove ! +#apply_pattern declare_runtime files="*.dat" +#apply_pattern dual_use_library files="*.cxx" +#apply_pattern declare_joboptions files="*.py" + + +# +# build with debug symbols +# +#private +#macro cppdebugflags '$(cppdebugflags_s)' +#macro_remove componentshr_linkopts "-Wl,-s" diff --git a/LArCalorimeter/LArCalibTools/doc/mainpage.h b/LArCalorimeter/LArCalibTools/doc/mainpage.h new file mode 100644 index 000000000000..11cdf25914db --- /dev/null +++ b/LArCalorimeter/LArCalibTools/doc/mainpage.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** +@mainpage LArCalibTools +@author Marco.Delmastro@cern.ch + +@section LArCalibToolsIntro Introduction + +This package containes the algorithms to dump the LAr calibration constants +into ROOT TTrees to be used for debugging, displaying, monitoring and analysis +purposes. + +@todo + + - Uniform TTree variables names/meaning + - Support for HEC and FCAL is to be added to + - LArAverages2Ntuple + - LArMphysOverMcalFromTuple + - LArParams2Ntuple + - LArPhysWaveFromTuple + - LArWFParams2Ntuple + - LArShape2PhysWave is to be renamed and possibly moved to LArCalibUtils. + - Cleanup/update of the exaple jobOptions is needed. + - All the algorithms need to be migrated to configurable. + - Doxygen description of classes and methods is missing. + +@section LArCalibToolsOverview Class Overview + + The LArCalibTools package contains of following classes: + + - LArAutoCorr2Ntuple + - LArAverages2Ntuple + - LArMphysOverMcalFromTuple + - LArOFC2Ntuple + - LArParams2Ntuple + - LArParamsProperties + - LArPedestals2Ntuple + - LArPhysWaveFromTuple + - LArRamps2Ntuple + - LArReadParamsFromFile + - LArShape2PhysWave + - LAruA2MeV2Ntuple + - LArWaves2Ntuple + - LArWFParams2Ntuple + +@ref used_LArCalibTools + +@ref requirements_LArCalibTools + +*/ + +/** +@page used_LArCalibTools Used Packages +@htmlinclude used_packages.html +*/ + +/** +@page requirements_LArCalibTools Requirements +@include requirements +*/ + diff --git a/LArCalorimeter/LArCalibTools/share/CaloCondBlob2Ntuple.py b/LArCalorimeter/LArCalibTools/share/CaloCondBlob2Ntuple.py new file mode 100644 index 000000000000..dd552c0c8b86 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/CaloCondBlob2Ntuple.py @@ -0,0 +1,86 @@ +# you could specify 'sqlitefile' for reading the local file +# and 'tag' to specify the folder level tag to dump + +if not 'Folder' in dir(): + Folder="/LAR/CellCorrOfl/EnergyCorr" + +if not 'output' in dir(): + output="CellCondBlob.root" + +if not 'RunNumber' in dir(): + RunNumber=1000000000 + +if not 'GlobalTag' in dir(): + GlobalTag='COMCOND-BLKPA-006-06' + +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +from AthenaCommon.GlobalFlags import GlobalFlags +#GlobalFlags.DetGeo.set_commis() +#GlobalFlags.Luminosity.set_zero() +#GlobalFlags.DataSource.set_data() +#GlobalFlags.InputFormat.set_bytestream() + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DataSource="data" +globalflags.InputFormat="bytestream" + + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-18-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) +svcMgr.IOVDbSvc.GlobalTag=GlobalTag +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) +#include("LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py") + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = RunNumber + + +from LArCalibTools.LArCalibToolsConf import CaloCondBlob2Ntuple +theCaloCondBlobs2Ntuple=CaloCondBlob2Ntuple() +theCaloCondBlobs2Ntuple.Folder="/LAR/CellCorrOfl/EnergyCorr" +theCaloCondBlobs2Ntuple.AddFEBTempInfo=False +theCaloCondBlobs2Ntuple.AddBadChannelInfo=False +topSequence+=theCaloCondBlobs2Ntuple + +if 'tag' in dir(): + tagstring="<tag>"+tag+"</tag>" +else: + tagstring="" +if 'sqlitefile' in dir(): + conddb.addFolder("",Folder+"<db>sqlite://;schema="+sqlitefile+";dbname=COMP200</db>"+tagstring) +else: + conddb.addFolder('LAR_OFL',Folder+tagstring) + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+output+"' OPT='NEW'" ] + + +#from GaudiSvc.GaudiSvcConf import THistSvc +#svcMgr+=THistSvc() +#svcMgr.THistSvc.Output = [ "FILE1 DATAFILE='CellGroup.root' OPT='RECREATE'" ] + +#svcMgr.DetectorStore.Dump=True +#svcMgr.MessageSvc.OutputLevel = DEBUG + diff --git a/LArCalorimeter/LArCalibTools/share/ConvertDSPThrePooltoCool.py b/LArCalorimeter/LArCalibTools/share/ConvertDSPThrePooltoCool.py new file mode 100644 index 000000000000..6d1d325889c9 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/ConvertDSPThrePooltoCool.py @@ -0,0 +1,113 @@ +if 'inputfolder' not in dir(): + inputfolder='/LAR/Configuration/DSPThreshold/Templates' + +if 'inputtag' not in dir(): + inputtag='Qt0-samp0' + +if 'outputtag' not in dir(): + outputtag='Qt0-samp0' + +if 'outputfolder' not in dir(): + outputfolder="/LAR/Configuration/DSPThresholdFlat/Templates" + +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector +from string import split,join +from time import time +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DataSource="data" +globalflags.InputFormat="bytestream" + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-20-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) +svcMgr.IOVDbSvc.GlobalTag="LARCALIB-000-02" +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = 500000 +#svcMgr.EventSelector.RunNumber = 2147483647 +svcMgr.EventSelector.InitialTimeStamp=int(time()) +dbname="<db>COOLOFL_LAR/COMP200</db>" + +conddb.addFolder("LAR_OFL","/LAR/BadChannelsOfl/BadChannels<key>/LAR/BadChannels/BadChannels</key>") +conddb.addFolder("LAR_OFL","/LAR/BadChannelsOfl/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>") +conddb.addFolder("","/LAR/IdentifierOfl/OnOffIdMap_SC<db>COOLOFL_LAR/OFLP200</db><tag>LARIdentifierOflOnOffIdMap_SC-000</tag>") + +#conddb.addFolder("","/LAR/ElecCalibOnl/Pedestal<db>COOLONL_LAR/COMP200</db>") + +intag=join(inputfolder.split("/"),'')+"-"+inputtag +conddb.addFolder("","/LAR/Configuration/DSPThreshold/Templates<db>COOLONL_LAR/COMP200</db><tag>"+intag+"</tag>") + +from LArCalibTools.LArCalibToolsConf import LArCompleteToFlat +theLArCompleteToFlat=LArCompleteToFlat() +theLArCompleteToFlat.ForceStop=False +theLArCompleteToFlat.doDSP=True +topSequence+=theLArCompleteToFlat + + +#from LArCalibTools.LArCalibToolsConf import LArDSPThresholds2Ntuple +#LArDSPThresholds2Ntuple=LArDSPThresholds2Ntuple("LArDSPThresholds2Ntuple") +#LArDSPThresholds2Ntuple.DumpFlat=True +#LArDSPThresholds2Ntuple.DumpFlat=True +#topSequence+=LArDSPThresholds2Ntuple + + +svcMgr.PoolSvc.ReadCatalog += ['xmlcatalog_file:'+'/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml'] + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='flatDSPThresholds.root' OPT='NEW'" ] + + + +outtagspec=join(outputfolder.split("/"),'')+"-"+outputtag +folderspec="AthenaAttributeList#"+outputfolder +#outtagspec=join(outputfolder.split("/"),'')+"-"+outputtag +#folderspec="CondAttrListCollection#"+outputfolder + +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg +OutputConditionsAlg=OutputConditionsAlg("OutputConditionsAlg","dummy.pool.root", + [folderspec],[outtagspec], + True) + + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder = False +#svcMgr.IOVRegistrationSvc.OverrideNames += [ "Pedestal","PedestalRMS","OFCa" ,"OFCb" ,"TimeOffset","RampVec","Shape","ShapeDer","HVScaleCorr","MphysOverMcal","DAC2uA","uA2MeV"] +svcMgr.IOVRegistrationSvc.OverrideNames += [ "tQThr", "samplesThr", "trigSumThr"] +#svcMgr.IOVRegistrationSvc.OverrideNames += [ "Pedestal", "PedestalRMS"] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; +svcMgr.IOVDbSvc.dbConnection = "sqlite://;schema=DSP_test.db;dbname=COMP200" + + +svcMgr.DetectorStore.Dump=True +svcMgr.StoreGateSvc.Dump = True +svcMgr.MessageSvc.OutputLevel = DEBUG +svcMgr.IOVDbSvc.DBInstance="" + diff --git a/LArCalorimeter/LArCalibTools/share/ConvertPoolToCoolInline.py b/LArCalorimeter/LArCalibTools/share/ConvertPoolToCoolInline.py new file mode 100644 index 000000000000..f31567d67299 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/ConvertPoolToCoolInline.py @@ -0,0 +1,134 @@ +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector +from string import split,join +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DataSource="data" +globalflags.InputFormat="bytestream" +globalflags.DatabaseInstance="COMP200" + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-20-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) +svcMgr.IOVDbSvc.GlobalTag="COMCOND-BLKPA-006-07" +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +theApp.EvtMax = 1 +#svcMgr.EventSelector.RunNumber = 210308 +svcMgr.EventSelector.RunNumber = 2147483647 +conddb.addFolder("LAR_OFL","/LAR/BadChannelsOfl/BadChannels<key>/LAR/BadChannels/BadChannels</key>") +conddb.addFolder("LAR_OFL","/LAR/BadChannelsOfl/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>") + + +conddb.addFolder("","/LAR/ElecCalibOnl/uA2MeV<db>COOLONL_LAR/COMP200</db>") +conddb.addFolder("","/LAR/ElecCalibOnl/DAC2uA<db>COOLONL_LAR/COMP200</db>") +conddb.addFolder("","/LAR/ElecCalibOnl/MphysOverMcal<db>COOLONL_LAR/COMP200</db>") +conddb.addFolder("","/LAR/ElecCalibOnl/HVScaleCorr<db>COOLONL_LAR/COMP200</db>") +conddb.addFolder("","/LAR/ElecCalibOnl/Pedestal<db>COOLONL_LAR/COMP200</db>") +conddb.addFolder("","/LAR/ElecCalibOnl/Ramp<db>COOLONL_LAR/COMP200</db>") +conddb.addFolder("","/LAR/ElecCalibOnl/OFC<db>COOLONL_LAR/COMP200</db>") +conddb.addFolder("","/LAR/ElecCalibOnl/Shape<db>COOLONL_LAR/COMP200</db>") + + +from LArCalibTools.LArCalibToolsConf import LArCompleteToFlat +theLArCompleteToFlat=LArCompleteToFlat() + +theLArCompleteToFlat.uA2MeVInput="LAruA2MeV" +theLArCompleteToFlat.DAC2uAVInput="LArDAC2uA" +theLArCompleteToFlat.HVScaleCorrInput="LArHVScaleCorr" +theLArCompleteToFlat.PedestalInput="Pedestal" +theLArCompleteToFlat.RampInput="LArRamp" +theLArCompleteToFlat.MphysOverMcalInput="LArMphysOverMcal" +theLArCompleteToFlat.OFCInput="LArOFC" +theLArCompleteToFlat.ShapeInput="LArShape" +#theLArCompleteToFlat.DSPThresholdsInput="LArDSPThresholds" + +topSequence+=theLArCompleteToFlat + + +## from LArCalibTools.LArCalibToolsConf import LArPedestals2Ntuple +## LArPedestals2Ntuple=LArPedestals2Ntuple("LArPedestals2Ntuple") +## LArPedestals2Ntuple.AddFEBTempInfo=False +## LArPedestals2Ntuple.ContainerKey="PedestalFlat" +## topSequence+=LArPedestals2Ntuple + +## from LArCalibTools.LArCalibToolsConf import LArOFC2Ntuple +## LArOFCs2Ntuple=LArOFC2Ntuple("LArOFCs2Ntuple") +## LArOFCs2Ntuple.AddFEBTempInfo=False +## LArOFCs2Ntuple.ContainerKey="OFCFlat" +## topSequence+=LArOFCs2Ntuple + + + + + +svcMgr.PoolSvc.ReadCatalog += ['xmlcatalog_file:'+'/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml'] + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='flatPedestalOFC.root' OPT='NEW'" ] + + +folderlist=("/LAR/ElecCalibFlat/uA2MeV", + "/LAR/ElecCalibFlat/DAC2uA", + "/LAR/ElecCalibFlat/MphysOverMcal", + "/LAR/ElecCalibFlat/HVScaleCorr", + "/LAR/ElecCalibFlat/Pedestal", + "/LAR/ElecCalibFlat/Ramp", + "/LAR/ElecCalibFlat/OFC", + "/LAR/ElecCalibFlat/Shape", + ) + +folderspec=[] +tagspec=[] +for f in folderlist: + folderspec.append("CondAttrListCollection#"+f) + tagspec.append("".join(f.split("/"))+"-00") + pass + + +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg +OutputConditionsAlg=OutputConditionsAlg("OutputConditionsAlg","dummy.pool.root", + #["CondAttrListCollection#/LAR/ElecCalibFlat/Pedestal","CondAttrListCollection#/LAR/ElecCalibFlat/OFC",], + #["testped","testofc"], + folderspec,[], + True) + + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder = True +svcMgr.IOVRegistrationSvc.userTags = False + +svcMgr.IOVRegistrationSvc.OverrideNames += [ "Pedestal","PedestalRMS","OFCa" ,"OFCb" ,"TimeOffset","RampVec","Shape","ShapeDer","HVScaleCorr","MphysOverMcal","DAC2uA","uA2MeV"] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; +svcMgr.IOVDbSvc.dbConnection = "sqlite://;schema=allConstantsSV_test.db;dbname=COMP200" + + +#svcMgr.DetectorStore.Dump=True +svcMgr.MessageSvc.OutputLevel = INFO + +svcMgr.IOVDbSvc.DBInstance="" diff --git a/LArCalorimeter/LArCalibTools/share/LArAverages2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArAverages2Ntuple_jobOptions.py new file mode 100755 index 000000000000..f3bcafcc8666 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArAverages2Ntuple_jobOptions.py @@ -0,0 +1,85 @@ +# ******************************************************************* +# JobOptions file to produce ramps +# +# 15/08/2005 S. Laplace (laplace@lapp.in2p3.fr) +# ******************************************************************* + +include( "ByteStreamCnvSvc/TBEventSelector_jobOptions.py" ) +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOn() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DetGeo.set_atlas() +GlobalFlags.DataSource.set_data() +include( "AthenaCommon/Atlas.UnixStandardJob.py" ) + + + +theApp.Dlls += [ "LArByteStream"] + +ByteStreamInputSvc = Service( "ByteStreamInputSvc" ) + +ByteStreamAddressProviderSvc = Service( "ByteStreamAddressProviderSvc" ) +ByteStreamAddressProviderSvc.TypeNames += ["LArCalibDigitContainer/MEDIUM"] +ByteStreamAddressProviderSvc.TypeNames += ["LArCalibDigitContainer/HIGH"] + +# Three input files (for H8): accordion HG, accordion MG, PS (HG only) +#ByteStreamInputSvc.FullFileName += ["/castor/cern.ch/atlas/testbeam/lar/2004/daq_ROS-41_LargCalib_0005134_file01.data"] +ByteStreamInputSvc.FullFileName += ["/castor/cern.ch/atlas/testbeam/lar/2004/daq_ROS-41_LargCalib_0005135_file01.data"] +#ByteStreamInputSvc.FullFileName += ["/castor/cern.ch/atlas/testbeam/lar/2004/daq_ROS-41_LargCalib_0005136_file01.data"] + + +include( "LArDetMgrDetDescrCnv/LArDetMgrDetDescrCnv_H8_joboptions.py" ) + +DetDescrCnvSvc = Service( "DetDescrCnvSvc" ) +DetDescrCnvSvc.DoIdChecks + +ToolSvc = Service( "ToolSvc" ) +ToolSvc.LArRoI_Map.Print=FALSE + +include ("LArConditionsCommon/LArConditionsCommon_H8_jobOptions.py") +IOVDbSvc.Folders += ["/LAR/LArElecCalibH8/LArCalibParams<tag>LArCalibParams-"+LArTB04FolderTag_Calib+"</tag>"+LArH8DBConnection] + +theApp.Dlls += ["LArRawUtils"] +theApp.Dlls += ["LArTools"] +theApp.Dlls += ["LArCalibUtils"] +theApp.Dlls += ["LArCalibTools"] +theApp.Dlls += ["LArRecUtils"] +theApp.Dlls += ["LArROD"] + +theApp.topAlg+=["LArCalibDigitsAccumulator"] +LArCalibDigitsAccumulator=Algorithm("LArCalibDigitsAccumulator") +LArCalibDigitsAccumulator.KeyList+=["HIGH"] +LArCalibDigitsAccumulator.KeyList+=["MEDIUM"] + +# output ntuples +theApp.topAlg+=["LArAverages2Ntuple/averageshigh"] +averageshigh=Algorithm("averageshigh") +averageshigh.containerKey="HIGH" + +theApp.topAlg+=["LArAverages2Ntuple/averagesmedium"] +averagesmedium=Algorithm("averagesmedium") +averagesmedium.containerKey="MEDIUM" + +theApp.Dlls += [ "RootHistCnv" ] +theApp.HistogramPersistency = "ROOT" +NTupleSvc = Service( "NTupleSvc" ) + +NTupleSvc.Output = [ "FILE1 DATAFILE='LArAverages.root' OPT='NEW'" ] + + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel=ERROR + +MessageSvc.OutputLevel=INFO +#MessageSvc.OutputLevel=DEBUG +MessageSvc.defaultLimit=1000000; + +#StoreGateSvc=Service("StoreGateSvc"); +#StoreGateSvc.dump=TRUE + diff --git a/LArCalorimeter/LArCalibTools/share/LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py new file mode 100755 index 000000000000..ea1ca861761f --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py @@ -0,0 +1,163 @@ +########################################################################### +# +# LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py dumps the conntet of a +# CaliWave + OFC POOL files (from standard AP processing) +# to ROOT TTree. +# +# Author: Pavol Strizenec (pavol @ mail.cern.ch) +# +# Created: Nov. 2010 by merging existing Wave and OFC 2 Ntuple jO +# +########################################################################### + +import commands + +CWOFC2NtupleLog = logging.getLogger( "CWOFC2NtupleLog" ) + +if not 'PoolFileName' in dir(): + CWOFC2NtupleLog.fatal("Please setup the input POOL file ('PoolFileName')!") + theApp.exit(-1) + +if not 'WaveType' in dir(): + WaveType = "Cali" # (Cali, Phys) + +if not 'ContainerKey' in dir(): + if (WaveType == "Cali"): + ContainerKey = "LArCaliWave" + if (WaveType == "Phys"): + ContainerKey = "LArPhysWave" + +if not 'DACSaturSkip' in dir(): + DACSaturSkip = False + +if not 'SaveDerivedInfo' in dir(): + SaveDerivedInfo = True + +if not 'SaveJitter' in dir(): + SaveJitter = True + +if not 'CaliWaveRootFileName' in dir(): + CaliWaveRootFileName = "LArWaves2Ntuple_POOL.root" + +if not 'OFCRootFileName' in dir(): + OFCRootFileName = "LArWaves2Ntuple_POOL.root" + +if not 'RunNumber' in dir(): + RunNumber = 165983 + +########################################################################### + +#include("LArConditionsCommon/LArMinimalSetup.py") + +include("LArCalibProcessing/LArCalib_Flags.py") + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +########################################################################### + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200;" + #DBConnectionCOOL = "COOLONL_LAR/COMP200" + +## define the DB Global Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" +svcMgr.IOVDbSvc.forceRunNumber=RunNumber + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +# Temperature folder +conddb.addFolder("DCS_OFL","/LAR/DCS/FEBTEMP") + +if 'InputBadChannelSQLiteFile' in dir(): + from string import * + InputDBConnectionBadChannel = "sqlite://;schema="+InputBadChannelSQLiteFile+";dbname=COMP200" +else: + InputDBConnectionBadChannel = DBConnectionCOOL + +if ( not 'InputBadChannelSQLiteFile' in dir()) and ("ONL" in DBConnectionCOOL): + conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+InputDBConnectionBadChannel+"</dbConnection>") + conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+InputDBConnectionBadChannel+"</dbConnection>") +else: + conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<dbConnection>"+InputDBConnectionBadChannel+"</dbConnection>") + conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<dbConnection>"+InputDBConnectionBadChannel+"</dbConnection>") + +include("LArCalibProcessing/LArCalib_BadChanTool.py") + +from AthenaCommon.ConfigurableDb import getConfigurable +svcMgr += getConfigurable( "ProxyProviderSvc" )() +svcMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] +svcMgr += getConfigurable( "CondProxyProvider" )() +svcMgr.CondProxyProvider.InputCollections += [ PoolFileName ] + +if ( WaveType == "Cali" ): + + from LArCalibTools.LArCalibToolsConf import LArCaliWaves2Ntuple + LArCaliWaves2Ntuple = LArCaliWaves2Ntuple( "LArCaliWaves2Ntuple" ) + LArCaliWaves2Ntuple.NtupleName = "CALIWAVE" + LArCaliWaves2Ntuple.KeyList = [ ContainerKey ] + LArCaliWaves2Ntuple.DACSaturSkip = DACSaturSkip + LArCaliWaves2Ntuple.SaveDerivedInfo = SaveDerivedInfo + LArCaliWaves2Ntuple.SaveJitter = SaveJitter + LArCaliWaves2Ntuple.OutputLevel = INFO + LArCaliWaves2Ntuple.NtupleFile = "FILE1" + + topSequence += LArCaliWaves2Ntuple + + +if ( WaveType == "Phys" ): + from LArCalibTools.LArCalibToolsConf import LArPhysWaves2Ntuple + LArPhysWaves2Ntuple = LArPhysWaves2Ntuple( "LArPhysWaves2Ntuple" ) + LArPhysWaves2Ntuple.NtupleName = "PHYSWAVE" + LArPhysWaves2Ntuple.KeyList = [ ContainerKey ] + LArPhysWaves2Ntuple.SaveDerivedInfo = SaveDerivedInfo + LArPhysWaves2Ntuple.OutputLevel = INFO + LArPhysWaves2Ntuple.NtupleFile = "FILE1" + + topSequence += LArPhysWaves2Ntuple + +from LArCalibTools.LArCalibToolsConf import LArOFC2Ntuple +LArOFC2Ntuple = LArOFC2Ntuple( "LArOFC2Ntuple" ) +LArOFC2Ntuple.OutputLevel = INFO +LArOFC2Ntuple.NtupleFile = "FILE2" +topSequence += LArOFC2Ntuple + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+CaliWaveRootFileName+"' OPT='NEW'" ] +svcMgr.NTupleSvc.Output += [ "FILE2 DATAFILE='"+OFCRootFileName+"' OPT='NEW'" ] + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +#svcMgr.MessageSvc.OutputLevel = INFO +#svcMgr.MessageSvc.defaultLimit = 10000 +#svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +#svcMgr += CfgMgr.AthenaEventLoopMgr(OutputLevel = VERBOSE) + +########################################################################### + +#from AthenaCommon.AppMgr import theAuditorSvc +#from AthenaCommon.ConfigurableDb import getConfigurable +#theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = DEBUG) +#theAuditorSvc += getConfigurable("ChronoAuditor")() +#theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/LArCommConditions2Ntuple.py b/LArCalorimeter/LArCalibTools/share/LArCommConditions2Ntuple.py new file mode 100644 index 000000000000..410e758c961a --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArCommConditions2Ntuple.py @@ -0,0 +1,396 @@ +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector +from string import split,join +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +#Input Parameters: +# PoolFiles: sequence of pool files to read from though CondProxyProvider +# if not given, read from COOL +# +# RunNumber: Input to COOL IOV-DB if reading from +# +# RootFile: root file for the ntuple +# +# Objects: List of objects written to ntuple (PEDESTAL OFC, RAMP, + +if not 'InputDB' in dir(): + InputDB="COOLOFL_LAR/COMP200" + +if not "OFCFolder" in dir(): + OFCFolder="5samples1phase" + +if not 'RunNumber' in dir(): + RunNumber=2147483647 + +if not "RootFile" in dir(): + RootFile="LArConditions.root" + +if not "Objects" in dir(): + Objects=["PEDESTAL","RAMP","OFC","MPHYSOVERMCAL"] + +if not "SuperCells" in dir(): + SuperCells=False + +# For shape MC-Data are different +if not "IsMC" in dir(): + IsMC=False + +if not "IsFlat" in dir(): + IsFlat=False + +if not "OffIdDump" in dir(): + OffIdDump=False + +if not "DBTag" in dir(): + if "OFLP" in InputDB: + DBTag="OFLCOND-RUN1-SDR-06" + else: + DBTag="LARCALIB-000-02" + +if not "TagSuffix" in dir(): + if SuperCells: # no linking to global tag yet + TagSuffix="-000" + +def doObj(objName): + for o in Objects: + if o.upper().find(objName.upper())!=-1: + return True + return False + +def getDBFolderAndTag(folder): + if "TagSuffix" in globals(): + tag="<tag>"+join(split(folder, '/'),'') + TagSuffix+"</tag>" + else: + tag="" + return "<db>"+InputDB+"</db>"+folder+tag + +from AthenaCommon.GlobalFlags import globalflags +if IsMC: + globalflags.DataSource="geant4" + globalflags.InputFormat="pool" +else: + globalflags.DataSource="data" + globalflags.InputFormat="bytestream" + globalflags.DatabaseInstance="COMP200" + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-20-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) +svcMgr.IOVDbSvc.GlobalTag=DBTag +if IsMC: + include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + conddb.addFolder("LAR_OFL","/LAR/BadChannels/BadChannels<tag>LArBadChannelsBadChannels-IOVDEP-06</tag>") + conddb.addFolder("LAR_OFL","/LAR/BadChannels/MissingFEBs<tag>LArBadChannelsMissingFEBs-IOVDEP-04</tag>") +else: + include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + conddb.addFolder("LAR_OFL","/LAR/BadChannelsOfl/BadChannels<key>/LAR/BadChannels/BadChannels</key>") + conddb.addFolder("LAR_OFL","/LAR/BadChannelsOfl/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>") + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = RunNumber + +if SuperCells or IsFlat: + include ("LArRecUtils/LArFlatConditionsSvc.py") + #from LArRecUtils.LArRecUtilsConf import LArFlatConditionSvc + #theLArCondSvc=LArFlatConditionSvc(OutputLevel=DEBUG,DoSuperCells=SuperCells,DoRegularCells=IsFlat) + #svcMgr+=theLArCondSvc + #svcMgr.ProxyProviderSvc.ProviderNames += [ "LArFlatConditionSvc" ] + #svcMgr.LArFlatConditionSvc.OutputLevel=DEBUG + svcMgr.LArFlatConditionSvc.DoSuperCells=SuperCells + svcMgr.LArFlatConditionSvc.DoRegularCells=IsFlat + + +if SuperCells: + conddb.addFolder("LAR_OFL","/LAR/IdentifierOfl/OnOffIdMap_SC<tag>LARIdentifierOflOnOffIdMap_SC-000</tag>") + + +if 'PoolFiles' in dir(): + from AthenaCommon.ConfigurableDb import getConfigurable + from AthenaCommon.AppMgr import ServiceMgr + ServiceMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] + ServiceMgr += getConfigurable( "CondProxyProvider" )() + svcMgr.CondProxyProvider.InputCollections=PoolFiles + +if 'PoolCat' in dir(): + svcMgr.PoolSvc.ReadCatalog+=["xmlcatalog_file:"+PoolCat] + +loadCastorCat=False + + +if doObj("PEDESTAL"): + from LArCalibTools.LArCalibToolsConf import LArPedestals2Ntuple + LArPedestals2Ntuple=LArPedestals2Ntuple("LArPedestals2Ntuple") + LArPedestals2Ntuple.AddFEBTempInfo=False + LArPedestals2Ntuple.OffId=OffIdDump + if IsMC: + if SuperCells: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/Pedestal")) + LArPedestals2Ntuple.ContainerKey="LArPedestalSC" + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/Pedestal")) + LArPedestals2Ntuple.ContainerKey="LArPedestal" + elif IsFlat: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/Pedestal")) + LArPedestals2Ntuple.ContainerKey="Pedestal" + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/Pedestals/Pedestal")) + LArPedestals2Ntuple.ContainerKey="Pedestal" + LArPedestals2Ntuple.isSC=SuperCells + LArPedestals2Ntuple.isFlat=IsFlat + topSequence+=LArPedestals2Ntuple + + +if doObj("AUTOCORR"): + from LArCalibTools.LArCalibToolsConf import LArAutoCorr2Ntuple + LArAutoCorr2Ntuple=LArAutoCorr2Ntuple("LArAutoCorr2Ntuple") + LArAutoCorr2Ntuple.AddFEBTempInfo=False + LArAutoCorr2Ntuple.OffId=OffIdDump + if IsMC: + if SuperCells: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/AutoCorr")) + LArAutoCorr2Ntuple.ContainerKey="LArAutoCorrSC" + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/AutoCorr")) + LArAutoCorr2Ntuple.ContainerKey="LArAutoCorr" + elif IsFlat: + print 'No Flat Autocorr exists !!!' + import sys; sys.exit(-1) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/AutoCorrs/AutoCorr")) + loadCastorCat=True + LArAutoCorr2Ntuple.isSC=SuperCells + LArAutoCorr2Ntuple.isFlat=IsFlat + topSequence+=LArAutoCorr2Ntuple + + +if doObj("OFC"): + from LArCalibTools.LArCalibToolsConf import LArOFC2Ntuple + LArOFC2Ntuple = LArOFC2Ntuple("LArOFC2Ntuple") + LArOFC2Ntuple.AddFEBTempInfo=False + LArOFC2Ntuple.OffId=OffIdDump + if IsMC: + if SuperCells: + LArOFC2Ntuple.IsMC=IsMC + from LArRecUtils.LArOFCSCToolDefault import LArOFCSCToolDefault + theOFCTool = LArOFCSCToolDefault() + theOFCTool.Dump=True + ToolSvc += theOFCTool + LArOFC2Ntuple.OFCTool = theOFCTool + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/OFC")) + LArOFC2Ntuple.IsMC=IsMC + from LArRecUtils.LArOFCToolDefault import LArOFCToolDefault + theOFCTool = LArOFCToolDefault() + theOFCTool.Dump=True + ToolSvc += theOFCTool + LArOFC2Ntuple.OFCTool = theOFCTool + elif IsFlat: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/OFC")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/OFC/PhysWave/RTM/"+OFCFolder)) + LArOFC2Ntuple.ContainerKey = "LArOFC" + LArOFC2Ntuple.isSC=SuperCells + LArOFC2Ntuple.isFlat=IsFlat + topSequence+=LArOFC2Ntuple + +if (doObj("SHAPE")): + if IsMC: + if SuperCells: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/Shape")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/Shape")) + elif IsFlat: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/Shape")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/Shape/RTM/"+OFCFolder)) + pass + from LArCalibTools.LArCalibToolsConf import LArShape2Ntuple + LArShape2Ntuple = LArShape2Ntuple("LArShape2Ntuple") + if SuperCells: + LArShape2Ntuple.ContainerKey = "LArShapeSC" + else: + LArShape2Ntuple.ContainerKey = "LArShape" + LArShape2Ntuple.AddFEBTempInfo=False + LArShape2Ntuple.isMC = IsMC + LArShape2Ntuple.isSC = SuperCells + LArShape2Ntuple.isFlat = IsFlat + LArShape2Ntuple.OffId=OffIdDump + LArShape2Ntuple.OutputLevel = VERBOSE + topSequence+=LArShape2Ntuple + +if doObj("RAMP"): + from LArCalibTools.LArCalibToolsConf import LArRamps2Ntuple + LArRamps2Ntuple=LArRamps2Ntuple("LArRamps2Ntuple") + LArRamps2Ntuple.NtupleName = "RAMPS" + LArRamps2Ntuple.OffId=OffIdDump + if IsMC: + if SuperCells: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/Ramp")) + LArRamps2Ntuple.RampKey="LArRampSC" + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/Ramp")) + elif IsFlat: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/Ramp")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/Ramps/RampLinea")) + LArRamps2Ntuple.RawRamp = False + LArRamps2Ntuple.AddFEBTempInfo=False + LArRamps2Ntuple.isSC = SuperCells + LArRamps2Ntuple.isFlat = IsFlat + topSequence+=LArRamps2Ntuple + +if (doObj("UA2MEV")): + if IsMC: + if SuperCells: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/DAC2uA")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/uA2MeV")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/DAC2uA")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/uA2MeV")) + elif IsFlat: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/DAC2uA")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/uA2MeV")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/DAC2uA/Symmetry")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/uA2MeV/Symmetry")) + from LArCalibTools.LArCalibToolsConf import LAruA2MeV2Ntuple + LAruA2MeV2Ntuple=LAruA2MeV2Ntuple("LAruA2MeV2Ntuple") + LAruA2MeV2Ntuple.AddFEBTempInfo=False + LAruA2MeV2Ntuple.isSC = SuperCells + LAruA2MeV2Ntuple.isFlat = IsFlat + LAruA2MeV2Ntuple.OffId=OffIdDump + topSequence+=LAruA2MeV2Ntuple + +if (doObj("MPHYSOVERMCAL")): + if IsMC: + if SuperCells: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/MphysOverMcal")) + print 'Not MPHYSOVERMCAL fo SuperCells yet !!' + import sys; sys.exit(-2) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/MphysOverMcal")) + elif IsFlat: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/MphysOverMcal")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/MphysOverMcal/RTM")) + from LArCalibTools.LArCalibToolsConf import LArMphysOverMcal2Ntuple + LArMphysOverMcal2Ntuple=LArMphysOverMcal2Ntuple("LArMphysOverMcal2Ntuple") + LArMphysOverMcal2Ntuple.AddFEBTempInfo=False + LArMphysOverMcal2Ntuple.isSC = SuperCells + LArMphysOverMcal2Ntuple.isFlat = IsFlat + LArMphysOverMcal2Ntuple.OffId=OffIdDump + topSequence+=LArMphysOverMcal2Ntuple + +if (doObj("CALIWAVE")): + if IsMC: + if SuperCells: + print 'No CALIWAVE for SuperCells yet !!!' + import sys; sys.exit(-3) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/CaliWave")) + elif IsFlat: + print 'No Flat CALIWAVE !!!' + import sys; sys.exit(-3) + else: + loadCastorCat=True + #conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/CaliWaves/CaliWave")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/CaliWaves/CaliWaveXtalkCorr")) + from LArCalibTools.LArCalibToolsConf import LArCaliWaves2Ntuple + LArCaliWaves2Ntuple=LArCaliWaves2Ntuple("LArCaliWaves2Ntuple") + LArCaliWaves2Ntuple.NtupleName = "CALIWAVE" + LArCaliWaves2Ntuple.KeyList = [ 'LArCaliWave' ] + LArCaliWaves2Ntuple.SaveDerivedInfo = True + LArCaliWaves2Ntuple.SaveJitter = True + LArCaliWaves2Ntuple.AddFEBTempInfo=False + LArCaliWaves2Ntuple.isSC = SuperCells + LArCaliWaves2Ntuple.isFlat = IsFlat + LArCaliWaves2Ntuple.OffId=OffIdDump + topSequence+=LArCaliWaves2Ntuple + +if (doObj("WFPARAMS")): + loadCastorCat=True + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/DetCellParams/RTM")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/CaliPulseParams/RTM")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/Tdrift/Computed")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/PhysCaliTdiff")) + from LArCalibTools.LArCalibToolsConf import LArWFParams2Ntuple + LArWFParams2Ntuple=LArWFParams2Ntuple("LArWFParams2Ntuple") + LArWFParams2Ntuple.DumpCaliPulseParams=True + LArWFParams2Ntuple.DumpDetCellParams=True + LArWFParams2Ntuple.DumpPhysCaliTdiff=True + LArWFParams2Ntuple.DumpTdrift=True + LArWFParams2Ntuple.DetStoreSuffix="_RTM" + LArWFParams2Ntuple.OffId=OffIdDump + #LArWFParams2Ntuple.OutputLevel=DEBUG + topSequence+=LArWFParams2Ntuple + +if (doObj("NOISE")): + if IsMC: + if SuperCells: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/Noise")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/Noise")) + elif IsFlat: + #conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/Noise")) + print 'No Flat LArNoise yet !!!' + import sys; sys.exit(-5) + else: + print 'For Cell noise use the CaloNoise2Ntuple algo !' + import sys; sys.exit(-5) + from LArCalibTools.LArCalibToolsConf import LArNoise2Ntuple + LArNoise2Ntuple=LArNoise2Ntuple("LArNoise2Ntuple") + LArNoise2Ntuple.AddFEBTempInfo=False + LArNoise2Ntuple.isSC = SuperCells + LArNoise2Ntuple.isFlat = IsFlat + LArNoise2Ntuple.OffId=OffIdDump + topSequence+=LArNoise2Ntuple + +if (doObj("FSAMPL")): + if IsMC: + if SuperCells: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMCSC/fSampl")) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/fSampl")) + elif IsFlat: + #conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibFlat/fSampl")) + print 'No Flat LArfSampl yet !!!' + import sys; sys.exit(-5) + else: + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/fSampl/Symmetry")) + from LArCalibTools.LArCalibToolsConf import LArfSampl2Ntuple + LArfSampl2Ntuple=LArfSampl2Ntuple("LArfSampl2Ntuple") + LArfSampl2Ntuple.AddFEBTempInfo=False + LArfSampl2Ntuple.isSC = SuperCells + LArfSampl2Ntuple.isFlat = IsFlat + LArfSampl2Ntuple.OffId=OffIdDump + topSequence+=LArfSampl2Ntuple + + +if loadCastorCat: + svcMgr.PoolSvc.ReadCatalog += ['xmlcatalog_file:'+'/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml'] + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+RootFile+"' OPT='NEW'" ] + +#svcMgr.DetectorStore.Dump=True +#svcMgr.MessageSvc.OutputLevel = DEBUG + +svcMgr.IOVDbSvc.DBInstance="" diff --git a/LArCalorimeter/LArCalibTools/share/LArCondComparionsExample.py b/LArCalorimeter/LArCalibTools/share/LArCondComparionsExample.py new file mode 100644 index 000000000000..4926bbce8c63 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArCondComparionsExample.py @@ -0,0 +1,107 @@ +InputDB="sqlite://;schema=freshConstants.db;dbname=COMP200" +InputTag="LARElecCalibPedestalsPedestal-comm-08" + +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DetGeo.set_commis() +GlobalFlags.Luminosity.set_zero() +GlobalFlags.DataSource.set_data() +GlobalFlags.InputFormat.set_bytestream() + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-Comm-00-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = 10000000 +svcMgr.IOVDbSvc.GlobalTag="COMCOND-004-01" +conddb.addFolder("LAR","/LAR/BadChannels/BadChannels") + + +# Pedestal: +conddb.addFolder("","/LAR/ElecCalib/Pedestals/Pedestal<db>"+InputDB+"</db><tag>LARElecCalibPedestalsPedestal-comm-08</tag>") +conddb.addFolder("LAR","/LAR/ElecCalib/Pedestals/Pedestal<key>PedestalRef</key>") +from LArCalibDataQuality.LArCalibDataQualityConf import LArPedestalValidationAlg +thePedestalValidationAlg=LArPedestalValidationAlg() +thePedestalValidationAlg.IgnoreBadChannels=True +thePedestalValidationAlg.ValidationKey="Pedestal" +thePedestalValidationAlg.ReferenceKey="PedestalRef" +thePedestalValidationAlg.MsgLevelForDeviations=INFO +thePedestalValidationAlg.ListOfDevFEBs="pedFebs.txt" +topSequence+=thePedestalValidationAlg + + + +# AutoCorr: +conddb.addFolder("","/LAR/ElecCalib/AutoCorr<db>"+InputDB+"</db><tag>LARElecCalibAutoCorr-comm-08</tag>") +conddb.addFolder("LAR","/LAR/ElecCalib/AutoCorr<key>LArAutoCorrRef</key>") +from LArCalibDataQuality.LArCalibDataQualityConf import LArAutoCorrValidationAlg +theAutoCorrValidationAlg=LArAutoCorrValidationAlg() +theAutoCorrValidationAlg.IgnoreBadChannels=True +theAutoCorrValidationAlg.ValidationKey="LArAutoCorr" +theAutoCorrValidationAlg.ReferenceKey="LArAutoCorrRef" +theAutoCorrValidationAlg.MsgLevelForDeviations=INFO +theAutoCorrValidationAlg.ListOfDevFEBs="ACFebs.txt" +topSequence+=theAutoCorrValidationAlg + + + +# Ramp: +conddb.addFolder("","/LAR/ElecCalib/Ramps/RampLinea<db>"+InputDB+"</db><tag>LARElecCalibRampsRampLinea-comm-08</tag>") +conddb.addFolder("LAR","/LAR/ElecCalib/Ramps/RampLinea<key>LArRampRef</key>") +from LArCalibDataQuality.LArCalibDataQualityConf import LArRampValidationAlg +theRampValidationAlg=LArRampValidationAlg() +theRampValidationAlg.IgnoreBadChannels=True +theRampValidationAlg.ValidationKey="LArRamp" +theRampValidationAlg.ReferenceKey="LArRampRef" +theRampValidationAlg.MsgLevelForDeviations=INFO +theRampValidationAlg.ListOfDevFEBs="rampFebs.txt" +theRampValidationAlg.ThinnedValContainer="ThinRampsVal" +theRampValidationAlg.ThinnedRefContainer="ThinRampsRef" +topSequence+=theRampValidationAlg + + +from LArCalibTools.LArCalibToolsConf import LArRamps2Ntuple +ValRamps2Ntuple=LArRamps2Ntuple("ValRamps2Ntuple") +ValRamps2Ntuple.NtupleName = "VALRAMPS" +ValRamps2Ntuple.RawRamp = False +ValRamps2Ntuple.RampKey = "ThinRampsVal" +topSequence+=ValRamps2Ntuple + +RefRamps2Ntuple=LArRamps2Ntuple("RefRamps2Ntuple") +RefRamps2Ntuple.NtupleName = "REFRAMPS" +RefRamps2Ntuple.RawRamp = False +RefRamps2Ntuple.RampKey = "ThinRampsRef" +topSequence+=RefRamps2Ntuple + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='RampComparison.root' OPT='NEW'" ] + + + +svcMgr.DetectorStore.Dump=True + + diff --git a/LArCalorimeter/LArCalibTools/share/LArDSPThresholds2Ntuple.py b/LArCalorimeter/LArCalibTools/share/LArDSPThresholds2Ntuple.py new file mode 100644 index 000000000000..8d6c7ce3fd42 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArDSPThresholds2Ntuple.py @@ -0,0 +1,84 @@ +if 'inputfolder' not in dir(): + inputfolder="/LAR/Configuration/DSPThreshold/Thresholds" + +if 'inputtag' not in dir(): + inputtag="" + +if 'inputdb' not in dir(): + inputdb="COOLONL_LAR/COMP200" + +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector +from string import split,join +from time import time +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.GlobalFlags import globalflags +globalflags.Luminosity.set_Value_and_Lock('zero') +globalflags.DataSource.set_Value_and_Lock('data') +globalflags.InputFormat.set_Value_and_Lock('bytestream') + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-20-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) + +svcMgr.IOVDbSvc.GlobalTag="LARCALIB-000-02" +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = 500000 +svcMgr.EventSelector.InitialTimeStamp=int(time()) +dbname="<db>COOLOFL_LAR/COMP200</db>" + +conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<key>/LAR/BadChannels/BadChannels</key>"+dbname) +conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>"+dbname) +conddb.addFolder("",inputfolder+"<tag>"+inputtag+"</tag><db>"+inputdb+"</db>") + + +## for f in LArFebConfigFolders: +## conddb.addFolder("LAR_ONL",f) + + +from LArCalibTools.LArCalibToolsConf import LArDSPThresholds2Ntuple +theLArDSPThresholds2Ntuple=LArDSPThresholds2Ntuple() +theLArDSPThresholds2Ntuple.OutputLevel=DEBUG +theLArDSPThresholds2Ntuple.AddFEBTempInfo=False +if "Flat" in inputfolder: + theLArDSPThresholds2Ntuple.DumpFlat=True + theLArDSPThresholds2Ntuple.FlatFolder=inputfolder + +topSequence+=theLArDSPThresholds2Ntuple + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='DSPthresholds.root' OPT='NEW'" ] + +#svcMgr.DetectorStore.Dump=True +svcMgr.MessageSvc.OutputLevel = DEBUG + +svcMgr.IOVDbSvc.DBInstance="" +svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml", + ] + + +svcMgr.MessageSvc.debugLimit = 5000000 + +svcMgr.IOVDbSvc.OutputLevel=DEBUG diff --git a/LArCalorimeter/LArCalibTools/share/LArDelayFromDB2NTuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArDelayFromDB2NTuple_jobOptions.py new file mode 100644 index 000000000000..1a6a3b0855d8 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArDelayFromDB2NTuple_jobOptions.py @@ -0,0 +1,217 @@ + +import commands +########################################################################### +# +# <Marco.Delmastro@cern.ch> +# +# Example jobOptions to reconstruction a DELAY runs in all 3 gains +# +# Last update: 06/03/2008 <Fabien.Tarrade@cern.ch> +# +########################################################################### + +include("LArCalibProcessing/LArCalib_Flags.py") +include("RecExCommission/GetInputFiles.py") + +####################################################### +# Run properties +####################################################### + +if not 'RunNumber' in dir(): + RunNumber = 88237 + +if not 'FilePrefix' in dir(): + FilePrefix = "daq.Delay" + +if not 'GainList' in dir(): + GainList = [ "HIGH", "MEDIUM", "LOW" ] + +if not 'GroupingType' in dir(): + GroupingType = "ExtendedFeedThrough" + +if not 'ChannelSelection' in dir(): + # read all + ChannelSelection = "<channelSelection>35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,1005" + ## example to read only cool for Barrel C : Strips->Back + #ChannelSelection = "<channelSelection>0,3:34</channelSelection>" + +if not 'SaveDerivedInfo' in dir(): + SaveDerivedInfo = True + +if not 'SaveJitter' in dir(): + SaveJitter = True + +if not 'StripsXtalkCorr' in dir(): + StripsXtalkCorr = True # Xtalk correction for strips + +if not 'Partition' in dir(): + Partition = "EB-EMB" + +####################################################### +# Delay output name +####################################################### + +if not 'WriteNtuple' in dir(): + WriteNtuple = LArCalib_Flags.WriteNtuple + +if not 'WritePoolFile' in dir(): + WritePoolFile = LArCalib_Flags.WritePoolFile + +if not 'WriteIOV' in dir(): + WriteIOV = LArCalib_Flags.WriteIOV + +if not 'IOVBegin' in dir(): + IOVBegin = RunNumber + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200;user=ATLAS_COOL_READER" + +## Output + +if not 'LArCalibFolderOutputTag' in dir(): + LArCalibFolderOutputTag = LArCalib_Flags.tagSuffix + +if not 'OutputCaliWaveRootFileDir' in dir(): + OutputCaliWaveRootFileDir = commands.getoutput("pwd") + +if not 'KeyOutput' in dir(): + KeyOutput = "LArCaliWave" # Key of LArCaliWaveContainer saved in Pool file + +if not 'BaseFileName' in dir(): + BaseFileName = "LArCaliWave" + +if StripsXtalkCorr : + BaseFileName = BaseFileName+"_"+str(RunNumber)+"_"+Partition.replace("*","") +"_StripsXtalkCorr" +else : + BaseFileName = BaseFileName+"_"+str(RunNumber)+"_"+Partition.replace("*","") + +if not 'OutputCaliWaveRootFileName' in dir(): + OutputCaliWaveRootFileName = BaseFileName+".root" + +if not 'OutputCaliWavePoolFileName' in dir(): + OutputCaliWavePoolFileName = BaseFileName+".pool.root" + +if not 'OutputObjectSpecCaliWave' in dir(): + if StripsXtalkCorr: + OutputObjectSpecCaliWave = "LArCaliWaveContainer#"+KeyOutput+"#"+LArCalib_Flags.LArCaliWaveFolderXtlk + OutputTagSpecCaliWave = LArCalibFolderTag(LArCalib_Flags.LArCaliWaveFolderXtlk,LArCalibFolderOutputTag) + else: + OutputObjectSpecCaliWave = "LArCaliWaveContainer#"+KeyOutput+"#"+LArCalib_Flags.LArCaliWaveFolder + OutputTagSpecCaliWave = LArCalibFolderTag(LArCalib_Flags.LArCaliWaveFolder,LArCalibFolderOutputTag) + +########################################################################### +# +# Global settings +# +########################################################################### + +include("AthenaCommon/Atlas_Gen.UnixStandardJob.py") + +# +# Provides ByteStreamInputSvc name of the data file to process in the offline context +# + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + + +## define the DB Gobal Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + +svcMgr.PoolSvc.ReadCatalog += ["prfile:poolcond/PoolCat_oflcond.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000005.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000006.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_diskbuffer_afs.xml", + "xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_cond08_data.000001.lar.COND_castor.xml"] + +## The reference is the Oracle DB +if StripsXtalkCorr: + conddb.addFolder("LAR",LArCalib_Flags.LArCaliWaveFolderXtlk+"<key>LArCaliWave</key><dbConnection>"+DBConnectionCOOL+"</dbConnection>"+ChannelSelection) +else: + conddb.addFolder("LAR",LArCalib_Flags.LArCaliWaveFolder+"<key>LArCaliWave</key><dbConnection>"+DBConnectionCOOL+"</dbConnection>"+ChannelSelection) + + +if ( len(PoolFileList)>0 ): + + from AthenaCommon.ConfigurableDb import getConfigurable + svcMgr += getConfigurable( "ProxyProviderSvc" )() + svcMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] + + svcMgr += getConfigurable( "CondProxyProvider" )() + svcMgr.CondProxyProvider.InputCollections += PoolFileList + +########################################################################## +# # +# Output # +# # +########################################################################## + +if (WriteNtuple): + from LArCalibTools.LArCalibToolsConf import LArCaliWaves2Ntuple + LArCaliWaves2Ntuple = LArCaliWaves2Ntuple( "LArCaliWaves2Ntuple" ) + LArCaliWaves2Ntuple.NtupleName = "CALIWAVE" + LArCaliWaves2Ntuple.SaveDerivedInfo = SaveDerivedInfo + LArCaliWaves2Ntuple.SaveJitter = SaveJitter + LArCaliWaves2Ntuple.KeyList = [ KeyOutput ] + + topSequence+=LArCaliWaves2Ntuple + + theApp.HistogramPersistency = "ROOT" + from GaudiSvc.GaudiSvcConf import NTupleSvc + if os.path.exists(OutputCaliWaveRootFileDir+"/"+OutputCaliWaveRootFileName): + os.remove(OutputCaliWaveRootFileDir+"/"+OutputCaliWaveRootFileName) + svcMgr += NTupleSvc() + svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+OutputCaliWaveRootFileDir+"/"+OutputCaliWaveRootFileName+"' OPT='NEW'" ] + +########################################################################### + + +########################################################################### +# Use EventSelector to select IOV # +########################################################################### + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = RunNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 1 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + + +########################################################################## +# don't remove otherwise infinite loop # +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +from AthenaCommon.AppMgr import theAuditorSvc +from AthenaCommon.ConfigurableDb import getConfigurable +theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = WARNING) +theAuditorSvc += getConfigurable("ChronoAuditor")() +theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArFEBTemp2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArFEBTemp2Ntuple_jobOptions.py new file mode 100755 index 000000000000..0e72cfe73b6b --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArFEBTemp2Ntuple_jobOptions.py @@ -0,0 +1,90 @@ +########################################################## +# Job options to dump the LAr FEB temperatures to ntuple.# +########################################################## + +RunNumber = 162903 + +COOL_folder = "/LAR/DCS/FEBTEMP" + +DBConnectionCOOL_OFL = "COOLOFL_DCS/COMP200" +DBConnectionCOOL_ONL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200;user=ATLAS_COOL_READER" + +include("LArCalibProcessing/LArCalib_Flags.py") +include("LArCalibProcessing/LArCalib_MinimalSetup.py") +include("RecExCommission/GetInputFiles.py") +include("AthenaCommon/Atlas_Gen.UnixStandardJob.py") + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +import IOVDbSvc.IOVDb + +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL_ONL+"</dbConnection>") +conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL_ONL+"</dbConnection>") + +svcMgr.PoolSvc.ReadCatalog += ["prfile:poolcond/PoolCat_oflcond.xml", +"xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000005.lar_conditions.recon.pool.v0000_castor.xml", +"xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000006.lar_conditions.recon.pool.v0000_castor.xml", +"xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_diskbuffer_afs.xml", +"xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", +"xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_cond08_data.000001.lar.COND_castor.xml"] + +if ( len(PoolFileList)>0 ): + from AthenaCommon.ConfigurableDb import getConfigurable + svcMgr += getConfigurable( "ProxyProviderSvc" )() + svcMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] + svcMgr += getConfigurable( "CondProxyProvider" )() + svcMgr.CondProxyProvider.InputCollections += PoolFileList + +svcMgr.IOVDbSvc.OutputLevel = INFO +svcMgr.IOVDbSvc.dbConnection = DBConnectionCOOL_OFL + +svcMgr.ProxyProviderSvc.OutputLevel = INFO +svcMgr.AthenaPoolCnvSvc.OutputLevel = INFO + +svcMgr.IOVSvc.partialPreLoadData = False +#svcMgr.IOVDbSvc.OnlineMode = True + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = RunNumber +#svcMgr.EventSelector.EventsPerRun = 100 +#svcMgr.EventSelector.FirstEvent = 2 +#svcMgr.EventSelector.InitialTimeStamp = 1259163985 +svcMgr.EventSelector.InitialTimeStamp = 1283145454 +#svcMgr.EventSelector.TimeStampInterval = 1 + +theApp.Dlls += ["LArCalibTools"] +theApp.Dlls += [ "LArFEBTempTool" ] + +from LArCondUtils.LArCondUtilsConf import LArFEBTempTool +ToolSvc += LArFEBTempTool() +ToolSvc.LArFEBTempTool.FolderName = COOL_folder + +from LArCalibTools.LArCalibToolsConf import LArFEBTemp2Ntuple +topSequence += LArFEBTemp2Ntuple() +LArFEBTemp2Ntuple = LArFEBTemp2Ntuple() + +svcMgr.IOVDbSvc.Folders += [ COOL_folder ] + +theApp.Dlls += [ "RootHistCnv" ] +theApp.HistogramPersistency = "ROOT" +NTupleSvc = Service( "NTupleSvc" ) +NTupleSvc.Output = [ "FILE1 DATAFILE='FEBTemp.root' OPT='NEW'" ] + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel=INFO + +LArFEBTemp2Ntuple.OutputLevel=INFO +LArFEBTempTool.OutputLevel=INFO + +theApp.EvtMax=1 +MessageSvc.OutputLevel=INFO +svcMgr.IOVDbSvc.OutputLevel = DEBUG diff --git a/LArCalorimeter/LArCalibTools/share/LArGainThresholds2Ntuple.py b/LArCalorimeter/LArCalibTools/share/LArGainThresholds2Ntuple.py new file mode 100644 index 000000000000..fadd2ca78c7d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArGainThresholds2Ntuple.py @@ -0,0 +1,106 @@ +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector +from string import split,join +from time import time +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.GlobalFlags import globalflags +globalflags.Luminosity.set_Value_and_Lock('zero') +globalflags.DataSource.set_Value_and_Lock('data') +globalflags.InputFormat.set_Value_and_Lock('bytestream') + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-20-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) + +svcMgr.IOVDbSvc.GlobalTag="LARCALIB-000-02" +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = 500000 +svcMgr.EventSelector.InitialTimeStamp=int(time()) +dbname="<db>COOLOFL_LAR/COMP200</db>" + +conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<key>/LAR/BadChannels/BadChannels</key>"+dbname) +conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>"+dbname) +#conddb.addFolder("","/LAR/ElecCalibOfl/PhysCaliTdiff<key>input</key>"+dbname) + +## LArFebConfigFolders=[ +## "/LAR/Configuration/FEBConfig/Physics/EMBA1", +## "/LAR/Configuration/FEBConfig/Physics/EMBA2", +## "/LAR/Configuration/FEBConfig/Physics/EMBA3", +## "/LAR/Configuration/FEBConfig/Physics/EMBA4", +## "/LAR/Configuration/FEBConfig/Physics/EMBC1", +## "/LAR/Configuration/FEBConfig/Physics/EMBC2", +## "/LAR/Configuration/FEBConfig/Physics/EMBC3", +## "/LAR/Configuration/FEBConfig/Physics/EMBC4", +## "/LAR/Configuration/FEBConfig/Physics/EMECA1", +## "/LAR/Configuration/FEBConfig/Physics/EMECA2", +## "/LAR/Configuration/FEBConfig/Physics/EMECA3", +## "/LAR/Configuration/FEBConfig/Physics/EMECC1", +## "/LAR/Configuration/FEBConfig/Physics/EMECC2", +## "/LAR/Configuration/FEBConfig/Physics/EMECC3", +## "/LAR/Configuration/FEBConfig/Physics/FCALA", +## "/LAR/Configuration/FEBConfig/Physics/FCALC", +## "/LAR/Configuration/FEBConfig/Physics/HECA", +## "/LAR/Configuration/FEBConfig/Physics/HECC", +## ] + + +## for f in LArFebConfigFolders: +## conddb.addFolder("LAR_ONL",f) + + +## from LArRecUtils.LArRecUtils import LArFEBConfigReader +## theLArFebConfigReader=LArFEBConfigReader() +## theLArFebConfigReader.OutputLevel=DEBUG +## theLArFebConfigReader.ListOfFolders=LArFebConfigFolders + + + +from LArRecUtils.LArFEBConfigReaderDefault import LArFEBConfigReaderDefault +theLArFebConfigReader=LArFEBConfigReaderDefault() +theLArFebConfigReader.OutputLevel=DEBUG +ToolSvc+=theLArFebConfigReader + +from LArCalibTools.LArCalibToolsConf import LArGainThresholds2Ntuple +theLArGainThresholds2Ntuple=LArGainThresholds2Ntuple() +theLArGainThresholds2Ntuple.OutputLevel=DEBUG +theLArGainThresholds2Ntuple.AddFEBTempInfo=False +theLArGainThresholds2Ntuple.FebConfigReader=theLArFebConfigReader + +topSequence+=theLArGainThresholds2Ntuple + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='thresholds.root' OPT='NEW'" ] + +#svcMgr.DetectorStore.Dump=True +#svcMgr.MessageSvc.OutputLevel = DEBUG + +svcMgr.IOVDbSvc.DBInstance="" +svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml", + ] + + +svcMgr.MessageSvc.debugLimit = 5000000 + +svcMgr.IOVDbSvc.OutputLevel=DEBUG diff --git a/LArCalorimeter/LArCalibTools/share/LArMCConditions2Ntuple.py b/LArCalorimeter/LArCalibTools/share/LArMCConditions2Ntuple.py new file mode 100644 index 000000000000..1a35ffa4835c --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArMCConditions2Ntuple.py @@ -0,0 +1,184 @@ +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector +from string import split,join +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +#Input Parameters: +# PoolFiles: sequence of pool files to read from though CondProxyProvider +# if not given, read from COOL +# +# RunNumber: Input to COOL IOV-DB if reading from +# +# RootFile: root file for the ntuple +# +# Objects: List of objects written to ntuple (PEDESTAL OFC, RAMP, +DBTag='OFLCOND-SDR-BS14T-IBL-06' + +if not 'InputDB' in dir(): + InputDB="COOLOFL_LAR/OFLP200" + +if not "OFCFolder" in dir(): + OFCFolder="5samples1phase" + +if not 'RunNumber' in dir(): + RunNumber=2147483647 + +if not "RootFile" in dir(): + RootFile="LArConditions.root" + +if not "Objects" in dir(): + Objects=["PEDESTAL","RAMP","OFC","MPHYSOVERMCAL","SHAPE","UA2MEV"] + +if not "DBTag" in dir(): + DBTag="LARCALIB-000-01" + + +def doObj(objName): + for o in Objects: + if o.upper().find(objName.upper())!=-1: + return True + return False + +def getDBFolderAndTag(folder): + if "TagSuffix" in dir(): + tag="<tag>"+join(split(folder, '/'),'') + TagSuffix+"</tag>" + else: + tag="" + return "<db>"+InputDB+"</db>"+folder+tag + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DataSource="geant4" +globalflags.InputFormat="pool" + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-18-01-03" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) +svcMgr.IOVDbSvc.GlobalTag=DBTag +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = RunNumber + +conddb.addFolder("","<db>COOLOFL_LAR/OFLP200</db>/LAR/BadChannels/BadChannels<key>/LAR/BadChannels/BadChannels</key>") +conddb.addFolder("","<db>COOLOFL_LAR/OFLP200</db>/LAR/BadChannels/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>") + +conddb.addOverride('/LAR/Identifier/FebRodAtlas','FebRodAtlas-005') +conddb.addOverride('/LAR/Identifier/OnOffIdAtlas','OnOffIdAtlas-012') + + +if 'PoolFiles' in dir(): + from AthenaCommon.ConfigurableDb import getConfigurable + from AthenaCommon.AppMgr import ServiceMgr + ServiceMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] + ServiceMgr += getConfigurable( "CondProxyProvider" )() + svcMgr.CondProxyProvider.InputCollections=PoolFiles + +if 'PoolCat' in dir(): + svcMgr.PoolSvc.ReadCatalog+=["xmlcatalog_file:"+PoolCat] + +loadCastorCat=False + +if doObj("PEDESTAL"): + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/Pedestal")) + from LArCalibTools.LArCalibToolsConf import LArPedestals2Ntuple + LArPedestals2Ntuple=LArPedestals2Ntuple("LArPedestals2Ntuple") + LArPedestals2Ntuple.AddFEBTempInfo=False + topSequence+=LArPedestals2Ntuple + + +if doObj("AUTOCORR"): + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibOfl/AutoCorrs/AutoCorr")) + from LArCalibTools.LArCalibToolsConf import LArAutoCorr2Ntuple + LArAutoCorr2Ntuple=LArAutoCorr2Ntuple("LArAutoCorr2Ntuple") + LArAutoCorr2Ntuple.AddFEBTempInfo=False + topSequence+=LArAutoCorr2Ntuple + + +if doObj("OFC"): + + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/HVScaleCorr")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/Noise")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/AutoCorr")) + from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault + from LArRecUtils.LArAutoCorrNoiseToolDefault import LArAutoCorrNoiseToolDefault + theLArADC2MeVToolDefault = LArADC2MeVToolDefault() + ToolSvc += theLArADC2MeVToolDefault + theLArAutoCorrNoiseToolDefault = LArAutoCorrNoiseToolDefault() + theLArAutoCorrNoiseToolDefault.NSamples = 5 + ToolSvc += theLArAutoCorrNoiseToolDefault + from LArRecUtils.LArOFCToolDefault import LArOFCToolDefault + theOFCTool = LArOFCToolDefault() + theOFCTool.Dump=True + ToolSvc += theOFCTool + + from LArCalibTools.LArCalibToolsConf import LArOFC2Ntuple + LArOFC2Ntuple = LArOFC2Ntuple("LArOFC2Ntuple") + LArOFC2Ntuple.ContainerKey = "LArOFC" + LArOFC2Ntuple.AddFEBTempInfo=False + LArOFC2Ntuple.IsMC = True + LArOFC2Ntuple.OFCTool = theOFCTool + topSequence+=LArOFC2Ntuple + +if (doObj("SHAPE")): + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/Shape")) + from LArCalibTools.LArCalibToolsConf import LArShape2Ntuple + LArShape2Ntuple = LArShape2Ntuple("LArShape2Ntuple") + LArShape2Ntuple.ContainerKey = "LArShape" + LArShape2Ntuple.AddFEBTempInfo=False + LArShape2Ntuple.IsMC = True + topSequence+=LArShape2Ntuple + +if doObj("RAMP"): + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/Ramp")) + from LArCalibTools.LArCalibToolsConf import LArRamps2Ntuple + LArRamps2Ntuple=LArRamps2Ntuple("LArRamps2Ntuple") + LArRamps2Ntuple.NtupleName = "RAMPS" + LArRamps2Ntuple.RawRamp = False + LArRamps2Ntuple.IsMC = True + LArRamps2Ntuple.AddFEBTempInfo=False + topSequence+=LArRamps2Ntuple + +if (doObj("UA2MEV")): + print 'DAC2uA check : ',getDBFolderAndTag("/LAR/ElecCalibMC/DAC2uA") + print 'uA2MeV check : ',getDBFolderAndTag("/LAR/ElecCalibMC/uA2MeV") + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/DAC2uA")) + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/uA2MeV")) + from LArCalibTools.LArCalibToolsConf import LAruA2MeV2Ntuple + LAruA2MeV2Ntuple=LAruA2MeV2Ntuple("LAruA2MeV2Ntuple") + LAruA2MeV2Ntuple.AddFEBTempInfo=False + topSequence+=LAruA2MeV2Ntuple + +if (doObj("MPHYSOVERMCAL")): + conddb.addFolder("",getDBFolderAndTag("/LAR/ElecCalibMC/MphysOverMcal")) + from LArCalibTools.LArCalibToolsConf import LArMphysOverMcal2Ntuple + LArMphysOverMcal2Ntuple=LArMphysOverMcal2Ntuple("LArMphysOverMcal2Ntuple") + LArMphysOverMcal2Ntuple.AddFEBTempInfo=False + LArMphysOverMcal2Ntuple.IsMC=True + topSequence+=LArMphysOverMcal2Ntuple + +if loadCastorCat: + svcMgr.PoolSvc.ReadCatalog += ['xmlcatalog_file:'+'/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml'] + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+RootFile+"' OPT='NEW'" ] + +svcMgr.MessageSvc.OutputLevel = DEBUG + +svcMgr.IOVDbSvc.DBInstance="OFLP200" diff --git a/LArCalorimeter/LArCalibTools/share/LArMphysOverMcalFromTuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArMphysOverMcalFromTuple_jobOptions.py new file mode 100755 index 000000000000..4af386a4a374 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArMphysOverMcalFromTuple_jobOptions.py @@ -0,0 +1,101 @@ +# Last update: Caroline Collard 2009-03-31 + +IOVBegin=80000 + +import commands +########################################################################### +include("LArCalibProcessing/LArCalib_Flags.py") + + +# output POOL file: +if not 'writePOOLfile' in dir(): + writePOOLfile = True + +if not 'MphysOverMcalPOOLFileOUT' in dir(): + MphysOverMcalPOOLFileOUT = "/tmp/collard/MphysOverMcal_88240_EMBC.pool.root" + +########################################################################### +# +# Global settings +# +########################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include( "LArCalibProcessing/LArCalib_MinimalSetup.py") + +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB + +######################################################################################################### +# +# Reading Ntuple +######################################################################################################### +theApp.Dlls += ["LArRawUtils"] +theApp.Dlls += ["LArTools"] +theApp.Dlls += ["LArCalibUtils"] +theApp.Dlls += ["LArCalibTools"] + +theApp.TopAlg += [ "LArMphysOverMcalFromTuple" ] +LArMphysOverMcalFromTuple = Algorithm( "LArMphysOverMcalFromTuple" ) +LArMphysOverMcalFromTuple.FileNames = [ + "/tmp/collard/fpm_pulse_mini88240.root" +] +FPMKey = "LArMphysOverMcal" +LArMphysOverMcalFromTuple.StoreKey = FPMKey + + +########################################################################### +# +# writing to POOL file... +# +########################################################################### + +if ( writePOOLfile ): + + FPMMphysFolder = "/LAR/ElecCalib/MphysOverMcal/FPM" + OutputObjectSpec = "LArMphysOverMcalComplete#"+FPMKey+"#"+FPMMphysFolder + LArMphysFolderOutputTag = LArCalib_Flags.tagSuffix + OutputObjectSpecTag = LArCalibFolderTag(FPMMphysFolder,LArMphysFolderOutputTag) + + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + theOutputConditionsAlg = OutputConditionsAlg("OutputConditionsAlg", MphysOverMcalPOOLFileOUT, + [OutputObjectSpec],[OutputObjectSpecTag],True) + theOutputConditionsAlg.Run1 = IOVBegin + + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +from AthenaCommon.AppMgr import theAuditorSvc +from AthenaCommon.ConfigurableDb import getConfigurable +theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = DEBUG) +theAuditorSvc += getConfigurable("ChronoAuditor")() +theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### + +svcMgr.IOVDbSvc.dbConnection="sqlite://;schema=myDB200.db;dbname=COMP200" + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArOFC2Ntuple_POOL_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArOFC2Ntuple_POOL_jobOptions.py new file mode 100755 index 000000000000..16719ce6c241 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArOFC2Ntuple_POOL_jobOptions.py @@ -0,0 +1,96 @@ +########################################################################### +# +# jobOptions to dump LAr OFC POOL file content to ROOT ntuple +# +# rewritten in Nov. 2010, P. Strizenec +########################################################################### + +import commands + +OFC2NtupleLog = logging.getLogger( "OFC2NtupleLog" ) + +if not 'PoolFileName' in dir(): + OFC2NtupleLog.fatal("Please setup the input POOL file ('PoolFileName')!") + theApp.exit(-1) + +if not 'RootFileName' in dir(): + RootFileName = "LArOFC2Ntuple_POOL.root" + + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200;" + #DBConnectionCOOL = "COOLONL_LAR/COMP200" + +if not 'RunNumber' in dir(): + RunNumber = 165983 + + +########################################################################### + +include("LArCalibProcessing/LArCalib_Flags.py") + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +########################################################################### +# +# POOL +# +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") +## define the DB Global Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" +svcMgr.IOVDbSvc.forceRunNumber=RunNumber + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +# Temperature folder +conddb.addFolder("DCS_OFL","/LAR/DCS/FEBTEMP") + +if "ONL" in DBConnectionCOOL: + conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +else: + conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + include("LArCalibProcessing/LArCalib_BadChanTool.py") + +from AthenaCommon.ConfigurableDb import getConfigurable +svcMgr += getConfigurable( "ProxyProviderSvc" )() +svcMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] +svcMgr += getConfigurable( "CondProxyProvider" )() +svcMgr.CondProxyProvider.InputCollections += [ PoolFileName ] + +# +# Dump OFC folder to a ROOT ntuple +# +from LArCalibTools.LArCalibToolsConf import LArOFC2Ntuple +LArOFC2Ntuple = LArOFC2Ntuple( "LArOFC2Ntuple" ) +LArOFC2Ntuple.OutputLevel = INFO +topSequence += LArOFC2Ntuple + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+RootFileName+"' OPT='NEW'" ] + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### +#svcMgr.MessageSvc.OutputLevel = INFO +#svcMgr.MessageSvc.defaultLimit = 10000 +#svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +#svcMgr += CfgMgr.AthenaEventLoopMgr(OutputLevel = VERBOSE) + +########################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/LArOFCBin_PhysCaliTdiffFromStdNtuple2Pool_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArOFCBin_PhysCaliTdiffFromStdNtuple2Pool_jobOptions.py new file mode 100755 index 000000000000..ac689f8c5f7d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArOFCBin_PhysCaliTdiffFromStdNtuple2Pool_jobOptions.py @@ -0,0 +1,197 @@ +# Last update: Caroline Collard 2009-03-31 + +import commands +########################################################################### +include("LArCalibProcessing/LArCalib_Flags.py") + +# output POOL file: +if not 'writePOOLfile' in dir(): + writePOOLfile = True + +if not 'POOLFileOUT' in dir(): + POOLFileOUT = "LArParams_0.pool.root" + +if not 'NTFileOUT' in dir(): + NTFileOUT = "LArParams_0_new.root" + +if not 'writeNTuple' in dir(): + writeNTuple = True + +if not 'NTName' in dir(): + NTName = "PARAMS" + +if not 'NTFileIN' in dir(): + NTFileIN = "LArParams_0.root" + +if not 'StoreOFC' in dir(): + StoreOFC = True + +if StoreOFC: + if not 'OutputKey_OFCBin' in dir(): + OutputKey_OFCBin = "LArOFCPhase" + if not 'OutputFolder_OFCBin' in dir(): + OutputFolder_OFCBin="/LAR/ElecCalibOfl/OFCBin/Dummy" + + +if not 'StoreTdiff' in dir(): + StoreTdiff = True + +if StoreTdiff: + if not 'OutputKey_Tdiff' in dir(): + OutputKey_Tdiff = "LArPhysCaliTdiff" + if not 'OutputFolder_Tdiff' in dir(): + OutputFolder_Tdiff="/LAR/ElecCalibOfl/PhysCaliTdiff" + + +if not 'OutputTag' in dir(): + OutputTag="comm-08" + +if not 'GroupingType' in dir(): + GroupingType = "ExtendedSubDetector" + +########################################################################### +# +# Global settings +# +########################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include( "LArCalibProcessing/LArCalib_MinimalSetup.py") + +if not 'OutputDB' in dir(): + OutputDB = LArCalib_Flags.OutputDB + +if 'OutputSQLiteFile' in dir(): + OutputDB = "sqlite://;schema="+OutputSQLiteFile+";dbname=COMP200" + +########################################################################### +# # +# Input conditions data (CaliWave) for COOL and/or POOL # +# # +########################################################################### + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") + +## define the DB Gobal Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200" +conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + +svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "prfile:poolcond/PoolCat_oflcond.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_diskbuffer_afs.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_cond08_data.000001.lar.COND_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000003.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000004.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000005.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000006.lar_conditions.recon.pool.v0000_castor.xml"] + + + + +######################################################################################################### +# +# Reading Ntuple ... +######################################################################################################### + +from LArCalibTools.LArCalibToolsConf import LArOFCBin_PhysCaliTdiffFromStdNtuple +LArParamsFromTuple = LArOFCBin_PhysCaliTdiffFromStdNtuple() +LArParamsFromTuple.NtupleName = NTName +LArParamsFromTuple.FileNames = [ NTFileIN ] +LArParamsFromTuple.Store_OFC = StoreOFC +LArParamsFromTuple.Store_Tdiff = StoreTdiff +if StoreOFC: + LArParamsFromTuple.StoreKey_OFC = OutputKey_OFCBin + +if StoreTdiff: + LArParamsFromTuple.StoreKey_Tdiff = OutputKey_Tdiff + +LArParamsFromTuple.GroupingType = GroupingType + +topSequence += LArParamsFromTuple + +########################################################################### +# +# Writing to Ntuple... +# +########################################################################### + +if ( writeNTuple ): + + from LArCalibTools.LArCalibToolsConf import LArParams2Ntuple + LArParams2Ntuple = LArParams2Ntuple( "LArParams2Ntuple" ) + LArParams2Ntuple.NtupleName = "PARAMS" + LArParams2Ntuple.KeyList = ["LArOFCBinComplete", "LArPhysCaliTdiffComplete"] + LArParams2Ntuple.AllChannels2Ntuple = False + LArParams2Ntuple.DBKeysList = [ "", "", "LArPhysCaliTdiff", + "", "", "", "", "", "", "", "", "", "", "LArOFCPhase"] + + topSequence += LArParams2Ntuple + + + theApp.HistogramPersistency = "ROOT" + from GaudiSvc.GaudiSvcConf import NTupleSvc + svcMgr += NTupleSvc() + svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+NTFileOUT+"' OPT='NEW'" ] + + +########################################################################### +# +# writing to POOL file... +# +########################################################################### + +if ( writePOOLfile ): + + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + + if StoreOFC: + OutputObjectSpecOFC = "LArOFCBinComplete#"+OutputKey_OFCBin+"#"+ OutputFolder_OFCBin + OutputObjectSpecTagOFC = LArCalibFolderTag(OutputFolder_OFCBin,OutputTag) + theOutputConditionsAlg = OutputConditionsAlg("OutputConditionsAlg",POOLFileOUT, + [OutputObjectSpecOFC],[OutputObjectSpecTagOFC],True) + theOutputConditionsAlg.Run1 = 0 + + if StoreTdiff: + OutputObjectSpecTdiff = "LArPhysCaliTdiffComplete#"+OutputKey_Tdiff+"#"+ OutputFolder_Tdiff + OutputObjectSpecTagTdiff = LArCalibFolderTag(OutputFolder_Tdiff,OutputTag) + theOutputConditionsAlg1 = OutputConditionsAlg("OutputConditionsAlg1",POOLFileOUT, + [OutputObjectSpecTdiff],[OutputObjectSpecTagTdiff],True) + theOutputConditionsAlg1.Run1 = 0 + + svcMgr.IOVDbSvc.dbConnection = OutputDB + + from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc + svcMgr += IOVRegistrationSvc() + svcMgr.IOVRegistrationSvc.RecreateFolders = True + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArParams2Ntuple_POOL_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArParams2Ntuple_POOL_jobOptions.py new file mode 100755 index 000000000000..5d5e4a503aa6 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArParams2Ntuple_POOL_jobOptions.py @@ -0,0 +1,141 @@ +########################################################################### +# +# Read parameters from POOL file and save them in ROOT Ntuple +# +# Author: Marcello.Fanti@mi.infn.it +# Marco Delmastro@cern.ch +# +# Last update 16/3/2006 +# +########################################################################### + +# List of the input data file(s) +PoolFileNameList = [ "./params.pool.root" ] + +# Pool file catalog location +PoolFileCatalog = "./PoolFileCatalog.xml" + +# List of the data structure to dump. Possible structures are: +# +# - LArCaliPulseParamsComplete +# - LArDetCellParamsComplete +# - LArPhysCaliTdiffComplete +# - LArTdriftComplete +# - LArMphysOverMcalComplete +# - LArRinjComplete +# - LArTshaperComplete +# - LArEMEC_CphiComplete +# - LArEMEC_HValphaComplete +# - LArEMEC_HVbetaComplete +# - LArCableLengthComplete +# - LArCableAttenuationComplete +# +# - LArCaliPulseParamsVsCalib +# +# possible examples: +#DataStructureList = [ "LArCaliPulseParamsComplete", "LArDetCellParamsComplete" ] +#DataStructureList = [ "LArCaliPulseParamsVsCalib" ] + +# Suffix to be added at the end fo the param class name to generate detStore key +#DetStoreSuffix = "_RTM" +DetStoreSuffix = "" + +# switch detector description (H8, ATLAS) +DetDescription = "ATLAS" + +# Output ROOT file name +NtupleFileName = "LArParams2Ntuple.root" + +########################################################################### + +# +# Detector description +# +DetDescrCnvSvc = Service( "DetDescrCnvSvc" ) +DetDescrCnvSvc.DetectorManagers += ["CaloTTDescrManager"] +DetDescrCnvSvc.DetectorManagers += ["CaloMgr"] + +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +if ( DetDescription == "ATLAS" ) : + DetDescrVersion = "ATLAS-DC3-05" + include( "LArIdCnv/LArIdCnv_joboptions.py" ) + include( "LArCondCnv/LArCondCnv_IdMapAtlas_jobOptions.py" ) + #don't work, due to some G4-related stuff... include("LArDetDescr/LArDetDescr_joboptions.py") + +elif ( DetDescription == "H8" ) : + include( "LArDetDescr/LArDetDescr_H8_joboptions.py" ) + DetDescrCnvSvc = Service( "DetDescrCnvSvc" ) + DetDescrCnvSvc.DoIdChecks + DetDescrCnvSvc.LArIDFileName ="IdDictParser/IdDictLArCalorimeter_H8_2004.xml" + +# +# Flags: LAr only +# +from AthenaCommon.DetFlags import DetFlags +DetFlags.all_setOff() +DetFlags.em_setOn() + +# the following is necessary for absolute eta,phi mapping +include ("AtlasGeoModel/SetGeometryVersion.py") +include ("AtlasGeoModel/GeoModelInit.py") + +ToolSvc = Service( "ToolSvc" ) +ToolSvc.LArRoI_Map.Print = False + +# +# Read in from POOL file +# +include("AthenaSealSvc/AthenaSealSvc_joboptions.py") +include("LArRawConditions/LArRawConditionsDict_joboptions.py") +AthenaSealSvc.CheckDictionary = True + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +theApp.Dlls += ["EventSelectorAthenaPool"] +theApp.Dlls += [ "LArAthenaPoolPoolCnv" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] + +CondProxyProvider = Service( "CondProxyProvider" ) +ProxyProviderSvc = Service( "ProxyProviderSvc" ) +ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] + +CondProxyProvider = Service( "CondProxyProvider" ) +CondProxyProvider.InputCollections += PoolFileNameList +CondProxyProvider.OutputLevel = DEBUG + +EventPersistencySvc = Service( "EventPersistencySvc" ) +EventPersistencySvc.CnvServices += [ "AthenaPoolCnvSvc" ] + +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) +include( "LArRawConditions/LArRawConditionsDict_joboptions.py" ) + +PoolSvc = Service ( "PoolSvc" ) +PoolSvc.ReadCatalog += [ "xmlcatalog_file:"+PoolFileCatalog ] + +# +# Write out to ROOT file +# + +theApp.Dlls += ["LArCalibTools"] + +theApp.TopAlg += [ "LArParams2Ntuple" ] +LArParams2Ntuple=Algorithm( "LArParams2Ntuple" ) +LArParams2Ntuple.OutputLevel = INFO +LArParams2Ntuple.KeyList += DataStructureList +LArParams2Ntuple.DetStoreSuffix = DetStoreSuffix + +theApp.Dlls += [ "RootHistCnv" ] +theApp.HistogramPersistency = "ROOT" +NTupleSvc = Service( "NTupleSvc" ) +NTupleSvc.Output = [ "FILE1 DATAFILE='"+NtupleFileName+"' OPT='NEW'" ] + +########################################################################### + +theApp.EvtMax = 1 + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = INFO + +########################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/LArParamsFromDB2NTuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArParamsFromDB2NTuple_jobOptions.py new file mode 100644 index 000000000000..1d284860d540 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArParamsFromDB2NTuple_jobOptions.py @@ -0,0 +1,182 @@ +import commands +########################################################################### + +include("LArCalibProcessing/LArCalib_Flags.py") +include("RecExCommission/GetInputFiles.py") + +####################################################### +# Run properties +####################################################### + +if not 'RunNumber' in dir(): + RunNumber = 88237 + +if not ' GainList' in dir(): + GainList = ["HIGH", "MEDIUM", "LOW"] + +if not 'ChannelSelection' in dir(): + ChannelSelection="" + +if not 'Partition' in dir(): + Partition = "EB-EMB" + +if not 'LArCaliInputKey' in dir(): + LArCaliInputKey = "" + +if not 'LArDetInputKey' in dir(): + LArDetInputKey = "" + +if not 'LArParamsTag' in dir(): + LArParamsTag = "" + +if not 'LArInputKey' in dir(): + LArInputKey = [""] + +if not 'AllChannels2Ntuple' in dir(): + AllChannels2Ntuple = False + +####################################################### +# Delay output name +####################################################### + +if not 'WriteNtuple' in dir(): + WriteNtuple = LArCalib_Flags.WriteNtuple + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200" + +if not 'DBConnection' in dir(): + DBConnection = DBConnectionCOOL + +## Output + +if not 'OutputRootFileDir' in dir(): + OutputRootFileDir = commands.getoutput("pwd") + +if not 'KeyOutput' in dir(): + KeyOutput = "" # Key of LArPhysWaveContainer saved in Pool file + +if not 'BaseFileName' in dir(): + BaseFileName = "LArParams" + +BaseFileName = BaseFileName+"_"+str(RunNumber)+"_"+Partition.replace("*","") + +if not 'OutputRootFileName' in dir(): + OutputRootFileName = BaseFileName+".root" + +########################################################################### +# +# Global settings +# +########################################################################### + +include("AthenaCommon/Atlas_Gen.UnixStandardJob.py") + +# +# Provides ByteStreamInputSvc name of the data file to process in the offline context +# + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + + +## define the DB Gobal Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" + +from IOVDbSvc.CondDB import conddb + +conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + +svcMgr.PoolSvc.ReadCatalog += ["prfile:poolcond/PoolCat_oflcond.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000005.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000006.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_diskbuffer_afs.xml", + "xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_cond08_data.000001.lar.COND_castor.xml"] + +## The reference is the Oracle DB +if 'LArCaliParamsFolder' in dir(): + if not 'InputTagSpecCali' in dir(): + InputTagSpecCali = LArCalibFolderTag(LArCaliParamsFolder,LArInputTag) + +# print 'Input tag: ',InputTagSpecCali," in folder: ",LArCaliParamsFolder + conddb.addFolder("",LArCaliParamsFolder+"<tag>"+InputTagSpecCali+"</tag><key>"+LArCaliInputKey+"</key><dbConnection>"+DBConnection+"</dbConnection>"+ChannelSelection) + + +if 'LArDetParamsFolder' in dir(): + if not 'InputTagSpecDet' in dir(): + InputTagSpecDet = LArCalibFolderTag(LArDetParamsFolder,LArInputTag) + +# print 'Input tag: ',InputTagSpecDet," in folder: ",LArDetParamsFolder + conddb.addFolder("",LArDetParamsFolder+"<tag>"+InputTagSpecDet+"</tag><key>"+LArDetInputKey+"</key><dbConnection>"+DBConnection+"</dbConnection>"+ChannelSelection) + + +########################################################################## +# # +# Output # +# # +########################################################################## + +if (WriteNtuple): + from LArCalibTools.LArCalibToolsConf import LArParams2Ntuple + LArParams2Ntuple = LArParams2Ntuple( "LArParams2Ntuple" ) + LArParams2Ntuple.NtupleName = "PARAMS" + LArParams2Ntuple.KeyList = LArInputKey + LArParams2Ntuple.AllChannels2Ntuple = AllChannels2Ntuple + + topSequence+=LArParams2Ntuple + + theApp.HistogramPersistency = "ROOT" + from GaudiSvc.GaudiSvcConf import NTupleSvc + if os.path.exists(OutputRootFileDir+"/"+OutputRootFileName): + os.remove(OutputRootFileDir+"/"+OutputRootFileName) + svcMgr += NTupleSvc() + svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+OutputRootFileDir+"/"+OutputRootFileName+"' OPT='NEW'" ] + +########################################################################### + + +########################################################################### +# Use EventSelector to select IOV # +########################################################################### + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = RunNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 1 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + + +########################################################################## +# don't remove otherwise infinite loop # +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +from AthenaCommon.AppMgr import theAuditorSvc +from AthenaCommon.ConfigurableDb import getConfigurable +theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = WARNING) +theAuditorSvc += getConfigurable("ChronoAuditor")() +theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArParamsFromStdNtuple2Pool_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArParamsFromStdNtuple2Pool_jobOptions.py new file mode 100755 index 000000000000..d90a41639f78 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArParamsFromStdNtuple2Pool_jobOptions.py @@ -0,0 +1,184 @@ +# Last update: Caroline Collard 2009-03-31 + +import commands +########################################################################### +include("LArCalibProcessing/LArCalib_Flags.py") + +# output POOL file: +if not 'writePOOLfile' in dir(): + writePOOLfile = True + +if not 'POOLFileOUT' in dir(): + POOLFileOUT = "LArParams_0_HEC.pool.root" + +if not 'NTFileOUT' in dir(): + NTFileOUT = "LArParams_0_HEC_new.root" + +if not 'writeNTuple' in dir(): + writeNTuple = True + +if not 'NTName' in dir(): + NTName = "PARAMS" + +if not 'NTFileIN' in dir(): + NTFileIN = "LArParams_0_HEC.root" + +if not 'OutputKey_Cali' in dir(): + OutputKey_Cali = "LArCaliPulseParams_RTM" + +if not 'OutputKey_Det' in dir(): + OutputKey_Det = "LArDetCellParams_RTM" + +if not 'OutputFolder_Cali' in dir(): + OutputFolder_Cali="/LAR/ElecCalibOfl/CaliPulseParams/RTM" + +if not 'OutputFolder_Det' in dir(): + OutputFolder_Det="/LAR/ElecCalibOfl/DetCellParams/RTM" + +if not 'OutputTag' in dir(): + OutputTag="comm-08" + +if not 'GroupingType' in dir(): + GroupingType = "ExtendedSubDetector" + +########################################################################### +# +# Global settings +# +########################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include( "LArCalibProcessing/LArCalib_MinimalSetup.py") + +if not 'OutputDB' in dir(): + OutputDB = LArCalib_Flags.OutputDB + +if 'OutputSQLiteFile' in dir(): + OutputDB = "sqlite://;schema="+OutputSQLiteFile+";dbname=COMP200" + +########################################################################### +# # +# Input conditions data (CaliWave) for COOL and/or POOL # +# # +########################################################################### + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") + +## define the DB Gobal Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200" +conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + +svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "prfile:poolcond/PoolCat_oflcond.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_diskbuffer_afs.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_cond08_data.000001.lar.COND_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000003.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000004.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000005.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000006.lar_conditions.recon.pool.v0000_castor.xml"] + + + + +######################################################################################################### +# +# Reading Ntuple ... +######################################################################################################### + +from LArCalibTools.LArCalibToolsConf import LArParamsFromStdNtuple +LArParamsFromTuple = LArParamsFromStdNtuple() +LArParamsFromTuple.NtupleName = NTName +LArParamsFromTuple.FileNames = [ NTFileIN ] +LArParamsFromTuple.StoreKey_Cali = OutputKey_Cali +LArParamsFromTuple.StoreKey_Det = OutputKey_Det +LArParamsFromTuple.GroupingType = GroupingType + +topSequence += LArParamsFromTuple + +########################################################################### +# +# Writing to Ntuple... +# +########################################################################### + +if ( writeNTuple ): + + from LArCalibTools.LArCalibToolsConf import LArParams2Ntuple + LArParams2Ntuple = LArParams2Ntuple( "LArParams2Ntuple" ) + LArParams2Ntuple.NtupleName = "PARAMS" + LArParams2Ntuple.KeyList = ["LArCaliPulseParamsComplete", "LArDetCellParamsComplete"] + LArParams2Ntuple.AllChannels2Ntuple = False + LArParams2Ntuple.DBKeysList = ["LArCaliPulseParams_RTM","LArDetCellParams_RTM"] + + topSequence += LArParams2Ntuple + + + theApp.HistogramPersistency = "ROOT" + from GaudiSvc.GaudiSvcConf import NTupleSvc + svcMgr += NTupleSvc() + svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+NTFileOUT+"' OPT='NEW'" ] + + +########################################################################### +# +# writing to POOL file... +# +########################################################################### + +if ( writePOOLfile ): + + OutputObjectSpecCali = "LArCaliPulseParamsComplete#"+OutputKey_Cali+"#"+ OutputFolder_Cali + OutputObjectSpecTagCali = LArCalibFolderTag(OutputFolder_Cali,OutputTag) + + OutputObjectSpecDet = "LArDetCellParamsComplete#"+OutputKey_Det+"#"+ OutputFolder_Det + OutputObjectSpecTagDet = LArCalibFolderTag(OutputFolder_Det,OutputTag) + + + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + theOutputConditionsAlg = OutputConditionsAlg("OutputConditionsAlg",POOLFileOUT, + [OutputObjectSpecCali],[OutputObjectSpecTagCali],True) + + theOutputConditionsAlg.Run1 = 0 + + theOutputConditionsAlg1 = OutputConditionsAlg("OutputConditionsAlg1",POOLFileOUT, + [OutputObjectSpecDet],[OutputObjectSpecTagDet],True) + + theOutputConditionsAlg1.Run1 = 0 + + svcMgr.IOVDbSvc.dbConnection = OutputDB + + from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc + svcMgr += IOVRegistrationSvc() + svcMgr.IOVRegistrationSvc.RecreateFolders = True + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArPedestal2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArPedestal2Ntuple_jobOptions.py new file mode 100755 index 000000000000..e9d97442f51c --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArPedestal2Ntuple_jobOptions.py @@ -0,0 +1,190 @@ +########################################################################### +# +# LArCalib_Pedestal2Ntuple_jobOptions.py +# +# Last update: 21/11/2007 <Marco.Delmasytro@cern.ch> +# +# DO NOT MODIFY THIS JOBOPTIONS FILE, USE YOUR OWN TOPOPTIONS FILE! +# +########################################################################### + +if not 'ReadCOOL' in dir(): + ReadCOOL = True + +if not 'RunNumber' in dir(): + RunNumber = 0 + +if not 'ChannelSelection' in dir(): + ChannelSelection = " " + # example to read only Barrel C (Strips->Back) + #ChannelSelection = "<channelSelection>0,3:34</channelSelection>" + +if not 'PedestalFolder' in dir(): + PedestalFolder = "/LAR/ElecCalib/Pedestals/Pedestal" + +if not 'PedestalFolderTag' in dir(): + PedestalFolderTag = "-comm-05" + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "impl=cool;techno=oracle;schema=ATLAS_COOLONL_LAR;ATLAS_COOLPROD:COMP200:ATLAS_COOL_READER:" + +if not 'PoolFileDir' in dir(): + PoolFileDir = "/afs/cern.ch/user/l/larp3c/maxidisk/poolFiles/Barrel-22/29142_29143_29146" + +if not 'PoolFileName' in dir(): + PoolFileName = "LArPedestal_29142_EB-EMBA.pool.root" + +if not 'ContainerKey' in dir(): + #ContainerKey = "Pedestal" # deprecated, do not use! + ContainerKey = "LArPedestal" + +if not 'NtupleFileName' in dir(): + NtupleFileName = "LArPedestal2Ntuple.root" + +########################################################################### +# +# Global settings +# +########################################################################### + +if not "DetDescrVersion" in dir(): + DetDescrVersion = 'ATLAS-Comm-00-00-00' + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DetGeo.set_commis() +GlobalFlags.Luminosity.set_zero() +GlobalFlags.DataSource.set_data() +GlobalFlags.InputFormat.set_bytestream() + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +# Set up GeoModel (not really needed but crashes without) +include ("AtlasGeoModel/SetGeometryVersion.py") +include ("AtlasGeoModel/GeoModelInit.py") + +# Get identifier mapping +include("LArConditionsCommon/LArIdMap_comm_jobOptions.py") +include("LArIdCnv/LArIdCnv_joboptions.py") + +ToolSvc = Service( "ToolSvc" ) +ToolSvc.LArRoI_Map.Print = False + +########################################################################### +# +# Algorithms sequencer +# +########################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +########################################################################### +# +# Read Pedestals from COOL(Oracle/SQLite) or POOL +# +########################################################################### + +from string import * + +def FolderTag(folder,tag): + return join(split(folder, '/'),'') + tag; + +def DBConnectionFile(sqlitefile): + return "impl=cool;techno=sqlite;schema="+sqlitefile+";X:XPTWK130"; + +if 'SQLiteFile' in dir(): + DBConnection = DBConnectionFile(SQLiteFile) +else: + DBConnection = DBConnectionCOOL + +if (ReadCOOL): + + include ("IOVDbSvc/IOVDbSvc_jobOptions.py") + + #if ( ReadCOOL and not 'SQLiteFile' in dir() ): + # PoolSvc = Service ( "PoolSvc" ) + # PoolSvc.ReadCatalog += [ "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml" ] + + PedestalTagSpec = FolderTag(PedestalFolder,PedestalFolderTag) + + IOVDbSvc.Folders += [ PedestalFolder+"<tag>"+PedestalTagSpec+"</tag>"+"<dbConnection>"+DBConnection+"</dbConnection>"+ChannelSelection ] + IOVDbSvc.OutputLevel = DEBUG + +else: + + include("AthenaSealSvc/AthenaSealSvc_joboptions.py") + include("LArRawConditions/LArRawConditionsDict_joboptions.py") + include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") + + EventPersistencySvc = Service( "EventPersistencySvc" ) + EventPersistencySvc.CnvServices += [ "AthenaPoolCnvSvc" ] + + ProxyProviderSvc = Service( "ProxyProviderSvc" ) + ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] + CondProxyProvider = Service( "CondProxyProvider" ) + CondProxyProvider.InputCollections += [ PoolFileDir+"/"+PoolFileName ] + +########################################################################### +# +# Dump pedestal DB folder(s) to a ROOT ntuple +# +########################################################################### + +from LArCalibTools.LArCalibToolsConf import LArPedestals2Ntuple +LArPedestals2Ntuple = LArPedestals2Ntuple("LArPedestals2Ntuple") +LArPedestals2Ntuple.ContainerKey = ContainerKey +topSequence += LArPedestals2Ntuple + +########################################################################### +# +# Write out to ROOT file +# +########################################################################### + +theApp.Dlls += [ "RootHistCnv" ] +theApp.HistogramPersistency = "ROOT" +NTupleSvc = Service( "NTupleSvc" ) +NTupleSvc.Output = [ "FILE1 DATAFILE='"+NtupleFileName+"' OPT='NEW'" ] + +########################################################################### +# +# Use EventSelector to select IOV +# +########################################################################### + +if (ReadCOOL): + + EventSelector = Service( "EventSelector" ) + EventSelector.RunNumber = RunNumber + EventSelector.EventsPerRun = 1 + EventSelector.FirstEvent = 1 + EventSelector.InitialTimeStamp = 0 + EventSelector.TimeStampInterval = 1 + +########################################################################### + +theApp.EvtMax = 1 + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = INFO + +########################################################################### + +StoreGateSvc = Service( "StoreGateSvc" ) +StoreGateSvc.Dump = True + +DetectorStore = Service( "DetectorStore" ) +DetectorStore.Dump = True + +ConditionsStore = Service( "ConditionsStore" ) +ConditionsStore.Dump = True + +########################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/LArPhysCaliTDiffAlg.py b/LArCalorimeter/LArCalibTools/share/LArPhysCaliTDiffAlg.py new file mode 100644 index 000000000000..c0adfc7f19ce --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArPhysCaliTDiffAlg.py @@ -0,0 +1,86 @@ +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector +from string import split,join +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.Luminosity.set_zero() +GlobalFlags.DataSource.set_data() +GlobalFlags.InputFormat.set_bytestream() + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-16-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) + +svcMgr.IOVDbSvc.GlobalTag="LARCALIB-000-01" +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = 500000 + +dbname="<db>COOLOFL_LAR/COMP200</db>" + +conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<key>/LAR/BadChannels/BadChannels</key>"+dbname) +conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<key>/LAR/BadChannels/MissingFEBs</key>"+dbname) +conddb.addFolder("","/LAR/ElecCalibOfl/PhysCaliTdiff<key>input</key>"+dbname) + + +from LArCalibTools.LArCalibToolsConf import LArPhysCaliTDiffAlg +theLArPhysCaliTDiffAlg=LArPhysCaliTDiffAlg() +theLArPhysCaliTDiffAlg.OutputLevel=DEBUG +theLArPhysCaliTDiffAlg.AddFEBTempInfo=False +theLArPhysCaliTDiffAlg.InputContainer="input" +theLArPhysCaliTDiffAlg.FileName="FebOffsets.txt" + +topSequence+=theLArPhysCaliTDiffAlg + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='timediff.root' OPT='NEW'" ] + +#svcMgr.DetectorStore.Dump=True +#svcMgr.MessageSvc.OutputLevel = DEBUG + +svcMgr.IOVDbSvc.DBInstance="" +svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/poolcond/PoolCat_comcond_castor.xml", + ] + + +#svcMgr.MessageSvc.debugLimit = 5000000 + + +OutputPoolFile="AdjustedTimeOffsets.pool.root" +outObject="LArPhysCaliTdiffComplete#LArPhysCaliTdiff#/LAR/ElecCalibOfl/PhysCaliTdiff" +outTag="LARElecCalibOflPhysCaliTdiff-gaincorr-01" + +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg +OutputConditionsAlg = OutputConditionsAlg("OutputConditionsAlg",OutputPoolFile, + [outObject],[outTag],True) + + +from AthenaCommon.AppMgr import ServiceMgr +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True + + +svcMgr.IOVDbSvc.dbConnection="sqlite://;schema=tdiff.db;dbname=COMP200" diff --git a/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromDB2NTuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromDB2NTuple_jobOptions.py new file mode 100644 index 000000000000..834ec145fbb0 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromDB2NTuple_jobOptions.py @@ -0,0 +1,201 @@ +import commands +########################################################################### + +include("LArCalibProcessing/LArCalib_Flags.py") +include("RecExCommission/GetInputFiles.py") + +####################################################### +# Run properties +####################################################### + +if not 'RunNumber' in dir(): + RunNumber = 88237 + +if not ' GainList' in dir(): + GainList = ["HIGH", "MEDIUM", "LOW"] + +if not 'ChannelSelection' in dir(): + ChannelSelection="" + +if not 'SaveDerivedInfo' in dir(): + SaveDerivedInfo = True + +if not 'StripsXtalkCorr' in dir(): + StripsXtalkCorr = True # Xtalk correction for strips + +if not 'Partition' in dir(): + Partition = "EB-EMB" + +if not 'LArInputWaveKey' in dir(): + LArInputWaveKey = "LArPhysWave" + +if not 'LArInputWaveTag' in dir(): + LArInputWaveTag = "" + +####################################################### +# Delay output name +####################################################### + +if not 'WriteNtuple' in dir(): + WriteNtuple = LArCalib_Flags.WriteNtuple + +if not 'WritePoolFile' in dir(): + WritePoolFile = LArCalib_Flags.WritePoolFile + +if not 'WriteIOV' in dir(): + WriteIOV = LArCalib_Flags.WriteIOV + +if not 'IOVBegin' in dir(): + IOVBegin = RunNumber + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200" + +if not 'DBConnectionWave' in dir(): + DBConnectionWave = DBConnectionCOOL + +## Output + +if not 'LArCalibFolderOutput' in dir(): + if StripsXtalkCorr: + LArCalibFolderOutput = LArCalib_Flags.LArPhysWaveFolderXtlk + else: + LArCalibFolderOutput = LArCalib_Flags.LArPhysWaveFolder +if not 'LArCalibFolderOutputTag' in dir(): + LArCalibFolderOutputTag = LArCalib_Flags.tagSuffix + +if not 'OutputPhysWaveRootFileDir' in dir(): + OutputPhysWaveRootFileDir = commands.getoutput("pwd") + +if not 'KeyOutput' in dir(): + KeyOutput = "LArPhysWave" # Key of LArPhysWaveContainer saved in Pool file + +if not 'BaseFileName' in dir(): + BaseFileName = "LArPhysWave" + +if StripsXtalkCorr : + BaseFileName = BaseFileName+"_"+str(RunNumber)+"_"+Partition.replace("*","") +"_StripsXtalkCorr" +else : + BaseFileName = BaseFileName+"_"+str(RunNumber)+"_"+Partition.replace("*","") + +if not 'OutputPhysWaveRootFileName' in dir(): + OutputPhysWaveRootFileName = BaseFileName+".root" + +if not 'OutputPhysWavePoolFileName' in dir(): + OutputPhysWavePoolFileName = BaseFileName+".pool.root" + +if not 'OutputObjectSpecPhysWave' in dir(): + OutputObjectSpecPhysWave = "LArPhysWaveContainer#"+KeyOutput+"#"+LArCalibFolderOutput + OutputTagSpecPhysWave = LArCalibFolderTag(LArCalibFolderOutput,LArCalibFolderOutputTag) + +########################################################################### +# +# Global settings +# +########################################################################### + +include("AthenaCommon/Atlas_Gen.UnixStandardJob.py") + +# +# Provides ByteStreamInputSvc name of the data file to process in the offline context +# + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + + +## define the DB Gobal Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" + +from IOVDbSvc.CondDB import conddb + +conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + +svcMgr.PoolSvc.ReadCatalog += ["prfile:poolcond/PoolCat_oflcond.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000005.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000006.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_diskbuffer_afs.xml", + "xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_cond08_data.000001.lar.COND_castor.xml"] + +## The reference is the Oracle DB +if not 'LArInputWaveFolder' in dir(): + if StripsXtalkCorr: + conddb.addFolder("",LArCalib_Flags.LArPhysWaveFolderXtlk+"<key>"+LArInputWaveKey+"</key><dbConnection>"+DBConnectionWave+"</dbConnection>"+ChannelSelection) + else: + conddb.addFolder("",LArCalib_Flags.LArPhysWaveFolder+"<key>"+LArInputWaveKey+"</key><dbConnection>"+DBConnectionWave+"</dbConnection>"+ChannelSelection) +else: + InputTagSpecPhysWave = LArCalibFolderTag(LArInputWaveFolder,LArInputWaveTag) + print 'Input tag: ',InputTagSpecPhysWave," in folder: ",LArInputWaveFolder + conddb.addFolder("",LArInputWaveFolder+"<key>"+LArInputWaveKey+"</key><dbConnection>"+DBConnectionWave+"</dbConnection>"+ChannelSelection) + + +########################################################################## +# # +# Output # +# # +########################################################################## + +if (WriteNtuple): + from LArCalibTools.LArCalibToolsConf import LArPhysWaves2Ntuple + LArPhysWaves2Ntuple = LArPhysWaves2Ntuple( "LArPhysWaves2Ntuple" ) + LArPhysWaves2Ntuple.NtupleName = "PhysWave" + LArPhysWaves2Ntuple.SaveDerivedInfo = SaveDerivedInfo + LArPhysWaves2Ntuple.KeyList = [ LArInputWaveKey ] + + topSequence+=LArPhysWaves2Ntuple + + theApp.HistogramPersistency = "ROOT" + from GaudiSvc.GaudiSvcConf import NTupleSvc + if os.path.exists(OutputPhysWaveRootFileDir+"/"+OutputPhysWaveRootFileName): + os.remove(OutputPhysWaveRootFileDir+"/"+OutputPhysWaveRootFileName) + svcMgr += NTupleSvc() + svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+OutputPhysWaveRootFileDir+"/"+OutputPhysWaveRootFileName+"' OPT='NEW'" ] + +########################################################################### + + +########################################################################### +# Use EventSelector to select IOV # +########################################################################### + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = RunNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 1 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + + +########################################################################## +# don't remove otherwise infinite loop # +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +from AthenaCommon.AppMgr import theAuditorSvc +from AthenaCommon.ConfigurableDb import getConfigurable +theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = WARNING) +theAuditorSvc += getConfigurable("ChronoAuditor")() +theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromNTuple2Pool_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromNTuple2Pool_jobOptions.py new file mode 100755 index 000000000000..aecb3e7bae0d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromNTuple2Pool_jobOptions.py @@ -0,0 +1,150 @@ +# Last update: Caroline Collard 2009-03-31 + +import commands +########################################################################### +include("LArCalibProcessing/LArCalib_Flags.py") + +# output POOL file: +if not 'writePOOLfile' in dir(): + writePOOLfile = True + +if not 'PhysWavePOOLFileOUT' in dir(): + PhysWavePOOLFileOUT = "/tmp/collard/PhysWaves_88240_EMBC.pool.root" + +if not 'writeNTuple' in dir(): + writeNTuple = True + +if not 'PhysWaveNTFile' in dir(): + PhysWaveNTFile = "/tmp/collard/PhysWaves_88240_EMBC.root" + +########################################################################### +# +# Global settings +# +########################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include( "LArCalibProcessing/LArCalib_MinimalSetup.py") + +########################################################################### +# # +# Input conditions data (CaliWave) for COOL and/or POOL # +# # +########################################################################### + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") + +## define the DB Gobal Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200;user=ATLAS_COOL_READER" +conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + +svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "prfile:poolcond/PoolCat_oflcond.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_diskbuffer_afs.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_cond08_data.000001.lar.COND_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000003.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000004.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000005.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000006.lar_conditions.recon.pool.v0000_castor.xml"] + + + + +######################################################################################################### +# +# Reading Ntuple ... +######################################################################################################### +theApp.Dlls += ["LArRawUtils"] +theApp.Dlls += ["LArTools"] +theApp.Dlls += ["LArCalibUtils"] +theApp.Dlls += ["LArCalibTools"] + +theApp.TopAlg += [ "LArPhysWaveFromTuple" ] +LArPhysWaveFromTuple = Algorithm( "LArPhysWaveFromTuple" ) +LArPhysWaveFromTuple.NPoints = 768 +LArPhysWaveFromTuple.SkipPoints = 4 +LArPhysWaveFromTuple.PrefixPoints = 25 +LArPhysWaveFromTuple.deltaT = (1./(40.08*1.e-3))/24. +LArPhysWaveFromTuple.LArWaveFlag = 20 +LArPhysWaveFromTuple.FileNames = [ + "/tmp/collard/fpm_pulse_mini88240.root" +] +LArPhysWaveFromTuple.StoreKey = "FROMTUPLE" + + +########################################################################### +# +# Writing to Ntuple... +# +########################################################################### + +if ( writeNTuple ): + + from LArCalibTools.LArCalibToolsConf import LArPhysWaves2Ntuple + LArPhysWaves2Ntuple = LArPhysWaves2Ntuple( "LArPhysWaves2Ntuple" ) + LArPhysWaves2Ntuple.NtupleName = "PHYSWAVE" + # LArPhysWaves2Ntuple.ReadCaliWave = False + LArPhysWaves2Ntuple.KeyList = [ "FROMTUPLE" ] + LArPhysWaves2Ntuple.SaveDerivedInfo = False + LArPhysWaves2Ntuple.OutputLevel = VERBOSE + + topSequence += LArPhysWaves2Ntuple + + + theApp.HistogramPersistency = "ROOT" + from GaudiSvc.GaudiSvcConf import NTupleSvc + svcMgr += NTupleSvc() + svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+PhysWaveNTFile+"' OPT='NEW'" ] + + +########################################################################### +# +# writing to POOL file... +# +########################################################################### + +if ( writePOOLfile ): + + OutputObjectSpec = "LArPhysWaveContainer#FROMTUPLE" + #OutputObjectSpecTag = ??? + + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + theOutputConditionsAlg = OutputConditionsAlg("OutputConditionsAlg",PhysWavePOOLFileOUT, + [OutputObjectSpec],[],False) + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +from AthenaCommon.AppMgr import theAuditorSvc +from AthenaCommon.ConfigurableDb import getConfigurable +theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = DEBUG) +theAuditorSvc += getConfigurable("ChronoAuditor")() +theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromStdNtuple2Pool_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromStdNtuple2Pool_jobOptions.py new file mode 100755 index 000000000000..906d58e92c09 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromStdNtuple2Pool_jobOptions.py @@ -0,0 +1,167 @@ +# Last update: Caroline Collard 2009-03-31 + +import commands +########################################################################### +include("LArCalibProcessing/LArCalib_Flags.py") + +# output POOL file: +if not 'writePOOLfile' in dir(): + writePOOLfile = True + +if not 'PhysWavePOOLFileOUT' in dir(): + PhysWavePOOLFileOUT = "LArPhysWave_0_HEC.pool.root" + +if not 'PhysWaveNTFileOUT' in dir(): + PhysWaveNTFileOUT = "LArPhysWave_0_HEC_new.root" + +if not 'writeNTuple' in dir(): + writeNTuple = True + +if not 'PhysWaveNTFileIN' in dir(): + PhysWaveNTFileIN = "LArPhysWave_0_HEC.root" + +if not 'OutputKey' in dir(): + OutputKey = "LArPhysWaveHECIdeal" + +if not 'OutputFolder' in dir(): + OutputFolder="/LAR/ElecCalibOfl/PhysWaves/HECIdeal" + +if not 'OutputTag' in dir(): + OutputTag="comm-08" + +if not 'GroupingType' in dir(): + GroupingType = "ExtendedSubDetector" + +########################################################################### +# +# Global settings +# +########################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include( "LArCalibProcessing/LArCalib_MinimalSetup.py") + +if not 'OutputDB' in dir(): + OutputDB = LArCalib_Flags.OutputDB + +if 'OutputSQLiteFile' in dir(): + OutputDB = "sqlite://;schema="+OutputSQLiteFile+";dbname=COMP200" + +########################################################################### +# # +# Input conditions data (CaliWave) for COOL and/or POOL # +# # +########################################################################### + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") + +## define the DB Gobal Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200" +conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + +svcMgr.PoolSvc.ReadCatalog += ["xmlcatalog_file:/afs/cern.ch/user/l/larcalib/w0/stableConds/PoolCat_stable.xml", + "prfile:poolcond/PoolCat_oflcond.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_diskbuffer_afs.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_cond08_data.000001.lar.COND_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000003.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000004.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000005.lar_conditions.recon.pool.v0000_castor.xml", + "xmlcatalog_file:/afs/cern.ch/atlas/conditions/poolcond/catalogue/fragments/PoolCat_comcond.000006.lar_conditions.recon.pool.v0000_castor.xml"] + + + + +######################################################################################################### +# +# Reading Ntuple ... +######################################################################################################### + +from LArCalibTools.LArCalibToolsConf import LArPhysWaveFromStdNtuple +LArPhysWaveFromTuple = LArPhysWaveFromStdNtuple() +LArPhysWaveFromTuple.SkipPoints = 0 +LArPhysWaveFromTuple.PrefixPoints = 0 +LArPhysWaveFromTuple.FileNames = [ PhysWaveNTFileIN ] +LArPhysWaveFromTuple.StoreKey = OutputKey +LArPhysWaveFromTuple.GroupingType = GroupingType + +topSequence += LArPhysWaveFromTuple + +########################################################################### +# +# Writing to Ntuple... +# +########################################################################### + +if ( writeNTuple ): + + from LArCalibTools.LArCalibToolsConf import LArPhysWaves2Ntuple + LArPhysWaves2Ntuple = LArPhysWaves2Ntuple( "LArPhysWaves2Ntuple" ) + LArPhysWaves2Ntuple.NtupleName = "PHYSWAVE" + # LArPhysWaves2Ntuple.ReadCaliWave = False + LArPhysWaves2Ntuple.KeyList = [ OutputKey ] + LArPhysWaves2Ntuple.SaveDerivedInfo = True + + topSequence += LArPhysWaves2Ntuple + + + theApp.HistogramPersistency = "ROOT" + from GaudiSvc.GaudiSvcConf import NTupleSvc + svcMgr += NTupleSvc() + svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+PhysWaveNTFileOUT+"' OPT='NEW'" ] + + +########################################################################### +# +# writing to POOL file... +# +########################################################################### + +if ( writePOOLfile ): + + OutputObjectSpecPhysWave = "LArPhysWaveContainer#"+OutputKey+"#"+ OutputFolder + OutputObjectSpecTagPhysWave = LArCalibFolderTag(OutputFolder,OutputTag) + + + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + theOutputConditionsAlg = OutputConditionsAlg("OutputConditionsAlg",PhysWavePOOLFileOUT, + [OutputObjectSpecPhysWave],[OutputObjectSpecTagPhysWave],True) + + theOutputConditionsAlg.Run1 = 0 + + svcMgr.IOVDbSvc.dbConnection = OutputDB + + from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc + svcMgr += IOVRegistrationSvc() + svcMgr.IOVRegistrationSvc.RecreateFolders = True + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromTuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromTuple_jobOptions.py new file mode 100644 index 000000000000..38dc7232d69e --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArPhysWaveFromTuple_jobOptions.py @@ -0,0 +1,91 @@ +########################################################################### +# +# LArPhysWaveFromTuple_jobOptions.py +# author: Alan Robinson <fbfree@interchange.ubc.ca> +# Converts formatted Root NTuple into a LArPhysWave ready for the +# conditions DB. Created for FCal wave shapes. +# +########################################################################### + +writePOOLfile = True +PhysWavePOOLFileOUT = "~/scratch0/poolFiles/FCalWave.pool.root" + +writeNTuple = True +PhysWaveNTFile = "~/scratch0/rootFiles/FCalCheck.root" + +InFile = "~/scratch0/FCalWave.root" + +NPoints = 189 +NSkipPoints = 23 # Shift peak to the 3rd sample if it is at 96ns + +########################################################################### +theApp.EvtMax = 1 + +ToolSvc = Service( "ToolSvc" ) +ToolSvc.LArRoI_Map.Print = False + +include( "AthenaCommon/Atlas.UnixStandardJob.py" ) + +# the following works for release 13 but nor for rel 12 +#DetDescrVersion = "ATLAS-CSC-01-01-00" +#include( "RecExCond/RecExCommon_flags.py" ) +#DetFlags.detdescr.ID_setOff() +#DetFlags.detdescr.Tile_setOff() +#DetFlags.detdescr.Muon_setOff() +#include ("RecExCond/AllDet_detDescr.py") + +# use this for release 12 +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) + + +theApp.Dlls += ["LArRawUtils"] +theApp.Dlls += ["LArTools"] +theApp.Dlls += ["LArCalibUtils"] +theApp.Dlls += ["LArCalibTools"] + +theApp.TopAlg += [ "LArPhysWaveFromTuple" ] +LArPhysWaveFromTuple = Algorithm( "LArPhysWaveFromTuple" ) +LArPhysWaveFromTuple.NPoints = NPoints +LArPhysWaveFromTuple.SkipPoints = NSkipPoints +LArPhysWaveFromTuple.PrefixPoints = 0 +LArPhysWaveFromTuple.deltaT = 1. +LArPhysWaveFromTuple.LArWaveFlag = 3 # Code for "Master Waveform Normalized" +LArPhysWaveFromTuple.FileNames = [ InFile ] +LArPhysWaveFromTuple.StoreKey = "LArPhysWave" +LArPhysWaveFromTuple.GroupingType = "ExtendedFeedThrough" + + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel = INFO + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = INFO +########################################################################### + +if ( writePOOLfile ) : + include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + AthenaSealSvc.CheckDictionary = True + + include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + include( "LArAthenaPool/LArAthenaPool_joboptions.py" ) + include( "LArCondAthenaPool/LArCondAthenaPool_joboptions.py" ) + + include("RegistrationServices/OutputConditionsAlg_jobOptions.py") + ToolSvc.ConditionsAlgStream.OutputFile = PhysWavePOOLFileOUT + + OutputConditionsAlg.ObjectList = [ "LArPhysWaveContainer#LArPhysWave#/LAR/ElecCalib/PhysWave" ] + +if ( writeNTuple ) : + theApp.Dlls += ["LArCalibTools"] + theApp.TopAlg += [ "LArWaves2Ntuple/LArPhysWaves2Ntuple"] + LArPhysWaves2Ntuple = Algorithm( "LArPhysWaves2Ntuple" ) + LArPhysWaves2Ntuple.NtupleName = "outfit" + LArPhysWaves2Ntuple.ReadCaliWave = False + LArPhysWaves2Ntuple.KeyList = [ "LArPhysWave" ] + theApp.Dlls += [ "RootHistCnv" ] + theApp.HistogramPersistency = "ROOT" + NTupleSvc = Service( "NTupleSvc" ) + NTupleSvc.Output = [ "FILE1 DATAFILE='"+PhysWaveNTFile+"' OPT='NEW'" ] + diff --git a/LArCalorimeter/LArCalibTools/share/LArRamp2Ntuple_POOL_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArRamp2Ntuple_POOL_jobOptions.py new file mode 100755 index 000000000000..8ca41eb48cf3 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArRamp2Ntuple_POOL_jobOptions.py @@ -0,0 +1,107 @@ +############################################################## +# Job options read a LArRampComplete object from a POOL file # +# and dump it to an ROOT ntuple # +############################################################## + +import commands +Ramp2NtupleLog = logging.getLogger( "Ramp2NtupleLog" ) + +if not 'PoolFileNameList' in dir(): + Ramp2NtupleLog.fatal("Please setup the input POOL file list ('PoolFileNameList')!") + theApp.exit(-1) + +if not 'RootFileName' in dir(): + RootFileName = "LArRamp2Ntuple_POOL_root" + +if not 'SaveRawRamp' in dir(): + SaveRawRamp = True + +if not 'SaveAllSamples' in dir(): + SaveAllSamples = False + +if not 'RunNumber' in dir(): + RunNumber=165983 + +########################################################################### + +include("LArCalibProcessing/LArCalib_Flags.py") + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +########################################################################### + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200;" + #DBConnectionCOOL = "COOLONL_LAR/COMP200" + +## define the DB Global Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" +svcMgr.IOVDbSvc.forceRunNumber=RunNumber + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +# Temperature folder +conddb.addFolder("DCS_OFL","/LAR/DCS/FEBTEMP") + +if 'InputBadChannelSQLiteFile' in dir(): + from string import * + InputDBConnectionBadChannel = "sqlite://;schema="+InputBadChannelSQLiteFile+";dbname=COMP200" +else: + InputDBConnectionBadChannel = DBConnectionCOOL + + +if ('InputBadChannelSQLiteFile' in dir()) or ("OFL" in DBConnectionCOOL): + conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<dbConnection>"+InputDBConnectionBadChannel+"</dbConnection>") + conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<dbConnection>"+InputDBConnectionBadChannel+"</dbConnection>") +else: + conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+InputDBConnectionBadChannel+"</dbConnection>") + conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+InputDBConnectionBadChannel+"</dbConnection>") + +include("LArCalibProcessing/LArCalib_BadChanTool.py") + +from AthenaCommon.ConfigurableDb import getConfigurable +svcMgr += getConfigurable( "ProxyProviderSvc" )() +svcMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] +svcMgr += getConfigurable( "CondProxyProvider" )() +svcMgr.CondProxyProvider.InputCollections += PoolFileNameList + + +from LArCalibTools.LArCalibToolsConf import LArRamps2Ntuple +LArRamps2Ntuple=LArRamps2Ntuple("LArRamps2Ntuple") +LArRamps2Ntuple.ContainerKey = ["HIGH","MEDIUM","LOW"] +LArRamps2Ntuple.RawRamp=SaveRawRamp +LArRamps2Ntuple.SaveAllSamples=SaveAllSamples + +topSequence+= LArRamps2Ntuple + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+RootFileName+"' OPT='NEW'" ] + + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel=ERROR + +theApp.EvtMax=1 +svcMgr.MessageSvc.OutputLevel=DEBUG + +#StoreGateSvc=Service("StoreGateSvc"); +#StoreGateSvc.dump=TRUE + +#DetStore=Service("DetectorStore"); +#DetStore.dump=TRUE diff --git a/LArCalorimeter/LArCalibTools/share/LArRamp2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArRamp2Ntuple_jobOptions.py new file mode 100755 index 000000000000..49a84597a9ef --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArRamp2Ntuple_jobOptions.py @@ -0,0 +1,60 @@ +############################################## +# Job options to dump the Ramps to a ntuple. # +############################################## + +from AthenaCommon.DetFlags import DetFlags +DetFlags.all_setOff() +DetFlags.em_setOn() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DetGeo.set_ctbh8() +GlobalFlags.DataSource.set_data() +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +include( "LArDetDescr/LArDetDescr_H8_joboptions.py" ) +#include ("LArIdCnv/LArIdCnv_joboptions.py") +#include ("LArConditionsCommon/LArIdMap_H8_jobOptions.py") + +EventSelector = Service( "EventSelector" ) +EventSelector.RunNumber=1000942 +EventSelector.EventsPerRun=1 +EventSelector.FirstEvent=1 + +LArTB04FolderTag_Calib = "TB04-Default" +LArTB04FolderTag_Pedestal = "TB04-Default" +LArTB04FolderTag_Ramp = "TB04-Default" +LArTB04FolderTag_OFC_RTM = "TB04-Default" +LArTB04FolderTag_OFC_TCM = "TB04-Default" + +include ( "LArConditionsCommon/LArConditionsCommon_H8_jobOptions.py") + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +from LArCalibTools.LArCalibToolsConf import LArRamps2Ntuple +LArRamps2Ntuple=LArRamps2Ntuple("LArRamps2Ntuple") +LArRamps2Ntuple.ContainerKey = ["HIGH","MEDIUM","LOW"] +LArRamps2Ntuple.RawRamp=False +LArRamps2Ntuple.SaveAllSamples=False + +topSequence+= LArRamps2Ntuple + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='LArRamp.root' OPT='NEW'" ] + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel=ERROR + +theApp.EvtMax=1 +svcMgr.MessageSvc.OutputLevel=DEBUG + +#DetStore=Service("DetectorStore"); +#DetStore.dump=TRUE + diff --git a/LArCalorimeter/LArCalibTools/share/LArRampPool2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArRampPool2Ntuple_jobOptions.py new file mode 100755 index 000000000000..7a032b7c1736 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArRampPool2Ntuple_jobOptions.py @@ -0,0 +1,71 @@ +############################################################## +# Job options read a LArRampComplete object from a POOL file # +# and dump it to an ROOT ntuple # +# modified for commissioning # +############################################################## + +PoolFileNameList = ["RampPoolFileToRead.pool.root"] + +from AthenaCommon.DetFlags import DetFlags +DetFlags.all_setOff() +DetFlags.em_setOn() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DataSource.set_data() +GlobalFlags.DetGeo.set_commis() +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +include( "AthenaCommon/Atlas.UnixStandardJob.py" ) + +# the Tile, LAr and Calo detector description package +DetDescrVersion = "ATLAS-CommNF-03-00-00" +include ("AtlasGeoModel/SetGeometryVersion.py") +include( "AtlasGeoModel/GeoModelInit.py" ) +include( "CaloIdCnv/CaloIdCnv_joboptions.py" ) +include( "TileIdCnv/TileIdCnv_jobOptions.py" ) +include( "LArDetDescr/LArDetDescr_joboptions.py" ) + +theApp.EvtMax = 1 + +CondProxyProvider = Service( "CondProxyProvider" ) +ProxyProviderSvc = Service( "ProxyProviderSvc" ) +ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] +EventPersistencySvc = Service( "EventPersistencySvc" ) +EventPersistencySvc.CnvServices += [ "AthenaPoolCnvSvc" ] +CondProxyProvider.InputCollections += PoolFileNameList + + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + + +from LArCalibTools.LArCalibToolsConf import LArRamps2Ntuple +LArRamps2Ntuple=LArRamps2Ntuple("LArRamps2Ntuple") +LArRamps2Ntuple.ContainerKey = ["HIGH","MEDIUM","LOW"] +LArRamps2Ntuple.RawRamp=False +LArRamps2Ntuple.SaveAllSamples=False + +topSequence+= LArRamps2Ntuple + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='LArRampFromPool.root' OPT='NEW'" ] + + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel=ERROR + +theApp.EvtMax=1 +svcMgr.MessageSvc.OutputLevel=DEBUG + +#StoreGateSvc=Service("StoreGateSvc"); +#StoreGateSvc.dump=TRUE + +#DetStore=Service("DetectorStore"); +#DetStore.dump=TRUE diff --git a/LArCalorimeter/LArCalibTools/share/LArReadParamsFromFile_CTB2004_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArReadParamsFromFile_CTB2004_jobOptions.py new file mode 100755 index 000000000000..bc6f3790964b --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArReadParamsFromFile_CTB2004_jobOptions.py @@ -0,0 +1,184 @@ +########################################################################### +# +# * Read parameters from ascii file into the appropriate conditions object +# +# FILE FORMAT: +# ----------- +# * Each record in the file refers to a channel, which can be identified using +# * either offline coordinates or online coordinates. +# +# *------------------------------------------------------------------------------------------ +# * File record format for OFFLINE coordinates (for readout channels only): +# * det subdet barrel_ec layer region eta phi parameters... (using offline channel id) +# * > det = 4 for LAr Calorimeter +# * > subdet = 1(EMB+EMEC) , 2(HEC) , 3(FCAL) +# * > barrel_ec = +/-1(barrel) , +/-2(emec outer wheel) , +/-3(emec inner wheel) +# * > region,eta,phi: see explanation in CaloIdentifier/LArEM_ID LArHEC_ID and LArFCAL_ID. +# * > parameters: values to be set for each channel +# *------------------------------------------------------------------------------------------ +# * File record format for ONLINE coordinates (for readout and calibration channels): +# * barrel_ec posneg feedthrough slot channel parameters... (using online channel id) +# * > barrel_ec = 0(barrel) , 1(em+had+fcal endcap) +# * > posneg = 0(neg.eta,C) , 1(pos.eta,A) +# * > feedthrough: see explanation in LArIdentifier/LArOnlineID.h +# * > parameters: values to be set for each channel +# *------------------------------------------------------------------------------------------ +# +########################################################################### +# +# define here the name of data structure to be read and saved to POOL. +# you need to set DataStructure (the name of the transient data class to fill) +# and DetStoreKey (the key to record/retrieve to/from detector store) +# +# Possible data structures are: +# +# - LArCaliPulseParamsComplete +# - LArDetCellParamsComplete +# - LArPhysCaliTdiffComplete +# - LArTdriftComplete +# - LArMphysOverMcalComplete +# - LArRinjComplete +# - LArTshaperComplete +# - LArEMEC_CphiComplete +# - LArEMEC_HValphaComplete +# - LArEMEC_HVbetaComplete +# - LArCableLengthComplete +# - LArCableAttenuationComplete +# - LArCaliPulseParamsVsCalib +# +# DetStoreKey must the same as DataStructure, without 'Complete' or 'VsCalib' +# + +#DataStructure = "MyData" # used by LArReadParamsFromFile and LArParams2Ntuple +#DetStoreKey = "Key" # used to extract collections from det.store and save to POOL +#AsciiFileName = "MyAsciiFile" # input ascii file +#ChannelIdType = "OfflineID" # file uses 'offline coordinates' (readout only) +#ChannelIdType = "OnlineID" # file uses 'online coordinates' (readout channels) +#ChannelIdType = "OnlineCalibID" # file uses 'online coordinates' (calibration lines) + +# An example for 'Complete' conditions object: +#-------------------------------------------- +#DataStructure = "LArDetCellParamsComplete" +#DetStoreKey = "LArDetCellParams" +#AsciiFileName = "/afs/cern.ch/user/m/mfanti/scratch0/Athena/Parameters/EMB/detcell_atlas_ft0.dat" +#ChannelIdType = "OfflineID" + +# An example for 'VsCalib' conditions object: +# ------------------------------------------ +#AsciiFileName = "/afs/cern.ch/user/m/mfanti/scratch0/Athena/Parameters/CTB-Barrel/Marco/CaliPulse_averaged.dat" +#DataStructure = "LArCaliPulseParamsVsCalib" +#DetStoreKey = "LArCaliPulseParams" +#ChannelIdType = "OnlineCalibID" + +# the following one is a non-physical test: +# ---------------------------------------- +#AsciiFileName = "/afs/cern.ch/user/m/mfanti/scratch0/Athena/Parameters/TestCalibLines/testAllCalibLinesH8.dat" +#DataStructure = "LArCaliPulseParamsVsCalib" +#DetStoreKey = "LArCaliPulseParams" +#ChannelIdType = "OnlineCalibID" + +WritePoolFile = True +WriteRootFile = True + +RootFileName = "params.root" +PoolFileName = "params.pool.root" + +########################################################################### +# +# Global settings +# +########################################################################### + +from AthenaCommon.GlobalFlags import GlobalFlags + +GlobalFlags.DetGeo.set_ctbh8() +GlobalFlags.Luminosity.set_zero() +GlobalFlags.DataSource.set_data() +GlobalFlags.InputFormat.set_bytestream() + +GlobalFlags.Print() + +from AthenaCommon.DetFlags import DetFlags + +DetFlags.digitize.em_on() +DetFlags.detdescr.em_setOn() +DetFlags.readRDOBS.em_setOn() +DetFlags.makeRIO.em_setOn() + +DetFlags.Print() + +LArCondCnvDbServer = 'atlobk02.cern.ch' +DetDescrVersion = "CTB" +useLArH8CondCool = True + +include("LArDetDescr/LArDetDescr_H8_joboptions.py") +DetDescrCnvSvc.DoIdChecks +DetDescrCnvSvc.LArIDFileName = "IdDictParser/IdDictLArCalorimeter_H8_2004.xml" + +ToolSvc = Service( "ToolSvc" ) +ToolSvc.LArRoI_Map.Print=False + + +########################################################################### +# +# Reading ascii file... +# +########################################################################### + +theApp.Dlls += ["LArCalibTools"] + +AlgName = "LArReadParamsFromFile<" + DataStructure + ">/LArReadFile" + +theApp.TopAlg += [ AlgName ] +LArReadFile=Algorithm( "LArReadFile" ) +LArReadFile.File = AsciiFileName +LArReadFile.ChannelIdType = ChannelIdType +#LArReadFile.OutputLevel = VERBOSE + +########################################################################### +# +# Output +# +########################################################################### + +if ( WriteRootFile ) : + + theApp.TopAlg += [ "LArParams2Ntuple" ] + LArParams2Ntuple=Algorithm( "LArParams2Ntuple" ) + LArParams2Ntuple.KeyList += [ DataStructure ] + #LArParams2Ntuple.DumpAllOnlineChannels = "dumpOnlineChannels_H8.txt" # ascii dump of all channels + #LArParams2Ntuple.UseAbstractInterface = True # access data set through abstract interface + #LArParams2Ntuple.AllChannels2Ntuple = True # loop through ALL existing online channels + #LArParams2Ntuple.OutputLevel = VERBOSE + + theApp.Dlls += [ "RootHistCnv" ] + theApp.HistogramPersistency = "ROOT" + NTupleSvc = Service( "NTupleSvc" ) + NTupleSvc.Output = [ "FILE1 DATAFILE='"+RootFileName+"' OPT='NEW'" ] + +if ( WritePoolFile ) : + + include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + AthenaSealSvc.CheckDictionary = True + + include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + theApp.Dlls += [ "LArAthenaPoolPoolCnv" ] + theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] + + include("RegistrationServices/OutputConditionsAlg_jobOptions.py") + ToolSvc.ConditionsAlgStream.OutputFile = PoolFileName + + OutputConditionsAlg.ObjectList = [ DataStructure + "#" + DetStoreKey ] + +########################################################################### + +theApp.EvtMax = 1 + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = INFO + +#ToolSvc.LArOnOffIdMap.OutputLevel = VERBOSE +#ToolSvc.LArOnOffIdMapCnv.OutputLevel = VERBOSE + +########################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/LArReadParamsFromFile_P3C_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArReadParamsFromFile_P3C_jobOptions.py new file mode 100644 index 000000000000..40140cf87e04 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArReadParamsFromFile_P3C_jobOptions.py @@ -0,0 +1,250 @@ +import commands +########################################################################### +# +# <Marco.Delmastro@cern.ch> +# +# Example jobOptions to put params in a poolfile+SQLite file +# +# Last update: 07/03/2008 <Fabien.Tarrade@cern.ch> +# +########################################################################### + +########################################################################### +# +# * Read parameters from ascii file into the appropriate conditions object +# +# FILE FORMAT: +# ----------- +# * Each record in the file refers to a channel, which can be identified using +# * either offline coordinates or online coordinates. +# +# *------------------------------------------------------------------------------------------ +# * File record format for OFFLINE coordinates (for readout channels only): +# * det subdet barrel_ec layer region eta phi parameters... (using offline channel id) +# * > det = 4 for LAr Calorimeter +# * > subdet = 1(EMB+EMEC) , 2(HEC) , 3(FCAL) +# * > barrel_ec = +/-1(barrel) , +/-2(emec outer wheel) , +/-3(emec inner wheel) +# * > region,eta,phi: see explanation in CaloIdentifier/LArEM_ID LArHEC_ID and LArFCAL_ID. +# * > parameters: values to be set for each channel +# *------------------------------------------------------------------------------------------ +# * File record format for ONLINE coordinates (for readout and calibration channels): +# * barrel_ec posneg feedthrough slot channel parameters... (using online channel id) +# * > barrel_ec = 0(barrel) , 1(em+had+fcal endcap) +# * > posneg = 0(neg.eta,C) , 1(pos.eta,A) +# * > feedthrough: see explanation in LArIdentifier/LArOnlineID.h +# * > parameters: values to be set for each channel +# *------------------------------------------------------------------------------------------ +# +########################################################################### +# +# define here the name of data structure to be read and saved to POOL. +# you need to set DataStructure (the name of the transient data class to fill) +# and DetStoreKey (the key to record/retrieve to/from detector store) +# +# Possible data structures are: +# +# - LArCaliPulseParamsComplete +# - LArDetCellParamsComplete +# - LArPhysCaliTdiffComplete +# - LArTdriftComplete +# - LArMphysOverMcalComplete +# - LArRinjComplete +# - LArTshaperComplete +# - LArEMEC_CphiComplete +# - LArEMEC_HValphaComplete +# - LArEMEC_HVbetaComplete +# - LArCableLengthComplete +# - LArCableAttenuationComplete +# - LArCaliPulseParamsVsCalib +# +# DetStoreKey must the same as DataStructure, without 'Complete' or 'VsCalib' +# +########################################################################### + + + +#DataStructure = "MyData" # used by LArReadParamsFromFile and LArParams2Ntuple +#DetStoreKey = "Key" # used to extract collections from det.store and save to POOL +#AsciiFileName = "MyAsciiFile" # input ascii file +#ChannelIdType = "OfflineID" # file uses 'offline coordinates' (readout only) +#ChannelIdType = "OnlineID" # file uses 'online coordinates' (readout channels) +#ChannelIdType = "OnlineCalibID" # file uses 'online coordinates' (calibration lines) + +# An example for 'Complete' conditions object: +#-------------------------------------------- + +if not 'DataStructure' in dir(): + DataStructure = "LArDetCellParamsComplete" + +if not 'DetStoreKey' in dir(): + DetStoreKey = "LArDetCellParams" + +if not 'AsciiFileName' in dir(): + AsciiFileName = "/users/carolina/rootFiles/pascal/lcmeas/new_detinner_Ccold.dat" + +if not 'ChannelIdType' in dir(): + ChannelIdType = "OfflineID" + +from string import * +def DBConnectionFile(sqlitefile): + return "sqlite://;schema="+sqlitefile+";dbname=COMP200" + +# output POOL file: +if not 'WritePoolFile' in dir(): + WritePoolFile = True + +if not 'PoolFileName' in dir(): + PoolFileName = "LArParams.pool.root" + +if not 'GroupingType' in dir(): + GroupingType = "FeedThroughGrouping" + +if not 'WriteIOV' in dir(): + WriteIOV = True + +if not 'IOVBegin' in dir(): + IOVBegin = 0 + +if not 'IOVEnd' in dir(): + IOVEnd = 0 + +if not 'LArCalibFolderOutputTag' in dir(): + LArCalibFolderOutputTag = "-comm-08" + +if not 'OutputDB' in dir(): + OutputDB = "sqlite://;schema=myDB200.db;dbname=COMP200" + +if 'OutputSQLiteFile' in dir(): + print 'OutputSQLiteFile',OutputSQLiteFile + OutputDB = DBConnectionFile(OutputSQLiteFile) + print 'OutputDB',OutputDB + +if not 'ParamsFolderName' in dir(): + ParamsFolderName = "/LAR/ElecCalib/DetCellParams" + +if not 'WriteNT' in dir(): + WriteNT = True + +if not 'RootFileName' in dir(): + RootFileName = "LArParams.root" + +########################################################################### +# +# Global settings +# +########################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +# +# Provides ByteStreamInputSvc name of the data file to process in the offline context +# + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + +include("LArCalibProcessing/LArCalib_Flags.py") +# define the DB Gobal Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB + +######################################################################################################### +# +# Reading ASCII file... + +######################################################################################################### + +# Example import statement for templated algorithms +#from LArCalibTools.LArCalibToolsConf import LArReadParamsFromFile_LArTdriftComplete_ as LArReadFile + +ImportStatement = "from LArCalibTools.LArCalibToolsConf import LArReadParamsFromFile_"+DataStructure+"_ as LArReadFile" +exec(ImportStatement) + +LArReadFile = LArReadFile("LArReadFile") +LArReadFile.File = AsciiFileName +LArReadFile.ChannelIdType = ChannelIdType +LArReadFile.GroupingType = GroupingType +if 'CustomKey' in dir(): + LArReadFile.CustomKey = CustomKey + +topSequence += LArReadFile + +########################################################################### +# +# Writing to Ntuple... +# +########################################################################### + +if ( WriteNT ): + + from LArCalibTools.LArCalibToolsConf import LArParams2Ntuple + LArParams2Ntuple = LArParams2Ntuple("LArParams2Ntuple") + LArParams2Ntuple.KeyList += [ DataStructure ] + # the following jOs act on ALL LAr readout channels! (~190000, also empty ones) and should be used for test only! + #LArParams2Ntuple.AllChannels2Ntuple = True # all channels to ntuple (also those with no params set) + #LArParams2Ntuple.DumpAllOnlineChannels = "dumpChannels.txt" # all channels identifiers to ascii file (for mapping tests) + if 'DetStoreSuffix' in dir(): + LArParams2Ntuple.DetStoreSuffix = DetStoreSuffix + + topSequence += LArParams2Ntuple + + theApp.HistogramPersistency = "ROOT" + from GaudiSvc.GaudiSvcConf import NTupleSvc + svcMgr += NTupleSvc() + svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+RootFileName+"' OPT='NEW'" ] + +########################################################################### +# +# writing to POOL file... +# +########################################################################### + +from string import * +def LArCalibFolderTag(folder,tag=LArCalibFolderOutputTag): + return join(split(folder, '/'),'') + tag + +if ( WritePoolFile ): + + OutputObjectSpec = DataStructure + "#" + DetStoreKey + "#" + ParamsFolderName + OutputObjectSpecTag = LArCalibFolderTag(ParamsFolderName, LArCalibFolderOutputTag) + + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + theOutputConditionsAlg = OutputConditionsAlg("OutputConditionsAlg",PoolFileName, + [OutputObjectSpec],[OutputObjectSpecTag],WriteIOV) + theOutputConditionsAlg.Run1 = IOVBegin + if IOVEnd>0: + theOutputConditionsAlg.Run2 = IOVEnd + + svcMgr.IOVDbSvc.dbConnection = OutputDB + + from AthenaCommon.AppMgr import ServiceMgr + from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc + svcMgr += IOVRegistrationSvc() + svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG + svcMgr.IOVRegistrationSvc.RecreateFolders = False + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +svcMgr.MessageSvc.OutputLevel = INFO +svcMgr.MessageSvc.defaultLimit = 10000 +svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = INFO) + +from AthenaCommon.AppMgr import theAuditorSvc +from AthenaCommon.ConfigurableDb import getConfigurable +theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = DEBUG) +theAuditorSvc += getConfigurable("ChronoAuditor")() +theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### + diff --git a/LArCalorimeter/LArCalibTools/share/LArShape2Ntuple_POOL_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArShape2Ntuple_POOL_jobOptions.py new file mode 100755 index 000000000000..c92cccba0823 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArShape2Ntuple_POOL_jobOptions.py @@ -0,0 +1,84 @@ +########################################################################### +# +# LArShape2Ntuple_POOL_jobOptions.py dumps the contet of a Wave POOL files +# to ROOT TTree. +# +# Author: Marco Delmastro <Marco.Delmastro@cern.ch> +# +# Last update: 2008-06-18 +# +########################################################################### + +import commands + +Shape2NtupleLog = logging.getLogger( "Shape2NtupleLog" ) + +if not 'PoolFileName' in dir(): + Shape2NtupleLog.fatal("Please setup the input POOL file ('PoolFileName')!") + theApp.exit(-1) + +if not 'ShapeKey' in dir(): + ShapeKey = "LArShape" + +if not 'RootFileName' in dir(): + RootFileName = "LArShape2Ntuple_POOL.root" + +########################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +########################################################################### + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + +########################################################################### + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") + +from AthenaCommon.ConfigurableDb import getConfigurable +svcMgr += getConfigurable( "ProxyProviderSvc" )() +svcMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] +svcMgr += getConfigurable( "CondProxyProvider" )() +svcMgr.CondProxyProvider.InputCollections += [ PoolFileName ] + +from LArCalibTools.LArCalibToolsConf import LArShape2Ntuple + +LArShape2Ntuple = LArShape2Ntuple("LArShape2Ntuple") +LArShape2Ntuple.ContainerKey = ShapeKey + +topSequence += LArShape2Ntuple + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+RootFileName+"' OPT='NEW'" ] + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +#svcMgr.MessageSvc.OutputLevel = INFO +#svcMgr.MessageSvc.defaultLimit = 10000 +#svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +#svcMgr += CfgMgr.AthenaEventLoopMgr(OutputLevel = VERBOSE) + +########################################################################### + +#from AthenaCommon.AppMgr import theAuditorSvc +#from AthenaCommon.ConfigurableDb import getConfigurable +#theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = DEBUG) +#theAuditorSvc += getConfigurable("ChronoAuditor")() +#theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/LArWaves2Ntuple_POOL_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArWaves2Ntuple_POOL_jobOptions.py new file mode 100755 index 000000000000..3abba2622a70 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LArWaves2Ntuple_POOL_jobOptions.py @@ -0,0 +1,143 @@ +########################################################################### +# +# LArWave2Ntuple_POOL_jobOptions.py dumps the contet of a Wave POOL files +# to ROOT TTree. Works with LArCaliWaveContainer and LAPhysWaveContainer. +# +# Author: Marco Delmastro <Marco.Delmastro@cern.ch> +# +# Last update: 2008-04-19 +# +########################################################################### + +import commands + +Waves2NtupleLog = logging.getLogger( "Waves2NtupleLog" ) + +if not 'PoolFileName' in dir(): + Waves2NtupleLog.fatal("Please setup the input POOL file ('PoolFileName')!") + theApp.exit(-1) + +if not 'WaveType' in dir(): + WaveType = "Cali" # (Cali, Phys) + +if not 'ContainerKey' in dir(): + if (WaveType == "Cali"): + ContainerKey = "LArCaliWave" + if (WaveType == "Phys"): + ContainerKey = "LArPhysWave" + +if not 'DACSaturSkip' in dir(): + DACSaturSkip = False + +if not 'SaveDerivedInfo' in dir(): + SaveDerivedInfo = False + +if not 'SaveJitter' in dir(): + SaveJitter = False + +if not 'RootFileName' in dir(): + RootFileName = "LArWaves2Ntuple_POOL.root" + +if not 'RunNumber' in dir(): + RunNumber = 165983 + +########################################################################### + +#include("LArConditionsCommon/LArMinimalSetup.py") + +include("LArCalibProcessing/LArCalib_Flags.py") + +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +########################################################################### + +include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") +include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") + +if not 'DBConnectionCOOL' in dir(): + DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=COMP200;" + #DBConnectionCOOL = "COOLONL_LAR/COMP200" + +## define the DB Global Tag : +svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" +svcMgr.IOVDbSvc.forceRunNumber=RunNumber + +from IOVDbSvc.CondDB import conddb +PoolFileList = [] + +# Temperature folder +conddb.addFolder("DCS_OFL","/LAR/DCS/FEBTEMP") + +if "ONL" in DBConnectionCOOL: + conddb.addFolder("","/LAR/BadChannels/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + conddb.addFolder("","/LAR/BadChannels/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") +else: + conddb.addFolder("","/LAR/BadChannelsOfl/BadChannels<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + conddb.addFolder("","/LAR/BadChannelsOfl/MissingFEBs<dbConnection>"+DBConnectionCOOL+"</dbConnection>") + include("LArCalibProcessing/LArCalib_BadChanTool.py") + +from AthenaCommon.ConfigurableDb import getConfigurable +svcMgr += getConfigurable( "ProxyProviderSvc" )() +svcMgr.ProxyProviderSvc.ProviderNames += [ "CondProxyProvider" ] +svcMgr += getConfigurable( "CondProxyProvider" )() +svcMgr.CondProxyProvider.InputCollections += [ PoolFileName ] + +if ( WaveType == "Cali" ): + + from LArCalibTools.LArCalibToolsConf import LArCaliWaves2Ntuple + LArCaliWaves2Ntuple = LArCaliWaves2Ntuple( "LArCaliWaves2Ntuple" ) + LArCaliWaves2Ntuple.NtupleName = "CALIWAVE" + LArCaliWaves2Ntuple.KeyList = [ ContainerKey ] + LArCaliWaves2Ntuple.DACSaturSkip = DACSaturSkip + LArCaliWaves2Ntuple.SaveDerivedInfo = SaveDerivedInfo + LArCaliWaves2Ntuple.SaveJitter = SaveJitter + LArCaliWaves2Ntuple.OutputLevel = INFO + + topSequence += LArCaliWaves2Ntuple + + +if ( WaveType == "Phys" ): + from LArCalibTools.LArCalibToolsConf import LArPhysWaves2Ntuple + LArPhysWaves2Ntuple = LArPhysWaves2Ntuple( "LArPhysWaves2Ntuple" ) + LArPhysWaves2Ntuple.NtupleName = "PHYSWAVE" + LArPhysWaves2Ntuple.KeyList = [ ContainerKey ] + LArPhysWaves2Ntuple.SaveDerivedInfo = SaveDerivedInfo + LArPhysWaves2Ntuple.OutputLevel = INFO + + topSequence += LArPhysWaves2Ntuple + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+RootFileName+"' OPT='NEW'" ] + +########################################################################## + +theApp.EvtMax = 1 + +########################################################################### + +#svcMgr.MessageSvc.OutputLevel = INFO +#svcMgr.MessageSvc.defaultLimit = 10000 +#svcMgr.MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +#svcMgr += CfgMgr.AthenaEventLoopMgr(OutputLevel = VERBOSE) + +########################################################################### + +#from AthenaCommon.AppMgr import theAuditorSvc +#from AthenaCommon.ConfigurableDb import getConfigurable +#theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = DEBUG) +#theAuditorSvc += getConfigurable("ChronoAuditor")() +#theAuditorSvc += getConfigurable("NameAuditor")() + +########################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/LAruAMeV2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LAruAMeV2Ntuple_jobOptions.py new file mode 100755 index 000000000000..cca171ddf2bd --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/LAruAMeV2Ntuple_jobOptions.py @@ -0,0 +1,49 @@ +######################################################### +# Job options to dump the LArADC2MeV factor to a ntuple.# +######################################################### + + +from AthenaCommon.DetFlags import DetFlags +DetFlags.all_setOff() +DetFlags.em_setOn() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DetGeo.set_ctbh8() +GlobalFlags.DataSource.set_data() +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +include( "LArDetDescr/LArDetDescr_H8_joboptions.py" ) +#include ("LArIdCnv/LArIdCnv_joboptions.py") +#include ("LArConditionsCommon/LArIdMap_H8_jobOptions.py") + +EventSelector = Service( "EventSelector" ) +EventSelector.RunNumber=1000942 +EventSelector.EventsPerRun=1 +EventSelector.FirstEvent=1 + +LArTB04FolderTag_Calib = "TB04-Default" +LArTB04FolderTag_Pedestal = "TB04-Default" +LArTB04FolderTag_Ramp = "TB04-Default" +LArTB04FolderTag_OFC_RTM = "TB04-Default" +LArTB04FolderTag_OFC_TCM = "TB04-Default" + +include ( "LArConditionsCommon/LArConditionsCommon_H8_jobOptions.py") + +theApp.Dlls += ["LArCalibTools"] + +theApp.TopAlg += [ "LAruA2MeV2Ntuple" ] + +theApp.Dlls += [ "RootHistCnv" ] +theApp.HistogramPersistency = "ROOT" +NTupleSvc = Service( "NTupleSvc" ) +NTupleSvc.Output = [ "FILE1 DATAFILE='uA2MEV.root' OPT='NEW'" ] + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel=ERROR + +theApp.EvtMax=1 +MessageSvc.OutputLevel=INFO + +DetStore=Service("DetectorStore"); +DetStore.dump=TRUE + diff --git a/LArCalorimeter/LArCalibTools/share/TestCaloCellGroup.py b/LArCalorimeter/LArCalibTools/share/TestCaloCellGroup.py new file mode 100644 index 000000000000..ee5147d0949d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/TestCaloCellGroup.py @@ -0,0 +1,60 @@ +import AthenaCommon.AtlasUnixGeneratorJob #use MC event selector + +## get a handle to the default top-level algorithm sequence +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DetGeo.set_commis() +GlobalFlags.Luminosity.set_zero() +GlobalFlags.DataSource.set_data() +GlobalFlags.InputFormat.set_bytestream() + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-Comm-00-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping (needed by LArConditionsContainer) +svcMgr.IOVDbSvc.GlobalTag='COMCOND-006-01' +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +theApp.EvtMax = 1 +svcMgr.EventSelector.RunNumber = 1 + + +from LArCalibTools.LArCalibToolsConf import CaloCellGroup2Ntuple +theCaloCellGroups2Ntuple=CaloCellGroup2Ntuple() +theCaloCellGroups2Ntuple.AddBadChannelInfo=False +theCaloCellGroups2Ntuple.group=["0, 21.1", + "[EMB,EMECIW,EMECOW/C/*/*/*/*] 1, 22.2", # + "[FCAL/A/*/*/*/*] 2, 24.4", #1 + "[EMB/C/1/0/0-32/*] 3, 32.2", #2 + "[EMECIW/*/1/0/3/4] 4, 42.2", #3 + ] +topSequence+=theCaloCellGroups2Ntuple + + +theApp.HistogramPersistency = "ROOT" +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='CellGroup.root' OPT='NEW'" ] + + +#from GaudiSvc.GaudiSvcConf import THistSvc +#svcMgr+=THistSvc() +#svcMgr.THistSvc.Output = [ "FILE1 DATAFILE='CellGroup.root' OPT='RECREATE'" ] + +#svcMgr.DetectorStore.Dump=True +#svcMgr.MessageSvc.OutputLevel = DEBUG + diff --git a/LArCalorimeter/LArCalibTools/share/TopOptsExample_ReadParamsFromFile.py b/LArCalorimeter/LArCalibTools/share/TopOptsExample_ReadParamsFromFile.py new file mode 100644 index 000000000000..5411acaf898e --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/TopOptsExample_ReadParamsFromFile.py @@ -0,0 +1,47 @@ +DataStructure = "LArCaliPulseParamsVsCalib" +DetStoreKey = "LArCaliPulseParams" +ChannelIdType = "OnlineCalibID" + +AsciiFileName = "/afs/cern.ch/user/m/mdelmast/scratch0/Athena/p3c/params/AllBoards.dat" + +PoolFileName = "LArCaliPulseParamsVsCalib_AllBoards.pool.root" +RootFileName = "LArCaliPulseParamsVsCalib_AllBoards.root" + +IOVBegin = 0 + +ParamsFolderName = "/LAR/ElecCalib/CaliPulseParams/Measured" +#ParamsFolderName = "/LAR/ElecCalib/CaliPulseParams/MeasuredCorrected" + +OutputSQLiteFile = "LArCaliPulseParamsVsCalib_AllBoards.db" + +include("LArCalibTools/LArReadParamsFromFile_jobOptions.py") + +LArReadFile.OutputLevel = VERBOSE + +#------------ +# Message +#------------ +#svcMgr.MessageSvc.defaultLimit = 9999999 # all messages +#svcMgr.MessageSvc.OutputLevel = VERBOSE + +#from StoreGate.StoreGateConf import StoreGateSvc +#---------------- +# Dump StoreGate +#---------------- +#sgStore = StoreGateSvc("StoreGateSvc") +#sgStore.Dump = True +#sgStore.OutputLevel = DEBUG + +#-------------------- +# Dump DetectorStore +#-------------------- +#dtStore = StoreGateSvc("DetectorStore") +#dtStore.Dump = True +#dtStore.OutputLevel = DEBUG + +#---------------------- +# Dump ConditionsStore +#---------------------- +#cdStore = StoreGateSvc("ConditionsStore") +#cdStore.Dump = True +#cdStore.OutputLevel = DEBUG diff --git a/LArCalorimeter/LArCalibTools/share/TopOptsExample_Shape2Ntuple_POOL.py b/LArCalorimeter/LArCalibTools/share/TopOptsExample_Shape2Ntuple_POOL.py new file mode 100644 index 000000000000..2a38b9411458 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/TopOptsExample_Shape2Ntuple_POOL.py @@ -0,0 +1,26 @@ +##################################################################### +# +# Dont' forget to insert your POOL file in the local XML catalog! +# +##################################################################### + +PoolFileDir = "/tmp" +PoolFileName = PoolFileDir+"/"+"LArShapePhys_29142_EB-EMBA_5samples.pool.root" + +# Output file location and name + +RootFileName = "/tmp/LArShape2Ntuple_POOL.root" + +##################################################################### + +include("LArCalibTools/LArShape2Ntuple_POOL_jobOptions.py") + +##################################################################### + +from AthenaCommon.AppMgr import theAuditorSvc +from AthenaCommon.ConfigurableDb import getConfigurable +theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = WARNING) +theAuditorSvc += getConfigurable("ChronoAuditor")() +theAuditorSvc += getConfigurable("NameAuditor")() + +##################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/TopOptsExample_Waves2Ntuple_POOL.py b/LArCalorimeter/LArCalibTools/share/TopOptsExample_Waves2Ntuple_POOL.py new file mode 100644 index 000000000000..fe255d244b6b --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/TopOptsExample_Waves2Ntuple_POOL.py @@ -0,0 +1,31 @@ +##################################################################### +# +# Dont' forget to insert your POOL file in the local XML catalog! +# +##################################################################### + +PoolFileDir = "/afs/cern.ch/user/l/larcalib/w0/data/WorkingDirectory/0088263_0088265_0088267_Barrel-EMB_HIGH_26_15.0.0_1/poolFiles" +PoolFileName = PoolFileDir+"/"+"LArCaliWave_0088265_EB-EMBA_StripsXtalkCorr.pool.root" +WaveType = "Cali" + +## swicth these to 'True' if you want the Wave derived quantities +## (Baseline, TmaxAmp, MaxAmp, Width, T0, PosLobe) and Jitter info in the TTree +SaveDerivedInfo = True +SaveJitter = True # works only with CaliWave + +## Output file location and name +RootFileName = "/tmp/LArWaves2Ntuple_POOL.root" + +##################################################################### + +include("LArCalibTools/LArWaves2Ntuple_POOL_jobOptions.py") + +##################################################################### + +from AthenaCommon.AppMgr import theAuditorSvc +from AthenaCommon.ConfigurableDb import getConfigurable +theAuditorSvc += getConfigurable("MemStatAuditor")(OutputLevel = WARNING) +theAuditorSvc += getConfigurable("ChronoAuditor")() +theAuditorSvc += getConfigurable("NameAuditor")() + +##################################################################### diff --git a/LArCalorimeter/LArCalibTools/share/rootMacros/LArPhysWaveCheck.C b/LArCalorimeter/LArCalibTools/share/rootMacros/LArPhysWaveCheck.C new file mode 100644 index 000000000000..6ea726456bb6 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/rootMacros/LArPhysWaveCheck.C @@ -0,0 +1,96 @@ +//**************************************************************************** +// +// LArPhysWaveCheck.C - Tool for checking the output of TWave2NTuple.C +// and the LArPhysWaveFromTuple algorithm. +// Author - Alan Robinson (fbfree@interchange.ubc.ca) +// Created - Aug 15, 2007 +// +//**************************************************************************** + +{ +// ASCII file preparations + const int nPoints = 629; + int timeOffset = 27; // Correction for Time offset introduced by LArPhysWaveFromTuple + + ifstream infile("./signalshapes/signalshapes3.dat"); + if (!infile.good()){ + std::cerr << "File not found." << std::endl; + return 2; + } + + // ASCII file columns + Double_t input[nPoints][7]; + Int_t sample; + + // Ignore header + infile.ignore(64, '\n'); + infile.ignore(64, '\n'); + +// Read ASCII File + for (int i=0; i<nPoints; i++){ + infile >> sample >> input[i][0] >> input[i][1] >> input[i][4] >> input[i][2] >> input[i][5] >> input[i][3] >> input[i][6]; + } + infile.close(); + + const int nBins = ceil(input[nPoints-1][0]); + +// Open ROOT File with TTree. + TFile checkfile("FCalWave.root"); + + Int_t side, chan, feb, gain, endTime; + Double_t wave[nBins]; + const Int_t one = 1, six = 6; + + TTree *checktree = (TTree*) checkfile.Get("outfit"); + checktree.SetBranchAddress("Slot", &feb); + if (checktree.FindBranch("tphys")){ + checktree.SetBranchAddress("tphys", wave); // If checking T2Ntuple.C + timeOffset = 0; + } else { + checktree.SetBranchAddress("Amplitude", wave); // If checking LArPhysWaveFromTuple + } + checktree.SetBranchAddress("Gain", &gain); + +// Fill the TTree + // Loop over all applicable channels + Int_t waveType = 1; +// WaveType Table +// Gain \ FEB | 1-9 (FCal1) | 10-13 (FCal2) | 14 & 15 (FCal3) +// 0 or 1 | 1 | 2 | 3 +// 2 | 4 | 5 | 6 + + TCanvas *c1 = new TCanvas("c1","c1"); + TH1D *h1 = new TH1D("h1","h1",nBins, timeOffset, nBins+timeOffset); + TH1D *h2 = new TH1D("h2","h2",nPoints, 0., (nPoints)*0.3/25*24); + h2->SetLineColor(kRed); + Int_t event = 0; + + //while(event >= 0){ + cout << "Event (-1 to quit):" << endl; + cin >> event; + + checktree->GetEvent(event); + waveType = 1; + if (gain == 2) + waveType+=3; + if (feb >= 10){ + waveType++; + if (feb >= 14) + waveType ++; + } + cout << waveType << " " << feb << " " << gain << " " << event << endl; + + for (int i=0; i<nBins; i++) + h1->SetBinContent(i+1, wave[i]); + for (int i=timeOffset; i < nPoints; i++) + h2->SetBinContent(i+1, input[i][waveType]); + + h1->Draw(); + h2->Draw("SAME"); + + c1->Modified(); + c1->Update(); + + //} + //checkfile.Close(); +} diff --git a/LArCalorimeter/LArCalibTools/share/rootMacros/TWave2NTuple.C b/LArCalorimeter/LArCalibTools/share/rootMacros/TWave2NTuple.C new file mode 100644 index 000000000000..d74a460446f7 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/share/rootMacros/TWave2NTuple.C @@ -0,0 +1,113 @@ +//**************************************************************************** +// +// TWave2NTuple.C - Convert ASCII file of FCal waves into a ROOT NTuple +// Author - Alan Robinson (fbfree@interchange.ubc.ca) +// Created - Aug 15, 2007 +// +//**************************************************************************** + +{ +// ASCII file preparations + const int nPoints = 629; // number of data points to read from the text file. + // nBins (initialized later) is the number of ns associated with these data points + ifstream infile("./signalshapes.dat"); + if (!infile.good()){ + std::cerr << "File not found." << std::endl; + return 2; + } + + // ASCII file columns + Double_t input[nPoints][7]; + Int_t sample; + + // Ignore header + infile.ignore(64, '\n'); + infile.ignore(64, '\n'); + +// Read ASCII File + for (int i=0; i<nPoints; i++){ + // The 2nd array index is chosen to facilitate later logic. See Int_t waveType. + infile >> sample >> input[i][0] >> input[i][1] >> input[i][4] >> input[i][2] >> input[i][5] >> input[i][3] >> input[i][6]; + } + infile.close(); + + // Automatically find the length of the extracted wave in ns; assuming start at t=0. + const int nBins = ceil(input[nPoints-1][0]); + +// Create ROOT File with TTree. + TFile outfile("FCalWave.root", "RECREATE"); + + Int_t side, chan, feb, gain, endTime; + Double_t wave[nBins]; + const Int_t one = 1, six = 6; + + TTree outtree("outfit", "LArPhysWave"); + outtree.Branch("BarEC", &one, "Code/I"); + outtree.Branch("Side", &side, "Code/I"); + outtree.Branch("FT", &six, "Code/I"); + outtree.Branch("Channel", &chan, "Code/I"); + outtree.Branch("Slot", &feb, "Code/I"); + char code[16]; + sprintf(code, "Code[%i]/D", nBins); + outtree.Branch("tphys", wave, code); + outtree.Branch("Gain", &gain, "Code/I"); + +// Fill the TTree + // Loop over all applicable channels + Int_t timeBin; + Int_t waveType = 1; + Double_t deltaT = input[1][0] - input[0][0]; // Time correction for + // midpoint approximation. It'd otherwise be a right Riemann approx. +// WaveType Table +// Gain \ FEB | 1-9 (FCal1) | 10-13 (FCal2) | 14 & 15 (FCal3) +// 0 or 1 | 1 | 2 | 3 +// 2 | 4 | 5 | 6 + + for (side=0; side<=1; side++){ // 0-EndCap C, 1-EndCap A + for (gain=0; gain<3; gain++){ // 0-High Gain, 1-Medium Gain, 2-Low Gain + switch (gain){ + case 0: + waveType = 1; // Switched side. Restart + break; + case 1: + waveType -= 2; // Undo feb increments + break; + case 2: + waveType++; // Increment with high gain + break; + } + for (feb=1; feb<=15; feb++){ + if(feb==8) + feb++; + if(feb==10 || feb==14) + waveType++; // Increment with new module + cout << waveType << " " << feb << " " << gain << endl; + for (chan=0; chan<128; chan++){ + + // Rebin data, and write out + timeBin = 0; + for (int i=1; i < nPoints; i++){ + // See note at initialization of deltaT + // If changing bins + if ( (int) floor((input[i][0]+deltaT/2)) != timeBin){ + // Finish filling current bin + wave[timeBin] += input[i][waveType]*(floor(input[i][0]+deltaT/2)-(input[i-1][0]+deltaT/2)); + // Increment timeBin + timeBin = (int) (input[i][0]+deltaT/2); + // Start filling next bin + wave[timeBin] = input[i][waveType]*(input[i][0]+deltaT/2-floor(input[i][0]+deltaT/2)); + } else { + // Just fill the bin + wave[timeBin] += input[i][waveType]*(deltaT); + } + } + // Last bin will not be fully filled. Set to 0. + wave[nBins-1] = 0.0; + outtree.Fill(); + } + } + } + } + outtree.Write(); + outfile.Close(); +} diff --git a/LArCalorimeter/LArCalibTools/src/CaloCellGroup2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/CaloCellGroup2Ntuple.cxx new file mode 100644 index 000000000000..0ff9f9990b61 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/CaloCellGroup2Ntuple.cxx @@ -0,0 +1,85 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/CaloCellGroup2Ntuple.h" +#include "CaloIdentifier/CaloGain.h" +#include "CaloIdentifier/CaloCell_ID.h" +#include "LArIdentifier/LArOnlineID.h" +//#include "LArTools/LArCablingService.h" +#include "StoreGate/StoreGateSvc.h" + +CaloCellGroup2Ntuple::CaloCellGroup2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator) { + declareProperty("group",m_groupInit); + + m_ntTitle="CaloCellGroup"; + m_ntpath="/NTUPLES/FILE1/CaloCellGroup"; + + +} + +CaloCellGroup2Ntuple::~CaloCellGroup2Ntuple() +{} + +StatusCode CaloCellGroup2Ntuple::stop () { + StatusCode sc; + + NTuple::Array<float> values; + NTuple::Item<long> nValues; + + sc=m_nt->addItem("nvalues",nValues,0,1000); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'nvalues' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("values",nValues,values); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'values' failed" << endreq; + return StatusCode::FAILURE; + } + + + + + const CaloCell_ID* caloCellId; + sc = m_detStore->retrieve(caloCellId,"CaloCell_ID"); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Could not get CaloCellID helper !" << endreq; + return StatusCode::FAILURE; + } + + bool stat=m_cellGroupList.setDefinition(caloCellId,m_groupInit,*m_log); + if (!stat) { + (*m_log) << MSG::ERROR << "CaloCellGroupList::setDefinition failed!" << endreq; + return StatusCode::FAILURE; + } + m_cellGroupList.printDef(); + + + + + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + if (m_larCablingSvc->isOnlineConnected(hwid)) { + fillFromIdentifier(hwid); + Identifier id=m_larCablingSvc->cnvToIdentifier(hwid); + const std::vector<float>& v=m_cellGroupList.valuesForCell(id); + nValues=v.size(); + for (size_t i=0;i<v.size();i++) + values[i]=v[i]; + //cellCounter++; + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end if isConnected + }//end loop over online ID + + (*m_log) << MSG::INFO << "CaloCellGroup2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. diff --git a/LArCalorimeter/LArCalibTools/src/CaloCondBlob2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/CaloCondBlob2Ntuple.cxx new file mode 100644 index 000000000000..120db65b08f5 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/CaloCondBlob2Ntuple.cxx @@ -0,0 +1,98 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/CaloCondBlob2Ntuple.h" +#include "CaloIdentifier/CaloGain.h" +#include "CaloIdentifier/CaloCell_ID.h" +#include "LArIdentifier/LArOnlineID.h" +//#include "LArTools/LArCablingService.h" +#include "StoreGate/StoreGateSvc.h" +#include "CaloCondBlobObjs/CaloCondBlobFlt.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" + +CaloCondBlob2Ntuple::CaloCondBlob2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator) { + declareProperty("Folder",m_folder); + + m_ntTitle="CaloCondBlob"; + m_ntpath="/NTUPLES/FILE1/CaloCondBlob"; + + +} + +CaloCondBlob2Ntuple::~CaloCondBlob2Ntuple() +{} + +StatusCode CaloCondBlob2Ntuple::stop () { + StatusCode sc; + +// NTuple::Array<float> values; +// NTuple::Item<long> nValues; + +// sc=m_nt->addItem("nvalues",nValues,0,1000); +// if (sc!=StatusCode::SUCCESS) +// {(*m_log) << MSG::ERROR << "addItem 'nvalues' failed" << endreq; +// return StatusCode::FAILURE; +// } + +// sc=m_nt->addItem("values",nValues,values); +// if (sc!=StatusCode::SUCCESS) +// {(*m_log) << MSG::ERROR << "addItem 'values' failed" << endreq; +// return StatusCode::FAILURE; +// } + + + NTuple::Item<float> value; + sc=m_nt->addItem("value",value,0,100); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'values' failed" << endreq; + return StatusCode::FAILURE; + } + + const AthenaAttributeList* attrList=0; + sc=detStore()->retrieve(attrList,m_folder); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to retrieve AthenaAttributeList with key " << m_folder << endreq; + return sc; + } + + const coral::Blob& blob = (*attrList)["CaloCondBlob16M"].data<coral::Blob>(); + if (blob.size()<3) { + ATH_MSG_INFO("Found empty blob, nothing to do"); + return StatusCode::SUCCESS; + } + + const CaloCondBlobFlt* condBlob=CaloCondBlobFlt::getInstance(blob); + ATH_MSG_INFO("Database folder has values for " << condBlob->getNChans() << " channels and " << condBlob->getNGains() << " gains."); + + + const CaloCell_ID* caloCellId; + sc = m_detStore->retrieve(caloCellId,"CaloCell_ID"); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Could not get CaloCellID helper !" << endreq; + return StatusCode::FAILURE; + } + + + const unsigned nChans=condBlob->getNChans(); + //const usnigend nGains=condBlob->getNGains(); + + + for(unsigned h=0;h<nChans;++h) { + //add here loop over gains + //const Identifier id=caloCellId->cell_id(h); + const HWIdentifier hwid=m_larCablingSvc->createSignalChannelIDFromHash(h); + fillFromIdentifier(hwid); + value= condBlob->getData(h,0,0); + + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end loop over hash ids + + (*m_log) << MSG::INFO << "CaloCondBlob2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. diff --git a/LArCalorimeter/LArCalibTools/src/ForceLoadCondObj.cxx b/LArCalorimeter/LArCalibTools/src/ForceLoadCondObj.cxx new file mode 100644 index 000000000000..d17eea1dfed3 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/ForceLoadCondObj.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ForceLoadCondObj.cxx + +#include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/IClassIDSvc.h" +//#include "GaudiKernel/AlgFactory.h" +#include "GaudiKernel/MsgStream.h" +#include "LArCalibTools/ForceLoadCondObj.h" + + +ForceLoadCondObj::ForceLoadCondObj(const std::string& name, + ISvcLocator* pSvcLocator) : + Algorithm(name, pSvcLocator), + p_detstore( "DetectorStore", name ), + p_clidsvc ( "ClassIDSvc", name ) +{ + declareProperty("ObjectList",m_objectList,"list of 'object#key'"); +} + +ForceLoadCondObj::~ForceLoadCondObj() +{} + +StatusCode ForceLoadCondObj::initialize() { + MsgStream log(msgSvc(), name()); + log <<MSG::DEBUG <<"in initialize()" <<endreq; + + // get pointer to detector store + if (StatusCode::SUCCESS!= p_detstore.retrieve()) { + log << MSG::FATAL << "Detector store not found" << endreq; + return StatusCode::FAILURE; + } + // get pointer to ClassIDSvc + if (StatusCode::SUCCESS!= p_clidsvc.retrieve()) { + log << MSG::FATAL << "ClassIDSvc not found" << endreq; + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode ForceLoadCondObj::finalize() { + + return StatusCode::SUCCESS; +} + +StatusCode ForceLoadCondObj::execute() { + MsgStream log(messageService(), name()); + //Loop through objects + for (unsigned int iobj=0;iobj<m_objectList.size();++iobj) { + // if object name contains a '#', it represents a specific typename#key + std::string::size_type ihash=m_objectList[iobj].find_first_of("#"); + if (ihash==std::string::npos) { + log << MSG::ERROR << "Expected syntax 'object#key' for property ObjectList, got" << m_objectList[iobj] << endreq; + return StatusCode::FAILURE; + } + std::string::size_type ihash2=m_objectList[iobj].find_first_of("#",ihash+1); + if (ihash2 != std::string::npos) ihash2-=(1+ihash); + const std::string objName=m_objectList[iobj].substr(0,ihash); + const std::string objKey=m_objectList[iobj].substr(ihash+1,ihash2); + + log << MSG::INFO << "Retrieving object " << objName << ", key " << objKey << endreq; + + CLID clid; + if (p_clidsvc->getIDOfTypeName(objName,clid).isFailure()) { + log << MSG::ERROR << "Failed to get CLID for type" << objName << endreq; + return StatusCode::FAILURE; + } + + SG::DataProxy* proxy=p_detstore->proxy(clid,objKey); + + if (!proxy) { + log << MSG::ERROR << "Could not find proxy for object of type " << objName << " with key " << objKey << endreq; + return StatusCode::FAILURE; + } + + if (proxy->accessData()!=0) { //This should trigger the conversion + log << MSG::INFO << "Sucessfully retrieved object of type " << objName << " with key " << objKey << endreq; + } + } + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArAccumulatedDigits2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArAccumulatedDigits2Ntuple.cxx new file mode 100644 index 000000000000..e8bcb88d8ad3 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArAccumulatedDigits2Ntuple.cxx @@ -0,0 +1,314 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArAccumulatedDigits2Ntuple.h" + +#include "LArRawEvent/LArAccumulatedDigitContainer.h" + +//#include "GaudiKernel/ToolHandle.h" + +LArAccumulatedDigits2Ntuple::LArAccumulatedDigits2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + Algorithm(name, pSvcLocator), + m_storeGateSvc(0), + m_emId(0), + m_onlineHelper(0), + m_larCablingSvc ("LArCablingService"), + m_ipass(0), + m_event(0) +{ + declareProperty("ContainerKey",m_contKey); + declareProperty("NSamples",m_Nsamples=7); + declareProperty("Normalize",m_normalize=1); +} + +LArAccumulatedDigits2Ntuple::~LArAccumulatedDigits2Ntuple() +{} + + +StatusCode LArAccumulatedDigits2Ntuple::initialize() +{ + + MsgStream log(msgSvc(), name()); + StatusCode sc; + + log << MSG::INFO << "in initialize" << endreq; + + sc= service("StoreGateSvc",m_storeGateSvc); + if(sc.isFailure()) { + log << MSG::ERROR << "StoreGate service not found" << endreq; + return StatusCode::FAILURE; + } + + StoreGateSvc* detStore = 0; + sc=service("DetectorStore",detStore); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + + const CaloIdManager *caloIdMgr=CaloIdManager::instance() ; + m_emId=caloIdMgr->getEM_ID(); + if (!m_emId) { + log << MSG::ERROR << "Could not access lar EM ID helper" << endreq; + return StatusCode::FAILURE; + } + + sc = detStore->retrieve(m_onlineHelper, "LArOnlineID"); + if (sc.isFailure()) { + log << MSG::ERROR << "Could not get LArOnlineID helper !" << endreq; + return sc; + } + + // Retrieve LArCablingService + sc = m_larCablingSvc.retrieve(); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << " Can't get LArCablingSvc " << endreq; + return sc; + } + + NTupleFilePtr file1(ntupleSvc(),"/NTUPLES/FILE1"); + if (!file1) { + log << MSG::ERROR << "Booking of NTuple failed" << endreq; + return StatusCode::FAILURE; + } + + m_ntuplePath="/NTUPLES/FILE1/ACCUMULATEDDIGITS"+m_contKey; + const std::string ntupleTitle="AccumulatedDigits "+m_contKey; + NTuplePtr nt(ntupleSvc(),m_ntuplePath); + if (!nt) { + nt=ntupleSvc()->book(m_ntuplePath,CLID_ColumnWiseTuple,ntupleTitle); + } + + if (!nt) { + log << MSG::ERROR << "Booking of NTuple failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("IEvent",IEvent,0,3000); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'IEvent' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Ntrigger",Ntrigger,0,500); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Ntrigger' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Nsamples",Nsamples,0,32); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Nsamples' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("sum",m_Nsamples,sum); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'sum' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("sumsq",m_Nsamples,sumsq); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'sumsq' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("mean",mean); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'mean' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("rms",rms); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'rms' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("covr",m_Nsamples-1,covr); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'RMS' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Layer",layer,0,4); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Layer' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Region",region,0,1); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Region' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Eta",eta,0,510); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Eta' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Phi",phi,0,1023); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Phi' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Slot",slot,0,127); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Slot' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("barrel_ec",barrel_ec,0,1); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'barrel_ec' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("pos_neg",pos_neg,0,1); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'pos_neg' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("FT",FT,0,31); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'FT' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("calibLine",calibLine,0,127); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'calibLine' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("isConnected",m_isConnected,0,1); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "addItem 'isConnected' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Channel",channel,0,127); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Channel' failed" << endreq; + return StatusCode::FAILURE; + } + + m_ipass = 0; + + m_event=0; + + return StatusCode::SUCCESS; + +} + +StatusCode LArAccumulatedDigits2Ntuple::execute() +{ + + MsgStream log(msgSvc(), name()); + StatusCode sc; + + log << MSG::DEBUG << "in execute" << endreq; + + m_event++; + + const LArAccumulatedDigitContainer* m_accuDigitContainer = NULL; + sc=m_storeGateSvc->retrieve(m_accuDigitContainer,m_contKey); + if (sc!=StatusCode::SUCCESS) + {log << MSG::WARNING << "Unable to retrieve LArAccumulatedDigitContainer with key " << m_contKey << " from DetectorStore. " << endreq; + } + else + log << MSG::DEBUG << "Got LArAccumulatedDigitContainer with key " << m_contKey << endreq; + + + if (m_accuDigitContainer) { + + LArAccumulatedDigitContainer::const_iterator it=m_accuDigitContainer->begin(); + LArAccumulatedDigitContainer::const_iterator it_e=m_accuDigitContainer->end(); + + if(it == it_e) { + log << MSG::DEBUG << "LArAccumulatedDigitContainer with key=" << m_contKey << " is empty " << endreq; + return StatusCode::SUCCESS; + }else{ + log << MSG::DEBUG << "LArAccumulatedDigitContainer with key=" << m_contKey << " has " <<m_accuDigitContainer->size() << " entries" <<endreq; + } + + unsigned cellCounter=0; + for (;it!=it_e;it++) { + + IEvent=m_event; + Ntrigger = (*it)->nTrigger(); + unsigned int trueMaxSample = (*it)->nsample(); + Nsamples = trueMaxSample; + + // std::cout << "trigger = " << Ntrigger << ", samples = "<< Nsamples << std::endl; + + if(trueMaxSample>m_Nsamples){ + if(!m_ipass){ + log << MSG::WARNING << "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " << endreq; + m_ipass=1; + } + trueMaxSample = m_Nsamples; + } + + mean = (*it)->mean(); + rms = (*it)->RMS(); + const std::vector<uint64_t> sampleSquare = (*it)->sampleSquare(); + const std::vector<uint64_t> sampleSum = (*it)->sampleSum(); + for(unsigned i=0;i<trueMaxSample;i++) { + sumsq[i] = sampleSquare[i]; + sum[i] = sampleSum[i]; + } + std::vector<float> cov; + (*it)->getCov(cov,m_normalize); + for(unsigned i=0;i<trueMaxSample-1;i++) { + covr[i] = cov[i]; + } + + // std::cout << "sum = "<< sum << "mean = "<< mean << ", rms = "<< rms << ", sumsq = "<< sumsq[0] << ", cov = "<< covr[0] << std::endl; + HWIdentifier chid=(*it)->channelID(); + channel=m_onlineHelper->channel(chid); + slot=m_onlineHelper->slot(chid); + FT=m_onlineHelper->feedthrough(chid); + barrel_ec = m_onlineHelper->barrel_ec(chid); + pos_neg = m_onlineHelper->pos_neg(chid); + + // std::cout << "channel = "<< channel << ", slot = "<< slot << ", FT = "<< FT << std::endl; + + bool isConnected = m_larCablingSvc->isOnlineConnected(chid); + if(isConnected){ + Identifier id=m_larCablingSvc->cnvToIdentifier(chid); + const std::vector<HWIdentifier>& calibLineV=m_larCablingSvc->calibSlotLine(chid); + std::vector<HWIdentifier>::const_iterator calibLineIt=calibLineV.begin(); + calibLine = m_onlineHelper->channel(*calibLineIt); + eta=m_emId->eta(id); + phi=m_emId->phi(id); + layer=m_emId->sampling(id); + region=m_emId->region(id); + }else{ + calibLine=-999; + eta=-999; + phi=-999; + layer=-999; + region=-999; + } + m_isConnected = (long)isConnected; + + // std::cout << "calibLine = "<< calibLine << ", eta = "<< eta << ", phi = "<< phi << std::endl; + // std::cout << "will write record " << cellCounter << ", sum = "<< sum << ", mean = "<< mean << std::endl; + sc=ntupleSvc()->writeRecord(m_ntuplePath); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + cellCounter++; + } + } + log << MSG::DEBUG << "LArAccumulatedDigits2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. diff --git a/LArCalorimeter/LArCalibTools/src/LArAutoCorr2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArAutoCorr2Ntuple.cxx new file mode 100755 index 000000000000..60d820964060 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArAutoCorr2Ntuple.cxx @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArAutoCorr2Ntuple.h" +#include "LArRawConditions/LArAutoCorrComplete.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArIdentifier/LArOnlineID.h" +#include "StoreGate/StoreGateSvc.h" + +LArAutoCorr2Ntuple::LArAutoCorr2Ntuple(const std::string& name, ISvcLocator* pSvcLocator) + : LArCond2NtupleBase(name, pSvcLocator),m_nsamples(7) +{ + declareProperty("ContainerKey",m_objKey); + declareProperty("Nsamples", m_nsamples); + + m_ntTitle="AutoCorrelation"; + m_ntpath="/NTUPLES/FILE1/AUTOCORR"; + +} + + +LArAutoCorr2Ntuple::~LArAutoCorr2Ntuple() +{} + +StatusCode LArAutoCorr2Ntuple::stop() { + + StatusCode sc; + NTuple::Array<float> cov; + NTuple::Item<long> gain, cellIndex; + sc=m_nt->addItem("gain",gain,0,3); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("cellIndex",cellIndex,0,200000); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'cellIndex' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("covr",m_nsamples-1,cov); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'covr' failed" << endreq; + return StatusCode::FAILURE; + } + + const ILArAutoCorr* larAutoCorr; + sc=m_detStore->retrieve(larAutoCorr,m_objKey); + if (sc!=StatusCode::SUCCESS){ + (*m_log) << MSG::ERROR << "Unable to retrieve ILArAutoCorr with key " + << m_objKey << " from DetectorStore" << endreq; + return StatusCode::FAILURE; + } + + + unsigned cellCounter=0; + for ( unsigned igain=CaloGain::LARHIGHGAIN; + igain<CaloGain::LARNGAIN ; ++igain ) { + std::vector<HWIdentifier>::const_iterator it = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator it_e = m_onlineId->channel_end(); + for (;it!=it_e;it++) { + const HWIdentifier hwid = *it; + ILArAutoCorr::AutoCorrRef_t corr=larAutoCorr->autoCorr(hwid,igain); + if (corr.size()>0) { + fillFromIdentifier(hwid); + gain = igain; + cellIndex = cellCounter; + for(unsigned i=0;i<m_nsamples-1 && i<corr.size();i++) + cov[i] = corr[i]; + + sc = ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end if size>0 + cellCounter++; + }//end if loop over cells + }//end if loop over gains + + (*m_log) << MSG::INFO << "LArAutoCorr2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx new file mode 100755 index 000000000000..ee58f6386d99 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx @@ -0,0 +1,334 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArAverages2Ntuple.h" + +#include "LArRawEvent/LArAccumulatedCalibDigitContainer.h" + +#include "GaudiKernel/ToolHandle.h" + +LArAverages2Ntuple::LArAverages2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + Algorithm(name, pSvcLocator), + m_storeGateSvc(NULL),m_detStore(NULL),m_emId(NULL), m_onlineHelper(NULL), + larCablingSvc ("LArCablingService") + // m_eventCounter(0) +{ + declareProperty("ContainerKey",m_contKey); + declareProperty("NSamples",m_Nsamples=7); + declareProperty("KeepOnlyPulsed",m_keepPulsed=true); + ipass=0; +} + +LArAverages2Ntuple::~LArAverages2Ntuple() +{} + + +StatusCode LArAverages2Ntuple::initialize() +{ + + MsgStream log(msgSvc(), name()); + StatusCode sc; + + log << MSG::INFO << "in initialize" << endreq; + + sc= service("StoreGateSvc",m_storeGateSvc); + if(sc.isFailure()) { + log << MSG::ERROR << "StoreGate service not found" << endreq; + return StatusCode::FAILURE; + } + + sc=service("DetectorStore",m_detStore); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + + const CaloIdManager *caloIdMgr=CaloIdManager::instance() ; + m_emId=caloIdMgr->getEM_ID(); + if (!m_emId) { + log << MSG::ERROR << "Could not access lar EM ID helper" << endreq; + return StatusCode::FAILURE; + } + + sc = m_detStore->retrieve(m_onlineHelper, "LArOnlineID"); + if (sc.isFailure()) { + log << MSG::ERROR << "Could not get LArOnlineID helper !" << endreq; + return sc; + } + + // Retrieve LArCablingService + sc = larCablingSvc.retrieve(); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << " Can't get LArCablingSvc " << endreq; + return sc; + } + + NTupleFilePtr file1(ntupleSvc(),"/NTUPLES/FILE1"); + if (!file1) { + log << MSG::ERROR << "Booking of NTuple failed" << endreq; + return StatusCode::FAILURE; + } + + ntuplePath="/NTUPLES/FILE1/AVERAGES"+m_contKey; + const std::string ntupleTitle="Averages "+m_contKey; + NTuplePtr nt(ntupleSvc(),ntuplePath); + if (!nt) { + nt=ntupleSvc()->book(ntuplePath,CLID_ColumnWiseTuple,ntupleTitle); + } + + if (!nt) { + log << MSG::ERROR << "Booking of NTuple failed" << endreq; + return StatusCode::FAILURE; + } + + + sc=nt->addItem("DAC",DAC,0,65535); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'DAC' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("isPulsed",isPulsed,0,1); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'isPulsed' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("delay",delay,0,240); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'delay' failed" << endreq; + return StatusCode::FAILURE; + } + + + sc=nt->addItem("Ntrigger",Ntrigger,0,500); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Ntrigger' failed" << endreq; + return StatusCode::FAILURE; + } + + + sc=nt->addItem("Nsamples",Nsamples,0,32); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Nsamples' failed" << endreq; + return StatusCode::FAILURE; + } + + + sc=nt->addItem("Nsteps",Nsteps,0,50); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Nsteps' failed" << endreq; + return StatusCode::FAILURE; + } + + + sc=nt->addItem("StepIndex",StepIndex,0,100); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'StepIndex' failed" << endreq; + return StatusCode::FAILURE; + } + + static const int maxSamples = m_Nsamples; + sc=nt->addItem("Sum",maxSamples,Sum); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Sum' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("SumSq",maxSamples,SumSq); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'SumSq' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Mean",maxSamples,Mean); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Mean' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("RMS",maxSamples,RMS); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'RMS' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Layer",layer,0,4); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Layer' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Region",region,0,1); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Region' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Eta",eta,0,510); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Eta' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Phi",phi,0,1023); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Phi' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Slot",slot,0,127); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Slot' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("barrel_ec",barrel_ec,0,1); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'barrel_ec' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("pos_neg",pos_neg,0,1); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'pos_neg' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("FT",FT,0,31); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'FT' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("calibLine",calibLine,0,127); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'calibLine' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("isConnected",m_isConnected,0,1); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "addItem 'isConnected' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("Channel",channel,0,127); + if (sc!=StatusCode::SUCCESS) + {log << MSG::ERROR << "addItem 'Channel' failed" << endreq; + return StatusCode::FAILURE; + } + + //ipass = 0; + + return StatusCode::SUCCESS; + +} + +StatusCode LArAverages2Ntuple::execute() +{ + + MsgStream log(msgSvc(), name()); + StatusCode sc; + + log << MSG::DEBUG << "in execute" << endreq; + + const LArAccumulatedCalibDigitContainer* m_accuDigitContainer = NULL; + sc=m_storeGateSvc->retrieve(m_accuDigitContainer,m_contKey); + if (sc!=StatusCode::SUCCESS) + {log << MSG::WARNING << "Unable to retrieve LArAccumulatedCalibDigitContainer with key " << m_contKey << " from DetectorStore. " << endreq; + } + else + log << MSG::DEBUG << "Got LArAccumulatedCalibDigitContainer with key " << m_contKey << endreq; + + + if (m_accuDigitContainer) { + + LArAccumulatedCalibDigitContainer::const_iterator it=m_accuDigitContainer->begin(); + LArAccumulatedCalibDigitContainer::const_iterator it_e=m_accuDigitContainer->end(); + + if(it == it_e) { + log << MSG::DEBUG << "LArAccumulatedCalibDigitContainer with key=" << m_contKey << " is empty " << endreq; + return StatusCode::SUCCESS; + }else{ + log << MSG::DEBUG << "LArAccumulatedCalibDigitContainer with key=" << m_contKey << " has " <<m_accuDigitContainer->size() << " entries" <<endreq; + } + + unsigned cellCounter=0; + for (;it!=it_e;it++) { + // Add protection - Modif from JF. Marchand + if ( !(*it) ) continue; + + isPulsed = (long)(*it)->isPulsed(); + if(m_keepPulsed && !(*it)->isPulsed()) continue; + DAC = (*it)->DAC(); + Nsteps = (*it)->nSteps(); + Ntrigger = (*it)->nTriggers(); + delay = (*it)->delay(); + StepIndex=(*it)->stepIndex(); + //unsigned int max = (Nsteps == 1) ? 1 : (Nsteps+1); + unsigned int trueMaxSample = (*it)->nsamples(); + Nsamples = trueMaxSample; + + if(trueMaxSample>m_Nsamples){ + if(!ipass){ + log << MSG::WARNING << "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " << endreq; + ipass=1; + } + trueMaxSample = m_Nsamples; + } + + // std::cout << " ==> DAC Nsteps Ntrigger max " << DAC << " " << Nsteps << " " << Ntrigger << " " << max << " Nsamples " << trueMaxSample << "/" << (*it)->nSamples() << std::endl; + + + const std::vector<uint32_t>& sampleSum = (*it)->sampleSum(); + const std::vector<uint32_t>& sampleSum2 = (*it)->sample2Sum(); + const std::vector<float>& mean = (*it)->mean(); + const std::vector<float>& RMSv = (*it)->RMS(); + + for(unsigned int j=0;j<trueMaxSample;j++){ + Sum[j] = sampleSum[j]; + SumSq[j] = sampleSum2[j]; + Mean[j] = mean[j]; + RMS[j] = RMSv[j]; + //std::cout << " i/j=" << i << "/" << j << " " << mean[j] << std::endl; + } + + HWIdentifier chid=(*it)->channelID(); + channel=m_onlineHelper->channel(chid); + slot=m_onlineHelper->slot(chid); + FT=m_onlineHelper->feedthrough(chid); + barrel_ec = m_onlineHelper->barrel_ec(chid); + pos_neg = m_onlineHelper->pos_neg(chid); + + bool isConnected = larCablingSvc->isOnlineConnected(chid); + if(isConnected){ + Identifier id=larCablingSvc->cnvToIdentifier(chid); + const std::vector<HWIdentifier>& calibLineV=larCablingSvc->calibSlotLine(chid); + std::vector<HWIdentifier>::const_iterator calibLineIt=calibLineV.begin(); + calibLine = m_onlineHelper->channel(*calibLineIt); + eta=m_emId->eta(id); + phi=m_emId->phi(id); + layer=m_emId->sampling(id); + region=m_emId->region(id); + } else { + calibLine=-999; + eta=-999; + phi=-999; + layer=-999; + region=-999; + } + m_isConnected = (long)isConnected; + + sc=ntupleSvc()->writeRecord(ntuplePath); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + cellCounter++; + }//end loop over cells + }//end if have accumulatedDigitContainer + log << MSG::DEBUG << "LArAverages2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. diff --git a/LArCalorimeter/LArCalibTools/src/LArBlockCorrections.cxx b/LArCalorimeter/LArCalibTools/src/LArBlockCorrections.cxx new file mode 100644 index 000000000000..6606cd1749ff --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArBlockCorrections.cxx @@ -0,0 +1,20 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArBlockCorrections.h" +#include "LArRawConditions/LArConditionsContainerBase.h" + +LArBlockCorrections::LArBlockCorrections(const std::string& name, ISvcLocator* pSvcLocator) : + Algorithm(name,pSvcLocator) {} + +StatusCode LArBlockCorrections::initialize() { + MsgStream log(msgSvc(),name()); + + bool setFlag = LArConditionsContainerBase::applyCorrectionsAtInit(true, false); + + log << MSG::INFO << "LArConditionsContainerBase::applyCorrectionsAtInit set to " << setFlag << endreq; + + return StatusCode::SUCCESS; +} + diff --git a/LArCalorimeter/LArCalibTools/src/LArCaliWaves2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArCaliWaves2Ntuple.cxx new file mode 100755 index 000000000000..617ea57888dd --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArCaliWaves2Ntuple.cxx @@ -0,0 +1,258 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArCaliWaves2Ntuple.h" +#include "CaloIdentifier/CaloGain.h" +//#include "TGraph.h" +//#include "TF1.h" + +LArCaliWaves2Ntuple::LArCaliWaves2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArWaves2Ntuple(name, pSvcLocator) +{ + m_keylist.clear() ; + declareProperty("KeyList", m_keylist); + declareProperty("DACSaturSkip", m_dacSaturSkip=false); + declareProperty("SaveJitter", m_saveJitter=false); + declareProperty("NtupleName", m_ntName="DELAYS"); + declareProperty("NtupleFile", m_ntFile= "FILE1"); + m_dacSaturLayer0.resize(0); + m_dacSaturLayer1.resize(0); + m_dacSaturLayer2.resize(0); + m_dacSaturLayer3.resize(0); + declareProperty("DACSaturPS", m_dacSaturLayer0); + declareProperty("DACSaturStrips",m_dacSaturLayer1); + declareProperty("DACSaturMiddle",m_dacSaturLayer2); + declareProperty("DACSaturBack", m_dacSaturLayer3); + declareProperty("AddCorrUndo", m_addCorrUndo=true); + declareProperty("ApplyCorrection",m_applyCorr=false); + + +} + +StatusCode LArCaliWaves2Ntuple::initialize() { + m_ntTitle="Calibration Wave"; + m_ntpath=std::string("/NTUPLES/")+m_ntFile+std::string("/")+m_ntName; + return LArWaves2Ntuple::initialize(); +} + +LArCaliWaves2Ntuple::~LArCaliWaves2Ntuple() +{} + +StatusCode LArCaliWaves2Ntuple::stop() +{ + + // Check DACSatur jobOption consistency, in case setup default values + if ( m_dacSaturSkip && m_dacSaturLayer0.size()<3 ) { + (*m_log) << MSG::WARNING << "DACSaturPS jobOption has wrong size. Will use default." << endreq ; + m_dacSaturLayer0.resize(3); + m_dacSaturLayer0[0] = 15000 ; + m_dacSaturLayer0[1] = 50000 ; + m_dacSaturLayer0[2] = 65000 ; + } + if ( m_dacSaturSkip && m_dacSaturLayer1.size()<3 ) { + (*m_log) << MSG::WARNING << "DACSaturStrips jobOption has wrong size. Will use default." << endreq ; + m_dacSaturLayer1.resize(3); + m_dacSaturLayer1[0] = 800 ; + m_dacSaturLayer1[1] = 8000 ; + m_dacSaturLayer1[2] = 65000 ; + } + if ( m_dacSaturSkip && m_dacSaturLayer2.size()<3 ) { + (*m_log) << MSG::WARNING << "DACSaturMiddle jobOption has wrong size. Will use default." << endreq ; + m_dacSaturLayer2.resize(3); + m_dacSaturLayer2[0] = 1000 ; + m_dacSaturLayer2[1] = 10000 ; + m_dacSaturLayer2[2] = 65000 ; + } + if ( m_dacSaturSkip && m_dacSaturLayer3.size()<3 ) { + (*m_log) << MSG::WARNING << "DACSaturBack jobOption has wrong size. Will use default." << endreq ; + m_dacSaturLayer3.resize(3); + m_dacSaturLayer3[0] = 800 ; + m_dacSaturLayer3[1] = 8000 ; + m_dacSaturLayer3[2] = 65000 ; + } + + StatusCode sc; + sc=m_nt->addItem("DAC",m_dac,0,64000); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'DAC' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("gain",m_gain,0,3); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("nPulsedCalibLines",m_nPulsedCalibLines,0,4); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'nPulsedCalibLines' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("pulsedCalibLines",4,m_pulsedCalibLines); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'pulsedCalibLines' failed" << endreq; + return StatusCode::FAILURE; + } + + if (m_saveJitter) { + sc=m_nt->addItem("Jitter",m_jitter,0.,1.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Jitter' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if (m_addCorrUndo) { + sc=m_nt->addItem("corrUndo",m_corrUndo,0,1); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'corrUndo' failed" << endreq; + return StatusCode::FAILURE; + } + } + + for ( unsigned k=0 ; k<m_keylist.size() ; k++ ) { + const std::string& key = m_keylist[k] ; + + + (*m_log) << MSG::INFO << "Processing WaveContainer from StoreGate! key=" << m_keylist[k] << endreq; + const LArCaliWaveContainer* caliWaveContainer; + StatusCode sc = m_detStore->retrieve(caliWaveContainer,key); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Cannot read LArCaliWaveContainer from StoreGate! key=" << key << endreq; + return StatusCode::FAILURE; + } else + (*m_log) << MSG::INFO << "Read LArCaliWaveContainer from StoreGate! key= " << key << endreq; + + if (m_applyCorr) { + if (!caliWaveContainer->correctionsApplied()) { + LArCaliWaveContainer* caliWaveContainer_nc=const_cast<LArCaliWaveContainer*>(caliWaveContainer); + sc=caliWaveContainer_nc->applyCorrections(); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Failed to apply corrections to LArCaliWaveContainer!" << endreq; + } + else + (*m_log) << MSG::INFO << "Applied corrections to LArCaliWaveContainer" << endreq; + } + else { + (*m_log) << MSG::WARNING << "Corrections already applied. Can't apply twice!" << endreq; + } + }// end if applyCorr + + + for (unsigned igain=CaloGain::LARHIGHGAIN;igain<CaloGain::LARNGAIN ;++igain){ + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier chid = *itOnId; + m_gain=(long)igain; + const LArCaliWaveVec& cwv = caliWaveContainer->get(chid,igain); + if (cwv.size()==0) continue; + + LArCaliWaveVec::const_iterator cwv_it=cwv.begin(); + LArCaliWaveVec::const_iterator cwv_it_e=cwv.end(); + for (;cwv_it!=cwv_it_e;++cwv_it) { + const LArCaliWave& wave=*cwv_it; + if (wave.isEmpty()) continue; + if (m_addCorrUndo) m_corrUndo=0; + bool skip=writeEntry(chid,igain,wave); + if (skip) continue; + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return sc; + } + }//End loop over DAC + }//end loop over identifiers + }//end loop over gains + + + if (m_addCorrUndo) { + for (unsigned igain=CaloGain::LARHIGHGAIN;igain<CaloGain::LARNGAIN ;++igain) { + LArCaliWaveContainer::ConstCorrectionIt itUndo=caliWaveContainer->undoCorrBegin(igain); + LArCaliWaveContainer::ConstCorrectionIt itUndo_e=caliWaveContainer->undoCorrEnd(igain); + for(;itUndo!=itUndo_e;itUndo++) { + const HWIdentifier chid(itUndo->first); + const LArCaliWaveVec& cwv = itUndo->second; + m_gain = (long)igain; + m_corrUndo = 1; + LArCaliWaveVec::const_iterator cwv_it=cwv.begin(); + LArCaliWaveVec::const_iterator cwv_it_e=cwv.end(); + for (;cwv_it!=cwv_it_e;++cwv_it) { + const LArCaliWave& wave=*cwv_it; + bool skip=writeEntry(chid,igain,wave); + if (skip) continue; + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return sc; + } + }//end loop over DAC + }//end loop over corrections + }//end loop over gain + }//end if addUndoCorr + }//end loop over container keys + (*m_log) << MSG::INFO << "LArWave2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +} // end finalize-method. + + + +bool LArCaliWaves2Ntuple::writeEntry(const HWIdentifier chid, const unsigned gain, const LArCaliWave& wave) { + //call fill method of base-class + fillWave(chid,wave); + m_dac = wave.getDAC(); + int DACSatur = 100000; + if (m_dacSaturSkip) { + switch (m_layer) { + case 0: + DACSatur = m_dacSaturLayer0[gain]; + break; + case 1: + DACSatur = m_dacSaturLayer1[gain]; + break; + case 2: + DACSatur = m_dacSaturLayer2[gain]; + break; + case 3: + DACSatur = m_dacSaturLayer3[gain]; + break; + } + if (m_dac > DACSatur ) return true; + } + + + /// HEC calibration lines + if ( !m_isSC ) { + const std::vector<HWIdentifier>& calibLineV = ((LArCablingService*)m_larCablingSvc)->calibSlotLine(chid); + if ( calibLineV.size()>0 ) { + for(int i=0;i<4;i++) + m_pulsedCalibLines[i] = NOT_VALID; + std::vector<HWIdentifier>::const_iterator calibLineIt = calibLineV.begin(); + unsigned iCalibLine=0; + m_nPulsedCalibLines=0; + for(calibLineIt = calibLineV.begin(); calibLineIt != calibLineV.end();++calibLineIt) { + if ( (wave.getIsPulsedInt()>>iCalibLine) & 1 ){ + m_pulsedCalibLines[iCalibLine] = m_onlineId->channel(*calibLineIt); + if (m_pulsedCalibLines[iCalibLine]>=0) m_calibLine = m_onlineId->channel(*calibLineIt); + m_nPulsedCalibLines++; + } + iCalibLine++; + } + }else { + m_nPulsedCalibLines = 0 ; + m_pulsedCalibLines[0] = NOT_VALID; + } + }else { + m_nPulsedCalibLines = 0 ; + m_pulsedCalibLines[0] = NOT_VALID; + } + + // Jitter + if ( m_saveJitter ) { + m_jitter = m_waveHelper.getJitter(wave); + } + + return false; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArCompleteToFlat.cxx b/LArCalorimeter/LArCalibTools/src/LArCompleteToFlat.cxx new file mode 100644 index 000000000000..21587bd0b6a4 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArCompleteToFlat.cxx @@ -0,0 +1,664 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArCompleteToFlat.h" + +#include "LArRawConditions/LArPedestalComplete.h" +#include "LArCOOLConditions/LArPedestalFlat.h" + +#include "LArRawConditions/LArOFCComplete.h" +#include "LArCOOLConditions/LArOFCFlat.h" + +#include "LArRawConditions/LArDAC2uAMC.h" +#include "LArRawConditions/LAruA2MeVMC.h" +#include "LArRawConditions/LArHVScaleCorrComplete.h" +#include "LArRawConditions/LArMphysOverMcalComplete.h" + +#include "LArRawConditions/LArShapeComplete.h" +#include "LArCOOLConditions/LArShapeFlat.h" + +#include "LArRawConditions/LArRampComplete.h" + +#include "LArRawConditions/LArDSPThresholdsComplete.h" +#include "LArCOOLConditions/LArDSPThresholdsFlat.h" + +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" +#include "CoralBase/Blob.h" + + +#include "LArElecCalib/LArCalibErrorCode.h" + +/////////////////////////////////////////////////////////////////// +// Public methods: +/////////////////////////////////////////////////////////////////// + +// Constructors +//////////////// +LArCompleteToFlat::LArCompleteToFlat( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::AthAlgorithm( name, pSvcLocator ), + m_hashMax(0), + m_onlineID(0), + m_cablingSvc("LArCablingService") +{ + + declareProperty("uA2MeVInput",m_uA2MeVInput);//="LAruA2MeV"); + declareProperty("DAC2uAVInput",m_DAC2uAInput);//="LArDAC2uA"); + declareProperty("HVScaleCorrInput",m_HVScaleCorrInput);//="LArHVScaleCorr"); + declareProperty("PedestalInput",m_PedestalInput);//="Pedestal"); + declareProperty("RampInput",m_RampInput);//="LArRamp"); + declareProperty("MphysOverMcalInput",m_MphysOverMcalInput);//="LArMphysOverMcal"); + declareProperty("OFCInput",m_OFCInput);//="LArOFC"); + declareProperty("ShapeInput",m_ShapeInput);//="LArShape"); + declareProperty("DSPThresholdsInput",m_DSPThresholdsInput);//="LArDSPThresholds"); + + declareProperty("ForceStop",m_forceStop=true); +} + +// Destructor +/////////////// +LArCompleteToFlat::~LArCompleteToFlat() +{} + +// Athena Algorithm's Hooks +//////////////////////////// +StatusCode LArCompleteToFlat::initialize() +{ + + CHECK(m_cablingSvc.retrieve()); + return StatusCode::SUCCESS; +} + + + +CondAttrListCollection* LArCompleteToFlat::singleFloatFlat(const char* blobName, const LArConditionsContainer<LArSingleFloatP>* input, + const std::string& outputName, const unsigned nGain,const bool withFCAL) { + + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend(blobName, "blob"); + spec->extend<unsigned>("version"); + CondAttrListCollection* coll=new CondAttrListCollection(true); + for (unsigned gain=0;gain<nGain;++gain) { + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& blob=(*attrList)[blobName].data<coral::Blob>(); + blob.resize(m_hashMax*sizeof(float)); + float* pblob=static_cast<float*>(blob.startingAddress()); + for (unsigned hs=0;hs<m_hashMax;++hs) { + const HWIdentifier chid=m_onlineID->channel_Id(hs); + if (!withFCAL && m_onlineID->isFCALchannel(chid)) { + pblob[hs]=1.0; //Fill fcal channels with 1.0. for MPhysOverMcal + } + else { + pblob[hs]=input->get(chid,gain).m_data; + } + + if (pblob[hs] < 0) { + errIfConnected(chid,gain,blobName); + } + } + unsigned coolChan=gain; + //Special case: Store single-gain constant in channel 1 + //To avoid AttrList vs AttrListCollection confusion in Athena DB infrastructure + if (nGain==1) coolChan=1; + + coll->add(coolChan,*attrList); + //delete attrList;//??? + } + + StatusCode sc=detStore()->record(coll,outputName); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record CondAttrListCollection with key" << outputName << endreq; + return NULL; + } + return coll; +} + + + +CondAttrListCollection* LArCompleteToFlat::pedestalFlat(const ILArPedestal* input, const std::string& outputName) { + msg(MSG::INFO)<<"LArCompleteToFlat::pedestalFlat, starting"<<endreq; + + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("Pedestal", "blob"); + spec->extend("PedestalRMS", "blob"); + spec->extend<unsigned>("version"); + + CondAttrListCollection* collPed=new CondAttrListCollection(true); + + for (unsigned gain=0;gain<3;++gain) { + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& blobPed=(*attrList)["Pedestal"].data<coral::Blob>(); + coral::Blob& blobRMS=(*attrList)["PedestalRMS"].data<coral::Blob>(); + blobPed.resize(m_hashMax*sizeof(float)); + blobRMS.resize(m_hashMax*sizeof(float)); + float* pblobPed=static_cast<float*>(blobPed.startingAddress()); + float* pblobRMS=static_cast<float*>(blobRMS.startingAddress()); + + for (unsigned hs=0;hs<m_hashMax;++hs) { + const HWIdentifier chid=m_onlineID->channel_Id(hs); + pblobPed[hs]=input->pedestal(chid,gain); + pblobRMS[hs]=input->pedestalRMS(chid,gain); + }//end loop over hash ids + collPed->add(gain,*attrList); + }//end loop over gains + + StatusCode sc=detStore()->record(collPed,outputName);//"/LAR/ElecCalibFlat/Pedestal"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record CondAttrListCollection for pedestal with key " << outputName << endreq; + return NULL; + } + msg(MSG::INFO)<<"LArCompleteToFlat::pedestalFlat, returning "<<collPed<<endreq; + return collPed; +} + + +CondAttrListCollection* LArCompleteToFlat::ofcFlat(const ILArOFC* input, const std::string& outputName) { + const unsigned nSamples=5; + + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("OFCa", "blob"); + spec->extend("OFCb", "blob"); + spec->extend("TimeOffset","blob"); + spec->extend<unsigned>("nSamples"); + spec->extend<unsigned>("version"); + CondAttrListCollection* collOFC=new CondAttrListCollection(true); + + for (unsigned gain=0;gain<3;++gain) { + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& ofcaBlob=(*attrList)["OFCa"].data<coral::Blob>(); + coral::Blob& ofcbBlob=(*attrList)["OFCb"].data<coral::Blob>(); + coral::Blob& toBlob=(*attrList)["TimeOffset"].data<coral::Blob>(); + + (*attrList)["nSamples"].setValue(nSamples); + + ofcaBlob.resize(m_hashMax*sizeof(float)*nSamples); + ofcbBlob.resize(m_hashMax*sizeof(float)*nSamples); + toBlob.resize(m_hashMax*sizeof(float)); + float* pOfca=static_cast<float*>(ofcaBlob.startingAddress()); + float* pOfcb=static_cast<float*>(ofcbBlob.startingAddress()); + float* pTimeOffset=static_cast<float*>(toBlob.startingAddress()); + for (unsigned hs=0;hs<m_hashMax;++hs) { + const HWIdentifier chid=m_onlineID->channel_Id(hs); + + LArOFCFlat::OFCRef_t ofca= input->OFC_a(chid,gain); + if (ofca.size()==nSamples) { + for (unsigned i=0;i<nSamples;++i) { + pOfca[hs*nSamples+i]=ofca[i]; + } + } + else { + for (unsigned i=0;i<nSamples;++i) { + pOfca[hs*nSamples+i]=LArOFCFlat::ERRORCODE; + } + } + + LArOFCFlat::OFCRef_t ofcb= input->OFC_b(chid,gain); + if (ofcb.size()==nSamples) { + for (unsigned i=0;i<nSamples;++i) { + pOfcb[hs*nSamples+i]=ofcb[i]; + } + } + else { + for (unsigned i=0;i<nSamples;++i) { + pOfcb[hs*nSamples+i]=LArOFCFlat::ERRORCODE; + } + } + pTimeOffset[hs]=input->timeOffset(chid,gain); + + }//end loop over hash ids + collOFC->add(gain,*attrList); + }//end loop over gains + + StatusCode sc=detStore()->record(collOFC,outputName);//"/LAR/ElecCalibFlat/OFC"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record CondAttrListCollection OFC with key " << outputName << endreq; + return NULL; + } + return collOFC; +} + + +CondAttrListCollection* LArCompleteToFlat::shapeFlat(const LArShapeComplete* input, const std::string& outputName) { + const unsigned nSamples=5; + + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("Shape", "blob"); + spec->extend("ShapeDer", "blob"); + spec->extend("TimeOffset","blob"); + spec->extend<unsigned>("nSamples"); + spec->extend<unsigned>("version"); + CondAttrListCollection* coll=new CondAttrListCollection(true); + + for (unsigned gain=0;gain<3;++gain) { + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& shapeBlob=(*attrList)["Shape"].data<coral::Blob>(); + coral::Blob& shapeDerBlob=(*attrList)["ShapeDer"].data<coral::Blob>(); + coral::Blob& toBlob=(*attrList)["TimeOffset"].data<coral::Blob>(); + + (*attrList)["nSamples"].setValue(nSamples); + + shapeBlob.resize(m_hashMax*sizeof(float)*nSamples); + shapeDerBlob.resize(m_hashMax*sizeof(float)*nSamples); + toBlob.resize(m_hashMax*sizeof(float)); + float* pShape=static_cast<float*>(shapeBlob.startingAddress()); + float* pShapeDer=static_cast<float*>(shapeDerBlob.startingAddress()); + float* pTimeOffset=static_cast<float*>(toBlob.startingAddress()); + for (unsigned hs=0;hs<m_hashMax;++hs) { + const HWIdentifier chid=m_onlineID->channel_Id(hs); + + ILArShape::ShapeRef_t shape= input->Shape(chid,gain); + if (shape.size()==nSamples) { + for (unsigned i=0;i<nSamples;++i) { + pShape[hs*nSamples+i]=shape[i]; + } + } + else { + for (unsigned i=0;i<nSamples;++i) { + pShape[hs*nSamples+i]=LArShapeFlat::ERRORCODE; + } + } + + ILArShape::ShapeRef_t shapeDer= input->ShapeDer(chid,gain); + if (shapeDer.size()==nSamples) { + for (unsigned i=0;i<nSamples;++i) { + pShapeDer[hs*nSamples+i]=shapeDer[i]; + } + } + else { + for (unsigned i=0;i<nSamples;++i) { + pShapeDer[hs*nSamples+i]=LArShapeFlat::ERRORCODE; + } + } + pTimeOffset[hs]=input->timeOffset(chid,gain); + + }//end loop over hash ids + coll->add(gain,*attrList); + }//end loop over gains + + StatusCode sc=detStore()->record(coll,outputName);//"/LAR/ElecCalibFlat/SHAPE"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record CondAttrListCollection Shape with key " << outputName << endreq; + return NULL; + } + return coll; +} + + + +CondAttrListCollection* LArCompleteToFlat::rampFlat(const ILArRamp* input, const std::string& outputName) { + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("RampVec", "blob"); + spec->extend<unsigned>("nPoints"); + spec->extend<unsigned>("version"); + CondAttrListCollection* coll=new CondAttrListCollection(true); + const unsigned nPoints=2; + + for (unsigned gain=0;gain<3;++gain) { + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& blobRamp=(*attrList)["RampVec"].data<coral::Blob>(); + (*attrList)["nPoints"].setValue(nPoints); + blobRamp.resize(m_hashMax*sizeof(float)*nPoints); + float* pblobRamp=static_cast<float*>(blobRamp.startingAddress()); + + for (unsigned hs=0;hs<m_hashMax;++hs) { + const HWIdentifier chid=m_onlineID->channel_Id(hs); + const ILArRamp::RampRef_t ramp=input->ADC2DAC(chid,gain); + if (ramp.size()>=nPoints) { + for (size_t i=0;i<nPoints;++i) { + pblobRamp[nPoints*hs+i]=ramp[i]; + } + } + else { + errIfConnected(chid,gain,"Ramp"); + //msg(MSG::ERROR) << "Found ramp polynom with degree " << ramp.size() << ". Need at least " + // << nPoints << ". Filling with with ERRORCODE" << endreq; + for (size_t i=0;i<nPoints;++i) { + pblobRamp[nPoints*hs+i]=LArElecCalib::ERRORCODE; + } + } + }//end loop over hash ids + coll->add(gain,*attrList); + }//end loop over gains + + StatusCode sc=detStore()->record(coll,outputName);//"/LAR/ElecCalibFlat/Ramp"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record CondAttrListCollection for ramp with key " << outputName << endreq; + return NULL; + } + return coll; +} + + +CondAttrListCollection* LArCompleteToFlat::DAC2uAFlat(const ILArDAC2uA* input, const std::string& outputName) { + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("DAC2uA", "blob"); + spec->extend<unsigned>("version"); + CondAttrListCollection* coll=new CondAttrListCollection(true); + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& blob=(*attrList)["DAC2uA"].data<coral::Blob>(); + blob.resize(m_hashMax*sizeof(float)); + float* pblob=static_cast<float*>(blob.startingAddress()); + for (unsigned hs=0;hs<m_hashMax;++hs) { + const HWIdentifier chid=m_onlineID->channel_Id(hs); + pblob[hs]=input->DAC2UA(chid); + } + coll->add(1,*attrList); + //delete attrList;//??? + StatusCode sc=detStore()->record(coll,outputName); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record CondAttrListCollection with key" << outputName << endreq; + return NULL; + } + return coll; +} + + +CondAttrListCollection* LArCompleteToFlat::uA2MeVFlat(const ILAruA2MeV* input, const std::string& outputName) { + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("uA2MeV", "blob"); + spec->extend<unsigned>("version"); + CondAttrListCollection* coll=new CondAttrListCollection(true); + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& blob=(*attrList)["uA2MeV"].data<coral::Blob>(); + blob.resize(m_hashMax*sizeof(float)); + float* pblob=static_cast<float*>(blob.startingAddress()); + for (unsigned hs=0;hs<m_hashMax;++hs) { + const HWIdentifier chid=m_onlineID->channel_Id(hs); + pblob[hs]=input->UA2MEV(chid); + } + coll->add(1,*attrList); + //delete attrList;//??? + StatusCode sc=detStore()->record(coll,outputName); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record CondAttrListCollection with key" << outputName << endreq; + return NULL; + } + return coll; +} + +AthenaAttributeList* LArCompleteToFlat::DSPThresholdsFlat(const LArDSPThresholdsComplete* input, const std::string& outputName) { + + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("tQThr", "blob"); + spec->extend("samplesThr", "blob"); + spec->extend("trigSumThr","blob"); + spec->extend<unsigned>("version"); + + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& QBlob=(*attrList)["tQThr"].data<coral::Blob>(); + coral::Blob& SamplesBlob=(*attrList)["samplesThr"].data<coral::Blob>(); + coral::Blob& TrigBlob=(*attrList)["trigSumThr"].data<coral::Blob>(); + + QBlob.resize(m_hashMax*sizeof(float)); + SamplesBlob.resize(m_hashMax*sizeof(float)); + TrigBlob.resize(m_hashMax*sizeof(float)); + float* ptQThr=static_cast<float*>(QBlob.startingAddress()); + float* pSamplesThr=static_cast<float*>(SamplesBlob.startingAddress()); + float* pTrigThr=static_cast<float*>(TrigBlob.startingAddress()); + + for (unsigned hs=0;hs<m_hashMax;++hs) { + const HWIdentifier chid=m_onlineID->channel_Id(hs); + + ptQThr[hs] = input->tQThr(chid); + pSamplesThr[hs] = input->samplesThr(chid); + pTrigThr[hs] = input->trigSumThr(chid); + + msg(MSG::INFO) << "hwid: "<<chid.getString()<<" "<<hs<<" | "<<ptQThr[hs]<<" : "<<pSamplesThr[hs]<<" | "<<pTrigThr[hs] << endreq; + }//end loop over hash ids + + AthenaAttributeList* coll=new AthenaAttributeList(*attrList); + + StatusCode sc=detStore()->record(coll,outputName); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record AthenaAttributeList DSPThresholds with key " << outputName << endreq; + return NULL; + } + + return coll; +} + + + +StatusCode LArCompleteToFlat::stop() { + + + StatusCode sc=detStore()->retrieve(m_onlineID); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to get LArOnlineID" << endreq; + return sc; + } + + m_hashMax=m_onlineID->channelHashMax(); + + + //CondAttrListCollection* coll; + + if (m_uA2MeVInput.size()) { + const ILAruA2MeV* uA2MeVComplete; + sc=detStore()->retrieve(uA2MeVComplete,m_uA2MeVInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LAruA2MeV with key " << m_uA2MeVInput << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LAruA2MeV" << endreq; + } + } else { + uA2MeVFlat(uA2MeVComplete, "/LAR/ElecCalibFlat/uA2MeV"); + } + }//end if have m_uA2MeV + + + if (m_DAC2uAInput.size()) { + const ILArDAC2uA* DAC2uAComplete; + sc=detStore()->retrieve(DAC2uAComplete,m_DAC2uAInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LArDAC2uA with key " << m_DAC2uAInput << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LArDAC2uA" << endreq; + } + } else { + DAC2uAFlat(DAC2uAComplete, "/LAR/ElecCalibFlat/DAC2uA"); + //singleFloatFlat("DAC2uA", DAC2uAComplete, "/LAR/ElecCalibFlat/DAC2uA",1); + } + }//end if have m_DAC2uAInput + + if (m_MphysOverMcalInput.size()) { + const LArMphysOverMcalComplete* MphysOverMcalComplete; + sc=detStore()->retrieve(MphysOverMcalComplete,m_MphysOverMcalInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LArMphysOverMcal with key " << m_MphysOverMcalInput << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LArMphysOverMcal" << endreq; + } + } else { + singleFloatFlat("MphysOverMcal", MphysOverMcalComplete, "/LAR/ElecCalibFlat/MphysOverMcal",3,false); //No MphysOverMCal for FCAL + } + }//end if have m_MphysOverMcalInput + + + if (m_HVScaleCorrInput.size()) { + const LArHVScaleCorrComplete* HVScaleCorrComplete; + sc=detStore()->retrieve(HVScaleCorrComplete,m_HVScaleCorrInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LArHVScaleCorr with key " << m_HVScaleCorrInput << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LArHVScaleCorr" << endreq; + } + } else { + singleFloatFlat("HVScaleCorr", HVScaleCorrComplete, "/LAR/ElecCalibFlat/HVScaleCorr",1); + } + }//end if have m_HVScaleCorrInput + + if (m_PedestalInput.size()) { + const LArPedestalComplete* pedComplete; + sc=detStore()->retrieve(pedComplete,m_PedestalInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LArPedestal" << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LArPedestal" << endreq; + } + } else { + pedestalFlat(pedComplete,"/LAR/ElecCalibFlat/Pedestal"); + + /* + CondAttrListCollection* coll=pedestalFlat(pedComplete,"/LAR/ElecCalibFlat/Pedestal"); + LArPedestalFlat* pf=new LArPedestalFlat(coll); + + sc=detStore()->record(pf,"PedestalFlat"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record LArPedestalFlat" << endreq; + } + + ILArPedestal* iped=pf; + sc=detStore()->symLink(pf,iped); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to symlink LArPedestalFlat" << endreq; + } + } + */ + } + }//end if have m_pedestalInput + + //OFC: + if (m_OFCInput.size()) { + const LArOFCComplete* ofcComplete; + sc=detStore()->retrieve(ofcComplete,m_OFCInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LArOFCComplete object" << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LArOFCComplete" << endreq; + } + } else { + ofcFlat(ofcComplete,"/LAR/ElecCalibFlat/OFC"); + /* + CondAttrListCollection* coll=ofcFlat(ofcComplete,"/LAR/ElecCalibFlat/OFC"); + + LArOFCFlat* of=new LArOFCFlat(coll); + + sc=detStore()->record(of,"OFCFlat"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record LArOFCFlat" << endreq; + } + + ILArOFC* iofc=of; + sc=detStore()->symLink(of,iofc); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to symlink LArOFCFlat" << endreq; + } + */ + } + }//end have m_OFCInput + + //Shape: + if (m_ShapeInput.size()) { + const LArShapeComplete* shapeComplete; + sc=detStore()->retrieve(shapeComplete,m_ShapeInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LArShapeComplete object" << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LArShapeComplete" << endreq; + } + } else { + shapeFlat(shapeComplete,"/LAR/ElecCalibFlat/Shape"); + /* + CondAttrListCollection* coll=shapeFlat(shapeComplete,"/LAR/ElecCalibFlat/Shape"); + + LArShapeFlat* sf=new LArShapeFlat(coll); + + sc=detStore()->record(sf,"ShapeFlat"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record LArShapeFlat" << endreq; + } + + ILArShape* ishape=sf; + sc=detStore()->symLink(sf,ishape); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to symlink LArShapeFlat" << endreq; + } + */ + } + }//end if have m_shapeInput + + //Ramp + if (m_RampInput.size()) { + const LArRampComplete* rampComplete; + sc=detStore()->retrieve(rampComplete,m_RampInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LArRampComplete object" << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LArRampComplete" << endreq; + } + } else { + rampFlat(rampComplete,"/LAR/ElecCalibFlat/Ramp"); + } + } + + if(m_DSPThresholdsInput.size()) { + //DSPThresh: + const LArDSPThresholdsComplete* DSPTComplete; + sc=detStore()->retrieve(DSPTComplete,m_DSPThresholdsInput); + if (sc.isFailure()) { + if(m_forceStop) { + msg(MSG::ERROR) << "Failed to get LArDSPThresholdsComplete object" << endreq; + return sc; + } else { + msg(MSG::WARNING) << "Will not process LArDSPThresholdsComplete" << endreq; + } + } + DSPThresholdsFlat(DSPTComplete,"/LAR/Configuration/DSPThresholdFlat/Templates"); + /* + AthenaAttributeList *cl=DSPThresholdsFlat(DSPTComplete,"/LAR/Configuration/DSPThresholdFlat/Templates"); + + LArDSPThresholdsFlat* df; + if(cl) { + df=new LArDSPThresholdsFlat(cl); + + sc=detStore()->record(df,"DSPThresholdsFlat"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to record LArDSPThresholdsFlat" << endreq; + } + } + */ + } //end if have m__DSPThresholdsInput + + + return StatusCode::SUCCESS; +} + + + + + +void LArCompleteToFlat::errIfConnected(const HWIdentifier chid, const int gain, const char* objName) const{ + + if (m_cablingSvc->isOnlineConnected(chid)) { + msg(MSG::ERROR) << "No valid " << objName << " found for channel " << m_onlineID->channel_name(chid) + << ", gain " << gain << ". Filling with ERRORCODE." << endreq; + } + return; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx new file mode 100644 index 000000000000..2412dea1d2af --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx @@ -0,0 +1,337 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArCond2NtupleBase.h" + +#include "LArIdentifier/LArOnlineID.h" +#include "LArIdentifier/LArOnline_SuperCellID.h" +#include "CaloIdentifier/CaloIdManager.h" +#include "LArCondUtils/LArFEBTempTool.h" + + +LArCond2NtupleBase::LArCond2NtupleBase(const std::string& name, ISvcLocator* pSvcLocator): + AthAlgorithm(name, pSvcLocator), m_initialized(false), m_nt(NULL), m_log(NULL), + m_detStore(NULL), m_emId(NULL), m_hecId(NULL), m_fcalId(NULL),m_onlineId(NULL), + m_badChanTool("LArBadChanTool"),m_FEBTempTool("LArFEBTempTool"), m_isSC(false) +{ + declareProperty("BadChannelTool",m_badChanTool); + declareProperty("AddBadChannelInfo",m_addBC=true); + declareProperty("AddFEBTempInfo",m_addFEBTemp=true); + declareProperty("isSC",m_isSC); + declareProperty("isFlat", m_isFlat=false); + declareProperty("OffId", m_OffId=false); +} + +LArCond2NtupleBase::~LArCond2NtupleBase() { + delete m_log; +} + +StatusCode LArCond2NtupleBase::initialize() { + m_log=new MsgStream(msgSvc(), name()); + + *m_log << MSG::DEBUG << "Initializing LArCond2Ntuple base class" << endreq; + + if (m_ntpath.size()==0 || m_ntTitle.size()==0) { + *m_log << MSG::ERROR << "Need to set variable 'm_ntpath' and 'm_ntTitle' in constructor of deriving class!" << endreq; + return StatusCode::FAILURE; + } + + size_t i=m_ntpath.rfind('/'); + if (i==std::string::npos) { + *m_log << MSG::ERROR << "Expected at least on '/' in path " << m_ntpath << endreq; + return StatusCode::FAILURE; + } + std::string basepath(m_ntpath.begin(),m_ntpath.begin()+i); + //std::cout << "Basepath" << basepath << std::endl; + + + NTupleFilePtr file1(ntupleSvc(),basepath); + if (!file1){ + (*m_log) << MSG::ERROR << "Could not get NTupleFilePtr with path " << basepath << " failed" << endreq; + return StatusCode::FAILURE; + } + NTuplePtr nt(ntupleSvc(),m_ntpath); + if (!nt) { + nt=ntupleSvc()->book(m_ntpath,CLID_ColumnWiseTuple,m_ntTitle); + } + if (!nt){ + (*m_log) << MSG::ERROR << "Booking of NTuple at "<< m_ntpath << " and name " << m_ntTitle << " failed" << endreq; + return StatusCode::FAILURE; + } + + m_nt=nt; + //std::cout << "Ntuple ptr:" << m_nt << std::endl; + + StatusCode sc=service("DetectorStore",m_detStore); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + + const CaloIdManager *caloIdMgr=CaloIdManager::instance() ; + if ( m_isSC ){ + m_emId=caloIdMgr->getEM_SuperCell_ID(); + m_fcalId=caloIdMgr->getFCAL_SuperCell_ID(); + m_hecId=caloIdMgr->getHEC_SuperCell_ID(); + } + else{ + m_emId=caloIdMgr->getEM_ID(); + m_fcalId=caloIdMgr->getFCAL_ID(); + m_hecId=caloIdMgr->getHEC_ID(); + } + + if (!m_emId) { + (*m_log) << MSG::ERROR << "Could not access lar EM ID helper" << endreq; + return StatusCode::FAILURE; + } + if (!m_fcalId) { + (*m_log) << MSG::ERROR << "Could not access lar FCAL ID helper" << endreq; + return StatusCode::FAILURE; + } + if (!m_hecId) { + (*m_log) << MSG::ERROR << "Could not access lar HEC ID helper" << endreq; + return StatusCode::FAILURE; + } + + if ( m_isSC ){ + const LArOnline_SuperCellID* ll; + sc = m_detStore->retrieve(ll, "LArOnline_SuperCellID"); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Could not get LArOnlineID helper !" << endreq; + return StatusCode::FAILURE; + } + else { + m_onlineId = (const LArOnlineID_Base*)ll; + (*m_log) << MSG::DEBUG << " Found the LArOnlineID helper. " << endreq; + } + + ToolHandle<LArSuperCellCablingTool> tool("LArSuperCellCablingTool"); + sc = tool.retrieve(); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << " Can't get LArCablingSvc." << endreq; + return sc; + } else m_larCablingSvc = (LArCablingBase*)&(*tool); + + } else { // m_isSC + const LArOnlineID* ll; + sc = m_detStore->retrieve(ll, "LArOnlineID"); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Could not get LArOnlineID helper !" << endreq; + return StatusCode::FAILURE; + } + else { + m_onlineId = (const LArOnlineID_Base*)ll; + (*m_log) << MSG::DEBUG << " Found the LArOnlineID helper. " << endreq; + } + + ToolHandle<LArCablingService> tool("LArCablingService"); + sc = tool.retrieve(); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << " Can't get LArCablingSvc." << endreq; + return sc; + } else m_larCablingSvc = (LArCablingBase*)&(*tool); + } // end of m_isSC if + + if (m_addBC) { + sc = m_badChanTool.retrieve(); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << " Can't get BadChanTool." << endreq; + return sc; + } + } + + if (m_addFEBTemp) { + sc = m_FEBTempTool.retrieve(); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << " Can't get FEBTempTool." << endreq; + return sc; + } + } + + //Online-identifier variables + sc=nt->addItem("channelId",m_onlChanId,0x38000000,0x3A000000); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'channelId' failed" << endreq; + return StatusCode::FAILURE; + } + + //Offline-identifier variables + if ( m_OffId ) { + sc=nt->addItem("offlineId",m_oflChanId,0x20000000,0x40000000); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'channelId' failed" << endreq; + return StatusCode::FAILURE; + } + } + + sc=nt->addItem("barrel_ec",m_barrel_ec,0,1); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'barrel_ec' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("pos_neg",m_pos_neg,0,1); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'pos_neg' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("FT",m_FT,0,32); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'FT' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("slot",m_slot,1,15); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'slot' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=nt->addItem("channel",m_channel,0,127); + if (sc!=StatusCode::SUCCESS){ + (*m_log) << MSG::ERROR << "addItem 'channel' failed" << endreq; + return StatusCode::FAILURE; + } + + if ( !m_isSC) { + sc=nt->addItem("calibLine",m_calibLine,0,127); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'calibLine' failed" << endreq; + return StatusCode::FAILURE; + } + } + + sc=nt->addItem("isConnected",m_isConnected,0,1); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'isConnected' failed" << endreq; + return StatusCode::FAILURE; + } + + //Offline-ID related variables + sc=nt->addItem("layer",m_layer,0,4); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'layer' failed" << endreq; + return StatusCode::FAILURE; + } + sc=nt->addItem("ieta",m_eta,0,510); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'ieta' failed" << endreq; + return StatusCode::FAILURE; + } + sc=nt->addItem("iphi",m_phi,0,1023); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'iphi' failed" << endreq; + return StatusCode::FAILURE; + } + sc=nt->addItem("region",m_region,0,5); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'region' failed" << endreq; + return StatusCode::FAILURE; + } + sc=nt->addItem("detector",m_detector,0,2); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'detector' failed" << endreq; + return StatusCode::FAILURE; + } + + if (m_addBC) { + sc=nt->addItem("badChan",m_badChanWord); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'badChan' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if (m_addFEBTemp) { + sc=nt->addItem("FEBTemp1",m_FEBTemp1); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'FEBTemp1' failed" << endreq; + return StatusCode::FAILURE; + } + sc=nt->addItem("FEBTemp2",m_FEBTemp2); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'FEBTemp2' failed" << endreq; + return StatusCode::FAILURE; + } + } + + m_initialized=true; + return StatusCode::SUCCESS; +} + +bool LArCond2NtupleBase::fillFromIdentifier(const HWIdentifier& hwid) { + + m_onlChanId = hwid.get_identifier32().get_compact(); + if ( m_OffId ){ + Identifier offId = m_larCablingSvc->cnvToIdentifier(hwid); + m_oflChanId = offId.get_identifier32().get_compact(); + } + m_barrel_ec = m_onlineId->barrel_ec(hwid); + m_pos_neg = m_onlineId->pos_neg(hwid); + m_FT = m_onlineId->feedthrough(hwid); + m_slot = m_onlineId->slot(hwid); + m_channel = m_onlineId->channel(hwid); + + if ( !m_isSC) { + m_calibLine=NOT_VALID; + const std::vector<HWIdentifier>& calibLineV=((LArCablingService*)m_larCablingSvc)->calibSlotLine(hwid); + if(calibLineV.size()) m_calibLine = m_onlineId->channel(calibLineV[0]); + } + + m_detector=NOT_VALID; + m_region=NOT_VALID; + m_layer=NOT_VALID; + m_eta=NOT_VALID; + m_phi=NOT_VALID; + if (m_addBC) m_badChanWord=0; + bool connected=false; + + try { + if (m_larCablingSvc->isOnlineConnected(hwid)) { + Identifier id=m_larCablingSvc->cnvToIdentifier(hwid); + if (m_emId->is_lar_em(id)) { + m_eta = m_emId->eta(id); + m_phi = m_emId->phi(id); + m_layer = m_emId->sampling(id); + m_region = m_emId->region(id); + m_detector = fabs(m_emId->barrel_ec(id)) - 1; //0-barrel, 1-EMEC-OW, 2-EMEC-IW + } + else if (m_hecId->is_lar_hec(id)) { + m_eta = m_hecId->eta(id); + m_phi = m_hecId->phi(id); + m_layer = m_hecId->sampling(id); + m_region = m_hecId->region(id); + m_detector = 3; + } + else if (m_fcalId->is_lar_fcal(id)) { + m_eta = m_fcalId->eta(id); + m_phi = m_fcalId->phi(id); + m_layer = m_fcalId->module(id); + m_region = 0; + m_detector = 4; + } + connected=true; + }//end if is connected + }catch (LArID_Exception & except) {} + + //bad-channel word + if (m_addBC) m_badChanWord=m_badChanTool->status(hwid).packedData(); + // FEB temperatures + if (m_addFEBTemp) { + FEBTemp tv = m_FEBTempTool->getFebTemp(hwid); + if( !tv.empty() ) { + FEBTemp::const_iterator itb = tv.begin(); + FEBTemp::const_iterator ite = tv.end(); + for(;itb!=ite;++itb) { + m_FEBTemp1 = (*itb).first; + m_FEBTemp2 = (*itb).second; + } + } + } + + m_isConnected = (long)connected; + + return connected; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArDSPThresholds2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArDSPThresholds2Ntuple.cxx new file mode 100644 index 000000000000..5225b895897a --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArDSPThresholds2Ntuple.cxx @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArDSPThresholds2Ntuple.h" +#include "LArIdentifier/LArOnlineID.h" + +#include "LArRawConditions/LArDSPThresholdsComplete.h" +#include "LArCOOLConditions/LArDSPThresholdsFlat.h" + +#include "CoralBase/Blob.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" + +LArDSPThresholds2Ntuple::LArDSPThresholds2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator){ + + declareProperty("NtupleTitle",m_ntTitle="Gain Thresholds"); + declareProperty("NtupleName",m_ntname="DSPTHR"); + declareProperty("DumpFlat",m_doFlat=false); + declareProperty("FlatFolder",m_folder=""); + m_ntpath="/NTUPLES/FILE1/"+m_ntname; + m_addFEBTemp=false; +} + + +StatusCode LArDSPThresholds2Ntuple::initialize() { + + StatusCode sc=LArCond2NtupleBase::initialize(); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "Base init failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("tQThr",m_tQThr); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem tQThr failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("samplesThr",m_samplesThr); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem samplesThr failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("trigThr",m_trigThr); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem trigThr failed" << endreq; + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +LArDSPThresholds2Ntuple::~LArDSPThresholds2Ntuple() +{} + +StatusCode LArDSPThresholds2Ntuple::stop() { + StatusCode sc; + + const LArDSPThresholdsComplete *dc = 0; + const LArDSPThresholdsFlat *df = 0; + const AthenaAttributeList* attrList=0; + if(m_doFlat) { + sc=detStore()->retrieve(attrList,m_folder); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Failed to retrieve AthenaAttributeList with key " << m_folder << endreq; + return sc; + } + + const coral::Blob& blob = (attrList->coralList())["tQThr"].data<coral::Blob>(); + if (blob.size()<3) { + msg(MSG::INFO) << "Found empty blob, nothing to do"<<endreq; + return StatusCode::SUCCESS; + } + + df=new LArDSPThresholdsFlat(attrList); + + } else { + sc=m_detStore->retrieve(dc); + if(sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) <<"Could not retrieve LArDSPThresholdsComplete...."<<endreq; + return StatusCode::FAILURE; + } + } + + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + if(m_doFlat) { + m_tQThr=df->tQThr(hwid); + m_samplesThr=df->samplesThr(hwid); + m_trigThr=df->trigSumThr(hwid); + } else { + m_tQThr=dc->tQThr(hwid); + m_samplesThr=dc->samplesThr(hwid); + m_trigThr=dc->trigSumThr(hwid); + } + + fillFromIdentifier(hwid); + //msg(MSG::INFO)<<"hwid: "<<hwid.getString()<<" "<<tQThr<<" : "<<samplesThr<<" : "<<trigThr<<endreq; + + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + } + + + msg(MSG::INFO) << "LArDSPThresholds2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; + +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LArFEBTemp2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArFEBTemp2Ntuple.cxx new file mode 100755 index 000000000000..551a43bfeec4 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArFEBTemp2Ntuple.cxx @@ -0,0 +1,92 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArFEBTemp2Ntuple.h" +#include "LArElecCalib/ILArFEBTempTool.h" +#include "LArCondUtils/LArFEBTempTool.h" +#include "LArIdentifier/LArOnlineID.h" +#include "StoreGate/StoreGateSvc.h" +#include "LArTools/LArCablingService.h" +#include "GaudiKernel/IToolSvc.h" + +LArFEBTemp2Ntuple::LArFEBTemp2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArCond2NtupleBase(name, pSvcLocator) { + + m_ntTitle="FEB Temperatures"; + m_ntpath="/NTUPLES/FILE1/FEBTEMP"; + +} + +LArFEBTemp2Ntuple::~LArFEBTemp2Ntuple() +{} + +StatusCode LArFEBTemp2Ntuple::stop() { + StatusCode sc; + NTuple::Item<float> temp1; + NTuple::Item<float> temp2; + + sc=m_nt->addItem("temp1",temp1,-1000.,5000.); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'temp1' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("temp2",temp2,-1000.,5000.); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'temp2' failed" << endreq; + return StatusCode::FAILURE; + } + + IToolSvc* toolSvc=0; + sc = service( "ToolSvc",toolSvc); + if (sc!=StatusCode::SUCCESS) + { + (*m_log) << MSG::ERROR << "Unable to retrieve IToolSvc" + << endreq; + } + + ILArFEBTempTool *larFEBTempTool; + sc = toolSvc->retrieveTool("LArFEBTempTool", larFEBTempTool); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Unable to retrieve LArFEBTempTool from ToolSvc" << endreq; + return StatusCode::FAILURE; + } + + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + + for(; itOnId!=itOnIdEnd;++itOnId) + { + const HWIdentifier hwid = *itOnId; + FEBTemp tv = larFEBTempTool->getFebTemp(hwid); + (*m_log) << MSG::DEBUG << hwid << " " << tv.size()<<endreq; + + if( !tv.empty() ) + { + FEBTemp::const_iterator itb = tv.begin(); + FEBTemp::const_iterator ite = tv.end(); + + for(;itb!=ite;++itb) + { + temp1 = (*itb).first; + temp2 = (*itb).second; + + fillFromIdentifier(hwid); + + sc=ntupleSvc()->writeRecord(m_nt); + + if (sc!=StatusCode::SUCCESS) + { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + } + } + } + + (*m_log) << MSG::INFO << "LArFEBTemp2Ntuple has finished." << endreq; + + return StatusCode::SUCCESS; + +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LArFebTimeOffset2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArFebTimeOffset2Ntuple.cxx new file mode 100644 index 000000000000..21a418670ee8 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArFebTimeOffset2Ntuple.cxx @@ -0,0 +1,72 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArFebTimeOffset2Ntuple.h" +#include "LArRawConditions/LArFEBTimeOffset.h" + +#include "LArIdentifier/LArOnlineID.h" + +LArFebTimeOffset2Ntuple::LArFebTimeOffset2Ntuple(const std::string & name, ISvcLocator * pSvcLocator) : + LArCond2NtupleBase(name,pSvcLocator) { + + declareProperty("Gain",m_gain=0); + declareProperty("ContainerKey",m_inputContainer="FebTimeOffset"); + + m_ntTitle="FebTimeOffsets"; + m_ntpath="/NTUPLES/FILE1/FEBTIME"; + return; +} + +LArFebTimeOffset2Ntuple::~LArFebTimeOffset2Ntuple() {} + + +StatusCode LArFebTimeOffset2Ntuple::initialize() { + + //m_ntTitle="TimeDiffs"; + //m_ntpath=std::string("/NTUPLES/FILE1/TIMEDIFF"); + return LArCond2NtupleBase::initialize(); +} + +StatusCode LArFebTimeOffset2Ntuple::stop() { + + //std::cout << detStore()->dump() << std::endl; + NTuple::Item<float> offset; + NTuple::Item<long> gain; + + + m_nt->addItem("gain",gain,0,3).ignore(); + m_nt->addItem("offset",offset,-5000,5000).ignore(); + + const LArFEBTimeOffset* feboffsets; + //if (detStore()->retrieve(feboffsets,m_inputContainer).isFailure()) { + if (detStore()->retrieve(feboffsets).isFailure()) { + msg(MSG::ERROR) << "Failed to retrieve LArFEBTimeOffset with key " << m_inputContainer << endreq; + return StatusCode::FAILURE; + } + + const float novalue=-99999; + (const_cast<LArFEBTimeOffset*>(feboffsets))->setDefaultReturnValue(novalue); + + + std::vector<HWIdentifier>::const_iterator fit=m_onlineId->feb_begin(); + std::vector<HWIdentifier>::const_iterator fit_e=m_onlineId->feb_end(); + for(;fit!=fit_e;++fit) { + const HWIdentifier fid=*fit; + offset=feboffsets->TimeOffset(fid); + + //FIXME: The PhysWave shifter fills 0 for all not-present FEBs. + if (offset!=0 && offset!=novalue) { + gain=m_gain; + fillFromIdentifier(fid); + + StatusCode sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end if have value + } // end loop over feb identifiers + + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArGainThresholds2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArGainThresholds2Ntuple.cxx new file mode 100644 index 000000000000..b65123d6b187 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArGainThresholds2Ntuple.cxx @@ -0,0 +1,67 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArGainThresholds2Ntuple.h" +#include "LArIdentifier/LArOnlineID.h" + +LArGainThresholds2Ntuple::LArGainThresholds2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator), m_febConfigReader("LArFEBConfigReader") { + + declareProperty("FebConfigReader",m_febConfigReader); + m_ntTitle="Gain Thresholds"; + m_ntpath="/NTUPLES/FILE1/GAINTH"; +} + + +StatusCode LArGainThresholds2Ntuple::initialize() { + + if (m_febConfigReader.retrieve().isFailure()) { + msg(MSG::ERROR) << "Failed to retrieve tool " << m_febConfigReader << endreq; + return StatusCode::FAILURE; + } + + return LArCond2NtupleBase::initialize(); +} + +LArGainThresholds2Ntuple::~LArGainThresholds2Ntuple() +{} + +StatusCode LArGainThresholds2Ntuple::stop() { + StatusCode sc; + NTuple::Item<long> lower; + NTuple::Item<long> upper; + + sc=m_nt->addItem("lower",lower,-1000,5000); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'lower' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("upper",upper,-1000.,5000.); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'upper' failed" << endreq; + return StatusCode::FAILURE; + } + + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + lower=m_febConfigReader->lowerGainThreshold(hwid); + upper=m_febConfigReader->upperGainThreshold(hwid); + + fillFromIdentifier(hwid); + + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + } + + msg(MSG::INFO) << "LArGainThresholds2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; + +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LArHVScaleCorr2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArHVScaleCorr2Ntuple.cxx new file mode 100644 index 000000000000..ab1fbf5b31c7 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArHVScaleCorr2Ntuple.cxx @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArHVScaleCorr2Ntuple.h" +#include "LArRawConditions/LArHVScaleCorrComplete.h" +#include "CaloIdentifier/CaloGain.h" + +LArHVScaleCorr2Ntuple::LArHVScaleCorr2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator) { + m_contKey = "LArHVScaleCorr"; + declareProperty("ContainerKey",m_contKey); + + m_ntTitle="HV Scale Correction"; + m_ntpath="/NTUPLES/FILE1/HVSCALE"; + +} + +LArHVScaleCorr2Ntuple::~LArHVScaleCorr2Ntuple() +{} + +StatusCode LArHVScaleCorr2Ntuple::stop() { + + const LArHVScaleCorrComplete* larHVScaleCorrComplete; + StatusCode sc=m_detStore->retrieve(larHVScaleCorrComplete,m_contKey); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Unable to retrieve LArHVScaleCorrComplete with key " + << m_contKey << " from DetectorStore" << endreq; + return StatusCode::FAILURE; + } + + NTuple::Item<float> corr; + + sc=m_nt->addItem("hvcorr",corr,-1000.,2.); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'corr' failed" << endreq; + return StatusCode::FAILURE; + } + + + unsigned cellCounter=0; + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + if (m_larCablingSvc->isOnlineConnected(hwid)) { + const LArHVScaleCorrComplete::LArCondObj hvScale_obj= + larHVScaleCorrComplete->get(hwid); + if (!hvScale_obj.isEmpty()) { + fillFromIdentifier(hwid); + corr=hvScale_obj.m_data; + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }// end if object exists + }//end if isConnected + cellCounter++; + }//end loop over online ID + + (*m_log) << MSG::INFO << "LArHVScaleCorr2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. diff --git a/LArCalorimeter/LArCalibTools/src/LArMphysOverMcal2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArMphysOverMcal2Ntuple.cxx new file mode 100644 index 000000000000..7e500f783771 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArMphysOverMcal2Ntuple.cxx @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArMphysOverMcal2Ntuple.h" +#include "LArRawConditions/LArMphysOverMcalComplete.h" +#include "LArRawConditions/LArMphysOverMcalMC.h" +#include "CaloIdentifier/CaloGain.h" +/* +#include "GaudiKernel/INTupleSvc.h" +#include "GaudiKernel/NTuple.h" +#include "GaudiKernel/SmartDataPtr.h" +*/ + +//#include <fstream> + +LArMphysOverMcal2Ntuple::LArMphysOverMcal2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator) { + declareProperty("ContainerKey",m_contKey); + declareProperty("IsMC",m_isMC = false); + + m_ntTitle="MphysOverMcal"; + m_ntpath="/NTUPLES/FILE1/MPMC"; + +} + +LArMphysOverMcal2Ntuple::~LArMphysOverMcal2Ntuple() +{} + +StatusCode LArMphysOverMcal2Ntuple::stop() { + const ILArMphysOverMcal* larMphysOverMcal = NULL; + StatusCode sc; + sc=m_detStore->retrieve(larMphysOverMcal,m_contKey); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Unable to retrieve ILArMphysOverMcal with key " + << m_contKey << " from DetectorStore" << endreq; + return StatusCode::FAILURE; + } + + NTuple::Item<long> cellIndex,gain; + NTuple::Item<float> mpmc; + + sc=m_nt->addItem("icell",cellIndex,0,2000); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Cell Index' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("gain",gain,0,3); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + + sc=m_nt->addItem("mphysovermcal",mpmc,-1000.,2.); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'mphysovermcal' failed" << endreq; + return StatusCode::FAILURE; + } + + + unsigned cellCounter=0; + for(long igain=CaloGain::LARHIGHGAIN; igain<CaloGain::LARNGAIN; igain++) { + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + if ( m_larCablingSvc->isOnlineConnected(hwid) && !m_onlineId->isFCALchannel(hwid)) { + fillFromIdentifier(hwid); + cellIndex = cellCounter; + gain=igain; + mpmc = larMphysOverMcal->MphysOverMcal(hwid,igain); + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end if isConnected + cellCounter++; + }//end loop over online ID + } // ovr gains + + (*m_log) << MSG::INFO << "LArMphysOverMcal2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LArMphysOverMcalFromTuple.cxx b/LArCalorimeter/LArCalibTools/src/LArMphysOverMcalFromTuple.cxx new file mode 100755 index 000000000000..008de7f0d533 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArMphysOverMcalFromTuple.cxx @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArMphysOverMcalFromTuple.h" + +#include "LArIdentifier/LArOnlineID.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArRawConditions/LArMphysOverMcalComplete.h" +#include "LArElecCalib/ILArMphysOverMcal.h" + +#include "TFile.h" +#include "TBranch.h" +#include "TTree.h" +#include "TChain.h" + +#include <vector> +#include <iostream> +#include <fstream> +#include <string> + + +LArMphysOverMcalFromTuple::LArMphysOverMcalFromTuple (const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator) +{ + declareProperty("FileNames", m_root_file_names); + declareProperty("StoreKey", m_store_key="FROMTUPLE"); +} + +LArMphysOverMcalFromTuple::~LArMphysOverMcalFromTuple() +{} + +StatusCode LArMphysOverMcalFromTuple::initialize() +{ + return StatusCode::SUCCESS ; +} + + +StatusCode LArMphysOverMcalFromTuple::stop() +{ + MsgStream log(msgSvc(), name()); + log << MSG::INFO << "... in finalize()" << endreq ; + + // Get access to the Detector Store + StoreGateSvc* detStore; + StatusCode sc = service("DetectorStore",detStore); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + + // get LArOnlineID helper + const LArOnlineID* onlineHelper; + sc = detStore->retrieve(onlineHelper, "LArOnlineID"); + if (sc.isFailure()) { + log << MSG::ERROR << "Could not get LArOnlineID" << endreq; + return sc; + } + + TChain* outfit = new TChain("outfit"); + for ( std::vector<std::string>::const_iterator it = m_root_file_names.begin(); + it != m_root_file_names.end(); it++ ) { + outfit->Add(it->c_str()); + } + + // variable names as in the Ntuple + Int_t BarAC; // 0 = barrel C 1 = barrel A + Int_t FT; // feedthrough 0 - 31 + Int_t Channel; // 0 - 14 + Int_t Slot; // 1 -14 + Double_t PhysOCal; // Mphys/Mcal + int gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2, + + outfit->SetBranchAddress("Channel", &Channel); + outfit->SetBranchAddress("Slot", &Slot); + outfit->SetBranchAddress("FT", &FT); + outfit->SetBranchAddress("BarAC", &BarAC); + outfit->SetBranchAddress("PhysOCal", &PhysOCal); + + + // Create new LArMphysOverMcalComplete + LArMphysOverMcalComplete* container = new LArMphysOverMcalComplete(); +// container->setGroupingType(LArConditionsContainerBase::FeedThroughGrouping); + container->setGroupingType(LArConditionsContainerBase::ExtendedFTGrouping); + container->initialize(); + + + + + // loop over entries in the Tuple, one entry = one channel + Long64_t nentries = outfit->GetEntries(); + for ( Int_t i = 0; i < nentries; i++ ) + { + outfit->GetEntry(i); + HWIdentifier id = onlineHelper->channel_Id(0, BarAC, FT, Slot, Channel); + container->set(id,gain,PhysOCal); + } + + + // store + sc=detStore->record(container,m_store_key); + if (sc.isFailure()) { + log << MSG::FATAL << "Cannot record LArMphysOverMcalComplete to StoreGate with key = " << m_store_key << endreq; + return sc; + } + // Symlink LArMphysOverMcalComplete to ILArMphysOverMcal for further use + ILArMphysOverMcal *larMphysOverMcal = NULL; + sc = detStore->symLink(container,larMphysOverMcal); + if (sc.isFailure()) { + log << MSG::FATAL << "Could not symlink ILArMphysOverMcal with LArMphysOverMcalComplete." << endreq; + return StatusCode::FAILURE; + } + + + log << MSG::INFO << "LArMphysOverMcalyFromTuple finalized!" << endreq; + + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArNoise2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArNoise2Ntuple.cxx new file mode 100644 index 000000000000..f13916566e31 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArNoise2Ntuple.cxx @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArNoise2Ntuple.h" +#include "LArRawConditions/LArNoiseComplete.h" +#include "LArRawConditions/LArNoiseMC.h" +#include "CaloIdentifier/CaloGain.h" +/* +#include "GaudiKernel/INTupleSvc.h" +#include "GaudiKernel/NTuple.h" +#include "GaudiKernel/SmartDataPtr.h" +*/ + +//#include <fstream> + +LArNoise2Ntuple::LArNoise2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator) { + declareProperty("ContainerKey",m_contKey); + //declareProperty("IsMC",m_isMC = false); + + m_ntTitle="Noise"; + m_ntpath="/NTUPLES/FILE1/NOISE"; + +} + +LArNoise2Ntuple::~LArNoise2Ntuple() +{} + +StatusCode LArNoise2Ntuple::stop() { + //const LArNoiseComplete* larNoiseComplete = NULL; + //const LArNoiseMC* larNoiseMC = NULL; + const ILArNoise* larNoise = NULL; + StatusCode sc; + sc=m_detStore->retrieve(larNoise,m_contKey); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Unable to retrieve ILArNoise with key " + << m_contKey << " from DetectorStore" << endreq; + return StatusCode::FAILURE; + } + + NTuple::Item<long> cellIndex,gain; + NTuple::Item<float> noise; + + sc=m_nt->addItem("icell",cellIndex,0,2000); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Cell Index' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("gain",gain,0,3); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + + sc=m_nt->addItem("noise",noise); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'noise' failed" << endreq; + return StatusCode::FAILURE; + } + + + unsigned cellCounter=0; + for(long igain=CaloGain::LARHIGHGAIN; igain<CaloGain::LARNGAIN; igain++) { + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + if ( m_larCablingSvc->isOnlineConnected(hwid)) { + fillFromIdentifier(hwid); + cellIndex = cellCounter; + gain=igain; + noise = larNoise->noise(hwid,igain); + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end if isConnected + cellCounter++; + }//end loop over online ID + } // ovr gains + + (*m_log) << MSG::INFO << "LArNoise2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LArOFC2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArOFC2Ntuple.cxx new file mode 100755 index 000000000000..ee167f83bcfc --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArOFC2Ntuple.cxx @@ -0,0 +1,168 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArOFC2Ntuple.h" +#include "LArRawConditions/LArOFCComplete.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArIdentifier/LArOnlineID.h" +#include "StoreGate/StoreGateSvc.h" +#include "LArTools/LArCablingService.h" + +LArOFC2Ntuple::LArOFC2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator) +{ + declareProperty("ContainerKey", m_contKey = "LArOFC"); + //declareProperty("Nsamples", m_nSamples = 5); + //declareProperty("Nphases", m_nPhases = 50); + declareProperty("NtupleName", m_ntName = "OFC"); + declareProperty("NtupleFile", m_ntFile = "FILE1"); + declareProperty("IsMC", m_isMC=false); + declareProperty("OFCTool", m_OFCTool ); +} + +LArOFC2Ntuple::~LArOFC2Ntuple() +{} + +StatusCode LArOFC2Ntuple::initialize() { + m_ntTitle="Optimal Filtering Coefficients"; + m_ntpath=std::string("/NTUPLES/")+m_ntFile+std::string("/")+m_ntName; + + if ( LArCond2NtupleBase::initialize().isFailure() ) { + return StatusCode::FAILURE; + } + if ( m_isMC && m_OFCTool.retrieve().isFailure() ) { + (*m_log) << MSG::ERROR << "OFC tool required for MC conditions but not available" << endreq; + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode LArOFC2Ntuple::stop() { + StatusCode sc; + // Ntuple booking: Specific + NTuple::Item<long> gain, phase, nSamples; + NTuple::Item<float> timeOffset, phasetime; + NTuple::Array<float> OFCa, OFCb; + + sc=m_nt->addItem("Gain",gain,-1,2); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + //Specific: + sc=m_nt->addItem("TimeOffset",timeOffset,0,100); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'TimeOffset' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Phase",phase,0,49); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'phase' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("PhaseTime",phasetime,0,800); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'PhaseTime' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("nSamples",nSamples,0,100); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'nSamples' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("OFCa",nSamples,OFCa); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'OFCa' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("OFCb",nSamples,OFCb); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'OFCb' failed" << endreq; + return StatusCode::FAILURE; + } + + // retrieve OFC object + const ILArOFC* larOFC = NULL ; + //const LArOFCComplete* larOFC = NULL ; + if ( !m_isMC ) { + (*m_log) << MSG::DEBUG << "Retrieving ILArOFC object with key " << m_contKey << endreq; + sc = m_detStore->retrieve(larOFC,m_contKey); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Can't retrieve ILArOFC with key " << m_contKey << " from Conditions Store" << endreq; + return StatusCode::FAILURE; + } + } + + unsigned cellCounter=0; + for ( unsigned igain=CaloGain::LARHIGHGAIN; + igain<CaloGain::LARNGAIN ; ++igain ) { + std::vector<HWIdentifier>::const_iterator it = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator it_e = m_onlineId->channel_end(); + if ( m_isMC ) { + for (;it!=it_e;it++) { + const HWIdentifier chid = *it; + if (!m_larCablingSvc->isOnlineConnected(chid)) continue; + (*m_log) << MSG::VERBOSE << "Dumping OFC for channel 0x" << MSG::hex + << chid.get_compact() << MSG::dec << endreq; + ILArOFC::OFCRef_t ofc_a=m_OFCTool->OFC_a(chid,igain); + ILArOFC::OFCRef_t ofc_b=m_OFCTool->OFC_b(chid,igain); + fillFromIdentifier(chid); + gain = (long)igain ; + phase = (long)0 ; + nSamples=ofc_a.size(); + for (int k=0;k<nSamples;k++ ) { + OFCa[k] = ofc_a[k] ; + OFCb[k] = ofc_b[k] ; + } + + timeOffset = 0; + phasetime = 0; + + sc = ntupleSvc()->writeRecord(m_nt); + cellCounter++; + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//loop over channels + } else { // is_MC + for (;it!=it_e;it++) { + const HWIdentifier chid = *it; + if ( !m_larCablingSvc->isOnlineConnected(chid)) continue; + (*m_log) << MSG::VERBOSE << "Dumping OFC for channel 0x" << MSG::hex + << chid.get_compact() << MSG::dec << endreq; + for (unsigned iphase=0;iphase<larOFC->nTimeBins(chid,igain);iphase++) { + ILArOFC::OFCRef_t ofc_a=larOFC->OFC_a(chid,igain,iphase); + //Check if we have OFC for this channel and gain + //if (!ofc_a.size()) break;//No more phases + ILArOFC::OFCRef_t ofc_b=larOFC->OFC_b(chid,igain,iphase); + fillFromIdentifier(chid); + gain = (long)igain ; + phase = (long)iphase ; + nSamples=ofc_a.size(); + for (int k=0;k<nSamples;k++ ) { + OFCa[k] = ofc_a[k] ; + OFCb[k] = ofc_b[k] ; + } + + timeOffset = larOFC->timeOffset(chid,igain); + phasetime = phase*larOFC->timeBinWidth(chid,igain); + + + sc = ntupleSvc()->writeRecord(m_nt); + cellCounter++; + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//loop over phases + }//loop over channels + } + }//loop over gains + (*m_log) << MSG::INFO << "Total number of cells = " << cellCounter << endreq; + (*m_log) << MSG::INFO << "LArOFC2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +} // end finalize-method. diff --git a/LArCalorimeter/LArCalibTools/src/LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx b/LArCalorimeter/LArCalibTools/src/LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx new file mode 100755 index 000000000000..3bad0541b7cd --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx @@ -0,0 +1,157 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArOFCBin_PhysCaliTdiffFromStdNtuple.h" + +#include "LArIdentifier/LArOnlineID.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArRawConditions/LArOFCBinComplete.h" +#include "LArRawConditions/LArPhysCaliTdiffComplete.h" + +#include "TFile.h" +#include "TBranch.h" +#include "TTree.h" +#include "TChain.h" + +#include <vector> +#include <iostream> +#include <fstream> +#include <string> + + +LArOFCBin_PhysCaliTdiffFromStdNtuple::LArOFCBin_PhysCaliTdiffFromStdNtuple (const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator) +{ + declareProperty("FileNames", m_root_file_names); + declareProperty("NtupleName", m_ntuple_name="PARAMS"); + declareProperty("Store_OFC", m_fillofc=false); + declareProperty("StoreKey_OFC", m_store_key_ofcbin="LArOFC"); + declareProperty("Store_Tdiff", m_filltdiff=false); + declareProperty("StoreKey_Tdiff", m_store_key_tdiff="LArPhysCaliTdiff"); + declareProperty("GroupingType", m_groupingType="FeedThrough"); +} + +LArOFCBin_PhysCaliTdiffFromStdNtuple::~LArOFCBin_PhysCaliTdiffFromStdNtuple() +{} + +StatusCode LArOFCBin_PhysCaliTdiffFromStdNtuple::initialize() +{ + return StatusCode::SUCCESS ; +} + + +StatusCode LArOFCBin_PhysCaliTdiffFromStdNtuple::stop() +{ + MsgStream log(msgSvc(), name()); + log << MSG::INFO << "... in stop()" << endreq ; + + // Get access to the Detector Store + StoreGateSvc* detStore; + StatusCode sc = service("DetectorStore",detStore); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + + // get LArOnlineID helper + const LArOnlineID* onlineHelper; + sc = detStore->retrieve(onlineHelper, "LArOnlineID"); + if (sc.isFailure()) { + log << MSG::ERROR << "Could not get LArOnlineID" << endreq; + return sc; + } + + TChain* outfit = new TChain(m_ntuple_name.c_str()); + for ( std::vector<std::string>::const_iterator it = m_root_file_names.begin(); + it != m_root_file_names.end(); it++ ) { + outfit->Add(it->c_str()); + } + + + Int_t channelId; + Int_t FT, slot, channel; + Int_t bin; + Double_t tdiff; + + + Int_t gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2, + outfit->SetBranchAddress("channelId", &channelId); + outfit->SetBranchAddress("FT", &FT); + outfit->SetBranchAddress("slot", &slot); + outfit->SetBranchAddress("channel", &channel); + outfit->SetBranchAddress("gain", &gain); + if(m_filltdiff) { + outfit->SetBranchAddress("Tdiff", &tdiff); + } + if(m_fillofc) { + outfit->SetBranchAddress("OFCBin", &bin); + } + + // Create new objects + LArOFCBinComplete *larOFCParams = new LArOFCBinComplete(); + larOFCParams->setGroupingType(m_groupingType, log); + larOFCParams->initialize(); + LArPhysCaliTdiffComplete *larTdiffParams = new LArPhysCaliTdiffComplete(); + larTdiffParams->setGroupingType(m_groupingType, log); + larTdiffParams->initialize(); + + + unsigned int hwid; + //unsigned int uflag; + // loop over entries in the Tuple, one entry = one channel + Long64_t nentries = outfit->GetEntries(); + for ( Long64_t i = 0; i < nentries; i++ ) + { + outfit->GetEvent(i); + log << MSG::INFO << " Chan " << std::hex << channelId << std::dec << endreq; + log << MSG::INFO << bin << " | " << tdiff << endreq; + hwid = channelId; + HWIdentifier id(hwid); + if(FT != onlineHelper->feedthrough(id) || slot != onlineHelper->slot(id) || channel != onlineHelper->channel(id)) { + log << MSG::ERROR << "Inconsistency in decoding HWID !!!!" <<endreq; + log << MSG::ERROR << FT << " - " << onlineHelper->feedthrough(id) << endreq; + log << MSG::ERROR << slot << " - " << onlineHelper->slot(id) << endreq; + log << MSG::ERROR << channel << " - " << onlineHelper->channel(id) << endreq; + log << MSG::ERROR << "Not creating PhysWave !!!!" << endreq; + continue; + } + + // Add to objects + if(m_fillofc) larOFCParams->set(id,gain,bin); + if(m_filltdiff) larTdiffParams->set(id,gain,tdiff); + } + + + // store + if(m_fillofc) { + sc=detStore->record(larOFCParams,m_store_key_ofcbin); + if (sc.isFailure()) { + log << MSG::FATAL << "Cannot record larOFCParams to StoreGate with key = " << m_store_key_ofcbin << endreq; + return sc; + } + } + + if(m_filltdiff) { + sc=detStore->record(larTdiffParams,m_store_key_tdiff); + if (sc.isFailure()) { + log << MSG::FATAL << "Cannot record larTdiffParams to StoreGate with key = " << m_store_key_tdiff << endreq; + return sc; + } + } + + // and symlink + + if(m_filltdiff) { + ILArPhysCaliTdiff *ilarTdiff = NULL; + sc = detStore->symLink(larTdiffParams,ilarTdiff); + if (sc.isFailure()) { + log << MSG::FATAL << "Could not symlink ILArPhysCaliTdiff with LArTdiffParamsComplete." << endreq; + return StatusCode::FAILURE; + } + } + + + log << MSG::INFO << "LArOFCBin_PhysCaliTdiffFromStdNtuple finalized!" << endreq; + + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArParams2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArParams2Ntuple.cxx new file mode 100755 index 000000000000..f94716b6c9be --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArParams2Ntuple.cxx @@ -0,0 +1,860 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArParams2Ntuple.h" +#include "CaloIdentifier/CaloGain.h" + +const unsigned LArParams2Ntuple::m_nClasses = LArParamsProperties::END_OF_LIST ; + +LArParams2Ntuple::LArParams2Ntuple(const std::string& name, ISvcLocator* pSvcLocator) + : LArCond2NtupleBase(name, pSvcLocator), + m_completeCaliPulseParams(0), m_completeDetCellParams(0), m_completePhysCaliTdiff(0), + m_completeTdrift(0), m_completeMphysOverMcal(0), m_completeRinj(0), m_completeTshaper(0), + m_completeEMEC_Cphi(0), m_completeEMEC_HValpha(0), m_completeEMEC_HVbeta(0), + m_completeCableLength(0), m_completeCableAttenuation(0), m_calibCaliPulseParams(0), + m_completeOFCBin(0) +{ + //declareProperty("DumpAllOnlineChannels",m_dumpAllOnlineChannels=std::string("")) ; + declareProperty("DetStoreSuffix",m_suffix=std::string("")) ; + declareProperty("AllChannels2Ntuple",m_allChannels2Ntuple=false) ; + declareProperty("UseAbstractInterface",m_useAbstractInterface=false) ; + declareProperty("NtupleName",m_ntName="PARAMS"); + m_keylist.clear() ; + declareProperty("KeyList",m_keylist); + m_detStoreJo.clear(); + declareProperty("DBKeysList",m_detStoreJo); + + m_classNames = LArParamsProperties::ClassNames() ; + + // set default keywords for detector store retrieval + + m_detStoreKeys.resize(m_nClasses) ; + for ( unsigned i=0 ; i<m_nClasses ; i++ ) + m_detStoreKeys[i] = LArParamsProperties::keyword( m_classNames[i] ) ; + +} + +LArParams2Ntuple::~LArParams2Ntuple() +{} + +StatusCode LArParams2Ntuple::initialize() { + + m_ntTitle=m_ntName; + m_ntpath=std::string("/NTUPLES/FILE1/")+m_ntName; + return LArCond2NtupleBase::initialize(); + + + if ( m_classNames.size() != m_nClasses ) { // should never happen! but just to be sure... + msg(MSG::FATAL) << "List of class names does not match foreseen number of classes, cannot go on!" << endreq ; + return StatusCode::FAILURE ; + } + + for ( unsigned i=0 ; i<m_keylist.size() ; i++ ) { + ATH_MSG_DEBUG("examinimg key " << m_keylist[i] << "..."); + unsigned idx = LArParamsProperties::getClassIndex(m_keylist[i]) ; + ATH_MSG_DEBUG("... class index " << idx); + if ( idx >= m_nClasses ) { + ATH_MSG_DEBUG("key " << m_keylist[i] << " does not correspond to any foreseen class"); + return StatusCode::FAILURE ; + } else { + msg(MSG::INFO) << "will dump " << m_keylist[i] << " to Ntuple" << endreq ; + m_dumpFlags.set(idx) ; + } + } + + if ( m_useAbstractInterface ) { + msg(MSG::INFO) << "All parameters will be accessed through abstract interface" << endreq ; + if ( ! m_allChannels2Ntuple ) { + msg(MSG::WARNING) << "This will force dumping to Ntuple all foreseen online channels!" << endreq ; + m_allChannels2Ntuple = true ; + } + } else { + msg(MSG::INFO) << "All parameters will be accessed through their Complete/VsCalib class" << endreq ; + } + if ( m_allChannels2Ntuple ) { + msg(MSG::INFO) << "All foreseen online channels will be written to Ntuple" << endreq ; + } else { + msg(MSG::INFO) << "Only channels with sensible parameters will be written to Ntuple (default)" << endreq ; + } + + return LArCond2NtupleBase::initialize(); +} + + +StatusCode LArParams2Ntuple::stop() { + + + // ntuple handling: + //------------------ + NTuple::Item<long> ntcellIndex; + NTuple::Item<long> ntflag, ntgain; + + // .................... CaliPulseParams: + NTuple::Item<double> ntTcal, ntFstep, ntOffset, ntdTimeCal ; + NTuple::Item<long> ntnCB ; + // .................... DetCellParams: + NTuple::Item<double> ntOmega0, ntTaur ; + // .................... PhysCaliTdiff, Tdrift: + NTuple::Item<double> ntTdiff, ntTdrift ; + // .................... MphysOverMcal: + NTuple::Item<double> ntMphysOverMcal ; + // .................... Rinj, Tshaper: + NTuple::Item<double> ntRinj, ntTshaper ; + // .................... EMEC stuff: + NTuple::Item<double> ntEMEC_Cphi, ntEMEC_HValpha, ntEMEC_HVbeta ; + // .................... Cable stuff: + NTuple::Item<double> ntCableLength, ntCableAttenuation ; + // OFCBin + NTuple::Item<long> ntbin; + + StatusCode sc=m_nt->addItem("cellIndex",ntcellIndex,0,2000); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Cell Index' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("gain",ntgain,-1,2); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Gain' failed" << endreq; + return StatusCode::FAILURE; + } + + if ( m_dumpFlags[CaliPulseParamsComplete] || m_dumpFlags[CaliPulseParamsVsCalib] ) { + sc=m_nt->addItem("Tcal",ntTcal); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Tcal' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Fstep",ntFstep); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Fstep' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Offset",ntOffset); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Offset' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("dTimeCal",ntdTimeCal); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'dTimeCal' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("nCB",ntnCB); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'nCB' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[DetCellParamsComplete] ) { + sc=m_nt->addItem("Omega0",ntOmega0); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Omega0' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Taur",ntTaur); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Taur' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[PhysCaliTdiffComplete] ) { + sc=m_nt->addItem("Tdiff",ntTdiff); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Tdiff' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[TdriftComplete] ) { + sc=m_nt->addItem("Tdrift",ntTdrift); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Tdrift' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[MphysOverMcalComplete] ) { + sc=m_nt->addItem("MphysOverMcal",ntMphysOverMcal); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'MphysOverMcal' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[RinjComplete] ) { + sc=m_nt->addItem("Rinj",ntRinj); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Rinj' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[TshaperComplete] ) { + sc=m_nt->addItem("Tshaper",ntTshaper); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Tshaper' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[EMEC_CphiComplete] ) { + sc=m_nt->addItem("EMEC_Cphi",ntEMEC_Cphi); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'EMEC_Cphi' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[EMEC_HValphaComplete] ) { + sc=m_nt->addItem("EMEC_HValpha",ntEMEC_HValpha); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'EMEC_HValpha' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[EMEC_HVbetaComplete] ) { + sc=m_nt->addItem("EMEC_HVbeta",ntEMEC_HVbeta); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'EMEC_HVbeta' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[CableLengthComplete] ) { + sc=m_nt->addItem("CableLength",ntCableLength); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'CableLength' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[CableAttenuationComplete] ) { + sc=m_nt->addItem("CableAttenuation",ntCableAttenuation); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'CableAttenuation' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if ( m_dumpFlags[OFCBinComplete] ) { + sc=m_nt->addItem("OFCBin",ntbin); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'OFCBin' failed" << endreq; + return StatusCode::FAILURE; + } + } + + //======================================================================================================= + // dump smaller complete structures to a common Ntuple + //======================================================================================================= + + // + // first, scan all complete data structures to collect a map of channels + // + + int nGains = (int)CaloGain::LARNGAIN ; + + m_dump_flags_map.resize(nGains) ; // map of channels to be dumped; resized to host 3 gains + + if ( m_allChannels2Ntuple ) { + + // *** all readout channels will go into the ntuple *** + + if ( m_dumpFlags[CaliPulseParamsComplete] ) { + sc = retrieveFromDetStore(m_completeCaliPulseParams) ; + if ( sc.isFailure() ) m_dumpFlags.clear(CaliPulseParamsComplete) ; + } + if ( m_dumpFlags[DetCellParamsComplete] ) { + sc = retrieveFromDetStore(m_completeDetCellParams) ; + if ( sc.isFailure() ) m_dumpFlags.clear(DetCellParamsComplete) ; + } + if ( m_dumpFlags[PhysCaliTdiffComplete] ) { + sc = retrieveFromDetStore(m_completePhysCaliTdiff) ; + if ( sc.isFailure() ) m_dumpFlags.clear(PhysCaliTdiffComplete) ; + } + if ( m_dumpFlags[TdriftComplete] ) { + sc = retrieveFromDetStore(m_completeTdrift) ; + if ( sc.isFailure() ) m_dumpFlags.clear(TdriftComplete) ; + } + if ( m_dumpFlags[MphysOverMcalComplete] ) { + sc = retrieveFromDetStore(m_completeMphysOverMcal) ; + if ( sc.isFailure() ) m_dumpFlags.clear(MphysOverMcalComplete) ; + } + if ( m_dumpFlags[RinjComplete] ) { + sc = retrieveFromDetStore(m_completeRinj) ; + if ( sc.isFailure() ) m_dumpFlags.clear(RinjComplete) ; + } + if ( m_dumpFlags[TshaperComplete] ) { + sc = retrieveFromDetStore(m_completeTshaper) ; + if ( sc.isFailure() ) m_dumpFlags.clear(TshaperComplete) ; + } + if ( m_dumpFlags[EMEC_CphiComplete] ) { + sc = retrieveFromDetStore(m_completeEMEC_Cphi) ; + if ( sc.isFailure() ) m_dumpFlags.clear(EMEC_CphiComplete) ; + } + if ( m_dumpFlags[EMEC_HValphaComplete] ) { + sc = retrieveFromDetStore(m_completeEMEC_HValpha) ; + if ( sc.isFailure() ) m_dumpFlags.clear(EMEC_HValphaComplete) ; + } + if ( m_dumpFlags[EMEC_HVbetaComplete] ) { + sc = retrieveFromDetStore(m_completeEMEC_HVbeta) ; + if ( sc.isFailure() ) m_dumpFlags.clear(EMEC_HVbetaComplete) ; + } + if ( m_dumpFlags[CableLengthComplete] ) { + sc = retrieveFromDetStore(m_completeCableLength) ; + if ( sc.isFailure() ) m_dumpFlags.clear(CableLengthComplete) ; + } + if ( m_dumpFlags[CableAttenuationComplete] ) { + sc = retrieveFromDetStore(m_completeCableAttenuation) ; + if ( sc.isFailure() ) m_dumpFlags.clear(CableAttenuationComplete) ; + } + if ( m_dumpFlags[CaliPulseParamsVsCalib] ) { + sc = retrieveFromDetStore(m_calibCaliPulseParams) ; + if ( sc.isFailure() ) m_dumpFlags.clear(CaliPulseParamsVsCalib) ; + } + if ( m_dumpFlags[OFCBinComplete] ) { + sc = retrieveFromDetStore(m_completeOFCBin) ; + if ( sc.isFailure() ) m_dumpFlags.clear(OFCBinComplete) ; + } + + std::vector<HWIdentifier>::const_iterator chIt = m_onlineId->channel_begin() ; + std::vector<HWIdentifier>::const_iterator chItEnd = m_onlineId->channel_end() ; + for ( ; chIt != chItEnd ; chIt++ ) { + HWIdentifier chid = *chIt ; + for ( unsigned gain=0 ; (int)gain<nGains ; ++gain ) { + DumpFlags & flags = m_dump_flags_map[gain][chid] ; + flags = m_dumpFlags ; + } + } + if ( ! m_isSC ) { + std::vector<HWIdentifier>::const_iterator chCalibIt = ((LArOnlineID*)m_onlineId)->calib_channel_begin() ; + std::vector<HWIdentifier>::const_iterator chCalibItEnd = ((LArOnlineID*)m_onlineId)->calib_channel_end() ; + for ( ; chCalibIt != chCalibItEnd ; chCalibIt++ ) { + HWIdentifier chid = *chCalibIt ; + for ( unsigned gain=0 ; (int)gain<nGains ; ++gain ) { + DumpFlags & flags = m_dump_flags_map[gain][chid] ; + flags = m_dumpFlags ; + } + } + } + + } else { + + // *** scan all complete data structures to collect a map of valid channels *** + + for ( unsigned i=0 ; i<m_nClasses ; i++ ) { + if ( ! m_dumpFlags[i] ) continue ; + ATH_MSG_DEBUG(m_classNames[i] << " was selected to be dumped..."); + + switch ( i ) { + case CaliPulseParamsComplete: { + sc = scanReadoutChannels(m_completeCaliPulseParams) ; + break ; + } + case DetCellParamsComplete: { + sc = scanReadoutChannels(m_completeDetCellParams) ; + break ; + } + case PhysCaliTdiffComplete: { + sc = scanReadoutChannels(m_completePhysCaliTdiff) ; + break ; + } + case TdriftComplete: { + sc = scanReadoutChannels(m_completeTdrift) ; + break ; + } + case MphysOverMcalComplete: { + sc = scanReadoutChannels(m_completeMphysOverMcal) ; + break ; + } + case RinjComplete: { + sc = scanReadoutChannels(m_completeRinj) ; + break ; + } + case TshaperComplete: { + sc = scanReadoutChannels(m_completeTshaper) ; + break ; + } + case EMEC_CphiComplete: { + sc = scanReadoutChannels(m_completeEMEC_Cphi) ; + break ; + } + case EMEC_HValphaComplete: { + sc = scanReadoutChannels(m_completeEMEC_HValpha) ; + break ; + } + case EMEC_HVbetaComplete: { + sc = scanReadoutChannels(m_completeEMEC_HVbeta) ; + break ; + } + case CableLengthComplete: { + sc = scanReadoutChannels(m_completeCableLength) ; + break ; + } + case CableAttenuationComplete: { + sc = scanReadoutChannels(m_completeCableAttenuation) ; + break ; + } + case CaliPulseParamsVsCalib: { + sc = scanCalibChannels(m_calibCaliPulseParams) ; + break ; + } + case OFCBinComplete: { + sc = scanReadoutChannels(m_completeOFCBin) ; + break ; + } + default: + break ; + } // end switch + + } // end of the channels scan + + } + + // + // ... then fill the ntuple + // + + for ( unsigned gain=0 ; (int)gain<nGains ; gain++) { + + std::map< HWIdentifier,DumpFlags >::const_iterator map_it = m_dump_flags_map[gain].begin() ; + std::map< HWIdentifier,DumpFlags >::const_iterator map_it_e = m_dump_flags_map[gain].end() ; + + for ( ; map_it!=map_it_e ; map_it++ ) { + + HWIdentifier chid = HWIdentifier(map_it->first) ; + + const std::vector<bool> & flags = (map_it->second).flags() ; + if ( flags.size() <= 0 ) continue ; + if ( flags.size() < m_nClasses ) { // should never happen... + msg(MSG::WARNING) << "... flags vector shorter than " << m_nClasses << ": " << flags.size() << endreq ; + continue ; + } + + fillFromIdentifier(chid); //Fill common values by base-class + + if ( flags[CaliPulseParamsComplete] ) { + ntTcal = m_completeCaliPulseParams->Tcal(chid,gain) ; + ntFstep = m_completeCaliPulseParams->Fstep(chid,gain) ; + ntOffset = m_completeCaliPulseParams->Offset(chid,gain) ; + ntdTimeCal = m_completeCaliPulseParams->dTimeCal(chid,gain) ; + ntnCB = m_completeCaliPulseParams->nCB(chid,gain) ; + + } + if ( flags[DetCellParamsComplete] ) { + ntOmega0 = m_completeDetCellParams->Omega0(chid,gain) ; + ntTaur = m_completeDetCellParams->Taur(chid,gain) ; + } + if ( flags[PhysCaliTdiffComplete] ) { + ntTdiff = m_completePhysCaliTdiff->Tdiff(chid,gain) ; + } + if ( flags[TdriftComplete] ) { + ntTdrift = m_completeTdrift->Tdrift(chid) ; + } + if ( flags[MphysOverMcalComplete] ) { + ntMphysOverMcal = m_completeMphysOverMcal->MphysOverMcal(chid,gain) ; + } + if ( flags[RinjComplete] ) { + ntRinj = m_completeRinj->Rinj(chid) ; + } + if ( flags[TshaperComplete] ) { + ntTshaper = m_completeTshaper->Tshaper(chid) ; + } + if ( flags[EMEC_CphiComplete] ) { + ntEMEC_Cphi = m_completeEMEC_Cphi->EMEC_Cphi(chid) ; + } + if ( flags[EMEC_HValphaComplete] ) { + ntEMEC_HValpha = m_completeEMEC_HValpha->EMEC_HValpha(chid) ; + } + if ( flags[EMEC_HVbetaComplete] ) { + ntEMEC_HVbeta = m_completeEMEC_HVbeta->EMEC_HVbeta(chid) ; + } + if ( flags[CableLengthComplete] ) { + ntCableLength = m_completeCableLength->CableLength(chid) ; + } + if ( flags[CableAttenuationComplete] ) { + ntCableAttenuation = m_completeCableAttenuation->CableAttenuation(chid) ; + } + + if ( flags[CaliPulseParamsVsCalib] ) { + ntTcal = m_calibCaliPulseParams->Tcal(chid,gain) ; + ntFstep = m_calibCaliPulseParams->Fstep(chid,gain) ; + ntOffset = m_calibCaliPulseParams->Offset(chid,gain) ; + ntdTimeCal = m_calibCaliPulseParams->dTimeCal(chid,gain) ; + ntnCB = m_calibCaliPulseParams->nCB(chid,gain) ; + } + + if ( flags[OFCBinComplete] ) { + ntbin = m_completeOFCBin->bin(chid,gain) ; + } + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG("... record written to ntuple"); + } // end channel loop + } // end gain loop + +ATH_MSG_INFO("LArParams2Ntuple has finished."); + return StatusCode::SUCCESS; +}// end stop-method. + + +template < class DATA > +StatusCode LArParams2Ntuple::scanReadoutChannels( const DATA*& data_object ) { + + unsigned classIndex = LArParamsProperties::getClassIndex(data_object) ; + bool useGain = LArParamsProperties::isGainDependent(data_object) ; + + if ( classIndex >= m_nClasses ) { + msg(MSG::ERROR) << "Class index " << classIndex << " beyond number of known classes: " << m_nClasses << endreq ; + return StatusCode::FAILURE ; + } + + std::string detStoreKey; + if (m_detStoreJo.size() > 0 && m_detStoreJo[classIndex] != "") { + detStoreKey = m_detStoreJo[classIndex]; + ATH_MSG_VERBOSE(classIndex<<" detStoreKey = "<<detStoreKey); + } else { + detStoreKey = m_detStoreKeys[classIndex] + m_suffix ; + } + + std::string dataName = m_classNames[classIndex] ; + + if ( dataName.substr(dataName.length()-8,8) != std::string("Complete") ) { + msg(MSG::ERROR) << "Function scanReadoutChannels cannot be called for data class " << dataName << endreq ; + return StatusCode::FAILURE ; + } + + ATH_MSG_VERBOSE("Trying to retrieve " << dataName << " from detector store with key="<< detStoreKey << " ..."); + + StatusCode sc = m_detStore->retrieve(data_object,detStoreKey) ; + if ( sc == StatusCode::FAILURE ) { + ATH_MSG_VERBOSE("... failed! Trying without key ..."); + StatusCode sc = m_detStore->retrieve(data_object) ; + } + + if ( sc == StatusCode::FAILURE ) { + msg(MSG::ERROR) << "Could not retrieve " << dataName << " from detector store!" << endreq ; + return sc ; + } + + // loop through the data object and keep memory of valid items + + ATH_MSG_VERBOSE("... " << dataName << " retrieved"); + + unsigned nGains = (int)CaloGain::LARNGAIN ; + if ( ! useGain ) nGains = 1 ; // data are gain-independent + + for ( unsigned gain=0 ; gain<nGains ; gain++) { + ATH_MSG_VERBOSE("... parsing gain " << gain); + typename DATA::ConstConditionsMapIterator it = data_object->begin(gain) ; + typename DATA::ConstConditionsMapIterator it_e = data_object->end(gain) ; + for ( ; it!=it_e ; it++ ) { + HWIdentifier chid = m_onlineId->channel_Id( HWIdentifier(it.getFebId()) , it.getChannel() ) ; + ATH_MSG_VERBOSE(" ... channel " << std::hex << chid.get_compact()<< std::dec); + if ( LArParamsProperties::isValid( data_object->get(chid,gain) ) ) { + if ( useGain ) { + DumpFlags & flags = m_dump_flags_map[gain][chid] ; + flags.set(classIndex) ; + } else { + for ( unsigned g=0 ; g<3 ; g++ ) { + DumpFlags & flags = m_dump_flags_map[g][chid] ; + flags.set(classIndex) ; + } + } + } else { + ATH_MSG_VERBOSE(" (looks empty!)"); + } // endif isValid + } // end loop over channels + } // end loop over gains + return sc ; + +} + +template < class DATA > +StatusCode LArParams2Ntuple::scanCalibChannels( const DATA*& data_object ) { + + unsigned classIndex = LArParamsProperties::getClassIndex(data_object) ; + //bool useGain = LArParamsProperties::isGainDependent(data_object) ; + if ( classIndex >= m_nClasses ) { + msg(MSG::ERROR) << "Class index " << classIndex << " beyond number of known classes: " << m_nClasses << endreq ; + return StatusCode::FAILURE ; + } + + std::string detStoreKey = m_detStoreKeys[classIndex] + m_suffix ; + std::string dataName = m_classNames[classIndex] ; + + if ( dataName.substr(dataName.length()-7,7) != std::string("VsCalib") ) { + msg(MSG::ERROR) << "Function scanCalibChannels cannot be called for data class " << dataName << endreq ; + return StatusCode::FAILURE ; + } + + ATH_MSG_VERBOSE("Trying to retrieve " << dataName << " from detector store with key="<< detStoreKey << " ..."); + + StatusCode sc = m_detStore->retrieve(data_object,detStoreKey) ; + if ( sc == StatusCode::FAILURE ) { + ATH_MSG_VERBOSE("... failed! Trying without key ..."); + StatusCode sc = m_detStore->retrieve(data_object) ; + } + + if ( sc == StatusCode::FAILURE ) { + msg(MSG::ERROR) << "Could not retrieve " << dataName << " from detector store!" << endreq ; + return sc ; + } + + // loop through the data object and keep memory of valid items + + ATH_MSG_VERBOSE("... " << dataName << " retrieved"); + ATH_MSG_DEBUG(dataName << " successfully retrieved!"); + // data_object->initialize() ; + + typename DATA::Const_CB_It cb_it = data_object->begin() ; + typename DATA::Const_CB_It cb_it_e = data_object->end() ; + for ( ; cb_it!=cb_it_e ; cb_it++ ) { // loop through calibration boards + const typename DATA::CB_Tvec_pair & cb_params_set = *cb_it ; + const typename DATA::CB_Id & cb_identifier = cb_params_set.first ; + const typename DATA::T_vector & cb_params = cb_params_set.second ; + HWIdentifier cb_HWid(cb_identifier) ; + unsigned nchan = cb_params.size() ; + if (msgLvl(MSG::VERBOSE)) { + unsigned b_ec = m_onlineId->barrel_ec(cb_HWid) ; + unsigned p_n = m_onlineId->pos_neg(cb_HWid) ; + unsigned ft = m_onlineId->feedthrough(cb_HWid) ; + unsigned slot = m_onlineId->slot(cb_HWid) ; + msg(MSG::VERBOSE) << " ... B/EC=" << b_ec << " P/N=" << p_n << " FT=" << ft << " slot=" << slot + << " nchan=" << nchan << endreq ; + }//end if verbose + + for ( unsigned ichan=0 ; ichan<nchan ; ichan++ ) { // loop through channels in a CB + if ( !m_isSC ) { + HWIdentifier chid = ((LArOnlineID*)m_onlineId)->calib_channel_Id(cb_HWid , ichan) ; + ATH_MSG_VERBOSE(" ... calib channel " << chid); + if ( LArParamsProperties::isValid( data_object->get(chid) ) ) { + for ( unsigned g=0 ; g<3 ; g++ ) { + DumpFlags & flags = m_dump_flags_map[g][chid] ; + flags.set(classIndex) ; + } + } + } // end of m_isSC + } + + } // end loop over calib boards + return sc ; + +} + +template < class DATA > +StatusCode LArParams2Ntuple::retrieveFromDetStore( const DATA*& data_object ) { + // + // data_object must be a concrete object (Complete or VsCalib) + // + unsigned classIndex = LArParamsProperties::getClassIndex(data_object) ; + //bool useGain = LArParamsProperties::isGainDependent(data_object) ; + if ( classIndex >= m_nClasses ) { + msg(MSG::ERROR) << "Class index " << classIndex << " beyond number of known classes: " << m_nClasses << endreq ; + return StatusCode::FAILURE ; + } + std::string detStoreKey = m_detStoreKeys[classIndex] + m_suffix ; + std::string dataName = m_classNames[classIndex] ; + if ( m_useAbstractInterface ) { + + ATH_MSG_VERBOSE("Trying to retrieve " << dataName << " from detector store through abstract interface I" << detStoreKey << " ..."); + StatusCode sc = retrieveAbstractInterface(data_object) ; + if ( sc == StatusCode::FAILURE ) { + msg(MSG::WARNING) << "Could not retrieve " << dataName << " from detector store!" << endreq ; + return sc ; + } + + } else { + + ATH_MSG_VERBOSE("Trying to retrieve "<<dataName<<" from detector store with key="<<detStoreKey<<" ..."); + StatusCode sc = m_detStore->retrieve(data_object,detStoreKey) ; + if ( sc == StatusCode::FAILURE ) { + ATH_MSG_VERBOSE("... failed! Trying without key ..."); + StatusCode sc = m_detStore->retrieve(data_object) ; + } + if ( sc == StatusCode::FAILURE ) { + msg(MSG::WARNING) << "Could not retrieve " << dataName << " from detector store!" << endreq ; + return sc ; + } + + } + ATH_MSG_INFO(dataName << " retrieved successfully from det store"); + return StatusCode::SUCCESS ; +} + + +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArCaliPulseParamsComplete*& data_object) { + const ILArCaliPulseParams* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArCaliPulseParamsComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArCaliPulseParamsVsCalib*& data_object) { + const ILArCaliPulseParams* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArCaliPulseParamsVsCalib*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArDetCellParamsComplete*& data_object) { + const ILArDetCellParams* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArDetCellParamsComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArPhysCaliTdiffComplete*& data_object) { + const ILArPhysCaliTdiff* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArPhysCaliTdiffComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArTdriftComplete*& data_object) { + const ILArTdrift* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArTdriftComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArMphysOverMcalComplete*& data_object) { + const ILArMphysOverMcal* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArMphysOverMcalComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArRinjComplete*& data_object) { + const ILArRinj* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArRinjComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArTshaperComplete*& data_object) { + const ILArTshaper* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArTshaperComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArEMEC_CphiComplete*& data_object) { + const ILArEMEC_Cphi* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArEMEC_CphiComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArEMEC_HValphaComplete*& data_object) { + const ILArEMEC_HValpha* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArEMEC_HValphaComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArEMEC_HVbetaComplete*& data_object) { + const ILArEMEC_HVbeta* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArEMEC_HVbetaComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArCableLengthComplete*& data_object) { + const ILArCableLength* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArCableLengthComplete*>(abstract_object) ; + return sc ; +} +inline StatusCode LArParams2Ntuple::retrieveAbstractInterface(const LArCableAttenuationComplete*& data_object) { + const ILArCableAttenuation* abstract_object ; + StatusCode sc = m_detStore->retrieve(abstract_object) ; + data_object = dynamic_cast<const LArCableAttenuationComplete*>(abstract_object) ; + return sc ; +} + + +/* +void LArParams2Ntuple::dumpChannels() +{ + MsgStream log(msgSvc(), name()); + if ( m_dumpAllOnlineChannels == std::string("") ) return ; + // + FILE* f = fopen( m_dumpAllOnlineChannels.c_str() , "w" ) ; + if ( f == NULL ) { + msg(MSG::WARNING) << "Could not open file " << m_dumpAllOnlineChannels << endreq ; + msg(MSG::WARNING) << "... channels dump cannot be done!" << endreq ; + return ; + } + std::string subdet , comment , descr ; + //unsigned FT, slot, channel, b_ec, p_n ; + + std::vector<HWIdentifier>::const_iterator chIt = m_onlineId->channel_begin() ; + std::vector<HWIdentifier>::const_iterator chItEnd = m_onlineId->channel_end() ; + msg(MSG::INFO) << "Dumping online read-out channels to file " << m_dumpAllOnlineChannels << endreq; + for ( ; chIt != chItEnd ; chIt++ ) { + writeToFile(*chIt,f) ; + } + std::vector<HWIdentifier>::const_iterator chCalibIt = m_onlineId->calib_channel_begin() ; + std::vector<HWIdentifier>::const_iterator chCalibItEnd = m_onlineId->calib_channel_end() ; + msg(MSG::INFO) << "Dumping online calib channels to file " << m_dumpAllOnlineChannels << endreq; + for ( ; chCalibIt != chCalibItEnd ; chCalibIt++ ) { + writeToFile(*chCalibIt,f) ; + } + fclose(f) ; +} + +void LArParams2Ntuple::writeToFile(const HWIdentifier & ch, FILE* f) { + unsigned b_ec = m_onlineId->barrel_ec(ch) ; + unsigned p_n = m_onlineId->pos_neg(ch) ; + unsigned FT = m_onlineId->feedthrough(ch) ; + unsigned slot = m_onlineId->slot(ch) ; + unsigned channel = m_onlineId->channel(ch) ; + unsigned layer, region, ieta, iphi ; + std::string descr = m_onlineId->show_to_string(ch) ; + std::string subdet = " " ; + if ( m_onlineId->isEmBarrelOnline(ch) ) subdet = "EMB " ; + if ( m_onlineId->isEmEndcapOnline(ch) ) subdet = "EMEC" ; + if ( m_onlineId->isHecOnline(ch) ) subdet = "HEC " ; + if ( m_onlineId->isFcalOnline(ch) ) subdet = "FCAL" ; + std::string comment = " " ; + bool offlineOK = false ; + layer = region = ieta = iphi = 99999 ; + if ( m_onlineId->isCalibration(ch) ) { + comment = "Calib Line" ; + } else { + int calibLine ; + try { + Identifier id = m_larCablingSvc->cnvToIdentifier(ch); + if ( m_emId->is_lar_em(id) ) { + layer = m_emId->sampling(id) ; + region = m_emId->region(id) ; + ieta = m_emId->eta(id) ; + iphi = m_emId->phi(id) ; + offlineOK = true ; + } + const std::vector<HWIdentifier>& calibLineV = m_larCablingSvc->calibSlotLine(ch); + std::vector<HWIdentifier>::const_iterator calibLineIt = calibLineV.begin(); + if ( calibLineIt != calibLineV.end() ) { + calibLine = m_onlineId->channel(*calibLineIt); + } else { + calibLine = -2 ; // says not possible to find calib line + } + } catch ( LArID_Exception & except ) { + calibLine = -2 ; + } + char comment_cstr[11] ; + sprintf(comment_cstr,"pulse=%3.3d",calibLine) ; + comment = std::string(comment_cstr) ; + if ( offlineOK ) { + char offline_cstr[30] ; + sprintf(offline_cstr," L=%1d R=%1d eta=%3.3d phi=%3.3d",layer,region,ieta,iphi) ; + comment += std::string(offline_cstr) ; + } + } + if ( p_n == 0 ) { + subdet = "-" + subdet ; + } else { + subdet = "+" + subdet ; + } + fprintf(f, "HWId=%11.11d B/E=%2.2d P/N=%2.2d FT=%2.2d sl=%2.2d ch=%3.3d det=%5s %50s %50s\n", + ch.get_identifier32().get_compact(), b_ec, p_n, FT, slot, channel, + subdet.c_str(), comment.c_str(), descr.c_str() ) ; +} +*/ diff --git a/LArCalorimeter/LArCalibTools/src/LArParamsFromStdNtuple.cxx b/LArCalorimeter/LArCalibTools/src/LArParamsFromStdNtuple.cxx new file mode 100755 index 000000000000..8d1cf48cc128 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArParamsFromStdNtuple.cxx @@ -0,0 +1,160 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArParamsFromStdNtuple.h" + +#include "LArIdentifier/LArOnlineID.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArRawConditions/LArCaliPulseParamsComplete.h" +#include "LArRawConditions/LArDetCellParamsComplete.h" + +#include "TFile.h" +#include "TBranch.h" +#include "TTree.h" +#include "TChain.h" + +#include <vector> +#include <iostream> +#include <fstream> +#include <string> + + +LArParamsFromStdNtuple::LArParamsFromStdNtuple (const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator) +{ + declareProperty("FileNames", m_root_file_names); + declareProperty("NtupleName", m_ntuple_name="PARAMS"); + declareProperty("StoreKey_Cali", m_store_key_cali="FromStdNtuple"); + declareProperty("StoreKey_Det", m_store_key_det="FromStdNtuple"); + declareProperty("GroupingType", m_groupingType="FeedThrough"); +} + +LArParamsFromStdNtuple::~LArParamsFromStdNtuple() +{} + +StatusCode LArParamsFromStdNtuple::initialize() +{ + return StatusCode::SUCCESS ; +} + + +StatusCode LArParamsFromStdNtuple::stop() +{ + MsgStream log(msgSvc(), name()); + log << MSG::INFO << "... in stop()" << endreq ; + + // Get access to the Detector Store + StoreGateSvc* detStore; + StatusCode sc = service("DetectorStore",detStore); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + + // get LArOnlineID helper + const LArOnlineID* onlineHelper; + sc = detStore->retrieve(onlineHelper, "LArOnlineID"); + if (sc.isFailure()) { + log << MSG::ERROR << "Could not get LArOnlineID" << endreq; + return sc; + } + + TChain* outfit = new TChain(m_ntuple_name.c_str()); + for ( std::vector<std::string>::const_iterator it = m_root_file_names.begin(); + it != m_root_file_names.end(); it++ ) { + outfit->Add(it->c_str()); + } + + + Int_t channelId; + Int_t FT, slot, channel; + Double_t Tcal; + Double_t Fstep; + Double_t Offset; + Double_t dTimeCal; + Int_t nCB; + Double_t Omega0; + Double_t Taur; + + + Int_t gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2, + outfit->SetBranchAddress("channelId", &channelId); + outfit->SetBranchAddress("FT", &FT); + outfit->SetBranchAddress("slot", &slot); + outfit->SetBranchAddress("channel", &channel); + outfit->SetBranchAddress("gain", &gain); + outfit->SetBranchAddress("Tcal", &Tcal); + outfit->SetBranchAddress("Fstep", &Fstep); + outfit->SetBranchAddress("Offset", &Offset); + outfit->SetBranchAddress("dTimeCal", &dTimeCal); + outfit->SetBranchAddress("nCB", &nCB); + outfit->SetBranchAddress("Omega0", &Omega0); + outfit->SetBranchAddress("Taur", &Taur); + + // Create new objects + LArCaliPulseParamsComplete *larCaliPulseParams = new LArCaliPulseParamsComplete(); + larCaliPulseParams->setGroupingType(m_groupingType, log); + larCaliPulseParams->initialize(); + LArDetCellParamsComplete *larDetCellParams = new LArDetCellParamsComplete(); + larDetCellParams->setGroupingType(m_groupingType, log); + larDetCellParams->initialize(); + + + unsigned int hwid; + //unsigned int uflag; + // loop over entries in the Tuple, one entry = one channel + Long64_t nentries = outfit->GetEntries(); + for ( Long64_t i = 0; i < nentries; i++ ) + { + outfit->GetEvent(i); + log << MSG::INFO << " Chan " << std::hex << channelId << std::dec << endreq; + hwid = channelId; + HWIdentifier id(hwid); + if(FT != onlineHelper->feedthrough(id) || slot != onlineHelper->slot(id) || channel != onlineHelper->channel(id)) { + log << MSG::ERROR << "Inconsistency in decoding HWID !!!!" <<endreq; + log << MSG::ERROR << FT << " - " << onlineHelper->feedthrough(id) << endreq; + log << MSG::ERROR << slot << " - " << onlineHelper->slot(id) << endreq; + log << MSG::ERROR << channel << " - " << onlineHelper->channel(id) << endreq; + log << MSG::ERROR << "Not creating PhysWave !!!!" << endreq; + continue; + } + + // Add to objects + larCaliPulseParams->set(id,gain,Tcal,Fstep,Offset,dTimeCal,nCB); + larDetCellParams->set(id,gain,Omega0,Taur); + } + + + // store + sc=detStore->record(larCaliPulseParams,m_store_key_cali); + if (sc.isFailure()) { + log << MSG::FATAL << "Cannot record larCaliPulseParams to StoreGate with key = " << m_store_key_cali << endreq; + return sc; + } + + sc=detStore->record(larDetCellParams,m_store_key_det); + if (sc.isFailure()) { + log << MSG::FATAL << "Cannot record larDetCellParams to StoreGate with key = " << m_store_key_det << endreq; + return sc; + } + + // and symlink + ILArCaliPulseParams *ilarCaliPulse = NULL; + sc = detStore->symLink(larCaliPulseParams,ilarCaliPulse); + if (sc.isFailure()) { + log << MSG::FATAL << "Could not symlink ILArCaliPulseParams with LArCaliPulseParamsComplete." << endreq; + return StatusCode::FAILURE; + } + + ILArDetCellParams *ilarDetCell = NULL; + sc = detStore->symLink(larDetCellParams,ilarDetCell); + if (sc.isFailure()) { + log << MSG::FATAL << "Could not symlink ILArDetCellParams with LArDetCellParamsComplete." << endreq; + return StatusCode::FAILURE; + } + + + log << MSG::INFO << "LArParamsFromStdNtuple finalized!" << endreq; + + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArParamsProperties.cxx b/LArCalorimeter/LArCalibTools/src/LArParamsProperties.cxx new file mode 100755 index 000000000000..4e58a92011eb --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArParamsProperties.cxx @@ -0,0 +1,168 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArParamsProperties.h" + +// validity of payload data ( invalid = empty ) +//---------------------------------------------- + +bool LArParamsProperties::isValid(const LArCaliPulseParamsP & p) { return ( p.m_Tcal != ILArCaliPulseParams::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArDetCellParamsP & p) { return ( p.m_Omega0 != ILArDetCellParams::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArPhysCaliTdiffP & p) { return ( p.m_Tdiff != ILArPhysCaliTdiff::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArTdriftP & p) { return ( p.m_Tdrift != ILArTdrift::ERRORCODE ) ; } +#ifdef LARRAWCONDITIONS_LARSINGLEFLOATP +bool LArParamsProperties::isValid(const LArSingleFloatP & p) { return ( p.isEmpty());} +#endif +#ifdef LARRAWCONDITIONS_LARMPHYSOVERMCALP1 +bool LArParamsProperties::isValid(const LArMphysOverMcalP1 & p) { return ( p.m_MphysOverMcal >= 0 ) ; } +#endif +bool LArParamsProperties::isValid(const LArRinjP & p) { return ( p.m_Rinj != ILArRinj::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArTshaperP & p) { return ( p.m_Tshaper != ILArTshaper::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArEMEC_CphiP & p) { return ( p.m_EMEC_Cphi != ILArEMEC_Cphi::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArEMEC_HValphaP & p) { return ( p.m_EMEC_HValpha != ILArEMEC_HValpha::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArEMEC_HVbetaP & p) { return ( p.m_EMEC_HVbeta != ILArEMEC_HVbeta::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArCableLengthP & p) { return ( p.m_CableLength != ILArCableLength::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArCableAttenuationP & p) { return ( p.m_CableAttenuation != ILArCableAttenuation::ERRORCODE ) ; } +bool LArParamsProperties::isValid(const LArOFCBinP & p) { return ( p.m_bin != LArOFCBinP::ERRORCODE ) ; } + +// conversion: data class pointer --> class index +//------------------------------------------------ +unsigned LArParamsProperties::getClassIndex(const LArCaliPulseParamsComplete*) { return CaliPulseParamsComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArDetCellParamsComplete*) { return DetCellParamsComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArPhysCaliTdiffComplete*) { return PhysCaliTdiffComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArTdriftComplete*) { return TdriftComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArMphysOverMcalComplete*) { return MphysOverMcalComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArRinjComplete*) { return RinjComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArTshaperComplete*) { return TshaperComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArEMEC_CphiComplete*) { return EMEC_CphiComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArEMEC_HValphaComplete*) { return EMEC_HValphaComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArEMEC_HVbetaComplete*) { return EMEC_HVbetaComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArCableLengthComplete*) { return CableLengthComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArCableAttenuationComplete*) { return CableAttenuationComplete ; } +unsigned LArParamsProperties::getClassIndex(const LArCaliPulseParamsVsCalib*) { return CaliPulseParamsVsCalib ; } +unsigned LArParamsProperties::getClassIndex(const LArOFCBinComplete*) { return OFCBinComplete ; } + +// vector of class names +//----------------------- +const std::vector< std::string > & LArParamsProperties::ClassNames() +{ + static std::vector<std::string> names ; + if ( names.size() == 0 ) { + names.resize(END_OF_LIST) ; + names[CaliPulseParamsComplete] = "LArCaliPulseParamsComplete" ; + names[DetCellParamsComplete] = "LArDetCellParamsComplete" ; + names[PhysCaliTdiffComplete] = "LArPhysCaliTdiffComplete" ; + names[TdriftComplete] = "LArTdriftComplete" ; + names[MphysOverMcalComplete] = "LArMphysOverMcalComplete" ; + names[RinjComplete] = "LArRinjComplete" ; + names[TshaperComplete] = "LArTshaperComplete" ; + names[EMEC_CphiComplete] = "LArEMEC_CphiComplete" ; + names[EMEC_HValphaComplete] = "LArEMEC_HValphaComplete" ; + names[EMEC_HVbetaComplete] = "LArEMEC_HVbetaComplete" ; + names[CableLengthComplete] = "LArCableLengthComplete" ; + names[CableAttenuationComplete] = "LArCableAttenuationComplete" ; + names[CaliPulseParamsVsCalib] = "LArCaliPulseParamsVsCalib" ; + names[OFCBinComplete] = "LArOFCBinComplete" ; + names[PhysCaliTdiffComplete] = "LArPhysCaliTdiffComplete" ; + } + return names ; +} + +// number of parameters hosted in each data class +//------------------------------------------------ +unsigned LArParamsProperties::numberOfParams(unsigned index) +{ + static std::vector<unsigned> nOfPars ; + if ( nOfPars.size() == 0 ) { + nOfPars.resize(END_OF_LIST) ; + nOfPars[CaliPulseParamsComplete] = 5 ; + nOfPars[DetCellParamsComplete] = 2 ; + nOfPars[PhysCaliTdiffComplete] = 1 ; + nOfPars[TdriftComplete] = 1 ; + nOfPars[MphysOverMcalComplete] = 1 ; + nOfPars[RinjComplete] = 1 ; + nOfPars[TshaperComplete] = 1 ; + nOfPars[EMEC_CphiComplete] = 1 ; + nOfPars[EMEC_HValphaComplete] = 1 ; + nOfPars[EMEC_HVbetaComplete] = 1 ; + nOfPars[CableLengthComplete] = 1 ; + nOfPars[CableAttenuationComplete] = 1 ; + nOfPars[CaliPulseParamsVsCalib] = 5 ; + nOfPars[OFCBinComplete] = 1 ; + nOfPars[PhysCaliTdiffComplete] = 1 ; + } + if ( index < END_OF_LIST ) return nOfPars[index] ; + return 0 ; +} + +// gain dependency of data class parameters +//------------------------------------------ +bool LArParamsProperties::isGainDependent(unsigned index) +{ + static std::vector<bool> useGain ; + if ( useGain.size() == 0 ) { + useGain.resize(END_OF_LIST) ; + useGain[CaliPulseParamsComplete] = true ; + useGain[DetCellParamsComplete] = true ; + useGain[PhysCaliTdiffComplete] = true ; + useGain[TdriftComplete] = false ; + useGain[MphysOverMcalComplete] = true ; + useGain[RinjComplete] = false ; + useGain[TshaperComplete] = false ; + useGain[EMEC_CphiComplete] = false ; + useGain[EMEC_HValphaComplete] = false ; + useGain[EMEC_HVbetaComplete] = false ; + useGain[CableLengthComplete] = false ; + useGain[CableAttenuationComplete] = false ; + useGain[CaliPulseParamsVsCalib] = false ; + useGain[OFCBinComplete] = true ; + useGain[PhysCaliTdiffComplete] = true ; + } + if ( index < END_OF_LIST ) return useGain[index] ; + return false ; +} + +// getClassName : from class index and class pointer +//--------------------------------------------------- +const std::string & LArParamsProperties::getClassName(unsigned index) +{ + static std::string empty(""); + const std::vector<std::string> & names = ClassNames() ; + if ( index < names.size() ) return names[index] ; + return empty ; +} + +// get class index from class name : +//---------------------------------- +unsigned LArParamsProperties::getClassIndex(std::string className) +{ + const std::vector<std::string> & names = ClassNames() ; + unsigned N = names.size() ; + for ( unsigned i=0 ; i<N ; i++ ) { + if ( className == names[i] ) return i ; + } + return N ; +} + +// number of parameters contained in each data class +//--------------------------------------------------- +unsigned LArParamsProperties::numberOfParams(std::string className) { return numberOfParams(getClassIndex(className)) ; } + + +// gain dependance of data class +//------------------------------- +bool LArParamsProperties::isGainDependent(std::string className) { return isGainDependent(getClassIndex(className)) ; } + + +// keyword for detector store +//---------------------------- +std::string LArParamsProperties::keyword(const std::string& classname) +{ + unsigned len = classname.length() ; + if ( classname.substr(len-8,8) == std::string("Complete") ) return classname.substr(0,len-8) ; + if ( classname.substr(len-7,7) == std::string("VsCalib") ) return classname.substr(0,len-7) ; + return classname ; +} + +std::string LArParamsProperties::keyword(unsigned i) { return keyword(getClassName(i)) ; } diff --git a/LArCalorimeter/LArCalibTools/src/LArPedestals2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArPedestals2Ntuple.cxx new file mode 100755 index 000000000000..f2021203bc34 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArPedestals2Ntuple.cxx @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArPedestals2Ntuple.h" +#include "LArRawConditions/LArPedestalComplete.h" +#include "CaloIdentifier/CaloGain.h" + + +LArPedestals2Ntuple::LArPedestals2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArCond2NtupleBase(name, pSvcLocator) +{ + declareProperty("ContainerKey",m_contKey); + m_ntTitle="Pedestals"; + m_ntpath="/NTUPLES/FILE1/PEDESTALS"; + +} + +LArPedestals2Ntuple::~LArPedestals2Ntuple() +{} + +StatusCode LArPedestals2Ntuple::stop() { + StatusCode sc; + const ILArPedestal* larPedestal; + sc=m_detStore->retrieve(larPedestal,m_contKey); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Unable to retrieve ILArPedestal with key " + << m_contKey << " from DetectorStore" << endreq; + return StatusCode::FAILURE; + } + + NTuple::Item<long> cellIndex,gain; + NTuple::Item<double> ped; + NTuple::Item<double> rms; + + + sc=m_nt->addItem("icell",cellIndex,0,200000); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Cell Index' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("gain",gain,0,3); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + + sc=m_nt->addItem("ped",ped,-1000.,5000.); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'ped' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("rms",rms,0.,1e12); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'rms' failed" << endreq; + return StatusCode::FAILURE; + } + + + unsigned cellCounter=0; + for(long igain=CaloGain::LARHIGHGAIN; igain<CaloGain::LARNGAIN; igain++) { + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + if (larPedestal->pedestal(hwid,igain)>ILArPedestal::ERRORCODE) { + fillFromIdentifier(hwid); + cellIndex = cellCounter; + + ped=larPedestal->pedestal(hwid,igain); + rms=larPedestal->pedestalRMS(hwid,igain); + gain=igain; + + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }// end if Pedestal exists for this channel + cellCounter++; + }//end loop over gains + }//end loop over online ID + + (*m_log) << MSG::INFO << "LArPedestals2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LArPhysCaliTDiffAlg.cxx b/LArCalorimeter/LArCalibTools/src/LArPhysCaliTDiffAlg.cxx new file mode 100644 index 000000000000..d0088049a240 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArPhysCaliTDiffAlg.cxx @@ -0,0 +1,129 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArPhysCaliTDiffAlg.h" +#include "LArRawConditions/LArPhysCaliTdiffComplete.h" + +//#include <ifstream> +#include <fstream> + +LArPhysCaliTDiffAlg::LArPhysCaliTDiffAlg(const std::string & name, ISvcLocator * pSvcLocator) : + LArCond2NtupleBase(name,pSvcLocator) { + + declareProperty("InputContainer",m_inputContainer="LArPhysCaliTdiffIn"); + declareProperty("OutputContainer",m_outputContainer="LArPhysCaliTdiff"); + declareProperty("FileName",m_fileName); + return; +} + +LArPhysCaliTDiffAlg::~LArPhysCaliTDiffAlg() {} + + +StatusCode LArPhysCaliTDiffAlg::initialize() { + + m_ntTitle="TimeDiffs"; + m_ntpath=std::string("/NTUPLES/FILE1/TIMEDIFF"); + return LArCond2NtupleBase::initialize(); +} + +StatusCode LArPhysCaliTDiffAlg::execute() { + + + NTuple::Item<float> ntold, ntnew, ntoffset, ntcorr; + NTuple::Item<long> ntgain; + + m_nt->addItem("gain",ntgain,0,3).ignore(); + m_nt->addItem("PCDiffOld",ntold,0,200).ignore(); + m_nt->addItem("PCDiffNew",ntnew,0,200).ignore(); + //m_nt->addItem("T0",ntT0,0,2000).ignore(); + m_nt->addItem("offset",ntoffset,0,200).ignore(); + m_nt->addItem("correction",ntcorr,0,200).ignore(); + + + const LArOnlineID* onlineID=0; + if (detStore()->retrieve(onlineID).isFailure()) { + msg(MSG::ERROR) << "Failed to retreive online helper" << endreq; + return StatusCode::FAILURE; + } + + + std::vector<std::map<HWIdentifier,float> > offsetMap; + offsetMap.resize(3); + std::ifstream rein(m_fileName.c_str(),std::ifstream::in); + if (!rein.good()) { + msg(MSG::ERROR) << "Failed to open file " << m_fileName << endreq; + return StatusCode::SUCCESS; + } + + + while (rein.good()) { + unsigned gain,chidint; + float offset; + rein >> chidint >> gain >> offset; + //std::cout << gain << " " << chidint << " " << offset << std::endl; + const HWIdentifier fid(chidint); + offsetMap[gain][fid]=offset; + } + + rein.close(); + + + const LArPhysCaliTdiffComplete* oldCont=0; + if (detStore()->retrieve(oldCont,m_inputContainer).isFailure()) { + msg(MSG::ERROR) << "Failed to retrieve LArPhysCaliTdiffComplete with key " << m_inputContainer << endreq; + return StatusCode::FAILURE; + } + + LArPhysCaliTdiffComplete* newCont=new LArPhysCaliTdiffComplete(); + newCont->setGroupingType(LArConditionsContainerBase::ExtendedSubDetGrouping); + newCont->initialize(); + if(detStore()->record(newCont,m_outputContainer).isFailure()) { + msg(MSG::ERROR) << "Failed to register container with key " << m_outputContainer << " to StoreGate" << endreq; + } + + for (int gain=0;gain<3;++gain) { + msg(MSG::INFO) << "Working on gain " << gain << endreq; + LArPhysCaliTdiffComplete::ConstConditionsMapIterator it=oldCont->begin(gain); + LArPhysCaliTdiffComplete::ConstConditionsMapIterator it_e=oldCont->end(gain); + for (;it!=it_e;++it) { + const HWIdentifier chid=it.channelId(); + const HWIdentifier fid=onlineID->feb_Id(chid); + const LArPhysCaliTdiffP& td=*it; + if (td.isEmpty()) { + ATH_MSG_DEBUG("Channel " << onlineID->channel_name(chid) << " has no data"); + continue; + } + float timediff=td.m_Tdiff; + ntold=timediff; + ntoffset=offsetMap[gain][fid]; + int refGain=0; + if (onlineID->isHECchannel(chid)) + refGain=1; + + if (gain>refGain) { + ntcorr=offsetMap[gain][fid]-offsetMap[refGain][fid]; + const float correction=offsetMap[gain][fid]-offsetMap[refGain][fid]; + timediff+=correction; + } + else + ntcorr=-999; + newCont->set(chid,gain,timediff); + ntnew=timediff; + fillFromIdentifier(chid); + ntgain=gain; + ATH_MSG_DEBUG("Gain " << gain << " Ch:" << onlineID->channel_name(chid) << ":" << td.m_Tdiff << " -> " << timediff); + + + StatusCode sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + + }//end loop over all channels + }//end loop over gains + + + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArPhysWaveFromStdNtuple.cxx b/LArCalorimeter/LArCalibTools/src/LArPhysWaveFromStdNtuple.cxx new file mode 100755 index 000000000000..b6a577abf5d4 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArPhysWaveFromStdNtuple.cxx @@ -0,0 +1,164 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArPhysWaveFromStdNtuple.h" + +#include "LArIdentifier/LArOnlineID.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArRawConditions/LArPhysWave.h" +#include "LArRawConditions/LArPhysWaveContainer.h" + +#include "TFile.h" +#include "TBranch.h" +#include "TTree.h" +#include "TChain.h" + +#include <vector> +#include <iostream> +#include <fstream> +#include <string> + + +LArPhysWaveFromStdNtuple::LArPhysWaveFromStdNtuple (const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator) +{ + declareProperty("SkipPoints", m_skipPoints = 0); + declareProperty("PrefixPoints", m_prefixPoints = 0); + declareProperty("FileNames", m_root_file_names); + declareProperty("NtupleName", m_ntuple_name="PhysWave"); + declareProperty("StoreKey", m_store_key="FromStdNtuple"); + declareProperty("GroupingType", m_groupingType="FeedThrough"); +} + +LArPhysWaveFromStdNtuple::~LArPhysWaveFromStdNtuple() +{} + +StatusCode LArPhysWaveFromStdNtuple::initialize() +{ + return StatusCode::SUCCESS ; +} + + +StatusCode LArPhysWaveFromStdNtuple::stop() +{ + MsgStream log(msgSvc(), name()); + log << MSG::INFO << "... in stop()" << endreq ; + + // Get access to the Detector Store + StoreGateSvc* detStore; + StatusCode sc = service("DetectorStore",detStore); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + + // get LArOnlineID helper + const LArOnlineID* onlineHelper; + sc = detStore->retrieve(onlineHelper, "LArOnlineID"); + if (sc.isFailure()) { + log << MSG::ERROR << "Could not get LArOnlineID" << endreq; + return sc; + } + + TChain* outfit = new TChain(m_ntuple_name.c_str()); + for ( std::vector<std::string>::const_iterator it = m_root_file_names.begin(); + it != m_root_file_names.end(); it++ ) { + outfit->Add(it->c_str()); + } + + + Int_t timeIndex; + Int_t flag; + Double_t Dt; + Double_t timeOffset; + Int_t channelId; + Int_t FT, slot, channel; + + Double_t Amplitude[2000]; // The function + Double_t Error[2000]; // The function + Int_t Triggers[2000]; // The function + Int_t gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2, + outfit->SetBranchAddress("channelId", &channelId); + outfit->SetBranchAddress("FT", &FT); + outfit->SetBranchAddress("slot", &slot); + outfit->SetBranchAddress("channel", &channel); + outfit->SetBranchAddress("timeIndex", &timeIndex); + outfit->SetBranchAddress("Dt", &Dt); + outfit->SetBranchAddress("timeOffset", &timeOffset); + outfit->SetBranchAddress("flag", &flag); + outfit->SetBranchAddress("gain", &gain); + outfit->SetBranchAddress("Amplitude", Amplitude); + outfit->SetBranchAddress("Error", Error); + outfit->SetBranchAddress("Triggers", Triggers); + + // Create new LArPhysWaveContainer + LArPhysWaveContainer* larPhysWaveContainerNew = new LArPhysWaveContainer(); + larPhysWaveContainerNew->setGroupingType(m_groupingType, log); + larPhysWaveContainerNew->initialize(); + + unsigned int hwid; + unsigned int uflag; + // loop over entries in the Tuple, one entry = one channel + Long64_t nentries = outfit->GetEntries(); + for ( Long64_t i = 0; i < nentries; i++ ) + { + outfit->GetEvent(i); + log << MSG::INFO << " Chan " << std::hex << channelId << std::dec << endreq; + hwid = channelId; + HWIdentifier id(hwid); + if(FT != onlineHelper->feedthrough(id) || slot != onlineHelper->slot(id) || channel != onlineHelper->channel(id)) { + log << MSG::ERROR << "Inconsistency in decoding HWID !!!!" <<endreq; + log << MSG::ERROR << FT << " - " << onlineHelper->feedthrough(id) << endreq; + log << MSG::ERROR << slot << " - " << onlineHelper->slot(id) << endreq; + log << MSG::ERROR << channel << " - " << onlineHelper->channel(id) << endreq; + log << MSG::ERROR << "Not creating PhysWave !!!!" << endreq; + continue; + } + + // Catch potential array index out of range error. + if ( timeIndex >= 2000 ) { + log << MSG::ERROR << " Too many points specified vs the expected content of the ntuple ! " << endreq; + log << MSG::ERROR << "Not creating PhysWave !!!!" << endreq; + continue; + } + std::vector<double> wave(timeIndex); + std::vector<double> wave_err(timeIndex); + std::vector<int> wave_trig(timeIndex); + for ( int i = 0; i < timeIndex; i++ ) { + wave[i]=0.; + wave_err[i]=0.; + wave_trig[i]=0.; + } + unsigned int skipped = 0; + unsigned int limit = timeIndex; + if ( m_skipPoints < m_prefixPoints ) limit = timeIndex+m_skipPoints-m_prefixPoints; + for ( unsigned int i = 0; i < limit; i++ ) + { + if ( skipped >= m_skipPoints ) + { + wave[i-m_skipPoints+m_prefixPoints]=Amplitude[i]; + wave_err[i-m_skipPoints+m_prefixPoints]=Error[i]; + wave_trig[i-m_skipPoints+m_prefixPoints]=Triggers[i]; + } + else skipped++; + } + + uflag = flag; + LArPhysWave newLArPhysWave(wave, wave_err, wave_trig, Dt, timeOffset, uflag); + + // Add physics wave to container + larPhysWaveContainerNew->setPdata(id, newLArPhysWave, (CaloGain::CaloGain)gain); + } + + + // store + sc=detStore->record(larPhysWaveContainerNew,m_store_key); + if (sc.isFailure()) { + log << MSG::FATAL << "Cannot record LArPhysWaveContainer to StoreGate with key = " << m_store_key << endreq; + return sc; + } + + log << MSG::INFO << "LArPhysWaveFromStdNtuple finalized!" << endreq; + + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArPhysWaveFromTuple.cxx b/LArCalorimeter/LArCalibTools/src/LArPhysWaveFromTuple.cxx new file mode 100755 index 000000000000..cac89b9a43fe --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArPhysWaveFromTuple.cxx @@ -0,0 +1,151 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArPhysWaveFromTuple.h" + +#include "LArIdentifier/LArOnlineID.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArRawConditions/LArPhysWave.h" +#include "LArRawConditions/LArPhysWaveContainer.h" + +#include "TFile.h" +#include "TBranch.h" +#include "TTree.h" +#include "TChain.h" + +#include <vector> +#include <iostream> +#include <fstream> +#include <string> + + +LArPhysWaveFromTuple::LArPhysWaveFromTuple (const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator) +{ + declareProperty("NPoints", m_NPoints = 800); + declareProperty("SkipPoints", m_skipPoints = 0); + declareProperty("PrefixPoints", m_prefixPoints = 0); + declareProperty("deltaT", m_deltaT = 1.04e-9); + declareProperty("LArWaveFlag", m_flag = 20); + declareProperty("FileNames", m_root_file_names); + declareProperty("StoreKey", m_store_key="FROMTUPLE"); + declareProperty("GroupingType", m_groupingType="FeedThrough"); +} + +LArPhysWaveFromTuple::~LArPhysWaveFromTuple() +{} + +StatusCode LArPhysWaveFromTuple::initialize() +{ + return StatusCode::SUCCESS ; +} + + +StatusCode LArPhysWaveFromTuple::stop() +{ + MsgStream log(msgSvc(), name()); + log << MSG::INFO << "... in finalize()" << endreq ; + + // Get access to the Detector Store + StoreGateSvc* detStore; + StatusCode sc = service("DetectorStore",detStore); + if (sc!=StatusCode::SUCCESS) { + log << MSG::ERROR << "Cannot get DetectorStore!" << endreq; + return sc; + } + + // get LArOnlineID helper + const LArOnlineID* onlineHelper; + sc = detStore->retrieve(onlineHelper, "LArOnlineID"); + if (sc.isFailure()) { + log << MSG::ERROR << "Could not get LArOnlineID" << endreq; + return sc; + } + + TChain* outfit = new TChain("outfit"); + for ( std::vector<std::string>::const_iterator it = m_root_file_names.begin(); + it != m_root_file_names.end(); it++ ) { + outfit->Add(it->c_str()); + } + + // This algorithm assumes the input NTuple in contains less than 2000 + // points. If the NTuple contains less than 2000 points, the + // remaining points are automatically initialized to 0. + // Catch potential array index out of range error. + if ( m_NPoints > 2000 ) { + log << MSG::ERROR << " Too many points specified vs the expected content of the ntuple ! " << endreq; + return StatusCode::FAILURE; + } + + // variable names as in the Ntuple + Int_t BarEC; // 0 = Barrel 1 = EndCap + Int_t Side; // 0 = side C 1 = side A + Int_t FT; // feedthrough 0 - 31 + Int_t Channel; // 0 - 127 + Int_t Slot; // 1 -14 + Double_t tphys[2000]; // The function + Int_t gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2, + outfit->SetBranchAddress("Channel", &Channel); + outfit->SetBranchAddress("Slot", &Slot); + outfit->SetBranchAddress("FT", &FT); + if(outfit->FindBranch("BarAC")){ // Handle changed naming scheme + log << MSG::INFO << "'Side' is prefered branch name to 'BarAC'." << endreq; + outfit->SetBranchAddress("BarAC", &Side); + } else { + outfit->SetBranchAddress("Side", &Side); + } + if(!outfit->FindBranch("BarEC")){ // Handle + log << MSG::INFO << "'BarEC' branch not found. Assuming barrel data." << endreq; + BarEC = 0; + } else { + outfit->SetBranchAddress("BarEC", &BarEC); + } + outfit->SetBranchAddress("Gain", &gain); + outfit->SetBranchAddress("tphys", tphys); + + // Create new LArPhysWaveContainer + LArPhysWaveContainer* larPhysWaveContainerNew = new LArPhysWaveContainer(); + larPhysWaveContainerNew->setGroupingType(m_groupingType, log); + larPhysWaveContainerNew->initialize(); + + // loop over entries in the Tuple, one entry = one channel + Long64_t nentries = outfit->GetEntries(); + for ( Long64_t i = 0; i < nentries; i++ ) + { + outfit->GetEvent(i); + log << MSG::INFO << BarEC << " Side " << Side << " FT " << FT << " slot " << Slot << " Chan " << Channel << endreq; + HWIdentifier id = onlineHelper->channel_Id(BarEC, Side, FT, Slot, Channel); + log << MSG::INFO << std::hex << id << std::dec << endreq; + + std::vector<double> wave(m_NPoints); + for ( unsigned int i = 0; i < m_NPoints; i++ ) wave[i]=0.; + unsigned int skipped = 0; + unsigned int limit = m_NPoints; + if ( m_skipPoints < m_prefixPoints ) limit = m_NPoints+m_skipPoints-m_prefixPoints; + for ( unsigned int i = 0; i < limit; i++ ) + { + if ( skipped >= m_skipPoints ) + { + wave[i-m_skipPoints+m_prefixPoints]=tphys[i]; + } + else skipped++; + } + + LArPhysWave newLArPhysWave(wave, m_deltaT, m_flag); + + // Add physics wave to container + larPhysWaveContainerNew->setPdata(id, newLArPhysWave, (CaloGain::CaloGain)gain); + } + + + // store + sc=detStore->record(larPhysWaveContainerNew,m_store_key); + if (sc.isFailure()) { + log << MSG::FATAL << "Cannot record LArPhysWaveContainer to StoreGate with key = " << m_store_key << endreq; + return sc; + } + + log << MSG::INFO << "LArPhysWaveFromTuple finalized!" << endreq; + + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCalibTools/src/LArPhysWaves2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArPhysWaves2Ntuple.cxx new file mode 100644 index 000000000000..93ec14034973 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArPhysWaves2Ntuple.cxx @@ -0,0 +1,131 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArPhysWaves2Ntuple.h" +#include "CaloIdentifier/CaloGain.h" + + +LArPhysWaves2Ntuple::LArPhysWaves2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArWaves2Ntuple(name, pSvcLocator) +{ + m_keylist.clear() ; + declareProperty("KeyList", m_keylist); + declareProperty("NtupleName", m_ntName); + declareProperty("AddCorrUndo", m_addCorrUndo=true); + declareProperty("ApplyCorrection",m_applyCorr=false); +} + +LArPhysWaves2Ntuple::~LArPhysWaves2Ntuple() +{} + + +StatusCode LArPhysWaves2Ntuple::initialize() { + m_ntTitle="Calibration Wave"; + m_ntpath=std::string("/NTUPLES/FILE1/")+m_ntName; + return LArWaves2Ntuple::initialize(); +} + + +StatusCode LArPhysWaves2Ntuple::stop() +{ + + StatusCode sc; + + sc=m_nt->addItem("gain",m_gain,0,3); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("timeOffset",m_timeOffset,0.,100.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'timeOffset' failed" << endreq; + return StatusCode::FAILURE; + } + + + if (m_addCorrUndo) { + sc=m_nt->addItem("corrUndo",m_corrUndo,0,1); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'corrUndo' failed" << endreq; + return StatusCode::FAILURE; + } + } + + for ( unsigned k=0 ; k<m_keylist.size() ; k++ ) { + const std::string& key = m_keylist[k] ; + + + (*m_log) << MSG::INFO << "Processing WaveContainer from StoreGate! key=" << m_keylist[k] << endreq; + const LArPhysWaveContainer* physWaveContainer; + LArPhysWaveContainer* physWaveContainer_nc; + StatusCode sc; + if (m_applyCorr) { + sc = m_detStore->retrieve(physWaveContainer_nc,key); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Cannot read non-const LArPhysWaveContainer from StoreGate! key=" << key << endreq; + (*m_log) << MSG::ERROR << "The ApplyCorrection option works only for non-const containers!" << endreq; + return sc; + } + else + (*m_log) << MSG::INFO << "Read non-const LArPhysWaveContainer from StoreGate! key= " << key << endreq; + + if (!physWaveContainer_nc->correctionsApplied()) { + sc=physWaveContainer_nc->applyCorrections(); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Failed to apply corrections to LArPhysWaveContainer!" << endreq; + } + } + physWaveContainer=physWaveContainer_nc; + } + else { + sc = m_detStore->retrieve(physWaveContainer,key); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Cannot read LArPhysWaveContainer from StoreGate! key=" << key << endreq; + return StatusCode::FAILURE; + } else + (*m_log) << MSG::INFO << "Read const LArPhysWaveContainer from StoreGate! key= " << key << endreq; + } + + for (unsigned igain=CaloGain::LARHIGHGAIN;igain<CaloGain::LARNGAIN ;++igain){ + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier chid = *itOnId; + m_gain=(long)igain; + const LArPhysWave& wave=physWaveContainer->get(chid,igain); + if (wave.isEmpty()) continue; + if (m_addCorrUndo) m_corrUndo=0; + fillWave(chid,wave); //Fill method from base-class + m_timeOffset = wave.getTimeOffset(); + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return sc; + } + }//end loop over identifiers + }//end loop over gains + + if (m_addCorrUndo) { + for (unsigned igain=CaloGain::LARHIGHGAIN;igain<CaloGain::LARNGAIN ;++igain) { + LArPhysWaveContainer::ConstCorrectionIt itUndo=physWaveContainer->undoCorrBegin(igain); + LArPhysWaveContainer::ConstCorrectionIt itUndo_e=physWaveContainer->undoCorrEnd(igain); + for(;itUndo!=itUndo_e;itUndo++) { + const HWIdentifier chid(itUndo->first); + const LArPhysWave& wave = itUndo->second; + m_gain = (long)igain; + m_corrUndo = 1; + fillWave(chid,wave); //Fill method from base-class + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return sc; + } + }//end loop over corrections + }//end loop over gain + }//end if addCorrUndo + }//end loop over container keys + (*m_log) << MSG::INFO << "LArWave2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +} // end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LArRamps2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArRamps2Ntuple.cxx new file mode 100755 index 000000000000..90edff277e6d --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArRamps2Ntuple.cxx @@ -0,0 +1,451 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArRamps2Ntuple.h" +#include "LArRawConditions/LArRawRampContainer.h" +#include "LArRawConditions/LArRampComplete.h" +#include "LArRawConditions/LArRampMC.h" + +//#include "CaloIdentifier/CaloIdManager.h" + +#include <math.h> + +LArRamps2Ntuple::LArRamps2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArCond2NtupleBase(name, pSvcLocator) +{ + declareProperty("ContainerKey", m_contKey, + "List of keys of RawRamp containers"); + declareProperty("RampKey", m_rampKey="LArRamp", + "Key of LArRampComplete or LArRampMC objects"); + declareProperty("NtupleName", m_ntName ="RAMPS"); + declareProperty("RawRamp", m_rawRamp = false); + declareProperty("SaveAllSamples", m_saveAllSamples = false); + declareProperty("ApplyCorr", m_applyCorr=false); + declareProperty("AddCorrUndo", m_addCorrUndo=true); + declareProperty("IsMC", m_isMC=false); +} + +StatusCode LArRamps2Ntuple::initialize() { + m_ntTitle="Ramps"; + m_ntpath=std::string("/NTUPLES/FILE1/")+m_ntName; + return LArCond2NtupleBase::initialize(); +} + + +LArRamps2Ntuple::~LArRamps2Ntuple() +{} + +StatusCode LArRamps2Ntuple::stop() { + bool hasRawRampContainer=false; + StatusCode sc; + NTuple::Item<long> cellIndex; + NTuple::Item<long> gain; + NTuple::Item<long> corrUndo; + NTuple::Array<float> SampleMax; + NTuple::Array<float> TimeMax; + NTuple::Array<float> DAC; + NTuple::Array<float> ADC; + NTuple::Array<long> NTriggers; + + // individual samples. Very dirty :-( + NTuple::Array<float> Sample0; + NTuple::Array<float> Sample1; + NTuple::Array<float> Sample2; + NTuple::Array<float> Sample3; + NTuple::Array<float> Sample4; + NTuple::Array<float> Sample5; + NTuple::Array<float> Sample6; + + // idem for RMS + NTuple::Array<float> RMS0; + NTuple::Array<float> RMS1; + NTuple::Array<float> RMS2; + NTuple::Array<float> RMS3; + NTuple::Array<float> RMS4; + NTuple::Array<float> RMS5; + NTuple::Array<float> RMS6; + + NTuple::Item<unsigned long> DACIndex; + NTuple::Array<float> coeffs; + NTuple::Item<unsigned long> coeffIndex; + + NTuple::Item<float> RampRMS; + + if (m_rawRamp && m_contKey.size() > 0) { + //Retrieve Raw Ramp Container + std::vector<std::string>::const_iterator key_it=m_contKey.begin(); + std::vector<std::string>::const_iterator key_it_e=m_contKey.end(); + for (;key_it!=key_it_e;key_it++) { + LArRawRampContainer* rawRampContainer=NULL; + sc=m_detStore->retrieve(rawRampContainer,*key_it); + if (sc!=StatusCode::SUCCESS || !rawRampContainer) { + (*m_log) << MSG::WARNING << "Unable to retrieve LArRawRampContainer with key " << *key_it << endreq; + } + else { + (*m_log) << MSG::DEBUG << "Got LArRawRampContainer with key " << *key_it << endreq; + hasRawRampContainer = true; + } + } + if (!hasRawRampContainer) (*m_log) << MSG::WARNING << " No LArRawRampContainer found. Only fitted ramp in ntuple " << endreq; + + } + //end-if m_rawRamp + + const ILArRamp* ramp=NULL; + sc=m_detStore->retrieve(ramp,m_rampKey); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::WARNING << "Unable to retrieve ILArRamp with key: "<<m_rampKey << " from DetectorStore" << endreq; + } + + if (!ramp && !hasRawRampContainer) { + (*m_log) << MSG::ERROR << "Have neither Raw Ramp nor Fitted Ramp. No Ntuple produced." << endreq; + return StatusCode::FAILURE; + } + + LArConditionsContainer<LArRampP1>* myramp = NULL; + if(m_applyCorr) { + if(dynamic_cast<const LArRampComplete*>(ramp)) myramp=(LArConditionsContainer<LArRampP1>*) ramp; + if( myramp) { + sc = myramp->applyCorrections(); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Applying corrections failed" << endreq; + } + } + } + + + sc=m_nt->addItem("cellIndex",cellIndex,0,2000); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Cell Index' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("gain",gain,0,3); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + if (m_addCorrUndo) { + sc=m_nt->addItem("corrUndo",corrUndo,0,1); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'corrUndo' failed" << endreq; + return StatusCode::FAILURE; + } + } + + if (hasRawRampContainer) + { + sc=m_nt->addItem("DACIndex",DACIndex,0,800); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'DACIndex' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("SampleMax",DACIndex,SampleMax); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'SampleMax' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("TimeMax",DACIndex,TimeMax); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'TimeMax' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("ADC",DACIndex,ADC); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'ADC' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("DAC",DACIndex,DAC); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'DAC' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("NTriggers",DACIndex,NTriggers); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'NTriggers' failed" << endreq; + return StatusCode::FAILURE; + } + + if(m_saveAllSamples){ + sc=m_nt->addItem("Sample0",DACIndex,Sample0); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Sample0' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Sample1",DACIndex,Sample1); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Sample1' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Sample2",DACIndex,Sample2); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Sample2' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Sample3",DACIndex,Sample3); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Sample3' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Sample4",DACIndex,Sample4); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Sample4' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Sample5",DACIndex,Sample5); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Sample5' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Sample6",DACIndex,Sample6); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Sample6' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("RMS0",DACIndex,RMS0); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'RMS0' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("RMS1",DACIndex,RMS1); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'RMS1' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("RMS2",DACIndex,RMS2); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'RMS2' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("RMS3",DACIndex,RMS3); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'RMS3' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("RMS4",DACIndex,RMS4); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'RMS4' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("RMS5",DACIndex,RMS5); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'RMS5' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("RMS6",DACIndex,RMS6); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'RMS6' failed" << endreq; + return StatusCode::FAILURE; + } + }// end-if Save all samples + }//end if rawRampContainer + + //if (rampComplete || rampMC) { + if (ramp) { + sc=m_nt->addItem("Xi",coeffIndex,0,7); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'coeffIndex' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("X",coeffIndex,coeffs); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'coeff' failed" << endreq; + return StatusCode::FAILURE; + } + + if (hasRawRampContainer) { //== RampComplete && RawRamp + sc=m_nt->addItem("RampRMS",RampRMS,-1000,1000); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'RampRMS' failed" << endreq; + return StatusCode::FAILURE; + } + } + }//end-if rampComplete + + + + unsigned cellCounter=0; + if (hasRawRampContainer) { //Loop over raw ramp container and fill ntuple + + //Retrieve Raw Ramp Container + std::vector<std::string>::const_iterator key_it=m_contKey.begin(); + std::vector<std::string>::const_iterator key_it_e=m_contKey.end(); + for (;key_it!=key_it_e;key_it++) { + LArRawRampContainer* rawRampContainer=NULL; + sc=m_detStore->retrieve(rawRampContainer,*key_it); + if (sc!=StatusCode::SUCCESS || !rawRampContainer) { + (*m_log) << MSG::WARNING << "Unable to retrieve LArRawRampContainer with key " << *key_it << endreq; + continue; + } + LArRawRampContainer::const_iterator cont_it=rawRampContainer->begin(); + LArRawRampContainer::const_iterator cont_it_e=rawRampContainer->end(); + for (;cont_it!=cont_it_e;cont_it++) { + const std::vector<LArRawRamp::RAMPPOINT_t>& singleRamp=(*cont_it)->theRamp(); + + for (DACIndex=0;DACIndex<singleRamp.size();DACIndex++) { + + SampleMax[DACIndex] = singleRamp[DACIndex].iMaxSample; + TimeMax[DACIndex] = singleRamp[DACIndex].TimeMax; + ADC[DACIndex] = singleRamp[DACIndex].ADC; + NTriggers[DACIndex] = singleRamp[DACIndex].NTriggers; + DAC[DACIndex] = singleRamp[DACIndex].DAC; + + if(m_saveAllSamples){ + + if ( !singleRamp[DACIndex].Samples.size() || !singleRamp[DACIndex].RMS.size() ) { + (*m_log) << MSG::WARNING << "Cannot save all samples, vector empty" << endreq; + } else { + + Sample0[DACIndex]=singleRamp[DACIndex].Samples[0]; + Sample1[DACIndex]=singleRamp[DACIndex].Samples[1]; + Sample2[DACIndex]=singleRamp[DACIndex].Samples[2]; + Sample3[DACIndex]=singleRamp[DACIndex].Samples[3]; + Sample4[DACIndex]=singleRamp[DACIndex].Samples[4]; + if(singleRamp[DACIndex].Samples.size()>5) Sample5[DACIndex]=singleRamp[DACIndex].Samples[5]; + if(singleRamp[DACIndex].Samples.size()>6) Sample6[DACIndex]=singleRamp[DACIndex].Samples[6]; + + RMS0[DACIndex]=singleRamp[DACIndex].RMS[0]; + RMS1[DACIndex]=singleRamp[DACIndex].RMS[1]; + RMS2[DACIndex]=singleRamp[DACIndex].RMS[2]; + RMS3[DACIndex]=singleRamp[DACIndex].RMS[3]; + RMS4[DACIndex]=singleRamp[DACIndex].RMS[4]; + if(singleRamp[DACIndex].RMS.size()>5) RMS5[DACIndex]=singleRamp[DACIndex].RMS[5]; + if(singleRamp[DACIndex].RMS.size()>6) RMS6[DACIndex]=singleRamp[DACIndex].RMS[6]; + } + } + + } + + HWIdentifier chid=(*cont_it)->channelID(); + unsigned igain = (unsigned)(*cont_it)->gain(); + gain = igain; + if (m_addCorrUndo) corrUndo=0; + if (ramp && m_larCablingSvc->isOnlineConnected(chid)) { + + //FT move to here + fillFromIdentifier(chid); + + unsigned nDAC=0; + unsigned nCoeff=0; + const ILArRamp::RampRef_t rampcoeff = ramp->ADC2DAC(chid,igain); + if (rampcoeff.size()==0) { + (*m_log) << MSG::WARNING << "Can't get fitted Ramp slot=" << static_cast<long>(m_slot) << + " channel=" << static_cast<long>(m_channel) << " gain=" << igain << endreq; + } + for (coeffIndex=0;coeffIndex<rampcoeff.size();coeffIndex++) coeffs[coeffIndex]=rampcoeff[coeffIndex]; + nDAC = singleRamp.size(); + nCoeff = rampcoeff.size(); + + if (nDAC>1 && nCoeff>0) { + + double rampDev=0; + for (unsigned iDAC=1;iDAC<nDAC;iDAC++) { + double fittedResult=0; + for (unsigned icoeff=0;icoeff<nCoeff;icoeff++) + fittedResult+=coeffs[icoeff]*pow(ADC[iDAC],icoeff); + rampDev+=(fittedResult-DAC[iDAC])*(fittedResult-DAC[iDAC]); + }//end loop over DAC values + RampRMS=1./(nDAC-1)*sqrt(rampDev); + }//end if nDAC>0 && nCoeff>0 + else + RampRMS=-999; + + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + + }//end if rampComplete or rampMC + + cellCounter++; + + }//end loop over container + } // loop over gains + } else {//have only fitted ramp + + //Iterate over gains and cells + for ( unsigned igain=CaloGain::LARHIGHGAIN; + igain<CaloGain::LARNGAIN ; ++igain ) { + std::vector<HWIdentifier>::const_iterator it = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator it_e = m_onlineId->channel_end(); + for (;it!=it_e;it++) { + const HWIdentifier chid=*it; + if (m_larCablingSvc->isOnlineConnected(chid)) { + gain = (long)igain; + if (m_addCorrUndo) corrUndo = 0; + const ILArRamp::RampRef_t rampcoeff=ramp->ADC2DAC(chid, gain); + if (rampcoeff.size()==0) continue; // No ramp for this cell + cellIndex = cellCounter; + fillFromIdentifier(chid); + for (coeffIndex=0;coeffIndex<rampcoeff.size();coeffIndex++) coeffs[coeffIndex]=rampcoeff[coeffIndex]; + + sc=ntupleSvc()->writeRecord(m_nt); + + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }// end if isConnected + cellCounter++; + }//end loop over cells + }//end loop over gains + + } //end else have only fitted ramp + + //if ((rampComplete||rampMC) && m_addCorrUndo) { + if (ramp && m_addCorrUndo) { + //Now loop over undoCorrections: + for ( unsigned igain=CaloGain::LARHIGHGAIN; + igain<CaloGain::LARNGAIN ; ++igain ) { + LArRampComplete::ConstCorrectionIt itUndo,itUndo_e; + itUndo_e = itUndo; + const LArRampComplete *rampComplete=dynamic_cast<const LArRampComplete *>(ramp); + if(rampComplete) { + itUndo = rampComplete->undoCorrBegin(igain); + itUndo_e=rampComplete->undoCorrEnd(igain); + + for(;itUndo!=itUndo_e;itUndo++) { + const HWIdentifier chid(itUndo->first); + gain = (long)igain; + corrUndo = 1; + const std::vector<float>& rampcoeff=itUndo->second.m_vRamp; + if (rampcoeff.size()==0) + continue; // No ramp for this cell + + cellIndex = cellCounter; + fillFromIdentifier(chid); + + for (coeffIndex=0;coeffIndex<rampcoeff.size();coeffIndex++) + coeffs[coeffIndex]=rampcoeff[coeffIndex]; + + sc=ntupleSvc()->writeRecord(m_nt); + + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end loop over cells + } + }//end loop over gains + }//end if add corrections + + if(m_applyCorr && myramp) { + sc = myramp->undoCorrections(); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Undo corrections failed" << endreq; + } + } + + + (*m_log) << MSG::INFO << "LArRamps2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; + +} // end finalize-method. diff --git a/LArCalorimeter/LArCalibTools/src/LArShape2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArShape2Ntuple.cxx new file mode 100644 index 000000000000..af5c14e39e8c --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArShape2Ntuple.cxx @@ -0,0 +1,196 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArShape2Ntuple.h" +#include "LArRawConditions/LArShapeComplete.h" +#include "LArRawConditions/LArShape32MC.h" +#include "LArCOOLConditions/LArShapeFlat.h" +#include "LArCOOLConditions/LArShapeSC.h" +#include "CaloIdentifier/CaloGain.h" + +LArShape2Ntuple::LArShape2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator) +{ + declareProperty("ContainerKey", m_contKey = "LArShape"); + //declareProperty("Nsamples", m_nSamples = 5); + //declareProperty("Nphases", m_nPhases = 50); + declareProperty("NtupleName", m_ntName = "SHAPE"); + declareProperty("NtupleFile", m_ntFile = "FILE1"); + declareProperty("isMC", m_isMC=false); +} + +LArShape2Ntuple::~LArShape2Ntuple() +{} + + +StatusCode LArShape2Ntuple::initialize() { + m_ntTitle="Pulse Shape"; + m_ntpath=std::string("/NTUPLES/")+m_ntFile+std::string("/")+m_ntName; + return LArCond2NtupleBase::initialize(); +} + + +StatusCode LArShape2Ntuple::stop() { + StatusCode sc; + // Ntuple booking: Specific + NTuple::Item<long> gain, phase, nSamples; + NTuple::Item<float> timeOffset, phasetime; + NTuple::Array<float> Shape, ShapeDer; + + //NTuple::Tuple *nt=m_nt; + + sc=m_nt->addItem("Gain",gain,-1,2); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'gain' failed" << endreq; + return StatusCode::FAILURE; + } + + //Specific: + sc=m_nt->addItem("TimeOffset",timeOffset,0,100); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'TimeOffset' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Phase",phase,0,49); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'phase' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("PhaseTime",phasetime,0,800); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'PhaseTime' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("nSamples",nSamples,0,100); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'nSamples' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Shape",nSamples,Shape); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Shape' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("ShapeDer",nSamples,ShapeDer); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'ShapeDer' failed" << endreq; + return StatusCode::FAILURE; + } + + // retrieve Shape object + //const ILArShape* IlarShape = NULL ; + const LArShapeComplete* larShape = NULL ; + const LArShape32MC* larShapeMC = NULL ; + const LArShapeSC* larShapeSC = NULL ; + const LArShapeFlat* larShapeFlat = NULL ; + if ( m_isMC && !m_isSC) { + (*m_log) << MSG::DEBUG << "Retrieving LArShapeMC object" << endreq; + sc = m_detStore->retrieve(larShapeMC,m_contKey); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Can't retrieve LArShapeMC from Conditions Store" << endreq; + return StatusCode::FAILURE; + } + } else if (m_isSC) { + (*m_log) << MSG::DEBUG << "Retrieving LArShapeSC object" << endreq; + sc = m_detStore->retrieve(larShapeSC,m_contKey); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Can't retrieve LArShapeSC from Conditions Store" << endreq; + return StatusCode::FAILURE; + } + } else if (m_isFlat) { + (*m_log) << MSG::DEBUG << "Retrieving LArShapeFlat object" << endreq; + sc = m_detStore->retrieve(larShapeFlat,m_contKey); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Can't retrieve LArShapeFlat from Conditions Store" << endreq; + return StatusCode::FAILURE; + } + }else { + (*m_log) << MSG::DEBUG << "Retrieving LArShape object" << endreq; + sc = m_detStore->retrieve(larShape,m_contKey); + if (sc.isFailure()) { + (*m_log) << MSG::ERROR << "Can't retrieve LArShape from Conditions Store" << endreq; + return StatusCode::FAILURE; + } + } + + (*m_log) << MSG::VERBOSE << " shape object retrieved" << endreq; + unsigned cellCounter=0; + for ( unsigned igain=CaloGain::LARHIGHGAIN; + igain<CaloGain::LARNGAIN ; ++igain ) { + std::vector<HWIdentifier>::const_iterator it = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator it_e = m_onlineId->channel_end(); + if ( m_isMC ) { + for (;it!=it_e;it++) { + const HWIdentifier chid = *it; + if (!m_larCablingSvc->isOnlineConnected(chid)) continue; + (*m_log) << MSG::VERBOSE << "Dumping ShapeMC for channel 0x" << MSG::hex + << chid.get_compact() << MSG::dec << endreq; + ILArShape::ShapeRef_t shape; + if(m_isSC) shape=larShapeSC->Shape(chid,igain); else shape=larShapeMC->Shape(chid,igain); + ILArShape::ShapeRef_t shapeder; + if(m_isSC) shapeder=larShapeSC->ShapeDer(chid,igain); else shapeder=larShapeMC->ShapeDer(chid,igain); + fillFromIdentifier(chid); + gain = (long)igain ; + phase = (long)0 ; + nSamples=shape.size(); + for (int k=0;k<nSamples;k++ ) { + Shape[k] = shape[k] ; + ShapeDer[k] = shapeder[k] ; + } + + timeOffset = 0; + phasetime = 0; + + + sc = ntupleSvc()->writeRecord(m_nt); + cellCounter++; + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//loop over channels + } else { // MC / not MC + for (;it!=it_e;it++) { + const HWIdentifier chid = *it; + if (!m_larCablingSvc->isOnlineConnected(chid)) continue; + (*m_log) << MSG::VERBOSE << "Dumping Shape for channel 0x" << MSG::hex + << chid.get_compact() << MSG::dec << endreq; + for (unsigned iphase=0;iphase<larShape->nTimeBins(chid,igain);iphase++) { + ILArShape::ShapeRef_t shape; + if(m_isSC) shape=larShapeSC->Shape(chid,igain,iphase); + else if(m_isFlat) shape=larShapeFlat->Shape(chid,igain,iphase); + else shape=larShape->Shape(chid,igain,iphase); + //Check if we have Shape for this channel and gain + //if (!shape.size()) break;//No more phases + ILArShape::ShapeRef_t shapeder; + if(m_isSC) shapeder=larShapeSC->ShapeDer(chid,igain,iphase); + else if(m_isFlat) shapeder=larShapeFlat->ShapeDer(chid,igain,iphase); + else shapeder=larShape->ShapeDer(chid,igain,iphase); + fillFromIdentifier(chid); + gain = (long)igain ; + phase = (long)iphase ; + nSamples=shape.size(); + for (int k=0;k<nSamples;k++ ) { + Shape[k] = shape[k] ; + ShapeDer[k] = shapeder[k] ; + } + + timeOffset = larShape->timeOffset(chid,igain); + phasetime = phase*larShape->timeBinWidth(chid,igain); + + + sc = ntupleSvc()->writeRecord(m_nt); + cellCounter++; + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//loop over phases + }//loop over channels + } + }//loop over gains + (*m_log) << MSG::INFO << "Total number of cells = " << cellCounter << endreq; + (*m_log) << MSG::INFO << "LArShape2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +} // end finalize-method. diff --git a/LArCalorimeter/LArCalibTools/src/LArWFParams2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArWFParams2Ntuple.cxx new file mode 100755 index 000000000000..e35524ee53b3 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArWFParams2Ntuple.cxx @@ -0,0 +1,271 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArWFParams2Ntuple.h" + +#include "LArRawConditions/LArWFParamsContainer.h" +#include "LArRawConditions/LArWFParamsComplete.h" +#include "LArRawConditions/LArCaliPulseParamsComplete.h" +#include "LArRawConditions/LArDetCellParamsComplete.h" +#include "LArRawConditions/LArPhysCaliTdiffComplete.h" +#include "LArRawConditions/LArTdriftComplete.h" +#include "LArRawConditions/LArOFCBinComplete.h" + +LArWFParams2Ntuple::LArWFParams2Ntuple(const std::string& name, ISvcLocator* pSvcLocator) + : LArCond2NtupleBase(name, pSvcLocator) +{ + //declareProperty("UseContainers",m_useContainers=false) ; + //declareProperty("UseComplete",m_useComplete=false) ; + declareProperty("DumpCaliPulseParams",m_dumpCaliPulseParams=false); + declareProperty("DumpDetCellParams" ,m_dumpDetCellParams=false); + declareProperty("DumpPhysCaliTdiff" ,m_dumpPhysCaliTdiff=false); + declareProperty("DumpTdrift" ,m_dumpTdrift=false); + declareProperty("DumpOFCBin" ,m_dumpOFCBin=false); + + declareProperty("CaliPulseParamsKey",m_caliPulseParamsKey="LArCaliPulseParams"); + declareProperty("DetCellParamsKey" ,m_detCellParamsKey="LArDetCellParams"); + declareProperty("PhysCaliTDiffKey" ,m_physCaliTDiffKey="LArPhysCaliTDiff"); + declareProperty("TdriftKey" ,m_tdriftKey="LArTdrift"); + declareProperty("OFCBinKey" ,m_ofcBinKey="LArOFCBin"); + + m_addFEBTemp=false; +} + +LArWFParams2Ntuple::~LArWFParams2Ntuple() +{} + + +StatusCode LArWFParams2Ntuple::initialize() { + + m_ntTitle="Parameters"; + m_ntpath="/NTUPLES/FILE1/PARAMS"; + return LArCond2NtupleBase::initialize(); +} + +StatusCode LArWFParams2Ntuple::stop() { + + //Retrieve objects from DetStore + const LArCaliPulseParamsComplete* completeCaliPulseParams=0 ; + const LArDetCellParamsComplete* completeDetCellParams=0 ; + const LArPhysCaliTdiffComplete* completePhysCaliTdiff=0 ; + const LArTdriftComplete* completeTdrift=0; + const LArOFCBinComplete* completeOFCBin=0; + + + if ( m_dumpCaliPulseParams ) { //try retrieving from det store + ATH_MSG_DEBUG("Retrieving LArCaliPulseParamsComplete from detector store..."); + StatusCode sc = detStore()->retrieve(completeCaliPulseParams,m_caliPulseParamsKey) ; + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Could not retrieve LArCaliPulseParamsComplete from detector store!" << endreq ; + m_dumpCaliPulseParams = false ; + } + } + + if ( m_dumpDetCellParams ) { //try retrieving from det store + ATH_MSG_DEBUG("Retrieving LArDetCellParamsComplete from detector store..."); + StatusCode sc = detStore()->retrieve(completeDetCellParams,m_detCellParamsKey); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Could not retrieve LArDetCellParamsComplete from detector store!" << endreq ; + m_dumpDetCellParams = false; + } + } + + + if ( m_dumpPhysCaliTdiff ) { //try retrieving from det store + ATH_MSG_DEBUG("Retrieving LArPhysCaliTdiffComplete from detector store..."); + StatusCode sc = detStore()->retrieve(completePhysCaliTdiff,m_physCaliTDiffKey); + if ( sc.isFailure()) { + msg(MSG::ERROR) << "Could not retrieve LArPhysCaliTdiffComplete from detector store!" << endreq ; + m_dumpPhysCaliTdiff = false ; + } + } + + + if ( m_dumpTdrift ) { //try retrieving from det store + ATH_MSG_DEBUG("Retrieving LArTdriftComplete from detector store..."); + StatusCode sc = detStore()->retrieve(completeTdrift,m_tdriftKey) ; + if ( sc.isFailure()) { + msg(MSG::ERROR) << "Could not retrieve LArTdriftComplete from detector store!" << endreq; + m_dumpTdrift = false ; + } + } + + if ( m_dumpOFCBin ) { //try retrieving from det store + ATH_MSG_DEBUG("Retrieving LArOFCBinComplete from detector store..."); + StatusCode sc = detStore()->retrieve(completeOFCBin,m_ofcBinKey) ; + if ( sc.isFailure()) { + msg(MSG::ERROR) << "Could not retrieve LArOFCBinComplete from detector store!" << endreq; + m_dumpOFCBin= false ; + } + } + + + //Book ntuple item + NTuple::Item<long> gain; + NTuple::Item<double> Tcal, Fstep, Tdrift, Omega0, Taur, Tdiff,ofcbin;// Tshaper, Amplitude; + + StatusCode sc=m_nt->addItem("gain",gain,-1,2); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Gain' failed" << endreq; + return StatusCode::FAILURE; + } + + + if ( m_dumpCaliPulseParams ) { + sc=m_nt->addItem("Tcal",Tcal); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Tcal' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Fstep",Fstep); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Fstep' failed" << endreq; + return StatusCode::FAILURE; + } + } + if ( m_dumpTdrift ) { + sc=m_nt->addItem("Tdrift",Tdrift); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Tdrift' failed" << endreq; + return StatusCode::FAILURE; + } + } + if ( m_dumpPhysCaliTdiff ) { + sc=m_nt->addItem("Tdiff",Tdiff); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Tdiff' failed" << endreq; + return StatusCode::FAILURE; + } + } + if ( m_dumpDetCellParams ) { + sc=m_nt->addItem("Omega0",Omega0); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Omega0' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("Taur",Taur); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addItem 'Taur' failed" << endreq; + return StatusCode::FAILURE; + } + } + if (m_dumpOFCBin) { + sc=m_nt->addItem("Bin",ofcbin); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "addIdetm 'Bin' failed!" << endreq; + } + } + +// sc=m_nt->addItem("Tshaper",m_Tshaper); +// if (sc!=StatusCode::SUCCESS) { +// msg(MSG::ERROR) << "addItem 'Tshaper' failed" << endreq; +// return StatusCode::FAILURE; +// } +// sc=m_nt->addItem("Amplitude",m_Amplitude); +// if (sc!=StatusCode::SUCCESS) { +// msg(MSG::ERROR) << "addItem 'Amplitude' failed" << endreq; +// return StatusCode::FAILURE; +// } + + //======================================================================================================= + // dump WFparams from smaller complete structures + // LArCaliPulseParamsComplete , LArDetCellParamsComplete , LArPhysCaliTdiffComplete , LArTdriftComplete + //======================================================================================================= + + + + + for(long igain=CaloGain::LARHIGHGAIN; igain<CaloGain::LARNGAIN; igain++) { + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + + //Initialize variables to 'errorcode' + float vTcal=ILArCaliPulseParams::ERRORCODE; + float vFstep=ILArCaliPulseParams::ERRORCODE; + float vTdrift=ILArCaliPulseParams::ERRORCODE; + float vOmega0=ILArCaliPulseParams::ERRORCODE; + float vTaur=ILArCaliPulseParams::ERRORCODE; + float vTdiff=ILArCaliPulseParams::ERRORCODE; + float vBin=ILArCaliPulseParams::ERRORCODE; + //Tshaper=ILArCaliPulseParams::ERRORCODE; + //Amplitude=ILArCaliPulseParams::ERRORCODE; + + + bool haveData=false; + if ( m_dumpCaliPulseParams ) { + const LArCaliPulseParamsP& params=completeCaliPulseParams->get(hwid,igain); + vTcal=params.m_Tcal; + vFstep=params.m_Fstep; + if (!haveData && (vTcal>1+ILArCaliPulseParams::ERRORCODE || vFstep>1+ILArCaliPulseParams::ERRORCODE)) haveData=true; + } + + if (m_dumpDetCellParams ) { + const LArDetCellParamsP& params=completeDetCellParams->get(hwid,igain); + vOmega0=params.m_Omega0; + vTaur=params.m_Taur; + if (!haveData && (vOmega0>1+ILArCaliPulseParams::ERRORCODE || vTaur>1+ILArCaliPulseParams::ERRORCODE)) haveData=true; + } + + if (m_dumpTdrift ) { + const LArTdriftP& params=completeTdrift->get(hwid,gain); + if (!params.isEmpty()) { + vTdrift=params.m_Tdrift; + haveData=true; + } + } + + if ( m_dumpPhysCaliTdiff ) { + const LArPhysCaliTdiffP& params= completePhysCaliTdiff->get(hwid,gain); + if (!params.isEmpty()) { + vTdiff=params.m_Tdiff; + if (!m_dumpTdrift && !m_dumpDetCellParams && !m_dumpCaliPulseParams) haveData=true; + } + } + + if ( m_dumpOFCBin ) { + const LArOFCBinP & bin = completeOFCBin->bin(hwid,gain); + if (!bin.isEmpty()) { + vBin=bin.m_bin; + haveData=true; + } + } + + if (haveData) { + bool connected=fillFromIdentifier(hwid); + if (!connected) { + //std::cout << "Disconnected: Tdrift:" << vTdrift << " Tdiff:" << vTdiff << " Taur" << vTaur << " Omega0" << vOmega0 << " Fstep" << vFstep << " Tcal" << vTcal << std::endl; + continue; + } + if ( m_dumpCaliPulseParams ) { + Tcal=vTcal; + Fstep=vFstep; + } + if (m_dumpDetCellParams ) { + Taur=vTaur; + Omega0=vOmega0; + } + + if (m_dumpPhysCaliTdiff) Tdiff=vTdiff; + + if (m_dumpTdrift ) Tdrift=vTdrift; + + if (m_dumpOFCBin) ofcbin=vBin; + + gain=igain; + + + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + msg(MSG::ERROR) << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end if have data + + }//end loop over identifiers + + }//end loop over gains + return StatusCode::SUCCESS; +}// end stop-method diff --git a/LArCalorimeter/LArCalibTools/src/LArWaves2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArWaves2Ntuple.cxx new file mode 100755 index 000000000000..7f97dd31813e --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArWaves2Ntuple.cxx @@ -0,0 +1,130 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawConditions/LArWaveCumul.h" + +#include "LArCalibTools/LArWaves2Ntuple.h" + +LArWaves2Ntuple::LArWaves2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArCond2NtupleBase(name, pSvcLocator) +{ + + declareProperty("SaveDerivedInfo",m_saveDerivedInfo=false); +} + +LArWaves2Ntuple::~LArWaves2Ntuple() +{} + +StatusCode LArWaves2Ntuple::initialize() { + + StatusCode sc=LArCond2NtupleBase::initialize(); + if (sc.isFailure()) + return sc; + + sc=m_nt->addItem("flag",m_flag,0,1000); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Flag' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("timeIndex",m_timeIndex,0,100000); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'timeIndex' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("Dt",m_dt,0.,25.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Dt' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("Time",m_timeIndex,m_time); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Time' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("Amplitude",m_timeIndex,m_ampliPulse); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("Error",m_timeIndex,m_errorPulse); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Error' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("Triggers",m_timeIndex,m_triggers); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Triggers' failed" << endreq; + return StatusCode::FAILURE; + } + + if ( m_saveDerivedInfo ) { + sc=m_nt->addItem("Baseline",m_baseline,0.,1200.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Baseline' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("TmaxAmp",m_tmaxAmp,0.,4095.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'TmaxAmp' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("MaxAmp",m_maxAmp,0.,4095.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'MaxAmp' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("PosLobe",m_posLobe,0.,100.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'PosLobe' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("T0",m_rT0,20.,100.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'RT0' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("Width",m_width,0.,125.); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "addItem 'Width' failed" << endreq; + return StatusCode::FAILURE; + } + } + return StatusCode::SUCCESS; +} + + +bool LArWaves2Ntuple::fillWave(const HWIdentifier chid, const LArWaveCumul& wave) { + fillFromIdentifier(chid); + m_flag = wave.getFlag(); + m_dt = wave.getDt(); + + for (m_timeIndex=0; m_timeIndex<(long)wave.getSize(); m_timeIndex++ ) { + m_time[m_timeIndex] = wave.getTime(m_timeIndex); + m_ampliPulse[m_timeIndex] = wave.getSample(m_timeIndex); + m_errorPulse[m_timeIndex] = wave.getError(m_timeIndex); + m_triggers[m_timeIndex] = wave.getTrigger(m_timeIndex); + } + + if ( m_saveDerivedInfo ) { // additional (derived) information, computed on the fly... + m_baseline = m_waveHelper.getBaseline(wave,10); + m_maxAmp = m_waveHelper.getMaxAmp(wave); + // please note the 'dt' normalization in the following! + m_tmaxAmp = m_dt * m_waveHelper.getMax(wave); + m_width = m_dt * m_waveHelper.getWidth(wave); + m_rT0 = m_dt * m_waveHelper.getT0(wave); + m_posLobe = m_dt * m_waveHelper.getSumRegion(wave,0,m_waveHelper.getZeroCross(wave))/m_maxAmp; + } + return true; +} + diff --git a/LArCalorimeter/LArCalibTools/src/LArfSampl2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArfSampl2Ntuple.cxx new file mode 100644 index 000000000000..da14dbe1e084 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LArfSampl2Ntuple.cxx @@ -0,0 +1,76 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LArfSampl2Ntuple.h" +#include "LArRawConditions/LArfSamplMC.h" +#include "CaloIdentifier/CaloGain.h" +/* +#include "GaudiKernel/INTupleSvc.h" +#include "GaudiKernel/NTuple.h" +#include "GaudiKernel/SmartDataPtr.h" +*/ + +//#include <fstream> + +LArfSampl2Ntuple::LArfSampl2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): + LArCond2NtupleBase(name, pSvcLocator) { + declareProperty("ContainerKey",m_contKey); + //declareProperty("IsMC",m_isMC = false); + + m_ntTitle="fSampl"; + m_ntpath="/NTUPLES/FILE1/FSAMPL"; + +} + +LArfSampl2Ntuple::~LArfSampl2Ntuple() +{} + +StatusCode LArfSampl2Ntuple::stop() { + const ILArfSampl* larfSampl = NULL; + StatusCode sc; + sc=m_detStore->retrieve(larfSampl,m_contKey); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "Unable to retrieve ILArNoise with key " + << m_contKey << " from DetectorStore" << endreq; + return StatusCode::FAILURE; + } + + NTuple::Item<long> cellIndex; + NTuple::Item<float> fsampl; + + sc=m_nt->addItem("icell",cellIndex,0,2000); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Cell Index' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("fsampl",fsampl); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'fsampl' failed" << endreq; + return StatusCode::FAILURE; + } + + + unsigned cellCounter=0; + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + if ( m_larCablingSvc->isOnlineConnected(hwid)) { + fillFromIdentifier(hwid); + cellIndex = cellCounter; + fsampl = larfSampl->FSAMPL(hwid); + sc=ntupleSvc()->writeRecord(m_nt); + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + }//end if isConnected + cellCounter++; + }//end loop over online ID + + (*m_log) << MSG::INFO << "LArfSampl2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/LAruA2MeV2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LAruA2MeV2Ntuple.cxx new file mode 100755 index 000000000000..2e585d7aa2f9 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/LAruA2MeV2Ntuple.cxx @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCalibTools/LAruA2MeV2Ntuple.h" +#include "LArElecCalib/ILAruA2MeV.h" +#include "LArElecCalib/ILArDAC2uA.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArIdentifier/LArOnlineID.h" +#include "StoreGate/StoreGateSvc.h" +#include "LArTools/LArCablingService.h" + +LAruA2MeV2Ntuple::LAruA2MeV2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArCond2NtupleBase(name, pSvcLocator) { + declareProperty("uA2MeVKey",m_uA2MeVKey); + declareProperty("DAC2uAKey",m_DAC2uAKey); + + m_ntTitle="ADC to Mev Conversion"; + m_ntpath="/NTUPLES/FILE1/ADCMEV"; + +} + +LAruA2MeV2Ntuple::~LAruA2MeV2Ntuple() +{} + +StatusCode LAruA2MeV2Ntuple::stop() { + StatusCode sc; + NTuple::Item<long> cellIndex; + NTuple::Item<float> uA2MeV; + NTuple::Item<float> DAC2uA; + + sc=m_nt->addItem("icell",cellIndex,0,2000); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'Cell Index' failed" << endreq; + return StatusCode::FAILURE; + } + sc=m_nt->addItem("uAMeV",uA2MeV,-1000.,5000.); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'uAMeV' failed" << endreq; + return StatusCode::FAILURE; + } + + sc=m_nt->addItem("DAC2uA",DAC2uA,-1000.,5000.); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "addItem 'DAC2uA' failed" << endreq; + return StatusCode::FAILURE; + } + + //const LAruA2MeVComplete* laruA2MeVComplete; + const ILAruA2MeV* laruA2MeVComplete; + sc=m_detStore->retrieve(laruA2MeVComplete,m_uA2MeVKey); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "Unable to retrieve LAruA2MeVComplete with key " + << m_uA2MeVKey << " from DetectorStore" << endreq; + return StatusCode::FAILURE; + } + + const ILArDAC2uA* larDAC2uAComplete; + sc=m_detStore->retrieve(larDAC2uAComplete,m_DAC2uAKey); + if (sc!=StatusCode::SUCCESS) + {(*m_log) << MSG::ERROR << "Unable to retrieve LArDAC2uAComplete with key " + << m_DAC2uAKey << " from DetectorStore" << endreq; + return StatusCode::FAILURE; + } + + + std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin(); + std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end(); + unsigned cellCounter=0; + for(; itOnId!=itOnIdEnd;++itOnId){ + const HWIdentifier hwid = *itOnId; + if (m_larCablingSvc->isOnlineConnected(hwid)) { + uA2MeV=laruA2MeVComplete->UA2MEV(hwid); + DAC2uA=larDAC2uAComplete->DAC2UA(hwid); + fillFromIdentifier(hwid); + cellIndex=cellCounter; + sc=ntupleSvc()->writeRecord(m_nt); + + if (sc!=StatusCode::SUCCESS) { + (*m_log) << MSG::ERROR << "writeRecord failed" << endreq; + return StatusCode::FAILURE; + } + cellCounter++; + }//end if connected + }//end loop over online ID + + (*m_log) << MSG::INFO << "LAruA2MeV2Ntuple has finished." << endreq; + return StatusCode::SUCCESS; +}// end finalize-method. + diff --git a/LArCalorimeter/LArCalibTools/src/components/LArCalibTools_entries.cxx b/LArCalorimeter/LArCalibTools/src/components/LArCalibTools_entries.cxx new file mode 100755 index 000000000000..f2bd19abf67c --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/components/LArCalibTools_entries.cxx @@ -0,0 +1,145 @@ +#include "LArCalibTools/LArAutoCorr2Ntuple.h" +#include "LArCalibTools/LArAverages2Ntuple.h" +#include "LArCalibTools/LArAccumulatedDigits2Ntuple.h" +#include "LArCalibTools/LArOFC2Ntuple.h" +#include "LArCalibTools/LArShape2Ntuple.h" +#include "LArCalibTools/LArPedestals2Ntuple.h" +#include "LArCalibTools/LArRamps2Ntuple.h" +#include "LArCalibTools/LArReadParamsFromFile.h" +#include "LArCalibTools/LAruA2MeV2Ntuple.h" +#include "LArCalibTools/LArCaliWaves2Ntuple.h" +#include "LArCalibTools/LArPhysWaves2Ntuple.h" +#include "LArCalibTools/LArWFParams2Ntuple.h" +#include "LArCalibTools/LArParams2Ntuple.h" +#include "LArCalibTools/LArPhysWaveFromTuple.h" +#include "LArCalibTools/LArPhysWaveFromStdNtuple.h" +#include "LArCalibTools/LArParamsFromStdNtuple.h" +#include "LArCalibTools/LArOFCBin_PhysCaliTdiffFromStdNtuple.h" +#include "LArCalibTools/LArMphysOverMcalFromTuple.h" +#include "LArCalibTools/LArMphysOverMcal2Ntuple.h" +#include "LArCalibTools/LArHVScaleCorr2Ntuple.h" +#include "LArCalibTools/LArBlockCorrections.h" +#include "LArCalibTools/CaloCellGroup2Ntuple.h" +#include "LArCalibTools/LArFEBTemp2Ntuple.h" +#include "LArCalibTools/ForceLoadCondObj.h" +#include "LArCalibTools/LArFebTimeOffset2Ntuple.h" +#include "LArCalibTools/LArGainThresholds2Ntuple.h" +#include "LArCalibTools/LArPhysCaliTDiffAlg.h" +#include "LArCalibTools/LArDSPThresholds2Ntuple.h" +#include "LArCalibTools/CaloCondBlob2Ntuple.h" +#include "LArCalibTools/LArCompleteToFlat.h" +#include "LArCalibTools/LArNoise2Ntuple.h" +#include "LArCalibTools/LArfSampl2Ntuple.h" + + +#include "GaudiKernel/DeclareFactoryEntries.h" + +typedef LArReadParamsFromFile<LArCaliPulseParamsComplete> LArReadCaliPulseParams ; +typedef LArReadParamsFromFile<LArDetCellParamsComplete> LArReadDetCellParams ; +typedef LArReadParamsFromFile<LArPhysCaliTdiffComplete> LArReadPhysCaliTdiff ; +typedef LArReadParamsFromFile<LArTdriftComplete> LArReadTdrift ; +typedef LArReadParamsFromFile<LArMphysOverMcalComplete> LArReadMphysOverMcal ; +typedef LArReadParamsFromFile<LArRinjComplete> LArReadRinj ; +typedef LArReadParamsFromFile<LArTshaperComplete> LArReadTshaper ; +typedef LArReadParamsFromFile<LArEMEC_CphiComplete> LArReadEMEC_Cphi ; +typedef LArReadParamsFromFile<LArEMEC_HValphaComplete> LArReadEMEC_HValpha ; +typedef LArReadParamsFromFile<LArEMEC_HVbetaComplete> LArReadEMEC_HVbeta ; +typedef LArReadParamsFromFile<LArCableLengthComplete> LArReadCableLength ; +typedef LArReadParamsFromFile<LArCableAttenuationComplete> LArReadCableAttenuation ; +typedef LArReadParamsFromFile<LArCaliPulseParamsVsCalib> LArReadCaliPulseParams_Calib ; + +DECLARE_ALGORITHM_FACTORY( LArAutoCorr2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArAverages2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArAccumulatedDigits2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArOFC2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArShape2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArPedestals2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArRamps2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArReadCaliPulseParams ) +DECLARE_ALGORITHM_FACTORY( LArReadCaliPulseParams_Calib ) +DECLARE_ALGORITHM_FACTORY( LArReadDetCellParams ) +DECLARE_ALGORITHM_FACTORY( LArReadPhysCaliTdiff ) +DECLARE_ALGORITHM_FACTORY( LArReadTdrift ) +DECLARE_ALGORITHM_FACTORY( LArReadMphysOverMcal ) +DECLARE_ALGORITHM_FACTORY( LArReadRinj ) +DECLARE_ALGORITHM_FACTORY( LArReadTshaper ) +DECLARE_ALGORITHM_FACTORY( LArReadEMEC_Cphi ) +DECLARE_ALGORITHM_FACTORY( LArReadEMEC_HValpha ) +DECLARE_ALGORITHM_FACTORY( LArReadEMEC_HVbeta ) +DECLARE_ALGORITHM_FACTORY( LArReadCableLength ) +DECLARE_ALGORITHM_FACTORY( LArReadCableAttenuation ) +DECLARE_ALGORITHM_FACTORY( LAruA2MeV2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArCaliWaves2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArPhysWaves2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArWFParams2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArParams2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArPhysWaveFromTuple ) +DECLARE_ALGORITHM_FACTORY( LArPhysWaveFromStdNtuple ) +DECLARE_ALGORITHM_FACTORY( LArParamsFromStdNtuple ) +DECLARE_ALGORITHM_FACTORY( LArOFCBin_PhysCaliTdiffFromStdNtuple ) +DECLARE_ALGORITHM_FACTORY( LArMphysOverMcalFromTuple ) +DECLARE_ALGORITHM_FACTORY( LArMphysOverMcal2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArHVScaleCorr2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArBlockCorrections ) +DECLARE_ALGORITHM_FACTORY ( CaloCellGroup2Ntuple ) +DECLARE_ALGORITHM_FACTORY ( LArFEBTemp2Ntuple ) +DECLARE_ALGORITHM_FACTORY (ForceLoadCondObj ) +DECLARE_ALGORITHM_FACTORY( LArFebTimeOffset2Ntuple ) +DECLARE_ALGORITHM_FACTORY(LArGainThresholds2Ntuple) +DECLARE_ALGORITHM_FACTORY(LArDSPThresholds2Ntuple) +DECLARE_ALGORITHM_FACTORY( LArPhysCaliTDiffAlg ) +DECLARE_ALGORITHM_FACTORY( CaloCondBlob2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArCompleteToFlat ) +DECLARE_ALGORITHM_FACTORY( LArNoise2Ntuple ) +DECLARE_ALGORITHM_FACTORY( LArfSampl2Ntuple ) + + + +DECLARE_FACTORY_ENTRIES( LArCalibTools ) { + DECLARE_ALGORITHM( LArAutoCorr2Ntuple ) + DECLARE_ALGORITHM( LArAverages2Ntuple ) + DECLARE_ALGORITHM( LArAccumulatedDigits2Ntuple ) + DECLARE_ALGORITHM( LArAutoCorr2Ntuple ) + DECLARE_ALGORITHM( LArOFC2Ntuple ) + DECLARE_ALGORITHM( LArShape2Ntuple ) + DECLARE_ALGORITHM( LArPedestals2Ntuple ) + DECLARE_ALGORITHM( LAruA2MeV2Ntuple ) + DECLARE_ALGORITHM( LArRamps2Ntuple ) + DECLARE_ALGORITHM( LArReadCaliPulseParams ) + DECLARE_ALGORITHM( LArReadCaliPulseParams_Calib ) + DECLARE_ALGORITHM( LArReadDetCellParams ) + DECLARE_ALGORITHM( LArReadPhysCaliTdiff ) + DECLARE_ALGORITHM( LArReadTdrift ) + DECLARE_ALGORITHM( LArReadMphysOverMcal ) + DECLARE_ALGORITHM( LArReadRinj ) + DECLARE_ALGORITHM( LArReadTshaper ) + DECLARE_ALGORITHM( LArReadEMEC_Cphi ) + DECLARE_ALGORITHM( LArReadEMEC_HValpha ) + DECLARE_ALGORITHM( LArReadEMEC_HVbeta ) + DECLARE_ALGORITHM( LArReadCableLength ) + DECLARE_ALGORITHM( LArReadCableAttenuation ) + DECLARE_ALGORITHM( LAruA2MeV2Ntuple ) + DECLARE_ALGORITHM( LArCaliWaves2Ntuple ) + DECLARE_ALGORITHM( LArPhysWaves2Ntuple ) + DECLARE_ALGORITHM( LArWFParams2Ntuple ) + DECLARE_ALGORITHM( LArParams2Ntuple ) + DECLARE_ALGORITHM( LArPhysWaveFromTuple ) + DECLARE_ALGORITHM( LArPhysWaveFromStdNtuple ) + DECLARE_ALGORITHM( LArParamsFromStdNtuple ) + DECLARE_ALGORITHM( LArOFCBin_PhysCaliTdiffFromStdNtuple ) + DECLARE_ALGORITHM( LArMphysOverMcalFromTuple ) + DECLARE_ALGORITHM( LArMphysOverMcal2Ntuple) + DECLARE_ALGORITHM( LArHVScaleCorr2Ntuple) + DECLARE_ALGORITHM( LArBlockCorrections ) + DECLARE_ALGORITHM (CaloCellGroup2Ntuple ) + DECLARE_ALGORITHM (LArFEBTemp2Ntuple ) + DECLARE_ALGORITHM (ForceLoadCondObj ) + DECLARE_ALGORITHM ( LArFebTimeOffset2Ntuple ) + DECLARE_ALGORITHM ( LArGainThresholds2Ntuple) + DECLARE_ALGORITHM ( LArDSPThresholds2Ntuple) + DECLARE_ALGORITHM ( LArPhysCaliTDiffAlg ) + DECLARE_ALGORITHM ( CaloCondBlob2Ntuple ) + DECLARE_ALGORITHM ( LArCompleteToFlat ) + DECLARE_ALGORITHM( LArNoise2Ntuple) + DECLARE_ALGORITHM( LArfSampl2Ntuple) +} diff --git a/LArCalorimeter/LArCalibTools/src/components/LArCalibTools_load.cxx b/LArCalorimeter/LArCalibTools/src/components/LArCalibTools_load.cxx new file mode 100755 index 000000000000..79764d3757b4 --- /dev/null +++ b/LArCalorimeter/LArCalibTools/src/components/LArCalibTools_load.cxx @@ -0,0 +1,3 @@ +#include "GaudiKernel/LoadFactoryEntries.h" + +LOAD_FACTORY_ENTRIES(LArCalibTools) -- GitLab