CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalHaloDataProducer.cc
Go to the documentation of this file.
3 
4 /*
5  [class]: GlobalHaloDataProducer
6  [authors]: R. Remington, The University of Florida
7  [description]: See GlobalHaloDataProducer.h
8  [date]: October 15, 2009
9 */
10 
11 using namespace edm;
12 using namespace std;
13 using namespace reco;
14 
15 GlobalHaloDataProducer::GlobalHaloDataProducer(const edm::ParameterSet& iConfig)
16 {
17  //Higher Level Reco
18  IT_met = iConfig.getParameter<edm::InputTag>("metLabel");
19  IT_CaloTower = iConfig.getParameter<edm::InputTag>("calotowerLabel");
20  IT_CSCSegment = iConfig.getParameter<edm::InputTag>("CSCSegmentLabel");
21  IT_CSCRecHit = iConfig.getParameter<edm::InputTag>("CSCRecHitLabel");
22 
23  //Halo Data from Sub-detectors
24  IT_CSCHaloData = iConfig.getParameter<edm::InputTag>("CSCHaloDataLabel");
25  IT_EcalHaloData = iConfig.getParameter<edm::InputTag> ("EcalHaloDataLabel");
26  IT_HcalHaloData = iConfig.getParameter<edm::InputTag> ("HcalHaloDataLabel");
27 
28  EcalMinMatchingRadius = (float)iConfig.getParameter<double>("EcalMinMatchingRadiusParam");
29  EcalMaxMatchingRadius = (float)iConfig.getParameter<double>("EcalMaxMatchingRadiusParam");
30  HcalMinMatchingRadius = (float)iConfig.getParameter<double>("HcalMinMatchingRadiusParam");
31  HcalMaxMatchingRadius = (float)iConfig.getParameter<double>("HcalMaxMatchingRadiusParam");
32  CaloTowerEtThreshold = (float)iConfig.getParameter<double>("CaloTowerEtThresholdParam");
33 
34  calotower_token_ = consumes<edm::View<Candidate> >(IT_CaloTower);
35  calomet_token_ = consumes<reco::CaloMETCollection>(IT_met);
36  cscsegment_token_ = consumes<CSCSegmentCollection>(IT_CSCSegment);
37  cscrechit_token_ = consumes<CSCRecHit2DCollection>(IT_CSCRecHit);
38  cschalo_token_ = consumes<CSCHaloData>(IT_CSCHaloData);
39  ecalhalo_token_ = consumes<EcalHaloData>(IT_EcalHaloData);
40  hcalhalo_token_ = consumes<HcalHaloData>(IT_HcalHaloData);
41 
42  produces<GlobalHaloData>();
43 }
44 
45 void GlobalHaloDataProducer::produce(Event& iEvent, const EventSetup& iSetup)
46 {
47  //Get CSC Geometry
48  edm::ESHandle<CSCGeometry> TheCSCGeometry;
49  iSetup.get<MuonGeometryRecord>().get(TheCSCGeometry);
50 
51  //Get Global Tracking Geometry
52  edm::ESHandle<GlobalTrackingGeometry> TheGlobalTrackingGeometry;
53  iSetup.get<GlobalTrackingGeometryRecord>().get(TheGlobalTrackingGeometry);
54 
55  //Get CaloGeometry
56  edm::ESHandle<CaloGeometry> TheCaloGeometry;
57  iSetup.get<CaloGeometryRecord>().get(TheCaloGeometry);
58 
59  //Get CaloTowers
60  edm::Handle<edm::View<Candidate> > TheCaloTowers;
61  // iEvent.getByLabel(IT_CaloTower,TheCaloTowers);
62  iEvent.getByToken(calotower_token_, TheCaloTowers);
63 
64  //Get MET
66  // iEvent.getByLabel(IT_met, TheCaloMET);
67  iEvent.getByToken(calomet_token_, TheCaloMET);
68 
69  //Get CSCSegments
70  edm::Handle<CSCSegmentCollection> TheCSCSegments;
71  // iEvent.getByLabel(IT_CSCSegment, TheCSCSegments);
72  iEvent.getByToken(cscsegment_token_, TheCSCSegments);
73 
74  //Get CSCRecHits
76  // iEvent.getByLabel(IT_CSCRecHit, TheCSCRecHits );
77  iEvent.getByToken(cscrechit_token_, TheCSCRecHits);
78 
79  //Get CSCHaloData
80  edm::Handle<reco::CSCHaloData> TheCSCHaloData;
81  // iEvent.getByLabel(IT_CSCHaloData, TheCSCHaloData );
82  iEvent.getByToken(cschalo_token_, TheCSCHaloData);
83 
84  // Get EcalHaloData
85  edm::Handle<reco::EcalHaloData> TheEcalHaloData;
86  // iEvent.getByLabel(IT_EcalHaloData, TheEcalHaloData );
87  iEvent.getByToken(ecalhalo_token_, TheEcalHaloData);
88 
89  // Get HcalHaloData
90  edm::Handle<reco::HcalHaloData> TheHcalHaloData;
91  // iEvent.getByLabel(IT_HcalHaloData, TheHcalHaloData );
92  iEvent.getByToken(hcalhalo_token_, TheHcalHaloData);
93 
94  // Run the GlobalHaloAlgo to reconstruct the GlobalHaloData object
95  GlobalHaloAlgo GlobalAlgo;
96  GlobalAlgo.SetEcalMatchingRadius(EcalMinMatchingRadius,EcalMaxMatchingRadius);
97  GlobalAlgo.SetHcalMatchingRadius(HcalMinMatchingRadius,HcalMaxMatchingRadius);
98  GlobalAlgo.SetCaloTowerEtThreshold(CaloTowerEtThreshold);
99  // GlobalHaloData GlobalData;
100 
101  if(TheCaloGeometry.isValid() && TheCaloMET.isValid() && TheCaloTowers.isValid() && TheCSCHaloData.isValid() && TheEcalHaloData.isValid() && TheHcalHaloData.isValid() )
102  {
103  std::auto_ptr<GlobalHaloData> GlobalData( new GlobalHaloData(GlobalAlgo.Calculate(*TheCaloGeometry, *TheCSCGeometry, *(&TheCaloMET.product()->front()), TheCaloTowers, TheCSCSegments, TheCSCRecHits, *TheCSCHaloData.product(), *TheEcalHaloData.product(), *TheHcalHaloData.product() )) );
104  iEvent.put(GlobalData);
105  }
106  else
107  {
108  std::auto_ptr<GlobalHaloData> GlobalData( new GlobalHaloData() ) ;
109  iEvent.put(GlobalData);
110  }
111 
112  return;
113 }
114 
115 GlobalHaloDataProducer::~GlobalHaloDataProducer(){}
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
reco::GlobalHaloData Calculate(const CaloGeometry &TheCaloGeometry, const CSCGeometry &TheCSCGeometry, const reco::CaloMET &TheCaloMET, edm::Handle< edm::View< reco::Candidate > > &TheCaloTowers, edm::Handle< CSCSegmentCollection > &TheCSCSegments, edm::Handle< CSCRecHit2DCollection > &TheCSCRecHits, const reco::CSCHaloData &TheCSCHaloData, const reco::EcalHaloData &TheEcalHaloData, const reco::HcalHaloData &TheHcalHaloData)
void SetHcalMatchingRadius(float min, float max)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
bool isValid() const
Definition: HandleBase.h:75
void SetEcalMatchingRadius(float min, float max)
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
void SetCaloTowerEtThreshold(float EtMin)
bool isValid() const
Definition: ESHandle.h:47