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