CMS 3D CMS Logo

PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo.cc
Go to the documentation of this file.
2 #include "Quad.h"
4 // ClusterShapeIncludes:::
11 /*
12 To Do:
13 
14 assign the parameters to some data member to avoid search at every event
15 
16  */
17 
18 //#define debugTSPFSLA
19 //#define mydebug_knuenz
20 
22  const edm::ParameterSet& conf, edm::ConsumesCollector&& iC)
23  : _conf(conf),
24  seedCollection(nullptr),
25  theClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet"), iC),
26  QuadCutPSet(conf.getParameter<edm::ParameterSet>("QuadCutPSet")),
27  theSilentOnClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet")
28  .getUntrackedParameter<bool>("silentClusterCheck", false)),
30  conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet"), iC)),
31  theSeedCreator(
32  new SeedForPhotonConversionFromQuadruplets(conf.getParameter<edm::ParameterSet>("SeedCreatorPSet"),
33  iC,
34  conf.getParameter<edm::ParameterSet>("SeedComparitorPSet"))),
35  theRegionProducer(
36  new GlobalTrackingRegionProducerFromBeamSpot(conf.getParameter<edm::ParameterSet>("RegionFactoryPSet"), iC)) {
37  token_vertex = iC.consumes<reco::VertexCollection>(_conf.getParameter<edm::InputTag>("primaryVerticesTag"));
38 }
39 
41 }
42 
44  const edm::EventSetup& setup) {
45  myEsetup = &setup;
46  myEvent = &event;
47 
48  if (seedCollection != nullptr)
49  delete seedCollection;
50 
52 
53  size_t clustsOrZero = theClusterCheck.tooManyClusters(event);
54  if (clustsOrZero) {
56  edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";
57  return;
58  }
59 
60  // Why is the regions variable (and theRegionProducer) needed at all?
61  regions = theRegionProducer->regions(event, setup);
62 
63  event.getByToken(token_vertex, vertexHandle);
64  if (!vertexHandle.isValid()) {
65  edm::LogError("PhotonConversionFinderFromTracks")
66  << "Error! Can't get the product primary Vertex Collection "
67  << _conf.getParameter<edm::InputTag>("primaryVerticesTag") << "\n";
68  return;
69  }
70 
71  //Do the analysis
72  loop();
73 
74 #ifdef mydebug_knuenz
75  std::cout << "Running PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo" << std::endl;
76 #endif
77 
78 #ifdef debugTSPFSLA
79  std::stringstream ss;
80  ss.str("");
81  ss << "\n++++++++++++++++++\n";
82  ss << "seed collection size " << seedCollection->size();
83  for (auto const& tjS : *seedCollection) {
84  po.print(ss, tjS);
85  }
86  edm::LogInfo("debugTrajSeedFromQuadruplets") << ss.str();
87  //-------------------------------------------------
88 #endif
89 }
90 
92  ss.str("");
93 
94  float ptMin = 0.1;
95 
96  for (auto const& primaryVertex : *vertexHandle) {
97  //FIXME currnetly using the first primaryVertex, should loop on the promaryVertexes
99  ptMin,
101  primaryVertex.xError() * 10,
102  primaryVertex.zError() * 10,
103  true);
104 
105 #ifdef debugTSPFSLA
106  ss << "[PrintRegion] " << region.print() << std::endl;
107 #endif
108 
109  inspect(region);
110  }
111 #ifdef debugTSPFSLA
112  edm::LogInfo("debugTrajSeedFromQuadruplets") << ss.str();
113 #endif
114 }
115 
117  const OrderedSeedingHits& hitss = theHitsGenerator->run(region, *myEvent, *myEsetup);
118 
119  unsigned int nHitss = hitss.size();
120 
121 #ifdef debugTSPFSLA
122  ss << "\n nHitss " << nHitss << "\n";
123 #endif
124 
125  // don't do multiple reserves in the case of multiple regions: it would make things even worse
126  // as it will cause N re-allocations instead of the normal log(N)/log(2)
127  if (seedCollection->empty())
128  seedCollection->reserve(nHitss / 2);
129 
130  unsigned int iHits = 0, jHits = 1;
131 
132  //
133  // Trivial arbitration
134  //
135  // Vector to store old quad values
136  std::vector<Quad> quadVector;
137 
138  for (; iHits < nHitss && jHits < nHitss; iHits += 2, jHits += 2) {
139 #ifdef debugTSPFSLA
140  // ss << "\n iHits " << iHits << " " << jHits << "\n";
141 #endif
142  //phits is the pair of hits for the positron
143  const SeedingHitSet& phits = hitss[iHits];
144  //mhits is the pair of hits for the electron
145  const SeedingHitSet& mhits = hitss[jHits];
146 
147  try {
148  //FIXME (modify the interface of the seed generator if needed)
149  //passing the region, that is centered around the primary vertex
150  theSeedCreator->trajectorySeed(
151  *seedCollection, phits, mhits, region, *myEvent, *myEsetup, ss, quadVector, QuadCutPSet);
152  } catch (cms::Exception& er) {
153  edm::LogError("SeedingConversion") << " Problem in the Quad Seed creator " << er.what() << std::endl;
154  } catch (std::exception& er) {
155  edm::LogError("SeedingConversion") << " Problem in the Quad Seed creator " << er.what() << std::endl;
156  }
157  }
158  quadVector.clear();
159  return true;
160 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
size_t tooManyClusters(const edm::Event &e) const
const Point & position() const
position
Definition: Vertex.h:127
constexpr float ptMin
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
virtual unsigned int size() const =0
Log< level::Error, false > LogError
double zError() const
error on z
Definition: Vertex.h:141
double xError() const
error on x
Definition: Vertex.h:137
std::unique_ptr< CombinedHitQuadrupletGeneratorForPhotonConversion > theHitsGenerator
std::vector< TrajectorySeed > TrajectorySeedCollection
TupleMultiplicity< TrackerTraits > const *__restrict__ TrackingRecHitSoAConstView< TrackerTraits > TrackerTraits::tindex_type *__restrict__ double *__restrict__ phits
PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
void print(std::stringstream &ss, const SiStripCluster &clus)
Log< level::Info, false > LogInfo
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
char const * what() const noexcept override
Definition: Exception.cc:107
Definition: event.py:1