CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
UncleanSCRecoveryProducer Class Reference

#include <UncleanSCRecoveryProducer.h>

Inheritance diagram for UncleanSCRecoveryProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 UncleanSCRecoveryProducer (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const std::string bcCollection_
 
const edm::EDGetTokenT< reco::BasicClusterCollectioncleanBcCollection_
 
const edm::EDGetTokenT< reco::SuperClusterCollectioncleanScCollection_
 
const std::string scCollection_
 
const edm::EDGetTokenT< reco::BasicClusterCollectionuncleanBcCollection_
 
const edm::EDGetTokenT< reco::SuperClusterCollectionuncleanScCollection_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 17 of file UncleanSCRecoveryProducer.h.

Constructor & Destructor Documentation

UncleanSCRecoveryProducer::UncleanSCRecoveryProducer ( const edm::ParameterSet ps)

Definition at line 38 of file UncleanSCRecoveryProducer.cc.

References bcCollection_, and scCollection_.

38  :
39  cleanBcCollection_(consumes<reco::BasicClusterCollection>(ps.getParameter<edm::InputTag>("cleanBcCollection"))),
40  cleanScCollection_(consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("cleanScCollection"))),
41  uncleanBcCollection_(consumes<reco::BasicClusterCollection>(ps.getParameter<edm::InputTag>("uncleanBcCollection"))),
42  uncleanScCollection_(consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("uncleanScCollection"))),
43  bcCollection_(ps.getParameter<std::string>("bcCollection")),
44  scCollection_(ps.getParameter<std::string>("scCollection"))
45 {
46  // the products:
47  produces< reco::BasicClusterCollection >(bcCollection_);
48  produces< reco::SuperClusterCollection >(scCollection_);
49 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScCollection_
const edm::EDGetTokenT< reco::SuperClusterCollection > cleanScCollection_
const edm::EDGetTokenT< reco::BasicClusterCollection > cleanBcCollection_
const edm::EDGetTokenT< reco::BasicClusterCollection > uncleanBcCollection_

Member Function Documentation

void UncleanSCRecoveryProducer::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup es 
) const
override

Definition at line 52 of file UncleanSCRecoveryProducer.cc.

References bcCollection_, cleanScCollection_, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), reco::CaloCluster::common, reco::CaloCluster::energy(), reco::CaloCluster::eta(), edm::Event::getByToken(), mps_fire::i, reco::CaloCluster::isInClean(), reco::CaloCluster::isInUnclean(), edm::OrphanHandleBase::isValid(), LogTrace, eostools::move(), reco::CaloCluster::position(), edm::Handle< T >::product(), edm::PtrVector< T >::push_back(), edm::Event::put(), scCollection_, reco::SuperCluster::seed(), SurveyInfoScenario_cff::seed, reco::CaloCluster::setFlags(), uncleanBcCollection_, reco::CaloCluster::uncleanOnly, and uncleanScCollection_.

54 {
55  // __________________________________________________________________________
56  //
57  // cluster collections:
60  //
63  // clean collections ________________________________________________________
64  evt.getByToken(cleanScCollection_, pCleanSC);
65  const reco::SuperClusterCollection cleanSC = *(pCleanSC.product());
66 
67  // unclean collections ______________________________________________________
68  evt.getByToken(uncleanBcCollection_, pUncleanBC);
69  const reco::BasicClusterCollection uncleanBC = *(pUncleanBC.product());
70  //
71  evt.getByToken(uncleanScCollection_, pUncleanSC);
72  const reco::SuperClusterCollection uncleanSC = *(pUncleanSC.product());
73  int uncleanSize = pUncleanSC->size();
74  int cleanSize = pCleanSC->size();
75 
76  LogTrace("EcalCleaning") << "Size of Clean Collection: " << cleanSize
77  << ", uncleanSize: " << uncleanSize;
78 
79  // collections are all taken now ____________________________________________
80  //
81  // the collections to be produced ___________________________________________
82  reco::BasicClusterCollection basicClusters;
83  reco::SuperClusterCollection superClusters;
84  //
85  //
86  // collect all the basic clusters of the SC that belong to the unclean
87  // collection and put them into the basicClusters vector
88  // keep the information of which SC they belong to
89  //
90  // loop over the unclean sc: all SC will join the new collection
91  std::vector< std::pair<int, int> > basicClusterOwner; // counting all
92 
93  std::vector<DetId> scUncleanSeedDetId; // counting the unclean
94  for (int isc =0; isc< uncleanSize; ++isc) {
95  const reco::SuperCluster unsc = uncleanSC[isc];
96  scUncleanSeedDetId.push_back(unsc.seed()->seed());
98  for (; bciter != unsc.clustersEnd(); ++bciter) {
99  // the basic clusters
100  basicClusters.push_back(**bciter);
101  // index of the unclean SC
102  basicClusterOwner.push_back( std::make_pair(isc,0) );
103  }
104  }
105  // loop over the clean: only the ones which are in common with the unclean
106  // are taken into account
107 
108  std::vector<DetId> scCleanSeedDetId; // counting the clean
109  std::vector<int> isToBeKept;
110  for (int isc =0; isc< cleanSize; ++isc) {
111  reco::SuperClusterRef cscRef( pCleanSC, isc );
112  scCleanSeedDetId.push_back(cscRef->seed()->seed());
113  for (reco::CaloCluster_iterator bciter = cscRef->clustersBegin(); bciter != cscRef->clustersEnd(); ++bciter) {
114  // the basic clusters
115  basicClusters.push_back(**bciter);
116  // index of the clean SC
117  basicClusterOwner.push_back( std::make_pair(isc,1) );
118  }
119  if (cscRef->isInUnclean()) isToBeKept.push_back(1);
120  else isToBeKept.push_back(0);
121  }
122  //
123  // now export the basic clusters into the event and get them back
124  auto basicClusters_p = std::make_unique<reco::BasicClusterCollection>();
125  basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
127  evt.put(std::move(basicClusters_p), bcCollection_);
128  if (!(bccHandle.isValid())) {
129 
130  edm::LogWarning("MissingInput") << "could not handle the new BasicClusters!";
131  return;
132  }
133  reco::BasicClusterCollection basicClustersProd = *bccHandle;
134 
135  LogTrace("EcalCleaning") <<"Got the BasicClusters from the event again";
136  int bcSize = bccHandle->size();
137  //
138  // now we can create the SC collection
139  //
140  // run over the unclean SC: all to be kept here
141  for (int isc=0; isc< uncleanSize; ++isc) {
142  reco::CaloClusterPtrVector clusterPtrVector;
143  // the seed is the basic cluster with the highest energy
145  for (int jbc=0; jbc< bcSize; ++jbc) {
146  std::pair<int,int> theBcOwner = basicClusterOwner[jbc];
147  if (theBcOwner.first == isc && theBcOwner.second == 0) {
148  reco::CaloClusterPtr currentClu=reco::CaloClusterPtr(bccHandle,jbc);
149  clusterPtrVector.push_back(currentClu);
150  if (scUncleanSeedDetId[isc] == currentClu->seed()) {
151  seed = currentClu;
152  }
153  }
154  }
155  const reco::SuperCluster unsc = uncleanSC[isc];
156  reco::SuperCluster newSC(unsc.energy(), unsc.position(), seed, clusterPtrVector );
158  superClusters.push_back(newSC);
159  }
160  // run over the clean SC: only those who are in common between the
161  // clean and unclean collection are kept
162  for (int isc=0; isc< cleanSize; ++isc) {
163  reco::SuperClusterRef cscRef( pCleanSC, isc);
164  if (not cscRef->isInUnclean()) continue;
165  reco::CaloClusterPtrVector clusterPtrVector;
166  // the seed is the basic cluster with the highest energy
168  for (int jbc=0; jbc< bcSize; ++jbc) {
169  std::pair<int,int> theBcOwner = basicClusterOwner[jbc];
170  if (theBcOwner.first == isc && theBcOwner.second == 1) {
171  reco::CaloClusterPtr currentClu=reco::CaloClusterPtr(bccHandle,jbc);
172  clusterPtrVector.push_back(currentClu);
173  if (scCleanSeedDetId[isc] == currentClu->seed()) {
174  seed = currentClu;
175  }
176  }
177  }
178  reco::SuperCluster newSC(cscRef->energy(), cscRef->position(),
179  seed, clusterPtrVector );
181  superClusters.push_back(newSC);
182  }
183 
184  auto superClusters_p = std::make_unique<reco::SuperClusterCollection>();
185  superClusters_p->assign(superClusters.begin(), superClusters.end());
186 
187  evt.put(std::move(superClusters_p), scCollection_);
188 
189  LogTrace("EcalCleaning")<<"Clusters (Basic/Super) added to the Event! :-)";
190 
191  // ----- debugging ----------
192  // print the new collection SC quantities
193  // print out the clean collection SC
194  LogTrace("EcalCleaning") << "Clean Collection SC ";
195  for (int i=0; i < cleanSize; ++i) {
196  const reco::SuperCluster csc = cleanSC[i];
197  LogTrace("EcalCleaning") << " >>> clean #" << i << "; Energy: " << csc.energy()
198  << " eta: " << csc.eta()
199  << " sc seed detid: " << csc.seed()->seed().rawId();
200  }
201  // the unclean SC
202  LogTrace("EcalCleaning") << "Unclean Collection SC ";
203  for (int i=0; i < uncleanSize; ++i) {
204  const reco::SuperCluster usc = uncleanSC[i];
205  LogTrace("EcalCleaning") << " >>> unclean #" << i << "; Energy: " << usc.energy()
206  << " eta: " << usc.eta()
207  << " sc seed detid: " << usc.seed()->seed().rawId();
208  }
209  // the new collection
210  LogTrace("EcalCleaning")<<"The new SC clean collection with size "<< superClusters.size();
211  for (unsigned int i=0; i < superClusters.size(); ++i) {
212  const reco::SuperCluster nsc = superClusters[i];
213  LogTrace("EcalCleaning")<< " >>> newSC #" << i << "; Energy: " << nsc.energy()
214  << " eta: " << nsc.eta() << " isClean="
215  << nsc.isInClean() << " isUnclean=" << nsc.isInUnclean()
216  << " sc seed detid: " << nsc.seed()->seed().rawId();
217  }
218 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:129
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool isInUnclean() const
Definition: CaloCluster.h:184
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
edm::Ptr< CaloCluster > CaloClusterPtr
const edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScCollection_
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:166
const edm::EDGetTokenT< reco::SuperClusterCollection > cleanScCollection_
void setFlags(uint32_t flags)
Definition: CaloCluster.h:179
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
double energy() const
cluster energy
Definition: CaloCluster.h:124
#define LogTrace(id)
Definition: L1Track.h:19
bool isInClean() const
Definition: CaloCluster.h:183
const edm::EDGetTokenT< reco::BasicClusterCollection > uncleanBcCollection_
T const * product() const
Definition: Handle.h:81
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:75
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
def move(src, dest)
Definition: eostools.py:510
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78

Member Data Documentation

const std::string UncleanSCRecoveryProducer::bcCollection_
private

Definition at line 34 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

const edm::EDGetTokenT<reco::BasicClusterCollection> UncleanSCRecoveryProducer::cleanBcCollection_
private

Definition at line 28 of file UncleanSCRecoveryProducer.h.

const edm::EDGetTokenT<reco::SuperClusterCollection> UncleanSCRecoveryProducer::cleanScCollection_
private

Definition at line 29 of file UncleanSCRecoveryProducer.h.

Referenced by produce().

const std::string UncleanSCRecoveryProducer::scCollection_
private

Definition at line 35 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

const edm::EDGetTokenT<reco::BasicClusterCollection> UncleanSCRecoveryProducer::uncleanBcCollection_
private

Definition at line 31 of file UncleanSCRecoveryProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::SuperClusterCollection> UncleanSCRecoveryProducer::uncleanScCollection_
private

Definition at line 32 of file UncleanSCRecoveryProducer.h.

Referenced by produce().