CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TCaloRCTToUpgradeConverter.cc
Go to the documentation of this file.
2 
6 
8 
11 
13 
14 #include <vector>
15 
16 //#include <stdio.h>
17 
19 
20  produces<l1t::CaloRegionBxCollection>();
21  produces<l1t::CaloEmCandBxCollection>();
22 
23  rgnToken_ = consumes<L1CaloRegionCollection>(ps.getParameter<edm::InputTag>("regionTag"));
24  emToken_ = consumes<L1CaloEmCollection>(ps.getParameter<edm::InputTag>("emTag"));
25 
26  // firstBx_ = -ps.getParameter<unsigned>("preSamples");
27  // lastBx_ = ps.getParameter<unsigned>("postSamples");
28 
29 }
30 
32 
33 }
34 
35 // ------------ method called to produce the data ------------
36 void
38 {
39 
40  // check status of RCT conditions & renew if needed
41 
42 
43  // store new formats
44  std::auto_ptr<BXVector<l1t::CaloEmCand> > emcands (new l1t::CaloEmCandBxCollection);
45  std::auto_ptr<BXVector<l1t::CaloRegion> > regions (new l1t::CaloRegionBxCollection);
46 
47  // get old formats
50 
51  iEvent.getByToken(emToken_, ems);
52  iEvent.getByToken(rgnToken_, rgns);
53 
54  // get the firstBx_ and lastBx_ from the input datatypes (assume bx for em same as rgn)
55  int firstBx = 0;
56  int lastBx = 0;
57  for (std::vector<L1CaloEmCand>::const_iterator em=ems->begin(); em!=ems->end(); ++em) {
58  int bx = em->bx();
59  if (bx < firstBx) firstBx = bx;
60  if (bx > lastBx) lastBx = bx;
61  }
62 
63  emcands->setBXRange(firstBx, lastBx);
64  regions->setBXRange(firstBx, lastBx);
65 
66  // loop over EM
67  for (std::vector<L1CaloEmCand>::const_iterator em=ems->begin(); em!=ems->end(); ++em) {
68 
69  // get physical units
70  // double pt = 0.;
71  // double eta = 0.;
72  // double phi = 0.;
73  //math::PtEtaPhiMLorentzVector p4( pt+1.e-6, eta, phi, 0. );
74  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
75  new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
76 
77  //l1t::CaloStage1Cluster cluster;
78  l1t::CaloEmCand EmCand(*p4,
79  (int) em->rank(),
80  (int) em->regionId().ieta(),
81  (int) em->regionId().iphi(),
82  0);
83 
84  // create new format
85  emcands->push_back( em->bx(), EmCand );
86 
87  }
88 
89  // loop over regions
90  for (std::vector<L1CaloRegion>::const_iterator rgn=rgns->begin(); rgn!=rgns->end(); ++rgn) {
91 
92  // get physical units
93  // double pt = 0.;
94  // double eta = 0.;
95  // double phi = 0.;
96  //math::PtEtaPhiMLorentzVector p4( pt+1.e-6, eta, phi, 0 );
97 
98  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
99  new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
100 
101 
102  // create new format
103  //l1t::CaloRegion region;
104  l1t::CaloRegion region(*p4,
105  0.,
106  0.,
107  (int) rgn->et(),
108  (int) rgn->id().ieta(),
109  (int) rgn->id().iphi(),
110  0,
111  0,
112  0);
113 
114  // add to output
115  regions->push_back( rgn->bx(), region );
116 
117  }
118 
119  iEvent.put(emcands);
120  iEvent.put(regions);
121 
122 }
123 
124 // ------------ method called once each job just before starting event loop ------------
125 void
127 {
128 }
129 
130 // ------------ method called once each job just after ending the event loop ------------
131 void
133 }
134 
135 // ------------ method called when starting to processes a run ------------
136 /*
137  void
138  l1t::L1TCaloRCTToUpgradeConverter::beginRun(edm::Run const&, edm::EventSetup const&)
139  {
140  }
141 */
142 
143 // ------------ method called when ending the processing of a run ------------
144 /*
145  void
146  l1t::L1TCaloRCTToUpgradeConverter::endRun(edm::Run const&, edm::EventSetup const&)
147  {
148  }
149 */
150 
151 // ------------ method called when starting to processes a luminosity block ------------
152 /*
153  void
154  l1t::L1TCaloRCTToUpgradeConverter::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup cons
155  t&)
156  {
157  }
158 */
159 
160 // ------------ method called when ending the processing of a luminosity block ------------
161 /*
162  void
163  l1t::L1TCaloRCTToUpgradeConverter::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&
164  )
165  {
166  }
167 */
168 
169 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
170 void
172  //The following says we do not know what parameters are allowed so do no validation
173  // Please change this to state exactly what you do use, even if it is no parameters
175  desc.setUnknown();
176  descriptions.addDefault(desc);
177 }
178 
179 //define this as a plug-in
T getParameter(std::string const &) const
L1TCaloRCTToUpgradeConverter(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void produce(edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
double p4[4]
Definition: TauolaWrapper.h:92
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)