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