CMS 3D CMS Logo

HLTPixelAsymmetryFilter.cc
Go to the documentation of this file.
1 //
3 // HLTPixelAsymmetryFilter
4 //
5 // See header file for infos
6 //
7 // S.Viret: 12/01/2011 (viret@in2p3.fr)
8 //
10 
12 
13 //
14 // constructors and destructor
15 //
16 
18  inputTag_ (config.getParameter<edm::InputTag>("inputTag")),
19  min_asym_ (config.getParameter<double>("MinAsym")),
20  max_asym_ (config.getParameter<double>("MaxAsym")),
21  clus_thresh_ (config.getParameter<double>("MinCharge")),
22  bmincharge_ (config.getParameter<double>("MinBarrel"))
23 {
24  inputToken_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(inputTag_);
25  LogDebug("") << "Using the " << inputTag_ << " input collection";
26  LogDebug("") << "Requesting events with a charge repartition asymmetry between " << min_asym_ << " and " << max_asym_;
27  LogDebug("") << "Mean cluster charge in the barrel should be higher than" << bmincharge_ << " electrons ";
28  LogDebug("") << "Only clusters with a charge larger than " << clus_thresh_ << " electrons will be used ";
29 }
30 
32 
33 void
37  desc.add<edm::InputTag>("inputTag",edm::InputTag("hltSiPixelClusters"));
38  desc.add<double>("MinAsym",0.); // minimum asymmetry
39  desc.add<double>("MaxAsym",1.); // maximum asymmetry
40  desc.add<double>("MinCharge",4000.); // minimum charge for a cluster to be selected (in e-)
41  desc.add<double>("MinBarrel",10000.); // minimum average charge in the barrel (bpix, in e-)
42  descriptions.add("hltPixelAsymmetryFilter",desc);
43 }
44 
45 //
46 // member functions
47 //
48 
49 // ------------ method called to produce the data ------------
51 {
52  // All HLT filters must create and fill an HLT filter object,
53  // recording any reconstructed physics objects satisfying (or not)
54  // this HLT filter, and place it in the Event.
55 
56  // The filter object
57  if (saveTags()) filterproduct.addCollectionTag(inputTag_);
58 
59  // get hold of products from Event
61  event.getByToken(inputToken_, clusterColl);
62 
63  unsigned int clusterSize = clusterColl->dataSize();
64  LogDebug("") << "Number of clusters accepted: " << clusterSize;
65 
66  bool accept = (clusterSize >= 2); // Not necessary to go further in this case
67 
68  if (!accept) return accept;
69 
70  double asym_pix_1 = -1;
71  double asym_pix_2 = -1;
72 
73  int n_clus[3] = {0,0,0};
74  double e_clus[3] = {0.,0.,0.};
75 
76  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter=clusterColl->begin(); DSViter!=clusterColl->end();DSViter++ )
77  {
80  uint32_t detid = DSViter->id();
81 
82  bool barrel = DetId(detid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
83  bool endcap = DetId(detid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
84 
85  int detpos = -1;
86 
87  // First we look if we are in the endcap or in the barrel PIXELS
88  // Asymmetry is computed with endcap pixels only
89 
90  if (endcap)
91  {
93 
94  if (position == PixelEndcapName::mI || position == PixelEndcapName::mO) // FPIX-
95  detpos = 0;
96 
97  if (position == PixelEndcapName::pI || position == PixelEndcapName::pO) // FPIX+
98  detpos = 2;
99  }
100 
101  if (barrel)
102  detpos = 1;
103 
104  if (detpos<0) continue;
105 
106  for(edmNew::DetSet<SiPixelCluster>::const_iterator iter=begin;iter!=end;++iter)
107  {
108  if (iter->charge()>clus_thresh_ )
109  {
110  ++n_clus[detpos];
111  e_clus[detpos]+=iter->charge();
112  }
113  }
114  } // End of cluster loop
115 
116  for (int i=0;i<3;++i)
117  {
118  if (n_clus[i])
119  e_clus[i] /= n_clus[i];
120  }
121 
122  if (e_clus[1] < bmincharge_) return false; // Reject event if the Barrel mean charge is too low
123 
124 
125  if (e_clus[0]+e_clus[2] != 0) // Compute asyms, if applicable
126  {
127  asym_pix_1 = e_clus[0]/(e_clus[0]+e_clus[2]);
128  asym_pix_2 = e_clus[2]/(e_clus[0]+e_clus[2]);
129  }
130  else // Otherwise reject event
131  {
132  return false;
133  }
134 
135  bool pkam_1 = (asym_pix_1 <= max_asym_ && asym_pix_1 >= min_asym_);
136  bool pkam_2 = (asym_pix_2 <= max_asym_ && asym_pix_2 >= min_asym_);
137 
138  if (pkam_1 || pkam_2) return accept; // Final selection
139 
140  return false;
141 }
142 
143 // declare this class as a framework plugin
#define LogDebug(id)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > inputToken_
HLTPixelAsymmetryFilter(const edm::ParameterSet &)
data_type const * const_iterator
Definition: DetSetNew.h:30
Definition: config.py:1
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
#define end
Definition: vmac.h:39
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: DetId.h:18
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~HLTPixelAsymmetryFilter() override
bool saveTags() const
Definition: HLTFilter.h:45
#define begin
Definition: vmac.h:32
HLT enums.
static int position[264][3]
Definition: ReadPGInfo.cc:509
HalfCylinder halfCylinder() const
Definition: event.py:1
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)