CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
TrackClusterSplitter Class Reference
Inheritance diagram for TrackClusterSplitter:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  ClusterWithTracks
 
class  FindCluster
 
struct  TrackAndState
 

Public Member Functions

void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 TrackClusterSplitter (const edm::ParameterSet &iConfig)
 
 ~TrackClusterSplitter ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::pair< uint32_t,
EncodedEventId
SimHitIdpr
 
typedef boost::sub_range
< std::vector
< SiPixelClusterWithTracks > > 
SiPixelClustersWithTracks
 
typedef ClusterWithTracks
< SiPixelCluster
SiPixelClusterWithTracks
 
typedef boost::sub_range
< std::vector
< SiStripClusterWithTracks > > 
SiStripClustersWithTracks
 
typedef ClusterWithTracks
< SiStripCluster
SiStripClusterWithTracks
 

Private Member Functions

template<>
const SiPixelClustergetCluster (const TrackingRecHit *hit)
 
template<>
const SiStripClustergetCluster (const TrackingRecHit *hit)
 
template<>
const SiStripClustergetCluster (const TrackingRecHit *hit)
 
template<>
const SiPixelClustergetCluster (const TrackingRecHit *hit)
 
template<typename Cluster >
void markClusters (std::map< uint32_t, boost::sub_range< std::vector< ClusterWithTracks< Cluster > > > > &map, const TrackingRecHit *hit, const reco::Track *track, const TrajectoryStateOnSurface &tsos) const
 
template<typename Cluster >
void splitCluster (const ClusterWithTracks< Cluster > &cluster, const GlobalVector &dir, typename edmNew::DetSetVector< Cluster >::FastFiller &output, DetId detId) const
 
template<>
void splitCluster (const SiPixelClusterWithTracks &cluster, const GlobalVector &dir, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output, DetId detId) const
 
template<>
void splitCluster (const SiStripClusterWithTracks &cluster, const GlobalVector &dir, edmNew::DetSetVector< SiStripCluster >::FastFiller &output, DetId detId) const
 
template<>
void splitCluster (const SiStripClusterWithTracks &c, const GlobalVector &vtx, edmNew::DetSetVector< SiStripCluster >::FastFiller &output, DetId detId) const
 
template<>
void splitCluster (const SiPixelClusterWithTracks &c, const GlobalVector &vtx, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output, DetId detId) const
 
template<typename Cluster >
std::auto_ptr
< edmNew::DetSetVector
< Cluster > > 
splitClusters (const std::map< uint32_t, boost::sub_range< std::vector< ClusterWithTracks< Cluster > > > > &input, const reco::Vertex &vtx) const
 

Static Private Member Functions

template<typename C >
static const C * equalClusters (const C &c1, const C &c2)
 
template<typename C >
static const C * getCluster (const TrackingRecHit *hit)
 

Private Attributes

std::vector
< SiPixelClusterWithTracks
allSiPixelClusters
 working data More...
 
std::vector
< SiStripClusterWithTracks
allSiStripClusters
 
edm::ESHandle
< GlobalTrackingGeometry
geometry_
 
std::unique_ptr
< TrackerHitAssociator
hitAssociator
 
edm::ESHandle< MagneticFieldmagfield_
 
edm::EDGetTokenT
< edmNew::DetSetVector
< SiPixelCluster > > 
pixelClusters_
 
edm::Handle< edm::DetSetVector
< PixelDigiSimLink > > 
pixeldigisimlink
 
edm::EDGetTokenT
< edm::DetSetVector
< PixelDigiSimLink > > 
pixeldigisimlinkToken
 
edm::ESHandle< Propagatorpropagator_
 
std::string propagatorName_
 
bool simSplitPixel_
 
bool simSplitStrip_
 
std::map< uint32_t,
SiPixelClustersWithTracks
siPixelDetsWithClusters
 
std::map< uint32_t,
SiStripClustersWithTracks
siStripDetsWithClusters
 
edm::EDGetTokenT
< edmNew::DetSetVector
< SiStripCluster > > 
stripClusters_
 
edm::Handle< edm::DetSetVector
< StripDigiSimLink > > 
stripdigisimlink
 
edm::EDGetTokenT
< edm::DetSetVector
< StripDigiSimLink > > 
stripdigisimlinkToken
 
std::vector
< SiPixelTemplateStore2D
thePixelTemp2D_
 
std::vector< SiPixelTemplateStorethePixelTemp_
 
std::vector< SiStripTemplateStoretheStripTemp_
 
bool tmpSplitPixel_
 
bool tmpSplitStrip_
 
TrackerHitAssociator::Config trackerHitAssociatorConfig_
 
edm::EDGetTokenT< std::vector
< reco::Track > > 
tracks_
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
trajTrackAssociations_
 
bool useStraightTracks_
 
bool useTrajectories_
 
edm::EDGetTokenT< std::vector
< reco::Vertex > > 
vertices_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
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 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 64 of file TrackClusterSplitter.cc.

Member Typedef Documentation

typedef std::pair<uint32_t, EncodedEventId> TrackClusterSplitter::SimHitIdpr
private

Definition at line 153 of file TrackClusterSplitter.cc.

typedef boost::sub_range<std::vector<SiPixelClusterWithTracks> > TrackClusterSplitter::SiPixelClustersWithTracks
private

Definition at line 148 of file TrackClusterSplitter.cc.

Definition at line 143 of file TrackClusterSplitter.cc.

typedef boost::sub_range<std::vector<SiStripClusterWithTracks> > TrackClusterSplitter::SiStripClustersWithTracks
private

Definition at line 149 of file TrackClusterSplitter.cc.

Definition at line 144 of file TrackClusterSplitter.cc.

Constructor & Destructor Documentation

TrackClusterSplitter::TrackClusterSplitter ( const edm::ParameterSet iConfig)

Definition at line 236 of file TrackClusterSplitter.cc.

References edm::ParameterSet::getParameter(), HLT_25ns14e33_v1_cff::InputTag, pixelClusters_, pixeldigisimlinkToken, propagatorName_, SiPixelTemplate2D::pushfile(), SiStripTemplate::pushfile(), SiPixelTemplate::pushfile(), simSplitPixel_, simSplitStrip_, AlCaHLTBitMon_QueryRunRegistry::string, stripClusters_, stripdigisimlinkToken, thePixelTemp2D_, thePixelTemp_, theStripTemp_, tmpSplitPixel_, tmpSplitStrip_, tracks_, trajTrackAssociations_, useStraightTracks_, useTrajectories_, and vertices_.

236  :
237  useTrajectories_(iConfig.getParameter<bool>("useTrajectories")),
239 {
240  if (useTrajectories_) {
241  trajTrackAssociations_ = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajTrackAssociations"));
242  } else {
243  propagatorName_ = iConfig.getParameter<std::string>("propagator");
244  tracks_ = consumes<std::vector<reco::Track> >(iConfig.getParameter<edm::InputTag>("tracks"));
245  }
246 
247  pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("pixelClusters"));
248  stripClusters_ = consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("stripClusters"));
249  vertices_ = consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("vertices"));
250 
251  produces< edmNew::DetSetVector<SiPixelCluster> >();
252 
253  produces< edmNew::DetSetVector<SiStripCluster> >();
254 
255  simSplitPixel_ = (iConfig.getParameter<bool>("simSplitPixel"));
256  simSplitStrip_ = (iConfig.getParameter<bool>("simSplitStrip"));
257  tmpSplitPixel_ = (iConfig.getParameter<bool>("tmpSplitPixel")); // not so nice... you don't want two bool but some switch
258  tmpSplitStrip_ = (iConfig.getParameter<bool>("tmpSplitStrip"));
259 
260  useStraightTracks_ = (iConfig.getParameter<bool>("useStraightTracks"));
261 
262 
263  if ( simSplitPixel_ ) pixeldigisimlinkToken = consumes< edm::DetSetVector<PixelDigiSimLink> >(edm::InputTag("simSiPixelDigis"));
264  if ( simSplitStrip_ ) stripdigisimlinkToken = consumes< edm::DetSetVector<StripDigiSimLink> >(edm::InputTag("simSiStripDigis"));
265 
266 
267 
268  /*
269  cout << "TrackClusterSplitter : " << endl;
270  cout << endl << endl << endl;
271  cout << "(int)simSplitPixel_ = " << (int)simSplitPixel_ << endl;
272  cout << "(int)simSplitStrip_ = " << (int)simSplitStrip_ << endl;
273  cout << "(int)tmpSplitPixel_ = " << (int)tmpSplitPixel_ << endl;
274  cout << "(int)tmpSplitStrip_ = " << (int)tmpSplitStrip_ << endl;
275  cout << "stripClusters_ = " << stripClusters_ << endl;
276  cout << "pixelClusters_ = " << pixelClusters_ << endl;
277  cout << "(int)useTrajectories_ = " << (int)useTrajectories_ << endl;
278  cout << "trajectories_ = " << trajectories_ << endl;
279  cout << "propagatorName_ = " << propagatorName_ << endl;
280  cout << "vertices_ = " << vertices_ << endl;
281  cout << "useStraightTracks_ = " << useStraightTracks_ << endl;
282  cout << endl << endl << endl;
283  */
284 
285  // Load template; 40 for barrel and 41 for endcaps
290 
291  // Load strip templates
298 
299 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > stripdigisimlinkToken
edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAssociations_
TrackerHitAssociator::Config trackerHitAssociatorConfig_
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &thePixelTemp_)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &thePixelTemp_)
std::vector< SiPixelTemplateStore > thePixelTemp_
std::vector< SiPixelTemplateStore2D > thePixelTemp2D_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlinkToken
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
std::vector< SiStripTemplateStore > theStripTemp_
edm::EDGetTokenT< std::vector< reco::Track > > tracks_
static bool pushfile(int filenum, std::vector< SiStripTemplateStore > &theStripTemp_)
TrackClusterSplitter::~TrackClusterSplitter ( )

Definition at line 330 of file TrackClusterSplitter.cc.

331 {
332 }

Member Function Documentation

template<typename C >
static const C* TrackClusterSplitter::equalClusters ( const C &  c1,
const C &  c2 
)
inlinestaticprivate

Definition at line 161 of file TrackClusterSplitter.cc.

162  {
163  return nullptr;
164  }
template<typename C >
static const C* TrackClusterSplitter::getCluster ( const TrackingRecHit hit)
staticprivate
template<>
const SiPixelCluster* TrackClusterSplitter::getCluster ( const TrackingRecHit hit)
private
template<>
const SiStripCluster* TrackClusterSplitter::getCluster ( const TrackingRecHit hit)
private
template<>
const SiStripCluster* TrackClusterSplitter::getCluster ( const TrackingRecHit hit)
private

Definition at line 304 of file TrackClusterSplitter.cc.

References Exception.

305 {
306  if ( typeid(*hit) == typeid(SiStripRecHit2D) )
307  {
308  return (static_cast<const SiStripRecHit2D &>(*hit)).cluster().get();
309  }
310  else if ( typeid(*hit) == typeid(SiStripRecHit1D) )
311  {
312  return (static_cast<const SiStripRecHit1D &>(*hit)).cluster().get();
313  }
314  else
315  throw cms::Exception("Unsupported") << "Detid of type " << typeid(*hit).name() << " not supported.\n";
316 }
template<>
const SiPixelCluster* TrackClusterSplitter::getCluster ( const TrackingRecHit hit)
private

Definition at line 320 of file TrackClusterSplitter.cc.

References Exception.

321 {
322  if ( typeid(*hit) == typeid(SiPixelRecHit) )
323  {
324  return (static_cast<const SiPixelRecHit&>(*hit)).cluster().get();
325  }
326  else
327  throw cms::Exception("Unsupported") << "Detid of type " << typeid(*hit).name() << " not supported.\n";
328 }
Our base class.
Definition: SiPixelRecHit.h:23
template<typename Cluster >
void TrackClusterSplitter::markClusters ( std::map< uint32_t, boost::sub_range< std::vector< ClusterWithTracks< Cluster > > > > &  map,
const TrackingRecHit hit,
const reco::Track track,
const TrajectoryStateOnSurface tsos 
) const
private

Definition at line 531 of file TrackClusterSplitter.cc.

References TrackingRecHit::geographicalId(), python.multivaluedict::map(), match(), mergeVDriftHistosByStation::name, and DetId::rawId().

535 {
536  boost::sub_range<std::vector<ClusterWithTracks<Cluster> > >& range = map[hit->geographicalId().rawId()];
537 
538  typedef typename std::vector<ClusterWithTracks<Cluster> >::iterator IT;
539  IT match = std::find_if(range.begin(), range.end(), FindCluster<Cluster>(hit));
540 
541  if ( match != range.end() )
542  {
543  match->tracks.push_back( TrackAndState(track,tsos) );
544  }
545  else
546  {
547  edm::LogWarning("ClusterNotFound") << "Cluster of type " << typeid(Cluster).name() << " on detid "
548  << hit->geographicalId().rawId() << " from hit of type " << typeid(*hit).name();
549  }
550 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< LinkConnSpec >::const_iterator IT
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
DetId geographicalId() const
void TrackClusterSplitter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 335 of file TrackClusterSplitter.cc.

References allSiPixelClusters, allSiStripClusters, edmNew::DetSet< T >::begin(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, edmNew::DetSet< T >::detId(), end, edmNew::DetSet< T >::end(), Exception, plotBeamSpotDB::first, TrackingRecHit::geographicalId(), geometry_, edm::EventSetup::get(), edm::Event::getByToken(), hitAssociator, trajectoryStateTransform::innerFreeState(), TrackingRecHit::isValid(), magfield_, Trajectory::measurements(), pixelClusters_, pixeldigisimlink, pixeldigisimlinkToken, propagator_, edm::Event::put(), DetId::rawId(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), reco::Track::recHitsSize(), simSplitPixel_, simSplitStrip_, siPixelDetsWithClusters, siStripDetsWithClusters, splitClusters(), dqm_diff::start, stripClusters_, stripdigisimlink, stripdigisimlinkToken, DetId::subdetId(), GeomDet::surface(), trackerHitAssociatorConfig_, testEve_cfg::tracks, tracks_, HLT_25ns14e33_v1_cff::trajectories, trajTrackAssociations_, useTrajectories_, HLT_25ns14e33_v1_cff::vertices, and vertices_.

336 {
337  using namespace edm;
338 
340 
341  if ( !useTrajectories_ )
342  {
343  iSetup.get<IdealMagneticFieldRecord>().get( magfield_ );
344  iSetup.get<TrackingComponentsRecord>().get( "AnalyticalPropagator", propagator_ );
345  }
346 
347  Handle<edmNew::DetSetVector<SiPixelCluster> > inputPixelClusters;
348  Handle<edmNew::DetSetVector<SiStripCluster> > inputStripClusters;
349 
350  iEvent.getByToken(pixelClusters_, inputPixelClusters);
351 
352  iEvent.getByToken(stripClusters_, inputStripClusters);
353 
354  if(simSplitStrip_)
356 
357 
360 
361 
362  allSiPixelClusters.reserve(inputPixelClusters->dataSize()); // this is important, otherwise push_back invalidates the iterators
363  allSiStripClusters.reserve(inputStripClusters->dataSize()); // this is important, otherwise push_back invalidates the iterators
364 
365 
366  // fill in the list of all tracks
367  foreach(const edmNew::DetSet<SiPixelCluster> &ds, *inputPixelClusters)
368  {
369  std::vector<SiPixelClusterWithTracks>::iterator start = allSiPixelClusters.end();
370  allSiPixelClusters.insert(start, ds.begin(), ds.end());
371 
372  std::vector<SiPixelClusterWithTracks>::iterator end = allSiPixelClusters.end();
374  }
375 
376  foreach(const edmNew::DetSet<SiStripCluster> &ds, *inputStripClusters)
377  {
378  std::vector<SiStripClusterWithTracks>::iterator start = allSiStripClusters.end();
379  allSiStripClusters.insert(start, ds.begin(), ds.end());
380 
381  std::vector<SiStripClusterWithTracks>::iterator end = allSiStripClusters.end();
383  }
384 
385  if ( useTrajectories_ )
386  {
387  // Here use the fully reconstructed tracks to get the track angle
388 
390  iEvent.getByToken(trajTrackAssociations_, trajectories);
391  for ( TrajTrackAssociationCollection::const_iterator it = trajectories->begin(),
392  ed = trajectories->end(); it != ed; ++it )
393  {
394  const Trajectory & traj = *it->key;
395  const reco::Track * tk = &*it->val;
396 
397  if ( traj.measurements().size() != tk->recHitsSize() )
398  throw cms::Exception("Aargh") << "Sizes don't match: traj " << traj.measurements().size()
399  << ", tk " << tk->recHitsSize() << "\n";
400 
401  trackingRecHit_iterator it_hit = tk->recHitsBegin(), ed_hit = tk->recHitsEnd();
402 
403  const Trajectory::DataContainer & tms = traj.measurements();
404 
405  size_t i_hit = 0, last_hit = tms.size()-1;
406 
407  bool first = true, reversed = false;
408 
409  for (; it_hit != ed_hit; ++it_hit, ++i_hit)
410  {
411  // ignore hits with no detid
412 
413  if ((*it_hit)->geographicalId().rawId() == 0)
414  {
415  //cout << "It should never happen that a trackingRecHit has no detector ID !!!!!!!!!!!!!!!!! " << endl;
416  continue;
417  }
418 
419  // if it's the first hit, check the ordering of track vs trajectory
420  if (first)
421  {
422 
423  if ((*it_hit)->geographicalId() == tms[i_hit].recHit()->hit()->geographicalId())
424  {
425  reversed = false;
426  }
427  else if ((*it_hit)->geographicalId() == tms[last_hit-i_hit].recHit()->hit()->geographicalId())
428  {
429  reversed = true;
430  }
431  else
432  {
433  throw cms::Exception("Aargh") << "DetIDs don't match either way :-( \n";
434  }
435  }
436 
437  const TrackingRecHit *hit = *it_hit;
438  if ( hit == 0 || !hit->isValid() )
439  continue;
440 
441  int subdet = hit->geographicalId().subdetId();
442 
443  if (subdet >= 3)
444  { // strip
445  markClusters<SiStripCluster>(siStripDetsWithClusters, hit, tk, tms[reversed ? last_hit-i_hit : i_hit].updatedState());
446  }
447  else if (subdet >= 1)
448  { // pixel
449  markClusters<SiPixelCluster>(siPixelDetsWithClusters, hit, tk, tms[reversed ? last_hit-i_hit : i_hit].updatedState());
450  }
451  else
452  {
453  edm::LogWarning("HitNotFound") << "Hit of type " << typeid(*hit).name() << ", detid "
454  << hit->geographicalId().rawId() << ", subdet " << subdet;
455  }
456  }
457  }
458  }
459  else
460  {
461  // Here use the pixel tracks to get the track angles
462 
464  iEvent.getByToken(tracks_, tracks);
465  //TrajectoryStateTransform transform;
466  foreach (const reco::Track &track, *tracks)
467  {
469  trackingRecHit_iterator it_hit = track.recHitsBegin(), ed_hit = track.recHitsEnd();
470  for (; it_hit != ed_hit; ++it_hit)
471  {
472  const TrackingRecHit *hit = *it_hit;
473  if ( hit == 0 || !hit->isValid() )
474  continue;
475 
476  int subdet = hit->geographicalId().subdetId();
477 
478  if ( subdet == 0 )
479  continue;
480 
481  const GeomDet *det = geometry_->idToDet( hit->geographicalId() );
482 
483  if ( det == 0 )
484  {
485  edm::LogError("MissingDetId") << "DetIDs " << (int)(hit->geographicalId()) << " is not in geometry.\n";
486  continue;
487  }
488 
489  TrajectoryStateOnSurface prop = propagator_->propagate(atVtx, det->surface());
490  if ( subdet >= 3 )
491  { // strip
492  markClusters<SiStripCluster>(siStripDetsWithClusters, hit, &track, prop);
493  }
494  else if (subdet >= 1)
495  { // pixel
496  markClusters<SiPixelCluster>(siPixelDetsWithClusters, hit, &track, prop);
497  }
498  else
499  {
500  edm::LogWarning("HitNotFound") << "Hit of type " << typeid(*hit).name() << ", detid "
501  << hit->geographicalId().rawId() << ", subdet " << subdet;
502  }
503  }
504  }
505  }
506 
508  iEvent.getByToken(vertices_, vertices);
509 
510  // Needed in case of simsplit
511  if ( simSplitPixel_ )
513 
514  // Needed in case of strip simsplit
515  if ( simSplitStrip_ )
517 
518  // gavril : to do: choose the best vertex here instead of just choosing the first one ?
519  std::auto_ptr<edmNew::DetSetVector<SiPixelCluster> > newPixelClusters( splitClusters( siPixelDetsWithClusters, vertices->front() ) );
520  std::auto_ptr<edmNew::DetSetVector<SiStripCluster> > newStripClusters( splitClusters( siStripDetsWithClusters, vertices->front() ) );
521 
522  iEvent.put(newPixelClusters);
523  iEvent.put(newStripClusters);
524 
525  allSiPixelClusters.clear(); siPixelDetsWithClusters.clear();
526  allSiStripClusters.clear(); siStripDetsWithClusters.clear();
527 
528 }
edm::ESHandle< Propagator > propagator_
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > stripdigisimlinkToken
edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAssociations_
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
TrackerHitAssociator::Config trackerHitAssociatorConfig_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
std::auto_ptr< edmNew::DetSetVector< Cluster > > splitClusters(const std::map< uint32_t, boost::sub_range< std::vector< ClusterWithTracks< Cluster > > > > &input, const reco::Vertex &vtx) const
edm::Handle< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlink
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
DataContainer const & measurements() const
Definition: Trajectory.h:203
edm::ESHandle< MagneticField > magfield_
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:42
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlinkToken
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
std::vector< SiPixelClusterWithTracks > allSiPixelClusters
working data
edm::ESHandle< GlobalTrackingGeometry > geometry_
#define end
Definition: vmac.h:37
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
boost::sub_range< std::vector< SiPixelClusterWithTracks > > SiPixelClustersWithTracks
std::vector< SiStripClusterWithTracks > allSiStripClusters
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
boost::sub_range< std::vector< SiStripClusterWithTracks > > SiStripClustersWithTracks
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
std::map< uint32_t, SiStripClustersWithTracks > siStripDetsWithClusters
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
bool isValid() const
id_type detId() const
Definition: DetSetNew.h:83
std::map< uint32_t, SiPixelClustersWithTracks > siPixelDetsWithClusters
iterator end()
Definition: DetSetNew.h:70
edm::EDGetTokenT< std::vector< reco::Track > > tracks_
std::unique_ptr< TrackerHitAssociator > hitAssociator
DetId geographicalId() const
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109
iterator begin()
Definition: DetSetNew.h:67
template<typename Cluster >
void TrackClusterSplitter::splitCluster ( const ClusterWithTracks< Cluster > &  cluster,
const GlobalVector dir,
typename edmNew::DetSetVector< Cluster >::FastFiller &  output,
DetId  detId 
) const
private

Definition at line 588 of file TrackClusterSplitter.cc.

References Exception.

Referenced by splitClusters().

592 {
593  //cout << "Should never be here: TrackClusterSplitter, TrackClusterSplitter::splitCluster(...) !!!!!!!!!!!!!!!!!!!!!!!!!!!!! " << endl;
594  throw cms::Exception("LogicError", "This should not be called");
595 }
template<>
void TrackClusterSplitter::splitCluster ( const SiPixelClusterWithTracks cluster,
const GlobalVector dir,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output,
DetId  detId 
) const
private
template<>
void TrackClusterSplitter::splitCluster ( const SiStripClusterWithTracks cluster,
const GlobalVector dir,
edmNew::DetSetVector< SiStripCluster >::FastFiller &  output,
DetId  detId 
) const
private
template<>
void TrackClusterSplitter::splitCluster ( const SiStripClusterWithTracks c,
const GlobalVector vtx,
edmNew::DetSetVector< SiStripCluster >::FastFiller &  output,
DetId  detId 
) const
private

Definition at line 598 of file TrackClusterSplitter.cc.

References SiStripCluster::amplitudes(), SiStripCluster::barycenter(), begin, BXSIZE, EnergyCorrector::c, GetRecoTauVFromDQM_MC_cff::cl2, edm::DetSet< T >::data, end, Exception, plotBeamSpotDB::first, SiStripCluster::firstStrip(), geometry_, hitAssociator, i, SiStripTemplate::interpolate(), j, prof2calltree::last, TrajectoryStateOnSurface::localParameters(), StripTopology::localPosition(), PV3DBase< T, PVType, FrameType >::mag(), magfield_, bookConverter::max, min(), SiStripDetId::moduleGeometry(), LocalTrajectoryParameters::momentum(), convertSQLitetoXML_cfg::output, GloballyPositioned< T >::position(), reco::TrackBase::pt(), SiStripTemplate::qbin(), SiStripCluster::setSplitClusterError(), simSplitStrip_, findQualityFiles::size, StripGeomDetUnit::specificTopology(), mathSSE::sqrt(), stripdigisimlink, SiStripTemplateSplit::StripTempSplit(), GeomDet::surface(), SiStripTemplate::sxtemp(), theStripTemp_, tmpSplitStrip_, Surface::toGlobal(), toLocal(), useStraightTracks_, PV3DBase< T, PVType, FrameType >::x(), SiStripTemplate::xsize(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

603 {
604  if ( simSplitStrip_ )
605  {
606  bool cluster_was_successfully_split = false;
607 
608  const SiStripCluster* clust = static_cast<const SiStripCluster*>(c.cluster);
609 
610  std::vector<SimHitIdpr> associatedIdpr;
611 
612  hitAssociator->associateSimpleRecHitCluster(clust, detId, associatedIdpr);
613 
614  size_t splittableClusterSize = 0;
615  splittableClusterSize = associatedIdpr.size();
616  auto const & amp = clust->amplitudes();
617  int clusiz = amp.size();
618  associatedIdpr.clear();
619 
620  SiStripDetId ssdid( detId );
621 
622  // gavril : sim splitting can be applied to the forward detectors as well...
623 
624  if ( ( splittableClusterSize > 1 && amp.size() > 2 ) &&
625  ( (int)ssdid.moduleGeometry() == 1 ||
626  (int)ssdid.moduleGeometry() == 2 ||
627  (int)ssdid.moduleGeometry() == 3 ||
628  (int)ssdid.moduleGeometry() == 4 ) )
629  {
630 
632 
633  int first = clust->firstStrip();
634  int last = first + clusiz;
635  uint16_t rawAmpl = 0, currentAmpl = 0;
636 
637  std::vector<uint16_t> tmp1, tmp2;
638 
639  std::vector<int> firstStrip;
640  std::vector<bool> trackInStrip;
641  std::vector<unsigned int> trackID;
642  std::vector<float> trackFraction;
643  std::vector< std::vector<uint16_t> > trackAmp;
644  unsigned int currentChannel( 9999 );
645  unsigned int thisTrackID = 0;
646 
647  if ( isearch != stripdigisimlink->end() )
648  {
649  edm::DetSet<StripDigiSimLink> link_detset = (*isearch);
650 
651  for ( edm::DetSet<StripDigiSimLink>::const_iterator linkiter = link_detset.data.begin();
652  linkiter != link_detset.data.end(); linkiter++)
653  {
654  if ( (int)(linkiter->channel()) >= first && (int)(linkiter->channel()) < last )
655  {
656  int stripIdx = (int)linkiter->channel()-first;
657  rawAmpl = (uint16_t)(amp[stripIdx]);
658 
659  // DigiSimLinks are ordered first by channel; there can be > 1 track, and > 1 simHit for each track
660 
661  if ( linkiter->channel() != currentChannel )
662  {
663  // New strip; store amplitudes for the previous one
664  uint16_t thisAmpl;
665 
666  for (size_t i=0; i<trackID.size(); ++i)
667  {
668  if ( trackInStrip[i] )
669  {
670  if ( ( thisAmpl=currentAmpl ) < 254 )
671  thisAmpl = min( uint16_t(253), max(uint16_t(0), (uint16_t)(currentAmpl*trackFraction[i]+0.5)) );
672  trackAmp[i].push_back( thisAmpl );
673  }
674 
675  trackFraction[i] = 0;
676  trackInStrip[i] = false;
677  }
678 
679  currentChannel = linkiter->channel();
680  currentAmpl = rawAmpl;
681  }
682 
683  // Now deal with this new DigiSimLink
684  thisTrackID = linkiter->SimTrackId();
685 
686  // Have we seen this track yet?
687  bool newTrack = true;
688  int thisTrackIdx = 9999;
689 
690  for (size_t i=0; i<trackID.size(); ++i)
691  {
692  if ( trackID[i] == thisTrackID )
693  {
694  thisTrackIdx = i;
695  newTrack = false;
696  }
697  }
698 
699  if ( newTrack )
700  {
701  trackInStrip.push_back(false); // We'll set it true below
702  trackID.push_back(thisTrackID);
703  firstStrip.push_back(currentChannel);
704  std::vector<uint16_t> ampTmp;
705  trackAmp.push_back(ampTmp);
706  trackFraction.push_back(0);
707  thisTrackIdx = trackID.size()-1;
708  }
709 
710  trackInStrip[thisTrackIdx] = true;
711  trackFraction[thisTrackIdx] += linkiter->fraction();
712  currentAmpl = rawAmpl;
713 
714  }
715 
716  }// end of loop over DigiSimLinks
717 
718  // we want to continue here!!!!
719 
720  std::vector<SiStripCluster> newCluster;
721  // Fill amplitudes for the last strip and create a cluster for each track
722  uint16_t thisAmpl;
723 
724  for (size_t i=0; i < trackID.size(); ++i)
725  {
726  if ( trackInStrip[i] )
727  {
728  if ( ( thisAmpl=rawAmpl ) < 254 )
729  thisAmpl = min(uint16_t(253), max(uint16_t(0), (uint16_t)(rawAmpl*trackFraction[i]+0.5)));
730 
731  if ( thisAmpl > 0 )
732  trackAmp[i].push_back( thisAmpl );
733  //else
734  //cout << "thisAmpl = " << (int)thisAmpl << endl;
735  }
736 
737  newCluster.push_back( SiStripCluster(
738  firstStrip[i],
739  trackAmp[i].begin(),
740  trackAmp[i].end() ) );
741 
742  }
743 
744 
745  for ( size_t i=0; i<newCluster.size(); ++i )
746  {
747 
748  // gavril : This is never used. Will use it below
749  float clusterAmp = 0.0;
750  for (size_t j=0; j<trackAmp[i].size(); ++j )
751  clusterAmp += (float)(trackAmp[i])[j];
752 
753  if ( clusterAmp > 0.0 && firstStrip[i] != 9999 && trackAmp[i].size() > 0 )
754  {
755  // gavril : I think this should work
756  output.push_back( newCluster[i] );
757 
758  //cout << endl << endl << endl;
759  //cout << "(int)(newCluster[i].amplitudes().size()) = " << (int)(newCluster[i].amplitudes().size()) << endl;
760  //for ( int j=0; j<(int)(newCluster[i].amplitudes().size()); ++j )
761  //cout << "(newCluster[i].amplitudes())[j] = " << (int)(newCluster[i].amplitudes())[j] << endl;
762 
763  cluster_was_successfully_split = true;
764  }
765  else
766  {
767  //std::cout << "\t\t Rejecting new cluster" << std::endl;
768 
769  // gavril : I think this pointer should be deleted above
770  //delete newCluster[i];
771  }
772  }
773 
774  } // if ( isearch != stripdigisimlink->end() ) ...
775  else
776  {
777  // Do nothing...
778  }
779  }
780 
781 
782  if ( !cluster_was_successfully_split )
783  output.push_back( *c.cluster );
784 
785  } // end of if ( strip_simSplit_ )...
786 
787  else if ( tmpSplitStrip_ )
788  {
789  bool cluster_was_successfully_split = false;
790 
791  const SiStripCluster* theStripCluster = static_cast<const SiStripCluster*>(c.cluster);
792 
793  if ( theStripCluster )
794  {
795  //SiStripDetId ssdid( theStripCluster->geographicalId() );
796  SiStripDetId ssdid( detId.rawId() );
797 
798  // Do not attempt to split clusters of size less than or equal to one.
799  // Only split clusters in IB1, IB2, OB1, OB2 (TIB and TOB).
800 
801  if ( (int)theStripCluster->amplitudes().size() <= 1 ||
802  ( (int)ssdid.moduleGeometry() != 1 &&
803  (int)ssdid.moduleGeometry() != 2 &&
804  (int)ssdid.moduleGeometry() != 3 &&
805  (int)ssdid.moduleGeometry() != 4 ) )
806  {
807  // Do nothing.
808  //cout << endl;
809  //cout << "Will NOT attempt to split this clusters: " << endl;
810  //cout << "(int)theStripCluster->amplitudes().size() = " << (int)theStripCluster->amplitudes().size() << endl;
811  //cout << "(int)ssdid.moduleGeometry() = " << (int)ssdid.moduleGeometry() << endl;
812 
813  }
814  else // if ( (int)theStripCluster->amplitudes().size() <= 1 )
815  {
816 
817  //cout << endl;
818  //cout << "Will attempt to split this clusters: " << endl;
819 
820  int ID = -99999;
821 
822  int is_stereo = (int)( ssdid.stereo() );
823 
824  if ( ssdid.moduleGeometry() == 1 ) // IB1
825  {
826  if ( !is_stereo )
827  ID = 11;
828  else
829  ID = 12;
830  }
831  else if ( ssdid.moduleGeometry() == 2 ) // IB2
832  {
833  ID = 13;
834  }
835  else if ( ssdid.moduleGeometry() == 3 ) // OB1
836  {
837  ID = 16;
838  }
839  else if ( ssdid.moduleGeometry() == 4 ) // OB2
840  {
841  if ( !is_stereo )
842  ID = 14;
843  else
844  ID = 15;
845  }
846  else
847  {
848  throw cms::Exception("TrackClusterSplitter::splitCluster")
849  << "\nERROR: Wrong strip teplate ID. Should only use templates for IB1, IB2, OB1 and OB2 !!!" << "\n\n";
850  }
851 
852 
853 
854 
855  // Begin: determine incident angles ============================================================
856 
857  float cotalpha_ = -99999.9;
858  float cotbeta_ = -99999.9;
859 
860  // First, determine track angles from straight track approximation
861 
862  // Find crude cluster center
863  // gavril : This is in local coordinates ?
864  float xcenter = theStripCluster->barycenter();
865 
866  const GeomDetUnit* theDet = geometry_->idToDetUnit( detId );
867  const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit*>( theDet );
868 
869  if ( !stripDet )
870  {
871  throw cms::Exception("TrackClusterSplitter : ")
872  << "\nERROR: Wrong stripDet !!! " << "\n\n";
873  }
874 
875 
876  const StripTopology* theTopol = &( stripDet->specificTopology() );
877 
878  // Transform from measurement to local coordinates (in cm)
879  // gavril: may have to differently if kicks/bows are introduced. However, at this point there are no tracks...:
880  // LocalPoint lp = theTopol->localPosition( xcenter, /*const Topology::LocalTrackPred & */ trkPred );
881 
882  // gavril : What is lp.y() for strips ? It is zero, but is that the strip center or one of the ends ?
883  LocalPoint lp = theTopol->localPosition( xcenter );
884 
885  // Transform from local to global coordinates
886  GlobalPoint gp0 = theDet->surface().toGlobal( lp );
887 
888  // Make a vector pointing from the PV to the cluster center
889  GlobalPoint gp(gp0.x()-vtx.x(), gp0.y()-vtx.y(), gp0.z()-vtx.z() );
890 
891  // Make gp a unit vector, gv, pointing from the PV to the cluster center
892  float gp_mod = sqrt( gp.x()*gp.x() + gp.y()*gp.y() + gp.z()*gp.z() );
893  float gpx = gp.x()/gp_mod;
894  float gpy = gp.y()/gp_mod;
895  float gpz = gp.z()/gp_mod;
896  GlobalVector gv(gpx, gpy, gpz);
897 
898  // Make unit vectors in local coordinates and then transform them in global coordinates
899  const Local3DVector lvx(1.0, 0.0, 0.0);
900  GlobalVector gvx = theDet->surface().toGlobal( lvx );
901  const Local3DVector lvy(0.0, 1.0, 0.0);
902  GlobalVector gvy = theDet->surface().toGlobal( lvy );
903  const Local3DVector lvz(0.0, 0.0, 1.0);
904  GlobalVector gvz = theDet->surface().toGlobal( lvz );
905 
906  // Calculate angles alpha and beta
907  float gv_dot_gvx = gv.x()*gvx.x() + gv.y()*gvx.y() + gv.z()*gvx.z();
908  float gv_dot_gvy = gv.x()*gvy.x() + gv.y()*gvy.y() + gv.z()*gvy.z();
909  float gv_dot_gvz = gv.x()*gvz.x() + gv.y()*gvz.y() + gv.z()*gvz.z();
910 
911  // gavril : check beta !!!!!!!!!!!!
912  //float alpha_ = atan2( gv_dot_gvz, gv_dot_gvx );
913  //float beta_ = atan2( gv_dot_gvz, gv_dot_gvy );
914 
915  cotalpha_ = gv_dot_gvx / gv_dot_gvz;
916  cotbeta_ = gv_dot_gvy / gv_dot_gvz;
917 
918  // Attempt to get a better angle from tracks (either pixel tracks or full tracks)
919  if ( !useStraightTracks_ )
920  {
921  //cout << "TrackClusterSplitter.cc : " << endl;
922  //cout << "Should not be here for now !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " << endl;
923 
924  // Use either pixel tracks (useTrajectories_ = False) or fully reconstructed tracks (useTrajectories_ = True)
925  // When pixel/full tracks are not associated with the current cluster, will use angles from straight tracks
926 
927  // These are the tracks associated with this cluster
928  std::vector<TrackAndState> vec_tracks_states = c.tracks;
929 
930  if ( (int)vec_tracks_states.size() > 0 )
931  {
932  //cout << "There is at least one track associated with this cluster. Pick the one with largest Pt." << endl;
933  //cout << "(int)vec_tracks_states.size() = " << (int)vec_tracks_states.size() << endl;
934 
935  int index_max_pt = -99999; // index of the track with the highest Pt
936  float max_pt = -99999.9;
937 
938  for (int i=0; i<(int)vec_tracks_states.size(); ++i )
939  {
940  const reco::Track* one_track = vec_tracks_states[i].track;
941 
942  if ( one_track->pt() > max_pt )
943  {
944  index_max_pt = i;
945  max_pt = one_track->pt();
946  }
947  }
948 
949  // Pick the tsos from the track with highest Pt
950  // gavril: Should we use highest Pt or best Chi2 ?
951  TrajectoryStateOnSurface one_tsos = vec_tracks_states[index_max_pt].state;
952 
954 
955  LocalVector localDir = ltp.momentum()/ltp.momentum().mag();
956 
957  float locx = localDir.x();
958  float locy = localDir.y();
959  float locz = localDir.z();
960 
961  //alpha_ = atan2( locz, locx );
962  //beta_ = atan2( locz, locy );
963 
964  cotalpha_ = locx/locz;
965  cotbeta_ = locy/locz;
966 
967  } // if ( (int)vec_tracks_states.size() > 0 )
968 
969  } // if ( !useStraightTracks_ )
970 
971 
972  // End: determine incident angles ============================================================
973 
974 
975  // Calculate strip cluster charge and store amplitudes in vector for later use
976 
977  //cout << endl;
978  //cout << "Calculate strip cluster charge and store amplitudes in vector for later use" << endl;
979 
980  float strip_cluster_charge = 0.0;
981  std::vector<float> vec_cluster_charge;
982  vec_cluster_charge.clear();
983  int cluster_size = (int)( (theStripCluster->amplitudes()).size() );
984 
985  int cluster_charge = 0;
986  for (int i=0; i<cluster_size; ++i)
987  {
988  float current_strip_charge = (float)( (theStripCluster->amplitudes())[i] );
989 
990  strip_cluster_charge += current_strip_charge;
991  vec_cluster_charge.push_back( current_strip_charge );
992 
993  cluster_charge +=current_strip_charge;
994  }
995 
996 
997  //cout << endl;
998  //cout << "Calling strip qbin to see if the strip cluster has to be split..." << endl;
999  SiStripTemplate strip_templ_(theStripTemp_);
1000  int strip_templQbin_ = strip_templ_.qbin( ID, cotalpha_, cotbeta_, strip_cluster_charge );
1001 
1002  if ( strip_templQbin_ < 0 || strip_templQbin_ > 5 )
1003  {
1004  // Do nothing...
1005  // cout << "Wrong strip strip_templQbin_ = " << strip_templQbin_ << endl;
1006  } // if ( strip_templQbin_ < 0 || strip_templQbin_ > 5 )
1007  else // if ( strip_templQbin_ < 0 || strip_templQbin_ > 5 ) {...} else
1008  {
1009  if ( strip_templQbin_ != 0 )
1010  {
1011  // Do not split this cluster. Do nothing.
1012  //cout << endl;
1013  //cout << "Do NOT split this cluster" << endl;
1014 
1015  } // if ( strip_templQbin_ != 0 )
1016  else // if ( templQbin_ != 0 ) {...} else
1017  {
1018  //cout << endl;
1019  //cout << "Split this cluster" << endl;
1020 
1021  // gavril : Is this OK ?
1022  uint16_t first_strip = theStripCluster->firstStrip();
1023 
1024  LocalVector lbfield = ( stripDet->surface() ).toLocal( magfield_->inTesla( stripDet->surface().position() ) );
1025  float locBy = lbfield.y();
1026 
1027  // Initialize values coming back from SiStripTemplateSplit::StripTempSplit
1028  float stripTemplXrec1_ = -99999.9;
1029  float stripTemplXrec2_ = -99999.9;
1030  float stripTemplSigmaX_ = -99999.9;
1031  float stripTemplProbX_ = -99999.9;
1032  int stripTemplQbin_ = -99999;
1033  float stripTemplProbQ_ = -99999.9;
1034 
1035 
1036  /*
1037  cout << endl;
1038  cout << "About to call SiStripTemplateSplit::StripTempSplit(...)" << endl;
1039 
1040  cout << endl;
1041  cout << "ID = " << ID << endl;
1042  cout << "cotalpha_ = " << cotalpha_ << endl;
1043  cout << "cotbeta_ = " << cotbeta_ << endl;
1044  cout << "locBy = " << locBy << endl;
1045  cout << "Amplitudes: ";
1046  for (int i=0; i<(int)vec_cluster_charge.size(); ++i)
1047  cout << vec_cluster_charge[i] << ", ";
1048  cout << endl;
1049  */
1050 
1051  int ierr =
1053  cotalpha_, cotbeta_,
1054  locBy,
1055  vec_cluster_charge,
1056  strip_templ_,
1057  stripTemplXrec1_,
1058  stripTemplXrec2_,
1059  stripTemplSigmaX_,
1060  stripTemplProbX_,
1061  stripTemplQbin_,
1062  stripTemplProbQ_ );
1063 
1064 
1065 
1066  stripTemplXrec1_ += 2*strip_templ_.xsize();
1067  stripTemplXrec2_ += 2*strip_templ_.xsize();
1068 
1069 
1070 
1071  if ( ierr != 0 )
1072  {
1073  //cout << endl;
1074  //cout << "Strip cluster splitting failed: ierr = " << ierr << endl;
1075  }
1076  else // if ( ierr != 0 )
1077  {
1078  // Cluster was successfully split.
1079  // Make the two split clusters and put them in the split cluster collection
1080 
1081  //cout << endl;
1082  //cout << "Cluster was successfully split" << endl;
1083 
1084  cluster_was_successfully_split = true;
1085 
1086  std::vector<float> strip_cluster1;
1087  std::vector<float> strip_cluster2;
1088 
1089  strip_cluster1.clear();
1090  strip_cluster2.clear();
1091 
1092  // gavril : Is this OK ?!?!?!?!
1093  for (int i=0; i<BXSIZE; ++i)
1094  {
1095  strip_cluster1.push_back(0.0);
1096  strip_cluster2.push_back(0.0);
1097  }
1098 
1099  //cout << endl;
1100  //cout << "About to call interpolate and sxtemp" << endl;
1101 
1102  strip_templ_.interpolate(ID, cotalpha_, cotbeta_, locBy);
1103  strip_templ_.sxtemp(stripTemplXrec1_, strip_cluster1);
1104  strip_templ_.sxtemp(stripTemplXrec2_, strip_cluster2);
1105 
1106 
1107 
1108  vector<SiStripDigi> vecSiStripDigi1;
1109  vecSiStripDigi1.clear();
1110  int strip_cluster1_size = (int)strip_cluster1.size();
1111  for (int i=2; i<strip_cluster1_size; ++i)
1112  {
1113  if ( strip_cluster1[i] > 0.0 )
1114  {
1115  SiStripDigi current_digi1( first_strip + i-2, strip_cluster1[i] );
1116 
1117  vecSiStripDigi1.push_back( current_digi1 );
1118  }
1119  }
1120 
1121 
1122 
1123  vector<SiStripDigi> vecSiStripDigi2;
1124  vecSiStripDigi2.clear();
1125  int strip_cluster2_size = (int)strip_cluster2.size();
1126  for (int i=2; i<strip_cluster2_size; ++i)
1127  {
1128  if ( strip_cluster2[i] > 0.0 )
1129  {
1130  SiStripDigi current_digi2( first_strip + i-2, strip_cluster2[i] );
1131 
1132  vecSiStripDigi2.push_back( current_digi2 );
1133  }
1134  }
1135 
1136 
1137 
1138 
1139  std::vector<SiStripDigi>::const_iterator SiStripDigiIterBegin1 = vecSiStripDigi1.begin();
1140  std::vector<SiStripDigi>::const_iterator SiStripDigiIterEnd1 = vecSiStripDigi1.end();
1141  std::pair<std::vector<SiStripDigi>::const_iterator,
1142  std::vector<SiStripDigi>::const_iterator> SiStripDigiRange1
1143  = make_pair(SiStripDigiIterBegin1, SiStripDigiIterEnd1);
1144 
1145  //if ( SiStripDigiIterBegin1 == SiStripDigiIterEnd1 )
1146  //{
1147  // throw cms::Exception("TrackClusterSplitter : ")
1148  //<< "\nERROR: SiStripDigiIterBegin1 = SiStripDigiIterEnd1 !!!" << "\n\n";
1149  //}
1150 
1151  std::vector<SiStripDigi>::const_iterator SiStripDigiIterBegin2 = vecSiStripDigi2.begin();
1152  std::vector<SiStripDigi>::const_iterator SiStripDigiIterEnd2 = vecSiStripDigi2.end();
1153  std::pair<std::vector<SiStripDigi>::const_iterator,
1154  std::vector<SiStripDigi>::const_iterator> SiStripDigiRange2
1155  = make_pair(SiStripDigiIterBegin2, SiStripDigiIterEnd2);
1156 
1157  // Sanity check...
1158  //if ( SiStripDigiIterBegin2 == SiStripDigiIterEnd2 )
1159  //{
1160  // cout << endl;
1161  // cout << "SiStripDigiIterBegin2 = SiStripDigiIterEnd2 !!!!!!!!!!!!!!!" << endl;
1162  //}
1163 
1164 
1165  // Save the split clusters
1166 
1167  if ( SiStripDigiIterBegin1 != SiStripDigiIterEnd1 )
1168  {
1169  // gavril : Raw id ?
1170  SiStripCluster cl1( SiStripDigiRange1 );
1171 
1172  cl1.setSplitClusterError( stripTemplSigmaX_ );
1173 
1174  output.push_back( cl1 );
1175 
1176  if ( (int)cl1.amplitudes().size() <= 0 )
1177  {
1178  throw cms::Exception("TrackClusterSplitter : ")
1179  << "\nERROR: (1) Wrong split cluster of size = " << (int)cl1.amplitudes().size() << "\n\n";
1180  }
1181 
1182  } // if ( SiStripDigiIterBegin1 != SiStripDigiIterEnd1 )
1183 
1184  if ( SiStripDigiIterBegin2 != SiStripDigiIterEnd2 )
1185  {
1186  // gavril : Raw id ?
1187  SiStripCluster cl2( SiStripDigiRange2 );
1188  cl2.setSplitClusterError( stripTemplSigmaX_ );
1189  output.push_back( cl2 );
1190 
1191  if ( (int)cl2.amplitudes().size() <= 0 )
1192  {
1193  throw cms::Exception("TrackClusterSplitter : ")
1194  << "\nERROR: (2) Wrong split cluster of size = " << (int)cl2.amplitudes().size() << "\n\n";
1195  }
1196 
1197  } // if ( SiStripDigiIterBegin2 != SiStripDigiIterEnd2 )
1198 
1199 
1200 
1201  } // else // if ( ierr != 0 )
1202 
1203  } // else // if ( strip_templQbin_ != 0 ) {...} else
1204 
1205  } // else // if ( strip_templQbin_ < 0 || strip_templQbin_ > 5 ) {...} else
1206 
1207  } // else // if ( (int)theStripCluster->amplitudes().size() <= 1 )
1208 
1209 
1210  if ( !cluster_was_successfully_split )
1211  output.push_back( *c.cluster );
1212 
1213  } // if ( theStripCluster )
1214  else
1215  {
1216  throw cms::Exception("TrackClusterSplitter : ")
1217  << "\nERROR: This is not a SiStripCluster !!!" << "\n\n";
1218  }
1219 
1220  } // else if ( strip_tmpSplit_ )
1221  else
1222  {
1223  // gavril : Neither sim nor template splitter. Just add the cluster as it was.
1224  output.push_back( *c.cluster );
1225  }
1226 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
int i
Definition: DBlmapReader.cc:9
void push_back(data_type const &d)
#define BXSIZE
const LocalTrajectoryParameters & localParameters() const
uint32_t ID
Definition: Definitions.h:26
T y() const
Definition: PV3DBase.h:63
uint16_t firstStrip() const
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
edm::ESHandle< MagneticField > magfield_
T mag() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:584
T z() const
Definition: PV3DBase.h:64
int j
Definition: DBlmapReader.cc:9
edm::ESHandle< GlobalTrackingGeometry > geometry_
float barycenter() const
#define end
Definition: vmac.h:37
LocalVector momentum() const
Momentum vector in the local frame.
T min(T a, T b)
Definition: MathUtil.h:58
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
std::vector< SiStripTemplateStore > theStripTemp_
int StripTempSplit(int id, float cotalpha, float cotbeta, float locBy, int speed, std::vector< float > &cluster, SiStripTemplate &templ, float &xrec1, float &xrec2, float &sigmax, float &prob2x, int &q2bin, float &prob2Q)
collection_type data
Definition: DetSet.h:78
#define begin
Definition: vmac.h:30
virtual LocalPoint localPosition(float strip) const =0
std::unique_ptr< TrackerHitAssociator > hitAssociator
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
tuple size
Write out results.
const std::vector< uint8_t > & amplitudes() const
template<>
void TrackClusterSplitter::splitCluster ( const SiPixelClusterWithTracks c,
const GlobalVector vtx,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output,
DetId  detId 
) const
private

Definition at line 1229 of file TrackClusterSplitter.cc.

References SiPixelCluster::add(), BXM2, BYM2, EnergyCorrector::c, PixelDigi::channelToPixel(), SiPixelCluster::charge(), GetRecoTauVFromDQM_MC_cff::cl2, edm::DetSet< T >::data, Exception, geometry_, i, PixelTopology::isItBigPixelInX(), PixelTopology::isItBigPixelInY(), j, TrajectoryStateOnSurface::localParameters(), Topology::localPosition(), PV3DBase< T, PVType, FrameType >::mag(), SiPixelCluster::minPixelCol(), SiPixelCluster::minPixelRow(), LocalTrajectoryParameters::momentum(), convertSQLitetoXML_cfg::output, PixelSubdetector::PixelBarrel, pixeldigisimlink, PixelSubdetector::PixelEndcap, SiPixelCluster::pixels(), SiPixelTemplateSplit::PixelTempSplit(), reco::TrackBase::pt(), SiPixelTemplate::qbin(), SiPixelTemplate::s50(), SiPixelCluster::setSplitClusterErrorX(), SiPixelCluster::setSplitClusterErrorY(), SiPixelTemplate::simpletemplate2D(), simSplitPixel_, SiPixelCluster::size(), findQualityFiles::size, PixelGeomDetUnit::specificTopology(), mathSSE::sqrt(), GeomDet::surface(), thePixelTemp2D_, thePixelTemp_, tmpSplitPixel_, Surface::toGlobal(), TXSIZE, TYSIZE, useStraightTracks_, PV3DBase< T, PVType, FrameType >::x(), SiPixelCluster::x(), xsize, SiPixelTemplate::xsize(), SiPixelTemplate2D::xytemp(), PV3DBase< T, PVType, FrameType >::y(), SiPixelCluster::y(), ysize, SiPixelTemplate::ysize(), and PV3DBase< T, PVType, FrameType >::z().

1234 {
1235  // The sim splitter:
1236  if ( simSplitPixel_ )
1237  {
1238  // cout << "Cluster splitting using simhits " << endl;
1239 
1240  int minPixelRow = (*c.cluster).minPixelRow();
1241  int maxPixelRow = (*c.cluster).maxPixelRow();
1242  int minPixelCol = (*c.cluster).minPixelCol();
1243  int maxPixelCol = (*c.cluster).maxPixelCol();
1244  int dsl = 0; // number of digisimlinks
1245 
1247  if (isearch != pixeldigisimlink->end()){
1248  edm::DetSet<PixelDigiSimLink> digiLink = (*isearch);
1249 
1250  edm::DetSet<PixelDigiSimLink>::const_iterator linkiter = digiLink.data.begin();
1251  //create a vector for the track ids in the digisimlinks
1252  std::vector<int> simTrackIdV;
1253  simTrackIdV.clear();
1254  //create a vector for the new splittedClusters
1255  std::vector<SiPixelCluster> splittedCluster;
1256  splittedCluster.clear();
1257 
1258  for ( ; linkiter != digiLink.data.end(); linkiter++)
1259  { // loop over all digisimlinks
1260  dsl++;
1261  std::pair<int,int> pixel_coord = PixelDigi::channelToPixel(linkiter->channel());
1262 
1263  // is the digisimlink inside the cluster boundaries?
1264  if ( pixel_coord.first <= maxPixelRow &&
1265  pixel_coord.first >= minPixelRow &&
1266  pixel_coord.second <= maxPixelCol &&
1267  pixel_coord.second >= minPixelCol )
1268  {
1269  bool inStock(false); // did we see this simTrackId before?
1270 
1271  SiPixelCluster::PixelPos newPixelPos(pixel_coord.first, pixel_coord.second); // coordinates to the pixel
1272 
1273  //loop over the pixels from the cluster to get the charge in this pixel
1274  int newPixelCharge(0); //fraction times charge in the original cluster pixel
1275 
1276  const std::vector<SiPixelCluster::Pixel>& pixvector = (*c.cluster).pixels();
1277 
1278  for(std::vector<SiPixelCluster::Pixel>::const_iterator itPix = pixvector.begin(); itPix != pixvector.end(); itPix++)
1279  {
1280  if (((int) itPix->x) == ((int) pixel_coord.first)&&(((int) itPix->y) == ((int) pixel_coord.second)))
1281  {
1282  newPixelCharge = (int) (linkiter->fraction()*itPix->adc);
1283  }
1284  }
1285 
1286  if ( newPixelCharge < 2500 )
1287  continue;
1288 
1289  //add the pixel to an already existing cluster if the charge is above the threshold
1290  int clusVecPos = 0;
1291  std::vector<int>::const_iterator sTIter = simTrackIdV.begin();
1292 
1293  for ( ; sTIter < simTrackIdV.end(); sTIter++)
1294  {
1295  if (((*sTIter)== (int) linkiter->SimTrackId()))
1296  {
1297  inStock=true; // now we saw this id before
1298  // // std::cout << " adding a pixel to the cluster " << (int) (clusVecPos) <<std::endl;
1299  // // std::cout << "newPixelCharge " << newPixelCharge << std::endl;
1300  splittedCluster.at(clusVecPos).add(newPixelPos,newPixelCharge); // add the pixel to the cluster
1301  }
1302  clusVecPos++;
1303  }
1304 
1305  //look if the splitted cluster was already made before, if not create one
1306 
1307  if ( !inStock )
1308  {
1309  // std::cout << "creating a new cluster " << std::endl;
1310  simTrackIdV.push_back(linkiter->SimTrackId()); // add the track id to the vector
1311  splittedCluster.push_back(SiPixelCluster(newPixelPos,newPixelCharge)); // add the cluster to the vector
1312  }
1313  }
1314  }
1315 
1316  // std::cout << "will add clusters : simTrackIdV.size() " << simTrackIdV.size() << std::endl;
1317 
1318  if ( ( ( (int)simTrackIdV.size() ) == 1 ) || ( *c.cluster).size()==1 )
1319  {
1320  // cout << "putting in this cluster" << endl;
1321  output.push_back(*c.cluster );
1322  // std::cout << "cluster added " << output.size() << std::endl;
1323  }
1324  else
1325  {
1326  for (std::vector<SiPixelCluster>::const_iterator cIter = splittedCluster.begin(); cIter != splittedCluster.end(); cIter++ )
1327  {
1328  output.push_back( (*cIter) );
1329  }
1330  }
1331 
1332  simTrackIdV.clear();
1333  splittedCluster.clear();
1334  }//if (isearch != pixeldigisimlink->end())
1335  }
1336  else if ( tmpSplitPixel_ )
1337  {
1338  bool cluster_was_successfully_split = false;
1339 
1340  const SiPixelCluster* thePixelCluster = static_cast<const SiPixelCluster*>(c.cluster);
1341 
1342  if ( thePixelCluster )
1343  {
1344  // Do not attempt to split clusters of size one
1345  if ( (int)thePixelCluster->size() <= 1 )
1346  {
1347  // Do nothing.
1348  //cout << "Will not attempt to split this clusters: " << endl;
1349  //cout << "(int)thePixelCluster->size() = " << (int)thePixelCluster->size() << endl;
1350  }
1351  else
1352  {
1353  // For barrel use template id 40 and for endcaps use template id 41
1354  int ID = -99999;
1355  if ( (int)detId.subdetId() == (int)PixelSubdetector::PixelBarrel )
1356  {
1357  // cout << "We are in the barrel : " << (int)PixelSubdetector::PixelBarrel << endl;
1358  ID = 40;
1359  }
1360  else if ( (int)detId.subdetId() == (int)PixelSubdetector::PixelEndcap )
1361  {
1362  // cout << "We are in the endcap : " << (int)PixelSubdetector::PixelEndcap << endl;
1363  ID = 41;
1364  }
1365  else
1366  {
1367  // cout << "Not a pixel detector !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " << endl;
1368  }
1369 
1370 
1371  // Begin: determine incident angles ============================================================
1372 
1373  float cotalpha_ = -99999.9;
1374  float cotbeta_ = -99999.9;
1375 
1376  // First, determine track angles from straight track approximation
1377 
1378  // Find crude cluster center.
1379  float xcenter = thePixelCluster->x();
1380  float ycenter = thePixelCluster->y();
1381 
1382  const GeomDetUnit* theDet = geometry_->idToDetUnit( detId );
1383  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>( theDet );
1384 
1385  const PixelTopology* theTopol = (&(pixDet->specificTopology()));
1386 
1387  // Transform from measurement to local coordinates (in cm)
1388  LocalPoint lp = theTopol->localPosition( MeasurementPoint(xcenter, ycenter) );
1389 
1390  // Transform from local to global coordinates
1391  GlobalPoint gp0 = theDet->surface().toGlobal( lp );
1392 
1393  // Make a vector pointing from the PV to the cluster center
1394  GlobalPoint gp(gp0.x()-vtx.x(), gp0.y()-vtx.y(), gp0.z()-vtx.z() );
1395 
1396  // Make gp a unit vector, gv, pointing from the PV to the cluster center
1397  float gp_mod = sqrt( gp.x()*gp.x() + gp.y()*gp.y() + gp.z()*gp.z() );
1398  float gpx = gp.x()/gp_mod;
1399  float gpy = gp.y()/gp_mod;
1400  float gpz = gp.z()/gp_mod;
1401  GlobalVector gv(gpx, gpy, gpz);
1402 
1403  // Make unit vectors in local coordinates and then transform them in global coordinates
1404  const Local3DVector lvx(1.0, 0.0, 0.0);
1405  GlobalVector gvx = theDet->surface().toGlobal( lvx );
1406  const Local3DVector lvy(0.0, 1.0, 0.0);
1407  GlobalVector gvy = theDet->surface().toGlobal( lvy );
1408  const Local3DVector lvz(0.0, 0.0, 1.0);
1409  GlobalVector gvz = theDet->surface().toGlobal( lvz );
1410 
1411  // Calculate angles alpha and beta
1412  float gv_dot_gvx = gv.x()*gvx.x() + gv.y()*gvx.y() + gv.z()*gvx.z();
1413  float gv_dot_gvy = gv.x()*gvy.x() + gv.y()*gvy.y() + gv.z()*gvy.z();
1414  float gv_dot_gvz = gv.x()*gvz.x() + gv.y()*gvz.y() + gv.z()*gvz.z();
1415 
1416  //float alpha_ = atan2( gv_dot_gvz, gv_dot_gvx );
1417  //float beta_ = atan2( gv_dot_gvz, gv_dot_gvy );
1418 
1419  cotalpha_ = gv_dot_gvx / gv_dot_gvz;
1420  cotbeta_ = gv_dot_gvy / gv_dot_gvz;
1421 
1422 
1423 
1424 
1425  // Attempt to get a better angle from tracks (either pixel tracks or full tracks)
1426  if ( !useStraightTracks_ )
1427  {
1428  // Use either pixel tracks (useTrajectories_ = False) or fully reconstructed tracks (useTrajectories_ = True)
1429  // When pixel/full tracks are not associated with the current cluster, will use angles from straight tracks
1430 
1431  // These are the tracks associated with this cluster
1432  std::vector<TrackAndState> vec_tracks_states = c.tracks;
1433 
1434 
1435 
1436  if ( (int)vec_tracks_states.size() > 0 )
1437  {
1438  //cout << "There is at least one track associated with this cluster. Pick the one with largest Pt." << endl;
1439  //cout << "(int)vec_tracks_states.size() = " << (int)vec_tracks_states.size() << endl;
1440 
1441  int index_max_pt = -99999; // index of the track with the highest Pt
1442  float max_pt = -99999.9;
1443 
1444  for (int i=0; i<(int)vec_tracks_states.size(); ++i )
1445  {
1446  const reco::Track* one_track = vec_tracks_states[i].track;
1447 
1448  if ( one_track->pt() > max_pt )
1449  {
1450  index_max_pt = i;
1451  max_pt = one_track->pt();
1452  }
1453  }
1454 
1455  // Pick the tsos from the track with highest Pt
1456  // gavril: Should we use highest Pt or best Chi2 ?
1457  TrajectoryStateOnSurface one_tsos = vec_tracks_states[index_max_pt].state;
1458 
1459  LocalTrajectoryParameters ltp = one_tsos.localParameters();
1460 
1461  LocalVector localDir = ltp.momentum()/ltp.momentum().mag();
1462 
1463  float locx = localDir.x();
1464  float locy = localDir.y();
1465  float locz = localDir.z();
1466 
1467  //alpha_ = atan2( locz, locx );
1468  //beta_ = atan2( locz, locy );
1469 
1470  cotalpha_ = locx/locz;
1471  cotbeta_ = locy/locz;
1472 
1473 
1474 
1475  } // if ( (int)vec_tracks_states.size() > 0 )
1476 
1477  } // if ( !useStraightTracks_ )
1478 
1479  // End: determine incident angles ============================================================
1480 
1481 
1482 
1483  //cout << "Calling qbin to see if the cluster has to be split..." << endl;
1486  int templQbin_ = templ_.qbin( ID, cotalpha_, cotbeta_, thePixelCluster->charge() );
1487 
1488  if ( templQbin_ < 0 || templQbin_ > 5 )
1489  {
1490  // gavril : check this....
1491  // cout << "Template call failed. Cannot decide if cluster should be split !!!!!!! " << endl;
1492  // cout << "Do nothing." << endl;
1493  }
1494  else // if ( templQbin_ < 0 || templQbin_ > 5 ) {...} else
1495  {
1496  //cout << " Returned OK from PixelTempReco2D..." << endl;
1497 
1498  // Check for split clusters: we split the clusters with larger than expected charge: templQbin_ == 0
1499  if ( templQbin_ != 0 )
1500  {
1501  // gavril: do not split this cluster
1502  //cout << "TEMPLATE SPLITTER SAYS : NO SPLIT " << endl;
1503  //cout << "This cluster will note be split !!!!!!!!!! " << endl;
1504  }
1505  else // if ( templQbin_ != 0 ) {...} else
1506  {
1507  //cout << "TEMPLATE SPLITTER SAYS : SPLIT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
1508  //cout << "Found a cluster that has to be split. templQbin_ = " << templQbin_ << endl;
1509 
1510  // gavril: Call the template splitter
1511  //cout << "Calling the splitter..." << endl;
1512 
1513  // Put the pixels of this clusters in a 2x2 array to be used by the template splitter
1514 
1515  const std::vector<SiPixelCluster::Pixel> & pixVec = thePixelCluster->pixels();
1516  std::vector<SiPixelCluster::Pixel>::const_iterator pixIter = pixVec.begin(), pixEnd = pixVec.end();
1517 
1518  const int cluster_matrix_size_x = 13;
1519  const int cluster_matrix_size_y = 21;
1520 
1521  boost::multi_array<float, 2> clust_array_2d(boost::extents[cluster_matrix_size_x][cluster_matrix_size_y]);
1522 
1523  int row_offset = thePixelCluster->minPixelRow();
1524  int col_offset = thePixelCluster->minPixelCol();
1525 
1526  // Copy clust's pixels (calibrated in electrons) into clust_array_2d;
1527 
1528  for ( ; pixIter != pixEnd; ++pixIter )
1529  {
1530  int irow = int(pixIter->x) - row_offset; // do we need +0.5 ???
1531  int icol = int(pixIter->y) - col_offset; // do we need +0.5 ???
1532 
1533  if ( irow<cluster_matrix_size_x && icol<cluster_matrix_size_y )
1534  {
1535  clust_array_2d[irow][icol] = (float)pixIter->adc;
1536  }
1537  }
1538 
1539  // Make and fill the bool arrays flagging double pixels
1540  std::vector<bool> ydouble(cluster_matrix_size_y), xdouble(cluster_matrix_size_x);
1541 
1542  // x directions (shorter), rows
1543  for (int irow = 0; irow < cluster_matrix_size_x; ++irow)
1544  {
1545  xdouble[irow] = theTopol->isItBigPixelInX( irow+row_offset );
1546  }
1547 
1548  // y directions (longer), columns
1549  for (int icol = 0; icol < cluster_matrix_size_y; ++icol)
1550  {
1551  ydouble[icol] = theTopol->isItBigPixelInY( icol+col_offset );
1552  }
1553 
1554  // gavril: Initialize values coming back from SiPixelTemplateSplit::PixelTempSplit
1555  float templYrec1_ = -99999.9;
1556  float templYrec2_ = -99999.9;
1557  float templSigmaY_ = -99999.9;
1558  float templProbY_ = -99999.9;
1559  float templXrec1_ = -99999.9;
1560  float templXrec2_ = -99999.9;
1561  float templSigmaX_ = -99999.9;
1562  float templProbX_ = -99999.9;
1563  float dchisq = -99999.9;
1564  float templProbQ_ = -99999.9;
1565 
1566  int ierr =
1568  cotalpha_, cotbeta_,
1569  clust_array_2d,
1570  ydouble, xdouble,
1571  templ_,
1572  templYrec1_, templYrec2_, templSigmaY_, templProbY_,
1573  templXrec1_, templXrec2_, templSigmaX_, templProbX_,
1574  templQbin_,
1575  templProbQ_,
1576  true,
1577  dchisq,
1578  templ2D_ );
1579 
1580  if ( ierr != 0 )
1581  {
1582  // cout << "Cluster splitting failed: ierr = " << ierr << endl;
1583  }
1584  else
1585  {
1586  // gavril: Cluster was successfully split.
1587  // gavril: Make the two split clusters and put them in the split cluster collection
1588  //cout << "Cluster splitting OK: ierr = " << ierr << endl;
1589 
1590  // 2D templates have origin at the lower left corner of template2d[1][1] which is
1591  // also 2 pixels larger than the cluster container
1592 
1593  float xsize = templ_.xsize(); // this is the pixel x-size in microns
1594  float ysize = templ_.ysize(); // this is the pixel y-size in microns
1595 
1596  // Shift the coordinates to the 2-D template system
1597  float yrecp1 = -99999.9;
1598  float yrecp2 = -99999.9;
1599  float xrecp1 = -99999.9;
1600  float xrecp2 = -99999.9;
1601 
1602  if ( ydouble[0] )
1603  {
1604  yrecp1 = templYrec1_ + ysize;
1605  yrecp2 = templYrec2_ + ysize;
1606  }
1607  else
1608  {
1609  yrecp1 = templYrec1_ + ysize/2.0;
1610  yrecp2 = templYrec2_ + ysize/2.0;
1611  }
1612 
1613  if ( xdouble[0] )
1614  {
1615  xrecp1 = templXrec1_ + xsize;
1616  xrecp2 = templXrec2_ + xsize;
1617  }
1618  else
1619  {
1620  xrecp1 = templXrec1_ + xsize/2.0;
1621  xrecp2 = templXrec2_ + xsize/2.0;
1622  }
1623 
1624  // The xytemp method adds charge to a zeroed buffer
1625 
1626  float template2d1[BXM2][BYM2];
1627  float template2d2[BXM2][BYM2];
1628 
1629  for ( int j=0; j<BXM2; ++j )
1630  {
1631  for ( int i=0; i<BYM2; ++i )
1632  {
1633  template2d1[j][i] = 0.0;
1634  template2d2[j][i] = 0.0;
1635  }
1636  }
1637 
1638 
1639  bool template_OK
1640  = templ2D_.xytemp(ID, cotalpha_, cotbeta_,
1641  xrecp1, yrecp1,
1642  ydouble, xdouble,
1643  template2d1);
1644 
1645  template_OK
1646  = template_OK &&
1647  templ2D_.xytemp(ID, cotalpha_, cotbeta_,
1648  xrecp2, yrecp2,
1649  ydouble, xdouble,
1650  template2d2);
1651 
1652  if ( !template_OK )
1653  {
1654  // gavril: check this
1655  //cout << "Template is not OK. Fill out with zeros !!!!!!!!!!!!!!! " << endl;
1656 
1657  for ( int j=0; j<BXM2; ++j )
1658  {
1659  for ( int i=0; i<BYM2; ++i )
1660  {
1661  template2d1[j][i] = 0.0;
1662  template2d2[j][i] = 0.0;
1663  }
1664  }
1665 
1666  if ( !templ_.simpletemplate2D(xrecp1, yrecp1,
1667  xdouble, ydouble,
1668  template2d1) )
1669  {
1670  cluster_was_successfully_split = false;
1671  }
1672 
1673  if ( !templ_.simpletemplate2D(xrecp2, yrecp2,
1674  xdouble, ydouble,
1675  template2d2) )
1676  {
1677  cluster_was_successfully_split = false;
1678  }
1679 
1680  } // if ( !template_OK )
1681  else
1682  {
1683  cluster_was_successfully_split = true;
1684 
1685  // Next, copy the 2-d templates into cluster containers, replace small signals with zero.
1686  // Cluster 1 and cluster 2 should line up with clust_array_2d (same origin and pixel indexing)
1687 
1688  float q50 = templ_.s50();
1689 
1690 
1691  float cluster1[TXSIZE][TYSIZE];
1692  float cluster2[TXSIZE][TYSIZE]; //Note that TXSIZE = BXM2 - 2, TYSIZE = BYM2 - 2
1693 
1694  for ( int j=0; j<TXSIZE; ++j )
1695  {
1696  for ( int i=0; i<TYSIZE; ++i )
1697  {
1698  cluster1[j][i] = template2d1[j+1][i+1];
1699 
1700  if ( cluster1[j][i] < q50 )
1701  cluster1[j][i] = 0.0;
1702 
1703  cluster2[j][i] = template2d2[j+1][i+1];
1704 
1705  if ( cluster2[j][i] < q50 )
1706  cluster2[j][i] = 0.0;
1707 
1708  //cout << "cluster1[j][i] = " << cluster1[j][i] << endl;
1709  //cout << "cluster2[j][i] = " << cluster2[j][i] << endl;
1710  }
1711  }
1712 
1713 
1714  // Find the coordinates of first pixel in each of the two split clusters
1715  int i1 = -999;
1716  int j1 = -999;
1717  int i2 = -999;
1718  int j2 = -999;
1719 
1720  bool done_searching = false;
1721  for ( int i=0; i<13 && !done_searching; ++i)
1722  {
1723  for (int j=0; j<21 && !done_searching; ++j)
1724  {
1725  if ( cluster1[i][j] > 0 )
1726  {
1727  i1 = i;
1728  j1 = j;
1729  done_searching = true;
1730  }
1731  }
1732  }
1733 
1734  done_searching = false;
1735  for ( int i=0; i<13 && !done_searching; ++i)
1736  {
1737  for (int j=0; j<21 && !done_searching; ++j)
1738  {
1739  if ( cluster2[i][j] > 0 )
1740  {
1741  i2 = i;
1742  j2 = j;
1743  done_searching = true;
1744  }
1745  }
1746  }
1747 
1748 
1749  // Make clusters out of the first pixels in each of the two split clsuters
1750 
1751  SiPixelCluster cl1( SiPixelCluster::PixelPos( i1 + row_offset, j1 + col_offset),
1752  cluster1[i1][j1] );
1753 
1754  SiPixelCluster cl2( SiPixelCluster::PixelPos( i2 + row_offset, j2 + col_offset),
1755  cluster2[i2][j2] );
1756 
1757 
1758  // Now add the rest of the pixels to the split clusters
1759 
1760  for ( int i=0; i<13; ++i)
1761  {
1762  for (int j=0; j<21; ++j)
1763  {
1764 
1765  if ( cluster1[i][j] > 0.0 && (i!=i1 || j!=j1 ) )
1766  {
1767  cl1.add( SiPixelCluster::PixelPos( i + row_offset, j + col_offset),
1768  cluster1[i][j] );
1769 
1770  //cout << "cluster1[i][j] = " << cluster1[i][j] << endl;
1771  }
1772 
1773 
1774  if ( cluster2[i][j] > 0.0 && (i!=i2 || j!=j2 ) )
1775  {
1776  cl2.add( SiPixelCluster::PixelPos( i + row_offset, j + col_offset),
1777  cluster2[i][j] );
1778 
1779  //cout << "cluster2[i][j] = " << cluster2[i][j] << endl;
1780  }
1781  }
1782  }
1783 
1784  // Attach errors and probabilities to the split Clusters
1785  // The errors will be later attahed to the SiPixelRecHit
1786 
1787 
1788  cl1.setSplitClusterErrorX( templSigmaX_ );
1789  cl1.setSplitClusterErrorY( templSigmaY_ );
1790  //cl1.prob_q = templProbQ_;
1791 
1792  cl2.setSplitClusterErrorX( templSigmaX_ );
1793  cl2.setSplitClusterErrorY( templSigmaY_ );
1794  //cl2.prob_q = templProbQ_;
1795 
1796 
1797  // Save the split clusters
1798  output.push_back( cl1 );
1799  output.push_back( cl2 );
1800 
1801  // Some sanity checks
1802 
1803  if ( (int)cl1.size() <= 0 )
1804  {
1805  edm::LogError("TrackClusterSplitter : ")
1806  << "1) Cluster of size = " << (int)cl1.size() << " !!! " << endl;
1807  }
1808 
1809  if ( (int)cl2.size() <= 0 )
1810  {
1811  edm::LogError("TrackClusterSplitter : ")
1812  << "2) Cluster of size = " << (int)cl2.size() << " !!! " << endl;
1813  }
1814 
1815  if ( cl1.charge() <= 0 )
1816  {
1817  edm::LogError("TrackClusterSplitter : ")
1818  << "1) Cluster of charge = " << (int)cl1.charge() << " !!! " << endl;
1819 
1820  }
1821 
1822  if ( cl2.charge() <= 0 )
1823  {
1824  edm::LogError("TrackClusterSplitter : ")
1825  << "2) Cluster of charge = " << (int)cl2.charge() << " !!!!!!!!!!!!!!!!!!!!!!!!!! " << endl;
1826  }
1827 
1828 
1829  } // if ( !template_OK ) ... else
1830 
1831  } // if ( ierr2 != 0 ) ... else
1832 
1833  } // if ( templQbin_ != 0 ) ... else
1834 
1835  } // else // if ( templQbin_ < 0 || templQbin_ > 5 ) {...} else
1836 
1837  } // if ( (int)thePixelCluster->size() <= 1 ) {... } else
1838 
1839  if ( !cluster_was_successfully_split )
1840  output.push_back(*c.cluster);
1841 
1842  } // if ( theSiPixelCluster )
1843  else
1844  {
1845  throw cms::Exception("TrackClusterSplitter :")
1846  << "This is not a SiPixelCluster !!! " << "\n";
1847  }
1848  }
1849  else
1850  {
1851  // gavril : Neither sim nor template splitter. Just add the cluster as it was.
1852  // original from G.P.
1853  output.push_back( *c.cluster );
1854  }
1855 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
int i
Definition: DBlmapReader.cc:9
float charge() const
void push_back(data_type const &d)
int minPixelCol() const
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
const LocalTrajectoryParameters & localParameters() const
#define TXSIZE
uint32_t ID
Definition: Definitions.h:26
T y() const
Definition: PV3DBase.h:63
std::vector< SiPixelTemplateStore > thePixelTemp_
const Int_t ysize
edm::Handle< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlink
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
#define BXM2
std::vector< SiPixelTemplateStore2D > thePixelTemp2D_
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
T mag() const
Definition: PV3DBase.h:67
int minPixelRow() const
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:584
T z() const
Definition: PV3DBase.h:64
int PixelTempSplit(int id, float cotalpha, float cotbeta, array_2d &cluster, std::vector< bool > &ydouble, std::vector< bool > &xdouble, SiPixelTemplate &templ, float &yrec1, float &yrec2, float &sigmay, float &prob2y, float &xrec1, float &xrec2, float &sigmax, float &prob2x, int &q2bin, float &prob2Q, bool resolve, int speed, float &dchisq, bool deadpix, std::vector< std::pair< int, int > > &zeropix, SiPixelTemplate2D &templ2D)
int j
Definition: DBlmapReader.cc:9
edm::ESHandle< GlobalTrackingGeometry > geometry_
#define BYM2
LocalVector momentum() const
Momentum vector in the local frame.
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
virtual bool isItBigPixelInX(const int ixbin) const =0
#define TYSIZE
static std::pair< int, int > channelToPixel(int ch)
Definition: PixelDigi.h:62
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
collection_type data
Definition: DetSet.h:78
Pixel cluster – collection of neighboring pixels above threshold.
float y() const
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
const Int_t xsize
T x() const
Definition: PV3DBase.h:62
tuple size
Write out results.
float x() const
const std::vector< Pixel > pixels() const
int size() const
virtual bool isItBigPixelInY(const int iybin) const =0
template<typename Cluster >
std::auto_ptr< edmNew::DetSetVector< Cluster > > TrackClusterSplitter::splitClusters ( const std::map< uint32_t, boost::sub_range< std::vector< ClusterWithTracks< Cluster > > > > &  input,
const reco::Vertex vtx 
) const
private

Definition at line 554 of file TrackClusterSplitter.cc.

References EnergyCorrector::c, geometry_, input, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, splitCluster(), reco::Vertex::x(), reco::Vertex::y(), and reco::Vertex::z().

Referenced by produce().

556 {
557  std::auto_ptr<edmNew::DetSetVector<Cluster> > output(new edmNew::DetSetVector<Cluster>());
558  typedef std::pair<uint32_t, boost::sub_range<std::vector<ClusterWithTracks<Cluster> > > > pair;
559 
560  foreach(const pair &p, input)
561  {
562  const GeomDet* det = geometry_->idToDet( DetId(p.first) );
563 
564  if ( det == 0 )
565  {
566  edm::LogError("MissingDetId") << "DetIDs " << p.first << " is not in geometry.\n";
567  continue;
568  }
569 
570  // gavril: Pass the PV instead of direction
571  // GlobalVector dir(det->position().x() - vtx.x(), det->position().y() - vtx.y(), det->position().z() - vtx.z());
572  GlobalVector primary_vtx( vtx.x(), vtx.y(), vtx.z() );
573 
574  // Create output collection
575  typename edmNew::DetSetVector<Cluster>::FastFiller detset(*output, p.first);
576 
577  // fill it
578  foreach(const ClusterWithTracks<Cluster> &c, p.second)
579  {
580  splitCluster(c, primary_vtx, detset, DetId(p.first) );
581  }
582  }
583 
584  return output;
585 }
double y() const
y coordinate
Definition: Vertex.h:110
static std::string const input
Definition: EdmProvDump.cc:43
double z() const
y coordinate
Definition: Vertex.h:112
edm::ESHandle< GlobalTrackingGeometry > geometry_
Definition: DetId.h:18
double x() const
x coordinate
Definition: Vertex.h:108
void splitCluster(const ClusterWithTracks< Cluster > &cluster, const GlobalVector &dir, typename edmNew::DetSetVector< Cluster >::FastFiller &output, DetId detId) const

Member Data Documentation

std::vector<SiPixelClusterWithTracks> TrackClusterSplitter::allSiPixelClusters
private

working data

Definition at line 206 of file TrackClusterSplitter.cc.

Referenced by produce().

std::vector<SiStripClusterWithTracks> TrackClusterSplitter::allSiStripClusters
private

Definition at line 209 of file TrackClusterSplitter.cc.

Referenced by produce().

edm::ESHandle<GlobalTrackingGeometry> TrackClusterSplitter::geometry_
private

Definition at line 109 of file TrackClusterSplitter.cc.

Referenced by produce(), splitCluster(), and splitClusters().

std::unique_ptr<TrackerHitAssociator> TrackClusterSplitter::hitAssociator
private

Definition at line 155 of file TrackClusterSplitter.cc.

Referenced by produce(), and splitCluster().

edm::ESHandle<MagneticField> TrackClusterSplitter::magfield_
private

Definition at line 107 of file TrackClusterSplitter.cc.

Referenced by produce(), and splitCluster().

edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > TrackClusterSplitter::pixelClusters_
private

Definition at line 73 of file TrackClusterSplitter.cc.

Referenced by produce(), and TrackClusterSplitter().

edm::Handle< edm::DetSetVector<PixelDigiSimLink> > TrackClusterSplitter::pixeldigisimlink
private

Definition at line 112 of file TrackClusterSplitter.cc.

Referenced by produce(), and splitCluster().

edm::EDGetTokenT< edm::DetSetVector<PixelDigiSimLink> > TrackClusterSplitter::pixeldigisimlinkToken
private

Definition at line 102 of file TrackClusterSplitter.cc.

Referenced by produce(), and TrackClusterSplitter().

edm::ESHandle<Propagator> TrackClusterSplitter::propagator_
private

Definition at line 108 of file TrackClusterSplitter.cc.

Referenced by produce().

std::string TrackClusterSplitter::propagatorName_
private

Definition at line 106 of file TrackClusterSplitter.cc.

Referenced by TrackClusterSplitter().

bool TrackClusterSplitter::simSplitPixel_
private

Definition at line 76 of file TrackClusterSplitter.cc.

Referenced by produce(), splitCluster(), and TrackClusterSplitter().

bool TrackClusterSplitter::simSplitStrip_
private

Definition at line 77 of file TrackClusterSplitter.cc.

Referenced by produce(), splitCluster(), and TrackClusterSplitter().

std::map<uint32_t, SiPixelClustersWithTracks> TrackClusterSplitter::siPixelDetsWithClusters
private

Definition at line 207 of file TrackClusterSplitter.cc.

Referenced by produce().

std::map<uint32_t, SiStripClustersWithTracks> TrackClusterSplitter::siStripDetsWithClusters
private

Definition at line 210 of file TrackClusterSplitter.cc.

Referenced by produce().

edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > TrackClusterSplitter::stripClusters_
private

Definition at line 74 of file TrackClusterSplitter.cc.

Referenced by produce(), and TrackClusterSplitter().

edm::Handle< edm::DetSetVector<StripDigiSimLink> > TrackClusterSplitter::stripdigisimlink
private

Definition at line 115 of file TrackClusterSplitter.cc.

Referenced by produce(), and splitCluster().

edm::EDGetTokenT< edm::DetSetVector<StripDigiSimLink> > TrackClusterSplitter::stripdigisimlinkToken
private

Definition at line 103 of file TrackClusterSplitter.cc.

Referenced by produce(), and TrackClusterSplitter().

std::vector< SiPixelTemplateStore2D > TrackClusterSplitter::thePixelTemp2D_
private

Definition at line 121 of file TrackClusterSplitter.cc.

Referenced by splitCluster(), and TrackClusterSplitter().

std::vector< SiPixelTemplateStore > TrackClusterSplitter::thePixelTemp_
private

Definition at line 120 of file TrackClusterSplitter.cc.

Referenced by splitCluster(), and TrackClusterSplitter().

std::vector< SiStripTemplateStore > TrackClusterSplitter::theStripTemp_
private

Definition at line 123 of file TrackClusterSplitter.cc.

Referenced by splitCluster(), and TrackClusterSplitter().

bool TrackClusterSplitter::tmpSplitPixel_
private

Definition at line 78 of file TrackClusterSplitter.cc.

Referenced by splitCluster(), and TrackClusterSplitter().

bool TrackClusterSplitter::tmpSplitStrip_
private

Definition at line 79 of file TrackClusterSplitter.cc.

Referenced by splitCluster(), and TrackClusterSplitter().

TrackerHitAssociator::Config TrackClusterSplitter::trackerHitAssociatorConfig_
private

Definition at line 154 of file TrackClusterSplitter.cc.

Referenced by produce().

edm::EDGetTokenT<std::vector<reco::Track> > TrackClusterSplitter::tracks_
private

Definition at line 97 of file TrackClusterSplitter.cc.

Referenced by produce(), and TrackClusterSplitter().

edm::EDGetTokenT<TrajTrackAssociationCollection > TrackClusterSplitter::trajTrackAssociations_
private

Definition at line 96 of file TrackClusterSplitter.cc.

Referenced by produce(), and TrackClusterSplitter().

bool TrackClusterSplitter::useStraightTracks_
private

Definition at line 87 of file TrackClusterSplitter.cc.

Referenced by splitCluster(), and TrackClusterSplitter().

bool TrackClusterSplitter::useTrajectories_
private

Definition at line 93 of file TrackClusterSplitter.cc.

Referenced by produce(), and TrackClusterSplitter().

edm::EDGetTokenT<std::vector<reco::Vertex> > TrackClusterSplitter::vertices_
private

Definition at line 100 of file TrackClusterSplitter.cc.

Referenced by produce(), and TrackClusterSplitter().