CMS 3D CMS Logo

ClusterizerFP420.cc
Go to the documentation of this file.
1 // File: ClusterizerFP420.cc
3 // Date: 12.2006
4 // Description: ClusterizerFP420 for FP420
5 // Modifications:
7 #include <memory>
8 #include <string>
9 
16 
20 
22 //#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
23 
28 
29 //Random Number
33 #include "CLHEP/Random/RandomEngine.h"
34 
35 #include <cstdlib>
36 #include <iostream>
37 using namespace std;
38 
39 namespace cms {
40  ClusterizerFP420::ClusterizerFP420(const edm::ParameterSet& conf) {
41  std::string alias(conf.getParameter<std::string>("@module_label"));
42 
43  produces<ClusterCollectionFP420>().setBranchAlias(alias);
44 
45  trackerContainers.clear();
46  trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
47 
48  verbosity = conf.getUntrackedParameter<int>("VerbosityLevel");
49  dn0 = conf.getParameter<int>("NumberFP420Detectors");
50  sn0 = conf.getParameter<int>("NumberFP420Stations");
51  pn0 = conf.getParameter<int>("NumberFP420SPlanes");
52  rn0 = 7;
53  if (verbosity > 0) {
54  std::cout << "Creating a ClusterizerFP420" << std::endl;
55  std::cout << "ClusterizerFP420: dn0=" << dn0 << " sn0=" << sn0 << " pn0=" << pn0 << " rn0=" << rn0 << std::endl;
56  }
57 
58  sClusterizerFP420_ = std::make_unique<FP420ClusterMain>(conf, dn0, sn0, pn0, rn0);
59  }
60 
61  //Get at the beginning
63  if (verbosity > 0) {
64  std::cout << "BeginJob method " << std::endl;
65  }
66  //Getting Calibration data (Noises and BadElectrodes Flag)
67  // bool UseNoiseBadElectrodeFlagFromDB_=conf_.getParameter<bool>("UseNoiseBadElectrodeFlagFromDB");
68  // if (UseNoiseBadElectrodeFlagFromDB_==true){
69  // iSetup.get<ClusterNoiseFP420Rcd>().get(noise);// AZ: do corrections for noise here
70  //=========================================================
71  //
72  // Debug: show noise for DetIDs
73  // ElectrodNoiseMapIterator mapit = noise->m_noises.begin();
74  // for (;mapit!=noise->m_noises.end();mapit++)
75  // {
76  // unsigned int detid = (*mapit).first;
77  // std::cout << "detid " << detid << " # Electrode " << (*mapit).second.size()<<std::endl;
78  // //ElectrodNoiseVector theElectrodVector = (*mapit).second;
79  // const ElectrodNoiseVector theElectrodVector = noise->getElectrodNoiseVector(detid);
80 
81  // int electrode=0;
82  // ElectrodNoiseVectorIterator iter=theElectrodVector.begin();
83  // //for(; iter!=theElectrodVector.end(); iter++)
84  // {
85  // std::cout << " electrode " << electrode++ << " =\t"
86  // << iter->getNoise() << " \t"
87  // << iter->getDisable() << " \t"
88  // << std::endl;
89  // }
90  // }
91  //===========================================================
92  // }
93  }
94 
95  void ClusterizerFP420::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
96  // beginJob;
97  // be lazy and include the appropriate namespaces
98  using namespace edm;
99  using namespace std;
100  if (verbosity > 0) {
101  std::cout << "ClusterizerFP420: produce" << std::endl;
102  }
103 
104  // Get input
105  //A
106  // edm::Handle<DigiCollectionFP420> icf_simhit;
107  /*
108  Handle<DigiCollectionFP420> cf_simhit;
109  std::vector<const DigiCollectionFP420 *> cf_simhitvec;
110  for(uint32_t i = 0; i< trackerContainers.size();i++){
111  iEvent.getByLabel( trackerContainers[i], cf_simhit);
112  cf_simhitvec.push_back(cf_simhit.product()); }
113  std::unique_ptr<DigiCollectionFP420 > digis(new DigiCollectionFP420(cf_simhitvec));
114 
115  std::vector<HDigiFP420> input;
116  DigiCollectionFP420::iterator isim;
117  for (isim=digis->begin(); isim!= digis->end();isim++) {
118  input.push_back(*isim);
119  }
120 */
121  //B
122 
124  try {
125  // iEvent.getByLabel( "FP420Digi" , digis);
126  iEvent.getByLabel(trackerContainers[0], input);
127  } catch (const Exception&) {
128  // in principal, should never happen, as it's taken care of by Framework
129  throw cms::Exception("InvalidReference") << "Invalid reference to DigiCollectionFP420 \n";
130  }
131 
132  if (verbosity > 0) {
133  std::cout << "ClusterizerFP420: OK1" << std::endl;
134  }
135 
136  // Step C: create empty output collection
137  auto soutput = std::make_unique<ClusterCollectionFP420>();
139  /*
140  std::vector<SimVertex> input;
141  Handle<DigiCollectionFP420> digis;
142  iEvent.getByLabel("FP420Digi",digis);
143  input.insert(input.end(),digis->begin(),digis->end());
144 
145 
146 
147  std::vector<HDigiFP420> input;
148  for(std::vector<HDigiFP420>::const_iterator vsim=digis->begin();
149  vsim!=digis->end(); ++vsim){
150  input.push_back(*vsim);
151  }
152  theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
153 */
154  // std::vector<HDigiFP420> input;
155  // DigiCollectionFP420 input;
156  //input.push_back(digis);
157  // input.insert(input.end(), digis->begin(), digis->end());
158 
159  /*
160  std::vector<HDigiFP420> input;
161  input.clear();
162  DigiCollectionFP420::ContainerIterator sort_begin = digis->begin();
163  DigiCollectionFP420::ContainerIterator sort_end = digis->end();
164  for ( ;sort_begin != sort_end; ++sort_begin ) {
165  input.push_back(*sort_begin);
166  } // for
167 */
168 
169  // put zero to container info from the beginning (important! because not any detID is updated with coming of new event !!!!!!
170  // clean info of container from previous event
171  for (int det = 1; det < dn0; det++) {
172  for (int sector = 1; sector < sn0; sector++) {
173  for (int zmodule = 1; zmodule < pn0; zmodule++) {
174  for (int zside = 1; zside < rn0; zside++) {
175  // intindex is a continues numbering of FP420
176  unsigned int detID = FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
177  std::vector<ClusterFP420> collector;
178  collector.clear();
180  inputRange.first = collector.begin();
181  inputRange.second = collector.end();
182 
183  soutput->putclear(inputRange, detID);
184 
185  } //for
186  } //for
187  } //for
188  } //for
189 
190  // !!!!!!
191  // if we want to keep Cluster container/Collection for one event ---> uncomment the line below and vice versa
192  soutput->clear(); //container_.clear() --> start from the beginning of the container
193 
194  // RUN now: !!!!!!
195  // sClusterizerFP420_.run(input, soutput, noise);
196  if (verbosity > 0) {
197  std::cout << "ClusterizerFP420: OK2" << std::endl;
198  }
199  sClusterizerFP420_->run(input, soutput.get());
200 
201  if (verbosity > 0) {
202  std::cout << "ClusterizerFP420: OK3" << std::endl;
203  }
204 
205  // if(collectorZS.data.size()>0){
206 
207  // std::cout <<"======= ClusterizerFP420: end of produce " << std::endl;
208 
209  // Step D: write output to file
210  iEvent.put(std::move(soutput));
211  if (verbosity > 0) {
212  std::cout << "ClusterizerFP420: OK4" << std::endl;
213  }
214  } //produce
215 
216 } // namespace cms
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int zside(DetId const &)
void beginJob()
Definition: Breakpoints.cc:14
static std::string const input
Definition: EdmProvDump.cc:47
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule)
Namespace of DDCMS conversion namespace.
HLT enums.
std::pair< ContainerIterator, ContainerIterator > Range
def move(src, dest)
Definition: eostools.py:511