Skip to content

Commit

Permalink
Merge pull request cms-sw#67 from jbsauvan/triggercell-dataformat-pre9
Browse files Browse the repository at this point in the history
Triggercell dataformat (pre9 backport)
  • Loading branch information
jbsauvan committed Oct 14, 2016
2 parents 813a636 + 7b72ced commit 9e9d219
Show file tree
Hide file tree
Showing 21 changed files with 1,253 additions and 37 deletions.
4 changes: 2 additions & 2 deletions DataFormats/L1THGCal/interface/HGCFETriggerDigi.h
Expand Up @@ -75,7 +75,7 @@ namespace l1t {
<< " given to data encoded with HGC codec type: "
<< codec_ << std::dec;
}
data = codec.decode(data_);
data = codec.decode(data_, detid_);
}

void print(std::ostream& out) const;
Expand All @@ -96,7 +96,7 @@ namespace l1t {
<< " given to data encoded with HGC codec type: "
<< codec_;
}
out << codec.decode(data_);
out << codec.decode(data_, detid_);
out << std::endl << " decoded from: " << std::endl;
this->print(out);
}
Expand Down
41 changes: 41 additions & 0 deletions DataFormats/L1THGCal/interface/HGCalTriggerCell.h
@@ -0,0 +1,41 @@
#ifndef DataFormats_L1TCalorimeter_HGCalTriggerCell_h
#define DataFormats_L1TCalorimeter_HGCalTriggerCell_h


#include "DataFormats/L1Trigger/interface/L1Candidate.h"
#include "DataFormats/L1Trigger/interface/BXVector.h"

namespace l1t
{

class HGCalTriggerCell;
typedef BXVector<HGCalTriggerCell> HGCalTriggerCellBxCollection;

class HGCalTriggerCell : public L1Candidate
{

public:

HGCalTriggerCell() {}

HGCalTriggerCell( const LorentzVector& p4,
int pt=0,
int eta=0,
int phi=0,
int qual=0,
uint32_t detid=0);

~HGCalTriggerCell();

void setDetId(uint32_t detid) {detid_ = detid;}

uint32_t detId() const {return detid_;}

private:
uint32_t detid_;

};

}

#endif
20 changes: 20 additions & 0 deletions DataFormats/L1THGCal/src/HGCalTriggerCell.cc
@@ -0,0 +1,20 @@
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"

using namespace l1t;

HGCalTriggerCell::
HGCalTriggerCell( const LorentzVector& p4,
int pt,
int eta,
int phi,
int qual,
uint32_t detid):
L1Candidate(p4, pt, eta, phi, qual),
detid_(detid)
{
}

HGCalTriggerCell::
~HGCalTriggerCell()
{
}
3 changes: 3 additions & 0 deletions DataFormats/L1THGCal/src/classes.h
Expand Up @@ -3,6 +3,7 @@

#include "DataFormats/L1THGCal/interface/HGCalCluster.h"
#include "DataFormats/L1THGCal/interface/HGCalTower.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"

namespace DataFormats {
namespace L1THGCal {
Expand All @@ -21,8 +22,10 @@ namespace DataFormats {

l1t::HGCalTowerBxCollection hgcalTowerBxColl;
l1t::HGCalClusterBxCollection hgcalClusterBxColl;
l1t::HGCalTriggerCellBxCollection hgcalTriggerCellBxColl;

edm::Wrapper<l1t::HGCalTowerBxCollection> w_hgcalTowerBxColl;
edm::Wrapper<l1t::HGCalClusterBxCollection> w_hgcalClusterBxColl;
edm::Wrapper<l1t::HGCalTriggerCellBxCollection> w_hgcalTriggerCellBxColl;
}
}
5 changes: 5 additions & 0 deletions DataFormats/L1THGCal/src/classes_def.xml
Expand Up @@ -24,4 +24,9 @@
<class name="l1t::HGCalClusterBxCollection"/>
<class name="edm::Wrapper<l1t::HGCalClusterBxCollection>"/>

<class name="l1t::HGCalTriggerCell" />
<class name="std::vector<l1t::HGCalTriggerCell>" />
<class name="l1t::HGCalTriggerCellBxCollection"/>
<class name="edm::Wrapper<l1t::HGCalTriggerCellBxCollection>"/>

</lcgdict>
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/BuildFile.xml
@@ -1,5 +1,6 @@
<use name="Geometry/HGCalGeometry"/>
<use name="Geometry/CaloTopology"/>
<use name="DataFormats/L1THGCal"/>

<export>
<lib name="1"/>
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h
Expand Up @@ -132,8 +132,8 @@ namespace HGCalTriggerFE {
return static_cast<const Impl&>(*this).encodeImpl(data);
}

DATA decode(const std::vector<bool>& data) const {
return static_cast<const Impl&>(*this).decodeImpl(data);
DATA decode(const std::vector<bool>& data, const uint32_t module=0) const {
return static_cast<const Impl&>(*this).decodeImpl(data, module);
}

protected:
Expand Down
Expand Up @@ -29,7 +29,7 @@ class HGCal64BitRandomCodec : public HGCalTriggerFE::Codec<HGCal64BitRandomCodec
void setDataPayloadImpl(const l1t::HGCFETriggerDigi& digi);

std::vector<bool> encodeImpl(const data_type&) const ;
data_type decodeImpl(const std::vector<bool>&) const;
data_type decodeImpl(const std::vector<bool>&, const uint32_t) const;

private:
HGCal64BitRandomCodecImpl codecImpl_;
Expand Down
Expand Up @@ -30,7 +30,7 @@ class HGCalBestChoiceCodec : public HGCalTriggerFE::Codec<HGCalBestChoiceCodec,H
void setDataPayloadImpl(const l1t::HGCFETriggerDigi& digi);

std::vector<bool> encodeImpl(const data_type&) const ;
data_type decodeImpl(const std::vector<bool>&) const;
data_type decodeImpl(const std::vector<bool>&, const uint32_t) const;

private:
HGCalBestChoiceCodecImpl codecImpl_;
Expand Down
@@ -0,0 +1,40 @@
#ifndef __L1Trigger_L1THGCal_HGCalTriggerCellBestChoiceCodec_h__
#define __L1Trigger_L1THGCal_HGCalTriggerCellBestChoiceCodec_h__

#include "L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h"
#include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellBestChoiceCodecImpl.h"


inline std::ostream& operator<<(std::ostream& o, const HGCalTriggerCellBestChoiceDataPayload& data)
{
for(const auto& dat : data.payload)
{
o << "(" << std::hex << dat.detId()
<< std::dec << " " << dat.hwPt() << ") ";
}
o << "\n";
return o;
}


class HGCalTriggerCellBestChoiceCodec : public HGCalTriggerFE::Codec<HGCalTriggerCellBestChoiceCodec,HGCalTriggerCellBestChoiceDataPayload>
{
public:
typedef HGCalTriggerCellBestChoiceDataPayload data_type;

HGCalTriggerCellBestChoiceCodec(const edm::ParameterSet& conf);

void setDataPayloadImpl(const HGCEEDigiCollection& ee,
const HGCHEDigiCollection& fh,
const HGCHEDigiCollection& bh );

void setDataPayloadImpl(const l1t::HGCFETriggerDigi& digi);

std::vector<bool> encodeImpl(const data_type&) const ;
data_type decodeImpl(const std::vector<bool>&, const uint32_t) const;

private:
HGCalTriggerCellBestChoiceCodecImpl codecImpl_;
};

#endif
@@ -0,0 +1,76 @@
#ifndef __L1Trigger_L1THGCal_HGCalTriggerCellBestChoiceCodecImpl_h__
#define __L1Trigger_L1THGCal_HGCalTriggerCellBestChoiceCodecImpl_h__


#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
#include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"

#include <array>
#include <vector>


struct HGCalTriggerCellBestChoiceDataPayload
{
typedef std::vector<l1t::HGCalTriggerCell> trigger_cell_list; // list of trigger cell
trigger_cell_list payload;

void reset()
{
payload.clear();
}
};



class HGCalTriggerCellBestChoiceCodecImpl
{
public:
typedef HGCalTriggerCellBestChoiceDataPayload data_type;

HGCalTriggerCellBestChoiceCodecImpl(const edm::ParameterSet& conf);

std::vector<bool> encode(const data_type&, const HGCalTriggerGeometryBase&) const ;
data_type decode(const std::vector<bool>&, const uint32_t, const HGCalTriggerGeometryBase&) const;

void linearize(const std::vector<HGCDataFrame<HGCalDetId,HGCSample>>&,
std::vector<std::pair<HGCalDetId, uint32_t > >&);

void triggerCellSums(const HGCalTriggerGeometryBase& ,
const std::vector<std::pair<HGCalDetId, uint32_t > >&,
data_type&);
void bestChoiceSelect(data_type&);

// Retrieve parameters
size_t nCellsInModule() const {return nCellsInModule_;}
size_t nData() const {return nData_;}
size_t dataLength() const {return dataLength_;}
double linLSB() const {return linLSB_;}
double adcsaturation() const {return adcsaturation_;}
uint32_t adcnBits() const {return adcnBits_;}
double tdcsaturation() const {return tdcsaturation_;}
uint32_t tdcnBits() const {return tdcnBits_;}
double tdcOnsetfC() const {return tdcOnsetfC_;}
uint32_t triggerCellTruncationBits() const {return triggerCellTruncationBits_;}
uint32_t triggerCellSaturationBits() const {return triggerCellSaturationBits_;}


private:
size_t nData_;
size_t dataLength_;
size_t nCellsInModule_;
double linLSB_;
double adcsaturation_;
uint32_t adcnBits_;
double tdcsaturation_ ;
uint32_t tdcnBits_ ;
double tdcOnsetfC_ ;
double adcLSB_;
double tdcLSB_;
uint32_t triggerCellTruncationBits_;
uint32_t triggerCellSaturationBits_;

};

#endif
18 changes: 10 additions & 8 deletions L1Trigger/L1THGCal/plugins/be_algorithms/FullModuleSumAlgo.cc
@@ -1,17 +1,17 @@
#include "L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h"
#include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalBestChoiceCodec.h"
#include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellBestChoiceCodec.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"

#include "DataFormats/L1THGCal/interface/HGCalCluster.h"

using namespace HGCalTriggerBackend;

class FullModuleSumAlgo : public Algorithm<HGCalBestChoiceCodec>
class FullModuleSumAlgo : public Algorithm<HGCalTriggerCellBestChoiceCodec>
{
public:

FullModuleSumAlgo(const edm::ParameterSet& conf):
Algorithm<HGCalBestChoiceCodec>(conf),
Algorithm<HGCalTriggerCellBestChoiceCodec>(conf),
cluster_product_( new l1t::HGCalClusterBxCollection ){}

virtual void setProduces(edm::EDProducer& prod) const override final
Expand Down Expand Up @@ -42,22 +42,24 @@ void FullModuleSumAlgo::run(const l1t::HGCFETriggerDigiCollection& coll)
{
for( const auto& digi : coll )
{
HGCalBestChoiceCodec::data_type data;
HGCalTriggerCellBestChoiceCodec::data_type data;
data.reset();
const HGCalDetId& moduleId = digi.getDetId<HGCalDetId>();
digi.decode(codec_, data);

// Sum of trigger cells inside the module
uint32_t moduleSum = 0;
for(const auto& value : data.payload)
for(const auto& triggercell : data.payload)
{
moduleSum += value;
moduleSum += triggercell.hwPt();
}
// dummy cluster without position
// moduleId filled in place of hardware eta
l1t::HGCalCluster cluster( reco::LeafCandidate::LorentzVector(),
moduleSum, moduleId, 0);

moduleSum, 0, 0);
cluster.setModule(moduleId.wafer());
cluster.setLayer(moduleId.layer());
cluster.setSubDet(moduleId.subdetId());
cluster_product_->push_back(0,cluster);
}
}
Expand Down
31 changes: 13 additions & 18 deletions L1Trigger/L1THGCal/plugins/be_algorithms/SingleCellClusterAlgo.cc
@@ -1,17 +1,17 @@
#include "L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h"
#include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalBestChoiceCodec.h"
#include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellBestChoiceCodec.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"

#include "DataFormats/L1THGCal/interface/HGCalCluster.h"

using namespace HGCalTriggerBackend;

class SingleCellClusterAlgo : public Algorithm<HGCalBestChoiceCodec>
class SingleCellClusterAlgo : public Algorithm<HGCalTriggerCellBestChoiceCodec>
{
public:

SingleCellClusterAlgo(const edm::ParameterSet& conf):
Algorithm<HGCalBestChoiceCodec>(conf),
Algorithm<HGCalTriggerCellBestChoiceCodec>(conf),
cluster_product_( new l1t::HGCalClusterBxCollection ){}

virtual void setProduces(edm::EDProducer& prod) const override final
Expand Down Expand Up @@ -42,28 +42,23 @@ void SingleCellClusterAlgo::run(const l1t::HGCFETriggerDigiCollection& coll)
{
for( const auto& digi : coll )
{
HGCalBestChoiceCodec::data_type data;
HGCalDetId module_id(digi.id());
HGCalTriggerCellBestChoiceCodec::data_type data;
data.reset();
const HGCalDetId& moduleId = digi.getDetId<HGCalDetId>();
digi.decode(codec_, data);
int i = 0;
for(const auto& value : data.payload)
for(const auto& triggercell : data.payload)
{
if(value>0)
if(triggercell.hwPt()>0)
{
GlobalPoint point = geometry_->getModulePosition(moduleId);
math::PtEtaPhiMLorentzVector p4((double)value/cosh(point.eta()), point.eta(), point.phi(), 0.);
// index in module stored as hwEta
HGCalDetId detid(triggercell.detId());
l1t::HGCalCluster cluster(
reco::LeafCandidate::LorentzVector(),
value, i, 0);
cluster.setP4(p4);
cluster.setModule(moduleId.wafer());
cluster.setLayer(moduleId.layer());
cluster.setSubDet(moduleId.subdetId());
triggercell.p4(),
triggercell.hwPt(), 0, 0);
cluster.setModule(module_id.wafer());
cluster.setLayer(detid.layer());
cluster.setSubDet(detid.subdetId());
cluster_product_->push_back(0,cluster);
}
i++;
}

}
Expand Down
Expand Up @@ -26,7 +26,7 @@ encodeImpl(const HGCal64BitRandomCodec::data_type& data) const {

HGCal64BitRandomCodec::data_type
HGCal64BitRandomCodec::
decodeImpl(const std::vector<bool>& data) const {
decodeImpl(const std::vector<bool>& data, const uint32_t) const {
return codecImpl_.decode(data);
}

Expand Down
Expand Up @@ -95,7 +95,7 @@ std::vector<bool> HGCalBestChoiceCodec::encodeImpl(const HGCalBestChoiceCodec::d
}

/*****************************************************************/
HGCalBestChoiceCodec::data_type HGCalBestChoiceCodec::decodeImpl(const std::vector<bool>& data) const
HGCalBestChoiceCodec::data_type HGCalBestChoiceCodec::decodeImpl(const std::vector<bool>& data, const uint32_t) const
/*****************************************************************/
{
return codecImpl_.decode(data);
Expand Down

0 comments on commit 9e9d219

Please sign in to comment.