Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
RecoRomanPot
RecoFP420
plugins
ReconstructerFP420.cc
Go to the documentation of this file.
1
// File: ReconstructerFP420.cc
3
// Date: 11.2007
4
// Description: ReconstructerFP420 for FP420
5
// Modifications:
7
#include <memory>
8
#include <string>
9
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
10
#include "
FWCore/Framework/interface/EDProducer.h
"
11
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
12
#include "
FWCore/Framework/interface/Event.h
"
13
#include "
FWCore/Framework/interface/MakerMacros.h
"
14
#include "
FWCore/Framework/interface/EventSetup.h
"
15
#include "
FWCore/Framework/interface/ESHandle.h
"
16
17
#include "
RecoRomanPot/RecoFP420/interface/ReconstructerFP420.h
"
18
#include "
DataFormats/FP420Cluster/interface/TrackCollectionFP420.h
"
19
#include "
DataFormats/FP420Cluster/interface/RecoCollectionFP420.h
"
20
21
//#include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
22
//#include "HepMC/GenEvent.h"
23
24
#include <iostream>
25
using namespace
std;
26
27
//
28
namespace
cms {
29
ReconstructerFP420::ReconstructerFP420(
const
edm::ParameterSet
& conf) : conf_(conf) {
30
edm::LogInfo
(
"ReconstructerFP420 "
) <<
"Enter the FP420 Reco constructer"
;
31
32
verbosity
=
conf_
.
getUntrackedParameter
<
int
>(
"VerbosityLevel"
);
33
if
(
verbosity
> 0) {
34
std::cout
<<
"Constructor of ReconstructerFP420"
<< std::endl;
35
}
36
37
std::string
alias
(conf.
getParameter
<
std::string
>(
"@module_label"
));
38
39
produces<RecoCollectionFP420>().setBranchAlias(alias);
40
41
trackerContainers
.clear();
42
trackerContainers
= conf.
getParameter
<std::vector<std::string> >(
"ROUList"
);
43
VtxFlag
= conf.
getParameter
<
int
>(
"VtxFlagGenRec"
);
44
m_genReadoutName
= conf.
getParameter
<
string
>(
"genReadoutName"
);
45
46
// Initialization:
47
sFP420RecoMain_
=
new
FP420RecoMain
(
conf_
);
48
}
49
50
// Virtual destructor needed.
51
ReconstructerFP420::~ReconstructerFP420
() {
52
if
(
verbosity
> 0) {
53
std::cout
<<
"ReconstructerFP420:delete FP420RecoMain"
<< std::endl;
54
}
55
delete
sFP420RecoMain_
;
56
}
57
58
//Get at the beginning
59
void
ReconstructerFP420::beginJob
() {
60
if
(
verbosity
> 0) {
61
std::cout
<<
"ReconstructerFP420:BeginJob method "
<< std::endl;
62
}
63
}
64
65
void
ReconstructerFP420::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
66
// beginJob;
67
// be lazy and include the appropriate namespaces
68
using namespace
edm;
69
using namespace
std;
70
71
// Get input
72
73
// Vtx info:
74
75
// define GEN Vtx of Signal
76
double
vtxGenX = 0.;
77
double
vtxGenY = 0.;
78
double
vtxGenZ = 0.;
79
80
/*
81
if(VtxFlag == 1) {
82
83
Handle<HepMCProduct> EvtHandle;
84
try{
85
iEvent.getByLabel(m_genReadoutName,EvtHandle);
86
}catch(const Exception&){
87
if(verbosity>0){
88
std::cout << "no HepMCProduct found"<< std::endl;
89
}
90
}
91
92
const HepMC::GenEvent* evt = EvtHandle->GetEvent() ;
93
HepMC::GenParticle* proton1 = 0;
94
HepMC::GenParticle* proton2 = 0;
95
double partmomcut=4000.;
96
double pz1max = 0.;
97
double pz2min = 0.;
98
for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) {
100
double pz = (*p)->momentum().pz();
101
// if (((*p)->pdg_id() == ipdgproton)&&((*p)->status() == 1)&&(pz > partmomcut)){
102
if( pz > partmomcut){
103
if(pz > pz1max){
104
proton1 = *p;pz1max=pz;
105
}
106
}
107
// else if(( (*p)->pdg_id() == ipdgproton)&&((*p)->status() == 1)&&(pz < -1.*partmomcut)) {
108
else if(pz < -1.*partmomcut) {
109
if(pz < pz2min){
110
proton2 = *p;pz2min=pz;
111
}
112
}
113
114
}// for
115
if(proton1 && !proton2){
116
vtxGenX = (proton1)->production_vertex()->position().x();
117
vtxGenY = (proton1)->production_vertex()->position().y();
118
vtxGenZ = (proton1)->production_vertex()->position().z();
119
}
120
else if(proton2 && !proton1){
121
vtxGenX = (proton2)->production_vertex()->position().x();
122
vtxGenY = (proton2)->production_vertex()->position().y();
123
vtxGenZ = (proton2)->production_vertex()->position().z();
124
}
125
else if(proton1 && proton2){
126
if(abs((proton1)->momentum().pz()) >= abs((proton2)->momentum().pz()) ) {
127
vtxGenX = (proton1)->production_vertex()->position().x();
128
vtxGenY = (proton1)->production_vertex()->position().y();
129
vtxGenZ = (proton1)->production_vertex()->position().z();
130
}
131
else {
132
vtxGenX = (proton2)->production_vertex()->position().x();
133
vtxGenY = (proton2)->production_vertex()->position().y();
134
vtxGenZ = (proton2)->production_vertex()->position().z();
135
}
136
}
137
}// if(VtxFlag == 1
138
139
*/
140
141
double
VtxX = 0.;
142
double
VtxY = 0.;
143
double
VtxZ = 0.;
144
if
(
VtxFlag
== 1) {
145
VtxX = vtxGenX;
// mm
146
VtxY = vtxGenY;
// mm
147
VtxZ = vtxGenZ;
// mm
148
}
149
150
// track collection:
151
//A
152
// edm::Handle<ClusterCollectionFP420> icf_simhit;
153
/*
154
Handle<ClusterCollectionFP420> cf_simhit;
155
std::vector<const ClusterCollectionFP420 *> cf_simhitvec;
156
for(uint32_t i = 0; i< trackerContainers.size();i++){
157
iEvent.getByLabel( trackerContainers[i], cf_simhit);
158
cf_simhitvec.push_back(cf_simhit.product()); }
159
std::unique_ptr<ClusterCollectionFP420 > input(new DigiCollectionFP420(cf_simhitvec));
160
*/
161
162
//B
163
164
Handle<TrackCollectionFP420>
input
;
165
iEvent.
getByLabel
(
trackerContainers
[0],
input
);
166
167
// Step C: create empty output collection
168
auto
toutput = std::make_unique<RecoCollectionFP420>();
169
170
// put zero to container info from the beginning (important! because not any detID is updated with coming of new event !!!!!!
171
// clean info of container from previous event
172
173
std::vector<RecoFP420> collector;
174
collector.clear();
175
RecoCollectionFP420::Range
inputRange
;
176
inputRange
.first = collector.begin();
177
inputRange
.second = collector.end();
178
179
unsigned
int
detID = 0;
180
toutput->putclear(
inputRange
, detID);
181
182
unsigned
int
StID = 1;
183
toutput->putclear(
inputRange
, StID);
184
StID = 2;
185
toutput->putclear(
inputRange
, StID);
186
187
// !!!!!!
188
// if we want to keep Reco container/Collection for one event ---> uncomment the line below and vice versa
189
toutput->clear();
//container_.clear() --> start from the beginning of the container
190
191
// RUN now: !!!!!!
192
// startFP420RecoMain_.run(input, toutput);
193
sFP420RecoMain_
->
run
(
input
, toutput.get(), VtxX, VtxY, VtxZ);
194
// std::cout <<"======= ReconstructerFP420: end of produce " << endl;
195
196
// Step D: write output to file
197
if
(
verbosity
> 0) {
198
std::cout
<<
"ReconstructerFP420: iEvent.put(std::move(toutput)"
<< std::endl;
199
}
200
iEvent.
put
(
std::move
(toutput));
201
if
(
verbosity
> 0) {
202
std::cout
<<
"ReconstructerFP420: iEvent.put(std::move(toutput) DONE"
<< std::endl;
203
}
204
}
//produce
205
206
}
// namespace cms
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
RecoCollectionFP420::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition:
RecoCollectionFP420.h:12
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:133
cms::ReconstructerFP420::VtxFlag
int VtxFlag
Definition:
ReconstructerFP420.h:42
HLT_FULL_cff.alias
tuple alias
Definition:
HLT_FULL_cff.py:9825
Event.h
MakerMacros.h
edm::Handle
Definition:
AssociativeIterator.h:50
EventSetup.h
cms::ReconstructerFP420::beginJob
void beginJob() override
Definition:
ReconstructerFP420.cc:59
Frameworkfwd.h
cms::ReconstructerFP420::~ReconstructerFP420
~ReconstructerFP420() override
Definition:
ReconstructerFP420.cc:51
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
input
static std::string const input
Definition:
EdmProvDump.cc:47
ParameterSet.h
cms::ReconstructerFP420::m_genReadoutName
std::string m_genReadoutName
Definition:
ReconstructerFP420.h:43
iEvent
int iEvent
Definition:
GenABIO.cc:224
cms::ReconstructerFP420::trackerContainers
vstring trackerContainers
Definition:
ReconstructerFP420.h:38
cms::ReconstructerFP420::verbosity
int verbosity
Definition:
ReconstructerFP420.h:41
ReconstructerFP420.h
eostools.move
def move
Definition:
eostools.py:511
ESHandle.h
cms::ReconstructerFP420::sFP420RecoMain_
FP420RecoMain * sFP420RecoMain_
Definition:
ReconstructerFP420.h:40
edm::EventSetup
Definition:
EventSetup.h:59
TrackCollectionFP420.h
cms::ReconstructerFP420::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition:
ReconstructerFP420.cc:65
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:500
FP420RecoMain::run
void run(edm::Handle< TrackCollectionFP420 > &input, RecoCollectionFP420 *toutput, double VtxX, double VtxY, double VtxZ)
Runs the algorithm.
Definition:
FP420RecoMain.cc:59
cms::ReconstructerFP420::conf_
edm::ParameterSet conf_
Definition:
ReconstructerFP420.h:37
edm::LogInfo
Log< level::Info, false > LogInfo
Definition:
MessageLogger.h:125
EDProducer.h
RecoCollectionFP420.h
pileupCalc.inputRange
tuple inputRange
Definition:
pileupCalc.py:168
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
edm::ParameterSet
Definition:
ParameterSet.h:47
gather_cfg.cout
tuple cout
Definition:
gather_cfg.py:144
FP420RecoMain
Definition:
FP420RecoMain.h:22
edm::Event
Definition:
Event.h:73
Generated for CMSSW Reference Manual by
1.8.5