53 ecal_parts_.push_back(
"Barrel");
54 ecal_parts_.push_back(
"Endcap");
56 histfile_ =
new TFile(
"histos.root",
"RECREATE");
57 tree_ =
new TTree(
"TPGtree",
"TPGtree");
58 tree_->Branch(
"iphi", &iphi_,
"iphi/I");
59 tree_->Branch(
"ieta", &ieta_,
"ieta/I");
60 tree_->Branch(
"eRec", &eRec_,
"eRec/F");
61 tree_->Branch(
"tpgADC", &tpgADC_,
"tpgADC/I");
62 tree_->Branch(
"tpgGeV", &tpgGeV_,
"tpgGeV/F");
63 tree_->Branch(
"ttf", &ttf_,
"ttf/I");
64 tree_->Branch(
"fg", &fg_,
"fg/I");
65 for (
unsigned int i = 0;
i < 2; ++
i) {
66 ecal_et_[
i] =
new TH1I(ecal_parts_[
i].c_str(),
"Et", 255, 0, 255);
68 sprintf(title,
"%s_ttf", ecal_parts_[
i].c_str());
69 ecal_tt_[
i] =
new TH1I(title,
"TTF", 10, 0, 10);
70 sprintf(title,
"%s_fgvb", ecal_parts_[
i].c_str());
71 ecal_fgvb_[
i] =
new TH1I(title,
"FGVB", 10, 0, 10);
78 new TH2F(
"TP_vs_RecHit",
"TP vs rechit", 256, -1, 255, 255, 0, 255);
79 hTPoverRechit_ =
new TH1F(
"TP_over_RecHit",
"TP over rechit", 500, 0, 4);
119 ecal_tt_[subdet]->Fill(d.
ttFlag());
127 iEvent.
getByLabel(rechits_labelEB_, rechit_EB_col);
130 iEvent.
getByLabel(rechits_labelEE_, rechit_EE_col);
137 theEndcapGeometry_handle);
139 theBarrelGeometry_handle);
142 theEndcapGeometry_handle.
product();
144 theBarrelGeometry_handle.
product();
148 map<EcalTrigTowerDetId, float> mapTow_Et;
150 for (
unsigned int i = 0;
i < rechit_EB_col.
product()->
size();
i++) {
154 float Etsum = ((*rechit_EB_col.
product())[
i].energy()) *
sin(theta);
155 bool test_alreadyin =
false;
156 map<EcalTrigTowerDetId, float>::iterator ittest = mapTow_Et.find(towid1);
157 if (ittest != mapTow_Et.end())
158 test_alreadyin =
true;
161 unsigned int j =
i + 1;
162 bool loopend =
false;
163 unsigned int count = 0;
164 while (j < rechit_EB_col.
product()->
size() && !loopend) {
168 if (towid1 == towid2) {
170 theBarrelGeometry->
getGeometry(myid2)->getPosition().theta();
171 Etsum += (*rechit_EB_col.
product())[j].energy() *
sin(theta);
177 mapTow_Et.insert(pair<EcalTrigTowerDetId, float>(towid1, Etsum));
180 for (
unsigned int i = 0;
i < rechit_EE_col.
product()->
size();
i++) {
184 float Etsum = (*rechit_EE_col.
product())[
i].energy() *
sin(theta);
185 bool test_alreadyin =
false;
186 map<EcalTrigTowerDetId, float>::iterator ittest = mapTow_Et.find(towid1);
187 if (ittest != mapTow_Et.end())
188 test_alreadyin =
true;
191 unsigned int j =
i + 1;
192 bool loopend =
false;
193 unsigned int count = 0;
194 while (j < rechit_EE_col.
product()->
size() && !loopend) {
197 if (towid1 == towid2) {
199 theEndcapGeometry->
getGeometry(myid2)->getPosition().theta();
200 Etsum += (*rechit_EE_col.
product())[j].energy() *
sin(theta);
208 mapTow_Et.insert(pair<EcalTrigTowerDetId, float>(towid1, Etsum));
216 map<EcalTrigTowerDetId, float>::iterator it = mapTow_Et.find(TPtowid);
220 iphi_ = TPtowid.
iphi();
221 ieta_ = TPtowid.
ieta();
226 if (it != mapTow_Et.end()) {
227 hTPvsRechit_->Fill(it->second, Et);
228 hTPoverRechit_->Fill(Et / it->second);
236 for (
unsigned int i = 0;
i < 2; ++
i) {
237 ecal_et_[
i]->Write();
238 ecal_tt_[
i]->Write();
239 ecal_fgvb_[
i]->Write();
242 hTPvsRechit_->Write();
243 hTPoverRechit_->Write();
T getParameter(std::string const &) const
void setEventSetup(const edm::EventSetup &evtSetup)
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
int ieta() const
get the tower ieta
void analyze(const edm::Event &, const edm::EventSetup &) override
int compressedEt() const
get the encoded/compressed Et of interesting sample
~EcalTrigPrimAnalyzer() override
int ietaAbs() const
get the absolute value of the tower ieta
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
EcalTrigPrimAnalyzer(const edm::ParameterSet &)
int iphi() const
get the tower iphi
const EcalTrigTowerDetId & id() const
T const * product() const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
bool fineGrain() const
get the fine-grain bit of interesting sample
int ttFlag() const
get the Trigger tower Flag of interesting sample
T const * product() const