CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalRawToRecHitRoI.h
Go to the documentation of this file.
1 #ifndef EventFilter_EcalRawToRecHitRoI_H
2 #define EventFilter_EcalRawToRecHitRoI_H
3 
5 
12 
15 
21 
22 #include <iostream>
23 #include <string>
24 #include <vector>
25 
29 
30 //additionnal stuff to be more precise with candidates
31 //#include "MagneticField/Engine/interface/MagneticField.h"
38 
40 
43 
44 public:
45 
47  virtual ~EcalRawToRecHitRoI();
48  void produce(edm::Event & e, const edm::EventSetup& c);
49 
50  private:
51 
52  void Egamma(edm::Event& e, const edm::EventSetup& es, std::vector<int>& FEDs);
53  void Muon(edm::Event& e, const edm::EventSetup& es, std::vector<int>& FEDs);
54  void Jet(edm::Event& e, const edm::EventSetup& es, std::vector<int>& FEDs);
55  void Cand(edm::Event& e, const edm::EventSetup& es, std::vector<int>& FEDs);
56 
57 
60  bool do_es_;
62  std::string esinstance_;
63 
67 
70  public:
73  Source = cfg.getParameter<edm::InputTag>("Source");
74  Ptmin = cfg.getParameter<double>("Ptmin");
75  regionEtaMargin = cfg.getParameter<double>("regionEtaMargin");
76  regionPhiMargin = cfg.getParameter<double>("regionPhiMargin");
77  }
79  double Ptmin;
82  };
83 
85  bool EGamma_;
87  class EmJobPSet : public CalUnpackJobPSet {
88  public:
91  };
94  const EmJobPSet & ejpset,
95  const edm::ESHandle< L1CaloGeometry > & l1CaloGeom,
96  std::vector<int> & FEDs);
98  std::vector< EmJobPSet > EmSource_;
99 
101  bool Muon_ ;
103  class MuJobPSet : public CalUnpackJobPSet {
104  public:
108  double epsilon;
109  };
112 
114  bool Jet_ ;
116  class JetJobPSet :public CalUnpackJobPSet {
117  public:
120  double epsilon;
121  };
124  const JetJobPSet & jjpset,
125  std::vector<int> & feds);
127  std::vector< JetJobPSet > JetSource_;
128 
132  class CandJobPSet : public CalUnpackJobPSet {
133  public:
137  double epsilon;
138  bool bePrecise;
141  };
143  template <typename CollectionType> void OneCandCollection(const edm::Event& e,
144  const edm::EventSetup& es,
145  const CandJobPSet & cjpset,
146  std::vector<int> & feds);
147 
149  std::vector< CandJobPSet > CandSource_;
150 
152  bool All_;
153 
155  void ListOfFEDS(double etaLow, double etaHigh, double phiLow,
156  double phiHigh, double etamargin, double phimargin,
157  std::vector<int>& FEDs);
158 
160  void unique(std::vector<int>& FEDs){
161  std::sort(FEDs.begin(),FEDs.end());
162  std::vector<int>::iterator n_end = std::unique(FEDs.begin(),FEDs.end());
163  FEDs.erase(n_end,FEDs.end());}
164  std::string dumpFEDs(const std::vector<int>& FEDs);
165 };
166 
167 template <typename CollectionType> void EcalRawToRecHitRoI::OneCandCollection(const edm::Event& e,
168  const edm::EventSetup& es,
169  const CandJobPSet & cjpset,
170  std::vector<int> & feds){
171  const std::string category ="EcalRawToRecHit|Cand";
172 
174  e.getByLabel(cjpset.Source, candColl);
175  if (candColl.failedToGet()) {
176  edm::LogError("IncorrectConfiguration")<<"could not get: "<<cjpset.Source<<" of type: "<<cjpset.cType;
177  return;
178  }
179 
180  typename CollectionType::const_iterator it = candColl->begin();
181  typename CollectionType::const_iterator end= candColl->end();
182 
183  StateOnTrackerBound * onBounds=0;
185  if (cjpset.bePrecise){
186  // grab a propagator from ES
187  es.get<TrackingComponentsRecord>().get(cjpset.propagatorNameToBePrecise, propH);
188  // make the extrapolator object
189  onBounds = new StateOnTrackerBound(propH.product());
190  }
191 
192  for (; it!=end;++it){
193  double pt = it->pt();
194  double eta = it->eta();
195  double phi = it->phi();
196  if (cjpset.bePrecise){
197  // starting FTS
198  GlobalPoint point(it->vx(),it->vy(),it->vz());
199  GlobalVector vector(it->px(),it->py(),it->pz());
200 
201  if (point.mag()==0 && vector.mag()==0){
202  edm::LogWarning("IncorrectRecHit")<<" state of candidate is not valid. skipping.";
203  continue;
204  }
205 
206  FreeTrajectoryState fts(point, vector, it->charge(), propH->magneticField());
207  // final TSOS
208  TrajectoryStateOnSurface out = (*onBounds)(fts);
209  if (out.isValid()){
210  vector=out.globalMomentum();
211  point=out.globalPosition();
212  // be more precise
213  pt= vector.perp();
214  eta= point.eta();
215  phi= point.phi();
216  }
217  else{edm::LogWarning("IncorrectRecHit")<<"I tried to be precise, but propagation failed. from:\n"<<fts;
218  continue;}
219  }
220 
221  LogDebug(category)<<" here is a candidate Seed with (eta,phi) = "
222  <<eta << " " << phi << " and pt " << pt;
223  if (pt < cjpset.Ptmin) continue;
224 
225  ListOfFEDS(eta, eta, phi-cjpset.epsilon, phi+cjpset.epsilon, cjpset.regionEtaMargin, cjpset.regionPhiMargin,feds);
226  }
227  if(cjpset.bePrecise){delete onBounds;}
228 }
229 
230 #endif
231 
232 
#define LogDebug(id)
JetJobPSet(edm::ParameterSet &cfg)
bool Candidate_
Candidate-versatile objects part flag.
void OneCandCollection(const edm::Event &e, const edm::EventSetup &es, const CandJobPSet &cjpset, std::vector< int > &feds)
process one collection of Candidate-versatile objects
void Cand(edm::Event &e, const edm::EventSetup &es, std::vector< int > &FEDs)
T getParameter(std::string const &) const
class to drive the job on L1Jet
edm::RefGetter< EcalRecHit > EcalRecHitRefGetter
void unique(std::vector< int > &FEDs)
remove duplicates
MuJobPSet MuonSource_
what drives the job from ONE L1Muon collection
EmJobPSet(edm::ParameterSet &cfg)
const ESElectronicsMapper * TheESMapping
class to drive the job on Candidate-inheriting object
bool Muon_
Muon part flag.
CalUnpackJobPSet(edm::ParameterSet &cfg)
std::vector< JetJobPSet > JetSource_
what drive the job on L1Jet collection
std::string dumpFEDs(const std::vector< int > &FEDs)
T eta() const
void Jet(edm::Event &e, const edm::EventSetup &es, std::vector< int > &FEDs)
edm::LazyGetter< EcalRecHit > EcalRecHitLazyGetter
std::vector< EmJobPSet > EmSource_
what drive the job on L1Em collection
void Muon(edm::Event &e, const edm::EventSetup &es, std::vector< int > &FEDs)
const EcalElectronicsMapping * TheMapping
tools
generic class to drive the job
edm::InputTag sourceTag_es_
std::vector< CandJobPSet > CandSource_
what drives the job from candidate
class to drive the job on L1Em
void ListOfFEDS(double etaLow, double etaHigh, double phiLow, double phiHigh, double etamargin, double phimargin, std::vector< int > &FEDs)
actually fill the vector with FED numbers
#define end
Definition: vmac.h:38
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
void Egamma_OneL1EmCollection(const edm::Handle< l1extra::L1EmParticleCollection > emColl, const EmJobPSet &ejpset, const edm::ESHandle< L1CaloGeometry > &l1CaloGeom, std::vector< int > &FEDs)
process one collection of L1Em
tuple out
Definition: dbtoconf.py:99
bool failedToGet() const
Definition: HandleBase.h:80
class to drive the job on L1Muon
edm::InputTag sourceTag_
input tag for the lazy getter
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void produce(edm::Event &e, const edm::EventSetup &c)
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
bool All_
if all need to be done
void Egamma(edm::Event &e, const edm::EventSetup &es, std::vector< int > &FEDs)
bool EGamma_
Egamma part flag.
bool Jet_
jet part flag
CandJobPSet(edm::ParameterSet &cfg)
MuJobPSet(edm::ParameterSet &cfg)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
EcalRawToRecHitRoI(const edm::ParameterSet &pset)
void Jet_OneL1JetCollection(const edm::Handle< l1extra::L1JetParticleCollection > jetColl, const JetJobPSet &jjpset, std::vector< int > &feds)
process on collection of L1Jets
Definition: DDAxes.h:10