Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unique_ptr, not auto_ptr in RecoEgamma and RecoEcal #15857

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -115,9 +115,9 @@ class PFECALSuperClusterAlgo {
void update(const edm::EventSetup&);


std::auto_ptr<reco::SuperClusterCollection>&
std::unique_ptr<reco::SuperClusterCollection>&
getEBOutputSCCollection() { return superClustersEB_; }
std::auto_ptr<reco::SuperClusterCollection>&
std::unique_ptr<reco::SuperClusterCollection>&
getEEOutputSCCollection() { return superClustersEE_; }

void loadAndSortPFClusters(const edm::Event &evt);
Expand All @@ -135,8 +135,8 @@ class PFECALSuperClusterAlgo {

CalibratedClusterPtrVector _clustersEB;
CalibratedClusterPtrVector _clustersEE;
std::auto_ptr<reco::SuperClusterCollection> superClustersEB_;
std::auto_ptr<reco::SuperClusterCollection> superClustersEE_;
std::unique_ptr<reco::SuperClusterCollection> superClustersEB_;
std::unique_ptr<reco::SuperClusterCollection> superClustersEE_;
const reco::PFCluster::EEtoPSAssociation* EEtoPS_;
std::shared_ptr<PFEnergyCalibration> _pfEnergyCalibration;
clustering_type _clustype;
Expand Down
4 changes: 2 additions & 2 deletions RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgo.cc
Expand Up @@ -240,9 +240,9 @@ loadAndSortPFClusters(const edm::Event &iEvent) {
}

// reset the system for running
superClustersEB_.reset(new reco::SuperClusterCollection);
superClustersEB_ = std::make_unique<reco::SuperClusterCollection>();
_clustersEB.clear();
superClustersEE_.reset(new reco::SuperClusterCollection);
superClustersEE_ = std::make_unique<reco::SuperClusterCollection>();
_clustersEE.clear();
EEtoPS_ = &psclusters;

Expand Down
12 changes: 6 additions & 6 deletions RecoEcal/EgammaClusterProducers/src/CleanAndMergeProducer.cc
Expand Up @@ -166,10 +166,10 @@ void CleanAndMergeProducer::produce(edm::Event& evt,
// now you have the collection of basic clusters of the SC to be remain in the
// in the clean collection, export them to the event
// you will need to reread them later in order to make correctly the refs to the SC
std::auto_ptr< reco::BasicClusterCollection> basicClusters_p(new reco::BasicClusterCollection);
auto basicClusters_p = std::make_unique<reco::BasicClusterCollection>();
basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
edm::OrphanHandle<reco::BasicClusterCollection> bccHandle =
evt.put(basicClusters_p, bcCollection_);
evt.put(std::move(basicClusters_p), bcCollection_);
if (!(bccHandle.isValid())) {
edm::LogWarning("MissingInput")<<"could not get a handle on the BasicClusterCollection!" << std::endl;
return;
Expand Down Expand Up @@ -201,13 +201,13 @@ void CleanAndMergeProducer::produce(edm::Event& evt,

}
// export the collection of references to the clean collection
std::auto_ptr< reco::SuperClusterRefVector > scRefs_p( scRefs );
evt.put(scRefs_p, refScCollection_);
std::unique_ptr<reco::SuperClusterRefVector> scRefs_p(scRefs);
evt.put(std::move(scRefs_p), refScCollection_);

// the collection of basic clusters is already in the event
// the collection of uncleaned SC
std::auto_ptr< reco::SuperClusterCollection > superClusters_p(new reco::SuperClusterCollection);
auto superClusters_p = std::make_unique<reco::SuperClusterCollection>();
superClusters_p->assign(superClusters.begin(), superClusters.end());
evt.put(superClusters_p, scCollection_);
evt.put(std::move(superClusters_p), scCollection_);
LogDebug("EcalCleaning")<< "Hybrid Clusters (Basic/Super) added to the Event! :-)";
}
19 changes: 9 additions & 10 deletions RecoEcal/EgammaClusterProducers/src/CosmicClusterProducer.cc
Expand Up @@ -166,33 +166,32 @@ void CosmicClusterProducer::clusterizeECALPart(edm::Event &evt, const edm::Event
}

//Put clustershapes in event, but retain a Handle on them.
std::auto_ptr< reco::ClusterShapeCollection> clustersshapes_p(new reco::ClusterShapeCollection);
auto clustersshapes_p = std::make_unique<reco::ClusterShapeCollection>();
clustersshapes_p->assign(ClusVec.begin(), ClusVec.end());
edm::OrphanHandle<reco::ClusterShapeCollection> clusHandle;
if (ecalPart == CosmicClusterAlgo::barrel)
clusHandle= evt.put(clustersshapes_p, clustershapecollectionEB_);
clusHandle= evt.put(std::move(clustersshapes_p), clustershapecollectionEB_);
else
clusHandle= evt.put(clustersshapes_p, clustershapecollectionEE_);
clusHandle= evt.put(std::move(clustersshapes_p), clustershapecollectionEE_);

// create an auto_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
// create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
clusters_p->assign(clusters.begin(), clusters.end());
edm::OrphanHandle<reco::BasicClusterCollection> bccHandle;

if (ecalPart == CosmicClusterAlgo::barrel)
bccHandle = evt.put(clusters_p, barrelClusterCollection_);
bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
else
bccHandle = evt.put(clusters_p, endcapClusterCollection_);
bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);


// BasicClusterShapeAssociationMap
std::auto_ptr<reco::BasicClusterShapeAssociationCollection> shapeAssocs_p(
new reco::BasicClusterShapeAssociationCollection(bccHandle, clusHandle));
auto shapeAssocs_p = std::make_unique<reco::BasicClusterShapeAssociationCollection>(bccHandle, clusHandle);

for (unsigned int i = 0; i < clusHandle->size(); i++){
shapeAssocs_p->insert(edm::Ref<reco::BasicClusterCollection>(bccHandle,i),edm::Ref<reco::ClusterShapeCollection>(clusHandle,i));
}
evt.put(shapeAssocs_p,clusterShapeAssociation);
evt.put(std::move(shapeAssocs_p),clusterShapeAssociation);

delete topology_p;
}
8 changes: 4 additions & 4 deletions RecoEcal/EgammaClusterProducers/src/EcalDigiSelector.cc
Expand Up @@ -101,8 +101,8 @@ void EcalDigiSelector::produce(edm::Event& evt, const edm::EventSetup& es)
}
}

std::auto_ptr<EBDigiCollection> SEBDigiCol(new EBDigiCollection);
std::auto_ptr<EEDigiCollection> SEEDigiCol(new EEDigiCollection);
auto SEBDigiCol = std::make_unique<EBDigiCollection>();
auto SEEDigiCol = std::make_unique<EEDigiCollection>();
int TotClus = saveBarrelSuperClusters.size() + saveEndcapSuperClusters.size();

if (TotClus >= nclus_sel_ || meet_single_thresh){
Expand Down Expand Up @@ -235,7 +235,7 @@ void EcalDigiSelector::produce(edm::Event& evt, const edm::EventSetup& es)
//Empty collection, or full, still put in event.
SEBDigiCol->sort();
SEEDigiCol->sort();
evt.put(SEBDigiCol, selectedEcalEBDigiCollection_);
evt.put(SEEDigiCol, selectedEcalEEDigiCollection_);
evt.put(std::move(SEBDigiCol), selectedEcalEBDigiCollection_);
evt.put(std::move(SEEDigiCol), selectedEcalEEDigiCollection_);

}
Expand Up @@ -157,7 +157,7 @@ EgammaSCCorrectionMaker::produce(edm::Event& evt, const edm::EventSetup& es)
const reco::SuperClusterCollection *rawClusters = pRawSuperClusters.product();

// Define a collection of corrected SuperClusters to put back into the event
std::auto_ptr<reco::SuperClusterCollection> corrClusters(new reco::SuperClusterCollection);
auto corrClusters = std::make_unique<reco::SuperClusterCollection>();

// Loop over raw clusters and make corrected ones
reco::SuperClusterCollection::const_iterator aClus;
Expand Down Expand Up @@ -193,7 +193,7 @@ EgammaSCCorrectionMaker::produce(edm::Event& evt, const edm::EventSetup& es)
}

// Put collection of corrected SuperClusters into the event
evt.put(corrClusters, outputCollection_);
evt.put(std::move(corrClusters), outputCollection_);

}

14 changes: 7 additions & 7 deletions RecoEcal/EgammaClusterProducers/src/HybridClusterProducer.cc
Expand Up @@ -117,13 +117,13 @@ void HybridClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es)
es.get<CaloGeometryRecord>().get(geoHandle);
const CaloGeometry& geometry = *geoHandle;
const CaloSubdetectorGeometry *geometry_p;
std::auto_ptr<const CaloSubdetectorTopology> topology;
std::unique_ptr<const CaloSubdetectorTopology> topology;

edm::ESHandle<EcalSeverityLevelAlgo> sevLv;
es.get<EcalSeverityLevelAlgoRcd>().get(sevLv);

geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
topology.reset(new EcalBarrelTopology(geoHandle));
topology = std::make_unique<EcalBarrelTopology>(geoHandle);

// make the Basic clusters!
reco::BasicClusterCollection basicClusters;
Expand All @@ -132,10 +132,10 @@ void HybridClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es)

LogTrace("EcalClusters") << "Finished clustering - BasicClusterCollection returned to producer..." ;

// create an auto_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
std::auto_ptr< reco::BasicClusterCollection > basicclusters_p(new reco::BasicClusterCollection);
// create a unique_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
auto basicclusters_p = std::make_unique<reco::BasicClusterCollection>();
basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
edm::OrphanHandle<reco::BasicClusterCollection> bccHandle = evt.put(basicclusters_p,basicclusterCollection_);
edm::OrphanHandle<reco::BasicClusterCollection> bccHandle = evt.put(std::move(basicclusters_p),basicclusterCollection_);

//Basic clusters now in the event.
LogTrace("EcalClusters") << "Basic Clusters now put into event." ;
Expand All @@ -161,10 +161,10 @@ void HybridClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es)
reco::SuperClusterCollection superClusters = hybrid_p->makeSuperClusters(clusterPtrVector);
LogTrace("EcalClusters") << "Found: " << superClusters.size() << " superclusters." ;

std::auto_ptr< reco::SuperClusterCollection > superclusters_p(new reco::SuperClusterCollection);
auto superclusters_p = std::make_unique<reco::SuperClusterCollection>();
superclusters_p->assign(superClusters.begin(), superClusters.end());

evt.put(superclusters_p, superclusterCollection_);
evt.put(std::move(superclusters_p), superclusterCollection_);
LogTrace("EcalClusters") << "Hybrid Clusters (Basic/Super) added to the Event! :-)" ;


Expand Down
Expand Up @@ -159,9 +159,7 @@ InterestingDetIdCollectionProducer::produce (edm::Event& iEvent,
std::sort(indexToStore.begin(),indexToStore.end());
std::unique(indexToStore.begin(),indexToStore.end());

std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection(indexToStore) ) ;


iEvent.put( detIdCollection, interestingDetIdCollection_ );
iEvent.put(std::make_unique<DetIdCollection>(indexToStore), interestingDetIdCollection_);

}
Expand Up @@ -161,9 +161,9 @@ InterestingDetIdFromSuperClusterProducer::produce (edm::Event& iEvent,
std::sort(indexToStore.begin(),indexToStore.end());
std::unique(indexToStore.begin(),indexToStore.end());

std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection(indexToStore) ) ;
auto detIdCollection = std::make_unique<DetIdCollection>(indexToStore);


iEvent.put( detIdCollection, interestingDetIdCollection_ );
iEvent.put(std::move(detIdCollection), interestingDetIdCollection_ );

}
Expand Up @@ -117,7 +117,7 @@ InterestingTrackEcalDetIdProducer::produce(edm::Event& iEvent, const edm::EventS
{
using namespace edm;

std::auto_ptr< DetIdCollection > interestingDetIdCollection( new DetIdCollection() ) ;
auto interestingDetIdCollection = std::make_unique<DetIdCollection>();

// Get tracks from event
edm::Handle<reco::TrackCollection> tracks;
Expand Down Expand Up @@ -150,7 +150,7 @@ InterestingTrackEcalDetIdProducer::produce(edm::Event& iEvent, const edm::EventS

}

iEvent.put(interestingDetIdCollection);
iEvent.put(std::move(interestingDetIdCollection));

}

Expand Down
18 changes: 9 additions & 9 deletions RecoEcal/EgammaClusterProducers/src/IslandClusterProducer.cc
Expand Up @@ -150,30 +150,30 @@ void IslandClusterProducer::clusterizeECALPart(edm::Event &evt, const edm::Event
}

//Put clustershapes in event, but retain a Handle on them.
std::auto_ptr< reco::ClusterShapeCollection> clustersshapes_p(new reco::ClusterShapeCollection);
auto clustersshapes_p = std::make_unique<reco::ClusterShapeCollection>();
clustersshapes_p->assign(ClusVec.begin(), ClusVec.end());
edm::OrphanHandle<reco::ClusterShapeCollection> clusHandle;
if (ecalPart == IslandClusterAlgo::barrel)
clusHandle= evt.put(clustersshapes_p, clustershapecollectionEB_);
clusHandle= evt.put(std::move(clustersshapes_p), clustershapecollectionEB_);
else
clusHandle= evt.put(clustersshapes_p, clustershapecollectionEE_);
clusHandle= evt.put(std::move(clustersshapes_p), clustershapecollectionEE_);

// create an auto_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
// create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
clusters_p->assign(clusters.begin(), clusters.end());
edm::OrphanHandle<reco::BasicClusterCollection> bccHandle;
if (ecalPart == IslandClusterAlgo::barrel)
bccHandle = evt.put(clusters_p, barrelClusterCollection_);
bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
else
bccHandle = evt.put(clusters_p, endcapClusterCollection_);
bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);


// BasicClusterShapeAssociationMap
std::auto_ptr<reco::BasicClusterShapeAssociationCollection> shapeAssocs_p(new reco::BasicClusterShapeAssociationCollection(bccHandle, clusHandle));
auto shapeAssocs_p = std::make_unique<reco::BasicClusterShapeAssociationCollection>(bccHandle, clusHandle);
for (unsigned int i = 0; i < clusHandle->size(); i++){
shapeAssocs_p->insert(edm::Ref<reco::BasicClusterCollection>(bccHandle,i),edm::Ref<reco::ClusterShapeCollection>(clusHandle,i));
}
evt.put(shapeAssocs_p,clusterShapeAssociation);
evt.put(std::move(shapeAssocs_p),clusterShapeAssociation);

delete topology_p;
}
Expand Up @@ -145,14 +145,14 @@ void Multi5x5ClusterProducer::clusterizeECALPart(edm::Event &evt, const edm::Eve
reco::BasicClusterCollection clusters;
clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p, geometryES_p, detector);

// create an auto_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
// create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
clusters_p->assign(clusters.begin(), clusters.end());
edm::OrphanHandle<reco::BasicClusterCollection> bccHandle;
if (detector == reco::CaloID::DET_ECAL_BARREL)
bccHandle = evt.put(clusters_p, barrelClusterCollection_);
bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
else
bccHandle = evt.put(clusters_p, endcapClusterCollection_);
bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);

delete topology_p;
}
Expand Up @@ -101,8 +101,7 @@ produceSuperclustersForECALPart(edm::Event& evt,
getClusterPtrVector(evt, clustersToken, clusterPtrVector_p);

// run the brem recovery and get the SC collection
std::auto_ptr<reco::SuperClusterCollection>
superclusters_ap(new reco::SuperClusterCollection(bremAlgo_p->makeSuperClusters(*clusterPtrVector_p)));
auto superclusters_ap = std::make_unique<reco::SuperClusterCollection>(bremAlgo_p->makeSuperClusters(*clusterPtrVector_p));

// count the total energy and the number of superclusters
reco::SuperClusterCollection::iterator it;
Expand All @@ -113,7 +112,7 @@ produceSuperclustersForECALPart(edm::Event& evt,
}

// put the SC collection in the event
evt.put(superclusters_ap, superclusterCollection);
evt.put(std::move(superclusters_ap), superclusterCollection);

delete clusterPtrVector_p;
}
Expand Down
24 changes: 12 additions & 12 deletions RecoEcal/EgammaClusterProducers/src/PFECALSuperClusterProducer.cc
Expand Up @@ -184,9 +184,9 @@ void PFECALSuperClusterProducer::produce(edm::Event& iEvent,
superClusterAlgo_.run();

//build collections of output CaloClusters from the used PFClusters
std::auto_ptr<reco::CaloClusterCollection> caloClustersEB(new reco::CaloClusterCollection);
std::auto_ptr<reco::CaloClusterCollection> caloClustersEE(new reco::CaloClusterCollection);
std::auto_ptr<reco::CaloClusterCollection> caloClustersES(new reco::CaloClusterCollection);
auto caloClustersEB = std::make_unique<reco::CaloClusterCollection>();
auto caloClustersEE = std::make_unique<reco::CaloClusterCollection>();
auto caloClustersES = std::make_unique<reco::CaloClusterCollection>();

std::map<reco::CaloClusterPtr, unsigned int> pfClusterMapEB; //maps of pfclusters to caloclusters
std::map<reco::CaloClusterPtr, unsigned int> pfClusterMapEE;
Expand Down Expand Up @@ -235,18 +235,18 @@ void PFECALSuperClusterProducer::produce(edm::Event& iEvent,
}

//create ValueMaps from output CaloClusters back to original PFClusters
std::auto_ptr<edm::ValueMap<reco::CaloClusterPtr> > pfClusterAssociationEBEE(new edm::ValueMap<reco::CaloClusterPtr>);
std::auto_ptr<edm::ValueMap<reco::CaloClusterPtr> > pfClusterAssociationES(new edm::ValueMap<reco::CaloClusterPtr>);
auto pfClusterAssociationEBEE = std::make_unique<edm::ValueMap<reco::CaloClusterPtr>>();
auto pfClusterAssociationES = std::make_unique<edm::ValueMap<reco::CaloClusterPtr>>();

//vectors to fill ValueMaps
std::vector<reco::CaloClusterPtr> clusptrsEB(caloClustersEB->size());
std::vector<reco::CaloClusterPtr> clusptrsEE(caloClustersEE->size());
std::vector<reco::CaloClusterPtr> clusptrsES(caloClustersES->size());

//put calocluster output collections in event and get orphan handles to create ptrs
const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleEB = iEvent.put(caloClustersEB,PFBasicClusterCollectionBarrel_);
const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleEE = iEvent.put(caloClustersEE,PFBasicClusterCollectionEndcap_);
const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleES = iEvent.put(caloClustersES,PFBasicClusterCollectionPreshower_);
const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleEB = iEvent.put(std::move(caloClustersEB),PFBasicClusterCollectionBarrel_);
const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleEE = iEvent.put(std::move(caloClustersEE),PFBasicClusterCollectionEndcap_);
const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleES = iEvent.put(std::move(caloClustersES),PFBasicClusterCollectionPreshower_);

//relink superclusters to output caloclusters and fill vectors for ValueMaps
for( auto& ebsc : *(superClusterAlgo_.getEBOutputSCCollection()) ) {
Expand Down Expand Up @@ -296,11 +296,11 @@ void PFECALSuperClusterProducer::produce(edm::Event& iEvent,
fillerES.fill();

//store in the event
iEvent.put(pfClusterAssociationEBEE,PFClusterAssociationEBEE_);
iEvent.put(pfClusterAssociationES,PFClusterAssociationES_);
iEvent.put(superClusterAlgo_.getEBOutputSCCollection(),
iEvent.put(std::move(pfClusterAssociationEBEE),PFClusterAssociationEBEE_);
iEvent.put(std::move(pfClusterAssociationES),PFClusterAssociationES_);
iEvent.put(std::move(superClusterAlgo_.getEBOutputSCCollection()),
PFSuperClusterCollectionBarrel_);
iEvent.put(superClusterAlgo_.getEEOutputSCCollection(),
iEvent.put(std::move(superClusterAlgo_.getEEOutputSCCollection()),
PFSuperClusterCollectionEndcapWithPreshower_);
}

Expand Down