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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 15 of file UncleanSCRecoveryProducer.h.

Constructor & Destructor Documentation

◆ UncleanSCRecoveryProducer()

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

Definition at line 36 of file UncleanSCRecoveryProducer.cc.

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

References bcCollection_, and scCollection_.

Member Function Documentation

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 50 of file UncleanSCRecoveryProducer.cc.

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

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(), fileCollector::seed, reco::CaloCluster::setFlags(), HLT_FULL_cff::superClusters, uncleanBcCollection_, reco::CaloCluster::uncleanOnly, and uncleanScCollection_.

Member Data Documentation

◆ bcCollection_

const std::string UncleanSCRecoveryProducer::bcCollection_
private

Definition at line 29 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

◆ cleanBcCollection_

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

Definition at line 23 of file UncleanSCRecoveryProducer.h.

◆ cleanScCollection_

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

Definition at line 24 of file UncleanSCRecoveryProducer.h.

Referenced by produce().

◆ scCollection_

const std::string UncleanSCRecoveryProducer::scCollection_
private

Definition at line 30 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

◆ uncleanBcCollection_

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

Definition at line 26 of file UncleanSCRecoveryProducer.h.

Referenced by produce().

◆ uncleanScCollection_

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

Definition at line 27 of file UncleanSCRecoveryProducer.h.

Referenced by produce().

UncleanSCRecoveryProducer::bcCollection_
const std::string bcCollection_
Definition: UncleanSCRecoveryProducer.h:29
mps_fire.i
i
Definition: mps_fire.py:428
edm::Handle::product
T const * product() const
Definition: Handle.h:70
reco::CaloCluster::isInUnclean
bool isInUnclean() const
Definition: CaloCluster.h:199
reco::SuperCluster
Definition: SuperCluster.h:18
edm::PtrVectorItr
Definition: PtrVector.h:51
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
reco::CaloClusterPtr
edm::Ptr< CaloCluster > CaloClusterPtr
Definition: CaloClusterFwd.h:21
UncleanSCRecoveryProducer::scCollection_
const std::string scCollection_
Definition: UncleanSCRecoveryProducer.h:30
edm::Ref< SuperClusterCollection >
HLT_FULL_cff.superClusters
superClusters
Definition: HLT_FULL_cff.py:15173
fileCollector.seed
seed
Definition: fileCollector.py:127
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
csc
Definition: L1Track.h:19
edm::PtrVector< CaloCluster >
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
reco::BasicClusterCollection
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
Definition: BasicClusterFwd.h:16
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
UncleanSCRecoveryProducer::cleanScCollection_
const edm::EDGetTokenT< reco::SuperClusterCollection > cleanScCollection_
Definition: UncleanSCRecoveryProducer.h:24
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
reco::SuperCluster::seed
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
UncleanSCRecoveryProducer::uncleanBcCollection_
const edm::EDGetTokenT< reco::BasicClusterCollection > uncleanBcCollection_
Definition: UncleanSCRecoveryProducer.h:26
UncleanSCRecoveryProducer::uncleanScCollection_
const edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScCollection_
Definition: UncleanSCRecoveryProducer.h:27
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
reco::SuperCluster::clustersBegin
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:86
reco::CaloCluster::common
Definition: CaloCluster.h:48
edm::OrphanHandleBase::isValid
bool isValid() const
Definition: OrphanHandleBase.h:53
reco::CaloCluster::position
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
edm::Ptr< CaloCluster >
reco::CaloCluster::uncleanOnly
Definition: CaloCluster.h:48
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
UncleanSCRecoveryProducer::cleanBcCollection_
const edm::EDGetTokenT< reco::BasicClusterCollection > cleanBcCollection_
Definition: UncleanSCRecoveryProducer.h:23
reco::CaloCluster::isInClean
bool isInClean() const
Definition: CaloCluster.h:198
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
reco::CaloCluster::setFlags
void setFlags(uint32_t flags)
Definition: CaloCluster.h:194
reco::SuperCluster::clustersEnd
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
edm::InputTag
Definition: InputTag.h:15