CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
OverlapValidation Class Reference
Inheritance diagram for OverlapValidation:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 OverlapValidation (const edm::ParameterSet &)
 
 ~OverlapValidation () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
 
typedef vector< TrajectoryTrajectoryCollection
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void analyze (const Trajectory &, const Propagator &, TrackerHitAssociator &, const TrackerTopology *const tTopo)
 
void endJob () override
 
int layerFromId (const DetId &, const TrackerTopology *const tTopo) const
 

Private Attributes

vector< bool > acceptLayer
 
const bool addExtraBranches_
 
bool barrelOnly_
 
float chi2_ [2]
 
const float chi2ProbCut_
 
uint clusterCharge_ [2]
 
float clusterSize_ [2]
 
float clusterWidthX_ [2]
 
float clusterWidthY_ [2]
 
TrajectoryStateCombiner combiner_
 
edm::ParameterSet config_
 
bool doSimHit_
 
int edge_ [2]
 
uint event_
 
edm::FileInPath FileInPath_
 
unsigned short hitCounts_ [2]
 
float hitErrors_ [2]
 
float hitErrorsY_ [2]
 
float hitPositions_ [2]
 
float hitPositionsY_ [2]
 
uint layer_
 
float localxdotglobalphi_ [2]
 
float localxdotglobalr_ [2]
 
float localxdotglobalx_ [2]
 
float localxdotglobaly_ [2]
 
float localxdotglobalz_ [2]
 
float localydotglobalphi_ [2]
 
float localydotglobalr_ [2]
 
float localydotglobalx_ [2]
 
float localydotglobaly_ [2]
 
float localydotglobalz_ [2]
 
const MagneticFieldmagField_
 
const int minHitsCut_
 
float moduleX_ [2]
 
float moduleY_ [2]
 
float moduleZ_ [2]
 
float momentum_
 
const Point2DBase< float, LocalTagonezero = Point2DBase<float, LocalTag>(1, 0)
 
int overlapCounts_ [3]
 
unsigned int overlapIds_ [2]
 
float overlapPath_
 
float predictedDeltaXError_
 
float predictedDeltaYError_
 
float predictedLocalErrors_ [5][2]
 
float predictedLocalParameters_ [5][2]
 
float predictedPositions_ [3][2]
 
SiStripDetInfoFileReaderreader
 
char relativeXSign_
 
char relativeYSign_
 
TTree * rootTree_
 
uint run_
 
float simHitPositions_ [2]
 
float simHitPositionsY_ [2]
 
int subdetID
 
const TrackerGeometrytrackerGeometry_
 
edm::InputTag trajectoryTag_
 
edm::EDGetTokenT< TrajectoryCollectiontrajectoryToken_
 
const Point2DBase< float, LocalTagzeroone = Point2DBase<float, LocalTag>(0, 1)
 
const Point2DBase< float, LocalTagzerozero = Point2DBase<float, LocalTag>(0, 0)
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 89 of file OverlapValidation.cc.

Member Typedef Documentation

Definition at line 100 of file OverlapValidation.cc.

Definition at line 95 of file OverlapValidation.cc.

Constructor & Destructor Documentation

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

Definition at line 187 of file OverlapValidation.cc.

References acceptLayer, addExtraBranches_, barrelOnly_, chi2_, clusterCharge_, clusterSize_, clusterWidthX_, clusterWidthY_, edm::ConsumesCollector::consumes(), edm::EDConsumerBase::consumesCollector(), doSimHit_, edge_, event_, FileInPath_, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), hitCounts_, hitErrors_, hitErrorsY_, hitPositions_, hitPositionsY_, layer_, localxdotglobalphi_, localxdotglobalr_, localxdotglobalx_, localxdotglobaly_, localxdotglobalz_, localydotglobalphi_, localydotglobalr_, localydotglobalx_, localydotglobaly_, localydotglobalz_, moduleX_, moduleY_, moduleZ_, momentum_, overlapCounts_, overlapIds_, overlapPath_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, predictedDeltaXError_, predictedDeltaYError_, predictedLocalErrors_, predictedLocalParameters_, predictedPositions_, reader, relativeXSign_, relativeYSign_, rootTree_, run_, simHitPositions_, simHitPositionsY_, subdetID, StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, trajectoryTag_, and trajectoryToken_.

187  :
188  config_(iConfig), rootTree_(nullptr),
189  FileInPath_("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"),
190  addExtraBranches_(false),
191  minHitsCut_(6),
192  chi2ProbCut_(0.001)
193 {
194 
196  //now do what ever initialization is needed
197  trajectoryTag_ = iConfig.getParameter<edm::InputTag>("trajectories");
199  doSimHit_ = iConfig.getParameter<bool>("associateStrip");
201 
202 
203  overlapCounts_[0] = 0; // #trajectories
204  overlapCounts_[1] = 0; // #hits
205  overlapCounts_[2] = 0; // #overlap hits
206  acceptLayer.resize(7,false);
207  acceptLayer[PixelSubdetector::PixelBarrel] = iConfig.getParameter<bool>("usePXB") ;
208  acceptLayer[PixelSubdetector::PixelEndcap] = iConfig.getParameter<bool>("usePXF") ;
209  acceptLayer[StripSubdetector::TIB] = iConfig.getParameter<bool>("useTIB") ;
210  acceptLayer[StripSubdetector::TOB] = iConfig.getParameter<bool>("useTOB") ;
211  acceptLayer[StripSubdetector::TID] = iConfig.getParameter<bool>("useTID") ;
212  acceptLayer[StripSubdetector::TEC] = iConfig.getParameter<bool>("useTEC") ;
213  barrelOnly_ = iConfig.getParameter<bool>("barrelOnly");
214 
215 
217  //
218  // root output
219  //
220  rootTree_ = fs->make<TTree>("Overlaps","Overlaps");
221  if (addExtraBranches_) {
222  rootTree_->Branch("hitCounts",hitCounts_,"found/s:lost/s");
223  rootTree_->Branch("chi2",chi2_,"chi2/F:ndf/F");
224  rootTree_->Branch("path",&overlapPath_,"path/F");
225  }
226  rootTree_->Branch("layer",&layer_,"layer/i");
227  rootTree_->Branch("detids",overlapIds_,"id[2]/i");
228  rootTree_->Branch("predPos",predictedPositions_,"gX[2]/F:gY[2]/F:gZ[2]/F");
229  rootTree_->Branch("predPar",predictedLocalParameters_,
230  "predQP[2]/F:predDX[2]/F:predDY[2]/F:predX[2]/F:predY[2]/F");
231  rootTree_->Branch("predErr",predictedLocalErrors_,
232  "predEQP[2]/F:predEDX[2]/F:predEDY[2]/F:predEX[2]/F:predEY[2]/F");
233  rootTree_->Branch("predEDeltaX",&predictedDeltaXError_,"sigDeltaX/F");
234  rootTree_->Branch("predEDeltaY",&predictedDeltaYError_,"sigDeltaY/F");
235  rootTree_->Branch("relSignX",&relativeXSign_,"relSignX/B");
236  rootTree_->Branch("relSignY",&relativeYSign_,"relSignY/B");
237  rootTree_->Branch("hitX",hitPositions_,"hitX[2]/F");
238  rootTree_->Branch("hitEX",hitErrors_,"hitEX[2]/F");
239  rootTree_->Branch("hitY",hitPositionsY_,"hitY[2]/F");
240  rootTree_->Branch("hitEY",hitErrorsY_,"hitEY[2]/F");
241  if (addExtraBranches_) {
242  rootTree_->Branch("simX",simHitPositions_,"simX[2]/F");
243  rootTree_->Branch("simY",simHitPositionsY_,"simY[2]/F");
244  rootTree_->Branch("clusterSize",clusterSize_,"clusterSize[2]/F");
245  rootTree_->Branch("clusterWidthX",clusterWidthX_,"clusterWidthX[2]/F");
246  rootTree_->Branch("clusterWidthY",clusterWidthY_,"clusterWidthY[2]/F");
247  rootTree_->Branch("clusterCharge",clusterCharge_,"clusterCharge[2]/i");
248  rootTree_->Branch("edge",edge_,"edge[2]/I");
249  }
250  rootTree_->Branch("momentum",&momentum_,"momentum/F");
251  rootTree_->Branch("run",&run_,"run/i");
252  rootTree_->Branch("event",&event_,"event/i");
253  rootTree_->Branch("subdetID",&subdetID,"subdetID/I");
254  rootTree_->Branch("moduleX",moduleX_,"moduleX[2]/F");
255  rootTree_->Branch("moduleY",moduleY_,"moduleY[2]/F");
256  rootTree_->Branch("moduleZ",moduleZ_,"moduleZ[2]/F");
257  rootTree_->Branch("localxdotglobalphi",localxdotglobalphi_,"localxdotglobalphi[2]/F");
258  rootTree_->Branch("localxdotglobalr",localxdotglobalr_,"localxdotglobalr[2]/F");
259  rootTree_->Branch("localxdotglobalz",localxdotglobalz_,"localxdotglobalz[2]/F");
260  rootTree_->Branch("localxdotglobalx",localxdotglobalx_,"localxdotglobalx[2]/F");
261  rootTree_->Branch("localxdotglobaly",localxdotglobaly_,"localxdotglobaly[2]/F");
262  rootTree_->Branch("localydotglobalphi",localydotglobalphi_,"localydotglobalphi[2]/F");
263  rootTree_->Branch("localydotglobalr",localydotglobalr_,"localydotglobalr[2]/F");
264  rootTree_->Branch("localydotglobalz",localydotglobalz_,"localydotglobalz[2]/F");
265  rootTree_->Branch("localydotglobalx",localydotglobalx_,"localydotglobalx[2]/F");
266  rootTree_->Branch("localydotglobaly",localydotglobaly_,"localydotglobaly[2]/F");
267 
268 }
edm::InputTag trajectoryTag_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< TrajectoryCollection > trajectoryToken_
unsigned int overlapIds_[2]
vector< bool > acceptLayer
const bool addExtraBranches_
float predictedPositions_[3][2]
unsigned short hitCounts_[2]
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
float predictedLocalErrors_[5][2]
float predictedLocalParameters_[5][2]
edm::FileInPath FileInPath_
SiStripDetInfoFileReader * reader
edm::ParameterSet config_
std::vector< Trajectory > TrajectoryCollection
std::string fullPath() const
Definition: FileInPath.cc:163
OverlapValidation::~OverlapValidation ( )
override

Definition at line 271 of file OverlapValidation.cc.

References overlapCounts_, and w.

272 {
273  edm::LogWarning w("Overlaps");
274  // do anything here that needs to be done at desctruction time
275  // (e.g. close files, deallocate resources etc.)
276 
277  w << "Counters =" ;
278  w << " Number of tracks: " << overlapCounts_[0];
279  w << " Number of valid hits: " << overlapCounts_[1];
280  w << " Number of overlaps: " << overlapCounts_[2];
281 }
const double w
Definition: UKUtility.cc:23

Member Function Documentation

void OverlapValidation::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 291 of file OverlapValidation.cc.

References AnalyticalPropagator_cfi::AnalyticalPropagator, anyDirection, ctfWithMaterialTrackMCMatch_cfi::associator, config_, edm::EDConsumerBase::consumesCollector(), doSimHit_, edm::EventID::event(), event_, edm::EventSetup::get(), edm::Event::getByToken(), edm::EventBase::id(), magField_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::propagator, edm::EventID::run(), run_, trackerGeometry_, and trajectoryToken_.

292 {
293  using namespace edm;
294  //
295  // mag field & search tracker
296  //
297  edm::ESHandle<MagneticField> magFieldHandle;
298  iSetup.get<IdealMagneticFieldRecord>().get(magFieldHandle);
299  magField_ = magFieldHandle.product();
300  //
301  // propagator
302  //
304  //
305  // geometry
306 
307 
308  //
309  edm::ESHandle<TrackerGeometry> geometryHandle;
310  iSetup.get<TrackerDigiGeometryRecord>().get(geometryHandle);
311  trackerGeometry_ = geometryHandle.product();
312  //
313  // make associator for SimHits
314  //
316  if(doSimHit_) {
318  associator = new TrackerHitAssociator(iEvent, hitassociatorconfig);
319  } else {
320  associator = nullptr;
321 
322 
323  }
324 
325 
326 
327 
328 
329 
330 
331 
332 //if(doSimHit_) associator = new TrackerHitAssociator(iEvent, config_); else associator = 0;
333 
334  //
335  // trajectories (from refit)
336  //
337  //typedef vector<Trajectory> TrajectoryCollection;
338  edm::Handle<TrajectoryCollection> trajectoryCollectionHandle;
339  iEvent.getByToken(trajectoryToken_,trajectoryCollectionHandle);
340  const TrajectoryCollection* const trajectoryCollection = trajectoryCollectionHandle.product();
341 
342  //
343  // loop over trajectories from refit
344  edm::ESHandle<TrackerTopology> tTopoHandle;
345  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
346  const TrackerTopology* const tTopo = tTopoHandle.product();
347  for (const auto& trajectory : *trajectoryCollection) analyze(trajectory,propagator,*associator, tTopo);
348 
349  run_ = iEvent.id().run();
350  event_ = iEvent.id().event();
351 
352 
353 
354 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
edm::EDGetTokenT< TrajectoryCollection > trajectoryToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void analyze(const edm::Event &, const edm::EventSetup &) override
const MagneticField * magField_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const TrackerGeometry * trackerGeometry_
T const * product() const
Definition: Handle.h:74
edm::ParameterSet config_
std::vector< Trajectory > TrajectoryCollection
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
void OverlapValidation::analyze ( const Trajectory trajectory,
const Propagator propagator,
TrackerHitAssociator associator,
const TrackerTopology *const  tTopo 
)
privatevirtual

Definition at line 358 of file OverlapValidation.cc.

References funct::abs(), acceptLayer, TrackerHitAssociator::associateHit(), barrelOnly_, ALCARECOTkAlJpsiMuMu_cff::charge, chi2_, chi2ProbCut_, Trajectory::chiSquared(), ChiSquaredProbability(), SiStripRecHit1D::cluster(), SiPixelRecHit::cluster(), clusterCharge_, clusterSize_, clusterWidthX_, clusterWidthY_, TrajectoryStateCombiner::combine(), combiner_, diffTreeTool::diff, doSimHit_, edge_, Trajectory::foundHits(), SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalParameters(), TrajectoryStateOnSurface::globalPosition(), SiStripDetId::glued(), runTauDisplay::gp, hitCounts_, hitErrors_, hitErrorsY_, hitPositions_, hitPositionsY_, mps_fire::i, globals_cff::id1, globals_cff::id2, PixelTopology::isItEdgePixelInX(), PixelTopology::isItEdgePixelInY(), TrajectoryStateOnSurface::isValid(), JacobianCurvilinearToLocal::jacobian(), layer_, layerFromId(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), localxdotglobalphi_, localxdotglobalr_, localxdotglobalx_, localxdotglobaly_, localxdotglobalz_, localydotglobalphi_, localydotglobalr_, localydotglobalx_, localydotglobaly_, localydotglobalz_, Trajectory::lostHits(), funct::m, PV3DBase< T, PVType, FrameType >::mag(), magField_, LocalTrajectoryError::matrix(), Trajectory::measurements(), minHitsCut_, moduleX_, moduleY_, moduleZ_, momentum_, GluedGeomDet::monoDet(), Trajectory::ndof(), onezero, muons1stStep_cfi::Overlap, overlapCounts_, overlapIds_, overlapPath_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, position, predictedDeltaXError_, predictedDeltaYError_, predictedLocalErrors_, predictedLocalParameters_, predictedPositions_, Propagator::propagate(), Propagator::propagateWithPath(), DetId::rawId(), reader, relativeXSign_, relativeYSign_, rootTree_, Scenarios_cff::scale, simHitPositions_, simHitPositionsY_, findQualityFiles::size, PixelGeomDetUnit::specificTopology(), mathSSE::sqrt(), SiStripDetId::stereo(), DetId::subdetId(), subdetID, GeomDet::surface(), TrajectoryStateOnSurface::surface(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, Surface::toGlobal(), GloballyPositioned< T >::toLocal(), parallelization::uint(), LocalTrajectoryParameters::vector(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), zeroone, and zerozero.

361 {
362  typedef std::pair<const TrajectoryMeasurement*, const TrajectoryMeasurement*> Overlap;
363  typedef vector<Overlap> OverlapContainer;
364  ++overlapCounts_[0];
365 
366  OverlapContainer overlapHits;
367 
368  // quality cuts on trajectory
369  // min. # hits / matched hits
370 
371  if ( trajectory.foundHits()<minHitsCut_ ) return;
372  if ( ChiSquaredProbability((double)( trajectory.chiSquared() ),(double)( trajectory.ndof(false) )) < chi2ProbCut_ ) return;
373  //
374  // loop over measurements in the trajectory and calculate residuals
375  //
376 
377 
378  vector<TrajectoryMeasurement> measurements(trajectory.measurements());
379  for ( vector<TrajectoryMeasurement>::const_iterator itm=measurements.begin();
380  itm!=measurements.end(); ++itm ) {
381  //
382  // skip "invalid" (i.e. missing) hits
383  //
384  ConstRecHitPointer hit = itm->recHit();
385  DetId id = hit->geographicalId();
386  int layer(layerFromId(id, tTopo));
387  int subDet = id.subdetId();
388 
389  if ( !hit->isValid() ) {
390  edm::LogVerbatim("OverlapValidation") << "Invalid";
391  continue;
392  }
393  if (barrelOnly_ && (subDet==StripSubdetector::TID || subDet==StripSubdetector::TEC) ) return;
394 
395  //edm::LogVerbatim("OverlapValidation") << "Check " <<subDet << ", layer = " << layer<<" stereo: "<< ((subDet > 2)?(SiStripDetId(id).stereo()):2);
396  //cout << "Check SubID " <<subDet << ", layer = " << layer<<" stereo: "<< ((subDet > 2)?(SiStripDetId(id).stereo()):2) << endl;
397 
398  //
399  // check for overlap: same subdet-id && layer number for
400  // two consecutive hits
401  //
402  ++overlapCounts_[1];
403  if ( (layer!=-1 )&&(acceptLayer[subDet])) {
404  for (vector<TrajectoryMeasurement>::const_iterator itmCompare = itm-1;
405  itmCompare >= measurements.begin() && itmCompare > itm - 4;
406  --itmCompare){
407 
408  DetId compareId = itmCompare->recHit()->geographicalId();
409 
410  if ( subDet != compareId.subdetId() || layer != layerFromId(compareId, tTopo)) break;
411  if (!itmCompare->recHit()->isValid()) continue;
412  if ( (subDet == PixelSubdetector::PixelBarrel || subDet == PixelSubdetector::PixelEndcap) ||
413  (SiStripDetId(id).stereo()==SiStripDetId(compareId).stereo() )) {
414  overlapHits.push_back(std::make_pair(&(*itmCompare),&(*itm)));
415  //edm::LogVerbatim("OverlapValidation") << "adding pair "<< ((subDet > 2)?(SiStripDetId(id).stereo()) : 2)
416  // << " from layer = " << layer;
417  //cout << "adding pair "<< ((subDet > 2)?(SiStripDetId(id).stereo()) : 2) << " from subDet = " << subDet << " and layer = " << layer;
418  //cout << " \t"<<run_<< "\t"<<event_<<"\t";
419  //cout << min(id.rawId(),compareId.rawId())<<"\t"<<max(id.rawId(),compareId.rawId())<<endl;
420  if ( SiStripDetId(id).glued() == id.rawId() ) edm::LogInfo("Overlaps") << "BAD GLUED: Have glued layer with id = " << id.rawId() << " and glued id = " << SiStripDetId(id).glued() << " and stereo = " << SiStripDetId(id).stereo() << endl;
421  if ( SiStripDetId(compareId).glued() == compareId.rawId() ) edm::LogInfo("Overlaps") << "BAD GLUED: Have glued layer with id = " << compareId.rawId() << " and glued id = " << SiStripDetId(compareId).glued() << " and stereo = " << SiStripDetId(compareId).stereo() << endl;
422  break;
423  }
424  }
425  }
426  }
427 
428 
429  //
430  // Loop over all overlap pairs.
431  //
432  hitCounts_[0] = trajectory.foundHits();
433  hitCounts_[1] = trajectory.lostHits();
434  chi2_[0] = trajectory.chiSquared();
435  chi2_[1] = trajectory.ndof(false);
436 
437  for (const auto& overlapHit : overlapHits) {
438  //
439  // create reference state @ module 1 (no info from overlap hits)
440  //
441  ++overlapCounts_[2];
442  // backward predicted state at module 1
443  TrajectoryStateOnSurface bwdPred1 = overlapHit.first->backwardPredictedState();
444  if ( !bwdPred1.isValid() ) continue;
445  //cout << "momentum from backward predicted state = " << bwdPred1.globalMomentum().mag() << endl;
446  // forward predicted state at module 2
447  TrajectoryStateOnSurface fwdPred2 = overlapHit.second->forwardPredictedState();
448  //cout << "momentum from forward predicted state = " << fwdPred2.globalMomentum().mag() << endl;
449  if ( !fwdPred2.isValid() ) continue;
450  // extrapolate fwdPred2 to module 1
451  TrajectoryStateOnSurface fwdPred2At1 = propagator.propagate(fwdPred2,bwdPred1.surface());
452  if ( !fwdPred2At1.isValid() ) continue;
453  // combine fwdPred2At1 with bwdPred1 (ref. state, best estimate without hits 1 and 2)
454  TrajectoryStateOnSurface comb1 = combiner_.combine(bwdPred1,fwdPred2At1);
455  if ( !comb1.isValid() ) continue;
456  //
457  // propagation of reference parameters to module 2
458  //
459  std::pair<TrajectoryStateOnSurface,double> tsosWithS =
460  propagator.propagateWithPath(comb1,fwdPred2.surface());
461  TrajectoryStateOnSurface comb1At2 = tsosWithS.first;
462  if ( !comb1At2.isValid() ) continue;
463  //distance of propagation from one surface to the next==could cut here
464  overlapPath_ = tsosWithS.second;
465  if (abs(overlapPath_) > 15 ) continue; //cut to remove hit pairs > 15 cm apart
466  // global position on module 1
468  predictedPositions_[0][0] = position.x();
469  predictedPositions_[1][0] = position.y();
470  predictedPositions_[2][0] = position.z();
471  momentum_ = comb1.globalMomentum().mag();
472  //cout << "momentum from combination = " << momentum_ << endl;
473  //cout << "magnetic field from TSOS = " << comb1.magneticField()->inTesla(position).mag() << endl;
474  // local parameters and errors on module 1
475  AlgebraicVector5 pars = comb1.localParameters().vector();
476  AlgebraicSymMatrix55 errs = comb1.localError().matrix();
477  for ( int i=0; i<5; ++i ) {
478  predictedLocalParameters_[i][0] = pars[i];
479  predictedLocalErrors_[i][0] = sqrt(errs(i,i));
480  }
481  // global position on module 2
482  position = comb1At2.globalPosition();
483  predictedPositions_[0][1] = position.x();
484  predictedPositions_[1][1] = position.y();
485  predictedPositions_[2][1] = position.z();
486  // local parameters and errors on module 2
487  pars = comb1At2.localParameters().vector();
488  errs = comb1At2.localError().matrix();
489  for ( int i=0; i<5; ++i ) {
490  predictedLocalParameters_[i][1] = pars[i];
491  predictedLocalErrors_[i][1] = sqrt(errs(i,i));
492  }
493 
494 
495  //print out local errors in X to check
496  //cout << "Predicted local error in X at 1 = " << predictedLocalErrors_[3][0] << " and predicted local error in X at 2 is = " << predictedLocalErrors_[3][1] << endl;
497  //cout << "Predicted local error in Y at 1 = " << predictedLocalErrors_[4][0] << " and predicted local error in Y at 2 is = " << predictedLocalErrors_[4][1] << endl;
498 
499  //
500  // jacobians (local-to-global@1,global 1-2,global-to-local@2)
501  //
502  JacobianLocalToCurvilinear jacLocToCurv(comb1.surface(),
503  comb1.localParameters(),
504  *magField_);
505  AnalyticalCurvilinearJacobian jacCurvToCurv(comb1.globalParameters(),
506  comb1At2.globalPosition(),
507  comb1At2.globalMomentum(),
508  tsosWithS.second);
509  JacobianCurvilinearToLocal jacCurvToLoc(comb1At2.surface(),
510  comb1At2.localParameters(),
511  *magField_);
512  // combined jacobian local-1-to-local-2
513  AlgebraicMatrix55 jacobian =
514  jacLocToCurv.jacobian()*jacCurvToCurv.jacobian()*jacCurvToLoc.jacobian();
515  // covariance on module 1
516  AlgebraicSymMatrix55 covComb1 = comb1.localError().matrix();
517  // variance and correlations for predicted local_x on modules 1 and 2
518  double c00 = covComb1(3,3);
519  double c10(0.);
520  double c11(0.);
521  for ( int i=1; i<5; ++i ) {
522  c10 += jacobian(3,i)*covComb1(i,3);
523  for ( int j=1; j<5; ++j ) c11 += jacobian(3,i)*covComb1(i,j)*jacobian(3,j);
524  }
525  // choose relative sign in order to minimize error on difference
526  double diff = c00 - 2*fabs(c10) + c11;
527  diff = diff>0 ? sqrt(diff) : -sqrt(-diff);
529  relativeXSign_ = c10>0 ? -1 : 1;
530  //
531  // now find variance and correlations for predicted local_y
532  double c00Y = covComb1(4,4);
533  double c10Y(0.);
534  double c11Y(0.);
535  for ( int i=1; i<5; ++i ) {
536  c10Y += jacobian(4,i)*covComb1(i,4);
537  for ( int j=1; j<5; ++j ) c11Y += jacobian(4,i)*covComb1(i,j)*jacobian(4,j);
538  }
539  double diffY = c00Y - 2*fabs(c10Y) + c11Y;
540  diffY = diffY>0 ? sqrt(diffY) : -sqrt(-diffY);
541  predictedDeltaYError_ = diffY;
542  relativeYSign_ = c10Y>0 ? -1 : 1;
543 
544  // information on modules and hits
545  overlapIds_[0] = overlapHit.first->recHit()->geographicalId().rawId();
546  overlapIds_[1] = overlapHit.second->recHit()->geographicalId().rawId();
547 
548  //added by Heshy and Jared
549  moduleX_[0] = overlapHit.first->recHit()->det()->surface().position().x();
550  moduleX_[1] = overlapHit.second->recHit()->det()->surface().position().x();
551  moduleY_[0] = overlapHit.first->recHit()->det()->surface().position().y();
552  moduleY_[1] = overlapHit.second->recHit()->det()->surface().position().y();
553  moduleZ_[0] = overlapHit.first->recHit()->det()->surface().position().z();
554  moduleZ_[1] = overlapHit.second->recHit()->det()->surface().position().z();
555  subdetID = overlapHit.first->recHit()->geographicalId().subdetId();
556  localxdotglobalphi_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(onezero).phi() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).phi();
557  localxdotglobalphi_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(onezero).phi() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).phi();
558  //added by Jason
559  localxdotglobalr_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(onezero).perp() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).perp();
560  localxdotglobalr_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(onezero).perp() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).perp();
561  localxdotglobalz_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(onezero).z() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).z();
562  localxdotglobalz_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(onezero).z() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).z();
563  localxdotglobalx_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(onezero).x() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).x();
564  localxdotglobalx_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(onezero).x() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).x();
565  localxdotglobaly_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(onezero).y() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).y();
566  localxdotglobaly_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(onezero).y() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).y();
567  localydotglobalr_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(zeroone).perp() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).perp();
568  localydotglobalr_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(zeroone).perp() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).perp();
569  localydotglobalz_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(zeroone).z() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).z();
570  localydotglobalz_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(zeroone).z() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).z();
571  localydotglobalx_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(zeroone).x() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).x();
572  localydotglobalx_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(zeroone).x() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).x();
573  localydotglobaly_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(zeroone).y() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).y();
574  localydotglobaly_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(zeroone).y() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).y();
575  localydotglobalphi_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(zeroone).phi() - overlapHit.first->recHit()->det()->surface().toGlobal(zerozero).phi();
576  localydotglobalphi_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(zeroone).phi() - overlapHit.second->recHit()->det()->surface().toGlobal(zerozero).phi();
577 
578 
579 
580 
581  if ( overlapHit.first->recHit()->geographicalId().subdetId()==StripSubdetector::TIB ) layer_ = layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo);
582  else if ( overlapHit.first->recHit()->geographicalId().subdetId()==StripSubdetector::TOB ) layer_ = layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo)+4;
583  else if ( overlapHit.first->recHit()->geographicalId().subdetId()==StripSubdetector::TID ) layer_ = layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo)+10;
584  else if ( overlapHit.first->recHit()->geographicalId().subdetId()==StripSubdetector::TEC ) layer_ = layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo)+13;
585  else if ( overlapHit.first->recHit()->geographicalId().subdetId()==PixelSubdetector::PixelBarrel ) layer_ = layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo)+20;
586  else if ( overlapHit.first->recHit()->geographicalId().subdetId()==PixelSubdetector::PixelEndcap ) layer_ = layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo)+30;
587  else layer_ = 99;
588 
589 
590  if ( overlapIds_[0] == SiStripDetId(overlapHit.first->recHit()->geographicalId()).glued() )
591  edm::LogWarning("Overlaps") << "BAD GLUED: First Id = " << overlapIds_[0] << " has glued = " << SiStripDetId(overlapHit.first->recHit()->geographicalId()).glued() << " and stereo = " << SiStripDetId(overlapHit.first->recHit()->geographicalId()).stereo() << endl;
592  if ( overlapIds_[1] == SiStripDetId(overlapHit.second->recHit()->geographicalId()).glued() )
593  edm::LogWarning("Overlaps") << "BAD GLUED: Second Id = " <<overlapIds_[1] << " has glued = " << SiStripDetId(overlapHit.second->recHit()->geographicalId()).glued() << " and stereo = " << SiStripDetId(overlapHit.second->recHit()->geographicalId()).stereo() << endl;
594 
595  const TransientTrackingRecHit::ConstRecHitPointer firstRecHit = overlapHit.first->recHit();
596  const TransientTrackingRecHit::ConstRecHitPointer secondRecHit = overlapHit.second->recHit();
597  hitPositions_[0] = firstRecHit->localPosition().x();
598  hitErrors_[0] = sqrt(firstRecHit->localPositionError().xx());
599  hitPositions_[1] = secondRecHit->localPosition().x();
600  hitErrors_[1] = sqrt(secondRecHit->localPositionError().xx());
601 
602  hitPositionsY_[0] = firstRecHit->localPosition().y();
603  hitErrorsY_[0] = sqrt(firstRecHit->localPositionError().yy());
604  hitPositionsY_[1] = secondRecHit->localPosition().y();
605  hitErrorsY_[1] = sqrt(secondRecHit->localPositionError().yy());
606 
607  //cout << "printing local X hit position and error for the overlap hits. Hit 1 = " << hitPositions_[0] << "+-" << hitErrors_[0] << " and hit 2 is " << hitPositions_[1] << "+-" << hitErrors_[1] << endl;
608 
609  DetId id1 = overlapHit.first->recHit()->geographicalId();
610  DetId id2 = overlapHit.second->recHit()->geographicalId();
611  int layer1 = layerFromId(id1, tTopo);
612  int subDet1 = id1.subdetId();
613  int layer2 = layerFromId(id2, tTopo);
614  int subDet2 = id2.subdetId();
615  if (abs(hitPositions_[0])>5) edm::LogInfo("Overlaps") << "BAD: Bad hit position: Id = " << id1.rawId() << " stereo = " << SiStripDetId(id1).stereo() << " glued = " << SiStripDetId(id1).glued() << " from subdet = " << subDet1 << " and layer = " << layer1 << endl;
616  if (abs(hitPositions_[1])>5) edm::LogInfo("Overlaps") << "BAD: Bad hit position: Id = " << id2.rawId() << " stereo = " << SiStripDetId(id2).stereo() << " glued = " << SiStripDetId(id2).glued() << " from subdet = " << subDet2 << " and layer = " << layer2 << endl;
617 
618 
619  // get track momentum
620  momentum_ = comb1.globalMomentum().mag();
621 
622  // get cluster size
623  if (!(subDet1 == PixelSubdetector::PixelBarrel || subDet1 == PixelSubdetector::PixelEndcap)) { //strip
624  const TransientTrackingRecHit::ConstRecHitPointer thit1=overlapHit.first->recHit();
625  const SiStripRecHit1D* hit1=dynamic_cast<const SiStripRecHit1D*>((*thit1).hit());
626  if (hit1) {
627  //check cluster width
628  const SiStripRecHit1D::ClusterRef & cluster1=hit1->cluster();
629  clusterSize_[0] = (cluster1->amplitudes()).size();
630  clusterWidthX_[0] = (cluster1->amplitudes()).size();
631  clusterWidthY_[0] = -1;
632 
633  //check if cluster at edge of sensor
634  uint16_t firstStrip = cluster1->firstStrip();
635  uint16_t lastStrip = firstStrip + (cluster1->amplitudes()).size() -1;
636  unsigned short Nstrips;
637  Nstrips=reader->getNumberOfApvsAndStripLength(id1).first*128;
638  bool atEdge = false;
639  if (firstStrip == 0 || lastStrip == (Nstrips-1) ) atEdge = true;
640  if (atEdge) edge_[0] = 1; else edge_[0] = -1;
641 
642  // get cluster total charge
643  const std::vector<uint8_t>& stripCharges = cluster1->amplitudes();
644  uint16_t charge = 0;
645  for (uint i = 0; i < stripCharges.size(); i++) {
646  charge += stripCharges.at(i);
647  }
648  clusterCharge_[0] = charge;
649  }
650 
651  const TransientTrackingRecHit::ConstRecHitPointer thit2=overlapHit.second->recHit();
652  const SiStripRecHit1D* hit2=dynamic_cast<const SiStripRecHit1D*>((*thit2).hit());
653  if (hit2) {
654  const SiStripRecHit1D::ClusterRef & cluster2=hit2->cluster();
655  clusterSize_[1] = (cluster2->amplitudes()).size();
656  clusterWidthX_[1] = (cluster2->amplitudes()).size();
657  clusterWidthY_[1] = -1;
658 
659  uint16_t firstStrip = cluster2->firstStrip();
660  uint16_t lastStrip = firstStrip + (cluster2->amplitudes()).size() -1;
661  unsigned short Nstrips;
662  Nstrips=reader->getNumberOfApvsAndStripLength(id2).first*128;
663  bool atEdge = false;
664  if (firstStrip == 0 || lastStrip == (Nstrips-1) ) atEdge = true;
665  if (atEdge) edge_[1] = 1; else edge_[1] = -1;
666 
667  // get cluster total charge
668  const std::vector<uint8_t>& stripCharges = cluster2->amplitudes();
669  uint16_t charge = 0;
670  for (uint i = 0; i < stripCharges.size(); i++) {
671  charge += stripCharges.at(i);
672  }
673  clusterCharge_[1] = charge;
674 
675  }
676  //cout << "strip cluster size2 = " << clusterWidthX_[0] << " and size 2 = " << clusterWidthX_[1] << endl;
677  }
678 
679 
680  if (subDet2 == PixelSubdetector::PixelBarrel || subDet2 == PixelSubdetector::PixelEndcap) { //pixel
681 
682  const TransientTrackingRecHit::ConstRecHitPointer thit1=overlapHit.first->recHit();
683  const SiPixelRecHit * recHitPix1 = dynamic_cast<const SiPixelRecHit *>((*thit1).hit());
684  if(recHitPix1) {
685  // check for cluster size and width
686  SiPixelRecHit::ClusterRef const& cluster1 = recHitPix1->cluster();
687 
688  clusterSize_[0] = cluster1->size();
689  clusterWidthX_[0] = cluster1->sizeX();
690  clusterWidthY_[0] = cluster1->sizeY();
691 
692  // check for cluster at edge
693  const PixelGeomDetUnit * theGeomDet =
694  dynamic_cast<const PixelGeomDetUnit*> ((*trackerGeometry_).idToDet(id1) );
695  const PixelTopology * topol =
696  (&(theGeomDet->specificTopology()));
697 
698 
699  int minPixelRow = cluster1->minPixelRow(); //x
700  int maxPixelRow = cluster1->maxPixelRow();
701  int minPixelCol = cluster1->minPixelCol(); //y
702  int maxPixelCol = cluster1->maxPixelCol();
703 
704  bool edgeHitX = (topol->isItEdgePixelInX(minPixelRow)) ||
705  (topol->isItEdgePixelInX(maxPixelRow));
706  bool edgeHitY = (topol->isItEdgePixelInY(minPixelCol)) ||
707  (topol->isItEdgePixelInY(maxPixelCol));
708  if (edgeHitX||edgeHitY) edge_[0] = 1; else edge_[0] = -1;
709 
710  clusterCharge_[0] = (uint)cluster1->charge();
711 
712  } else {
713  edm::LogWarning("Overlaps") << "didn't find pixel cluster" << endl;
714  continue;
715  }
716 
717  const TransientTrackingRecHit::ConstRecHitPointer thit2=overlapHit.second->recHit();
718  const SiPixelRecHit * recHitPix2 = dynamic_cast<const SiPixelRecHit *>((*thit2).hit());
719  if(recHitPix2) {
720  SiPixelRecHit::ClusterRef const& cluster2 = recHitPix2->cluster();
721 
722  clusterSize_[1] = cluster2->size();
723  clusterWidthX_[1] = cluster2->sizeX();
724  clusterWidthY_[1] = cluster2->sizeY();
725  //cout << "second pixel cluster is " << clusterSize_[1] << " pixels with x width = " << clusterWidthX_[1] << " and y width = " << clusterWidthY_[1] << endl;
726 
727  const PixelGeomDetUnit * theGeomDet =
728  dynamic_cast<const PixelGeomDetUnit*> ((*trackerGeometry_).idToDet(id2) );
729  const PixelTopology * topol =
730  (&(theGeomDet->specificTopology()));
731 
732  int minPixelRow = cluster2->minPixelRow(); //x
733  int maxPixelRow = cluster2->maxPixelRow();
734  int minPixelCol = cluster2->minPixelCol(); //y
735  int maxPixelCol = cluster2->maxPixelCol();
736 
737  bool edgeHitX = (topol->isItEdgePixelInX(minPixelRow)) ||
738  (topol->isItEdgePixelInX(maxPixelRow));
739  bool edgeHitY = (topol->isItEdgePixelInY(minPixelCol)) ||
740  (topol->isItEdgePixelInY(maxPixelCol));
741  if (edgeHitX||edgeHitY) edge_[1] = 1; else edge_[1] = -1;
742 
743  clusterCharge_[1] = (uint)cluster2->charge();
744 
745  } else {
746  edm::LogWarning("Overlaps") << "didn't find pixel cluster" << endl;
747  continue;
748  }
749 
750  }
751 
752 
753 
754  //also check for edge pixels
755 
756  //try writing out the SimHit info (for MC only)
757  if(doSimHit_){
758  std::vector<PSimHit> psimHits1;
759  std::vector<PSimHit> psimHits2;
760  //calculate layer
761  DetId id = overlapHit.first->recHit()->geographicalId();
762  int layer(-1);
763  layer = layerFromId(id, tTopo);
764  int subDet = id.subdetId();
765  edm::LogVerbatim("OverlapValidation") << "Subdet = " << subDet << " ; layer = " << layer;
766 
767  psimHits1 = associator.associateHit( *(firstRecHit->hit()) );
768  edm::LogVerbatim("OverlapValidation") << "single hit ";
769  edm::LogVerbatim("OverlapValidation") << "length of psimHits1: " << psimHits1.size();
770  if ( !psimHits1.empty() ) {
771  float closest_dist = 99999.9;
772  std::vector<PSimHit>::const_iterator closest_simhit = psimHits1.begin();
773  for (std::vector<PSimHit>::const_iterator m = psimHits1.begin(); m < psimHits1.end(); m++) {
774  //find closest simHit to the recHit
775  float simX = (*m).localPosition().x();
776  float dist = fabs( simX - (overlapHit.first->recHit()->localPosition().x()) );
777  edm::LogVerbatim("OverlapValidation") << "simHit1 simX = " << simX << " hitX = " << overlapHit.first->recHit()->localPosition().x() << " distX = " << dist << " layer = " << layer;
778  if (dist<closest_dist) {
779  //cout << "found newest closest dist for simhit1" << endl;
780  closest_dist = dist;
781  closest_simhit = m;
782  }
783  }
784  //if glued layer, convert sim hit position to matchedhit surface
785  //layer index from 1-4 for TIB, 1-6 for TOB
786  // Are the sim hits on the glued layers or are they split???
787  if ( subDet > 2 && !SiStripDetId(id).glued() ) {
788  const GluedGeomDet* gluedDet = (const GluedGeomDet*)(*trackerGeometry_).idToDet((*firstRecHit).hit()->geographicalId());
789  const StripGeomDetUnit* stripDet =(StripGeomDetUnit*) gluedDet->monoDet();
790  GlobalPoint gp = stripDet->surface().toGlobal( (*closest_simhit).localPosition() );
791  LocalPoint lp = gluedDet->surface().toLocal( gp );
792  LocalVector localdirection = (*closest_simhit).localDirection();
793  GlobalVector globaldirection = stripDet->surface().toGlobal(localdirection);
794  LocalVector direction = gluedDet->surface().toLocal(globaldirection);
795  float scale = -lp.z() / direction.z();
796  LocalPoint projectedPos = lp + scale*direction;
797  simHitPositions_[0] = projectedPos.x();
798  edm::LogVerbatim("OverlapValidation") << "simhit position from matched layer = " << simHitPositions_[0];
799  simHitPositionsY_[0] = projectedPos.y();
800  } else {
801  simHitPositions_[0] = (*closest_simhit).localPosition().x();
802  simHitPositionsY_[0] = (*closest_simhit).localPosition().y();
803  edm::LogVerbatim("OverlapValidation") << "simhit position from non-matched layer = " << simHitPositions_[0];
804  }
805  edm::LogVerbatim("OverlapValidation") << "hit position = " << hitPositions_[0];
806  } else {
807  simHitPositions_[0] = -99.;
808  simHitPositionsY_[0] = -99.;
809  //cout << " filling simHitX: " << -99 << endl;
810  }
811 
812 
813  psimHits2 = associator.associateHit( *(secondRecHit->hit()) );
814  if ( !psimHits2.empty() ) {
815  float closest_dist = 99999.9;
816  std::vector<PSimHit>::const_iterator closest_simhit = psimHits2.begin();
817  for (std::vector<PSimHit>::const_iterator m = psimHits2.begin(); m < psimHits2.end(); m++) {
818  float simX = (*m).localPosition().x();
819  float dist = fabs( simX - (overlapHit.second->recHit()->localPosition().x()) );
820  if (dist<closest_dist) {
821  closest_dist = dist;
822  closest_simhit = m;
823  }
824  }
825  //if glued layer, convert sim hit position to matchedhit surface
826  // if no sim hits on matched layers then this section can be removed
827  if ( subDet > 2 && !SiStripDetId(id).glued() ) {
828  const GluedGeomDet* gluedDet = (const GluedGeomDet*)(*trackerGeometry_).idToDet((*secondRecHit).hit()->geographicalId());
829  const StripGeomDetUnit* stripDet =(StripGeomDetUnit*) gluedDet->monoDet();
830  GlobalPoint gp = stripDet->surface().toGlobal( (*closest_simhit).localPosition() );
831  LocalPoint lp = gluedDet->surface().toLocal( gp );
832  LocalVector localdirection = (*closest_simhit).localDirection();
833  GlobalVector globaldirection = stripDet->surface().toGlobal(localdirection);
834  LocalVector direction = gluedDet->surface().toLocal(globaldirection);
835  float scale = -lp.z() / direction.z();
836  LocalPoint projectedPos = lp + scale*direction;
837  simHitPositions_[1] = projectedPos.x();
838  simHitPositionsY_[1] = projectedPos.y();
839  } else {
840  simHitPositions_[1] = (*closest_simhit).localPosition().x();
841  simHitPositionsY_[1] = (*closest_simhit).localPosition().y();
842  }
843  } else {
844  simHitPositions_[1] = -99.;
845  simHitPositionsY_[1] = -99.;
846  }
847  }
848  rootTree_->Fill();
849  }
850 }
ClusterRef cluster() const
size
Write out results.
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
const Point2DBase< float, LocalTag > zerozero
int foundHits() const
Definition: Trajectory.h:225
int lostHits() const
Definition: Trajectory.h:236
TrajectoryStateCombiner combiner_
unsigned int overlapIds_[2]
vector< bool > acceptLayer
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
uint32_t stereo() const
Definition: SiStripDetId.h:163
const LocalTrajectoryParameters & localParameters() const
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
float predictedPositions_[3][2]
virtual bool isItEdgePixelInX(int ixbin) const =0
const Point2DBase< float, LocalTag > onezero
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
virtual bool isItEdgePixelInY(int iybin) const =0
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const Point2DBase< float, LocalTag > zeroone
unsigned short hitCounts_[2]
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const MagneticField * magField_
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
DataContainer const & measurements() const
Definition: Trajectory.h:196
AlgebraicVector5 vector() const
const SurfaceType & surface() const
T mag() const
Definition: PV3DBase.h:67
int layerFromId(const DetId &, const TrackerTopology *const tTopo) const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
T sqrt(T t)
Definition: SSEVec.h:18
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
Definition: Propagator.cc:15
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float ChiSquaredProbability(double chiSquared, double nrDOF)
const AlgebraicSymMatrix55 & matrix() const
float predictedLocalErrors_[5][2]
const LocalTrajectoryError & localError() const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
Definition: DetId.h:18
uint32_t glued() const
Definition: SiStripDetId.h:158
int ndof(bool bon=true) const
Definition: Trajectory.cc:102
float predictedLocalParameters_[5][2]
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const GlobalTrajectoryParameters & globalParameters() const
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
def uint(string)
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
SiStripDetInfoFileReader * reader
float chiSquared() const
Definition: Trajectory.h:262
GlobalVector globalMomentum() const
static int position[264][3]
Definition: ReadPGInfo.cc:509
const AlgebraicMatrix55 & jacobian() const
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
T x() const
Definition: PV3DBase.h:62
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
Our base class.
Definition: SiPixelRecHit.h:23
void OverlapValidation::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 865 of file OverlapValidation.cc.

References DEFINE_FWK_MODULE, and rootTree_.

Referenced by o2olib.O2ORunMgr::executeJob().

865  {
866  if ( rootTree_ ) {
867  rootTree_->GetDirectory()->cd();
868  rootTree_->Write();
869  delete rootTree_;
870  }
871 }
int OverlapValidation::layerFromId ( const DetId id,
const TrackerTopology *const  tTopo 
) const
private

Definition at line 853 of file OverlapValidation.cc.

References TrackerAlignableId::typeAndLayerFromDetId().

Referenced by analyze().

854 {
855  TrackerAlignableId aliid;
856  std::pair<int,int> subdetandlayer = aliid.typeAndLayerFromDetId(id, tTopo);
857  int layer = subdetandlayer.second;
858 
859 
860  return layer;
861 
862 }
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const

Member Data Documentation

vector<bool> OverlapValidation::acceptLayer
private

Definition at line 148 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

const bool OverlapValidation::addExtraBranches_
private

Definition at line 120 of file OverlapValidation.cc.

Referenced by OverlapValidation().

bool OverlapValidation::barrelOnly_
private

Definition at line 151 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::chi2_[2]
private

Definition at line 127 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

const float OverlapValidation::chi2ProbCut_
private

Definition at line 122 of file OverlapValidation.cc.

Referenced by analyze().

uint OverlapValidation::clusterCharge_[2]
private

Definition at line 145 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::clusterSize_[2]
private

Definition at line 144 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::clusterWidthX_[2]
private

Definition at line 142 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::clusterWidthY_[2]
private

Definition at line 143 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

TrajectoryStateCombiner OverlapValidation::combiner_
private

Definition at line 115 of file OverlapValidation.cc.

Referenced by analyze().

edm::ParameterSet OverlapValidation::config_
private

Definition at line 108 of file OverlapValidation.cc.

Referenced by analyze().

bool OverlapValidation::doSimHit_
private

Definition at line 111 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

int OverlapValidation::edge_[2]
private

Definition at line 146 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

uint OverlapValidation::event_
private

Definition at line 150 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

edm::FileInPath OverlapValidation::FileInPath_
private

Definition at line 119 of file OverlapValidation.cc.

Referenced by OverlapValidation().

unsigned short OverlapValidation::hitCounts_[2]
private

Definition at line 126 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::hitErrors_[2]
private

Definition at line 137 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::hitErrorsY_[2]
private

Definition at line 139 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::hitPositions_[2]
private

Definition at line 136 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::hitPositionsY_[2]
private

Definition at line 138 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

uint OverlapValidation::layer_
private

Definition at line 125 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localxdotglobalphi_[2]
private

Definition at line 162 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localxdotglobalr_[2]
private

Definition at line 163 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localxdotglobalx_[2]
private

Definition at line 165 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localxdotglobaly_[2]
private

Definition at line 166 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localxdotglobalz_[2]
private

Definition at line 164 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localydotglobalphi_[2]
private

Definition at line 167 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localydotglobalr_[2]
private

Definition at line 168 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localydotglobalx_[2]
private

Definition at line 170 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localydotglobaly_[2]
private

Definition at line 171 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::localydotglobalz_[2]
private

Definition at line 169 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

const MagneticField* OverlapValidation::magField_
private

Definition at line 113 of file OverlapValidation.cc.

Referenced by analyze().

const int OverlapValidation::minHitsCut_
private

Definition at line 121 of file OverlapValidation.cc.

Referenced by analyze().

float OverlapValidation::moduleX_[2]
private

Definition at line 154 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::moduleY_[2]
private

Definition at line 155 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::moduleZ_[2]
private

Definition at line 156 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::momentum_
private

Definition at line 149 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

const Point2DBase<float, LocalTag> OverlapValidation::onezero = Point2DBase<float, LocalTag>(1, 0)
private

Definition at line 159 of file OverlapValidation.cc.

Referenced by analyze().

int OverlapValidation::overlapCounts_[3]
private

Definition at line 116 of file OverlapValidation.cc.

Referenced by analyze(), OverlapValidation(), and ~OverlapValidation().

unsigned int OverlapValidation::overlapIds_[2]
private

Definition at line 128 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::overlapPath_
private

Definition at line 124 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::predictedDeltaXError_
private

Definition at line 132 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::predictedDeltaYError_
private

Definition at line 133 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::predictedLocalErrors_[5][2]
private

Definition at line 131 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::predictedLocalParameters_[5][2]
private

Definition at line 130 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::predictedPositions_[3][2]
private

Definition at line 129 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

SiStripDetInfoFileReader* OverlapValidation::reader
private

Definition at line 110 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

char OverlapValidation::relativeXSign_
private

Definition at line 134 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

char OverlapValidation::relativeYSign_
private

Definition at line 135 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

TTree* OverlapValidation::rootTree_
private

Definition at line 118 of file OverlapValidation.cc.

Referenced by analyze(), endJob(), and OverlapValidation().

uint OverlapValidation::run_
private

Definition at line 150 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::simHitPositions_[2]
private

Definition at line 140 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

float OverlapValidation::simHitPositionsY_[2]
private

Definition at line 141 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

int OverlapValidation::subdetID
private

Definition at line 157 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

const TrackerGeometry* OverlapValidation::trackerGeometry_
private

Definition at line 112 of file OverlapValidation.cc.

Referenced by analyze().

edm::InputTag OverlapValidation::trajectoryTag_
private

Definition at line 109 of file OverlapValidation.cc.

Referenced by OverlapValidation().

edm::EDGetTokenT<TrajectoryCollection> OverlapValidation::trajectoryToken_
private

Definition at line 99 of file OverlapValidation.cc.

Referenced by analyze(), and OverlapValidation().

const Point2DBase<float, LocalTag> OverlapValidation::zeroone = Point2DBase<float, LocalTag>(0, 1)
private

Definition at line 160 of file OverlapValidation.cc.

Referenced by analyze().

const Point2DBase<float, LocalTag> OverlapValidation::zerozero = Point2DBase<float, LocalTag>(0, 0)
private

Definition at line 158 of file OverlapValidation.cc.

Referenced by analyze().