CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
HcalTTPDigiProducer Class Reference

#include <HcalTTPDigiProducer.h>

Inheritance diagram for HcalTTPDigiProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HcalTTPDigiProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~HcalTTPDigiProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

bool decision (int nP, int nM, int bit)
 
bool isMasked (HcalDetId id)
 

Private Attributes

std::string bit_ [4]
 
int calc_ [4]
 
int fwAlgo_
 
int id_
 
int iEtaMax_
 
int iEtaMin_
 
std::vector< unsigned int > maskedChannels_
 
char mReq_ [4]
 
int nHFm_ [4]
 
int nHFp_ [4]
 
int nHits_ [4]
 
char pmLogic_ [4]
 
char pReq_ [4]
 
int presamples_
 
int samples_
 
int SoI_
 
unsigned int threshold_
 
edm::EDGetTokenT
< HFDigiCollection
tok_hf_
 

Static Private Attributes

static const int inputs_ []
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 11 of file HcalTTPDigiProducer.h.

Constructor & Destructor Documentation

HcalTTPDigiProducer::HcalTTPDigiProducer ( const edm::ParameterSet ps)
explicit

Definition at line 23 of file HcalTTPDigiProducer.cc.

References bit_, calc_, Exception, fwAlgo_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, id_, iEtaMax_, iEtaMin_, maskedChannels_, mReq_, nHFm_, nHFp_, nHits_, pmLogic_, pReq_, presamples_, samples_, SoI_, AlCaHLTBitMon_QueryRunRegistry::string, threshold_, and tok_hf_.

24 {
25  tok_hf_ = consumes<HFDigiCollection>(ps.getParameter<edm::InputTag>("HFDigiCollection"));
26  maskedChannels_ = ps.getParameter< std::vector<unsigned int> >("maskedChannels") ;
27  bit_[0] = ps.getParameter<std::string>("defTT8") ;
28  bit_[1] = ps.getParameter<std::string>("defTT9") ;
29  bit_[2] = ps.getParameter<std::string>("defTT10") ;
30  bit_[3] = ps.getParameter<std::string>("defTTLocal") ;
31 
32  for (int i=0; i<4; i++) {
33  nHits_[i] = -1 ; nHFp_[i] = -1 ; nHFm_[i] = -1 ;
34  pReq_[i] = ' ' ; mReq_[i] = ' ' ; pmLogic_[i] = ' ' ;
35  calc_[i] = sscanf(bit_[i].c_str(),"hits>=%d:hfp%c=%d%chfm%c=%d",
36  &(nHits_[i]),&(pReq_[i]),&(nHFp_[i]),
37  &(pmLogic_[i]),&(mReq_[i]),&(nHFm_[i])) ;
38  if ( calc_[i] == 1 ) {
39  if ( nHits_[i] < 0 )
40  throw cms::Exception("HcalTTPDigiProducer")
41  << "Unable to read logic for technical trigger" ;
42  } else if ( calc_[i] == 6 ) {
43  if ( nHits_[i] < 0 || nHFp_[i] < 0 || nHFm_[i] < 0 )
44  throw cms::Exception("HcalTTPDigiProducer")
45  << "Unable to read logic for technical trigger" ;
46  if ( (pReq_[i] != '>' && pReq_[i] != '<') ||
47  (mReq_[i] != '>' && mReq_[i] != '<') ||
48  (pmLogic_[i] != ':' && pmLogic_[i] != '|') )
49  throw cms::Exception("HcalTTPDigiProducer")
50  << "Technical Trigger logic must obey the following format:\n"
51  "\"hits>=[A1]:hfp[B1]=[A2][C]hfm[B2]=[A3]\",\n"
52  "or \"hits>=[A1]\",\n"
53  "with A# >= 0, B# = (</>) and C = (:/|)" ;
54  } else {
55  throw cms::Exception("HcalTTPDigiProducer")
56  << "Unable to read logic for technical trigger" ;
57  }
58  }
59 
60  id_ = ps.getUntrackedParameter<int>("id",-1) ;
61  samples_ = ps.getParameter<int>("samples") ;
62  presamples_ = ps.getParameter<int>("presamples") ;
63  iEtaMin_ = ps.getParameter<int>("iEtaMin") ;
64  iEtaMax_ = ps.getParameter<int>("iEtaMax") ;
65  threshold_ = ps.getParameter<unsigned int>("threshold") ;
66  fwAlgo_ = ps.getParameter<int>("fwAlgorithm") ;
67 
68  SoI_ = ps.getParameter<int>("HFSoI") ;
69 
70  if ( samples_ > 8 ) {
71  samples_ = 8 ;
72  edm::LogWarning("HcalTTPDigiProducer") << "Samples forced to maximum value of 8" ;
73  }
74  if ( presamples_ - SoI_ > 0 ) { // Too many presamples
75  presamples_ = SoI_ ;
76  edm::LogWarning("HcalTTPDigiProducer") << "Presamples reset to HF SoI value" ;
77  }
78 
79  produces<HcalTTPDigiCollection>();
80 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > maskedChannels_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
HcalTTPDigiProducer::~HcalTTPDigiProducer ( )
default

Member Function Documentation

bool HcalTTPDigiProducer::decision ( int  nP,
int  nM,
int  bit 
)
private

Definition at line 89 of file HcalTTPDigiProducer.cc.

References calc_, edm::false, mReq_, nHFm_, nHFp_, nHits_, pmLogic_, and pReq_.

Referenced by produce().

89  {
90 
91  bool pOK = false ; bool mOK = false ;
92  if ( (nP + nM) < nHits_[bit] ) return false ;
93  if ( calc_[bit] == 1 ) return ( (nP + nM) >= nHits_[bit] ) ;
94 
95  if ( pReq_[bit] == '>' ) pOK = ( nP >= nHFp_[bit] ) ;
96  else if ( pReq_[bit] == '<' ) pOK = ( nP <= nHFp_[bit] ) ;
97 
98  if ( mReq_[bit] == '>' ) mOK = ( nM >= nHFm_[bit] ) ;
99  else if ( mReq_[bit] == '<' ) mOK = ( nM <= nHFm_[bit] ) ;
100 
101  if ( pmLogic_[bit] == ':' ) return ( pOK && mOK ) ;
102  else if ( pmLogic_[bit] == '|' ) return ( pOK || mOK ) ;
103 
104  // Should not ever get here...need to create a warning message
105  edm::LogWarning("HcalTTPDigiProducer") << "Trigger logic exhausted. Returning false" ;
106  return false ;
107 }
volatile std::atomic< bool > shutdown_flag false
bool HcalTTPDigiProducer::isMasked ( HcalDetId  id)
private

Definition at line 82 of file HcalTTPDigiProducer.cc.

References edm::false, i, and maskedChannels_.

Referenced by produce().

82  {
83 
84  for ( unsigned int i=0; i<maskedChannels_.size(); i++ )
85  if ( id.rawId() == maskedChannels_.at(i) ) return true ;
86  return false ;
87 }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > maskedChannels_
volatile std::atomic< bool > shutdown_flag false
void HcalTTPDigiProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 109 of file HcalTTPDigiProducer.cc.

References decision(), fwAlgo_, edm::EventSetup::get(), edm::Event::getByToken(), watchdog::group, i, id_, iEtaMax_, iEtaMin_, inputs_, isMasked(), j, hltrates_dqm_sourceclient-live_cfg::offset, presamples_, edm::Event::put(), samples_, HcalTTPDigi::setSample(), edm::shift, SoI_, threshold_, and tok_hf_.

109  {
110 
111  // Step A: Get Inputs
112  edm::Handle<HFDigiCollection> hfDigiCollection ;
113  e.getByToken(tok_hf_,hfDigiCollection) ;
114  edm::ESHandle<HcalTPGCoder> inputCoder ;
115  eventSetup.get<HcalTPGRecord>().get(inputCoder) ;
116 
117  // Step B: Create empty output
118  std::auto_ptr<HcalTTPDigiCollection> ttpResult(new HcalTTPDigiCollection()) ;
119 
120  // Step C: Compute TTP inputs
121  uint16_t trigInputs[40] ;
122  int nP[8] ; int nM[8] ;
123  for (int i=0; i<8; i++) {
124  nP[i] = 0 ; nM[i] = 0 ;
125  for (int j=0; j<5; j++) trigInputs[j*8+i] = 0 ;
126  }
127  for (HFDigiCollection::const_iterator theDigi=hfDigiCollection->begin();
128  theDigi!=hfDigiCollection->end(); theDigi++) {
129  HcalDetId id = HcalDetId(theDigi->id()) ;
130  if ( isMasked(id) ) continue ;
131  if ( id.ietaAbs() < iEtaMin_ || id.ietaAbs() > iEtaMax_ ) continue ;
132 
133  IntegerCaloSamples samples(id,theDigi->size()) ;
134  inputCoder->adc2Linear(*theDigi,samples) ;
135 
136  for (int relSample=-presamples_; relSample<(samples_-presamples_); relSample++) {
137  if ( samples[SoI_+relSample] >= threshold_ ) {
138  int linSample = presamples_ + relSample ;
139  int offset = (-1+id.zside())/2 ;
140  int shift = inputs_[id.iphi()+offset] ;
141  int group = 0 ;
142  while ( shift >= 16 ) { shift -= 16 ; group++ ; }
143  if ( !(trigInputs[(linSample*8)+group]&(1<<shift)) )
144  ( id.ieta() > 0 ) ? ( nP[linSample]++) : ( nM[linSample]++ ) ;
145  trigInputs[(linSample*8)+group] |= (1<<shift) ;
146  }
147  }
148  }
149 
150  // Step D: Compute trigger decision and fill TTP digi
151  uint8_t trigOutput[8] ;
152  uint32_t algoDepBits[8] ;
154  for (int linSample=0; linSample<8; linSample++) {
155  trigOutput[linSample] = 0 ; algoDepBits[linSample] = 0 ;
156  if ( linSample<samples_) {
157  for (int j=0; j<4; j++)
158  trigOutput[linSample] |= (decision(nP[linSample],nM[linSample],j)<<j) ;
159  int nT = nP[linSample] + nM[linSample] ;
160 
161  // Algorithm Dependent bits for FW flavor = 1
162  // NOTE: this disagrees with the fw var. names that implies (LSB) T,M,P (MSB)
163  if ( fwAlgo_ == 1 ) algoDepBits[linSample] = (nT&0x7F) | ((nP[linSample]&0x3F)<<7) | ((nM[linSample]&0x3F)<<13) ;
164  ttpDigi.setSample((linSample-presamples_),&trigInputs[linSample*8],algoDepBits[linSample],trigOutput[linSample]) ;
165  }
166  }
167  ttpResult->push_back( ttpDigi ) ;
168 
169  // Step E: Put outputs into event
170  e.put(ttpResult);
171 }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< HFDataFrame >::const_iterator const_iterator
bool isMasked(HcalDetId id)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
static const int inputs_[]
int j
Definition: DBlmapReader.cc:9
bool decision(int nP, int nM, int bit)
tuple group
Definition: watchdog.py:82
edm::SortedCollection< HcalTTPDigi > HcalTTPDigiCollection
edm::EDGetTokenT< HFDigiCollection > tok_hf_
static unsigned int const shift

Member Data Documentation

std::string HcalTTPDigiProducer::bit_[4]
private

Definition at line 27 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer().

int HcalTTPDigiProducer::calc_[4]
private

Definition at line 28 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::fwAlgo_
private

Definition at line 32 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::id_
private

Definition at line 31 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::iEtaMax_
private

Definition at line 33 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::iEtaMin_
private

Definition at line 33 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

const int HcalTTPDigiProducer::inputs_
staticprivate
Initial value:
= { 30,66,4,44,4,44,0,68,
0,68,16,48,16,48,6,46,
6,46,2,70,2,70,18,50,
18,50,12,40,12,40,8,52,
8,52,20,36,20,36,14,42,
14,42,10,54,10,54,22,38,
22,38,24,56,24,56,32,60,
32,60,28,64,28,64,26,58,
26,58,34,62,34,62,30,66 }

Definition at line 38 of file HcalTTPDigiProducer.h.

Referenced by produce().

std::vector<unsigned int> HcalTTPDigiProducer::maskedChannels_
private

Definition at line 26 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and isMasked().

char HcalTTPDigiProducer::mReq_[4]
private

Definition at line 30 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::nHFm_[4]
private

Definition at line 29 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::nHFp_[4]
private

Definition at line 29 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::nHits_[4]
private

Definition at line 29 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

char HcalTTPDigiProducer::pmLogic_[4]
private

Definition at line 30 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

char HcalTTPDigiProducer::pReq_[4]
private

Definition at line 30 of file HcalTTPDigiProducer.h.

Referenced by decision(), and HcalTTPDigiProducer().

int HcalTTPDigiProducer::presamples_
private

Definition at line 31 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::samples_
private

Definition at line 31 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

int HcalTTPDigiProducer::SoI_
private

Definition at line 36 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

unsigned int HcalTTPDigiProducer::threshold_
private

Definition at line 34 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().

edm::EDGetTokenT<HFDigiCollection> HcalTTPDigiProducer::tok_hf_
private

Definition at line 25 of file HcalTTPDigiProducer.h.

Referenced by HcalTTPDigiProducer(), and produce().