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 Member Functions | Private Attributes
EEBadScFilter Class Reference
Inheritance diagram for EEBadScFilter:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EEBadScFilter (const edm::ParameterSet &iConfig)
 
 ~EEBadScFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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 Member Functions

virtual bool filter (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual void scan5x5 (const DetId &det, const edm::Handle< EcalRecHitCollection > &hits, const edm::ESHandle< CaloTopology > &caloTopo, const edm::ESHandle< CaloGeometry > &geometry, int &nHits, float &totEt)
 

Private Attributes

const std::vector< int > badsc_
 
const bool debug_
 
const edm::EDGetTokenT
< EcalRecHitCollection
eeRHSrcToken_
 
const double Emin_
 
const double EtminSC_
 
const int nBadHitsSC_
 
const int side_
 
const bool taggingMode_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter 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::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 37 of file EEBadScFilter.cc.

Constructor & Destructor Documentation

EEBadScFilter::EEBadScFilter ( const edm::ParameterSet iConfig)
explicit

Definition at line 72 of file EEBadScFilter.cc.

73  : eeRHSrcToken_ (consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("EERecHitSource")))
74  , Emin_ (iConfig.getParameter<double>("EminHit"))
75  , EtminSC_ (iConfig.getParameter<double>("EtminSC"))
76  , side_ (iConfig.getParameter<int>("SCsize"))
77  , nBadHitsSC_ (iConfig.getParameter<int>("nBadHitsSC"))
78  , badsc_ (iConfig.getParameter<std::vector<int> >("badscEE"))
79  , taggingMode_ (iConfig.getParameter<bool>("taggingMode"))
80  , debug_ (iConfig.getParameter<bool>("debug"))
81 {
82  produces<bool>();
83 }
const edm::EDGetTokenT< EcalRecHitCollection > eeRHSrcToken_
T getParameter(std::string const &) const
const double Emin_
const std::vector< int > badsc_
const bool debug_
const int nBadHitsSC_
const bool taggingMode_
const int side_
const double EtminSC_
EEBadScFilter::~EEBadScFilter ( )
inline

Definition at line 42 of file EEBadScFilter.cc.

42 {}

Member Function Documentation

bool EEBadScFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDFilter.

Definition at line 136 of file EEBadScFilter.cc.

References badsc_, gather_cfg::cout, debug_, eeRHSrcToken_, EtminSC_, edm::EventSetup::get(), edm::Event::getByToken(), nBadHitsSC_, nhits, edm::Event::put(), scan5x5(), and taggingMode_.

136  {
137 
138 
139  // load required collections
140 
141 
142  // EE rechit collection
144  iEvent.getByToken(eeRHSrcToken_, eeRHs);
145 
146  // Calo Geometry - needed for computing E_t
148  iSetup.get<CaloGeometryRecord>().get(pG);
149 
150  // Calo Toplology - needed for navigating the 5x5 xtal array around the centre of a SC
151  edm::ESHandle<CaloTopology> pTopology;
152  iSetup.get<CaloTopologyRecord>().get(pTopology);
153 
154  // by default the event is OK
155  bool pass = true;
156 
157 
158  // set discriminating variables to zero
159  int nhits=0;
160  float totEt=0.0;
161 
162 
163  // define detid variables and ix,iy,iz coordinates
164 
165  EEDetId scdet;
166  DetId det;
167 
168  int ix,iy,iz;
169 
170  ix=0,iy=0,iz=0;
171 
172 
173  // loop over the list of bad SCs (defined in the python file)
174 
175  for (std::vector<int>::const_iterator scit = badsc_.begin(); scit != badsc_.end(); ++ scit) {
176 
177 
178 
179  // unpack the SC coordinates from the python file into ix,iy,iz
180 
181  iz=int(*scit/1000000);
182  iy=*scit%100*iz;
183  ix=int((*scit-iy-1000000*iz)/1000)*iz;
184 
185  // make the DetId from these coordinates
186  scdet=EEDetId(ix,iy,iz);
187  det=scdet;
188 
189  // loop over the 5x5 SC centered on this DetId and fill discriminating variables
190 
191  scan5x5(det,eeRHs,pTopology,pG,nhits,totEt);
192 
193  // print some debug info
194 
195  if (debug_) {
196  std::cout << "EEBadScFilter.cc: SCID=" << *scit << std::endl;
197  std::cout << "EEBadScFilter.cc: ix=" << ix << " iy=" << iy << " iz=" << iz << std::endl;
198  std::cout << "EEBadScFilter.cc: Et(5x5)=" << totEt << " nbadhits=" << nhits << std::endl;
199  }
200 
201 
202  // if 5x5 transverse energy is above threshold and number of bad hits above threshold
203  // event is bad
204 
205  if (totEt>EtminSC_ && nhits>=nBadHitsSC_) pass=false;
206 
207 
208  }
209 
210  // print the decision if event is bad
211  if (pass==false && debug_) std::cout << "EEBadScFilter.cc: REJECT EVENT!!!" << std::endl;
212 
213 
214  iEvent.put( std::auto_ptr<bool>(new bool(pass)) );
215 
216  // return the decision
217 
218  return taggingMode_ || pass;
219 }
const edm::EDGetTokenT< EcalRecHitCollection > eeRHSrcToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
virtual void scan5x5(const DetId &det, const edm::Handle< EcalRecHitCollection > &hits, const edm::ESHandle< CaloTopology > &caloTopo, const edm::ESHandle< CaloGeometry > &geometry, int &nHits, float &totEt)
const std::vector< int > badsc_
const bool debug_
const int nBadHitsSC_
const bool taggingMode_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:56
const double EtminSC_
tuple cout
Definition: gather_cfg.py:121
void EEBadScFilter::scan5x5 ( const DetId det,
const edm::Handle< EcalRecHitCollection > &  hits,
const edm::ESHandle< CaloTopology > &  caloTopo,
const edm::ESHandle< CaloGeometry > &  geometry,
int &  nHits,
float &  totEt 
)
privatevirtual

Definition at line 86 of file EEBadScFilter.cc.

References EcalRecHit::checkFlag(), Emin_, EcalRecHit::energy(), CaloNavigator< T, TOPO >::home(), i, j, EcalRecHit::kGood, CaloNavigator< T, TOPO >::offsetBy(), AlCaHLTBitMon_ParallelJobs::p, and side_.

Referenced by filter().

87 {
88 
89  // function to compute: total transverse energy in a given supercrystal (totEt)
90  // number of hits with E>Emin_ and rechit flag != kGood (nHits)
91  // bad events have large totEt and many high energy hits with rechit flags !kGood
92 
93  nHits = 0;
94  totEt = 0;
95 
96  // navigator to define a 5x5 region around the input DetId
97 
98  CaloNavigator<DetId> cursor = CaloNavigator<DetId>(det,caloTopo->getSubdetectorTopology(det));
99 
100  // loop over a 5x5 array centered on the input DetId
101 
102  for(int j=side_/2; j>=-side_/2; --j)
103  {
104  for(int i=-side_/2; i<=side_/2; ++i)
105  {
106  cursor.home();
107  cursor.offsetBy(i,j);
108  if(hits->find(*cursor)!=hits->end()) // if hit exists in the rechit collection
109  {
110  EcalRecHit tmpHit = *hits->find(*cursor); // get rechit with detID at cursor
111 
112 
113  const GlobalPoint p ( geometry->getPosition(*cursor) ) ; // calculate Et of the rechit
114  TVector3 hitPos(p.x(),p.y(),p.z());
115  hitPos *= 1.0/hitPos.Mag();
116  hitPos *= tmpHit.energy();
117  float rechitEt = hitPos.Pt();
118 
119  //--- add rechit E_t to the total for this supercrystal
120  totEt += rechitEt;
121 
122  // increment nHits if E>Emin and rechit flag is not kGood
123  if(tmpHit.energy()>Emin_ && !tmpHit.checkFlag(EcalRecHit::kGood))nHits++;
124 
125  }
126  }
127  }
128 
129 
130 }
int i
Definition: DBlmapReader.cc:9
const double Emin_
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
Definition: CaloNavigator.h:80
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:172
const int side_
int j
Definition: DBlmapReader.cc:9
float energy() const
Definition: EcalRecHit.h:68
void home() const
move the navigator back to the starting point

Member Data Documentation

const std::vector<int> EEBadScFilter::badsc_
private

Definition at line 64 of file EEBadScFilter.cc.

Referenced by filter().

const bool EEBadScFilter::debug_
private

Definition at line 67 of file EEBadScFilter.cc.

Referenced by filter().

const edm::EDGetTokenT<EcalRecHitCollection> EEBadScFilter::eeRHSrcToken_
private

Definition at line 57 of file EEBadScFilter.cc.

Referenced by filter().

const double EEBadScFilter::Emin_
private

Definition at line 60 of file EEBadScFilter.cc.

Referenced by scan5x5().

const double EEBadScFilter::EtminSC_
private

Definition at line 61 of file EEBadScFilter.cc.

Referenced by filter().

const int EEBadScFilter::nBadHitsSC_
private

Definition at line 63 of file EEBadScFilter.cc.

Referenced by filter().

const int EEBadScFilter::side_
private

Definition at line 62 of file EEBadScFilter.cc.

Referenced by scan5x5().

const bool EEBadScFilter::taggingMode_
private

Definition at line 66 of file EEBadScFilter.cc.

Referenced by filter().