Skip to content

Commit

Permalink
Merge pull request #15782 from PFCal-dev/hgc-tpg-integration-81X
Browse files Browse the repository at this point in the history
Optimizations of the HGCAL L1 trigger
  • Loading branch information
davidlange6 committed Sep 22, 2016
2 parents 86cd2d7 + f8b46db commit 4b2f7e3
Show file tree
Hide file tree
Showing 33 changed files with 2,058 additions and 475 deletions.
1 change: 0 additions & 1 deletion DataFormats/ForwardDetId/interface/HGCTriggerDetId.h
Expand Up @@ -4,7 +4,6 @@
#include <iosfwd>
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
#include "TObject.h"


class HGCTriggerDetId : public DetId {
Expand Down
1 change: 1 addition & 0 deletions DataFormats/ForwardDetId/interface/HGCalDetId.h
Expand Up @@ -59,6 +59,7 @@ class HGCalDetId : public DetId {
static const HGCalDetId Undefined;
};


std::ostream& operator<<(std::ostream&,const HGCalDetId& id);

#endif
2 changes: 2 additions & 0 deletions DataFormats/ForwardDetId/src/HGCalDetId.cc
Expand Up @@ -63,6 +63,8 @@ bool HGCalDetId::isValid(ForwardSubdetector subdet, int zp, int lay, int waferty
return ok;
}



std::ostream& operator<<(std::ostream& s,const HGCalDetId& id) {
return s << "isHGCal=" << id.isHGCal() << " zpos=" << id.zside()
<< " layer=" << id.layer() << " wafer type=" << id.waferType()
Expand Down
3 changes: 3 additions & 0 deletions DataFormats/L1THGCal/src/classes_def.xml
Expand Up @@ -2,6 +2,7 @@
<class name="l1t::HGCFETriggerDigi" ClassVersion="10">
<version ClassVersion="10" checksum="3197268020"/>
</class>
<class name="std::vector<l1t::HGCFETriggerDigi>"/>
<class name="l1t::HGCFETriggerDigiCollection"/>
<class name="edm::Wrapper<l1t::HGCFETriggerDigiCollection>"/>

Expand All @@ -14,10 +15,12 @@
<class name="edm::Wrapper<l1t::HGCFETriggerDigiPtrVector>"/>

<class name="l1t::HGCalTower" />
<class name="std::vector<l1t::HGCalTower>" />
<class name="l1t::HGCalTowerBxCollection"/>
<class name="edm::Wrapper<l1t::HGCalTowerBxCollection>"/>

<class name="l1t::HGCalCluster" />
<class name="std::vector<l1t::HGCalCluster>" />
<class name="l1t::HGCalClusterBxCollection"/>
<class name="edm::Wrapper<l1t::HGCalClusterBxCollection>"/>

Expand Down
16 changes: 7 additions & 9 deletions L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h
Expand Up @@ -25,8 +25,6 @@

class HGCalTriggerFECodecBase {
public:
typedef HGCalTriggerGeometry::Module Module;

HGCalTriggerFECodecBase(const edm::ParameterSet& conf) :
name_(conf.getParameter<std::string>("CodecName")),
codec_idx_(static_cast<unsigned char>(conf.getParameter<uint32_t>("CodecIndex")))
Expand All @@ -37,13 +35,13 @@ class HGCalTriggerFECodecBase {

const unsigned char getCodecType() const { return codec_idx_; }

// give the FECodec a module + input digis and it sets itself
// give the FECodec the trigger geometry + input digis and it sets itself
// with the approprate data
virtual void setDataPayload(const Module& cell,
virtual void setDataPayload(const HGCalTriggerGeometryBase&,
const HGCEEDigiCollection&,
const HGCHEDigiCollection&,
const HGCHEDigiCollection& ) = 0;
virtual void setDataPayload(const Module& ,
virtual void setDataPayload(const HGCalTriggerGeometryBase& ,
const l1t::HGCFETriggerDigi&) = 0;
virtual void unSetDataPayload() = 0;
// get the set data out for your own enjoyment
Expand Down Expand Up @@ -92,7 +90,7 @@ namespace HGCalTriggerFE {
dataIsSet_ = true;
}

virtual void setDataPayload(const Module& mod,
virtual void setDataPayload(const HGCalTriggerGeometryBase& geom,
const HGCEEDigiCollection& ee,
const HGCHEDigiCollection& fh,
const HGCHEDigiCollection& bh ) override final {
Expand All @@ -101,18 +99,18 @@ namespace HGCalTriggerFE {
<< "Data payload was already set for HGCTriggerFECodec: "
<< this->name() << " overwriting current data!";
}
static_cast<Impl&>(*this).setDataPayloadImpl(mod,ee,fh,bh);
static_cast<Impl&>(*this).setDataPayloadImpl(geom,ee,fh,bh);
dataIsSet_ = true;
}

virtual void setDataPayload(const Module& mod,
virtual void setDataPayload(const HGCalTriggerGeometryBase& geom,
const l1t::HGCFETriggerDigi& digi) override final {
if( dataIsSet_ ) {
edm::LogWarning("HGCalTriggerFECodec|OverwritePayload")
<< "Data payload was already set for HGCTriggerFECodec: "
<< this->name() << " overwriting current data!";
}
static_cast<Impl&>(*this).setDataPayloadImpl(mod,digi);
static_cast<Impl&>(*this).setDataPayloadImpl(geom,digi);
dataIsSet_ = true;
}

Expand Down
208 changes: 53 additions & 155 deletions L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h
Expand Up @@ -13,161 +13,59 @@
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
#include "Geometry/CaloTopology/interface/HGCalTopology.h"

/*******
*
* class: HGCalTriggerGeometryBase
* author: L.Gray (FNAL)
* date: 26 July, 2015
*
* This class is the base class for all HGCal trigger geometry definitions.
* Typically this is just a ganging of cells and nearest-neighbour relationships.
*
* Classes for TriggerCells and Modules are defined. They are containers for
* maps relating modules to modules and trigger cells to trigger cells and
* raw HGC cells.
*
* It is up to the user of the class to define what these mappings are through the
* initialize() function. This function takes the full HGC geometry as input and
* creates all the necessary maps for navigating the trigger system. All of the
* containers for parts of the map are available through protected members of the base
* class.
*
* All unsigned ints used here are DetIds, or will become them once we sort out the
* full nature of the trigger detids.
*******/

class HGCalTriggerGeometryBase;

namespace HGCalTriggerGeometry {
class TriggerCell {
public:
typedef std::unordered_set<unsigned> list_type;

TriggerCell(unsigned tc_id, unsigned mod_id, const GlobalPoint& pos,
const list_type& neighbs, const list_type& comps) :
trigger_cell_id_(tc_id),
module_id_(mod_id),
position_(pos),
neighbours_(neighbs),
components_(comps)
{}
~TriggerCell() {}


unsigned triggerCellId() const { return trigger_cell_id_; }
unsigned moduleId() const { return module_id_; }

bool containsCell(const unsigned cell) const {
return ( components_.find(cell) != components_.end() );
}

const GlobalPoint& position() const { return position_; }

const std::unordered_set<unsigned>& neighbours() const { return neighbours_; }
const std::unordered_set<unsigned>& components() const { return components_; }

private:
unsigned trigger_cell_id_; // the ID of this trigger cell
unsigned module_id_; // module this TC belongs to
GlobalPoint position_;
list_type neighbours_; // neighbouring trigger cells
list_type components_; // contained HGC cells
};

class Module {
public:
typedef std::unordered_set<unsigned> list_type;
typedef std::unordered_multimap<unsigned,unsigned> tc_map_type;

Module(unsigned mod_id, const GlobalPoint& pos,
const list_type& neighbs, const list_type& comps,
const tc_map_type& tc_comps):
module_id_(mod_id),
position_(pos),
neighbours_(neighbs),
components_(comps),
tc_components_(tc_comps)
{}
~Module() {}

unsigned moduleId() const { return module_id_; }

bool containsTriggerCell(const unsigned trig_cell) const {
return ( components_.find(trig_cell) != components_.end() );
}

bool containsCell(const unsigned cell) const {
for( const auto& value : tc_components_ ) {
if( value.second == cell ) return true;
}
return false;
}

const GlobalPoint& position() const { return position_; }

const list_type& neighbours() const { return neighbours_; }
const list_type& components() const { return components_; }

const tc_map_type& triggerCellComponents() const { return tc_components_; }

private:
unsigned module_id_; // module this TC belongs to
GlobalPoint position_;
list_type neighbours_; // neighbouring Modules
list_type components_; // contained HGC trigger cells
tc_map_type tc_components_; // cells contained by trigger cells
};
}

class HGCalTriggerGeometryBase {
public:
struct es_info {
edm::ESHandle<HGCalGeometry> geom_ee, geom_fh, geom_bh;
edm::ESHandle<HGCalTopology> topo_ee, topo_fh, topo_bh;
};

typedef std::unordered_map<unsigned,unsigned> geom_map;
typedef std::unordered_map<unsigned,std::unique_ptr<const HGCalTriggerGeometry::Module> > module_map;
typedef std::unordered_map<unsigned,std::unique_ptr<const HGCalTriggerGeometry::TriggerCell> > trigger_cell_map;

HGCalTriggerGeometryBase(const edm::ParameterSet& conf);
virtual ~HGCalTriggerGeometryBase() {}

const std::string& name() const { return name_; }

const std::string& eeSDName() const { return ee_sd_name_; }
const std::string& fhSDName() const { return fh_sd_name_; }
const std::string& bhSDName() const { return bh_sd_name_; }

// non-const access to the geometry class
virtual void initialize( const es_info& ) = 0;
void reset();

// const access to the geometry class
// all of the get*From* functions return nullptr if the thing you
// ask for doesn't exist
const std::unique_ptr<const HGCalTriggerGeometry::TriggerCell>& getTriggerCellFromCell( const unsigned cell_det_id ) const;
const std::unique_ptr<const HGCalTriggerGeometry::Module>& getModuleFromCell( const unsigned cell_det_id ) const;
const std::unique_ptr<const HGCalTriggerGeometry::Module>& getModuleFromTriggerCell( const unsigned trigger_cell_det_id ) const;

const geom_map& cellsToTriggerCellsMap() const { return cells_to_trigger_cells_; }
const geom_map& triggerCellsToModulesMap() const { return trigger_cells_to_modules_; }

const module_map& modules() const { return modules_; }
const trigger_cell_map& triggerCells() const { return trigger_cells_; }

protected:
geom_map cells_to_trigger_cells_;
geom_map trigger_cells_to_modules_;

module_map modules_;
trigger_cell_map trigger_cells_;

private:
const std::string name_;
const std::string ee_sd_name_;
const std::string fh_sd_name_;
const std::string bh_sd_name_;


// Pure virtual trigger geometry class
// Provides the interface to access trigger cell and module mappings
class HGCalTriggerGeometryBase
{
public:
struct es_info
{
edm::ESHandle<HGCalGeometry> geom_ee, geom_fh, geom_bh;
edm::ESHandle<HGCalTopology> topo_ee, topo_fh, topo_bh;
};

typedef std::unordered_map<unsigned,unsigned> geom_map;
typedef std::unordered_set<unsigned> geom_set;
typedef std::set<unsigned> geom_ordered_set;

HGCalTriggerGeometryBase(const edm::ParameterSet& conf);
virtual ~HGCalTriggerGeometryBase() {}

const std::string& name() const { return name_; }

const std::string& eeSDName() const { return ee_sd_name_; }
const std::string& fhSDName() const { return fh_sd_name_; }
const std::string& bhSDName() const { return bh_sd_name_; }

// non-const access to the geometry class
virtual void initialize( const es_info& ) = 0;
virtual void reset();

// const access to the geometry class
virtual unsigned getTriggerCellFromCell( const unsigned cell_det_id ) const = 0;
virtual unsigned getModuleFromCell( const unsigned cell_det_id ) const = 0;
virtual unsigned getModuleFromTriggerCell( const unsigned trigger_cell_det_id ) const = 0;

virtual geom_set getCellsFromTriggerCell( const unsigned cell_det_id ) const = 0;
virtual geom_set getCellsFromModule( const unsigned cell_det_id ) const = 0;
virtual geom_set getTriggerCellsFromModule( const unsigned trigger_cell_det_id ) const = 0;

virtual geom_ordered_set getOrderedCellsFromModule( const unsigned cell_det_id ) const = 0;
virtual geom_ordered_set getOrderedTriggerCellsFromModule( const unsigned trigger_cell_det_id ) const = 0;

virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const = 0;
virtual GlobalPoint getModulePosition(const unsigned module_det_id) const = 0;


private:
const std::string name_;
const std::string ee_sd_name_;
const std::string fh_sd_name_;
const std::string bh_sd_name_;


};

#include "FWCore/PluginManager/interface/PluginFactory.h"
Expand Down

0 comments on commit 4b2f7e3

Please sign in to comment.