CMS 3D CMS Logo

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>
15 
19 
20 //#include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
21 //#include "HepMC/GenEvent.h"
22 
23 #include <iostream>
24 using namespace std;
25 
26 //
27 namespace cms {
28  ReconstructerFP420::ReconstructerFP420(const edm::ParameterSet& conf) : conf_(conf) {
29  edm::LogInfo("ReconstructerFP420 ") << "Enter the FP420 Reco constructer";
30 
31  verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
32  if (verbosity > 0) {
33  std::cout << "Constructor of ReconstructerFP420" << std::endl;
34  }
35 
36  std::string alias(conf.getParameter<std::string>("@module_label"));
37 
38  produces<RecoCollectionFP420>().setBranchAlias(alias);
39 
40  trackerContainers.clear();
41  trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
42  VtxFlag = conf.getParameter<int>("VtxFlagGenRec");
43  m_genReadoutName = conf.getParameter<string>("genReadoutName");
44 
45  // Initialization:
47  }
48 
49  // Virtual destructor needed.
51  if (verbosity > 0) {
52  std::cout << "ReconstructerFP420:delete FP420RecoMain" << std::endl;
53  }
54  delete sFP420RecoMain_;
55  }
56 
58  // beginJob;
59  // be lazy and include the appropriate namespaces
60  using namespace edm;
61  using namespace std;
62 
63  // Get input
64 
65  // Vtx info:
66 
67  // define GEN Vtx of Signal
68  double vtxGenX = 0.;
69  double vtxGenY = 0.;
70  double vtxGenZ = 0.;
71 
72  /*
73  if(VtxFlag == 1) {
74 
75  Handle<HepMCProduct> EvtHandle;
76  try{
77  iEvent.getByLabel(m_genReadoutName,EvtHandle);
78  }catch(const Exception&){
79  if(verbosity>0){
80  std::cout << "no HepMCProduct found"<< std::endl;
81  }
82  }
83 
84  const HepMC::GenEvent* evt = EvtHandle->GetEvent() ;
85  HepMC::GenParticle* proton1 = 0;
86  HepMC::GenParticle* proton2 = 0;
87  double partmomcut=4000.;
88  double pz1max = 0.;
89  double pz2min = 0.;
90  for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) {
92  double pz = (*p)->momentum().pz();
93  // if (((*p)->pdg_id() == ipdgproton)&&((*p)->status() == 1)&&(pz > partmomcut)){
94  if( pz > partmomcut){
95  if(pz > pz1max){
96  proton1 = *p;pz1max=pz;
97  }
98  }
99  // else if(( (*p)->pdg_id() == ipdgproton)&&((*p)->status() == 1)&&(pz < -1.*partmomcut)) {
100  else if(pz < -1.*partmomcut) {
101  if(pz < pz2min){
102  proton2 = *p;pz2min=pz;
103  }
104  }
105 
106  }// for
107  if(proton1 && !proton2){
108  vtxGenX = (proton1)->production_vertex()->position().x();
109  vtxGenY = (proton1)->production_vertex()->position().y();
110  vtxGenZ = (proton1)->production_vertex()->position().z();
111  }
112  else if(proton2 && !proton1){
113  vtxGenX = (proton2)->production_vertex()->position().x();
114  vtxGenY = (proton2)->production_vertex()->position().y();
115  vtxGenZ = (proton2)->production_vertex()->position().z();
116  }
117  else if(proton1 && proton2){
118  if(abs((proton1)->momentum().pz()) >= abs((proton2)->momentum().pz()) ) {
119  vtxGenX = (proton1)->production_vertex()->position().x();
120  vtxGenY = (proton1)->production_vertex()->position().y();
121  vtxGenZ = (proton1)->production_vertex()->position().z();
122  }
123  else {
124  vtxGenX = (proton2)->production_vertex()->position().x();
125  vtxGenY = (proton2)->production_vertex()->position().y();
126  vtxGenZ = (proton2)->production_vertex()->position().z();
127  }
128  }
129  }// if(VtxFlag == 1
130 
131 */
132 
133  double VtxX = 0.;
134  double VtxY = 0.;
135  double VtxZ = 0.;
136  if (VtxFlag == 1) {
137  VtxX = vtxGenX; // mm
138  VtxY = vtxGenY; // mm
139  VtxZ = vtxGenZ; // mm
140  }
141 
142  // track collection:
143  //A
144  // edm::Handle<ClusterCollectionFP420> icf_simhit;
145  /*
146  Handle<ClusterCollectionFP420> cf_simhit;
147  std::vector<const ClusterCollectionFP420 *> cf_simhitvec;
148  for(uint32_t i = 0; i< trackerContainers.size();i++){
149  iEvent.getByLabel( trackerContainers[i], cf_simhit);
150  cf_simhitvec.push_back(cf_simhit.product()); }
151  std::unique_ptr<ClusterCollectionFP420 > input(new DigiCollectionFP420(cf_simhitvec));
152  */
153 
154  //B
155 
157  iEvent.getByLabel(trackerContainers[0], input);
158 
159  // Step C: create empty output collection
160  auto toutput = std::make_unique<RecoCollectionFP420>();
161 
162  // put zero to container info from the beginning (important! because not any detID is updated with coming of new event !!!!!!
163  // clean info of container from previous event
164 
165  std::vector<RecoFP420> collector;
166  collector.clear();
168  inputRange.first = collector.begin();
169  inputRange.second = collector.end();
170 
171  unsigned int detID = 0;
172  toutput->putclear(inputRange, detID);
173 
174  unsigned int StID = 1;
175  toutput->putclear(inputRange, StID);
176  StID = 2;
177  toutput->putclear(inputRange, StID);
178 
179  // !!!!!!
180  // if we want to keep Reco container/Collection for one event ---> uncomment the line below and vice versa
181  toutput->clear(); //container_.clear() --> start from the beginning of the container
182 
183  // RUN now: !!!!!!
184  // startFP420RecoMain_.run(input, toutput);
185  sFP420RecoMain_->run(input, toutput.get(), VtxX, VtxY, VtxZ);
186  // std::cout <<"======= ReconstructerFP420: end of produce " << endl;
187 
188  // Step D: write output to file
189  if (verbosity > 0) {
190  std::cout << "ReconstructerFP420: iEvent.put(std::move(toutput)" << std::endl;
191  }
192  iEvent.put(std::move(toutput));
193  if (verbosity > 0) {
194  std::cout << "ReconstructerFP420: iEvent.put(std::move(toutput) DONE" << std::endl;
195  }
196  } //produce
197 
198 } // namespace cms
std::pair< ContainerIterator, ContainerIterator > Range
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static std::string const input
Definition: EdmProvDump.cc:47
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
FP420RecoMain * sFP420RecoMain_
void produce(edm::Event &e, const edm::EventSetup &c) override
void run(edm::Handle< TrackCollectionFP420 > &input, RecoCollectionFP420 *toutput, double VtxX, double VtxY, double VtxZ)
Runs the algorithm.
Namespace of DDCMS conversion namespace.
Log< level::Info, false > LogInfo
HLT enums.
def move(src, dest)
Definition: eostools.py:511