215 std::unique_ptr< EBRecHitCollection > selEBRecHitCollection(
new EBRecHitCollection );
217 std::unique_ptr< EERecHitCollection > selEERecHitCollection(
new EERecHitCollection );
221 vector<DetId> selectedEBDetIds;
222 vector<DetId> selectedEEDetIds;
234 std::unique_ptr<CaloSubdetectorTopology> topology_es;
236 topology_es = std::make_unique<EcalPreshowerTopology>();
252 if (!barrelRecHitsHandle.
isValid()) {
253 LogDebug(
"") <<
"AlCaEcalResonanceProducer: Error! can't get product barrel hits!" << std::endl;
261 if (!barrelClustersHandle.
isValid()) {
262 LogDebug(
"") <<
"AlCaEcalResonanceProducer: Error! can't get product barrel clusters!" << std::endl;
265 if(
debug_>=1)
LogDebug(
"")<<
" barrel_input_size: run "<<iEvent.
id().
run()<<
" event "<<iEvent.
id().
event()<<
" nhitEB: "<<hitCollection_eb->
size()<<
" nCluster: "<< clusterCollection_eb->size() <<endl;
270 map<int, vector<EcalRecHit> > RecHits5x5_clus;
271 vector<int> indIsoClus;
272 vector<int> indCandClus;
273 vector<int> indClusSelected;
277 indCandClus,indIsoClus, indClusSelected);
281 for(
int ind : indClusSelected){
282 auto it_bc3 = clusterCollection_eb->begin() + ind;
283 const std::vector< std::pair<DetId, float> > &
vid = it_bc3->hitsAndFractions();
284 for (
auto const & idItr : vid){
285 auto hit = hitCollection_eb->
find(idItr.first);
286 if(
hit == hitCollection_eb->
end())
continue;
287 selEBRecHitCollection->push_back(*
hit);
288 selectedEBDetIds.push_back(idItr.first);
295 for(
int ind : indCandClus){
296 vector<EcalRecHit> v5x5 = RecHits5x5_clus[ind];
297 for(
auto &
n : v5x5){
299 auto itdet =
find(selectedEBDetIds.begin(),selectedEBDetIds.end(),ed);
300 if( itdet == selectedEBDetIds.end()){
301 selectedEBDetIds.push_back(ed);
302 selEBRecHitCollection->push_back(
n);
309 for(
int ind : indIsoClus){
310 auto it =
find(indCandClus.begin(),indCandClus.end(), ind);
311 if( it != indCandClus.end())
continue;
313 auto it_bc3 = clusterCollection_eb->begin() + ind;
314 DetId seedId = it_bc3->seed();
315 std::vector<DetId> clus_v5x5 = topology_eb->
getWindow(seedId,5,5);
316 for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
318 auto rit = hitCollection_eb->
find( ed );
319 if ( rit == hitCollection_eb->
end() )
continue;
321 auto itdet =
find(selectedEBDetIds.begin(),selectedEBDetIds.end(),ed);
322 if( itdet == selectedEBDetIds.end()){
323 selectedEBDetIds.push_back(ed);
324 selEBRecHitCollection->push_back(*rit);
333 int eb_collsize = selEBRecHitCollection->size();
335 if(
debug_>=1)
LogDebug(
"")<<
" barrel_output_size_run "<<iEvent.
id().
run()<<
" event "<<iEvent.
id().
event()<<
" nEBSaved "<<selEBRecHitCollection->size()<<std::endl;
344 if( !esRecHitsHandle.
isValid()){
345 LogDebug(
"") <<
"AlCaEcalResonanceProducer: Error! can't get product esRecHit!" << std::endl;
351 for (iter = esRecHitsHandle->
begin(); iter != esRecHitsHandle->
end(); iter++) {
361 if (!endcapRecHitsHandle.
isValid()) {
362 LogDebug(
"") <<
"AlCaEcalResonanceProducer: Error! can't get product endcap hits!" << std::endl;
367 if (!endcapClustersHandle.
isValid()) {
368 LogDebug(
"") <<
"AlCaEcalResonanceProducer: Error! can't get product endcap clusters!" << std::endl;
371 if(
debug_>=1)
LogDebug(
"")<<
" endcap_input_size: run "<<iEvent.
id().
run()<<
" event "<<iEvent.
id().
event()<<
" nhitEE: "<<hitCollection_ee->
size()<<
" nhitES: "<<hitCollection_es->
size()<<
" nCluster: "<< clusterCollection_ee->size() <<endl;
376 map<int, vector<EcalRecHit> > RecHits5x5_clus;
377 vector<int> indIsoClus;
378 vector<int> indCandClus;
379 vector<int> indClusSelected;
383 indCandClus,indIsoClus, indClusSelected);
386 for(
int ind : indClusSelected){
387 auto it_bc3 = clusterCollection_ee->begin() + ind;
388 const std::vector< std::pair<DetId, float> > &vid = it_bc3->hitsAndFractions();
389 for (
auto const & idItr : vid){
390 auto hit = hitCollection_ee->
find(idItr.first);
391 if(
hit == hitCollection_ee->
end())
continue;
392 selEERecHitCollection->push_back(*
hit);
393 selectedEEDetIds.push_back(idItr.first);
398 makeClusterES(it_bc3->x(),it_bc3->y(),it_bc3->z(),geometry_es,topology_es.get());
402 auto ites2 =
find(used_strips_before.begin(),used_strips_before.end(),d1);
403 if( (ites2 == used_strips_before.end())){
405 selESRecHitCollection->push_back(itmap->second);
414 for(
int ind : indCandClus){
415 vector<EcalRecHit> v5x5 = RecHits5x5_clus[ind];
416 for(
auto &
n : v5x5){
418 auto itdet =
find(selectedEEDetIds.begin(),selectedEEDetIds.end(),ed);
419 if( itdet == selectedEEDetIds.end()){
420 selectedEEDetIds.push_back(ed);
421 selEERecHitCollection->push_back(
n);
428 for(
int ind : indIsoClus){
429 auto it =
find(indCandClus.begin(),indCandClus.end(), ind);
430 if( it != indCandClus.end())
continue;
432 auto it_bc3 = clusterCollection_ee->begin() + ind;
433 DetId seedId = it_bc3->seed();
434 std::vector<DetId> clus_v5x5 = topology_ee->
getWindow(seedId,5,5);
435 for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
437 auto rit = hitCollection_ee->
find( ed );
438 if ( rit == hitCollection_ee->
end() )
continue;
440 auto itdet =
find(selectedEEDetIds.begin(),selectedEEDetIds.end(),ed);
441 if( itdet == selectedEEDetIds.end()){
442 selectedEEDetIds.push_back(ed);
443 selEERecHitCollection->push_back(*rit);
455 if(
debug_>=1)
LogDebug(
"")<<
" endcap_output_size run "<<iEvent.
id().
run()<<
"_"<<iEvent.
id().
event()<<
" nEESaved "<<selEERecHitCollection->size()<<
" nESSaved: " << selESRecHitCollection->size() <<endl;
459 int ee_collsize = selEERecHitCollection->size();
461 if( eb_collsize < 2 && ee_collsize <2)
return false;
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
EventNumber_t event() const
void doSelection(int detector, const reco::BasicClusterCollection *clusterCollection, const EcalRecHitCollection *hitCollection, const EcalChannelStatus &channelStatus, const CaloSubdetectorTopology *topology_p, std::map< int, std::vector< EcalRecHit > > &RecHits5x5_clus, std::vector< int > &indCandClus, std::vector< int > &indIsoClus, std::vector< int > &indClusSelected)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< EERecHitCollection > endcapHitsToken_
std::vector< EcalRecHit >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, const EcalRecHit &rh)
void makeClusterES(float x, float y, float z, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorTopology *topology_p)
edm::EDGetTokenT< EBRecHitCollection > barrelHitsToken_
std::map< DetId, EcalRecHit > m_esrechit_map
std::set< DetId > m_used_strips
std::string BarrelHits_
output hits
bool doSelBarrel_
for pi0/eta ->gg barrel
const_iterator end() const
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
T const * product() const
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
iterator find(key_type k)
edm::EDGetTokenT< reco::BasicClusterCollection > barrelClustersToken_
edm::EDGetTokenT< ESRecHitCollection > preshHitsToken_
const_iterator begin() const
edm::EDGetTokenT< reco::BasicClusterCollection > endcapClustersToken_