Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
13 #include <Eigen/Dense>
23 ATH_MSG_DEBUG(
"==== LArRampBuilder - looking at SuperCells ====");
27 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
28 return StatusCode::FAILURE;
39 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
40 return StatusCode::FAILURE;
57 m_ramps=std::make_unique<LArConditionsContainer<ACCRAMP> >();
67 return StatusCode::SUCCESS;
77 if (
sc!=StatusCode::SUCCESS) {
81 ATH_MSG_DEBUG(
"LArParabolaPeakRecoTool retrieved with success!");
105 ATH_MSG_DEBUG(
"LArShapePeakRecoTool retrieved with success!");
131 ATH_MSG_ERROR(
"Key list is empty! No containers to process!");
132 return StatusCode::FAILURE;
136 if (
evtStore()->contains<LArFebErrorSummary>(
"LArFebErrorSummary")) {
138 if (
sc.isFailure()) {
139 ATH_MSG_ERROR(
"Failed to retrieve FebErrorSummary object!");
145 ATH_MSG_WARNING(
"No FebErrorSummaryObject found! Feb errors not checked!");
153 return StatusCode::FAILURE;
160 return StatusCode::FAILURE;
165 std::vector<std::string>::const_iterator key_it=
m_keylist.begin();
166 std::vector<std::string>::const_iterator key_it_e=
m_keylist.end();
178 std::vector<double> tempWave;
179 int NSamplesKeep = 8;
180 tempWave.resize(24*NSamplesKeep);
191 sc=
detStore()->retrieve(caliWaveContainer,
"CaliWave");
192 if (
sc.isFailure()) {
193 ATH_MSG_WARNING(
"Cannot read LArCaliWaveContainer from StoreGate for key 'CaliWave' ! ");
194 return StatusCode::FAILURE;
196 ATH_MSG_DEBUG(
"Succefully retrieved LArCaliWaveContainer from StoreGate!");
197 for (;key_it!=key_it_e;++key_it) {
201 if(*key_it ==
"HIGH") {
203 }
else if(*key_it ==
"MEDIUM") {
205 }
else if(*key_it ==
"LOW") {
222 const_iterator itVec = caliWaveContainer->
begin(
gain);
223 const_iterator itVec_e = caliWaveContainer->
end(
gain);
225 for (; itVec != itVec_e; ++itVec) {
228 unsigned int DAC = larCaliWave.getDAC();
232 for(
int i=0;
i<24*NSamplesKeep;
i++){
233 tempWave[
i] = larCaliWave.getSample(
i);
234 if(tempWave[
i]<-500) {
242 m_CaliWaves[gainref][chidwave_hash].push_back(tempWave);
243 m_CaliDACs[gainref][chidwave_hash].push_back(DAC);
258 if (
sc.isFailure()) {
259 ATH_MSG_WARNING(
"Cannot remove LArCaliWaveContainer from StoreGate ! ");
260 return StatusCode::FAILURE;
262 ATH_MSG_DEBUG(
"Successfully removed LArCaliWaveContainer from StoreGate ");
271 for (;key_it!=key_it_e;++key_it) {
273 sc=
evtStore()->retrieve(larAccumulatedCalibDigitContainer,*key_it);
274 if (
sc.isFailure()) {
275 ATH_MSG_WARNING(
"Cannot read LArAccumulatedCalibDigitContainer from StoreGate! key=" << *key_it);
276 if ( (
std::next(key_it) == key_it_e) && foundkey==0 ){
277 ATH_MSG_ERROR(
"None of the provided LArAccumulatedDigitContainer keys could be read");
278 return StatusCode::FAILURE;
286 if(larAccumulatedCalibDigitContainer->
empty()) {
287 ATH_MSG_DEBUG(
"LArAccumulatedCalibDigitContainer with key=" << *key_it <<
" is empty ");
289 ATH_MSG_DEBUG(
"LArAccumulatedCalibDigitContainer with key=" << *key_it <<
" has size " << larAccumulatedCalibDigitContainer->
size());
294 if (!(
digit->isPulsed())){
303 if (febid!=lastFailedFEB) {
306 <<
" reports error(s):" << febErrSum->
error_to_string(febErrs) <<
". Data ignored.");
325 return StatusCode::FAILURE;
338 if (
sc.isFailure()) {
339 ATH_MSG_FATAL(
"No pedestals found in database. Aborting executiong." );
350 <<
". Skipping channel."
357 <<
". Skipping channel."
371 ATH_MSG_ERROR(
"Failed to accumulate sub-steps: Inconsistent number of ADC samples");
374 ATH_MSG_ERROR(
"Failed to accumulate sub-steps: Numeric Overflow");
379 return StatusCode::SUCCESS;
396 std::unique_ptr<LArRampComplete> larRampComplete;
398 larRampComplete=std::make_unique<LArRampComplete>();
410 return StatusCode::FAILURE;
418 return StatusCode::FAILURE;
428 int containerCounter=0;
436 if (cell_it==cell_it_e) {
441 std::unique_ptr<LArRawRampContainer> larRawRampContainer;
443 larRawRampContainer=std::make_unique<LArRawRampContainer>();
447 for (;cell_it!=cell_it_e;cell_it++){
451 ACCRAMP::const_iterator dac_it=cell_it->
begin();
452 ACCRAMP::const_iterator dac_it_e=cell_it->
end();
453 auto rawramp=std::make_unique<LArRawRamp>(chid,
gain);
455 std::vector<float> peak;
456 float adcpeak, timepeak;
457 std::vector<float> adc0v;
458 bool isADCsat =
false;
463 for (;dac_it!=dac_it_e;++dac_it) {
476 if(dac_it!=cell_it->
begin())
477 ATH_MSG_ERROR(
"DAC0 is not the first DAC ? This might be a problem... " );
478 adc0v = dac_it->second.mean();
480 ramppoint.
RMS = dac_it->second.RMS();
481 ramppoint.
NTriggers = dac_it->second.nTriggers();
483 const size_t nS=dac_it->second.nsamples();
484 adc0v.resize(nS,0.0);
486 ramppoint.
RMS.resize(nS);
487 ramppoint.
NTriggers = dac_it->second.nTriggers();
488 for(
size_t k=0;
k<nS;++
k){
489 ramppoint.
Samples[
k]=dac_it->second.mean(
k) - adc0v[
k];
490 ramppoint.
RMS[
k]=dac_it->second.RMS(
k);
503 for (
size_t k=0;
k<ramppoint.
Samples.size();++
k) {
510 unsigned kMax = max_element(ramppoint.
Samples.begin(),ramppoint.
Samples.end()) - ramppoint.
Samples.begin() ;
514 if ( kMax < 2 || kMax+2 >= ramppoint.
Samples.size() ) {
519 if (
cabling->isOnlineConnected(chid) && isgood) {
522 <<
", Amp[2]=" << ramppoint.
Samples[2] <<
" )" );
525 for (
unsigned k=0;
k<ramppoint.
Samples.size();
k++)
554 adcpeak =
results.getAmplitude();
558 ATH_MSG_ERROR(
"LArOFPeak reco tool returns invalid result.");
569 unsigned int GoodIndex = 9999;
573 if(GoodIndex == 9999) {
574 ATH_MSG_WARNING(
"No wave found for cell = " << chid_hash <<
", DAC = " << dac_it->first);
597 peak.push_back(-999);
598 peak.push_back(-999);
626 ATH_MSG_ERROR(
"Both OF and Parabola reconstruction modes not available!" ) ;
627 return StatusCode::FAILURE ;
630 ramppoint.
ADC = adcpeak;
631 ramppoint.
DAC = dac_it->first;
635 const float rinjval = rinj->
Rinj(chid);
636 if(rinjval < 4) ramppoint.
DAC /= 2;
646 if( (dac_it->first>=
m_minDAC) && ramppoint.
ADC > -998
648 rawramp->add(ramppoint);
652 if(ramppoint.
DAC < 200){
663 if (larRampComplete) {
664 std::vector<LArRawRamp::RAMPPOINT_t>&
data=rawramp->theRamp();
666 std::vector<float> rampCoeffs;
667 std::vector<int> vSat;
669 if (
sc!=StatusCode::SUCCESS){
670 if (!
cabling->isOnlineConnected(chid))
679 ATH_MSG_ERROR(
"Negative 1rst order coef for ramp = " << rampCoeffs[1] <<
" for channel "
682 if (vSat[0] != -1) { rawramp->setsat(vSat[0]); }
684 if (isADCsat) { rawramp->setsat(
data.size()-1); }
685 if (!isADCsat) { rawramp->setsat(
data.size()); }
689 larRampComplete->
set(chid,(
int)
gain,rampCoeffs);
694 if (larRawRampContainer){
695 larRawRampContainer->
push_back(std::move(rawramp));
699 if (larRawRampContainer) {
718 if (
sc.isFailure()) {
725 if (containerCounter==0) {
727 return StatusCode::FAILURE;
730 if (larRampComplete){
732 ATH_MSG_INFO(
" Summary : Number of cells with a ramp value computed : " << NRamp );
733 ATH_MSG_INFO(
" Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 = 4096 ");
734 ATH_MSG_INFO(
" Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 = 53248 ");
735 ATH_MSG_INFO(
" Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 = 35328 ");
736 ATH_MSG_INFO(
" Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 = 3072 ");
737 ATH_MSG_INFO(
" Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 = 1792 ");
741 if (
sc.isFailure()) {
745 if (
sc.isFailure()) {
751 return StatusCode::SUCCESS;
756 std::vector<float>& rampCoeffs, std::vector<int>& vSat,
759 unsigned linRange=
data.size();
763 if (
cabling->isOnlineConnected(chid) && isgood ) {
764 ATH_MSG_ERROR(
"Not enough datapoints (" << linRange <<
") to fit a polynom!" );
765 return StatusCode::FAILURE;
768 ATH_MSG_DEBUG(
"Not enough datapoints (" << linRange <<
") to fit a polynom for a disconnected or known bad channel!" );
769 return StatusCode::FAILURE;
775 float thisslope = 0., meanslope = 0.;
776 std::vector<float> accslope;
777 accslope.push_back(0);
778 for (
unsigned int DACIndex=1;DACIndex<linRange;DACIndex++){
779 thisslope = (
data[DACIndex].ADC -
data[DACIndex-1].ADC)/(
data[DACIndex].DAC -
data[DACIndex-1].DAC);
784 }
else { scut = meanslope/10.;}
785 if ( (satpoint == -1) && ((meanslope-thisslope) > scut) ) {
793 meanslope = ( thisslope + (DACIndex-1)*(accslope[DACIndex-1]) )/DACIndex;
794 accslope.push_back(meanslope);
798 if (satpoint != -1) { linRange = satpoint; }
801 vSat.push_back(satpoint);
809 if (
cabling->isOnlineConnected(chid) && isgood )
813 <<
" (channel disconnected or known to be bad)");
815 return StatusCode::FAILURE;
820 <<
". Dead channel?" );
821 return StatusCode::FAILURE;
830 for (
unsigned k=0;
k<
deg;
k++)
831 for (
unsigned j=0;j<=
k;j++)
834 for (
unsigned i=
begin;
i<linRange;
i++)
845 if (
data[
i].NTriggers ) {
847 sigma2 = 100./
data[
i].NTriggers;
865 for (
unsigned k=0;
k<
deg;
k++)
868 for (
unsigned i=
begin;
i<linRange;
i++) {
870 if (
data[
i].NTriggers ) {
871 sigma2 = 100./
data[
i].NTriggers;
882 const Eigen::VectorXd
comp=
alpha.colPivHouseholderQr().solve(
beta);
886 rampCoeffs.push_back(0);
888 for (
int l=0;
l<
comp.size() ;
l++)
889 rampCoeffs.push_back(
comp[
l]);
891 #ifdef LARRAMPBUILDER_DEBUGOUTPUT
894 for (
unsigned i=1;
i<
data.size();
i++)
895 std::cout <<
data[
i].DAC <<
" " <<
data[
i].
ADC <<
" " << std::endl;
896 std::cout <<
"LinRange= " << linRange <<
" satpoint= " << satpoint<<std::endl;
897 for (
unsigned k=0;
k<
deg;
k++) {
898 std::cout<<
"Beta "<<
k<<
" "<<
beta[
k]<<std::endl;
899 for (
unsigned j=0;j<=
k;j++) {
900 std::cout<<
"Alpha "<<j<<
" "<<
alpha(
k,j)<<std::endl;
906 for (
unsigned k=0;
k<linRange;
k++)
907 {
double DACcalc=
comp[0];
908 for (
int i=1;
i<
comp.size();
i++)
916 std::cout <<
"Components: ";
917 for (
int i=0;
i<
comp.size();
i++)
918 std::cout <<
comp[
i] <<
" ";
919 std::cout <<
"sigma=" <<
sigma << std::endl;
920 #undef LARRAMPBUILDER_DEBUGOUTPUT
923 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
IntegerProperty m_deadChannelCut
virtual float pedestal(const HWIdentifier &id, int gain) const =0
Data class for calibration ADC samples preprocessed by the DSP.
char data[hepevt_bytes_allocation_ATLAS]
BooleanProperty m_dac0sub
std::vector< float > m_thePedestal
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Gaudi::Property< bool > m_isSC
Gaudi::Property< std::vector< std::string > > m_keylist
ToolHandle< LArOFPeakRecoTool > m_peakOFTool
const LArEM_ID * em_idHelper() const
access to EM idHelper
BooleanProperty m_withIntercept
ERRTYPE add(const std::vector< short > &digits)
accumulated individual set of digits.
BooleanProperty m_saveRecRamp
std::vector< std::vector< std::vector< std::vector< double > > > > m_CaliWaves
PublicToolHandle< LArParabolaPeakRecoTool > m_peakParabolaTool
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
StatusCode rampfit(unsigned deg, const std::vector< LArRawRamp::RAMPPOINT_t > &data, std::vector< float > &rampCoeffs, std::vector< int > &vSat, const HWIdentifier chid, const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont)
Declaration of const iterator.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Gaudi::Property< std::string > m_groupingType
StatusCode buildBitMask(const std::vector< std::string > &problemsToMask, MsgStream &msg)
value_type get_compact() const
Get the compact id.
bool msgLvl(const MSG::Level lvl) const
const LArEM_Base_ID * m_emId
int sampling(const Identifier id) const
return sampling according to :
Gaudi::Property< std::string > m_keyoutput
virtual const float & Rinj(const HWIdentifier &id) const =0
static std::string error_to_string(uint16_t error)
interpret the error in string
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
StringProperty m_recoTypeProp
bool cellShouldBeMasked(const LArBadChannelCont *bcCont, const HWIdentifier &hardwareId) const
Gaudi::Property< bool > m_iterate
value_type get_compact() const
Get the compact id.
const LArOnlineID_Base * m_onlineHelper
Liquid Argon Cumulative Wave Container.
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
std::vector< std::vector< int > > m_IndexHighestDAC
uint16_t feb_error(HWIdentifier febid) const
get error for feb
Helper class to accumulate calibration triggers.
PublicToolHandle< LArShapePeakRecoTool > m_peakShapeTool
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
virtual bool isHECchannel(const HWIdentifier id) const =0
::StatusCode StatusCode
StatusCode definition for legacy code.
BooleanProperty m_satSlope
Gaudi::Property< bool > m_doBadChannelMask
Default, invalid implementation of ClassID_traits.
uint16_t m_fatalFebErrorPattern
FloatProperty m_delayShift
double delay(std::size_t d)
Helper class for offline cell identifiers.
virtual void set(const HWIdentifier &CellID, int gain, const std::vector< float > &vRamp)
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
UnsignedIntegerProperty m_minDAC
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
Gaudi::Property< std::string > m_hec_key
Gaudi::Property< bool > m_ishec
Helper for the Liquid Argon Calorimeter cell identifiers.
LArBadChannelMask m_bcMask
size_type channelHashMax(void) const
Define channel hash tables max size.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StatusCode initialize(bool used=true)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
std::unique_ptr< LArConditionsContainer< ACCRAMP > > m_ramps
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
#define ATH_MSG_WARNING(x)
Holds information from the FEB Error Summary.
std::vector< float > Samples
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
std::vector< std::vector< int > > m_IndexDAC0
BooleanProperty m_saveRawRamp
std::vector< std::vector< std::vector< unsigned int > > > m_CaliDACs
BooleanProperty m_correctBias
virtual StatusCode stop()
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
Container class for LArAccumulatedCalibDigit.
constexpr int pow(int base, int exp) noexcept
UnsignedIntegerProperty m_DAC0
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
Gaudi::Property< std::vector< std::string > > m_problemsToMask