CMS 3D CMS Logo

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

#include <CleanAndMergeProducer.h>

Inheritance diagram for CleanAndMergeProducer:
edm::stream::EDProducer<>

Public Member Functions

 CleanAndMergeProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~CleanAndMergeProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

std::string bcCollection_
 
edm::EDGetTokenT< reco::SuperClusterCollectioncleanScToken_
 
std::string refScCollection_
 
std::string scCollection_
 
edm::EDGetTokenT< reco::SuperClusterCollectionuncleanScToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 17 of file CleanAndMergeProducer.h.

Constructor & Destructor Documentation

◆ CleanAndMergeProducer()

CleanAndMergeProducer::CleanAndMergeProducer ( const edm::ParameterSet ps)

Definition at line 51 of file CleanAndMergeProducer.cc.

51  {
52  // get the parameters
53  // the cleaned collection:
54  cleanScToken_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("cleanScInputTag"));
55  uncleanScToken_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("uncleanScInputTag"));
56 
57  // the names of the products to be produced:
58  bcCollection_ = ps.getParameter<std::string>("bcCollection");
59  scCollection_ = ps.getParameter<std::string>("scCollection");
60  refScCollection_ = ps.getParameter<std::string>("refScCollection");
61 
62  std::map<std::string, double> providedParameters;
63  providedParameters.insert(std::make_pair("LogWeighted", ps.getParameter<bool>("posCalc_logweight")));
64  providedParameters.insert(std::make_pair("T0_barl", ps.getParameter<double>("posCalc_t0")));
65  providedParameters.insert(std::make_pair("W0", ps.getParameter<double>("posCalc_w0")));
66  providedParameters.insert(std::make_pair("X0", ps.getParameter<double>("posCalc_x0")));
67 
68  // the products:
69  produces<reco::BasicClusterCollection>(bcCollection_);
70  produces<reco::SuperClusterCollection>(scCollection_);
71  produces<reco::SuperClusterRefVector>(refScCollection_);
72 }

References bcCollection_, cleanScToken_, edm::ParameterSet::getParameter(), refScCollection_, scCollection_, AlCaHLTBitMon_QueryRunRegistry::string, and uncleanScToken_.

◆ ~CleanAndMergeProducer()

CleanAndMergeProducer::~CleanAndMergeProducer ( )
override

Definition at line 74 of file CleanAndMergeProducer.cc.

74 { ; }

Member Function Documentation

◆ produce()

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

Definition at line 76 of file CleanAndMergeProducer.cc.

76  {
77  // get the input collections
78  // ______________________________________________________________________________________
79  //
80  // cluster collections:
81 
84 
85  evt.getByToken(cleanScToken_, pCleanSC);
86  evt.getByToken(uncleanScToken_, pUncleanSC);
87 
88  //
89  // collections are all taken now _____________________________________________________
90  //
91  //
92  // the collections to be produced:
93  reco::BasicClusterCollection basicClusters;
96 
97  //
98  // run over the uncleaned SC and check how many of them are matched to the cleaned ones
99  // if you find a matched one, create a reference to the cleaned collection and store it
100  // if you find an unmatched one, then keep all its basic clusters in the basic Clusters
101  // vector
102  int uncleanSize = pUncleanSC->size();
103  int cleanSize = pCleanSC->size();
104 
105  LogTrace("EcalCleaning") << "Size of Clean Collection: " << cleanSize << ", uncleanSize: " << uncleanSize
106  << std::endl;
107  //
108  // keep whether the SC in unique in the uncleaned collection
109  std::vector<int> isUncleanOnly; // 1 if unique in the uncleaned
110  std::vector<int> basicClusterOwner; // contains the index of the SC that owns that BS
111  std::vector<int> isSeed; // if this basic cluster is a seed it is 1
112  for (int isc = 0; isc < uncleanSize; ++isc) {
113  reco::SuperClusterRef unscRef(pUncleanSC, isc);
114  const std::vector<std::pair<DetId, float> >& uhits = unscRef->hitsAndFractions();
115  int uhitsSize = uhits.size();
116  bool foundTheSame = false;
117  for (int jsc = 0; jsc < cleanSize; ++jsc) { // loop over the cleaned SC
118  reco::SuperClusterRef cscRef(pCleanSC, jsc);
119  const std::vector<std::pair<DetId, float> >& chits = cscRef->hitsAndFractions();
120  int chitsSize = chits.size();
121  foundTheSame = true;
122  if (unscRef->seed()->seed() == cscRef->seed()->seed() && chitsSize == uhitsSize) {
123  // if the clusters are exactly the same then because the clustering
124  // algorithm works in a deterministic way, the order of the rechits
125  // will be the same
126  for (int i = 0; i < chitsSize; ++i) {
127  if (uhits[i].first != chits[i].first) {
128  foundTheSame = false;
129  break;
130  }
131  }
132  if (foundTheSame) { // ok you have found it!
133  // make the reference
134  //scRefs->push_back( edm::Ref<reco::SuperClusterCollection>(pCleanSC, jsc) );
135  scRefs->push_back(cscRef);
136  isUncleanOnly.push_back(0);
137  break;
138  }
139  }
140  }
141  if (not foundTheSame) {
142  // mark it as unique in the uncleaned
143  isUncleanOnly.push_back(1);
144  // keep all its basic clusters
145  for (reco::CaloCluster_iterator bciter = unscRef->clustersBegin(); bciter != unscRef->clustersEnd(); ++bciter) {
146  // the basic clusters
147  basicClusters.push_back(**bciter);
148  basicClusterOwner.push_back(isc);
149  }
150  }
151  }
152  int bcSize = basicClusters.size();
153 
154  LogDebug("EcalCleaning") << "Found cleaned SC: " << cleanSize << " uncleaned SC: " << uncleanSize << " from which "
155  << scRefs->size() << " will become refs to the cleaned collection";
156 
157  // now you have the collection of basic clusters of the SC to be remain in the
158  // in the clean collection, export them to the event
159  // you will need to reread them later in order to make correctly the refs to the SC
160  auto basicClusters_p = std::make_unique<reco::BasicClusterCollection>();
161  basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
163  if (!(bccHandle.isValid())) {
164  edm::LogWarning("MissingInput") << "could not get a handle on the BasicClusterCollection!" << std::endl;
165  return;
166  }
167 
168  LogDebug("EcalCleaning") << "Got the BasicClusters from the event again";
169  // now you have to create again your superclusters
170  // you run over the uncleaned SC, but now you know which of them are
171  // the ones that are needed and which are their basic clusters
172  for (int isc = 0; isc < uncleanSize; ++isc) {
173  if (isUncleanOnly[isc] == 1) { // look for sc that are unique in the unclean collection
174  // make the basic cluster collection
175  reco::CaloClusterPtrVector clusterPtrVector;
176  reco::CaloClusterPtr seed; // the seed is the basic cluster with the highest energy
177  double energy = -1;
178  for (int jbc = 0; jbc < bcSize; ++jbc) {
179  if (basicClusterOwner[jbc] == isc) {
180  reco::CaloClusterPtr currentClu = reco::CaloClusterPtr(bccHandle, jbc);
181  clusterPtrVector.push_back(currentClu);
182  if (energy < currentClu->energy()) {
183  energy = currentClu->energy();
184  seed = currentClu;
185  }
186  }
187  }
188  reco::SuperClusterRef unscRef(pUncleanSC, isc);
189  reco::SuperCluster newSC(unscRef->energy(), unscRef->position(), seed, clusterPtrVector);
190  superClusters.push_back(newSC);
191  }
192  }
193  // export the collection of references to the clean collection
194  std::unique_ptr<reco::SuperClusterRefVector> scRefs_p(scRefs);
195  evt.put(std::move(scRefs_p), refScCollection_);
196 
197  // the collection of basic clusters is already in the event
198  // the collection of uncleaned SC
199  auto superClusters_p = std::make_unique<reco::SuperClusterCollection>();
200  superClusters_p->assign(superClusters.begin(), superClusters.end());
201  evt.put(std::move(superClusters_p), scCollection_);
202  LogDebug("EcalCleaning") << "Hybrid Clusters (Basic/Super) added to the Event! :-)";
203 }

References bcCollection_, cleanScToken_, HCALHighEnergyHPDFilter_cfi::energy, first, edm::Event::getByToken(), mps_fire::i, edm::OrphanHandleBase::isValid(), LogDebug, LogTrace, eostools::move(), edm::RefVector< C, T, F >::push_back(), edm::PtrVector< T >::push_back(), edm::Event::put(), refScCollection_, scCollection_, fileCollector::seed, edm::RefVector< C, T, F >::size(), HLT_FULL_cff::superClusters, and uncleanScToken_.

Member Data Documentation

◆ bcCollection_

std::string CleanAndMergeProducer::bcCollection_
private

Definition at line 30 of file CleanAndMergeProducer.h.

Referenced by CleanAndMergeProducer(), and produce().

◆ cleanScToken_

edm::EDGetTokenT<reco::SuperClusterCollection> CleanAndMergeProducer::cleanScToken_
private

Definition at line 26 of file CleanAndMergeProducer.h.

Referenced by CleanAndMergeProducer(), and produce().

◆ refScCollection_

std::string CleanAndMergeProducer::refScCollection_
private

Definition at line 32 of file CleanAndMergeProducer.h.

Referenced by CleanAndMergeProducer(), and produce().

◆ scCollection_

std::string CleanAndMergeProducer::scCollection_
private

Definition at line 31 of file CleanAndMergeProducer.h.

Referenced by CleanAndMergeProducer(), and produce().

◆ uncleanScToken_

edm::EDGetTokenT<reco::SuperClusterCollection> CleanAndMergeProducer::uncleanScToken_
private

Definition at line 27 of file CleanAndMergeProducer.h.

Referenced by CleanAndMergeProducer(), and produce().

mps_fire.i
i
Definition: mps_fire.py:428
reco::SuperCluster
Definition: SuperCluster.h:18
CleanAndMergeProducer::refScCollection_
std::string refScCollection_
Definition: CleanAndMergeProducer.h:32
edm::PtrVectorItr
Definition: PtrVector.h:51
CleanAndMergeProducer::uncleanScToken_
edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScToken_
Definition: CleanAndMergeProducer.h:27
edm::RefVector
Definition: EDProductfwd.h:27
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
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
edm::PtrVector< CaloCluster >
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
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
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
edm::OrphanHandleBase::isValid
bool isValid() const
Definition: OrphanHandleBase.h:53
edm::Ptr< CaloCluster >
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
CleanAndMergeProducer::cleanScToken_
edm::EDGetTokenT< reco::SuperClusterCollection > cleanScToken_
Definition: CleanAndMergeProducer.h:26
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::SuperClusterRefVector
edm::RefVector< SuperClusterCollection > SuperClusterRefVector
vector of references to objects in the same colletion of SuperCluster objects
Definition: SuperClusterFwd.h:21
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
edm::RefVector::size
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
edm::InputTag
Definition: InputTag.h:15
CleanAndMergeProducer::bcCollection_
std::string bcCollection_
Definition: CleanAndMergeProducer.h:30
CleanAndMergeProducer::scCollection_
std::string scCollection_
Definition: CleanAndMergeProducer.h:31