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
|
// -*- C++ -*-
//
// Package: CaloPropagationTest
// Class: CaloPropagationTest
//
/**\class CaloPropagationTest CaloPropagationTest.cc test/CaloPropagationTest.cc
Description: <one line class summary>
Implementation:
<Notes on implementation>
*/
// system include files
#include <memory>
#include <iostream>
#include <fstream>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "Calibration/IsolatedParticles/interface/CaloPropagateTrack.h"
#include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/CaloTopology/interface/CaloTowerConstituentsMap.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
class CaloPropagationTest : public edm::one::EDAnalyzer<> {
public:
explicit CaloPropagationTest(const edm::ParameterSet&);
~CaloPropagationTest() override;
void beginJob() override {}
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}
private:
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> tok_magField_;
const edm::ESGetToken<CaloTowerConstituentsMap, CaloGeometryRecord> tok_ctmap_;
};
CaloPropagationTest::CaloPropagationTest(const edm::ParameterSet&)
: tok_geom_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
tok_magField_(esConsumes<MagneticField, IdealMagneticFieldRecord>()),
tok_ctmap_(esConsumes<CaloTowerConstituentsMap, CaloGeometryRecord>()) {}
CaloPropagationTest::~CaloPropagationTest() {}
// ------------ method called to produce the data ------------
void CaloPropagationTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
const CaloGeometry* geo = &iSetup.getData(tok_geom_);
const HcalGeometry* gHB = (const HcalGeometry*)(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
const MagneticField* bField = &iSetup.getData(tok_magField_);
const CaloTowerConstituentsMap* ctmap = &iSetup.getData(tok_ctmap_);
const std::vector<DetId>& ids = gHB->getValidDetIds(DetId::Hcal, 0);
bool debug(false);
for (const auto& id : ids) {
if (id.det() == DetId::Hcal && ((id.subdetId() == HcalBarrel) || (id.subdetId() == HcalEndcap))) {
const HcalDetId hid(id);
std::pair<DetId, bool> info = spr::propagateIdECAL(hid, geo, bField, debug);
if (!info.second) {
edm::LogVerbatim("IsoTrack") << "No valid Ecal Id found for " << hid;
} else {
CaloTowerDetId tower = ctmap->towerOf(id);
std::vector<DetId> idts = ctmap->constituentsOf(tower);
std::string found("not found");
for (auto idt : idts) {
if (info.first == idt) {
found = "found";
break;
}
}
if ((info.first).subdetId() == EcalBarrel) {
edm::LogVerbatim("IsoTrack") << "Find " << EBDetId(info.first) << " as partner of " << hid
<< " and mtaching with tower " << found;
} else {
edm::LogVerbatim("IsoTrack") << "Find " << EEDetId(info.first) << " as partner of " << hid
<< " and mtaching with tower " << found;
}
}
}
}
}
//define this as a plug-in
DEFINE_FWK_MODULE(CaloPropagationTest);
|