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 
5 /*
6 To Do:
7 
8 assign the parameters to some data member to avoid search at every event
9 
10  */
11 
12 //#define debugTSPFSLA
13 
16  :_conf(conf),seedCollection(0),
17  hitsfactoryPSet(conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet")),
18  creatorPSet(conf.getParameter<edm::ParameterSet>("SeedCreatorPSet")),
19  regfactoryPSet(conf.getParameter<edm::ParameterSet>("RegionFactoryPSet")),
20  theClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet")),
21  theSilentOnClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet").getUntrackedParameter<bool>("silentClusterCheck",false)){
22 
23  init();
24 }
25 
29  delete theHitsGenerator;
30  if(theSeedCreator!=NULL)
31  delete theSeedCreator;
33  delete theRegionProducer;
34 }
35 
37 init(){
41 }
42 
45 
46  myEsetup = &setup;
47  myEvent = &event;
48 
49  if(seedCollection!=0)
50  delete seedCollection;
51 
53 
54  size_t clustsOrZero = theClusterCheck.tooManyClusters(event);
55  if (clustsOrZero){
57  edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";
58  return ;
59  }
60 
61  regions = theRegionProducer->regions(event,setup);
62 
63  event.getByLabel(_conf.getParameter<edm::InputTag>("primaryVerticesTag"), vertexHandle);
64  if (!vertexHandle.isValid()){
65  edm::LogError("PhotonConversionFinderFromTracks") << "Error! Can't get the product primary Vertex Collection "<< _conf.getParameter<edm::InputTag>("primaryVerticesTag") << "\n";
66  return;
67  }
68 
69  //Do the analysis
70  loop();
71 
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
98  GlobalTrackingRegion region(ptMin
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 
123 inspect(const TrackingRegion & region ){
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  for (; iHits < nHitss && jHits < nHitss; iHits+=2 , jHits+=2) {
145 
146 #ifdef debugTSPFSLA
147  // ss << "\n iHits " << iHits << " " << jHits << "\n";
148 #endif
149  //phits is the pair of hits for the positron
150  const SeedingHitSet & phits = hitss[iHits];
151  //mhits is the pair of hits for the electron
152  const SeedingHitSet & mhits = hitss[jHits];
153 
154  //if (!theComparitor || theComparitor->compatible( hits, es) ) {
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, *myEsetup, ss, quadVector);
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 }
169 
170 
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
virtual 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)
virtual std::vector< TrackingRegion * > regions(const edm::Event &ev, const edm::EventSetup &) const
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")