CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HitPixelLayersTPSelector.h
Go to the documentation of this file.
1 #ifndef HitPixelLayersTrackSelection_h
2 #define HitPixelLayersTrackSelection_h
3 
6 
10 
19 {
20 
21  public:
22  // input collection type
24 
25 
26  // output collection type
27  typedef std::vector<const TrackingParticle*> container;
28 
29  // iterator over result collection type.
30  typedef container::const_iterator const_iterator;
31 
32  // constructor from parameter set configurability
34  tripletSeedOnly_(iConfig.getParameter<bool>("tripletSeedOnly")),
35  ptMin_(iConfig.getParameter<double>("ptMin")),
36  minRapidity_(iConfig.getParameter<double>("minRapidity")),
37  maxRapidity_(iConfig.getParameter<double>("maxRapidity")),
38  tip_(iConfig.getParameter<double>("tip")),
39  lip_(iConfig.getParameter<double>("lip")),
40  minHit_(iConfig.getParameter<int>("minHit")),
41  signalOnly_(iConfig.getParameter<bool>("signalOnly")),
42  chargedOnly_(iConfig.getParameter<bool>("chargedOnly")),
43  primaryOnly_(iConfig.getParameter<bool>("primaryOnly")),
44  tpStatusBased_(iConfig.getParameter<bool>("tpStatusBased")),
45  pdgId_(iConfig.getParameter< std::vector<int> >("pdgId"))
46  {};
47 
48  // select object from a collection and
49  // possibly event content
50  void select( const edm::Handle<collection> & TPCH, const edm::Event & iEvent, const edm::EventSetup & iSetup)
51  {
52  selected_.clear();
53  //Retrieve tracker topology from geometry
55  iSetup.get<IdealGeometryRecord>().get(tTopoHand);
56  const TrackerTopology *tTopo=tTopoHand.product();
57 
58 
59  const collection & tpc = *(TPCH.product());
60 
61  for (TrackingParticleCollection::size_type i=0; i<tpc.size(); i++)
62  {
63  TrackingParticleRef tpr(TPCH, i);
64 
65  // quickly reject if it is from pile-up
66  if (signalOnly_ && !(tpr->eventId().bunchCrossing()==0 && tpr->eventId().event()==0) ) continue;
67  if (chargedOnly_ && tpr->charge()==0) continue; //select only if charge!=0
68  if (tpStatusBased_ && primaryOnly_ && tpr->status()!=1 ) continue; // TP status based sel primary
69  if ((!tpStatusBased_) && primaryOnly_ && tpr->parentVertex()->nSourceTracks()!=0 ) continue; // vertex based sel for primary
70 
71  // loop over specified PID values
72  bool testId = false;
73  unsigned int idSize = pdgId_.size();
74  if (idSize==0) testId = true;
75  else for (unsigned int it=0;it!=idSize;++it){
76  if (tpr->pdgId()==pdgId_[it]) testId = true;
77  }
78 
79  // selection criteria
80  if ( tpr->numberOfTrackerLayers() >= minHit_ &&
81  sqrt(tpr->momentum().perp2()) >= ptMin_ &&
82  tpr->momentum().eta() >= minRapidity_ && tpr->momentum().eta() <= maxRapidity_ &&
83  sqrt(tpr->vertex().perp2()) <= tip_ &&
84  fabs(tpr->vertex().z()) <= lip_ &&
85  testId)
86  {
87  if (tripletSeedOnly_ && !goodHitPattern(pixelHitPattern(tpr,tTopo)) ) continue; //findable triplet seed
88  const TrackingParticle * trap = &(tpc[i]);
89  selected_.push_back(trap);
90  }
91 
92  }
93  }
94 
95  // return pixel layer hit pattern
96  std::vector<bool> pixelHitPattern( const TrackingParticleRef& simTrack, const TrackerTopology *tTopo )
97  {
98  std::vector<bool> hitpattern(5,false); // PXB 0,1,2 PXF 0,1
99 
100 #warning "This file has been modified just to get it to compile without any regard as to whether it still functions as intended"
101 #ifdef REMOVED_JUST_TO_GET_IT_TO_COMPILE__THIS_CODE_NEEDS_TO_BE_CHECKED
102  for(std::vector<PSimHit>::const_iterator simHit = simTrack->pSimHit_begin();simHit!= simTrack->pSimHit_end();simHit++){
103 
104  DetId id = DetId(simHit->detUnitId());
105  uint32_t detid = id.det();
106  uint32_t subdet = id.subdetId();
107 
108  if (detid == DetId::Tracker) {
109  if (subdet == PixelSubdetector::PixelBarrel)
110  hitpattern[tTopo->pxbLayer(id)-1]=true;
111  else if (subdet == PixelSubdetector::PixelEndcap)
112  hitpattern[tTopo->pxfDisk(id)+2]=true;
113  }
114 
115  }// end simhit loop
116 #endif
117 
118  return hitpattern;
119  }
120 
121  // test whether hit pattern would give a pixel triplet seed
122  bool goodHitPattern( const std::vector<bool>& hitpattern )
123  {
124  if( (hitpattern[0] && hitpattern[1] && hitpattern[2]) ||
125  (hitpattern[0] && hitpattern[1] && hitpattern[3]) ||
126  (hitpattern[0] && hitpattern[3] && hitpattern[4]) )
127  return true;
128  else
129  return false;
130  }
131 
132  // iterators over selected objects: collection begin
134  {
135  return selected_.begin();
136  }
137 
138  // iterators over selected objects: collection end
140  {
141  return selected_.end();
142  }
143 
144  // true if no object has been selected
145  size_t size() const
146  {
147  return selected_.size();
148  }
149 
150  //private:
151 
154  double ptMin_;
155  double minRapidity_;
156  double maxRapidity_;
157  double tip_;
158  double lip_;
159  int minHit_;
164  std::vector<int> pdgId_;
165 
166 
167 };
168 
169 
170 #endif
int i
Definition: DBlmapReader.cc:9
std::vector< TrackingParticle > TrackingParticleCollection
unsigned int pxfDisk(const DetId &id) const
std::vector< bool > pixelHitPattern(const TrackingParticleRef &simTrack, const TrackerTopology *tTopo)
std::vector< const TrackingParticle * > container
uint16_t size_type
HitPixelLayersTPSelector(const edm::ParameterSet &iConfig)
int iEvent
Definition: GenABIO.cc:243
TrackingParticleCollection collection
void select(const edm::Handle< collection > &TPCH, const edm::Event &iEvent, const edm::EventSetup &iSetup)
T sqrt(T t)
Definition: SSEVec.h:48
unsigned int pxbLayer(const DetId &id) const
container::const_iterator const_iterator
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
bool goodHitPattern(const std::vector< bool > &hitpattern)
Monte Carlo truth information used for tracking validation.
const_iterator begin() const