Skip to content
Snippets Groups Projects
Commit cb883d3f authored by Walter Lampl's avatar Walter Lampl Committed by Julien Maurer
Browse files

LArRamps2Ntuple: Implement apply-corrections, schedule ntuple-dumping after DB-writing

LArRamps2Ntuple: Implement apply-corrections, schedule ntuple-dumping after DB-writing
parent eacf3313
No related merge requests found
//Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
......@@ -22,9 +22,10 @@
#include "LArCalibTools/LArCond2NtupleBase.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "LArElecCalib/ILArRamp.h"
#include "LArRawConditions/LArRampSym.h"
class LArRamps2Ntuple : public LArCond2NtupleBase
#include "CxxUtils/checker_macros.h"
class ATLAS_NOT_THREAD_SAFE LArRamps2Ntuple : public LArCond2NtupleBase
{
public:
LArRamps2Ntuple(const std::string & name, ISvcLocator * pSvcLocator);
......@@ -43,7 +44,6 @@ class LArRamps2Ntuple : public LArCond2NtupleBase
std::vector<std::string> m_contKey;
SG::ReadCondHandleKey<ILArRamp> m_rampKey;
std::string m_ntName;
bool m_isMC;
};
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "LArCalibTools/LArRamps2Ntuple.h"
#include "LArRawConditions/LArRawRampContainer.h"
#include "LArRawConditions/LArRampComplete.h"
#include "LArRawConditions/LArRampSym.h"
#include <math.h>
......@@ -22,7 +21,6 @@ LArRamps2Ntuple::LArRamps2Ntuple(const std::string& name, ISvcLocator* pSvcLocat
declareProperty("SaveAllSamples", m_saveAllSamples = false);
declareProperty("ApplyCorr", m_applyCorr=false);
declareProperty("AddCorrUndo", m_addCorrUndo=true);
declareProperty("IsMC", m_isMC=false);
}
StatusCode LArRamps2Ntuple::initialize() {
......@@ -100,7 +98,8 @@ StatusCode LArRamps2Ntuple::stop() {
SG::ReadCondHandle<ILArRamp> readHandle{m_rampKey};
ramp = *readHandle;
}
LArRampComplete* rampComplete_nc=nullptr; //for (potential) applyCorr
if (ramp==nullptr) {
ATH_MSG_WARNING( "Unable to retrieve ILArRamp with key: "<<m_rampKey << " from DetectorStore" );
......@@ -243,7 +242,6 @@ StatusCode LArRamps2Ntuple::stop() {
}// 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)
......@@ -264,8 +262,27 @@ StatusCode LArRamps2Ntuple::stop() {
return StatusCode::FAILURE;
}
}
}//end-if rampComplete
if (m_applyCorr) {
const LArRampComplete* rampComplete=dynamic_cast<const LArRampComplete*>(ramp);
if (!rampComplete) {
ATH_MSG_WARNING("Failed to dyn-cast to ILArRamp to LArRampComplete. Cannot apply corrections");
m_applyCorr=false;
}
if (!rampComplete->correctionsApplied()) {
rampComplete_nc=const_cast<LArRampComplete*>(rampComplete);
sc=rampComplete_nc->applyCorrections();
if (sc.isFailure()) {
ATH_MSG_ERROR( "Failed to apply corrections to LArRampComplete!" );
}
else
ATH_MSG_INFO( "Applied corrections to LArRampComplete" );
}
else {
ATH_MSG_WARNING( "Corrections already applied. Can't apply twice!" );
}
}// end if applyCorr
}//end-if ramp
const LArOnOffIdMapping *cabling=0;
if(m_isSC) {
......@@ -440,6 +457,10 @@ StatusCode LArRamps2Ntuple::stop() {
}//end loop over gains
}//end if add corrections
if (rampComplete_nc) {
ATH_CHECK(rampComplete_nc->undoCorrections());
ATH_MSG_INFO("Reverted corrections of LArRampComplete container");
}
ATH_MSG_INFO( "LArRamps2Ntuple has finished." );
return StatusCode::SUCCESS;
......
......@@ -99,10 +99,21 @@ def LArRampCfg(flags):
theLArRampPatcher.PatchMethod="PhiAverage"
theLArRampPatcher.ProblemsToPatch=["deadCalib","deadReadout","deadPhys","almostDead","short"]
theLArRampPatcher.UseCorrChannels=False
theLArRampPatcher.UseCorrChannels=True
result.addEventAlgo(theLArRampPatcher)
#Output (POOL + sqlite) file writing:
from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
result.merge(OutputConditionsAlgCfg(flags,
outputFile=flags.LArCalib.Output.POOLFile,
ObjectList=["LArRampComplete#LArRamp#"+flags.LArCalib.Ramp.Folder,],
IOVTagList=[rampTag,]
))
#RegistrationSvc
result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
result.getService("IOVDbSvc").DBInstance=""
#ROOT ntuple writing:
......@@ -112,6 +123,7 @@ def LArRampCfg(flags):
AddFEBTempInfo = False,
RawRamp = True,
SaveAllSamples = True,
ApplyCorr=True,
))
import os
......@@ -121,23 +133,6 @@ def LArRampCfg(flags):
result.setAppProperty("HistogramPersistency","ROOT")
pass # end if ROOT ntuple writing
#Output (POOL + sqlite) file writing:
from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
result.merge(OutputConditionsAlgCfg(flags,
outputFile=flags.LArCalib.Output.POOLFile,
ObjectList=["LArRampComplete#LArRamp#"+flags.LArCalib.Ramp.Folder,],
IOVTagList=[rampTag,]
))
#RegistrationSvc
result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
result.getService("IOVDbSvc").DBInstance=""
return result
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment