CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual 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
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

const std::string bcCollection_
 
const edm::EDGetTokenT
< reco::BasicClusterCollection
cleanBcCollection_
 
const edm::EDGetTokenT
< reco::SuperClusterCollection
cleanScCollection_
 
const std::string scCollection_
 
const edm::EDGetTokenT
< reco::BasicClusterCollection
uncleanBcCollection_
 
const edm::EDGetTokenT
< reco::SuperClusterCollection
uncleanScCollection_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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
overridevirtual

Implements edm::global::EDProducerBase.

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(), i, reco::CaloCluster::isInClean(), reco::CaloCluster::isInUnclean(), edm::OrphanHandleBase::isValid(), LogTrace, reco::CaloCluster::position(), edm::Handle< T >::product(), edm::PtrVector< T >::push_back(), edm::Event::put(), scCollection_, reco::SuperCluster::seed(), fileCollector::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  std::auto_ptr< reco::BasicClusterCollection> basicClusters_p(new reco::BasicClusterCollection);
125  basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
127  evt.put(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  std::auto_ptr< reco::SuperClusterCollection>
185  superClusters_p(new reco::SuperClusterCollection);
186  superClusters_p->assign(superClusters.begin(), superClusters.end());
187 
188  evt.put(superClusters_p, scCollection_);
189 
190  LogTrace("EcalCleaning")<<"Clusters (Basic/Super) added to the Event! :-)";
191 
192  // ----- debugging ----------
193  // print the new collection SC quantities
194  // print out the clean collection SC
195  LogTrace("EcalCleaning") << "Clean Collection SC ";
196  for (int i=0; i < cleanSize; ++i) {
197  const reco::SuperCluster csc = cleanSC[i];
198  LogTrace("EcalCleaning") << " >>> clean #" << i << "; Energy: " << csc.energy()
199  << " eta: " << csc.eta()
200  << " sc seed detid: " << csc.seed()->seed().rawId();
201  }
202  // the unclean SC
203  LogTrace("EcalCleaning") << "Unclean Collection SC ";
204  for (int i=0; i < uncleanSize; ++i) {
205  const reco::SuperCluster usc = uncleanSC[i];
206  LogTrace("EcalCleaning") << " >>> unclean #" << i << "; Energy: " << usc.energy()
207  << " eta: " << usc.eta()
208  << " sc seed detid: " << usc.seed()->seed().rawId();
209  }
210  // the new collection
211  LogTrace("EcalCleaning")<<"The new SC clean collection with size "<< superClusters.size();
212  for (unsigned int i=0; i < superClusters.size(); ++i) {
213  const reco::SuperCluster nsc = superClusters[i];
214  LogTrace("EcalCleaning")<< " >>> newSC #" << i << "; Energy: " << nsc.energy()
215  << " eta: " << nsc.eta() << " isClean="
216  << nsc.isInClean() << " isUnclean=" << nsc.isInUnclean()
217  << " sc seed detid: " << nsc.seed()->seed().rawId();
218  }
219 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:126
int i
Definition: DBlmapReader.cc:9
bool isInUnclean() const
Definition: CaloCluster.h:181
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:141
edm::Ptr< CaloCluster > CaloClusterPtr
const edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScCollection_
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:163
const edm::EDGetTokenT< reco::SuperClusterCollection > cleanScCollection_
void setFlags(uint32_t flags)
Definition: CaloCluster.h:176
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
double energy() const
cluster energy
Definition: CaloCluster.h:121
#define LogTrace(id)
bool isInClean() const
Definition: CaloCluster.h:180
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
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().