test
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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 
 UncleanSCRecoveryProducer (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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_, cleanBcCollection_, cleanScCollection_, edm::ParameterSet::getParameter(), scCollection_, AlCaHLTBitMon_QueryRunRegistry::string, uncleanBcCollection_, and uncleanScCollection_.

39 {
40 
43 
44  // get the parameters
45  // the cleaned collection:
47  consumes<BasicClusterCollection>(ps.getParameter<edm::InputTag>("cleanBcCollection"));
49  consumes<SuperClusterCollection>(ps.getParameter<edm::InputTag>("cleanScCollection"));
50 
51  // the uncleaned collection
53  consumes<BasicClusterCollection>(ps.getParameter<edm::InputTag>("uncleanBcCollection"));
55  consumes<SuperClusterCollection>(ps.getParameter<edm::InputTag>("uncleanScCollection"));
56  // the names of the products to be produced:
57  bcCollection_ = ps.getParameter<std::string>("bcCollection");
58  scCollection_ = ps.getParameter<std::string>("scCollection");
59  // the products:
60  produces< reco::BasicClusterCollection >(bcCollection_);
61  produces< reco::SuperClusterCollection >(scCollection_);
62 
63 
64 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::SuperClusterCollection > cleanScCollection_
edm::EDGetTokenT< reco::BasicClusterCollection > cleanBcCollection_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScCollection_
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
edm::EDGetTokenT< reco::BasicClusterCollection > uncleanBcCollection_

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 67 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_.

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

Member Data Documentation

std::string UncleanSCRecoveryProducer::bcCollection_
private

Definition at line 34 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

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

Definition at line 28 of file UncleanSCRecoveryProducer.h.

Referenced by UncleanSCRecoveryProducer().

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

Definition at line 29 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

std::string UncleanSCRecoveryProducer::scCollection_
private

Definition at line 35 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

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

Definition at line 31 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

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

Definition at line 32 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().