CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1TStage2Layer1Producer Class Reference
Inheritance diagram for L1TStage2Layer1Producer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TStage2Layer1Producer (const edm::ParameterSet &ps)
 
 ~L1TStage2Layer1Producer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob () override
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &) override
 
virtual void endJob () override
 
virtual void endRun (edm::Run const &, edm::EventSetup const &) override
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

int bxFirst_
 
int bxLast_
 
std::vector< edm::EDGetTokenecalToken_
 
Stage2Layer1FirmwareFactory factory_
 
unsigned fwv_
 
std::vector< edm::EDGetTokenhcalToken_
 
int ietaMax_
 
int ietaMin_
 
int iphiMax_
 
int iphiMin_
 
CaloParamsHelperparams_
 
unsigned long long paramsCacheId_
 
boost::shared_ptr
< Stage2PreProcessor
processor_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 62 of file L1TStage2Layer1Producer.cc.

Constructor & Destructor Documentation

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

Definition at line 103 of file L1TStage2Layer1Producer.cc.

References bxFirst_, bxLast_, ecalToken_, fwv_, edm::ParameterSet::getParameter(), hcalToken_, and params_.

103  :
104  verbosity_(ps.getParameter<int>("verbosity")),
105  bxFirst_(ps.getParameter<int>("bxFirst")),
106  bxLast_(ps.getParameter<int>("bxLast")),
107  ietaMin_(-32),
108  ietaMax_(32),
109  iphiMin_(1),
110  iphiMax_(72),
113  paramsCacheId_(0),
114  params_(0)
115 {
116 
117  // register what you produce
118  produces<CaloTowerBxCollection> ();
119 
120  // register what you consume and keep token for later access:
121  for (int ibx=0; ibx<bxLast_+1-bxFirst_; ibx++) {
122  ecalToken_[ibx] = consumes<EcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("ecalToken"));
123  hcalToken_[ibx] = consumes<HcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("hcalToken"));
124  }
125 
126  // placeholder for the parameters
128 
129  // set firmware version from python config for now
130  fwv_ = ps.getParameter<int>("firmware");
131 
132 }
T getParameter(std::string const &) const
std::vector< edm::EDGetToken > ecalToken_
std::vector< edm::EDGetToken > hcalToken_
L1TStage2Layer1Producer::~L1TStage2Layer1Producer ( )

Definition at line 134 of file L1TStage2Layer1Producer.cc.

References params_.

134  {
135 
136  delete params_;
137 
138 }

Member Function Documentation

void L1TStage2Layer1Producer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 273 of file L1TStage2Layer1Producer.cc.

274 {
275 }
void L1TStage2Layer1Producer::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 284 of file L1TStage2Layer1Producer.cc.

References l1t::Stage2Layer1FirmwareFactory::create(), factory_, fwv_, edm::EventSetup::get(), LogDebug, params_, paramsCacheId_, processor_, edm::ESHandle< class >::product(), and l1t::CaloParamsHelper::~CaloParamsHelper().

285 {
286 
287  // update parameters and algorithms at run start, if they have changed
288  // update params first because the firmware factory relies on pointer to params
289 
290  // parameters
291 
292  unsigned long long id = iSetup.get<L1TCaloParamsRcd>().cacheIdentifier();
293 
294  if (id != paramsCacheId_) {
295 
296  paramsCacheId_ = id;
297 
298  edm::ESHandle<CaloParams> paramsHandle;
299  iSetup.get<L1TCaloParamsRcd>().get(paramsHandle);
300 
301  // replace our local copy of the parameters with a new one using placement new
303  params_ = new (params_) CaloParamsHelper(*paramsHandle.product());
304 
305  LogDebug("L1TDebug") << *params_ << std::endl;
306 
307  if (! params_){
308  edm::LogError("l1t|caloStage2") << "Could not retrieve params from Event Setup" << std::endl;
309  }
310 
311  }
312 
313  // firmware
314 
315  if ( !processor_ ) { // in future, also check if the firmware cache ID has changed !
316 
317  // m_fwv = ; // get new firmware version in future
318 
319  // Set the current algorithm version based on DB pars from database:
321 
322  LogDebug("L1TDebug") << "Processor object : " << (processor_?1:0) << std::endl;
323 
324  if (! processor_) {
325  // we complain here once per run
326  edm::LogError("l1t|caloStage2") << "Layer 1 firmware could not be configured.\n";
327  }
328 
329  }
330 
331 
332 }
#define LogDebug(id)
boost::shared_ptr< Stage2PreProcessor > processor_
Stage2Layer1FirmwareFactory factory_
ReturnType create(unsigned fwv, CaloParamsHelper *params)
T const * product() const
Definition: ESHandle.h:86
void L1TStage2Layer1Producer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 279 of file L1TStage2Layer1Producer.cc.

279  {
280 }
void L1TStage2Layer1Producer::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 337 of file L1TStage2Layer1Producer.cc.

338 {
339 }
void L1TStage2Layer1Producer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 361 of file L1TStage2Layer1Producer.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

361  {
362  //The following says we do not know what parameters are allowed so do no validation
363  // Please change this to state exactly what you do use, even if it is no parameters
365  desc.setUnknown();
366  descriptions.addDefault(desc);
367 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TStage2Layer1Producer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 142 of file L1TStage2Layer1Producer.cc.

References funct::abs(), bxFirst_, bxLast_, ecalToken_, edm::EventSetup::get(), edm::Event::getByToken(), hcalToken_, ietaMax_, ietaMin_, iphiMax_, iphiMin_, LogDebug, params_, processor_, edm::Event::put(), l1t::CaloParamsHelper::towerLsbE(), and l1t::CaloParamsHelper::towerLsbH().

143 {
144 
145  LogDebug("l1t|stage 2") << "L1TStage2Layer1Producer::produce function called..." << std::endl;
146 
147  // do event setup
148  // get RCT input scale objects
150  iSetup.get<L1CaloEcalScaleRcd>().get(ecalScale);
151  // const L1CaloEcalScale* e = ecalScale.product();
152 
154  iSetup.get<L1CaloHcalScaleRcd>().get(hcalScale);
155  // const L1CaloHcalScale* h = hcalScale.product();
156 
157  LogDebug("L1TDebug") << "First BX=" << bxFirst_ << ", last BX=" << bxLast_ << ", LSB(E)=" << params_->towerLsbE() << ", LSB(H)=" << params_->towerLsbH() << std::endl;
158 
159 
160  // output collection
161  std::auto_ptr<CaloTowerBxCollection> towersColl (new CaloTowerBxCollection);
162 
163 
164  // loop over crossings
165  for (int bx = bxFirst_; bx < bxLast_+1; ++bx) {
166 
167  int ibx = bx-bxFirst_;
168 
171 
172  iEvent.getByToken(hcalToken_[ibx], hcalTPs);
173  iEvent.getByToken(ecalToken_[ibx], ecalTPs);
174 
175  // create input and output tower vectors for this BX
176  std::auto_ptr< std::vector<CaloTower> > localInTowers (new std::vector<CaloTower>(CaloTools::caloTowerHashMax()));
177  std::auto_ptr< std::vector<CaloTower> > localOutTowers (new std::vector<CaloTower>()); //this is later filled to the same size as localInTowers
178 
179  // loop over ECAL TPs
181  int nEcal=0;
182  for (ecalItr=ecalTPs->begin(); ecalItr!=ecalTPs->end(); ++ecalItr, ++nEcal) {
183 
184  int ieta = ecalItr->id().ieta();
185  int iphi = ecalItr->id().iphi();
186 
187  int ietIn = ecalItr->compressedEt();
188  bool ifg = ecalItr->fineGrain();
189 
190  // decompress
191  double et = ecalScale->et( ietIn, abs(ieta), (ieta>0) );
192  int ietOut = floor( et / params_->towerLsbE() );
193  // int ietOutMask = (int) pow(2,params_->towerNBitsE())-1;
194 
195  if (ietIn>0)
196  LogDebug("L1TDebug") << " ECAL TP : " << ieta << ", " << iphi << ", " << ietIn << ", " << et << ", " << ietOut << std::endl;
197 
198  int itow = CaloTools::caloTowerHash(ieta, iphi);
199  localInTowers->at(itow).setHwEtEm(ietOut);// & ietOutMask);
200  localInTowers->at(itow).setHwQual( localInTowers->at(itow).hwQual() | (ifg ? 0x4 : 0x0) );
201 
202  }
203 
204  // loop over HCAL TPs
206  int nHcal=0;
207  for (hcalItr=hcalTPs->begin(); hcalItr!=hcalTPs->end(); ++hcalItr, ++nHcal) {
208 
209  int ieta = hcalItr->id().ieta();
210  int iphi = hcalItr->id().iphi();
211 
212  int ietIn = hcalItr->SOI_compressedEt();
213  //int ifg = hcalItr->SOI_fineGrain();
214 
215  // decompress
216  double et = hcalScale->et( ietIn, abs(ieta), (ieta>0) );
217  int ietOut = floor( et / params_->towerLsbH() );
218  // int ietOutMask = (int) pow(2,params_->towerNBitsH() )-1;
219 
220  if (ietIn>0)
221  LogDebug("L1TDebug") << " HCAL TP : " << ieta << ", " << iphi << ", " << ietIn << ", " << et << ", " << ietOut << std::endl;
222 
223  int itow = CaloTools::caloTowerHash(ieta, iphi);
224  localInTowers->at(itow).setHwEtHad(ietOut);// & ietOutMask);
225  // towers.at(itow).setHwFGHad(ifg);
226 
227  }
228 
229  // now calculate remaining tower quantities
230  for (int ieta=ietaMin_; ieta<ietaMax_+1; ieta++) {
231 
232  for (int iphi=iphiMin_; iphi<iphiMax_+1; iphi++) {
233 
234  if(!CaloTools::isValidIEtaIPhi(ieta,iphi)) continue;
235 
236  int itow = CaloTools::caloTowerHash(ieta, iphi);
237 
238  // get ECAL/HCAL raw numbers
239  int ietEcal = localInTowers->at(itow).hwEtEm();
240  int ietHcal = localInTowers->at(itow).hwEtHad();
241 
242  // const LorentzVector& p4;
243  int iet = ietEcal + ietHcal; // this is nonsense, temp solution!
244 
245  //LogDebug("L1TDebug") << " Tower : " << ieta << ", " << iphi << ", " << iet << ", " << ietEcal << ", " << ietHcal << std::endl;
246 
247  localInTowers->at(itow).setHwPt(iet);
248  localInTowers->at(itow).setHwEta(ieta);
249  localInTowers->at(itow).setHwPhi(iphi);
250 
251  }
252  }
253 
254  // do the decompression
255  processor_->processEvent(*localInTowers, *localOutTowers);
256 
257  // copy towers to output collection
258  for(std::vector<CaloTower>::const_iterator tower = localOutTowers->begin();
259  tower != localOutTowers->end();
260  ++tower)
261  towersColl->push_back(ibx, *tower);
262 
263  LogDebug("L1TDebug") << "BX=" << ibx << ", N(Tower in)=" << localInTowers->size() << ", N(Tower out)=" << localOutTowers->size() << std::endl;
264 
265  }
266 
267  iEvent.put(towersColl);
268 
269 }
#define LogDebug(id)
boost::shared_ptr< Stage2PreProcessor > processor_
std::vector< edm::EDGetToken > ecalToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< EcalTriggerPrimitiveDigi >::const_iterator const_iterator
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< edm::EDGetToken > hcalToken_
const T & get() const
Definition: EventSetup.h:56
double towerLsbE() const
double towerLsbH() const

Member Data Documentation

int L1TStage2Layer1Producer::bxFirst_
private

Definition at line 84 of file L1TStage2Layer1Producer.cc.

Referenced by L1TStage2Layer1Producer(), and produce().

int L1TStage2Layer1Producer::bxLast_
private

Definition at line 84 of file L1TStage2Layer1Producer.cc.

Referenced by L1TStage2Layer1Producer(), and produce().

std::vector<edm::EDGetToken> L1TStage2Layer1Producer::ecalToken_
private

Definition at line 87 of file L1TStage2Layer1Producer.cc.

Referenced by L1TStage2Layer1Producer(), and produce().

Stage2Layer1FirmwareFactory L1TStage2Layer1Producer::factory_
private

Definition at line 96 of file L1TStage2Layer1Producer.cc.

Referenced by beginRun().

unsigned L1TStage2Layer1Producer::fwv_
private

Definition at line 92 of file L1TStage2Layer1Producer.cc.

Referenced by beginRun(), and L1TStage2Layer1Producer().

std::vector<edm::EDGetToken> L1TStage2Layer1Producer::hcalToken_
private

Definition at line 88 of file L1TStage2Layer1Producer.cc.

Referenced by L1TStage2Layer1Producer(), and produce().

int L1TStage2Layer1Producer::ietaMax_
private

Definition at line 85 of file L1TStage2Layer1Producer.cc.

Referenced by produce().

int L1TStage2Layer1Producer::ietaMin_
private

Definition at line 85 of file L1TStage2Layer1Producer.cc.

Referenced by produce().

int L1TStage2Layer1Producer::iphiMax_
private

Definition at line 85 of file L1TStage2Layer1Producer.cc.

Referenced by produce().

int L1TStage2Layer1Producer::iphiMin_
private

Definition at line 85 of file L1TStage2Layer1Producer.cc.

Referenced by produce().

CaloParamsHelper* L1TStage2Layer1Producer::params_
private
unsigned long long L1TStage2Layer1Producer::paramsCacheId_
private

Definition at line 91 of file L1TStage2Layer1Producer.cc.

Referenced by beginRun().

boost::shared_ptr<Stage2PreProcessor> L1TStage2Layer1Producer::processor_
private

Definition at line 97 of file L1TStage2Layer1Producer.cc.

Referenced by beginRun(), and produce().

int L1TStage2Layer1Producer::verbosity_
private

Definition at line 82 of file L1TStage2Layer1Producer.cc.