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  regions = theRegionProducer->regions(event,setup);
59 
60  event.getByToken(token_vertex, vertexHandle);
61  if (!vertexHandle.isValid()){
62  edm::LogError("PhotonConversionFinderFromTracks") << "Error! Can't get the product primary Vertex Collection "<< _conf.getParameter<edm::InputTag>("primaryVerticesTag") << "\n";
63  return;
64  }
65 
66  //Do the analysis
67  loop();
68 
69 #ifdef mydebug_knuenz
70  std::cout << "Running PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo" <<std::endl;
71 #endif
72 
73 #ifdef debugTSPFSLA
74  std::stringstream ss;
75  ss.str("");
76  ss << "\n++++++++++++++++++\n";
77  ss << "seed collection size " << seedCollection->size();
78  BOOST_FOREACH(TrajectorySeed tjS,*seedCollection){
79  po.print(ss, tjS);
80  }
81  edm::LogInfo("debugTrajSeedFromQuadruplets") << ss.str();
82  //-------------------------------------------------
83 #endif
84 }
85 
86 
88 loop(){
89 
90 
91  ss.str("");
92 
93  float ptMin=0.1;
94 
95  BOOST_FOREACH(const reco::Vertex primaryVertex, *vertexHandle){
96 
97  //FIXME currnetly using the first primaryVertex, should loop on the promaryVertexes
99  ,GlobalPoint(
100  primaryVertex.position().x(),
101  primaryVertex.position().y(),
102  primaryVertex.position().z()
103  )
104  ,primaryVertex.xError()*10
105  ,primaryVertex.zError()*10
106  ,true
107  );
108 
109 #ifdef debugTSPFSLA
110  ss << "[PrintRegion] " << region.print() << std::endl;
111 #endif
112 
113  inspect(region);
114 
115  }
116 #ifdef debugTSPFSLA
117  edm::LogInfo("debugTrajSeedFromQuadruplets") << ss.str();
118 #endif
119 }
120 
121 
124 
125  const OrderedSeedingHits & hitss = theHitsGenerator->run(region, *myEvent, *myEsetup);
126 
127  unsigned int nHitss = hitss.size();
128 
129 #ifdef debugTSPFSLA
130  ss << "\n nHitss " << nHitss << "\n";
131 #endif
132 
133  if (seedCollection->empty()) seedCollection->reserve(nHitss/2); // don't do multiple reserves in the case of multiple regions: it would make things even worse
134  // as it will cause N re-allocations instead of the normal log(N)/log(2)
135 
136  unsigned int iHits=0, jHits=1;
137 
138  //
139  // Trivial arbitration
140  //
141  // Vector to store old quad values
142  std::vector<Quad> quadVector;
143 
144 
145  for (; iHits < nHitss && jHits < nHitss; iHits+=2 , jHits+=2) {
146 
147 #ifdef debugTSPFSLA
148  // ss << "\n iHits " << iHits << " " << jHits << "\n";
149 #endif
150  //phits is the pair of hits for the positron
151  const SeedingHitSet & phits = hitss[iHits];
152  //mhits is the pair of hits for the electron
153  const SeedingHitSet & mhits = hitss[jHits];
154 
155 
156  try{
157  //FIXME (modify the interface of the seed generator if needed)
158  //passing the region, that is centered around the primary vertex
159  theSeedCreator->trajectorySeed(*seedCollection, phits, mhits, region, *myEvent, *myEsetup, ss, quadVector, QuadCutPSet);
160  }catch(cms::Exception& er){
161  edm::LogError("SeedingConversion") << " Problem in the Quad Seed creator " <<er.what()<<std::endl;
162  }catch(std::exception& er){
163  edm::LogError("SeedingConversion") << " Problem in the Quad Seed creator " <<er.what()<<std::endl;
164  }
165  }
166  quadVector.clear();
167  return true;
168 }
virtual char const * what() const
Definition: Exception.cc:141
T getParameter(std::string const &) const
double zError() const
error on z
Definition: Vertex.h:118
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:106
std::unique_ptr< CombinedHitQuadrupletGeneratorForPhotonConversion > theHitsGenerator
return((rh^lh)&mask)
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
tuple conf
Definition: dbtoconf.py:185
double xError() const
error on x
Definition: Vertex.h:114
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")