CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
UncleanSCRecoveryProducer Class Reference
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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 34 of file UncleanSCRecoveryProducer.cc.

Constructor & Destructor Documentation

◆ UncleanSCRecoveryProducer()

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

Definition at line 55 of file UncleanSCRecoveryProducer.cc.

References bcCollection_, and scCollection_.

56  : cleanBcCollection_(consumes<reco::BasicClusterCollection>(ps.getParameter<edm::InputTag>("cleanBcCollection"))),
57  cleanScCollection_(consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("cleanScCollection"))),
59  consumes<reco::BasicClusterCollection>(ps.getParameter<edm::InputTag>("uncleanBcCollection"))),
61  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("uncleanScCollection"))),
62  bcCollection_(ps.getParameter<std::string>("bcCollection")),
63  scCollection_(ps.getParameter<std::string>("scCollection")) {
64  // the products:
65  produces<reco::BasicClusterCollection>(bcCollection_);
66  produces<reco::SuperClusterCollection>(scCollection_);
67 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 69 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(), fileCollector::seed, reco::CaloCluster::setFlags(), HLT_2022v12_cff::superClusters, uncleanBcCollection_, reco::CaloCluster::uncleanOnly, and uncleanScCollection_.

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

Member Data Documentation

◆ bcCollection_

const std::string UncleanSCRecoveryProducer::bcCollection_
private

Definition at line 48 of file UncleanSCRecoveryProducer.cc.

Referenced by produce(), and UncleanSCRecoveryProducer().

◆ cleanBcCollection_

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

Definition at line 42 of file UncleanSCRecoveryProducer.cc.

◆ cleanScCollection_

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

Definition at line 43 of file UncleanSCRecoveryProducer.cc.

Referenced by produce().

◆ scCollection_

const std::string UncleanSCRecoveryProducer::scCollection_
private

Definition at line 49 of file UncleanSCRecoveryProducer.cc.

Referenced by produce(), and UncleanSCRecoveryProducer().

◆ uncleanBcCollection_

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

Definition at line 45 of file UncleanSCRecoveryProducer.cc.

Referenced by produce().

◆ uncleanScCollection_

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

Definition at line 46 of file UncleanSCRecoveryProducer.cc.

Referenced by produce().