Skip to content
Snippets Groups Projects
Commit 85988fc4 authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

Fix compilation warning. (LArCalibUtils-00-16-23)

	* Tagging LArCalibUtils-00-16-23.
	* LArCalibUtils/LArCalibPatchingAlg.icc: Fix compilation warning.

12-04-2016 Pavol Strizenec
	* changes connected with CaloIdentifier updates
	* tag LArCalibUtils-00-16-22

2016-04-01  scott snyder  <snyder@bnl.gov>

	* Tagging LArCalibUtils-00-16-21.
	* src/LArMasterWaveBuilder.cxx (stop): Coverity 105977, 105999.
	* Tagging LArCalibUtils-00-16-20.
	* Fix warnings about duplicated properties.
	* Tagging LArCalibUtils-00-16-19.
	* Fix compilation warnings.
	* Tagging LArCalibUtils-00-16-18.
	* Comply with ATLAS naming conventions.

10-01-2016 Pavol Strizenec
...
(Long ChangeLog diff - truncated)
parent 778da751
No related branches found
No related tags found
No related merge requests found
Showing
with 251 additions and 56 deletions
################################################################################
# Package: LArCalibUtils
################################################################################
# Declare the package name:
atlas_subdir( LArCalibUtils )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Calorimeter/CaloIdentifier
Control/AthenaBaseComps
Control/AthenaKernel
Control/StoreGate
DetectorDescription/Identifier
GaudiKernel
LArCalorimeter/LArElecCalib
LArCalorimeter/LArIdentifier
LArCalorimeter/LArRawConditions
LArCalorimeter/LArRawEvent
LArCalorimeter/LArRawUtils
LArCalorimeter/LArRecConditions
LArCalorimeter/LArRecUtils
LArCalorimeter/LArTools
TestBeam/TBEvent
PRIVATE
Calorimeter/CaloDetDescr
Database/AthenaPOOL/AthenaPoolUtilities
Event/xAOD/xAODEventInfo
LArCalorimeter/LArBadChannelTool
LArCalorimeter/LArCOOLConditions
LArCalorimeter/LArSimEvent
Trigger/TrigAnalysis/TrigAnalysisInterfaces )
# External dependencies:
find_package( CLHEP )
find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess )
find_package( Eigen )
find_package( GSL )
find_package( ROOT COMPONENTS Minuit Core Tree MathCore Hist RIO pthread MathMore Minuit2 Matrix Physics HistPainter Rint Graf Graf3d Gpad Html Postscript Gui GX11TTF GX11 )
find_package( TBB )
# Component(s) in the package:
atlas_add_component( LArCalibUtils
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${GSL_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${TBB_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${GSL_LIBRARIES} ${CORAL_LIBRARIES} ${EIGEN_LIBRARIES} ${TBB_LIBRARIES} ${CLHEP_LIBRARIES} CaloIdentifier AthenaBaseComps AthenaKernel StoreGateLib SGtests Identifier GaudiKernel LArIdentifier LArRawConditions LArRawEvent LArRawUtilsLib LArRecConditions LArRecUtilsLib LArToolsLib TBEvent CaloDetDescrLib AthenaPoolUtilities xAODEventInfo LArBadChannelToolLib LArCOOLConditions LArSimEvent )
# Install files from the package:
atlas_install_headers( LArCalibUtils )
atlas_install_python_modules( python/*.py )
......@@ -54,6 +54,9 @@ class LArCaliWaveBuilder : public AthAlgorithm
bool m_pedSub;
//const ILArPedestal* m_larPedestal;
unsigned m_baseline;
// Reco also unpulsed and saturated cells ?
bool m_recAll;
//used to store different waves for different HEC calib lines
bool m_useDacAndIsPulsedIndex;
......@@ -73,7 +76,9 @@ class LArCaliWaveBuilder : public AthAlgorithm
float m_dt;
uint16_t m_fatalFebErrorPattern;
int m_usePatt;
unsigned m_numPatt;
};
#endif
......@@ -345,18 +345,18 @@ std::vector<HWIdentifier>& LArCalibPatchingAlg<CONDITIONSCONTAINER>::getFEBChans
for (int i=0;i<128;++i) {
HWIdentifier fchan = m_onlineHelper->channel_Id(febid,i);
if(fchan == chid) continue;
try {
const Identifier id=m_larCablingSvc->cnvToIdentifier(chid);
if(m_onlineHelper->isEMBchannel(chid) || m_onlineHelper->isEMECchannel(chid)) {
if(!m_emId->is_connected(id)) continue;
} else if (m_onlineHelper->isHECchannel(chid)) {
if(!m_hecId->is_connected(id)) continue;
} else {
if(!m_fcalId->is_connected(id)) continue;
}
} catch(LArID_Exception& except) {
ATH_MSG_ERROR ( "LArID_Exception caught!" );
}
//try {
//const Identifier id=m_larCablingSvc->cnvToIdentifier(chid);
//if(m_onlineHelper->isEMBchannel(chid) || m_onlineHelper->isEMECchannel(chid)) {
// if(!m_emId->is_connected(id)) continue;
//} else if (m_onlineHelper->isHECchannel(chid)) {
// if(!m_hecId->is_connected(id)) continue;
//} else {
// if(!m_fcalId->is_connected(id)) continue;
//}
//} catch(LArID_Exception& except) {
// ATH_MSG_ERROR ( "LArID_Exception caught!" );
//}
ATH_MSG_VERBOSE ( " Adding channel =" << i );
if (m_badChannelTool->status(fchan).good()) {
m_idList.push_back(fchan);
......
......@@ -64,10 +64,12 @@ class LArPedestal
// Get mean value
double get_mean() const;
double get_mean(const unsigned isample) const;
double get_mean(const unsigned isample_min, const unsigned isample_max) const;
// Get rms value
double get_rms() const;
double get_rms(const unsigned isample) const;
double get_rms(const unsigned isample_min, const unsigned isample_max) const;
// Get number of samples
inline unsigned get_nsamples() const { return m_sum.size();}
......
......@@ -70,6 +70,9 @@ private:
uint16_t m_fatalFebErrorPattern;
int m_normalize;
int m_sample_min;
int m_sample_max;
};
#endif
......@@ -68,6 +68,9 @@ class LArPedestalMaker : public AthAlgorithm
// Sample number for pedestal
int m_which_sample;
int m_sample_min;
int m_sample_max;
// Vector of LArPedestal
//typedef std::map<HWIdentifier, LArPedestal > LARPEDMAP;
......
......@@ -68,7 +68,7 @@ class LArPhysWaveHECTool : public AthAlgTool
//LArPhysWave m_gPhys;
const LArPhysWave* m_gIdealPhys;
const LArOnlineID* onlineHelper;
const LArOnlineID* m_onlineHelper;
// bool m_verb;
//int m_region, m_layer ;
bool m_normalizeCali , m_timeOriginShift , m_subtractBaseline;
......
......@@ -78,13 +78,19 @@ class LArRampAdHocPatchingAlg : public AthAlgorithm
std::vector<unsigned> m_patchesToBeAppliedMG;
std::vector<unsigned> m_patchesToBeAppliedLG;
std::vector<std::vector<double> > m_valuesToBeAppliedHG;
std::vector<std::vector<double> > m_valuesToBeAppliedMG;
std::vector<std::vector<double> > m_valuesToBeAppliedLG;
enum patchMethod{
ZeroIntercept
ZeroIntercept,
PutValues
};
bool ZeroTheIntercept(HWIdentifier chid, unsigned gain);
StatusCode ApplyAdHocPatches( std::vector<unsigned>& m_channelsToBePatched, std::vector<unsigned>& m_patchesTobeApplied, unsigned gain );
bool PutTheValues(HWIdentifier chid, std::vector<double>& rvalues, unsigned gain);
StatusCode ApplyAdHocPatches( std::vector<unsigned>& channelsToBePatched, std::vector<unsigned>& patchesTobeApplied, std::vector<std::vector<double> >& valuesToBeApplied, unsigned gain );
bool m_useCorrChannel;
......
......@@ -101,20 +101,20 @@ private:
unsigned m_event_counter;
int m_delay;
int ipassShape;
int ipassPedestal;
int m_ipassShape;
int m_ipassPedestal;
// vector (gain) of vector(HashCell) of vector (DAC) of vector(Ndelays) of caliwaves
std::vector< std::vector< std::vector< std::vector<double> > > >CaliWaves;
std::vector< std::vector< std::vector< std::vector<double> > > >m_CaliWaves;
// vector (gain) of vector(HashCell) of vector (DAC) of DACs
std::vector< std::vector< std::vector< int > > >CaliDACs;
std::vector< std::vector< std::vector< int > > >m_CaliDACs;
// vector (gain) of vector(HashCell) of DAC0 index
std::vector< std::vector< int> > IndexDAC0;
std::vector< std::vector< int> > m_IndexDAC0;
// vector (gain) of vector(HashCell) of Highest DAC index
std::vector< std::vector< int> > IndexHighestDAC;
std::vector< std::vector< int> > m_IndexHighestDAC;
// vector(HashCell) of pedestals
std::vector<float> thePedestal;
std::vector<float> m_thePedestal;
std::string m_recoTypeProp; // ( "Parabola", "Shape" or "OF" )
......@@ -144,11 +144,12 @@ private:
bool m_withIntercept;
float m_delayShift;
// hashID sample
std::vector<std::vector<short> > adc0;
std::vector<std::vector<short> > m_adc0;
ToolHandle<LArCablingService> m_larCablingSvc;
//ToolHandle<ILArBadChanTool> m_badChannelTool;
ToolHandle< ILArBadChannelMasker> m_badChannelMask;
bool m_doBadChannelMask;
const LArOnlineID* m_onlineHelper;
const LArEM_ID* m_emId;
......@@ -159,6 +160,7 @@ private:
const DataHandle<ILArRinj> m_dd_rinj;
std::string m_hec_key;
bool m_ishec;
bool m_iterate;
uint16_t m_fatalFebErrorPattern;
......
......@@ -61,7 +61,9 @@ StatusCode LArAccumulatedCalibDigitContSplitter::execute()
}
// execute() method...
return executeWithAccumulatedDigits();
ATH_CHECK( executeWithAccumulatedDigits() );
return StatusCode::SUCCESS;
}
StatusCode LArAccumulatedCalibDigitContSplitter::executeWithAccumulatedDigits()
......
......@@ -40,6 +40,10 @@ LArCaliWaveBuilder::LArCaliWaveBuilder(const std::string& name, ISvcLocator* pSv
declareProperty("GroupingType", m_groupingType);
declareProperty("UseDacAndIsPulsedIndex", m_useDacAndIsPulsedIndex=false);
declareProperty("CheckEmptyPhases", m_checkEmptyPhases=false);
declareProperty("RecAllCells", m_recAll=false);
declareProperty("UsePattern", m_usePatt=-1);
declareProperty("NumPattern", m_numPatt=16); // fix me - is it possible to get from outside ?
//m_dt=25*ns/m_NStep;
m_dt = m_SamplingPeriod/m_NStep;
......@@ -111,7 +115,16 @@ StatusCode LArCaliWaveBuilder::initialize()
StatusCode LArCaliWaveBuilder::execute()
{
if ( m_event_counter < 100 || ( m_event_counter < 1000 && m_event_counter%100==0 ) || m_event_counter%1000==0 )
if(m_usePatt >= 0) { // we have to check in which event we are, reading only ones corresponding
// to our pattern
if(static_cast<int>(m_event_counter % m_numPatt) != m_usePatt) {
m_event_counter++ ;
return StatusCode::SUCCESS;
}
}
// if ( m_event_counter < 100 || ( m_event_counter < 1000 && m_event_counter%100==0 ) || m_event_counter%1000==0 )
if ( m_event_counter < 1000 || m_event_counter%100==0 )
msg(MSG::INFO) << "Processing event " << m_event_counter << endreq;
m_event_counter++ ;
......@@ -120,6 +133,7 @@ StatusCode LArCaliWaveBuilder::execute()
return StatusCode::FAILURE;
}
// execute() method...
if (m_useAccumulatedDigits)
return executeWithAccumulatedDigits();
......@@ -171,8 +185,11 @@ StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits()
for (;it!=it_end; ++it) { // Loop over all cells
if ( !(*it)->isPulsed() ) continue; // Check if cell is pulsed
if ( (!m_recAll) && (!(*it)->isPulsed()) ) {
msg(MSG::DEBUG) << "Non pulsed cell " << m_onlineID->channel_name((*it)->hardwareID()) << endreq;
continue; // Check if cell is pulsed
}
msg(MSG::DEBUG) << "Pulsed cell " << m_onlineID->channel_name((*it)->hardwareID()) << endreq;
HWIdentifier chid=(*it)->hardwareID();
HWIdentifier febid=m_onlineID->feb_Id(chid);
if (febErrSum) {
......@@ -215,7 +232,7 @@ StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits()
int index;
for(int iLine=1;iLine<5;iLine++){
if((*it)->isPulsed(iLine)){
// std::cout<<"GR: line pulsed true, line="<<iLine<<std::endl;
msg(MSG::DEBUG) <<"GR: line pulsed true, line="<<iLine<<endreq;
dacPulsed=(dacPulsed | (0x1 << (15+iLine)));
}
}
......@@ -273,7 +290,7 @@ StatusCode LArCaliWaveBuilder::executeWithStandardDigits()
for (;it!=it_end; ++it) { // Loop over all cells
if ( !(*it)->isPulsed() ) continue ; // Check if cell is pulsed
if ((!m_recAll) && !(*it)->isPulsed() ) continue ; // Check if cell is pulsed
HWIdentifier chid=(*it)->hardwareID();
CaloGain::CaloGain gain=(*it)->gain();
......@@ -352,13 +369,17 @@ StatusCode LArCaliWaveBuilder::stop()
//
const HWIdentifier hwId = cell_it.channelId();
if (!m_cablingSvc->isOnlineConnected(hwId)) continue; //Ignore disconnected channels
if ((!m_recAll) && (!m_cablingSvc->isOnlineConnected(hwId))) {
//msg(MSG::INFO) << "Skipping disconnected channel: "<<MSG::hex<<hwId<<MSG::dec << endreq;
continue; //Ignore disconnected channels
}
const WaveMap& waveMap = (*cell_it);
if (waveMap.size()==0) {
msg(MSG::INFO) << "Empty accumulated wave. Last id: " << MSG::hex
//<< lastId << " " << emId->show_to_string(lastId) << endreq;
<< lastId << MSG::dec << endreq;
<< lastId << " this id: "<<hwId<<MSG::dec << endreq;
continue;
}
......@@ -408,7 +429,7 @@ StatusCode LArCaliWaveBuilder::stop()
}
double waveMax = thisWave.getSample( wHelper.getMax(thisWave) ) ;
if ( m_ADCsatur>0 && waveMax>=m_ADCsatur ) {
if ( (!m_recAll) && m_ADCsatur>0 && waveMax>=m_ADCsatur ) {
msg(MSG::INFO) << "Absolute ADC saturation at DAC = " << thisWave.getDAC() << " ... skip!" << endreq ;
continue ;
} else {
......
......@@ -66,7 +66,8 @@ StatusCode LArCalibDigitMaker::initialize()
return StatusCode::FAILURE;
}
LArCalibParams* calibParams=new LArCalibParams;
calibParams->initialize() ;
ATH_CHECK( calibParams->initialize() );
//void LArCalibParams::set(const HWIdentifier CalibModuleID, const unsigned nTrigger,
// const std::vector<unsigned>& Pattern, const std::vector<unsigned>& DAC, const std::vector<unsigned>& Delay)
for (std::vector<unsigned>::const_iterator it=m_vBoardIDs.begin();it!=m_vBoardIDs.end();it++) {
......
......@@ -340,10 +340,9 @@ StatusCode LArMasterWaveBuilder::stop()
minOverallDiff = thisOverallDiff ;
}
}
int refDAC = thisDAC[refIndex] ;
// reject strongly non-linear waves (if reference wave was found)
if ( refIndex >=0 ) {
int refDAC = thisDAC[refIndex] ;
ATH_MSG_DEBUG ( "Check non-linearity against DAC " << refDAC );
for ( unsigned i=0 ; i<nDACs ; i++ ) {
if ( ! usable[i] ) continue ;
......
......@@ -70,6 +70,22 @@ double LArPedestal::get_sum() const
return sum;
}
//----------------------------------------------------------------------------
double LArPedestal::get_mean(const unsigned isample_min, const unsigned isample_max) const
//----------------------------------------------------------------------------
{
unsigned imin=0;
unsigned imax=m_sum.size()-1;
if (isample_min > 0 && isample_min < m_sum.size()) imin=isample_min;
if (isample_max > 0 && isample_max < m_sum.size()) imax=isample_max;
double mean = 0;
for(unsigned int i=0; i<=imax; ++i) mean += m_sum[i];
mean /= ((imax-imin+1)*(double) m_nped);
return mean;
}
//----------------------------------------------------------------------------
double LArPedestal::get_mean(const unsigned isample) const
//----------------------------------------------------------------------------
......@@ -98,6 +114,27 @@ double LArPedestal::get_mean() const
}
//----------------------------------------------------------------------------
double LArPedestal::get_rms(const unsigned isample_min, const unsigned isample_max) const
//----------------------------------------------------------------------------
{
unsigned imin=0;
unsigned imax=m_sum.size()-1;
if (isample_min > 0 && isample_min < m_sum.size()) imin=isample_min;
if (isample_max > 0 && isample_max < m_sum.size()) imax=isample_max;
//const int nsamples = m_sum.size();
uint64_t x=0, y=0;
for(unsigned int i=imin; i<=imax; i++) {
x+=m_sum[i];
y+=m_sumSquares[i];
}
const double mean=double(x)/((imax-imin+1)*m_nped);
const double ss=double(y)/((imax-imin+1)*m_nped);
return sqrt(ss-mean*mean);
}
//----------------------------------------------------------------------------
double LArPedestal::get_rms(const unsigned isample) const
......
......@@ -35,10 +35,11 @@ LArPedestalAutoCorrBuilder::LArPedestalAutoCorrBuilder(const std::string& name,
declareProperty("PedestalKey", m_pedContName="LArPedestal");
declareProperty("normalize", m_normalize=1);
declareProperty("AutoCorrKey", m_acContName="LArAutoCorr");
declareProperty("GroupingType", m_groupingType);
declareProperty("GroupingType", m_groupingType="ExtendedFeedThrough");
declareProperty("doPedestal", m_doPedestal=true);
declareProperty("doAutoCorr", m_doAutoCorr=true);
declareProperty("sample_min", m_sample_min=-1);
declareProperty("sample_max", m_sample_max=-1);
}
LArPedestalAutoCorrBuilder::~LArPedestalAutoCorrBuilder()
......@@ -224,7 +225,7 @@ StatusCode LArPedestalAutoCorrBuilder::stop() {
// Fill the data class with pedestal and rms values
if (larPedestalComplete)
larPedestalComplete->set(chid,gain,dg.mean(),dg.RMS());
larPedestalComplete->set(chid,gain,dg.mean(m_sample_min, m_sample_max),dg.RMS(m_sample_min, m_sample_max));
if (larAutoCorrComplete) {
dg.getCov(cov,m_normalize);
......
......@@ -36,7 +36,6 @@ LArPedestalBuilder::LArPedestalBuilder(const std::string& name, ISvcLocator* pSv
{
declareProperty("KeyList", m_keylist);
declareProperty("PedestalKey", m_pedContName="LArPedestal");
declareProperty("GroupingType", m_groupingType);
declareProperty("GroupingType", m_groupingType="ExtendedFeedThrough");
}
......
......@@ -42,6 +42,8 @@ LArPedestalMaker::LArPedestalMaker(const std::string& name, ISvcLocator* pSvcLoc
declareProperty("events_ref", m_nref);
declareProperty("nsigma", m_rms_cut);
declareProperty("which_sample", m_which_sample=-1);
declareProperty("sample_min", m_sample_min=-1);
declareProperty("sample_max", m_sample_max=-1);
declareProperty("GroupingType", m_groupingType);
}
......@@ -165,7 +167,11 @@ StatusCode LArPedestalMaker::stop()
LArPedestal thisPed=*cell_it;
if(thisPed.get_nentries()==0) { n_zero++; continue; }
// Get the mean and rms
if (m_which_sample==-1 || m_which_sample>=(int)thisPed.get_nsamples()) {
if (m_sample_min >=0 ) {
m_mean[0] = thisPed.get_mean(m_sample_min, m_sample_max);
m_rms[0] = thisPed.get_rms(m_sample_max, m_sample_max);
}
else if (m_which_sample==-1 || m_which_sample>=(int)thisPed.get_nsamples()) {
m_mean[0] = thisPed.get_mean();
m_rms[0] = thisPed.get_rms();
}
......
......@@ -82,7 +82,7 @@ LArPhysWaveHECTool::~LArPhysWaveHECTool() {}
StatusCode LArPhysWaveHECTool::initialize()
{
ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
ATH_CHECK( detStore()->retrieve(m_onlineHelper, "LArOnlineID") );
return StatusCode::SUCCESS;
}
......@@ -156,9 +156,9 @@ StatusCode LArPhysWaveHECTool::makeLArPhysWaveHEC(LArWFParams& wfParam, LArCaliW
}
int FT = onlineHelper->feedthrough(chid);
int Slot = onlineHelper->slot(chid);
int Channel = onlineHelper->channel(chid);
int FT = m_onlineHelper->feedthrough(chid);
int Slot = m_onlineHelper->slot(chid);
int Channel = m_onlineHelper->channel(chid);
int adc = 128*(Slot-5)+ Channel+1;
ATH_MSG_VERBOSE ( "*** Physics waveform\t|-> FT=" << FT << " Slot=" << Slot << " Channel=" <<Channel<< " adc=" << adc << " gain=" << gain );
......
......@@ -358,7 +358,7 @@ StatusCode LArRTMParamExtractor::stop()
int PosNeg = onlineHelper->pos_neg(itVec.channelId());
int FT = onlineHelper->feedthrough(itVec.channelId());
std::vector<int>::const_iterator selectFT = std::find(m_FT.begin(),m_FT.end(),FT);
if ( PosNeg!=m_PosNeg && selectFT==m_FT.end() ) {
if ( PosNeg!=m_PosNeg || selectFT==m_FT.end() ) {
ATH_MSG_DEBUG( "Channel 0x" << MSG::hex << itVec.channelId() << MSG::dec
<< " does not match FT selection (FT = " << FT << ", PosNeg = " << PosNeg
<< "), skipping...");
......
......@@ -23,6 +23,10 @@ LArRampAdHocPatchingAlg::LArRampAdHocPatchingAlg (const std::string& name, ISvcL
declareProperty("PatchesToBeAppliedMG",m_patchesToBeAppliedMG);
declareProperty("PatchesToBeAppliedLG",m_patchesToBeAppliedLG);
declareProperty("ValuesToBeAppliedHG",m_valuesToBeAppliedHG);
declareProperty("ValuesToBeAppliedMG",m_valuesToBeAppliedMG);
declareProperty("ValuesToBeAppliedLG",m_valuesToBeAppliedLG);
declareProperty("UseCorrChannels",m_useCorrChannel,
"True: Use separate correction COOL channel, False: Correction + data in the same channel");
}
......@@ -44,21 +48,39 @@ StatusCode LArRampAdHocPatchingAlg::initialize()
ATH_MSG_ERROR ( "Wrong size of HIGH gain input vectors!" );
return StatusCode::FAILURE;
} else {
ATH_MSG_INFO ( m_channelsToBePatchedHG.size() << " ad-hoc patches to be applied in HIGH gain" );
unsigned count = std::count_if (m_patchesToBeAppliedHG.begin(), m_patchesToBeAppliedHG.end(), std::bind2nd(std::equal_to<int>(),1) ); // 1 is to apply values
if ( (count > 0) && (m_valuesToBeAppliedHG.size() != count)) {
ATH_MSG_ERROR ( "Wrong size of HIGH gain values vector ! " << count << " " << m_valuesToBeAppliedHG.size());
return StatusCode::FAILURE;
} else {
ATH_MSG_INFO ( m_channelsToBePatchedHG.size() << " ad-hoc patches to be applied in HIGH gain" );
}
}
if ( m_channelsToBePatchedMG.size() && ( m_channelsToBePatchedMG.size() != m_patchesToBeAppliedMG.size() ) ) {
ATH_MSG_ERROR ( "Wrong size of MEDIUM gain input vectors!" );
return StatusCode::FAILURE;
} else {
ATH_MSG_INFO ( m_channelsToBePatchedMG.size() << " ad-hoc patches to be applied in MEDIUM gain" );
unsigned count = std::count_if (m_patchesToBeAppliedMG.begin(), m_patchesToBeAppliedMG.end(), std::bind2nd(std::equal_to<int>(),1) ); // 1 is to apply values
if ( (count > 0) && (m_valuesToBeAppliedMG.size() != count)) {
ATH_MSG_ERROR ( "Wrong size of MEDIUM gain values vector !" );
return StatusCode::FAILURE;
} else {
ATH_MSG_INFO ( m_channelsToBePatchedMG.size() << " ad-hoc patches to be applied in MEDIUM gain" );
}
}
if ( m_channelsToBePatchedLG.size() && ( m_channelsToBePatchedLG.size() != m_patchesToBeAppliedLG.size() ) ) {
ATH_MSG_ERROR ( "Wrong size of LOW gain input vectors!" );
return StatusCode::FAILURE;
} else {
ATH_MSG_INFO ( m_channelsToBePatchedLG.size() << " ad-hoc patches to be applied in LOW gain" );
unsigned count = std::count_if (m_patchesToBeAppliedLG.begin(), m_patchesToBeAppliedLG.end(), std::bind2nd(std::equal_to<int>(),1) ); // 1 is to apply values
if ( (count > 0) && (m_valuesToBeAppliedLG.size() != count)) {
ATH_MSG_ERROR ( "Wrong size of LOW gain values vector !" );
return StatusCode::FAILURE;
} else {
ATH_MSG_INFO ( m_channelsToBePatchedLG.size() << " ad-hoc patches to be applied in LOW gain" );
}
}
return StatusCode::SUCCESS;
......@@ -87,17 +109,17 @@ StatusCode LArRampAdHocPatchingAlg::stop()
if (m_channelsToBePatchedHG.size()) {
ATH_MSG_INFO ( "Going to apply ad-hoc patches to HIGH gain ramps." );
ATH_CHECK( ApplyAdHocPatches(m_channelsToBePatchedHG,m_patchesToBeAppliedHG,0) );
ATH_CHECK( ApplyAdHocPatches(m_channelsToBePatchedHG,m_patchesToBeAppliedHG,m_valuesToBeAppliedHG, 0) );
}
if (m_channelsToBePatchedMG.size()) {
ATH_MSG_INFO ( "Going to apply ad-hoc patches to MEDIUM gain ramps." );
ATH_CHECK( ApplyAdHocPatches(m_channelsToBePatchedMG,m_patchesToBeAppliedMG,1) );
ATH_CHECK( ApplyAdHocPatches(m_channelsToBePatchedMG,m_patchesToBeAppliedMG,m_valuesToBeAppliedMG,1) );
}
if (m_channelsToBePatchedLG.size()) {
ATH_MSG_INFO ( "Going to apply ad-hoc patches to LOW gain ramps." );
ATH_CHECK( ApplyAdHocPatches(m_channelsToBePatchedLG,m_patchesToBeAppliedLG,2) );
ATH_CHECK( ApplyAdHocPatches(m_channelsToBePatchedLG,m_patchesToBeAppliedLG,m_valuesToBeAppliedLG,2) );
}
ATH_MSG_INFO ( "Done with LArRampAdHocPatchingAlg" );
......@@ -106,20 +128,29 @@ StatusCode LArRampAdHocPatchingAlg::stop()
StatusCode LArRampAdHocPatchingAlg::ApplyAdHocPatches(std::vector<unsigned>& channelsToBePatched , std::vector<unsigned>& patchesToBeApplied, unsigned gain)
StatusCode LArRampAdHocPatchingAlg::ApplyAdHocPatches(std::vector<unsigned>& channelsToBePatched , std::vector<unsigned>& patchesToBeApplied, std::vector<std::vector<double> >& valuesToBeApplied, unsigned gain)
{
if (channelsToBePatched.size() != patchesToBeApplied.size())
return StatusCode::FAILURE;
unsigned putcount=0;
for (unsigned ich=0;ich<channelsToBePatched.size();++ich ) {
const HWIdentifier chid = (HWIdentifier)channelsToBePatched[ich];
// check if the channel to be patched is there...
if (m_contIn->get(chid,gain).isEmpty()) continue;
// ... if so, proceed with ad-hoc patching(s)
const unsigned patchMethod = patchesToBeApplied[ich];
//bool status = false;
switch (patchMethod) {
case ZeroIntercept:
/*status =*/ ZeroTheIntercept(chid,gain);
case ZeroIntercept: {
// check if the channel to be patched is there...
if (m_contIn->get(chid,gain).isEmpty()) continue;
ZeroTheIntercept(chid,gain);
break;
}
case PutValues: {
if ( valuesToBeApplied[putcount].size() == 0 ) return StatusCode::FAILURE;
PutTheValues(chid,valuesToBeApplied[putcount],gain);
++putcount;
break;
}
}
/*
if (status) {
......@@ -156,3 +187,28 @@ bool LArRampAdHocPatchingAlg::ZeroTheIntercept(HWIdentifier chid, unsigned gain)
return true;
}
}
bool LArRampAdHocPatchingAlg::PutTheValues(HWIdentifier chid, std::vector<double>& rvalues, unsigned gain)
{
unsigned s = rvalues.size();
LArRampObj patch;
patch.m_vRamp.clear();
patch.m_vRamp.resize(s);
ATH_MSG_INFO ( "Size of the patched object: "<<s);
if(s==0) return false;
for (unsigned i=0;i<s;++i){ // copy the values
patch.m_vRamp[i] = rvalues[i];
}
StatusCode sc;
try { sc=m_contOut->insertCorrection(chid,patch,gain,m_useCorrChannel);}
catch(...) { ATH_MSG_INFO ("Skipping insert of corrections, maybe it's not about this partition");}
if (sc.isFailure()) {
ATH_MSG_ERROR ( "Failed to put the values for channel 0x"
<< MSG::hex << chid.get_compact() << MSG::dec << ", gain " << gain << "." );
return false;
} else {
ATH_MSG_INFO ( "Successfully put the values for channel 0x"
<< MSG::hex << chid.get_compact() << MSG::dec << ", gain " << gain << "." );
return true;
}
}
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