CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
24  :_conf(conf),seedCollection(0),
25  theClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet"), iC),
26  QuadCutPSet(conf.getParameter<edm::ParameterSet>("QuadCutPSet")),
27  theSilentOnClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet").getUntrackedParameter<bool>("silentClusterCheck",false)),
28  theHitsGenerator(new CombinedHitQuadrupletGeneratorForPhotonConversion(conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet"), iC)),
29  theSeedCreator(new SeedForPhotonConversionFromQuadruplets(conf.getParameter<edm::ParameterSet>("SeedCreatorPSet"),
30  iC,
31  conf.getParameter<edm::ParameterSet>("SeedComparitorPSet"))),
32  theRegionProducer(new GlobalTrackingRegionProducerFromBeamSpot(conf.getParameter<edm::ParameterSet>("RegionFactoryPSet"), iC)) {
33 
34  token_vertex = iC.consumes<reco::VertexCollection>(_conf.getParameter<edm::InputTag>("primaryVerticesTag"));
35 }
36 
38 }
39 
42 
43  myEsetup = &setup;
44  myEvent = &event;
45 
46  if(seedCollection!=0)
47  delete seedCollection;
48 
50 
51  size_t clustsOrZero = theClusterCheck.tooManyClusters(event);
52  if (clustsOrZero){
54  edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";
55  return ;
56  }
57 
58  // Why is the regions variable (and theRegionProducer) needed at all?
59  regions = theRegionProducer->regions(event,setup);
60 
61  event.getByToken(token_vertex, vertexHandle);
62  if (!vertexHandle.isValid()){
63  edm::LogError("PhotonConversionFinderFromTracks") << "Error! Can't get the product primary Vertex Collection "<< _conf.getParameter<edm::InputTag>("primaryVerticesTag") << "\n";
64  return;
65  }
66 
67  //Do the analysis
68  loop();
69 
70 #ifdef mydebug_knuenz
71  std::cout << "Running PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo" <<std::endl;
72 #endif
73 
74 #ifdef debugTSPFSLA
75  std::stringstream ss;
76  ss.str("");
77  ss << "\n++++++++++++++++++\n";
78  ss << "seed collection size " << seedCollection->size();
79  BOOST_FOREACH(TrajectorySeed tjS,*seedCollection){
80  po.print(ss, tjS);
81  }
82  edm::LogInfo("debugTrajSeedFromQuadruplets") << ss.str();
83  //-------------------------------------------------
84 #endif
85 }
86 
87 
89 loop(){
90 
91 
92  ss.str("");
93 
94  float ptMin=0.1;
95 
96  BOOST_FOREACH(const reco::Vertex primaryVertex, *vertexHandle){
97 
98  //FIXME currnetly using the first primaryVertex, should loop on the promaryVertexes
100  ,GlobalPoint(
101  primaryVertex.position().x(),
102  primaryVertex.position().y(),
103  primaryVertex.position().z()
104  )
105  ,primaryVertex.xError()*10
106  ,primaryVertex.zError()*10
107  ,true
108  );
109 
110 #ifdef debugTSPFSLA
111  ss << "[PrintRegion] " << region.print() << std::endl;
112 #endif
113 
114  inspect(region);
115 
116  }
117 #ifdef debugTSPFSLA
118  edm::LogInfo("debugTrajSeedFromQuadruplets") << ss.str();
119 #endif
120 }
121 
122 
125 
126  const OrderedSeedingHits & hitss = theHitsGenerator->run(region, *myEvent, *myEsetup);
127 
128  unsigned int nHitss = hitss.size();
129 
130 #ifdef debugTSPFSLA
131  ss << "\n nHitss " << nHitss << "\n";
132 #endif
133 
134  if (seedCollection->empty()) seedCollection->reserve(nHitss/2); // don't do multiple reserves in the case of multiple regions: it would make things even worse
135  // as it will cause N re-allocations instead of the normal log(N)/log(2)
136 
137  unsigned int iHits=0, jHits=1;
138 
139  //
140  // Trivial arbitration
141  //
142  // Vector to store old quad values
143  std::vector<Quad> quadVector;
144 
145 
146  for (; iHits < nHitss && jHits < nHitss; iHits+=2 , jHits+=2) {
147 
148 #ifdef debugTSPFSLA
149  // ss << "\n iHits " << iHits << " " << jHits << "\n";
150 #endif
151  //phits is the pair of hits for the positron
152  const SeedingHitSet & phits = hitss[iHits];
153  //mhits is the pair of hits for the electron
154  const SeedingHitSet & mhits = hitss[jHits];
155 
156 
157  try{
158  //FIXME (modify the interface of the seed generator if needed)
159  //passing the region, that is centered around the primary vertex
160  theSeedCreator->trajectorySeed(*seedCollection, phits, mhits, region, *myEvent, *myEsetup, ss, quadVector, QuadCutPSet);
161  }catch(cms::Exception& er){
162  edm::LogError("SeedingConversion") << " Problem in the Quad Seed creator " <<er.what()<<std::endl;
163  }catch(std::exception& er){
164  edm::LogError("SeedingConversion") << " Problem in the Quad Seed creator " <<er.what()<<std::endl;
165  }
166  }
167  quadVector.clear();
168  return true;
169 }
virtual char const * what() const
Definition: Exception.cc:141
T getParameter(std::string const &) const
double zError() const
error on z
Definition: Vertex.h:111
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
virtual unsigned int size() const =0
const Point & position() const
position
Definition: Vertex.h:99
std::unique_ptr< CombinedHitQuadrupletGeneratorForPhotonConversion > theHitsGenerator
std::vector< TrajectorySeed > TrajectorySeedCollection
size_t tooManyClusters(const edm::Event &e) const
PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
void print(std::stringstream &ss, const SiStripCluster &clus)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:75
double xError() const
error on x
Definition: Vertex.h:107
return(e1-e2)*(e1-e2)+dp *dp
tuple cout
Definition: gather_cfg.py:145
volatile std::atomic< bool > shutdown_flag false