CMS 3D CMS Logo

ProducerAnalyzer.cc
Go to the documentation of this file.
1 // system include files
2 
3 // user include files
4 
18 
19 using namespace reco;
20 
21 namespace cms {
22 
23  //
24  // constructors and destructor
25  //
26  ProducerAnalyzer::ProducerAnalyzer(const edm::ParameterSet& iConfig) {
27  // get name of output file with histogramms
28 
29  nameProd_ = iConfig.getUntrackedParameter<std::string>("nameProd");
30  jetCalo_ = iConfig.getUntrackedParameter<std::string>("jetCalo", "GammaJetJetBackToBackCollection");
31  gammaClus_ = iConfig.getUntrackedParameter<std::string>("gammaClus", "GammaJetGammaBackToBackCollection");
32  ecalInput_ = iConfig.getUntrackedParameter<std::string>("ecalInput", "GammaJetEcalRecHitCollection");
33  hbheInput_ = iConfig.getUntrackedParameter<std::string>("hbheInput");
34  hoInput_ = iConfig.getUntrackedParameter<std::string>("hoInput");
35  hfInput_ = iConfig.getUntrackedParameter<std::string>("hfInput");
36  Tracks_ = iConfig.getUntrackedParameter<std::string>("Tracks", "GammaJetTracksCollection");
37 
38  tok_hovar_ = consumes<HOCalibVariableCollection>(edm::InputTag(nameProd_, hoInput_));
39  tok_horeco_ = consumes<HORecHitCollection>(edm::InputTag("horeco"));
40  tok_ho_ = consumes<HORecHitCollection>(edm::InputTag(hoInput_));
41  tok_hoProd_ = consumes<HORecHitCollection>(edm::InputTag(nameProd_, hoInput_));
42 
43  tok_hf_ = consumes<HFRecHitCollection>(edm::InputTag(hfInput_));
44 
45  tok_jets_ = consumes<reco::CaloJetCollection>(edm::InputTag(nameProd_, jetCalo_));
46  tok_gamma_ = consumes<reco::SuperClusterCollection>(edm::InputTag(nameProd_, gammaClus_));
47  tok_muons_ = consumes<reco::MuonCollection>(edm::InputTag(nameProd_, "SelectedMuons"));
48  tok_ecal_ = consumes<EcalRecHitCollection>(edm::InputTag(nameProd_, ecalInput_));
49  tok_tracks_ = consumes<reco::TrackCollection>(edm::InputTag(nameProd_, Tracks_));
50 
51  tok_hbheProd_ = consumes<HBHERecHitCollection>(edm::InputTag(nameProd_, hbheInput_));
52  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag(hbheInput_));
53 
54  tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
55  }
56 
57  ProducerAnalyzer::~ProducerAnalyzer() {
58  // do anything here that needs to be done at desctruction time
59  // (e.g. close files, deallocate resources etc.)
60  }
61 
63 
64  void ProducerAnalyzer::endJob() {}
65 
66  //
67  // member functions
68  //
69 
70  // ------------ method called to produce the data ------------
72  using namespace edm;
73 
74  const CaloGeometry* geo = &(iSetup.getData(tok_geom_));
75 
76  std::vector<StableProvenance const*> theProvenance;
77  iEvent.getAllStableProvenance(theProvenance);
78  for (auto const& provenance : theProvenance) {
79  edm::LogVerbatim("HcalAlCa") << " Print all module/label names " << provenance->moduleName() << " "
80  << provenance->moduleLabel() << " " << provenance->productInstanceName();
81  }
82 
83  if (nameProd_ == "hoCalibProducer") {
85  iEvent.getByToken(tok_hovar_, ho);
86  const HOCalibVariableCollection Hitho = *(ho.product());
87  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
88  }
89 
90  if (nameProd_ == "ALCARECOMuAlZMuMu") {
92  iEvent.getByToken(tok_horeco_, ho);
93  const HORecHitCollection Hitho = *(ho.product());
94  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
96  iEvent.getByToken(tok_muons_, mucand);
97  edm::LogVerbatim("HcalAlCa") << " Size of muon collection " << mucand->size();
98  for (const auto& it : *(mucand.product())) {
99  TrackRef mu = it.combinedMuon();
100  edm::LogVerbatim("HcalAlCa") << " Pt muon " << mu->innerMomentum();
101  }
102  }
103 
104  if (nameProd_ != "IsoProd" && nameProd_ != "ALCARECOMuAlZMuMu" && nameProd_ != "hoCalibProducer") {
106  iEvent.getByToken(tok_hbhe_, hbhe);
107  const HBHERecHitCollection Hithbhe = *(hbhe.product());
108  edm::LogVerbatim("HcalAlCa") << " Size of HBHE " << (Hithbhe).size();
109 
111  iEvent.getByToken(tok_ho_, ho);
112  const HORecHitCollection Hitho = *(ho.product());
113  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
114 
116  iEvent.getByToken(tok_hf_, hf);
117  const HFRecHitCollection Hithf = *(hf.product());
118  edm::LogVerbatim("HcalAlCa") << " Size of HF " << (Hithf).size();
119  }
120  if (nameProd_ == "IsoProd") {
121  edm::LogVerbatim("HcalAlCa") << " We are here ";
123  iEvent.getByToken(tok_tracks_, tracks);
124 
125  edm::LogVerbatim("HcalAlCa") << " Tracks size " << (*tracks).size();
126  for (const auto& track : *(tracks.product())) {
127  edm::LogVerbatim("HcalAlCa") << " P track " << track.p() << " eta " << track.eta() << " phi " << track.phi()
128  << " Outer " << track.outerMomentum() << " " << track.outerPosition();
129  const TrackExtraRef& myextra = track.extra();
130  edm::LogVerbatim("HcalAlCa") << " Track extra " << myextra->outerMomentum() << " " << myextra->outerPosition();
131  }
132 
134  iEvent.getByToken(tok_ecal_, ecal);
135  const EcalRecHitCollection Hitecal = *(ecal.product());
136  edm::LogVerbatim("HcalAlCa") << " Size of Ecal " << (Hitecal).size();
137 
138  double energyECAL = 0.;
139  double energyHCAL = 0.;
140 
141  for (const auto& hite : *(ecal.product())) {
142  const GlobalPoint& posE = geo->getPosition(hite.detid());
143 
144  edm::LogVerbatim("HcalAlCa") << " Energy ECAL " << hite.energy() << " eta " << posE.eta() << " phi "
145  << posE.phi();
146 
147  energyECAL = energyECAL + hite.energy();
148  }
149 
151  iEvent.getByToken(tok_hbheProd_, hbhe);
152  const HBHERecHitCollection Hithbhe = *(hbhe.product());
153  edm::LogVerbatim("HcalAlCa") << " Size of HBHE " << (Hithbhe).size();
154 
155  for (const auto& hith : *(hbhe.product())) {
156  GlobalPoint posH =
157  (static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(hith.detid())))->getPosition(hith.detid());
158 
159  edm::LogVerbatim("HcalAlCa") << " Energy HCAL " << hith.energy() << " eta " << posH.eta() << " phi "
160  << posH.phi();
161 
162  energyHCAL = energyHCAL + hith.energy();
163  }
164 
165  edm::LogVerbatim("HcalAlCa") << " Energy ECAL " << energyECAL << " Energy HCAL " << energyHCAL;
166  }
167 
168  if (nameProd_ == "GammaJetProd" || nameProd_ == "DiJProd") {
169  edm::LogVerbatim("HcalAlCa") << " we are in GammaJetProd area ";
171  iEvent.getByToken(tok_ecal_, ecal);
172  edm::LogVerbatim("HcalAlCa") << " Size of ECAL " << (*ecal).size();
173 
175  iEvent.getByToken(tok_jets_, jets);
176  edm::LogVerbatim("HcalAlCa") << " Jet size " << (*jets).size();
177 
178  for (const auto& jet : *(jets.product())) {
179  edm::LogVerbatim("HcalAlCa") << " Et jet " << jet.et() << " eta " << jet.eta() << " phi " << jet.phi();
180  }
181 
183  iEvent.getByToken(tok_tracks_, tracks);
184  edm::LogVerbatim("HcalAlCa") << " Tracks size " << (*tracks).size();
185  }
186  if (nameProd_ == "GammaJetProd") {
188  iEvent.getByToken(tok_gamma_, eclus);
189  edm::LogVerbatim("HcalAlCa") << " GammaClus size " << (*eclus).size();
190  for (const auto& iclus : *(eclus.product())) {
191  edm::LogVerbatim("HcalAlCa") << " Et gamma " << iclus.energy() / cosh(iclus.eta()) << " eta " << iclus.eta()
192  << " phi " << iclus.phi();
193  }
194  }
195  }
196  //define this as a plug-in
197  //DEFINE_FWK_MODULE(ProducerAnalyzer)
198 } // namespace cms
TrackExtra.h
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
Muon.h
MessageLogger.h
TrackExtraFwd.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
HOCalibVariableCollection
std::vector< HOCalibVariables > HOCalibVariableCollection
collection of HOcalibration variabale
Definition: HOCalibVariableCollection.h:12
edm
HLT enums.
Definition: AlignableModifier.h:19
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
edm::SortedCollection
Definition: SortedCollection.h:49
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
TransientTrack.h
edm::Handle
Definition: AssociativeIterator.h:50
HcalGeometry.h
edm::Ref< TrackCollection >
spr::energyHCAL
double energyHCAL(std::vector< DetId > &vdets, edm::Handle< T > &hits, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int useRaw=0, bool debug=false)
CaloGeometry
Definition: CaloGeometry.h:21
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
TrackProducerBase.h
Point3DBase< float, GlobalTag >
spr::energyECAL
double energyECAL(std::vector< DetId > &vdets, edm::Handle< T > &hitsEB, edm::Handle< T > &hitsEE, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)
CaloGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
iEvent
int iEvent
Definition: GenABIO.cc:224
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:57
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
HOCalibVariables.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
metsig::jet
Definition: SignAlgoResolutions.h:47
CaloGeometry.h
ProducerAnalyzer.h
bsc_activity_cfg.ecal
ecal
Definition: bsc_activity_cfg.py:25
edm::Event
Definition: Event.h:73
GlobalPoint.h
StableProvenance.h
edm::InputTag
Definition: InputTag.h:15
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443