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