1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
// -*- C++ -*-
//
// Package: BeamSplash
// Class: BeamSPlash
//
//
// Original Author: Luca Malgeri
#include <iostream>
#include <memory>
#include <vector>
#include <map>
#include <set>
// user include files
#include "DPGAnalysis/Skims/interface/BeamSplash.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
using namespace edm;
using namespace std;
BeamSplash::BeamSplash(const edm::ParameterSet& iConfig) {
EBRecHitCollection_ = iConfig.getParameter<edm::InputTag>("ebrechitcollection");
EERecHitCollection_ = iConfig.getParameter<edm::InputTag>("eerechitcollection");
HBHERecHitCollection_ = iConfig.getParameter<edm::InputTag>("hbherechitcollection");
EnergyCutTot = iConfig.getUntrackedParameter<double>("energycuttot");
EnergyCutEcal = iConfig.getUntrackedParameter<double>("energycutecal");
EnergyCutHcal = iConfig.getUntrackedParameter<double>("energycuthcal");
applyfilter = iConfig.getUntrackedParameter<bool>("applyfilter", true);
}
BeamSplash::~BeamSplash() {}
bool BeamSplash::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
bool accepted = false;
bool acceptedtot = false;
bool acceptedEcal = false;
bool acceptedHcal = false;
int ievt = iEvent.id().event();
int irun = iEvent.id().run();
int ils = iEvent.luminosityBlock();
int ibx = iEvent.bunchCrossing();
double totene = 0;
double ecalene = 0;
double hcalene = 0;
Handle<EBRecHitCollection> pEBRecHits;
Handle<EERecHitCollection> pEERecHits;
Handle<HBHERecHitCollection> pHBHERecHits;
const EBRecHitCollection* EBRecHits = nullptr;
const EERecHitCollection* EERecHits = nullptr;
const HBHERecHitCollection* HBHERecHits = nullptr;
if (!EBRecHitCollection_.label().empty() && !EBRecHitCollection_.instance().empty()) {
iEvent.getByLabel(EBRecHitCollection_, pEBRecHits);
if (pEBRecHits.isValid()) {
EBRecHits = pEBRecHits.product(); // get a ptr to the product
} else {
edm::LogError("EcalRecHitError") << "Error! can't get the product " << EBRecHitCollection_.label();
}
}
if (!EERecHitCollection_.label().empty() && !EERecHitCollection_.instance().empty()) {
iEvent.getByLabel(EERecHitCollection_, pEERecHits);
if (pEERecHits.isValid()) {
EERecHits = pEERecHits.product(); // get a ptr to the product
} else {
edm::LogError("EcalRecHitError") << "Error! can't get the product " << EERecHitCollection_.label();
}
}
if (!HBHERecHitCollection_.label().empty()) {
iEvent.getByLabel(HBHERecHitCollection_, pHBHERecHits);
if (pHBHERecHits.isValid()) {
HBHERecHits = pHBHERecHits.product(); // get a ptr to the product
} else {
edm::LogError("HcalRecHitError") << "Error! can't get the product " << HBHERecHitCollection_.label();
}
}
// now sum over them
if (EBRecHits) {
for (EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it) {
totene += it->energy();
ecalene += it->energy();
}
}
if (EERecHits) {
for (EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it) {
totene += it->energy();
ecalene += it->energy();
}
}
if (HBHERecHits) {
for (HBHERecHitCollection::const_iterator it = HBHERecHits->begin(); it != HBHERecHits->end(); ++it) {
totene += it->energy();
hcalene += it->energy();
}
}
if (totene > EnergyCutTot)
acceptedtot = true;
if (ecalene > EnergyCutEcal)
acceptedEcal = true;
if (hcalene > EnergyCutHcal)
acceptedHcal = true;
accepted = acceptedtot | acceptedEcal | acceptedHcal;
if (accepted) {
edm::LogVerbatim("BeamSplash") << "!!!!!!!BeamSplash!!!!!!!: run:" << irun << " event:" << ievt << " ls:" << ils
<< " bx= " << ibx << " totene=" << totene << " ecalene=" << ecalene
<< " hcalene=" << hcalene;
std::cout << "!!!!!!!BeamSplash!!!!!!!: run:" << irun << " event:" << ievt << " ls:" << ils << " bx= " << ibx
<< " totene=" << totene << " ecalene=" << ecalene << " hcalene=" << hcalene << std::endl;
}
if (applyfilter)
return accepted;
else
return true;
}
//define this as a plug-in
DEFINE_FWK_MODULE(BeamSplash);
|