CMS 3D CMS Logo

EGMSeedLocationProducer.cc
Go to the documentation of this file.
1 //
2 // EGMSeedLocationProducer
3 // to compute iEta/iPhi (for barrel) and iX/iY (for endcaps) of seed crystal
4 // for size considerations, they are compressed into 2 vars (iEtaOriX/iPhiOriY)
5 //
6 // Author: Swagata Mukherjee
7 // Date: December 2022
8 //
9 
10 #include <memory>
22 
23 template <typename T>
25 public:
26  explicit EGMSeedLocationProducer(const edm::ParameterSet& iConfig)
27  : src_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("src"))) {
28  produces<edm::ValueMap<int>>("iEtaOriX");
29  produces<edm::ValueMap<int>>("iPhiOriY");
30  }
32 
33  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
34 
35 private:
36  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
37 
39 };
40 
41 template <typename T>
44  const edm::EventSetup& iSetup) const {
45  auto src = iEvent.getHandle(src_);
46 
47  unsigned nSrc = src->size();
48  // Range of the variables are the following:
49  // iEta runs from -85 to +85, with no crystal at iEta=0.
50  // iPhi runs from 1 to 360.
51  // iX and iY run from 1 to 100.
52  // So, when combined, iEtaOriX will be -85 to 100 (except 0).
53  // and iPhiOriY will be 1 to 360.
54  std::vector<int> iEtaOriX(nSrc, 0);
55  std::vector<int> iPhiOriY(nSrc, 0);
56 
57  for (unsigned i = 0; i < nSrc; i++) { // object loop
58  auto obj = src->ptrAt(i);
59  auto detid = obj->superCluster()->seed()->seed();
60 
61  if (detid.subdetId() == EcalBarrel) {
62  EBDetId ebdetid(detid);
63  iEtaOriX[i] = ebdetid.ieta();
64  iPhiOriY[i] = ebdetid.iphi();
65  } else if (detid.subdetId() == EcalEndcap) {
66  EEDetId eedetid(detid);
67  iEtaOriX[i] = eedetid.ix();
68  iPhiOriY[i] = eedetid.iy();
69  }
70  } // end of object loop
71 
72  std::unique_ptr<edm::ValueMap<int>> iEtaOriXV(new edm::ValueMap<int>());
73  edm::ValueMap<int>::Filler filleriEtaOriXV(*iEtaOriXV);
74  filleriEtaOriXV.insert(src, iEtaOriX.begin(), iEtaOriX.end());
75  filleriEtaOriXV.fill();
76  iEvent.put(std::move(iEtaOriXV), "iEtaOriX");
77 
78  std::unique_ptr<edm::ValueMap<int>> iPhiOriYV(new edm::ValueMap<int>());
79  edm::ValueMap<int>::Filler filleriPhiOriYV(*iPhiOriYV);
80  filleriPhiOriYV.insert(src, iPhiOriY.begin(), iPhiOriY.end());
81  filleriPhiOriYV.fill();
82  iEvent.put(std::move(iPhiOriYV), "iPhiOriY");
83 }
84 
85 template <typename T>
88  desc.add<edm::InputTag>("src")->setComment("input physics object collection");
89  descriptions.addDefault(desc);
90 }
91 
94 
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
EGMSeedLocationProducer< pat::Electron > ElectronSeedLocationProducer
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
int ix() const
Definition: EEDetId.h:77
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
EGMSeedLocationProducer(const edm::ParameterSet &iConfig)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
edm::EDGetTokenT< edm::View< T > > src_
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EGMSeedLocationProducer< pat::Photon > PhotonSeedLocationProducer
HLT enums.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
long double T
def move(src, dest)
Definition: eostools.py:511
int iy() const
Definition: EEDetId.h:83