CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SuperClusterImporter.cc
Go to the documentation of this file.
9 
10 // for single tower H/E
12 
13 //quick pT for superclusters
14 inline double ptFast( const double energy,
15  const math::XYZPoint& position,
16  const math::XYZPoint& origin ) {
17  const auto v = position - origin;
18  return energy*std::sqrt(v.perp2()/v.mag2());
19 }
20 
21 #include <unordered_map>
22 
24 public:
26 
27  void updateEventSetup( const edm::EventSetup& es ) override;
28 
29  void importToBlock( const edm::Event& ,
30  ElementList& ) const override;
31 
32 private:
35  const double _maxHoverE, _pTbyPass, _minSCPt;
36  std::unique_ptr<EgammaHadTower> _hadTower;
38  static const math::XYZPoint _zero;
39 };
40 
42 
45  "SuperClusterImporter");
46 
48  edm::ConsumesCollector& sumes) :
49  BlockElementImporterBase(conf,sumes),
50  _srcEB(sumes.consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("source_eb"))),
51  _srcEE(sumes.consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("source_ee"))),
52  _srcTowers(sumes.consumes<CaloTowerCollection>(conf.getParameter<edm::InputTag>("source_towers"))),
53  _maxHoverE(conf.getParameter<double>("maximumHoverE")),
54  _pTbyPass(conf.getParameter<double>("minPTforBypass")),
55  _minSCPt(conf.getParameter<double>("minSuperClusterPt")),
56  _hadTower((EgammaHadTower*)NULL),
57  _superClustersArePF(conf.getParameter<bool>("superClustersArePF")) {
58 }
59 
63 }
64 
70  e.getByToken(_srcEB,eb_scs);
72  e.getByToken(_srcEE,ee_scs);
74  e.getByToken(_srcTowers,towers);
75  _hadTower->setTowerCollection(towers.product());
76  elems.reserve(elems.size()+eb_scs->size()+ee_scs->size());
77  // setup our elements so that all the SCs are grouped together
78  auto SCs_end = std::partition(elems.begin(),elems.end(),
79  [](const ElementType& a){
80  return a->type() == reco::PFBlockElement::SC;
81  });
82  // add eb superclusters
83  auto bsc = eb_scs->cbegin();
84  auto esc = eb_scs->cend();
87  for( auto sc = bsc; sc != esc; ++sc ) {
88  scref = reco::SuperClusterRef(eb_scs,std::distance(bsc,sc));
89  PFBlockElementSCEqual myEqual(scref);
90  auto sc_elem = std::find_if(elems.begin(),SCs_end,myEqual);
91  const double scpT = ptFast(sc->energy(),sc->position(),_zero);
92  const double H_tower = ( _hadTower->getDepth1HcalESum(*sc) +
93  _hadTower->getDepth2HcalESum(*sc) );
94  const double HoverE = H_tower/sc->energy();
95  if( sc_elem == SCs_end && scpT > _minSCPt &&
96  (scpT > _pTbyPass || HoverE < _maxHoverE) ) {
97  scbe = new reco::PFBlockElementSuperCluster(scref);
99  SCs_end = elems.insert(SCs_end,ElementType(scbe));
100  ++SCs_end; // point to element *after* the new one
101  }
102  }// loop on eb superclusters
103  // add ee superclusters
104  bsc = ee_scs->cbegin();
105  esc = ee_scs->cend();
106  for( auto sc = bsc; sc != esc; ++sc ) {
107  scref = reco::SuperClusterRef(ee_scs,std::distance(bsc,sc));
108  PFBlockElementSCEqual myEqual(scref);
109  auto sc_elem = std::find_if(elems.begin(),SCs_end,myEqual);
110  const double scpT = ptFast(sc->energy(),sc->position(),_zero);
111  const double H_tower = ( _hadTower->getDepth1HcalESum(*sc) +
112  _hadTower->getDepth2HcalESum(*sc) );
113  const double HoverE = H_tower/sc->energy();
114  if( sc_elem == SCs_end && scpT > _minSCPt &&
115  (scpT > _pTbyPass || HoverE < _maxHoverE)) {
116  scbe = new reco::PFBlockElementSuperCluster(scref);
118  SCs_end = elems.insert(SCs_end,ElementType(scbe));
119  ++SCs_end; // point to element *after* the new one
120  }
121  }// loop on ee superclusters
122  elems.shrink_to_fit();
123 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< reco::SuperClusterCollection > _srcEE
void importToBlock(const edm::Event &, ElementList &) const override
#define NULL
Definition: scimark2.h:8
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
edm::EDGetTokenT< reco::SuperClusterCollection > _srcEB
double ptFast(const double energy, const math::XYZPoint &position, const math::XYZPoint &origin)
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
SuperClusterImporter(const edm::ParameterSet &, edm::ConsumesCollector &)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
T sqrt(T t)
Definition: SSEVec.h:48
std::unique_ptr< EgammaHadTower > _hadTower
Container::value_type value_type
tuple conf
Definition: dbtoconf.py:185
edm::EDGetTokenT< CaloTowerCollection > _srcTowers
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
_superClustersArePF(conf.getParameter< bool >("superClustersArePF"))
T const * product() const
Definition: Handle.h:81
double a
Definition: hdecay.h:121
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
static const math::XYZPoint _zero
void updateEventSetup(const edm::EventSetup &es) override