{"action":"created","comment":{"url":"https://api.github.com/repos/cms-sw/cmssw/pulls/comments/168311761","pull_request_review_id":96657012,"id":168311761,"diff_hunk":"@@ -0,0 +1,908 @@\n+/*\n+  \\class Phase2PixelNtuple\n+*/\n+\n+// DataFormats\n+#include \"DataFormats/Common/interface/DetSetVector.h\"\n+#include \"DataFormats/Common/interface/Handle.h\"\n+#include \"FWCore/Framework/interface/ConsumesCollector.h\"\n+#include \"DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h\"\n+\n+#include \"DataFormats/DetId/interface/DetId.h\"\n+#include \"DataFormats/TrackerCommon/interface/TrackerTopology.h\"\n+#include \"DataFormats/SiPixelDetId/interface/PixelSubdetector.h\"\n+#include \"DataFormats/SiPixelCluster/interface/SiPixelCluster.h\"\n+\n+#include \"DataFormats/TrackReco/interface/Track.h\"\n+\n+#include \"SimDataFormats/TrackingHit/interface/PSimHit.h\"\n+#include \"SimDataFormats/TrackingHit/interface/PSimHitContainer.h\"\n+#include \"SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h\"\n+#include \"SimDataFormats/Track/interface/SimTrack.h\"\n+#include \"SimDataFormats/Track/interface/SimTrackContainer.h\"\n+#include \"SimDataFormats/Vertex/interface/SimVertex.h\"\n+#include \"SimDataFormats/Vertex/interface/SimVertexContainer.h\"\n+\n+#include \"FWCore/Framework/interface/MakerMacros.h\"\n+#include \"FWCore/Framework/interface/EDAnalyzer.h\"\n+#include \"FWCore/Framework/interface/Event.h\"\n+#include \"FWCore/Framework/interface/EventSetup.h\"\n+#include \"FWCore/Utilities/interface/InputTag.h\"\n+#include \"FWCore/Framework/interface/ESHandle.h\"\n+#include \"FWCore/MessageLogger/interface/MessageLogger.h\"\n+#include \"FWCore/ParameterSet/interface/ParameterSet.h\"\n+\n+// Geometry\n+#include \"MagneticField/Engine/interface/MagneticField.h\"\n+#include \"Geometry/CommonDetUnit/interface/GeomDetType.h\"\n+#include \"Geometry/CommonDetUnit/interface/GeomDet.h\"\n+#include \"Geometry/Records/interface/IdealGeometryRecord.h\"\n+#include \"Geometry/Records/interface/TrackerDigiGeometryRecord.h\"\n+#include \"Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h\"\n+#include \"Geometry/TrackerGeometryBuilder/interface/PixelGeomDetType.h\"\n+#include \"Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h\"\n+#include \"Geometry/TrackerGeometryBuilder/interface/RectangularPixelTopology.h\"\n+#include \"Geometry/TrackerGeometryBuilder/interface/PixelTopologyBuilder.h\"\n+\n+// For ROOT\n+#include \"FWCore/ServiceRegistry/interface/Service.h\"\n+#include \"CommonTools/UtilAlgos/interface/TFileService.h\"\n+#include <TTree.h>\n+\n+// STD\n+#include <memory>\n+#include <string>\n+#include <iostream>\n+\n+using namespace std;\n+using namespace edm;\n+using namespace reco;\n+  \n+ \n+class Phase2PixelNtuple : public edm::EDAnalyzer\n+{\n+public:\n+   \n+  explicit Phase2PixelNtuple(const edm::ParameterSet& conf);\n+  virtual ~Phase2PixelNtuple();\n+  virtual void beginJob();\n+  virtual void endJob();\n+  virtual void analyze(const edm::Event& e, const edm::EventSetup& es);\n+ \n+protected:\n+ \n+  void fillEvt(const edm::Event& );\n+  //void fillPRecHit(const int subid, SiPixelRecHitCollection::const_iterator pixeliter,\n+  //                 const GeomDet* PixGeom);\n+  void fillPRecHit(const int detid_db, const int subid, \n+\t\t   const int layer_num,const int ladder_num,const int module_num,\n+\t\t   const int disk_num,const int blade_num,const int panel_num,const int side_num,\n+\t\t   SiPixelRecHitCollection::DetSet::const_iterator pixeliter,\n+\t\t   const int num_simhit,\n+\t\t   std::vector<PSimHit>::const_iterator closest_simhit,\n+\t\t   const GeomDet* PixGeom);\n+  void fillPRecHit(const int detid_db, const int subid,\n+\t\t   const int layer_num,const int ladder_num,const int module_num,\n+\t\t   const int disk_num,const int blade_num,const int panel_num,const int side_num,\n+\t\t   trackingRecHit_iterator pixeliter,\n+\t\t   const int num_simhit,\n+\t\t   std::vector<PSimHit>::const_iterator closest_simhit,\n+\t\t   const GeomDet* PixGeom);\n+  std::pair<float, float> computeAnglesFromDetPosition(const SiPixelCluster & cl, \n+\t\t\t\t\t\t       const PixelTopology  & top, \n+\t\t\t\t\t\t       const GeomDetUnit    & det ) const; \n+\n+private:\n+  edm::ParameterSet const conf_;\n+  TrackerHitAssociator::Config trackerHitAssociatorConfig_;\n+  edm::EDGetTokenT<edmNew::DetSetVector<SiPixelRecHit>> pixelRecHits_token;\n+  //edm::InputTag src_;\n+  edm::EDGetTokenT<edm::View<reco::Track> > token_recoTracks;\n+  bool verbose_;\n+  bool picky_;\n+  static const int DGPERCLMAX = 100;  \n+     \n+  //--- Structures for ntupling:\n+  struct evt\n+  {\n+    int run;\n+    int evtnum;\n+     \n+    void init();\n+  } evt_;\n+   \n+  struct RecHit \n+  {\n+    int pdgid;\n+    int process;\n+    float q;\n+    float x;\n+    float y;\n+    float xx;\n+    float xy;\n+    float yy;\n+    float row;\n+    float col;\n+    float gx;\n+    float gy;\n+    float gz;\n+    int subid,module;\n+    int layer,ladder;           // BPix\n+    int disk,blade,panel,side;  // FPix\n+    int nsimhit;\n+    int spreadx,spready;\n+    float hx, hy;\n+    float hrow, hcol;\n+    float tx, ty, tz;\n+    float theta, phi;\n+  \n+    // detector topology\n+    int nRowsInDet;\n+    int nColsInDet;\n+    float pitchx;\n+    float pitchy;\n+    float thickness;\n+\n+    // local angles from det position\n+    float cotAlphaFromDet, cotBetaFromDet;    \n+\n+    // digis\n+    int fDgN;  \n+    int fDgRow[DGPERCLMAX], fDgCol[DGPERCLMAX];\n+    int fDgDetId[DGPERCLMAX];\n+    //   int fDgRoc[DGPERCLMAX], fDgRocR[DGPERCLMAX], fDgRocC[DGPERCLMAX];\n+    float fDgAdc[DGPERCLMAX], fDgCharge[DGPERCLMAX];\n+\n+    void init();\n+  } recHit_;\n+\n+  edm::Service<TFileService> tFileService; \n+  TTree * pixeltree_;\n+  TTree * pixeltreeOnTrack_;\n+};\n+ \n+ \n+Phase2PixelNtuple::Phase2PixelNtuple(edm::ParameterSet const& conf) : \n+  trackerHitAssociatorConfig_(conf, consumesCollector()),\n+  pixelRecHits_token(consumes<edmNew::DetSetVector<SiPixelRecHit>>(edm::InputTag(\"siPixelRecHits\"))),\n+  //src_( conf.getParameter<edm::InputTag>( \"src\" ) ),\n+  token_recoTracks(consumes<edm::View<reco::Track> >(conf.getParameter<edm::InputTag>( \"trackProducer\" ))),  \n+  verbose_( conf.getUntrackedParameter<bool>(\"verbose\",false)),\n+  picky_(conf.getUntrackedParameter<bool>(\"picky\",false)),\n+  pixeltree_(0),\n+  pixeltreeOnTrack_(0)\n+{\n+}\n+ \n+ \n+Phase2PixelNtuple::~Phase2PixelNtuple() { }  \n+ \n+void Phase2PixelNtuple::endJob() \n+{\n+  std::cout << \" Phase2PixelNtuple::endJob\" << std::endl;\n+}\n+ \n+ \n+ \n+void Phase2PixelNtuple::beginJob()\n+{\n+  std::cout << \" Phase2PixelNtuple::beginJob\" << std::endl;\n+  pixeltree_        = tFileService->make<TTree>(\"PixelNtuple\",\"Pixel hit analyzer ntuple\");\n+  pixeltreeOnTrack_ = tFileService->make<TTree>(\"PixelNtupleOnTrack\",\"On-Track Pixel hit analyzer ntuple\");\n+\n+  int bufsize = 64000;\n+  //Common Branch\n+  // pixeltree_->Branch(\"evt\",    &evt_,      \"run/I:evtnum/I\", bufsize);\n+  // pixeltree_->Branch(\"pixel_recHit\", &recHit_, \n+  //                     \"pdgid/I:process:q/F:x:y:xx:xy:yy:row:col:gx:gy:gz:subid/I:module:layer:ladder:disk:blade:panel:side:nsimhit:spreadx:spready:hx/F:hy:tx:ty:tz:theta:phi:DgN/I:DgRow[DgN]/I:DgCol[DgN]/I:DgDetId[DgN]/I:DgAdc[DgN]/F:DgCharge[DgN]/F:DgClI[DgN]/I:ClN/I:ClDgN[ClN]/I:ClDgI[ClN][100]/I]\", bufsize);\n+\n+  //Common Branch\n+  pixeltree_->Branch(\"evt\",     &evt_ ,          \"run/I:evtnum/I\", bufsize);\n+  pixeltree_->Branch(\"pdgid\",   &recHit_.pdgid,  \"pdgid/I\"  );\n+  pixeltree_->Branch(\"process\", &recHit_.process,\"process/I\");\n+  pixeltree_->Branch(\"q\",       &recHit_.q               ,\"q/F\"\t    );\t   \n+  pixeltree_->Branch(\"x\",\t&recHit_.x     \t\t ,\"x/F\"\t    );\t   \n+  pixeltree_->Branch(\"y\",\t&recHit_.y     \t\t ,\"y/F\"\t    );\t   \n+  pixeltree_->Branch(\"xx\",\t&recHit_.xx    \t\t ,\"xx/F\"\t    );\t   \n+  pixeltree_->Branch(\"xy\",\t&recHit_.xy    \t\t ,\"xy/F\"\t    );\t   \n+  pixeltree_->Branch(\"yy\",\t&recHit_.yy    \t\t ,\"yy/F\"\t    );\t   \n+  pixeltree_->Branch(\"row\",\t&recHit_.row   \t\t ,\"row/F\"    );\t\t   \n+  pixeltree_->Branch(\"col\",\t&recHit_.col   \t\t ,\"col/F\"    );\t\t   \n+  pixeltree_->Branch(\"gx\",\t&recHit_.gx    \t\t ,\"gx/F\"\t    );\t   \n+  pixeltree_->Branch(\"gy\",\t&recHit_.gy    \t\t ,\"gy/F\"\t    );\t   \n+  pixeltree_->Branch(\"gz\",\t&recHit_.gz    \t\t ,\"gz/F\"\t    );\t   \n+  pixeltree_->Branch(\"subid\",\t&recHit_.subid \t\t ,\"subid/I\"  );\t   \n+  pixeltree_->Branch(\"module\",\t&recHit_.module \t ,\"module/I\" );\t   \n+  pixeltree_->Branch(\"layer\",\t&recHit_.layer \t\t ,\"layer/I\"  );\t   \n+  pixeltree_->Branch(\"ladder\",\t&recHit_.ladder      \t ,\"ladder/I\" );\t   \n+  pixeltree_->Branch(\"disk\",\t&recHit_.disk  \t\t ,\"disk/I\"   );\t   \n+  pixeltree_->Branch(\"blade\",\t&recHit_.blade \t\t ,\"blade/I\"  );\t   \n+  pixeltree_->Branch(\"panel\",\t&recHit_.panel \t\t ,\"panel/I\"  );\t   \n+  pixeltree_->Branch(\"side\",\t&recHit_.side  \t\t ,\"side/I\"   );\t   \n+  pixeltree_->Branch(\"nsimhit\",\t&recHit_.nsimhit\t ,\"nsimhit/I\");\t   \n+  pixeltree_->Branch(\"spreadx\",\t&recHit_.spreadx\t ,\"spreadx/I\");\t   \n+  pixeltree_->Branch(\"spready\",\t&recHit_.spready\t ,\"spready/I\");\t   \n+  pixeltree_->Branch(\"hx\",\t&recHit_.hx\t\t ,\"hx/F\");\t   \n+  pixeltree_->Branch(\"hy\",\t&recHit_.hy\t\t ,\"hy/F\");\t   \n+  pixeltree_->Branch(\"hrow\",\t&recHit_.hrow   \t ,\"hrow/F\");\t\t   \n+  pixeltree_->Branch(\"hcol\",\t&recHit_.hcol   \t ,\"hcol/F\");\t\n+  pixeltree_->Branch(\"tx\",\t&recHit_.tx\t\t ,\"tx/F\");\t   \n+  pixeltree_->Branch(\"ty\",\t&recHit_.ty\t\t ,\"ty/F\");\t   \n+  pixeltree_->Branch(\"tz\",\t&recHit_.tz\t\t ,\"tz/F\");\t   \n+  pixeltree_->Branch(\"theta\",\t&recHit_.theta\t\t ,\"theta/F\" );\t   \n+  pixeltree_->Branch(\"phi\",\t&recHit_.phi\t\t ,\"phi/F\"    );\t\t   \n+  pixeltree_->Branch(\"nRowsInDet\", &recHit_.nRowsInDet\t ,\"nRowsInDet/I\");\t\n+  pixeltree_->Branch(\"nColsInDet\", &recHit_.nColsInDet\t ,\"nColsInDet/I\");\n+  pixeltree_->Branch(\"pitchx\",     &recHit_.pitchx\t ,\"pitchx/F\");\n+  pixeltree_->Branch(\"pitchy\",     &recHit_.pitchy\t ,\"pitchy/F\");\t   \n+  pixeltree_->Branch(\"thickness\",  &recHit_.thickness\t ,\"thickness/F\");\t   \n+  pixeltree_->Branch(\"cotAlphaFromDet\",\t&recHit_.cotAlphaFromDet  ,\"cotAlphaFromDet/F\");\t   \n+  pixeltree_->Branch(\"cotBetaFromDet\",\t&recHit_.cotBetaFromDet\t  ,\"cotBetaFraomDet/F\");\t   \n+\n+  pixeltree_->Branch(\"DgN\",\t&recHit_.fDgN\t\t ,\"DgN/I\"    );\t\n+  pixeltree_->Branch(\"DgRow\",\t recHit_.fDgRow\t\t ,\"DgRow[DgN]/I\"  );\t   \n+  pixeltree_->Branch(\"DgCol\",\t recHit_.fDgCol\t\t ,\"DgCol[DgN]/I\"   ); \n+  pixeltree_->Branch(\"DgDetId\",\t recHit_.fDgDetId\t ,\"DgDetId[DgN]/I\" );  \n+  pixeltree_->Branch(\"DgAdc\",\t recHit_.fDgAdc\t\t ,\"DgAdc[DgN]/F\"   ); \n+  pixeltree_->Branch(\"DgCharge\", recHit_.fDgCharge\t ,\"DgCharge[DgN]/F\");  \n+\n+  //Common Branch (on-track)\n+  pixeltreeOnTrack_->Branch(\"evt\",     &evt_ ,          \"run/I:evtnum/I\", bufsize);\n+  pixeltreeOnTrack_->Branch(\"pdgid\",   &recHit_.pdgid,  \"pdgid/I\"  );\n+  pixeltreeOnTrack_->Branch(\"process\", &recHit_.process,\"process/I\");\n+  pixeltreeOnTrack_->Branch(\"q\",       &recHit_.q               ,\"q/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"x\",\t&recHit_.x     \t\t ,\"x/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"y\",\t&recHit_.y     \t\t ,\"y/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"xx\",\t&recHit_.xx    \t\t ,\"xx/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"xy\",\t&recHit_.xy    \t\t ,\"xy/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"yy\",\t&recHit_.yy    \t\t ,\"yy/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"row\",\t&recHit_.row   \t\t ,\"row/F\"    );\t\t   \n+  pixeltreeOnTrack_->Branch(\"col\",\t&recHit_.col   \t\t ,\"col/F\"    );\t\t   \n+  pixeltreeOnTrack_->Branch(\"gx\",\t&recHit_.gx    \t\t ,\"gx/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"gy\",\t&recHit_.gy    \t\t ,\"gy/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"gz\",\t&recHit_.gz    \t\t ,\"gz/F\"\t    );\t   \n+  pixeltreeOnTrack_->Branch(\"subid\",\t&recHit_.subid \t\t ,\"subid/I\"  );\t   \n+  pixeltreeOnTrack_->Branch(\"module\",\t&recHit_.module \t ,\"module/I\" );\t   \n+  pixeltreeOnTrack_->Branch(\"layer\",\t&recHit_.layer \t\t ,\"layer/I\"  );\t   \n+  pixeltreeOnTrack_->Branch(\"ladder\",\t&recHit_.ladder      \t ,\"ladder/I\" );\t   \n+  pixeltreeOnTrack_->Branch(\"disk\",\t&recHit_.disk  \t\t ,\"disk/I\"   );\t   \n+  pixeltreeOnTrack_->Branch(\"blade\",\t&recHit_.blade \t\t ,\"blade/I\"  );\t   \n+  pixeltreeOnTrack_->Branch(\"panel\",\t&recHit_.panel \t\t ,\"panel/I\"  );\t   \n+  pixeltreeOnTrack_->Branch(\"side\",\t&recHit_.side  \t\t ,\"side/I\"   );\t   \n+  pixeltreeOnTrack_->Branch(\"nsimhit\",&recHit_.nsimhit\t ,\"nsimhit/I\");\t   \n+  pixeltreeOnTrack_->Branch(\"spreadx\",&recHit_.spreadx\t ,\"spreadx/I\");\t   \n+  pixeltreeOnTrack_->Branch(\"spready\",&recHit_.spready\t ,\"spready/I\");\t   \n+  pixeltreeOnTrack_->Branch(\"hx\",\t&recHit_.hx\t\t ,\"hx/F\");\t   \n+  pixeltreeOnTrack_->Branch(\"hy\",\t&recHit_.hy\t\t ,\"hy/F\");\n+  pixeltreeOnTrack_->Branch(\"hrow\",\t&recHit_.hrow   \t ,\"hrow/F\");\t\t   \n+  pixeltreeOnTrack_->Branch(\"hcol\",\t&recHit_.hcol   \t ,\"hcol/F\");\n+  pixeltreeOnTrack_->Branch(\"tx\",\t&recHit_.tx\t\t ,\"tx/F\");\t   \n+  pixeltreeOnTrack_->Branch(\"ty\",\t&recHit_.ty\t\t ,\"ty/F\");\t   \n+  pixeltreeOnTrack_->Branch(\"tz\",\t&recHit_.tz\t\t ,\"tz/F\");\t   \n+  pixeltreeOnTrack_->Branch(\"theta\",\t&recHit_.theta\t\t ,\"theta/F\" );\t   \n+  pixeltreeOnTrack_->Branch(\"phi\",\t&recHit_.phi\t\t ,\"phi/F\"    );\t\n+  pixeltreeOnTrack_->Branch(\"nRowsInDet\", &recHit_.nRowsInDet\t ,\"nRowsInDet/I\");\t\n+  pixeltreeOnTrack_->Branch(\"nColsInDet\", &recHit_.nColsInDet\t ,\"nColsInDet/I\");\n+  pixeltreeOnTrack_->Branch(\"pitchx\",     &recHit_.pitchx\t ,\"pitchx/F\");\n+  pixeltreeOnTrack_->Branch(\"pitchy\",     &recHit_.pitchy\t ,\"pitchy/F\");\t  \t  \n+  pixeltreeOnTrack_->Branch(\"thickness\",  &recHit_.thickness\t ,\"thickness/F\");\t   \n+  pixeltreeOnTrack_->Branch(\"cotAlphaFromDet\",\t&recHit_.cotAlphaFromDet  ,\"cotAlphaFromDet/F\");\t   \n+  pixeltreeOnTrack_->Branch(\"cotBetaFromDet\",\t&recHit_.cotBetaFromDet\t  ,\"cotBetaFraomDet/F\");\t   \n+\n+  pixeltreeOnTrack_->Branch(\"DgN\",\t&recHit_.fDgN\t\t ,\"DgN/I\"    );\t\t   \n+  pixeltreeOnTrack_->Branch(\"DgRow\",\t recHit_.fDgRow\t\t ,\"DgRow[DgN]/I\"  );\t   \n+  pixeltreeOnTrack_->Branch(\"DgCol\",\t recHit_.fDgCol\t\t ,\"DgCol[DgN]/I\"   ); \n+  pixeltreeOnTrack_->Branch(\"DgDetId\",\t recHit_.fDgDetId\t ,\"DgDetId[DgN]/I\" );  \n+  pixeltreeOnTrack_->Branch(\"DgAdc\",\t recHit_.fDgAdc\t\t ,\"DgAdc[DgN]/F\"   ); \n+  pixeltreeOnTrack_->Branch(\"DgCharge\",  recHit_.fDgCharge\t ,\"DgCharge[DgN]/F\");  \n+}\n+ \n+// Functions that gets called by framework every event\n+void Phase2PixelNtuple::analyze(const edm::Event& e, const edm::EventSetup& es)\n+{\n+  //Retrieve tracker topology from geometry\n+  edm::ESHandle<TrackerTopology> tTopoHandle;\n+  es.get<TrackerTopologyRcd>().get(tTopoHandle);\n+  const TrackerTopology* const tTopo = tTopoHandle.product();\n+ \n+  // geometry setup\n+  edm::ESHandle<TrackerGeometry>        geometry;\n+ \n+  es.get<TrackerDigiGeometryRecord>().get(geometry);\n+  const TrackerGeometry*  theGeometry = &(*geometry);\n+  \n+  std::vector<PSimHit> matched;\n+  std::vector<PSimHit>::const_iterator closest_simhit;\n+\n+  edm::Handle<SiPixelRecHitCollection> recHitColl;\n+  //e.getByLabel( src_, recHitColl);\n+  e.getByToken(pixelRecHits_token, recHitColl);\n+  // for finding matched simhit\n+  TrackerHitAssociator associate( e, trackerHitAssociatorConfig_);\n+ \n+  //  std::cout << \" Step A: Standard RecHits found \" << (recHitColl.product())->dataSize() << std::endl;\n+  if((recHitColl.product())->dataSize() > 0) {\n+    SiPixelRecHitCollection::const_iterator recHitIdIterator      = (recHitColl.product())->begin();\n+    SiPixelRecHitCollection::const_iterator recHitIdIteratorEnd   = (recHitColl.product())->end();\n+ \n+    std::string detname ;\n+\n+    evt_.init();\n+    fillEvt(e);\n+\n+    // Loop over Detector IDs\n+    for ( ; recHitIdIterator != recHitIdIteratorEnd; recHitIdIterator++) {\n+      SiPixelRecHitCollection::DetSet detset = *recHitIdIterator;\n+ \n+      if( detset.empty() ) continue;\n+      DetId detId = DetId(detset.detId()); // Get the Detid object\n+ \n+      const GeomDet* geomDet( theGeometry->idToDet(detId) );\n+       \n+      // Loop over rechits for this detid\n+      SiPixelRecHitCollection::DetSet::const_iterator rechitRangeIteratorBegin = detset.begin();\n+      SiPixelRecHitCollection::DetSet::const_iterator rechitRangeIteratorEnd   = detset.end();\n+      SiPixelRecHitCollection::DetSet::const_iterator iterRecHit;\n+      for ( iterRecHit = rechitRangeIteratorBegin; \n+            iterRecHit != rechitRangeIteratorEnd; ++iterRecHit) {\n+\t// get matched simhit\n+\tmatched.clear();\n+\tmatched = associate.associateHit(*iterRecHit);\n+\tif ( !matched.empty() ) {\n+\t  float closest = 9999.9;\n+\t  std::vector<PSimHit>::const_iterator closestit = matched.begin();\n+\t  LocalPoint lp = iterRecHit->localPosition();\n+\t  float rechit_x = lp.x();\n+\t  float rechit_y = lp.y();\n+\t  //loop over simhits and find closest\n+\t  for (std::vector<PSimHit>::const_iterator m = matched.begin(); m<matched.end(); m++) \n+\t    {\n+\t      float sim_x1 = (*m).entryPoint().x();\n+\t      float sim_x2 = (*m).exitPoint().x();\n+\t      float sim_xpos = 0.5*(sim_x1+sim_x2);\n+\t      float sim_y1 = (*m).entryPoint().y();\n+\t      float sim_y2 = (*m).exitPoint().y();\n+\t      float sim_ypos = 0.5*(sim_y1+sim_y2);\n+             \n+\t      float x_res = sim_xpos - rechit_x;\n+\t      float y_res = sim_ypos - rechit_y;\n+\t      float dist = sqrt(x_res*x_res + y_res*y_res);\n+\t      if ( dist < closest ) {\n+\t\tclosest = dist;\n+\t\tclosestit = m;\n+\t      }\n+\t    } // end of simhit loop\n+\t  closest_simhit = closestit;\n+\t} // end matched emtpy\n+\tunsigned int subid = detId.subdetId();\n+\tint detid_db = detId.rawId();\n+\tint layer_num = -99,ladder_num=-99,module_num=-99,disk_num=-99,blade_num=-99,panel_num=-99,side_num=-99;       \n+\tif ( ( subid == PixelSubdetector::PixelBarrel ) || ( subid == PixelSubdetector::PixelEndcap ) ) {\n+\t  // 1 = PXB, 2 = PXF\n+\t  if ( subid ==  PixelSubdetector::PixelBarrel ) {\n+\t    layer_num   = tTopo->pxbLayer(detId.rawId());\n+\t    ladder_num  = tTopo->pxbLadder(detId.rawId());\n+\t    module_num  = tTopo->pxbModule(detId.rawId());\n+\t    //\t    std::cout <<\"\\ndetId = \"<<subid<<\" : \"<<tTopo->pxbLayer(detId.rawId())<<\" , \"<<tTopo->pxbLadder(detId.rawId())<<\" , \"<< tTopo->pxbModule(detId.rawId());\n+\t  } else if ( subid ==  PixelSubdetector::PixelEndcap ) {\n+\t    module_num  = tTopo->pxfModule(detId());\n+\t    disk_num    = tTopo->pxfDisk(detId());\n+\t    blade_num   = tTopo->pxfBlade(detId());\n+\t    panel_num   = tTopo->pxfPanel(detId());\n+\t    side_num    = tTopo->pxfSide(detId());\n+\t  }\n+\t  int num_simhit = matched.size();\n+\t  recHit_.init();\n+\t  fillPRecHit(  detid_db, subid,layer_num,ladder_num,module_num,disk_num,blade_num,panel_num,side_num,\n+\t\t\titerRecHit, num_simhit, closest_simhit, geomDet );\n+\t  pixeltree_->Fill();\n+\t}\n+      } // end of rechit loop\n+    } // end of detid loop\n+  } // end of loop test on recHitColl size\n+ \n+  // Now loop over recotracks\n+  edm::Handle<View<reco::Track>> trackCollection;\n+  e.getByToken(token_recoTracks, trackCollection);\n+\n+  if (!trackCollection.isValid()){\n+    if(picky_){\n+      throw cms::Exception(\"ProductNotValid\") << \"TrackCollection product not valid\";\n+    } else {;}\n+  } else {\n+    int rT = 0;\n+    for(View<reco::Track>::size_type i=0; i<trackCollection->size(); ++i){\n+      ++rT;\n+      RefToBase<reco::Track> track(trackCollection, i);\n+      int iT = 0;\n+      //std::cout << \" num of hits for track \" << rT << \" = \" << track->recHitsSize() << std::endl;\n+      for(trackingRecHit_iterator ih=track->recHitsBegin(); ih != track->recHitsEnd(); ++ih) {\n+\t++iT;\n+\t//std::cout<<\" analyzing hit n. \"<<iT<<std::endl;\n+\tTrackingRecHit * hit = (*ih)->clone();\n+\tconst DetId& detId =  hit->geographicalId();\n+\tconst GeomDet* geomDet( theGeometry->idToDet(detId) );\n+\t\n+\tconst SiPixelRecHit *pixhit = dynamic_cast<const SiPixelRecHit*>(hit);\n+\t\n+\tif(pixhit){\n+\t  if(pixhit->isValid() ) {\n+\t    \n+\t    // get matched simhit\n+\t    matched.clear();\n+\t    matched = associate.associateHit(*pixhit);\n+\t    \n+\t    if ( !matched.empty() ) {\n+\t      float closest = 9999.9;\n+\t      std::vector<PSimHit>::const_iterator closestit = matched.begin();\n+\t      LocalPoint lp = pixhit->localPosition();\n+\t      float rechit_x = lp.x();\n+\t      float rechit_y = lp.y();\n+\t      \n+\t      //loop over simhits and find closest\t   \t    \n+\t      for (std::vector<PSimHit>::const_iterator m = matched.begin(); m<matched.end(); m++) \n+\t\t{\n+\t\t  float sim_x1 = (*m).entryPoint().x();\n+\t\t  float sim_x2 = (*m).exitPoint().x();\n+\t\t  float sim_xpos = 0.5*(sim_x1+sim_x2);\n+\t\t  float sim_y1 = (*m).entryPoint().y();\n+\t\t  float sim_y2 = (*m).exitPoint().y();\n+\t\t  float sim_ypos = 0.5*(sim_y1+sim_y2);\n+\t\t  \n+\t\t  float x_res = sim_xpos - rechit_x;\n+\t\t  float y_res = sim_ypos - rechit_y;\n+\t\t  float dist = sqrt(x_res*x_res + y_res*y_res);\n+\t\t  if ( dist < closest ) {\n+\t\t    closest = dist;\n+\t\t    closestit = m;\n+\t\t  }\n+\t\t} // end of simhit loop\n+\t      closest_simhit = closestit;\n+\t    } // end matched emtpy\n+\t    \n+\t    int num_simhit = matched.size();\n+\t    \n+\t    int layer_num = -99,ladder_num=-99,module_num=-99,disk_num=-99,blade_num=-99,panel_num=-99,side_num=-99;\n+\t    \n+\t    unsigned int subid = detId.subdetId();\n+\t    int detid_db = detId.rawId();\n+\t    if ( ( subid == PixelSubdetector::PixelBarrel ) || ( subid == PixelSubdetector::PixelEndcap ) ) {\n+\t      // 1 = PXB, 2 = PXF\n+\t      if ( subid ==  PixelSubdetector::PixelBarrel ) {\n+\t\tlayer_num   = tTopo->pxbLayer(detId.rawId());\n+\t\tladder_num  = tTopo->pxbLadder(detId.rawId());\n+\t\tmodule_num  = tTopo->pxbModule(detId.rawId());\n+\t\t//std::cout <<\"\\ndetId = \"<<subid<<\" : \"<<tTopo->pxbLayer(detId.rawId())<<\" , \"<<tTopo->pxbLadder(detId.rawId())<<\" , \"<< tTopo->pxbModule(detId.rawId()) <<std::endl;\n+\t      } else if ( subid ==  PixelSubdetector::PixelEndcap ) {\n+\t\tmodule_num  = tTopo->pxfModule(detId());\n+\t\tdisk_num    = tTopo->pxfDisk(detId());\n+\t\tblade_num   = tTopo->pxfBlade(detId());\n+\t\tpanel_num   = tTopo->pxfPanel(detId());\n+\t\tside_num    = tTopo->pxfSide(detId());\n+\t      }\n+\t      \n+\t      recHit_.init();\n+\t      fillPRecHit(detid_db, subid, layer_num,ladder_num,module_num,disk_num,blade_num,panel_num,side_num, \n+\t\t\t  ih, num_simhit, closest_simhit, geomDet );\t \n+\t      pixeltreeOnTrack_->Fill();\t   \n+\t      /*\n+\t\tTrackingRecHit * hit = (*ih)->clone();\n+\t\tLocalPoint lp = hit->localPosition();\n+\t\tLocalError le = hit->localPositionError();\n+\t\t//            std::cout << \"   lp x,y = \" << lp.x() << \" \" << lp.y() << \" lpe xx,xy,yy = \"\n+\t\t//                  << le.xx() << \" \" << le.xy() << \" \" << le.yy() << std::endl;\n+\t\tstd::cout << \"Found RecHit in \" << detname << \" from detid \" << detId.rawId()\n+\t\t<< \" subdet = \" << subdetId\n+\t\t<< \" layer = \" << layerNumber\n+\t\t<< \"global x/y/z/r = \"\n+\t\t<< geomDet->surface().toGlobal(lp).x() << \" \" \n+\t\t<< geomDet->surface().toGlobal(lp).y() << \" \" \n+\t\t<< geomDet->surface().toGlobal(lp).z() << \" \" \n+\t\t<< geomDet->surface().toGlobal(lp).perp() \n+\t\t<< \" err x/y = \" << sqrt(le.xx()) << \" \" << sqrt(le.yy()) << std::endl;\n+\t      */\n+\t    } // if ( (subid==1)||(subid==2) ) \n+\t  } // if SiPixelHit is valid\n+\t} // if cast is possible to SiPixelHit\n+\tdelete pixhit;\n+      } //end of loop on tracking rechits\n+    } // end of loop on recotracks\n+  } // else track collection is valid\n+} // end analyze function\n+ \n+// Function for filling in all the rechits\n+// I know it is lazy to pass everything, but I'm doing it anyway. -EB\n+void Phase2PixelNtuple::fillPRecHit(const int detid_db, const int subid, \n+\t\t\t\t  const int layer_num,const int ladder_num,const int module_num,\n+\t\t\t\t  const int disk_num,const int blade_num,const int panel_num,const int side_num,\n+\t\t\t\t  SiPixelRecHitCollection::DetSet::const_iterator pixeliter,\n+\t\t\t\t  const int num_simhit,\n+\t\t\t\t  std::vector<PSimHit>::const_iterator closest_simhit,\n+\t\t\t\t  const GeomDet* PixGeom)\n+{\n+  LocalPoint lp = pixeliter->localPosition();\n+  LocalError le = pixeliter->localPositionError();\n+ \n+  recHit_.x = lp.x();\n+  recHit_.y = lp.y();\n+  recHit_.xx = le.xx();\n+  recHit_.xy = le.xy();\n+  recHit_.yy = le.yy();\n+  GlobalPoint GP = PixGeom->surface().toGlobal(pixeliter->localPosition());\n+  recHit_.gx = GP.x();\n+  recHit_.gy = GP.y();\n+  recHit_.gz = GP.z();\n+  GlobalPoint GP0 = PixGeom->surface().toGlobal(LocalPoint(0,0,0));\n+  recHit_.theta = GP0.theta(); \n+  recHit_.phi = GP0.phi(); \n+\n+  SiPixelRecHit::ClusterRef const& Cluster =  pixeliter->cluster();\n+  recHit_.q = Cluster->charge();\n+  recHit_.spreadx = Cluster->sizeX();\n+  recHit_.spready = Cluster->sizeY();\n+ \n+  recHit_.subid = subid;\n+  recHit_.nsimhit = num_simhit;\n+  \n+  recHit_.layer = layer_num;\n+  recHit_.ladder= ladder_num;\n+  recHit_.module= module_num;\n+  recHit_.module= module_num;\n+  recHit_.disk  = disk_num;\n+  recHit_.blade = blade_num;\n+  recHit_.panel = panel_num;\n+  recHit_.side  = side_num;\n+\n+  /*-- module topology --*/\n+  const PixelGeomDetUnit *theGeomDet = dynamic_cast<const PixelGeomDetUnit*> (PixGeom );\n+  const PixelTopology * topol = &(theGeomDet->specificTopology());\n+  recHit_.nRowsInDet =  topol->nrows();\n+  recHit_.nColsInDet =  topol->ncolumns();\n+  recHit_.pitchx     =\ttopol->pitch().first;      \n+  recHit_.pitchy     =\ttopol->pitch().second;        \n+  recHit_.thickness  =\ttheGeomDet->surface().bounds().thickness();      \n+\n+  MeasurementPoint mp = topol->measurementPosition(LocalPoint(recHit_.x, recHit_.y));\n+  recHit_.row = mp.x();\n+  recHit_.col = mp.y();\n+  \n+  // if ( subid == 1 ) {\n+  //     std::cout << \"all hits: BPIX Layer \"<< layer_num << \" RectangularPixelTopology \"\n+  // \t      << \" rechit row \" << recHit_.row << \n+  // \t      << \" , rechit col \" << recHit_.col\n+  // \t      << \" , nrow \" << topol->nrows() << \", ncols \" << topol->ncolumns() << \", pitchx \" << topol->pitch().first << \", pitchy \" << topol->pitch().second \n+  // \t      << std::endl;\n+  //  }\n+\n+  if ( Cluster.isNonnull() ) { \n+\n+    // compute local angles from det position\n+    std::pair<float, float> local_angles = computeAnglesFromDetPosition(*Cluster, *topol, *theGeomDet);\n+    recHit_.cotAlphaFromDet = local_angles.first;\n+    recHit_.cotBetaFromDet = local_angles.second;\n+\n+\n+    // -- Get digis of this cluster\n+    const std::vector<SiPixelCluster::Pixel>& pixvector = Cluster->pixels();\n+    //      std::cout << \"  Found \" << pixvector.size() << \" pixels for this cluster \" << std::endl;\n+    for (unsigned int i = 0; i < pixvector.size(); ++i) {\n+      if (recHit_.fDgN > DGPERCLMAX - 1) break;\n+      SiPixelCluster::Pixel holdpix = pixvector[i];\n+      \n+      recHit_.fDgRow[recHit_.fDgN]    = holdpix.x;\n+      recHit_.fDgCol[recHit_.fDgN]    = holdpix.y;\n+      //\tstd::cout << \"holdpix \" << holdpix.x << \" \" <<  holdpix.y << std::endl;\n+      recHit_.fDgDetId[recHit_.fDgN]  = detid_db;\n+      recHit_.fDgAdc[recHit_.fDgN]    = -99.;\n+      recHit_.fDgCharge[recHit_.fDgN] = holdpix.adc/1000.;\t\n+      ++recHit_.fDgN;\n+      \n+    }      \n+  } // if ( Cluster.isNonnull() )\n+  else \n+    {\n+      std::cout << \"Pixel rechits with no associated cluster ?!?!?!!!!!!!!!!!!!!!!!!!!!!! \" << std::endl;\n+\t// for (std::vector<TrajectoryMeasurement>::const_iterator tmeasIt = tmeasColl.begin(); ...\n+    }\n+\t/*-- --*/\n+\n+  //std::cout << \"num_simhit = \" << num_simhit << std::endl;\n+  if(num_simhit > 0) {\n+\n+    recHit_.pdgid = (*closest_simhit).particleType();\n+    recHit_.process= (*closest_simhit).processType();\n+\n+    float sim_x1 = (*closest_simhit).entryPoint().x();\n+    float sim_x2 = (*closest_simhit).exitPoint().x();\n+    recHit_.hx = 0.5*(sim_x1+sim_x2);\n+    float sim_y1 = (*closest_simhit).entryPoint().y();\n+    float sim_y2 = (*closest_simhit).exitPoint().y();\n+    recHit_.hy = 0.5*(sim_y1+sim_y2);\n+\n+    recHit_.tx = (*closest_simhit).localDirection().x();\n+    recHit_.ty = (*closest_simhit).localDirection().y();\n+    recHit_.tz = (*closest_simhit).localDirection().z();\n+\n+    MeasurementPoint hmp = topol->measurementPosition(LocalPoint(recHit_.hx, recHit_.hy));\n+    recHit_.hrow = hmp.x();\n+    recHit_.hcol = hmp.y();\n+\n+    // alpha: angle with respect to local x axis in local (x,z) plane\n+    // float cotalpha = sim_xdir/sim_zdir;\n+    // beta: angle with respect to local y axis in local (y,z) plane\n+    // float cotbeta = sim_ydir/sim_zdir;\n+    \n+    //std::cout << \"num_simhit x, y = \" << 0.5*(sim_x1+sim_x2) << \" \" << 0.5*(sim_y1+sim_y2) << std::endl;\n+  }\n+  /*\n+    std::cout << \"Found RecHit in \" << subid\n+    << \" global x/y/z : \"\n+    << PixGeom->surface().toGlobal(pixeliter->localPosition()).x() << \" \" \n+    << PixGeom->surface().toGlobal(pixeliter->localPosition()).y() << \" \" \n+    << PixGeom->surface().toGlobal(pixeliter->localPosition()).z() << std::endl;\n+  */\n+}\n+\n+// Function for filling in on track rechits\n+void Phase2PixelNtuple::fillPRecHit(const int detid_db, const int subid, \n+\t\t\t\t     const int layer_num,const int ladder_num,const int module_num,\n+\t\t\t\t     const int disk_num,const int blade_num,const int panel_num,const int side_num,\n+\t\t\t\t     trackingRecHit_iterator ih,\n+\t\t\t\t     const int num_simhit,\n+\t\t\t\t     std::vector<PSimHit>::const_iterator closest_simhit,\n+\t\t\t\t     const GeomDet* PixGeom)\n+{\n+  TrackingRecHit * pixeliter = (*ih)->clone(); \n+  LocalPoint lp = pixeliter->localPosition();\n+  LocalError le = pixeliter->localPositionError();\n+ \n+  recHit_.x = lp.x();\n+  recHit_.y = lp.y();\n+  recHit_.xx = le.xx();\n+  recHit_.xy = le.xy();\n+  recHit_.yy = le.yy();\n+  GlobalPoint GP = PixGeom->surface().toGlobal(pixeliter->localPosition());\n+  recHit_.gx = GP.x();\n+  recHit_.gy = GP.y();\n+  recHit_.gz = GP.z();\n+  GlobalPoint GP0 = PixGeom->surface().toGlobal(LocalPoint(0,0,0));\n+  recHit_.theta = GP0.theta(); \n+  recHit_.phi = GP0.phi(); \n+  recHit_.subid = subid;\n+\n+\n+  SiPixelRecHit::ClusterRef const& Cluster =  dynamic_cast<const SiPixelRecHit*>(pixeliter)->cluster();\n+  recHit_.q = Cluster->charge();\n+  recHit_.spreadx = Cluster->sizeX();\n+  recHit_.spready = Cluster->sizeY();\n+\n+  recHit_.nsimhit = num_simhit;\n+\n+  recHit_.layer = layer_num;\n+  recHit_.ladder= ladder_num;\n+  recHit_.module= module_num;\n+  recHit_.module= module_num;\n+  recHit_.disk  = disk_num;\n+  recHit_.blade = blade_num;\n+  recHit_.panel = panel_num;\n+  recHit_.side  = side_num;\n+\n+  /*-- module topology --*/\n+  const PixelGeomDetUnit *theGeomDet = dynamic_cast<const PixelGeomDetUnit*> (PixGeom );\n+  const PixelTopology * topol = &(theGeomDet->specificTopology());\n+  recHit_.nRowsInDet =  topol->nrows();\n+  recHit_.nColsInDet =  topol->ncolumns();\n+  recHit_.pitchx     =\ttopol->pitch().first;      \n+  recHit_.pitchy     =\ttopol->pitch().second;        \n+  recHit_.thickness  =\ttheGeomDet->surface().bounds().thickness();      \n+\n+  // if ( subid == 1 ) {\n+  //     std::cout << \"on track only: BPIX Layer \"<< layer_num << \" RectangularPixelTopology \" << \"nrows \" << topol->nrows() << \", ncols \" << topol->ncolumns() << \", pitchx \" << topol->pitch().first << \", pitchy \" << topol->pitch().second << std::endl;\n+  //   }\n+\n+  if ( Cluster.isNonnull() ) { \n+    // compute local angles from det position\n+    std::pair<float, float> local_angles = computeAnglesFromDetPosition(*Cluster, *topol, *theGeomDet);\n+    recHit_.cotAlphaFromDet = local_angles.first;\n+    recHit_.cotBetaFromDet = local_angles.second;\n+\n+    // -- Get digis of this cluster\n+    const std::vector<SiPixelCluster::Pixel>& pixvector = Cluster->pixels();\n+    //      std::cout << \"  Found \" << pixvector.size() << \" pixels for this cluster \" << std::endl;\n+    for (unsigned int i = 0; i < pixvector.size(); ++i) {\n+      if (recHit_.fDgN > DGPERCLMAX - 1) break;\n+      SiPixelCluster::Pixel holdpix = pixvector[i];\n+      \n+      recHit_.fDgRow[recHit_.fDgN]    = holdpix.x;\n+      recHit_.fDgCol[recHit_.fDgN]    = holdpix.y;\n+      //\tstd::cout << \"holdpix \" << holdpix.x << \" \" <<  holdpix.y << std::endl;\n+      recHit_.fDgDetId[recHit_.fDgN]  = detid_db;\n+      recHit_.fDgAdc[recHit_.fDgN]    = -99.;\n+      recHit_.fDgCharge[recHit_.fDgN] = holdpix.adc/1000.;\t\n+      ++recHit_.fDgN;      \n+    }      \n+  } // if ( Cluster.isNonnull() )\n+  else \n+    {\n+      std::cout << \"Pixel rechits with no associated cluster ?!?!?!!!!!!!!!!!!!!!!!!!!!!! \" << std::endl;\n+\t// for (std::vector<TrajectoryMeasurement>::const_iterator tmeasIt = tmeasColl.begin(); ...\n+    }\n+\n+  //std::cout << \"num_simhit = \" << num_simhit << std::endl;\n+  if(num_simhit > 0) {\n+\n+    recHit_.pdgid = (*closest_simhit).particleType();\n+    recHit_.process= (*closest_simhit).processType();\n+\n+    float sim_x1 = (*closest_simhit).entryPoint().x();\n+    float sim_x2 = (*closest_simhit).exitPoint().x();\n+    recHit_.hx = 0.5*(sim_x1+sim_x2);\n+    float sim_y1 = (*closest_simhit).entryPoint().y();\n+    float sim_y2 = (*closest_simhit).exitPoint().y();\n+    recHit_.hy = 0.5*(sim_y1+sim_y2);\n+\n+    recHit_.tx = (*closest_simhit).localDirection().x();\n+    recHit_.ty = (*closest_simhit).localDirection().y();\n+    recHit_.tz = (*closest_simhit).localDirection().z();\n+\n+    MeasurementPoint hmp = topol->measurementPosition(LocalPoint(recHit_.hx, recHit_.hy));\n+    recHit_.hrow = hmp.x();\n+    recHit_.hcol = hmp.y();\n+\n+    // alpha: angle with respect to local x axis in local (x,z) plane\n+    // float cotalpha = sim_xdir/sim_zdir;\n+    // beta: angle with respect to local y axis in local (y,z) plane\n+    // float cotbeta = sim_ydir/sim_zdir;\n+    \n+    //std::cout << \"num_simhit x, y = \" << 0.5*(sim_x1+sim_x2) << \" \" << 0.5*(sim_y1+sim_y2) << std::endl;\n+  }\n+\n+  delete pixeliter;\n+\n+}\n+ \n+void\n+Phase2PixelNtuple::fillEvt(const edm::Event& E)\n+{\n+  evt_.run = E.id().run();\n+  evt_.evtnum = E.id().event();\n+}\n+ \n+ \n+void Phase2PixelNtuple::evt::init()\n+{\n+  int dummy_int = 9999;\n+  run = dummy_int;\n+  evtnum = dummy_int;\n+}\n+ \n+void Phase2PixelNtuple::RecHit::init()\n+{\n+  float dummy_float = 9999.0;\n+ \n+  pdgid = 0;\n+  process = 0;\n+  q = dummy_float;\n+  x = dummy_float;\n+  y = dummy_float;\n+  xx = dummy_float;\n+  xy = dummy_float; \n+  yy = dummy_float;\n+  row = dummy_float;\n+  col = dummy_float;\n+  gx = dummy_float;\n+  gy = dummy_float;\n+  gz = dummy_float;\n+  nsimhit = 0;\n+  subid=-99;\n+  module=-99;\n+  layer=-99;\n+  ladder=-99;\n+  disk=-99;\n+  blade=-99;\n+  panel=-99;\n+  side=-99;\n+  spreadx=0;\n+  spready=0;\n+  hx = dummy_float;\n+  hy = dummy_float;\n+  tx = dummy_float;\n+  ty = dummy_float;\n+  tz = dummy_float;\n+  theta = dummy_float;\n+  phi = dummy_float;\n+\n+  fDgN = DGPERCLMAX;\n+  for (int i = 0; i < fDgN; ++i) {\n+    fDgRow[i] = fDgCol[i] = -9999;\n+    fDgAdc[i] = fDgCharge[i] = -9999.;\n+    //    fDgRoc[i] = fDgRocR[i] = fDgRocC[i] = -9999;\n+  }\n+  fDgN = 0; \n+\n+}\n+\n+std::pair<float, float> Phase2PixelNtuple::computeAnglesFromDetPosition(const SiPixelCluster & cl, \n+\t\t\t\t\t\t\t\t\t   const PixelTopology  & theTopol, \n+\t\t\t\t\t\t\t\t\t   const GeomDetUnit    & theDet ) const\n+ {\n+   // EM check performed outside\n+   // //--- This is a new det unit, so cache it\n+   // PixelGeomDetUnit * theDet = dynamic_cast<const PixelGeomDetUnit*>( &det );","path":"SLHCUpgradeSimulations/Geometry/test/Phase2PixelNtuple.cc","position":831,"original_position":831,"commit_id":"35405cf7b7c65b1bfdff7fef9bcad3dd14d7a843","original_commit_id":"35405cf7b7c65b1bfdff7fef9bcad3dd14d7a843","user":{"login":"kpedro88","id":4672808,"avatar_url":"https://avatars0.githubusercontent.com/u/4672808?v=4","gravatar_id":"","url":"https://api.github.com/users/kpedro88","html_url":"https://github.com/kpedro88","followers_url":"https://api.github.com/users/kpedro88/followers","following_url":"https://api.github.com/users/kpedro88/following{/other_user}","gists_url":"https://api.github.com/users/kpedro88/gists{/gist_id}","starred_url":"https://api.github.com/users/kpedro88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpedro88/subscriptions","organizations_url":"https://api.github.com/users/kpedro88/orgs","repos_url":"https://api.github.com/users/kpedro88/repos","events_url":"https://api.github.com/users/kpedro88/events{/privacy}","received_events_url":"https://api.github.com/users/kpedro88/received_events","type":"User","site_admin":false},"body":"delete commented-out code","created_at":"2018-02-14T21:15:11Z","updated_at":"2018-02-14T21:19:54Z","html_url":"https://github.com/cms-sw/cmssw/pull/22204#discussion_r168311761","pull_request_url":"https://api.github.com/repos/cms-sw/cmssw/pulls/22204","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/comments/168311761"},"html":{"href":"https://github.com/cms-sw/cmssw/pull/22204#discussion_r168311761"},"pull_request":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/22204"}}},"pull_request":{"url":"https://api.github.com/repos/cms-sw/cmssw/pulls/22204","id":169036086,"html_url":"https://github.com/cms-sw/cmssw/pull/22204","diff_url":"https://github.com/cms-sw/cmssw/pull/22204.diff","patch_url":"https://github.com/cms-sw/cmssw/pull/22204.patch","issue_url":"https://api.github.com/repos/cms-sw/cmssw/issues/22204","number":22204,"state":"open","locked":false,"title":"Code for Phase2Pixel Ntuple with Unit Tests (+ cleaning old stuff) ","user":{"login":"boudoul","id":5131720,"avatar_url":"https://avatars1.githubusercontent.com/u/5131720?v=4","gravatar_id":"","url":"https://api.github.com/users/boudoul","html_url":"https://github.com/boudoul","followers_url":"https://api.github.com/users/boudoul/followers","following_url":"https://api.github.com/users/boudoul/following{/other_user}","gists_url":"https://api.github.com/users/boudoul/gists{/gist_id}","starred_url":"https://api.github.com/users/boudoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boudoul/subscriptions","organizations_url":"https://api.github.com/users/boudoul/orgs","repos_url":"https://api.github.com/users/boudoul/repos","events_url":"https://api.github.com/users/boudoul/events{/privacy}","received_events_url":"https://api.github.com/users/boudoul/received_events","type":"User","site_admin":false},"body":"Greetings\r\nThis PR is resurrecting the code used in the past for pixel phase2 studies which was sitting in SLHC releases but never ported to the mainstream . It is going to be very useful for the coming phase2 pixel studies. I also created an associated unit test  . \r\nFinally I take the opportunity to clean old and obsolete stuff in this package, likely more to do but doing gradually \r\n@emiglior FYI ","created_at":"2018-02-14T07:06:50Z","updated_at":"2018-02-14T21:19:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e43560c5fb16f2dfe24924959ae128d3357a291b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":673935047,"url":"https://api.github.com/repos/cms-sw/cmssw/labels/code-checks-approved","name":"code-checks-approved","color":"009800","default":false},{"id":88645479,"url":"https://api.github.com/repos/cms-sw/cmssw/labels/comparison-available","name":"comparison-available","color":"009800","default":false},{"id":52881721,"url":"https://api.github.com/repos/cms-sw/cmssw/labels/geometry-pending","name":"geometry-pending","color":"fbca04","default":false},{"id":56953091,"url":"https://api.github.com/repos/cms-sw/cmssw/labels/orp-pending","name":"orp-pending","color":"fbca04","default":false},{"id":53167770,"url":"https://api.github.com/repos/cms-sw/cmssw/labels/pending-signatures","name":"pending-signatures","color":"eb6420","default":false},{"id":56131195,"url":"https://api.github.com/repos/cms-sw/cmssw/labels/tests-approved","name":"tests-approved","color":"009800","default":false},{"id":530655448,"url":"https://api.github.com/repos/cms-sw/cmssw/labels/upgrade-pending","name":"upgrade-pending","color":"fbca04","default":false}],"milestone":{"url":"https://api.github.com/repos/cms-sw/cmssw/milestones/73","html_url":"https://github.com/cms-sw/cmssw/milestone/73","labels_url":"https://api.github.com/repos/cms-sw/cmssw/milestones/73/labels","id":3060828,"number":73,"title":"CMSSW_10_1_X","description":null,"creator":{"login":"smuzaffar","id":4115138,"avatar_url":"https://avatars3.githubusercontent.com/u/4115138?v=4","gravatar_id":"","url":"https://api.github.com/users/smuzaffar","html_url":"https://github.com/smuzaffar","followers_url":"https://api.github.com/users/smuzaffar/followers","following_url":"https://api.github.com/users/smuzaffar/following{/other_user}","gists_url":"https://api.github.com/users/smuzaffar/gists{/gist_id}","starred_url":"https://api.github.com/users/smuzaffar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smuzaffar/subscriptions","organizations_url":"https://api.github.com/users/smuzaffar/orgs","repos_url":"https://api.github.com/users/smuzaffar/repos","events_url":"https://api.github.com/users/smuzaffar/events{/privacy}","received_events_url":"https://api.github.com/users/smuzaffar/received_events","type":"User","site_admin":false},"open_issues":64,"closed_issues":210,"state":"open","created_at":"2018-01-24T11:24:59Z","updated_at":"2018-02-14T21:00:11Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/cms-sw/cmssw/pulls/22204/commits","review_comments_url":"https://api.github.com/repos/cms-sw/cmssw/pulls/22204/comments","review_comment_url":"https://api.github.com/repos/cms-sw/cmssw/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cms-sw/cmssw/issues/22204/comments","statuses_url":"https://api.github.com/repos/cms-sw/cmssw/statuses/35405cf7b7c65b1bfdff7fef9bcad3dd14d7a843","head":{"label":"boudoul:pixelntuplep2","ref":"pixelntuplep2","sha":"35405cf7b7c65b1bfdff7fef9bcad3dd14d7a843","user":{"login":"boudoul","id":5131720,"avatar_url":"https://avatars1.githubusercontent.com/u/5131720?v=4","gravatar_id":"","url":"https://api.github.com/users/boudoul","html_url":"https://github.com/boudoul","followers_url":"https://api.github.com/users/boudoul/followers","following_url":"https://api.github.com/users/boudoul/following{/other_user}","gists_url":"https://api.github.com/users/boudoul/gists{/gist_id}","starred_url":"https://api.github.com/users/boudoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boudoul/subscriptions","organizations_url":"https://api.github.com/users/boudoul/orgs","repos_url":"https://api.github.com/users/boudoul/repos","events_url":"https://api.github.com/users/boudoul/events{/privacy}","received_events_url":"https://api.github.com/users/boudoul/received_events","type":"User","site_admin":false},"repo":{"id":12590783,"name":"cmssw","full_name":"boudoul/cmssw","owner":{"login":"boudoul","id":5131720,"avatar_url":"https://avatars1.githubusercontent.com/u/5131720?v=4","gravatar_id":"","url":"https://api.github.com/users/boudoul","html_url":"https://github.com/boudoul","followers_url":"https://api.github.com/users/boudoul/followers","following_url":"https://api.github.com/users/boudoul/following{/other_user}","gists_url":"https://api.github.com/users/boudoul/gists{/gist_id}","starred_url":"https://api.github.com/users/boudoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boudoul/subscriptions","organizations_url":"https://api.github.com/users/boudoul/orgs","repos_url":"https://api.github.com/users/boudoul/repos","events_url":"https://api.github.com/users/boudoul/events{/privacy}","received_events_url":"https://api.github.com/users/boudoul/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/boudoul/cmssw","description":"CMS Offline Software","fork":true,"url":"https://api.github.com/repos/boudoul/cmssw","forks_url":"https://api.github.com/repos/boudoul/cmssw/forks","keys_url":"https://api.github.com/repos/boudoul/cmssw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/boudoul/cmssw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/boudoul/cmssw/teams","hooks_url":"https://api.github.com/repos/boudoul/cmssw/hooks","issue_events_url":"https://api.github.com/repos/boudoul/cmssw/issues/events{/number}","events_url":"https://api.github.com/repos/boudoul/cmssw/events","assignees_url":"https://api.github.com/repos/boudoul/cmssw/assignees{/user}","branches_url":"https://api.github.com/repos/boudoul/cmssw/branches{/branch}","tags_url":"https://api.github.com/repos/boudoul/cmssw/tags","blobs_url":"https://api.github.com/repos/boudoul/cmssw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/boudoul/cmssw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/boudoul/cmssw/git/refs{/sha}","trees_url":"https://api.github.com/repos/boudoul/cmssw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/boudoul/cmssw/statuses/{sha}","languages_url":"https://api.github.com/repos/boudoul/cmssw/languages","stargazers_url":"https://api.github.com/repos/boudoul/cmssw/stargazers","contributors_url":"https://api.github.com/repos/boudoul/cmssw/contributors","subscribers_url":"https://api.github.com/repos/boudoul/cmssw/subscribers","subscription_url":"https://api.github.com/repos/boudoul/cmssw/subscription","commits_url":"https://api.github.com/repos/boudoul/cmssw/commits{/sha}","git_commits_url":"https://api.github.com/repos/boudoul/cmssw/git/commits{/sha}","comments_url":"https://api.github.com/repos/boudoul/cmssw/comments{/number}","issue_comment_url":"https://api.github.com/repos/boudoul/cmssw/issues/comments{/number}","contents_url":"https://api.github.com/repos/boudoul/cmssw/contents/{+path}","compare_url":"https://api.github.com/repos/boudoul/cmssw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/boudoul/cmssw/merges","archive_url":"https://api.github.com/repos/boudoul/cmssw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/boudoul/cmssw/downloads","issues_url":"https://api.github.com/repos/boudoul/cmssw/issues{/number}","pulls_url":"https://api.github.com/repos/boudoul/cmssw/pulls{/number}","milestones_url":"https://api.github.com/repos/boudoul/cmssw/milestones{/number}","notifications_url":"https://api.github.com/repos/boudoul/cmssw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/boudoul/cmssw/labels{/name}","releases_url":"https://api.github.com/repos/boudoul/cmssw/releases{/id}","deployments_url":"https://api.github.com/repos/boudoul/cmssw/deployments","created_at":"2013-09-04T12:59:58Z","updated_at":"2014-06-20T14:11:59Z","pushed_at":"2018-02-14T15:42:39Z","git_url":"git://github.com/boudoul/cmssw.git","ssh_url":"git@github.com:boudoul/cmssw.git","clone_url":"https://github.com/boudoul/cmssw.git","svn_url":"https://github.com/boudoul/cmssw","homepage":"cms-sw.github.io/cmssw","size":972382,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"CMSSW_7_0_X"}},"base":{"label":"cms-sw:master","ref":"master","sha":"2634b66c78abc76e5e6a3b3e987ac3ea8b953622","user":{"login":"cms-sw","id":3863500,"avatar_url":"https://avatars0.githubusercontent.com/u/3863500?v=4","gravatar_id":"","url":"https://api.github.com/users/cms-sw","html_url":"https://github.com/cms-sw","followers_url":"https://api.github.com/users/cms-sw/followers","following_url":"https://api.github.com/users/cms-sw/following{/other_user}","gists_url":"https://api.github.com/users/cms-sw/gists{/gist_id}","starred_url":"https://api.github.com/users/cms-sw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cms-sw/subscriptions","organizations_url":"https://api.github.com/users/cms-sw/orgs","repos_url":"https://api.github.com/users/cms-sw/repos","events_url":"https://api.github.com/users/cms-sw/events{/privacy}","received_events_url":"https://api.github.com/users/cms-sw/received_events","type":"Organization","site_admin":false},"repo":{"id":10969551,"name":"cmssw","full_name":"cms-sw/cmssw","owner":{"login":"cms-sw","id":3863500,"avatar_url":"https://avatars0.githubusercontent.com/u/3863500?v=4","gravatar_id":"","url":"https://api.github.com/users/cms-sw","html_url":"https://github.com/cms-sw","followers_url":"https://api.github.com/users/cms-sw/followers","following_url":"https://api.github.com/users/cms-sw/following{/other_user}","gists_url":"https://api.github.com/users/cms-sw/gists{/gist_id}","starred_url":"https://api.github.com/users/cms-sw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cms-sw/subscriptions","organizations_url":"https://api.github.com/users/cms-sw/orgs","repos_url":"https://api.github.com/users/cms-sw/repos","events_url":"https://api.github.com/users/cms-sw/events{/privacy}","received_events_url":"https://api.github.com/users/cms-sw/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cms-sw/cmssw","description":"CMS Offline Software","fork":false,"url":"https://api.github.com/repos/cms-sw/cmssw","forks_url":"https://api.github.com/repos/cms-sw/cmssw/forks","keys_url":"https://api.github.com/repos/cms-sw/cmssw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cms-sw/cmssw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cms-sw/cmssw/teams","hooks_url":"https://api.github.com/repos/cms-sw/cmssw/hooks","issue_events_url":"https://api.github.com/repos/cms-sw/cmssw/issues/events{/number}","events_url":"https://api.github.com/repos/cms-sw/cmssw/events","assignees_url":"https://api.github.com/repos/cms-sw/cmssw/assignees{/user}","branches_url":"https://api.github.com/repos/cms-sw/cmssw/branches{/branch}","tags_url":"https://api.github.com/repos/cms-sw/cmssw/tags","blobs_url":"https://api.github.com/repos/cms-sw/cmssw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cms-sw/cmssw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cms-sw/cmssw/git/refs{/sha}","trees_url":"https://api.github.com/repos/cms-sw/cmssw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cms-sw/cmssw/statuses/{sha}","languages_url":"https://api.github.com/repos/cms-sw/cmssw/languages","stargazers_url":"https://api.github.com/repos/cms-sw/cmssw/stargazers","contributors_url":"https://api.github.com/repos/cms-sw/cmssw/contributors","subscribers_url":"https://api.github.com/repos/cms-sw/cmssw/subscribers","subscription_url":"https://api.github.com/repos/cms-sw/cmssw/subscription","commits_url":"https://api.github.com/repos/cms-sw/cmssw/commits{/sha}","git_commits_url":"https://api.github.com/repos/cms-sw/cmssw/git/commits{/sha}","comments_url":"https://api.github.com/repos/cms-sw/cmssw/comments{/number}","issue_comment_url":"https://api.github.com/repos/cms-sw/cmssw/issues/comments{/number}","contents_url":"https://api.github.com/repos/cms-sw/cmssw/contents/{+path}","compare_url":"https://api.github.com/repos/cms-sw/cmssw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cms-sw/cmssw/merges","archive_url":"https://api.github.com/repos/cms-sw/cmssw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cms-sw/cmssw/downloads","issues_url":"https://api.github.com/repos/cms-sw/cmssw/issues{/number}","pulls_url":"https://api.github.com/repos/cms-sw/cmssw/pulls{/number}","milestones_url":"https://api.github.com/repos/cms-sw/cmssw/milestones{/number}","notifications_url":"https://api.github.com/repos/cms-sw/cmssw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cms-sw/cmssw/labels{/name}","releases_url":"https://api.github.com/repos/cms-sw/cmssw/releases{/id}","deployments_url":"https://api.github.com/repos/cms-sw/cmssw/deployments","created_at":"2013-06-26T14:09:07Z","updated_at":"2018-02-12T21:04:22Z","pushed_at":"2018-02-14T21:02:51Z","git_url":"git://github.com/cms-sw/cmssw.git","ssh_url":"git@github.com:cms-sw/cmssw.git","clone_url":"https://github.com/cms-sw/cmssw.git","svn_url":"https://github.com/cms-sw/cmssw","homepage":"http://cms-sw.github.io/","size":992220,"stargazers_count":512,"watchers_count":512,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2455,"mirror_url":null,"archived":false,"open_issues_count":451,"license":null,"forks":2455,"open_issues":451,"watchers":512,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/22204"},"html":{"href":"https://github.com/cms-sw/cmssw/pull/22204"},"issue":{"href":"https://api.github.com/repos/cms-sw/cmssw/issues/22204"},"comments":{"href":"https://api.github.com/repos/cms-sw/cmssw/issues/22204/comments"},"review_comments":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/22204/comments"},"review_comment":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/22204/commits"},"statuses":{"href":"https://api.github.com/repos/cms-sw/cmssw/statuses/35405cf7b7c65b1bfdff7fef9bcad3dd14d7a843"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kpedro88"}}