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::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 
 UncleanSCRecoveryProducer (const edm::ParameterSet &ps)
 
 ~UncleanSCRecoveryProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

std::string bcCollection_
 
edm::InputTag cleanBcCollection_
 
edm::InputTag cleanScCollection_
 
std::string scCollection_
 
edm::InputTag uncleanBcCollection_
 
edm::InputTag uncleanScCollection_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 17 of file UncleanSCRecoveryProducer.h.

Constructor & Destructor Documentation

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

Definition at line 39 of file UncleanSCRecoveryProducer.cc.

References bcCollection_, cleanBcCollection_, cleanScCollection_, edm::ParameterSet::getParameter(), scCollection_, uncleanBcCollection_, and uncleanScCollection_.

40 {
41 
42  // get the parameters
43  // the cleaned collection:
44  cleanBcCollection_ = ps.getParameter<edm::InputTag>("cleanBcCollection");
45  cleanScCollection_ = ps.getParameter<edm::InputTag>("cleanScCollection");
46  // the uncleaned collection
47  uncleanBcCollection_ = ps.getParameter<edm::InputTag>("uncleanBcCollection");
48  uncleanScCollection_ = ps.getParameter<edm::InputTag>("uncleanScCollection");
49  // the names of the products to be produced:
50  bcCollection_ = ps.getParameter<std::string>("bcCollection");
51  scCollection_ = ps.getParameter<std::string>("scCollection");
52  // the products:
53  produces< reco::BasicClusterCollection >(bcCollection_);
54  produces< reco::SuperClusterCollection >(scCollection_);
55 
56 
57 }
T getParameter(std::string const &) const
UncleanSCRecoveryProducer::~UncleanSCRecoveryProducer ( )

Definition at line 59 of file UncleanSCRecoveryProducer.cc.

59 {;}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 61 of file UncleanSCRecoveryProducer.cc.

References bcCollection_, cleanScCollection_, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), reco::CaloCluster::common, reco::CaloCluster::energy(), reco::CaloCluster::eta(), edm::Event::getByLabel(), i, reco::CaloCluster::isInClean(), reco::CaloCluster::isInUnclean(), edm::OrphanHandleBase::isValid(), edm::HandleBase::isValid(), LogTrace, reco::CaloCluster::position(), edm::Handle< T >::product(), edm::PtrVector< T >::push_back(), edm::Event::put(), scCollection_, reco::SuperCluster::seed(), reco::CaloCluster::setFlags(), uncleanBcCollection_, reco::CaloCluster::uncleanOnly, and uncleanScCollection_.

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

Member Data Documentation

std::string UncleanSCRecoveryProducer::bcCollection_
private

Definition at line 36 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

edm::InputTag UncleanSCRecoveryProducer::cleanBcCollection_
private

Definition at line 30 of file UncleanSCRecoveryProducer.h.

Referenced by UncleanSCRecoveryProducer().

edm::InputTag UncleanSCRecoveryProducer::cleanScCollection_
private

Definition at line 31 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

std::string UncleanSCRecoveryProducer::scCollection_
private

Definition at line 37 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

edm::InputTag UncleanSCRecoveryProducer::uncleanBcCollection_
private

Definition at line 33 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().

edm::InputTag UncleanSCRecoveryProducer::uncleanScCollection_
private

Definition at line 34 of file UncleanSCRecoveryProducer.h.

Referenced by produce(), and UncleanSCRecoveryProducer().