CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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>
16 
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:
48  }
49 
50  // Virtual destructor needed.
52  if (verbosity > 0) {
53  std::cout << "ReconstructerFP420:delete FP420RecoMain" << std::endl;
54  }
55  delete sFP420RecoMain_;
56  }
57 
58  //Get at the beginning
60  if (verbosity > 0) {
61  std::cout << "ReconstructerFP420:BeginJob method " << std::endl;
62  }
63  }
64 
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 
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();
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
T getUntrackedParameter(std::string const &, T const &) const
std::pair< ContainerIterator, ContainerIterator > Range
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
static std::string const input
Definition: EdmProvDump.cc:47
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
FP420RecoMain * sFP420RecoMain_
void produce(edm::Event &e, const edm::EventSetup &c) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
void run(edm::Handle< TrackCollectionFP420 > &input, RecoCollectionFP420 *toutput, double VtxX, double VtxY, double VtxZ)
Runs the algorithm.
Log< level::Info, false > LogInfo
tuple inputRange
Definition: pileupCalc.py:168
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
tuple cout
Definition: gather_cfg.py:144