CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFEcalRecHitCreator.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFEcalRecHitCreator_h
2 #define RecoParticleFlow_PFClusterProducer_PFEcalRecHitCreator_h
3 
8 
11 
12 
18 
25 
26 template <typename Geometry,PFLayer::Layer Layer,int Detector>
28 
29  public:
31  PFRecHitCreatorBase(iConfig,iC)
32  {
34  }
35 
36  void importRecHits(std::auto_ptr<reco::PFRecHitCollection>&out,std::auto_ptr<reco::PFRecHitCollection>& cleaned ,const edm::Event& iEvent,const edm::EventSetup& iSetup) {
37 
38  for (unsigned int i=0;i<qualityTests_.size();++i) {
39  qualityTests_.at(i)->beginEvent(iEvent,iSetup);
40  }
41 
42 
44 
46  iSetup.get<CaloGeometryRecord>().get(geoHandle);
47 
48  // get the ecal geometry
49  const CaloSubdetectorGeometry *gTmp =
50  geoHandle->getSubdetectorGeometry(DetId::Ecal, Detector);
51 
52  const Geometry *ecalGeo =dynamic_cast< const Geometry* > (gTmp);
53 
54  iEvent.getByToken(recHitToken_,recHitHandle);
55  for(const auto& erh : *recHitHandle ) {
56  const DetId& detid = erh.detid();
57  double energy = erh.energy();
58  double time = erh.time();
59 
61  math::XYZVector axis;
62 
63  const CaloCellGeometry *thisCell;
64  thisCell= ecalGeo->getGeometry(detid);
65 
66  // find rechit geometry
67  if(!thisCell) {
68  edm::LogError("PFEcalRecHitCreator")
69  <<"warning detid "<<detid.rawId()
70  <<" not found in geometry"<<std::endl;
71  continue;
72  }
73 
74  position.SetCoordinates ( thisCell->getPosition().x(),
75  thisCell->getPosition().y(),
76  thisCell->getPosition().z() );
77 
78  // the axis vector is the difference
79  const TruncatedPyramid* pyr
80  = dynamic_cast< const TruncatedPyramid* > (thisCell);
81 
82 
83  if( pyr ) {
84  axis.SetCoordinates( pyr->getPosition(1).x(),
85  pyr->getPosition(1).y(),
86  pyr->getPosition(1).z() );
87 
88  math::XYZVector axis0( pyr->getPosition(0).x(),
89  pyr->getPosition(0).y(),
90  pyr->getPosition(0).z() );
91 
92  axis -= axis0;
93  }
94  else continue;
95 
96  reco::PFRecHit rh( detid.rawId(),Layer,
97  energy,
98  position.x(), position.y(), position.z(),
99  axis.x(), axis.y(), axis.z() );
100 
101 
102 
103  const CaloCellGeometry::CornersVec& corners = thisCell->getCorners();
104  assert( corners.size() == 8 );
105 
106  rh.setNECorner( corners[0].x(), corners[0].y(), corners[0].z() );
107  rh.setSECorner( corners[1].x(), corners[1].y(), corners[1].z() );
108  rh.setSWCorner( corners[2].x(), corners[2].y(), corners[2].z() );
109  rh.setNWCorner( corners[3].x(), corners[3].y(), corners[3].z() );
110 
111 
112  bool rcleaned = false;
113  bool keep=true;
114 
115  //Apply Q tests
116  for( const auto& qtest : qualityTests_ ) {
117  if (!qtest->test(rh,erh,rcleaned)) {
118  keep = false;
119  }
120  }
121 
122  if(keep) {
123  rh.setTime(time);
124  out->push_back(rh);
125  }
126  else if (rcleaned)
127  cleaned->push_back(rh);
128  }
129  }
130 
131 
132 
133  protected:
135 
136 
137 };
138 
139 
142 
143 #endif
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
void importRecHits(std::auto_ptr< reco::PFRecHitCollection > &out, std::auto_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
T y() const
Definition: PV3DBase.h:63
float float float z
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const int keep
PFEcalRecHitCreator< EcalEndcapGeometry, PFLayer::ECAL_ENDCAP, EcalEndcap > PFEERecHitCreator
int iEvent
Definition: GenABIO.cc:230
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:35
edm::EDGetTokenT< EcalRecHitCollection > recHitToken_
T z() const
Definition: PV3DBase.h:64
tuple out
Definition: dbtoconf.py:99
Definition: DetId.h:18
const GlobalPoint getPosition(CCGFloat depth) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
const T & get() const
Definition: EventSetup.h:55
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
static int position[264][3]
Definition: ReadPGInfo.cc:509
PFEcalRecHitCreator< EcalBarrelGeometry, PFLayer::ECAL_BARREL, EcalBarrel > PFEBRecHitCreator
PFEcalRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
Definition: DDAxes.h:10
const CornersVec & getCorners() const
Returns the corner points of this cell&#39;s volume.
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
T x() const
Definition: PV3DBase.h:62