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.
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  hitsfactoryPSet(conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet")),
26  creatorPSet(conf.getParameter<edm::ParameterSet>("SeedCreatorPSet")),
27  regfactoryPSet(conf.getParameter<edm::ParameterSet>("RegionFactoryPSet")),
28  theClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet"), std::move(iC)),
29  SeedComparitorPSet(conf.getParameter<edm::ParameterSet>("SeedComparitorPSet")),
30  QuadCutPSet(conf.getParameter<edm::ParameterSet>("QuadCutPSet")),
31  theSilentOnClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet").getUntrackedParameter<bool>("silentClusterCheck",false)){
32 
34 
35  token_vertex = iC.consumes<reco::VertexCollection>(_conf.getParameter<edm::InputTag>("primaryVerticesTag"));
36 
37  init();
38 }
39 
42  delete theRegionProducer;
43 }
44 
48  delete theHitsGenerator;
49  if(theSeedCreator!=NULL)
50  delete theSeedCreator;
51 }
52 
54 init(){
57 }
58 
61 
62  myEsetup = &setup;
63  myEvent = &event;
64 
65  if(seedCollection!=0)
66  delete seedCollection;
67 
69 
70  size_t clustsOrZero = theClusterCheck.tooManyClusters(event);
71  if (clustsOrZero){
73  edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";
74  return ;
75  }
76 
77  regions = theRegionProducer->regions(event,setup);
78 
79  event.getByToken(token_vertex, vertexHandle);
80  if (!vertexHandle.isValid()){
81  edm::LogError("PhotonConversionFinderFromTracks") << "Error! Can't get the product primary Vertex Collection "<< _conf.getParameter<edm::InputTag>("primaryVerticesTag") << "\n";
82  return;
83  }
84 
85  //Do the analysis
86  loop();
87 
88 #ifdef mydebug_knuenz
89  std::cout << "Running PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo" <<std::endl;
90 #endif
91 
92 #ifdef debugTSPFSLA
93  std::stringstream ss;
94  ss.str("");
95  ss << "\n++++++++++++++++++\n";
96  ss << "seed collection size " << seedCollection->size();
97  BOOST_FOREACH(TrajectorySeed tjS,*seedCollection){
98  po.print(ss, tjS);
99  }
100  edm::LogInfo("debugTrajSeedFromQuadruplets") << ss.str();
101  //-------------------------------------------------
102 #endif
103 }
104 
105 
108 
109 
110  ss.str("");
111 
112  float ptMin=0.1;
113 
114  BOOST_FOREACH(const reco::Vertex primaryVertex, *vertexHandle){
115 
116  //FIXME currnetly using the first primaryVertex, should loop on the promaryVertexes
117  GlobalTrackingRegion region(ptMin
118  ,GlobalPoint(
119  primaryVertex.position().x(),
120  primaryVertex.position().y(),
121  primaryVertex.position().z()
122  )
123  ,primaryVertex.xError()*10
124  ,primaryVertex.zError()*10
125  ,true
126  );
127 
128 #ifdef debugTSPFSLA
129  ss << "[PrintRegion] " << region.print() << std::endl;
130 #endif
131 
132  inspect(region);
133 
134  }
135 #ifdef debugTSPFSLA
136  edm::LogInfo("debugTrajSeedFromQuadruplets") << ss.str();
137 #endif
138 }
139 
140 
142 inspect(const TrackingRegion & region ){
143 
144  const OrderedSeedingHits & hitss = theHitsGenerator->run(region, *myEvent, *myEsetup);
145 
146  unsigned int nHitss = hitss.size();
147 
148 #ifdef debugTSPFSLA
149  ss << "\n nHitss " << nHitss << "\n";
150 #endif
151 
152  if (seedCollection->empty()) seedCollection->reserve(nHitss/2); // don't do multiple reserves in the case of multiple regions: it would make things even worse
153  // as it will cause N re-allocations instead of the normal log(N)/log(2)
154 
155  unsigned int iHits=0, jHits=1;
156 
157  //
158  // Trivial arbitration
159  //
160  // Vector to store old quad values
161  std::vector<Quad> quadVector;
162 
163 
164  for (; iHits < nHitss && jHits < nHitss; iHits+=2 , jHits+=2) {
165 
166 #ifdef debugTSPFSLA
167  // ss << "\n iHits " << iHits << " " << jHits << "\n";
168 #endif
169  //phits is the pair of hits for the positron
170  const SeedingHitSet & phits = hitss[iHits];
171  //mhits is the pair of hits for the electron
172  const SeedingHitSet & mhits = hitss[jHits];
173 
174 
175  try{
176  //FIXME (modify the interface of the seed generator if needed)
177  //passing the region, that is centered around the primary vertex
178  theSeedCreator->trajectorySeed(*seedCollection, phits, mhits, region, *myEsetup, ss, quadVector, SeedComparitorPSet, QuadCutPSet);
179  }catch(cms::Exception& er){
180  edm::LogError("SeedingConversion") << " Problem in the Quad Seed creator " <<er.what()<<std::endl;
181  }catch(std::exception& er){
182  edm::LogError("SeedingConversion") << " Problem in the Quad Seed creator " <<er.what()<<std::endl;
183  }
184  }
185  quadVector.clear();
186  return true;
187 }
virtual char const * what() const
Definition: Exception.cc:141
T getParameter(std::string const &) const
double zError() const
error on z
Definition: Vertex.h:104
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
#define NULL
Definition: scimark2.h:8
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:92
const OrderedHitPairs & run(const TrackingRegion &region, const edm::Event &ev, const edm::EventSetup &es)
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:76
tuple conf
Definition: dbtoconf.py:185
double xError() const
error on x
Definition: Vertex.h:100
const TrajectorySeed * trajectorySeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &phits, const SeedingHitSet &mhits, const TrackingRegion &region, const edm::EventSetup &es, std::stringstream &ss, std::vector< Quad > &quadV, edm::ParameterSet &SeedComparitorPSet, edm::ParameterSet &QuadCutPSet)
return(e1-e2)*(e1-e2)+dp *dp
virtual std::vector< TrackingRegion * > regions(const edm::Event &ev, const edm::EventSetup &) const
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="")