46 if ( phiSize_ % 2 == 0 || etaSize_ % 2 == 0)
47 edm::LogError(
"AlCaECALRecHitReducerError") <<
"Size of eta/phi should be odd numbers";
58 produces< double > (
"weight") ;
82 const CaloTopology *caloTopology = theCaloTopology.product();
87 if (!pElectrons.isValid()) {
98 bool barrelIsFull =
true ;
101 if (!barrelRecHitsHandle.isValid()) {
103 barrelIsFull =
false ;
108 barrelHitsCollection = barrelRecHitsHandle.product () ;
112 bool endcapIsFull =
true ;
115 if (!endcapRecHitsHandle.isValid()) {
117 endcapIsFull =
false ;
122 endcapHitsCollection = endcapRecHitsHandle.product () ;
147 std::auto_ptr< double >
weight (
new double(1));
152 reco::GsfElectronCollection::const_iterator eleIt;
156 std::set<DetId> reducedRecHit_EBmap;
157 std::set<DetId> reducedRecHit_EEmap;
159 for (eleIt=electronCollection->begin(); eleIt!=electronCollection->end(); eleIt++) {
169 std::vector<DetId> recHit_window = caloTopology->getWindow(seed,
phiSize_,
etaSize_);
170 for(
unsigned int i =0;
i < recHit_window.size();
i++){
172 std::cout <<
i <<
"/" << recHit_window.size() <<
"\t" << recHit_window[
i]() << std::endl;
174 reducedRecHit_EBmap.insert(recHit_window[
i]);
176 EBDetId ebrechit(recHit_window[i]);
183 float energy_recHit_max=-999;
185 if(reducedRecHit_EBmap.size() < sc.
size())
186 std::cerr <<
"[WARNING] number of recHit in selected window < RECO SC recHits!" << std::endl;
190 const std::vector< std::pair<DetId, float> > & scHits = sc.
hitsAndFractions();
193 std::vector< std::pair<DetId, float> >::const_iterator scHit_max_itr = scHits.end();
195 for(std::vector< std::pair<DetId, float> >::const_iterator scHit_itr = scHits.begin();
196 scHit_itr != scHits.end(); scHit_itr++){
198 reducedRecHit_EBmap.insert(scHit_itr->first);
202 if(energy_recHit_max < ecalRecHit.
energy()){
203 scHit_max_itr = scHit_itr;
204 energy_recHit_max=ecalRecHit.
energy();
212 if(
EBDetId(scHit_max_itr->first) != seed)
213 std::cerr <<
"[ERROR] highest energetic crystal is not the seed of the SC" << std::endl;
217 std::cout <<
"[DEBUG] highest energetic crystal = " <<
EBDetId(scHit_max_itr->first) << std::endl;
218 std::cout <<
"[DEBUG] seed of the SC = " << seed << std::endl;
223 if(reducedRecHit_EBmap.size() < sc.
size()){
224 if(eleIt->ecalDrivenSeed())
225 edm::LogError(
"AlCaSavedRecHitsEB") <<
"[ERROR] ecalDrivenSeed: number of saved recHits < RECO SC recHits!: " << reducedRecHit_EBmap.size() <<
" < " << sc.
size() << std::endl;
227 edm::LogWarning(
"AlCaSavedRecHitsEB") <<
"[WARNING] trackerDrivenSeed: number of saved recHits < RECO SC recHits!: " << reducedRecHit_EBmap.size() <<
" < " << sc.
size() << std::endl;
239 std::vector<DetId> recHit_window = caloTopology->getWindow(seed, sideSize, sideSize);
242 for(std::vector<DetId>::const_iterator window_itr = recHit_window.begin();
243 window_itr != recHit_window.end(); window_itr++){
244 reducedRecHit_EEmap.insert(*window_itr);
247 if(reducedRecHit_EEmap.size() < sc.
size())
248 std::cerr <<
"[WARNING] number of recHit in selected window < RECO SC recHits!" << std::endl;
251 const std::vector< std::pair<DetId, float> > & scHits = sc.
hitsAndFractions();
256 for(std::vector< std::pair<DetId, float> >::const_iterator scHit_itr = scHits.begin();
257 scHit_itr != scHits.end(); scHit_itr++){
259 reducedRecHit_EEmap.insert(scHit_itr->first);
264 if(reducedRecHit_EEmap.size() < sc.
size()){
265 if(eleIt->ecalDrivenSeed())
266 edm::LogError(
"AlCaSavedRecHitsEE") <<
"[ERROR] ecalDrivenSeed: number of saved recHits < RECO SC recHits!: " << reducedRecHit_EEmap.size() <<
" < " << sc.
size() << std::endl;
268 edm::LogWarning(
"AlCaSavedRecHitsEE") <<
"[WARNING] trackerDrivenSeed: number of saved recHits < RECO SC recHits!: " << reducedRecHit_EEmap.size() <<
" < " << sc.
size() << std::endl;
276 for(std::set<DetId>::const_iterator itr = reducedRecHit_EBmap.begin();
277 itr != reducedRecHit_EBmap.end(); itr++){
278 if (barrelHitsCollection->find(*itr) != barrelHitsCollection->end())
279 miniEBRecHitCollection->push_back(*(barrelHitsCollection->find(*itr)));
283 recHits_itr != barrelHitsCollection->end();
285 miniEBRecHitCollection->push_back(*recHits_itr);
290 for(std::set<DetId>::const_iterator itr = reducedRecHit_EEmap.begin();
291 itr != reducedRecHit_EEmap.end(); itr++){
292 if (endcapHitsCollection->find(*itr) != endcapHitsCollection->end())
293 miniEERecHitCollection->push_back(*(endcapHitsCollection->find(*itr)));
299 std::cout <<
"nEle_EB= " << nEle_EB <<
"\tnEle_EE = " << nEle_EE << std::endl;
300 if(nEle_EB > 0 && miniEBRecHitCollection->size() < (
unsigned int)
phiSize_*
etaSize_)
301 edm::LogError(
"AlCaECALRecHitReducerError") <<
"Size EBRecHitCollection < " <<
phiSize_*etaSize_ <<
": " << miniEBRecHitCollection->size() ;
306 if(nEle_EE > 0 && miniEERecHitCollection->size() < (
unsigned int )side*side)
307 edm::LogError(
"AlCaECALRecHitReducerError") <<
"Size EERecHitCollection < " << side*side <<
": " << miniEERecHitCollection->size() ;
314 iEvent.
put( weight,
"weight");
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
producer
#define DEFINE_FWK_MODULE(type)
edm::InputTag ebRecHitsLabel_
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
edm::InputTag eeRecHitsLabel_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
int iphi() const
get the crystal iphi
std::string alcaBarrelHitsCollection_
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
int ieta() const
get the crystal ieta
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
AlCaECALRecHitReducer(const edm::ParameterSet &)
ctor
std::string alcaEndcapHitsCollection_
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
const CaloClusterPtr & seed() const
seed BasicCluster
edm::InputTag electronLabel_