52 superClusters->reserve(gsfPfRecTracks->size());
56 std::vector<reco::SuperClusterRef> superClustersValueMap;
60 caloClusters->reserve(ecalClusters->size());
63 std::vector< std::vector<int> > cluster_idx;
64 cluster_idx.reserve( gsfPfRecTracks->size());
67 std::vector< std::vector<int> > pfcluster_idx;
68 pfcluster_idx.reserve( gsfPfRecTracks->size());
71 std::vector< std::vector<float> > cluster_dr2min;
72 cluster_dr2min.reserve( gsfPfRecTracks->size());
75 std::vector< std::vector<const reco::PFTrajectoryPoint*> >
points;
76 points.reserve( gsfPfRecTracks->size());
77 for (
auto const& trk: *gsfPfRecTracks) {
79 std::vector<const reco::PFTrajectoryPoint*> traj;
80 traj.reserve(trk.PFRecBrem().size()+1);
81 traj.push_back( &trk.extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax) );
83 for (
auto const& brem : trk.PFRecBrem() ) {
84 traj.push_back( &brem.extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax) );
86 auto size = traj.size();
89 cluster_idx.emplace_back(
size,-1);
90 pfcluster_idx.emplace_back(
size,-1);
91 cluster_dr2min.emplace_back(
size,1.e6);
95 for (
size_t iclu = 0; iclu < ecalClusters->size(); ++iclu ) {
96 std::pair<int,int>
point = std::make_pair(-1,-1);
99 for (
size_t jpoint = 0; jpoint < points[
ipoint].size(); ++jpoint ) {
100 if ( points[
ipoint][jpoint]->isValid() ) {
101 float dr2 =
reco::deltaR2( ecalClusters->at(iclu), points[
ipoint][jpoint]->positionREP() );
102 if ( dr2 < dr2min ) {
105 point = std::make_pair(
ipoint,jpoint);
110 if ( point.first >= 0 && point.second >= 0 &&
111 dr2min < cluster_dr2min[point.first][point.second] ) {
113 caloClusters->push_back(ecalClusters->at(iclu));
115 cluster_idx[point.first][point.second] = caloClusters->size()-1;
116 pfcluster_idx[point.first][point.second] = iclu;
117 cluster_dr2min[point.first][point.second] = dr2min;
125 for (
size_t itrk = 0; itrk < gsfPfRecTracks->size(); ++itrk ) {
129 float X = 0.,
Y = 0.,
Z = 0.;
132 std::vector<const reco::PFCluster*> barePtrs;
138 if ( cluster_idx[itrk][
ipoint] < 0 ) {
continue; }
139 if ( cluster_dr2min[itrk][
ipoint] < dr2 ) {
140 dr2 = cluster_dr2min[itrk][
ipoint];
141 index = cluster_idx[itrk][
ipoint];
147 if ( cluster_idx[itrk][
ipoint] < 0 ) {
continue; }
149 if ( clu.isNull() ) {
continue; }
150 if ( !( cluster_dr2min[itrk][
ipoint] <
dr2_ ||
151 index == cluster_idx[itrk][
ipoint] ) ) {
continue; }
152 if ( seed.
isNull() ) { seed = clu; }
154 energy += clu->correctedEnergy();
155 X += clu->position().X() * clu->correctedEnergy();
156 Y += clu->position().Y() * clu->correctedEnergy();
157 Z += clu->position().Z() * clu->correctedEnergy();
158 auto index = pfcluster_idx[itrk][
ipoint];
159 if(index <
static_cast<decltype(index)
>(ecalClusters->size())) {
160 barePtrs.push_back(&(*ecalClusters)[index]);
170 sc.setCorrectedEnergy(energy);
172 sc.setClusters(clusters);
174 sc.setEtaWidth(pfwidth.pflowEtaWidth());
175 sc.setPhiWidth(pfwidth.pflowPhiWidth());
177 superClusters->push_back(
sc);
180 superClustersValueMap.push_back(
reco::SuperClusterRef( superClustersRefProd, superClusters->size()-1 ) );
192 filler.insert(gsfPfRecTracks, superClustersValueMap.begin(), superClustersValueMap.end());
const edm::EDGetTokenT< reco::PFClusterCollection > ecalClusters_
void push_back(Ptr< T > const &iPtr)
const edm::EDGetTokenT< reco::GsfPFRecTrackCollection > gsfPfRecTracks_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
bool isNull() const
Checks for null.
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
bool isNonnull() const
Checks for non-null.
ProductID id() const
Accessor for product ID.
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
XYZPointD XYZPoint
point in space with cartesian internal representation
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point