302 std::unique_ptr< EBRecHitCollection > selEBRecHitCollection(
new EBRecHitCollection );
304 std::unique_ptr< EERecHitCollection > selEERecHitCollection(
new EERecHitCollection );
308 vector<DetId> selectedEBDetIds;
309 vector<DetId> selectedEEDetIds;
321 std::unique_ptr<CaloSubdetectorTopology> topology_es;
323 topology_es = std::make_unique<EcalPreshowerTopology>();
339 if (!barrelRecHitsHandle.
isValid()) {
340 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product barrel hits!";
348 if (!barrelClustersHandle.
isValid()) {
349 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product barrel clusters!";
353 LogDebug(
"AlCaEcalResonanceProducer") <<
" barrel_input_size: run "<<iEvent.
id().
run()<<
" event "<<iEvent.
id().
event()<<
" nhitEB: "<<hitCollection_eb->
size()<<
" nCluster: "<< clusterCollection_eb->size();
358 map<int, vector<EcalRecHit> > RecHits5x5_clus;
359 vector<int> indIsoClus;
360 vector<int> indCandClus;
361 vector<int> indClusSelected;
365 indCandClus,indIsoClus, indClusSelected);
369 for(
int ind : indClusSelected){
370 auto it_bc3 = clusterCollection_eb->begin() + ind;
371 const std::vector< std::pair<DetId, float> > &
vid = it_bc3->hitsAndFractions();
372 for (
auto const & idItr : vid){
373 auto hit = hitCollection_eb->
find(idItr.first);
374 if(
hit == hitCollection_eb->
end())
continue;
375 selEBRecHitCollection->push_back(*
hit);
376 selectedEBDetIds.push_back(idItr.first);
383 for(
int ind : indCandClus){
384 vector<EcalRecHit> v5x5 = RecHits5x5_clus[ind];
385 for(
auto &
n : v5x5){
387 auto itdet =
find(selectedEBDetIds.begin(),selectedEBDetIds.end(),ed);
388 if( itdet == selectedEBDetIds.end()){
389 selectedEBDetIds.push_back(ed);
390 selEBRecHitCollection->push_back(
n);
397 for(
int ind : indIsoClus){
398 auto it =
find(indCandClus.begin(),indCandClus.end(), ind);
399 if( it != indCandClus.end())
continue;
401 auto it_bc3 = clusterCollection_eb->begin() + ind;
402 DetId seedId = it_bc3->seed();
403 std::vector<DetId> clus_v5x5 = topology_eb->
getWindow(seedId,5,5);
404 for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
406 auto rit = hitCollection_eb->
find( ed );
407 if ( rit == hitCollection_eb->
end() )
continue;
409 auto itdet =
find(selectedEBDetIds.begin(),selectedEBDetIds.end(),ed);
410 if( itdet == selectedEBDetIds.end()){
411 selectedEBDetIds.push_back(ed);
412 selEBRecHitCollection->push_back(*rit);
421 int eb_collsize = selEBRecHitCollection->size();
424 LogDebug(
"AlCaEcalResonanceProducer") <<
" barrel_output_size_run "<<iEvent.
id().
run()<<
" event "<<iEvent.
id().
event()<<
" nEBSaved "<<selEBRecHitCollection->size();
433 if( !esRecHitsHandle.
isValid()){
434 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product esRecHit!";
440 for (iter = esRecHitsHandle->
begin(); iter != esRecHitsHandle->
end(); iter++) {
450 if (!endcapRecHitsHandle.
isValid()) {
451 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product endcap hits!";
456 if (!endcapClustersHandle.
isValid()) {
457 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product endcap clusters!";
461 LogDebug(
"AlCaEcalResonanceProducer") <<
" endcap_input_size: run "<<iEvent.
id().
run()<<
" event "<<iEvent.
id().
event()<<
" nhitEE: "<<hitCollection_ee->
size()<<
" nhitES: "<<hitCollection_es->
size()<<
" nCluster: "<< clusterCollection_ee->size();
466 map<int, vector<EcalRecHit> > RecHits5x5_clus;
467 vector<int> indIsoClus;
468 vector<int> indCandClus;
469 vector<int> indClusSelected;
473 indCandClus,indIsoClus, indClusSelected);
476 for(
int ind : indClusSelected){
477 auto it_bc3 = clusterCollection_ee->begin() + ind;
478 const std::vector< std::pair<DetId, float> > &vid = it_bc3->hitsAndFractions();
479 for (
auto const & idItr : vid){
480 auto hit = hitCollection_ee->
find(idItr.first);
481 if(
hit == hitCollection_ee->
end())
continue;
482 selEERecHitCollection->push_back(*
hit);
483 selectedEEDetIds.push_back(idItr.first);
488 makeClusterES(it_bc3->x(),it_bc3->y(),it_bc3->z(),geometry_es,topology_es.get());
492 auto ites2 =
find(used_strips_before.begin(),used_strips_before.end(),d1);
493 if( (ites2 == used_strips_before.end())){
495 selESRecHitCollection->push_back(itmap->second);
504 for(
int ind : indCandClus){
505 vector<EcalRecHit> v5x5 = RecHits5x5_clus[ind];
506 for(
auto &
n : v5x5){
508 auto itdet =
find(selectedEEDetIds.begin(),selectedEEDetIds.end(),ed);
509 if( itdet == selectedEEDetIds.end()){
510 selectedEEDetIds.push_back(ed);
511 selEERecHitCollection->push_back(
n);
518 for(
int ind : indIsoClus){
519 auto it =
find(indCandClus.begin(),indCandClus.end(), ind);
520 if( it != indCandClus.end())
continue;
522 auto it_bc3 = clusterCollection_ee->begin() + ind;
523 DetId seedId = it_bc3->seed();
524 std::vector<DetId> clus_v5x5 = topology_ee->
getWindow(seedId,5,5);
525 for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
527 auto rit = hitCollection_ee->
find( ed );
528 if ( rit == hitCollection_ee->
end() )
continue;
530 auto itdet =
find(selectedEEDetIds.begin(),selectedEEDetIds.end(),ed);
531 if( itdet == selectedEEDetIds.end()){
532 selectedEEDetIds.push_back(ed);
533 selEERecHitCollection->push_back(*rit);
546 LogDebug(
"AlCaEcalResonanceProducer") <<
" endcap_output_size run "<<iEvent.
id().
run()<<
"_"<<iEvent.
id().
event()<<
" nEESaved "<<selEERecHitCollection->size()<<
" nESSaved: " << selESRecHitCollection->size();
550 int ee_collsize = selEERecHitCollection->size();
552 if( eb_collsize < 2 && ee_collsize <2)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
EventNumber_t event() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, const EcalRecHit &rh)
std::vector< EcalRecHit >::const_iterator const_iterator
void makeClusterES(float x, float y, float z, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorTopology *topology_p)
std::set< DetId > m_used_strips
edm::EDGetTokenT< EERecHitCollection > endcapHitsToken_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
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)
edm::EDGetTokenT< reco::BasicClusterCollection > barrelClustersToken_
edm::EDGetTokenT< ESRecHitCollection > preshHitsToken_
edm::EDGetTokenT< EBRecHitCollection > barrelHitsToken_
edm::EDGetTokenT< reco::BasicClusterCollection > endcapClustersToken_
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
bool doSelBarrel_
------—BARREL CONFIGURATION
std::string BarrelHits_
output hits
iterator find(key_type k)
std::map< DetId, EcalRecHit > m_esrechit_map
const_iterator begin() const