CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
17 
22 
24 //#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
25 
26 
31 
32 //Random Number
36 #include "CLHEP/Random/RandomEngine.h"
37 
38 #include <cstdlib>
39 #include <iostream>
40 using namespace std;
41 
42 namespace cms
43 {
44  ClusterizerFP420::ClusterizerFP420(const edm::ParameterSet& conf):
45  conf_(conf) {
46 
47 
48  std::string alias ( conf.getParameter<std::string>("@module_label") );
49 
50  produces<ClusterCollectionFP420>().setBranchAlias( alias );
51 
52  trackerContainers.clear();
53  trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
54 
55  verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
56  dn0 = conf_.getParameter<int>("NumberFP420Detectors");
57  sn0 = conf_.getParameter<int>("NumberFP420Stations");
58  pn0 = conf_.getParameter<int>("NumberFP420SPlanes");
59  rn0 = 7;
60  if (verbosity > 0) {
61  std::cout << "Creating a ClusterizerFP420" << std::endl;
62  std::cout << "ClusterizerFP420: dn0=" << dn0 << " sn0=" << sn0 << " pn0=" << pn0 << " rn0=" << rn0 << std::endl;
63  }
64 
65  sClusterizerFP420_ = new FP420ClusterMain(conf_,dn0,sn0,pn0,rn0);
66  }
67 
68  // Virtual destructor needed.
70  delete sClusterizerFP420_;
71  }
72 
73  //Get at the beginning
75  if (verbosity > 0) {
76  std::cout << "BeginJob method " << std::endl;
77  }
78  //Getting Calibration data (Noises and BadElectrodes Flag)
79  // bool UseNoiseBadElectrodeFlagFromDB_=conf_.getParameter<bool>("UseNoiseBadElectrodeFlagFromDB");
80  // if (UseNoiseBadElectrodeFlagFromDB_==true){
81  // iSetup.get<ClusterNoiseFP420Rcd>().get(noise);// AZ: do corrections for noise here
82  //=========================================================
83  //
84  // Debug: show noise for DetIDs
85  // ElectrodNoiseMapIterator mapit = noise->m_noises.begin();
86  // for (;mapit!=noise->m_noises.end();mapit++)
87  // {
88  // unsigned int detid = (*mapit).first;
89  // std::cout << "detid " << detid << " # Electrode " << (*mapit).second.size()<<std::endl;
90  // //ElectrodNoiseVector theElectrodVector = (*mapit).second;
91  // const ElectrodNoiseVector theElectrodVector = noise->getElectrodNoiseVector(detid);
92 
93 
94  // int electrode=0;
95  // ElectrodNoiseVectorIterator iter=theElectrodVector.begin();
96  // //for(; iter!=theElectrodVector.end(); iter++)
97  // {
98  // std::cout << " electrode " << electrode++ << " =\t"
99  // << iter->getNoise() << " \t"
100  // << iter->getDisable() << " \t"
101  // << std::endl;
102  // }
103  // }
104  //===========================================================
105  // }
106  }
107 
109  {
110  // beginJob;
111  // be lazy and include the appropriate namespaces
112  using namespace edm;
113  using namespace std;
114  if (verbosity > 0) {
115  std::cout << "ClusterizerFP420: produce" << std::endl;
116  }
117 
118  // Get input
119  //A
120  // edm::Handle<DigiCollectionFP420> icf_simhit;
121  /*
122  Handle<DigiCollectionFP420> cf_simhit;
123  std::vector<const DigiCollectionFP420 *> cf_simhitvec;
124  for(uint32_t i = 0; i< trackerContainers.size();i++){
125  iEvent.getByLabel( trackerContainers[i], cf_simhit);
126  cf_simhitvec.push_back(cf_simhit.product()); }
127  std::auto_ptr<DigiCollectionFP420 > digis(new DigiCollectionFP420(cf_simhitvec));
128 
129  std::vector<HDigiFP420> input;
130  DigiCollectionFP420::iterator isim;
131  for (isim=digis->begin(); isim!= digis->end();isim++) {
132  input.push_back(*isim);
133  }
134 */
135  //B
136 
138  try{
139  // iEvent.getByLabel( "FP420Digi" , digis);
140  iEvent.getByLabel( trackerContainers[0] , input);
141  } catch(const Exception&)
142  {
143  // in principal, should never happen, as it's taken care of by Framework
144  throw cms::Exception("InvalidReference")
145  << "Invalid reference to DigiCollectionFP420 \n";
146  }
147 
148  if (verbosity > 0) {
149  std::cout << "ClusterizerFP420: OK1" << std::endl;
150  }
151 
152  // Step C: create empty output collection
153  std::auto_ptr<ClusterCollectionFP420> soutput(new ClusterCollectionFP420);
155  /*
156  std::vector<SimVertex> input;
157  Handle<DigiCollectionFP420> digis;
158  iEvent.getByLabel("FP420Digi",digis);
159  input.insert(input.end(),digis->begin(),digis->end());
160 
161 
162 
163  std::vector<HDigiFP420> input;
164  for(std::vector<HDigiFP420>::const_iterator vsim=digis->begin();
165  vsim!=digis->end(); ++vsim){
166  input.push_back(*vsim);
167  }
168  theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
169 */
170  // std::vector<HDigiFP420> input;
171  // DigiCollectionFP420 input;
172  //input.push_back(digis);
173  // input.insert(input.end(), digis->begin(), digis->end());
174 
175  /*
176  std::vector<HDigiFP420> input;
177  input.clear();
178  DigiCollectionFP420::ContainerIterator sort_begin = digis->begin();
179  DigiCollectionFP420::ContainerIterator sort_end = digis->end();
180  for ( ;sort_begin != sort_end; ++sort_begin ) {
181  input.push_back(*sort_begin);
182  } // for
183 */
184 
185 
186  // put zero to container info from the beginning (important! because not any detID is updated with coming of new event !!!!!!
187  // clean info of container from previous event
188  for (int det=1; det<dn0; det++) {
189  for (int sector=1; sector<sn0; sector++) {
190  for (int zmodule=1; zmodule<pn0; zmodule++) {
191  for (int zside=1; zside<rn0; zside++) {
192  // intindex is a continues numbering of FP420
193  unsigned int detID = theFP420NumberingScheme->FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
194  std::vector<ClusterFP420> collector;
195  collector.clear();
197  inputRange.first = collector.begin();
198  inputRange.second = collector.end();
199 
200  soutput->putclear(inputRange,detID);
201 
202  }//for
203  }//for
204  }//for
205  }//for
206 
207 
208  // !!!!!!
209  // if we want to keep Cluster container/Collection for one event ---> uncomment the line below and vice versa
210  soutput->clear(); //container_.clear() --> start from the beginning of the container
211 
212  // RUN now: !!!!!!
213  // sClusterizerFP420_.run(input, soutput, noise);
214  if (verbosity > 0) {
215  std::cout << "ClusterizerFP420: OK2" << std::endl;
216  }
217  sClusterizerFP420_->run(input, soutput, noise);
218 
219  if (verbosity > 0) {
220  std::cout << "ClusterizerFP420: OK3" << std::endl;
221  }
222 
223  // if(collectorZS.data.size()>0){
224 
225  // std::cout <<"======= ClusterizerFP420: end of produce " << std::endl;
226 
227  // Step D: write output to file
228  iEvent.put(soutput);
229  if (verbosity > 0) {
230  std::cout << "ClusterizerFP420: OK4" << std::endl;
231  }
232  }//produce
233 
234 } // namespace cms
235 
virtual void produce(edm::Event &e, const edm::EventSetup &c)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
inputRange
Get input source.
void run(edm::Handle< DigiCollectionFP420 > &input, std::auto_ptr< ClusterCollectionFP420 > &soutput, std::vector< ClusterNoiseFP420 > &noise)
Runs the algorithm.
edm::ParameterSet conf_
static std::string const input
Definition: EdmProvDump.cc:44
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
tuple conf
Definition: dbtoconf.py:185
ClusterCollectionFP420 * soutput
FP420NumberingScheme * theFP420NumberingScheme
FP420ClusterMain * sClusterizerFP420_
tuple cout
Definition: gather_cfg.py:121
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< ClusterNoiseFP420 > noise