CMS 3D CMS Logo

SiPixelPhase1TrackClustersV.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelPhase1TrackClustersV
4 // Class: SiPixelPhase1TrackClustersV
5 //
6 
7 // Original Author: Marcel Schneider
8 // Additional Authors: Alexander Morton - modifying code for validation use
9 
12 
24 
25 
27  SiPixelPhase1Base(iConfig)
28 {
29  clustersToken_ = consumes<edmNew::DetSetVector<SiPixelCluster>>(iConfig.getParameter<edm::InputTag>("clusters"));
30  tracksToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
31 }
32 
34 
35  // get geometry
37  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
38  assert(tracker.isValid());
39 
40  //get the map
42  iEvent.getByToken( tracksToken_, tracks);
43 
44  // get clusters
46  iEvent.getByToken( clustersToken_, clusterColl );
47 
48  // we need to store some per-cluster data. Instead of a map, we use a vector,
49  // exploiting the fact that all custers live in the DetSetVector and we can
50  // use the same indices to refer to them.
51  // corr_charge is not strictly needed but cleaner to have it.
52  std::vector<bool> ontrack (clusterColl->data().size(), false);
53  std::vector<float> corr_charge(clusterColl->data().size(), -1.0f);
54 
55  for (auto const & track : *tracks) {
56 
57  auto const & trajParams = track.extra()->trajParams();
58  assert(trajParams.size()==track.recHitsSize());
59  auto hb = track.recHitsBegin();
60  for(unsigned int h=0;h<track.recHitsSize();h++){
61  auto hit = *(hb+h);
62  if (!hit->isValid()) continue;
63  DetId id = hit->geographicalId();
64 
65  // check that we are in the pixel
66  uint32_t subdetid = (id.subdetId());
67  if (subdetid != PixelSubdetector::PixelBarrel && subdetid != PixelSubdetector::PixelEndcap) continue;
68  auto pixhit = dynamic_cast<const SiPixelRecHit*>(hit->hit());
69  if (!pixhit) continue;
70 
71  // get the cluster
72  auto clust = pixhit->cluster();
73  if (clust.isNull()) continue;
74  ontrack[clust.key()] = true; // mark cluster as ontrack
75 
76 
77  // correct charge for track impact angle
78  auto const & ltp = trajParams[h];
79  LocalVector localDir = ltp.momentum()/ltp.momentum().mag();
80 
81  float clust_alpha = atan2(localDir.z(), localDir.x());
82  float clust_beta = atan2(localDir.z(), localDir.y());
83  double corrCharge = clust->charge()/1000. * sqrt( 1.0 / ( 1.0/pow( tan(clust_alpha), 2 ) +
84  1.0/pow( tan(clust_beta ), 2 ) +
85  1.0 ));
86  corr_charge[clust.key()] = (float) corrCharge;
87  }
88 
90  for (it = clusterColl->begin(); it != clusterColl->end(); ++it) {
91  auto id = DetId(it->detId());
92 
93  for(auto subit = it->begin(); subit != it->end(); ++subit) {
94  // we could do subit-...->data().front() as well, but this seems cleaner.
95  auto key = edmNew::makeRefTo(clusterColl, subit).key();
96  float corrected_charge = corr_charge[key];
97  SiPixelCluster const& cluster = *subit;
98 
99  histo[CHARGE].fill(double(corrected_charge), id, &iEvent);
100  histo[SIZE_X].fill(double(cluster.sizeX() ), id, &iEvent);
101  histo[SIZE_Y].fill(double(cluster.sizeY() ), id, &iEvent);
102  }
103  }
104  }
105 
106 }
107 
109 
T getParameter(std::string const &) const
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
void analyze(const edm::Event &, const edm::EventSetup &)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
SiPixelPhase1TrackClustersV(const edm::ParameterSet &conf)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
T y() const
Definition: PV3DBase.h:63
int iEvent
Definition: GenABIO.cc:230
T mag() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
Definition: DetId.h:18
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
const T & get() const
Definition: EventSetup.h:55
std::vector< HistogramManager > histo
int sizeY() const
Pixel cluster – collection of neighboring pixels above threshold.
bool isValid() const
Definition: ESHandle.h:47
int sizeX() const
T x() const
Definition: PV3DBase.h:62
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > clustersToken_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
const_iterator begin(bool update=false) const
Our base class.
Definition: SiPixelRecHit.h:23