CMS 3D CMS Logo

AlCaECALRecHitReducer.cc
Go to the documentation of this file.
2 //#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
5 
10 
11 //#define ALLrecHits
12 //#define DEBUG
13 
14 //#define QUICK -> if commented loop over the recHits of the SC and add them to the list of recHits to be saved
15 // comment it if you want a faster module but be sure the window is large enough
16 
21 
24  ebRecHitsToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("ebRecHitsLabel"));
25  eeRecHitsToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("eeRecHitsLabel"));
26  // esRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("esRecHitsLabel");
27 
28  std::vector<edm::InputTag> srcLabels = iConfig.getParameter<std::vector<edm::InputTag> >("srcLabels");
29  for (auto inputTag = srcLabels.begin(); inputTag != srcLabels.end(); ++inputTag) {
31  }
32 
33  //eleViewToken_ = consumes<edm::View <reco::RecoCandidate> > (iConfig.getParameter< edm::InputTag > ("electronLabel"));
34  photonToken_ = consumes<reco::PhotonCollection>(iConfig.getParameter<edm::InputTag>("photonLabel"));
36  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("EESuperClusterCollection"));
37 
38  caloTopologyToken_ = esConsumes<CaloTopology, CaloTopologyRecord>();
39 
40  minEta_highEtaSC_ = iConfig.getParameter<double>("minEta_highEtaSC");
41 
42  alcaBarrelHitsCollection_ = iConfig.getParameter<std::string>("alcaBarrelHitCollection");
43  alcaEndcapHitsCollection_ = iConfig.getParameter<std::string>("alcaEndcapHitCollection");
44  alcaCaloClusterCollection_ = iConfig.getParameter<std::string>("alcaCaloClusterCollection");
45 
46  // alcaPreshowerHitsCollection_ = iConfig.getParameter<std::string>("alcaPreshowerHitCollection");
47 
48  etaSize_ = iConfig.getParameter<int>("etaSize");
49  phiSize_ = iConfig.getParameter<int>("phiSize");
50  // FIXME: minimum size of etaSize_ and phiSize_
51  if (phiSize_ % 2 == 0 || etaSize_ % 2 == 0)
52  edm::LogError("AlCaECALRecHitReducerError") << "Size of eta/phi should be odd numbers";
53 
54  // esNstrips_ = iConfig.getParameter<int> ("esNstrips");
55  // esNcolumns_ = iConfig.getParameter<int> ("esNcolumns");
56 
57  //register your products
58  produces<EBRecHitCollection>(alcaBarrelHitsCollection_);
59  produces<EERecHitCollection>(alcaEndcapHitsCollection_);
60  produces<reco::CaloClusterCollection>(alcaCaloClusterCollection_);
61  // produces< ESRecHitCollection > (alcaPreshowerHitsCollection_) ;
62 }
63 
65 
66 // ------------ method called to produce the data ------------
68  using namespace edm;
69  //using namespace std;
70 
71  const CaloTopology* caloTopology = &iSetup.getData(caloTopologyToken_);
72 
73  // Get Photons
75  iEvent.getByToken(photonToken_, phoHandle);
76 
77  // get RecHits
78  Handle<EBRecHitCollection> barrelRecHitsHandle;
79  iEvent.getByToken(ebRecHitsToken_, barrelRecHitsHandle);
80  const EBRecHitCollection* barrelHitsCollection = barrelRecHitsHandle.product();
81 
82  // get RecHits
83  Handle<EERecHitCollection> endcapRecHitsHandle;
84  iEvent.getByToken(eeRecHitsToken_, endcapRecHitsHandle);
85  const EERecHitCollection* endcapHitsCollection = endcapRecHitsHandle.product();
86 
87  // // get ES RecHits
88  // Handle<ESRecHitCollection> preshowerRecHitsHandle;
89  // iEvent.getByToken(esRecHitsToken_,preshowerRecHitsHandle);
90 
91  // const ESRecHitCollection * preshowerHitsCollection = 0 ;
92  // if (preshowerIsFull)
93  // preshowerHitsCollection = preshowerRecHitsHandle.product () ;
94 
95  // // make a vector to store the used ES rechits:
96  // set<ESDetId> used_strips;
97  // used_strips.clear();
98 
99  // for Z->ele+SC
101  iEvent.getByToken(EESuperClusterToken_, EESCHandle);
102 
103  //Create empty output collections
104  auto miniEBRecHitCollection = std::make_unique<EBRecHitCollection>();
105  auto miniEERecHitCollection = std::make_unique<EERecHitCollection>();
106  // auto miniESRecHitCollection = std::make_unique<ESRecHitCollection>();
107 
108  std::set<DetId> reducedRecHit_EBmap;
109  std::set<DetId> reducedRecHit_EEmap;
110 
111  // std::set< edm::Ref<reco::CaloCluster> > reducedCaloClusters_map;
112 
113  auto reducedCaloClusterCollection = std::make_unique<reco::CaloClusterCollection>();
114 
115  //Photons:
116 #ifdef shervin
117  for (reco::PhotonCollection::const_iterator phoIt = phoHandle->begin(); phoIt != phoHandle->end(); phoIt++) {
118  const reco::SuperCluster& sc = *(phoIt->superCluster());
119 
120  if (phoIt->isEB()) {
121  AddMiniRecHitCollection(sc, reducedRecHit_EBmap, caloTopology);
122  } else { // endcap
123  AddMiniRecHitCollection(sc, reducedRecHit_EEmap, caloTopology);
124  } // end of endcap
125 
129  for (; it != itend; ++it) {
130  reco::CaloCluster caloClus(**it);
131  reducedCaloClusterCollection->push_back(caloClus);
132  }
133  }
134 #endif
135 
137  for (auto iToken = eleViewTokens_.begin(); iToken != eleViewTokens_.end(); iToken++) {
138  iEvent.getByToken(*iToken, eleViewHandle);
139 
140  //Electrons:
141  for (auto eleIt = eleViewHandle->begin(); eleIt != eleViewHandle->end(); eleIt++) {
142  const reco::SuperCluster& sc = *(eleIt->superCluster());
143 
144  if (fabs(sc.eta()) < 1.479) {
145  AddMiniRecHitCollection(sc, reducedRecHit_EBmap, caloTopology);
146  } else { // endcap
147  AddMiniRecHitCollection(sc, reducedRecHit_EEmap, caloTopology);
148  } // end of endcap
149 
152  for (; it != itend; ++it) {
153  reco::CaloCluster caloClus(**it);
154  reducedCaloClusterCollection->push_back(caloClus);
155  }
156  }
157  }
158 
159  //saving recHits for highEta SCs for highEta studies
160  for (reco::SuperClusterCollection::const_iterator SC_iter = EESCHandle->begin(); SC_iter != EESCHandle->end();
161  SC_iter++) {
162  if (fabs(SC_iter->eta()) < minEta_highEtaSC_)
163  continue;
164  AddMiniRecHitCollection(*SC_iter, reducedRecHit_EEmap, caloTopology);
165 
166  const reco::SuperCluster& sc = *(SC_iter);
169  for (; it != itend; ++it) {
170  reco::CaloCluster caloClus(**it);
171  reducedCaloClusterCollection->push_back(caloClus);
172  }
173  }
174 
175  //------------------------------ fill the alcareco reduced recHit collection
176  for (std::set<DetId>::const_iterator itr = reducedRecHit_EBmap.begin(); itr != reducedRecHit_EBmap.end(); itr++) {
177  if (barrelHitsCollection->find(*itr) != barrelHitsCollection->end())
178  miniEBRecHitCollection->push_back(*(barrelHitsCollection->find(*itr)));
179  }
180 
181  for (std::set<DetId>::const_iterator itr = reducedRecHit_EEmap.begin(); itr != reducedRecHit_EEmap.end(); itr++) {
182  if (endcapHitsCollection->find(*itr) != endcapHitsCollection->end())
183  miniEERecHitCollection->push_back(*(endcapHitsCollection->find(*itr)));
184  }
185 
186  //--------------------------------------- Put selected information in the event
187  iEvent.put(std::move(miniEBRecHitCollection), alcaBarrelHitsCollection_);
188  iEvent.put(std::move(miniEERecHitCollection), alcaEndcapHitsCollection_);
189  // iEvent.put(std::move(miniESRecHitCollection),alcaPreshowerHitsCollection_ );
190  iEvent.put(std::move(reducedCaloClusterCollection), alcaCaloClusterCollection_);
191 }
192 
194  std::set<DetId>& reducedRecHitMap,
195  const CaloTopology* caloTopology) const {
196  DetId seed = (sc.seed()->seed());
197  int phiSize = phiSize_, etaSize = etaSize_;
198  if (seed.subdetId() != EcalBarrel) { // if not EB, take a square window
200  phiSize = etaSize;
201  }
202 
203  std::vector<DetId> recHit_window = caloTopology->getWindow(seed, phiSize, etaSize);
204  for (unsigned int i = 0; i < recHit_window.size(); i++) {
205  reducedRecHitMap.insert(recHit_window[i]);
206  }
207 
208  const std::vector<std::pair<DetId, float> >& scHits = sc.hitsAndFractions();
209  for (std::vector<std::pair<DetId, float> >::const_iterator scHit_itr = scHits.begin(); scHit_itr != scHits.end();
210  scHit_itr++) {
211  // the map fills just one time (avoiding double insert of recHits)
212  reducedRecHitMap.insert(scHit_itr->first);
213  }
214 
215  return;
216 }
217 
edm::StreamID
Definition: StreamID.h:30
mps_fire.i
i
Definition: mps_fire.py:428
AlCaECALRecHitReducer::photonToken_
edm::EDGetTokenT< reco::PhotonCollection > photonToken_
Definition: AlCaECALRecHitReducer.h:67
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
reco::SuperCluster
Definition: SuperCluster.h:18
BasicCluster.h
edm
HLT enums.
Definition: AlignableModifier.h:19
interestingDetIdCollectionProducer_cfi.phiSize
phiSize
Definition: interestingDetIdCollectionProducer_cfi.py:7
CaloTopology::getWindow
std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Get the neighbors of the given cell in a window of given size.
Definition: CaloTopology.cc:64
AlCaECALRecHitReducer::eeRecHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > eeRecHitsToken_
Definition: AlCaECALRecHitReducer.h:62
interestingDetIdCollectionProducer_cfi.etaSize
etaSize
Definition: interestingDetIdCollectionProducer_cfi.py:6
AlCaECALRecHitReducer::alcaBarrelHitsCollection_
std::string alcaBarrelHitsCollection_
Definition: AlCaECALRecHitReducer.h:70
edm::PtrVectorItr
Definition: PtrVector.h:51
edm::SortedCollection< EcalRecHit >
AlCaECALRecHitReducer::~AlCaECALRecHitReducer
~AlCaECALRecHitReducer() override
Definition: AlCaECALRecHitReducer.cc:64
edm::Handle< reco::PhotonCollection >
CaloTopology
Definition: CaloTopology.h:19
EcalBarrel
Definition: EcalSubdetector.h:10
AlCaECALRecHitReducer::minEta_highEtaSC_
double minEta_highEtaSC_
Definition: AlCaECALRecHitReducer.h:82
AlCaECALRecHitReducer.h
fileCollector.seed
seed
Definition: fileCollector.py:127
DetId
Definition: DetId.h:17
Photon.h
AlCaECALRecHitReducer::EESuperClusterToken_
edm::EDGetTokenT< reco::SuperClusterCollection > EESuperClusterToken_
Definition: AlCaECALRecHitReducer.h:68
AlCaECALRecHitReducer::eleViewTokens_
std::vector< edm::EDGetTokenT< edm::View< reco::RecoCandidate > > > eleViewTokens_
Definition: AlCaECALRecHitReducer.h:65
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlCaECALRecHitReducer::alcaCaloClusterCollection_
std::string alcaCaloClusterCollection_
Definition: AlCaECALRecHitReducer.h:83
reco::CaloCluster
Definition: CaloCluster.h:31
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSubdetector.h
AlCaECALRecHitReducer
Definition: AlCaECALRecHitReducer.h:49
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaECALRecHitReducer::AddMiniRecHitCollection
void AddMiniRecHitCollection(const reco::SuperCluster &sc, std::set< DetId > &reducedRecHitMap, const CaloTopology *caloTopology) const
Definition: AlCaECALRecHitReducer.cc:193
reco::SuperCluster::seed
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
CaloTopologyRecord.h
iEvent
int iEvent
Definition: GenABIO.cc:224
AlCaECALRecHitReducer::alcaEndcapHitsCollection_
std::string alcaEndcapHitsCollection_
Definition: AlCaECALRecHitReducer.h:71
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
reco::SuperCluster::clustersBegin
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:86
edm::EventSetup
Definition: EventSetup.h:57
AlCaECALRecHitReducer::caloTopologyToken_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
Definition: AlCaECALRecHitReducer.h:69
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
AlCaECALRecHitReducer::etaSize_
int etaSize_
Definition: AlCaECALRecHitReducer.h:73
AlCaECALRecHitReducer::phiSize_
int phiSize_
Definition: AlCaECALRecHitReducer.h:74
eostools.move
def move(src, dest)
Definition: eostools.py:511
AlCaECALRecHitReducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
producer
Definition: AlCaECALRecHitReducer.cc:67
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlCaECALRecHitReducer::AlCaECALRecHitReducer
AlCaECALRecHitReducer(const edm::ParameterSet &)
ctor
Definition: AlCaECALRecHitReducer.cc:23
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
reco::SuperCluster::clustersEnd
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89
SimL1EmulatorRepack_Full_cff.inputTag
inputTag
Definition: SimL1EmulatorRepack_Full_cff.py:56
edm::Event
Definition: Event.h:73
AlCaECALRecHitReducer::ebRecHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > ebRecHitsToken_
Definition: AlCaECALRecHitReducer.h:61
edm::InputTag
Definition: InputTag.h:15