CMS 3D CMS Logo

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