CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiTrackerGaussianSmearingRecHitConverter.cc
Go to the documentation of this file.
1 
8 //PAT
9 //FastTrackerCluster
11 
12 // SiTracker Gaussian Smearing
14 
15 // SiPixel Gaussian Smearing
17 
18 // SiStripGaussianSmearing
20 
21 // Geometry and magnetic field
29 
30 // Data Formats
33 
34 // Framework
41 
42 // Numbering scheme
45 
46 //For Pileup events
48 
49 // Random engine
51 
52 // topology
53 
54 // the rec hit matcher
55 #include "GSRecHitMatcher.h"
56 
57 // STL
58 #include <memory>
59 
60 // ROOT
61 #include <TFile.h>
62 #include <TH1F.h>
63 
64 
65 //#define FAMOS_DEBUG
66 
68  edm::ParameterSet const& conf)
69  : pset_(conf)
70 {
71  thePixelDataFile = 0;
78 
79 #ifdef FAMOS_DEBUG
80  std::cout << "SiTrackerGaussianSmearingRecHitConverter instantiated" << std::endl;
81 #endif
82 
83  //PAT
84  produces<FastTrackerClusterCollection>("TrackerClusters");
85 
86  produces<SiTrackerGSRecHit2DCollection>("TrackerGSRecHits");
87  produces<SiTrackerGSMatchedRecHit2DCollection>("TrackerGSMatchedRecHits");
88 
89  //--- PSimHit Containers
90  // trackerContainers.clear();
91  // trackerContainers = conf.getParameter<std::vector<edm::InputTag> >("ROUList");
92  simHitLabel = conf.getParameter<edm::InputTag>("InputSimHits");
93  simHitToken = consumes<edm::PSimHitContainer>(simHitLabel);
94  //--- delta rays p cut [GeV/c] to filter PSimHits with p>
95  deltaRaysPCut = conf.getParameter<double>("DeltaRaysMomentumCut");
96 
97  //--- switch to have RecHit == PSimHit
98  trackingPSimHits = conf.getParameter<bool>("trackingPSimHits");
99  if(trackingPSimHits) std::cout << "### trackingPSimHits chosen " << trackingPSimHits << std::endl;
100 
101  // switch on/off matching
102  doMatching = conf.getParameter<bool>("doRecHitMatching");
103 
104  // disable/enable dead channels
105  doDisableChannels = conf.getParameter<bool>("killDeadChannels");
106 
107  // Switch between old (ORCA) and new (CMSSW) pixel parameterization
108  useCMSSWPixelParameterization = conf.getParameter<bool>("UseCMSSWPixelParametrization");
109 #ifdef FAMOS_DEBUG
110  std::cout << (useCMSSWPixelParameterization? "CMSSW" : "ORCA") << " pixel parametrization chosen in config file." << std::endl;
111 #endif
112 
113  //Clusters
114  GevPerElectron = conf.getParameter<double>("GevPerElectron");
115  ElectronsPerADC = conf.getParameter<double>("ElectronsPerADC");
116 
117  //
118  // TIB
119  localPositionResolution_TIB1x = conf.getParameter<double>("TIB1x");
120  localPositionResolution_TIB1y = conf.getParameter<double>("TIB1y");
121  localPositionResolution_TIB2x = conf.getParameter<double>("TIB2x");
122  localPositionResolution_TIB2y = conf.getParameter<double>("TIB2y");
123  localPositionResolution_TIB3x = conf.getParameter<double>("TIB3x");
124  localPositionResolution_TIB3y = conf.getParameter<double>("TIB3y");
125  localPositionResolution_TIB4x = conf.getParameter<double>("TIB4x");
126  localPositionResolution_TIB4y = conf.getParameter<double>("TIB4y");
127  //
128  // TID
129  localPositionResolution_TID1x = conf.getParameter<double>("TID1x");
130  localPositionResolution_TID1y = conf.getParameter<double>("TID1y");
131  localPositionResolution_TID2x = conf.getParameter<double>("TID2x");
132  localPositionResolution_TID2y = conf.getParameter<double>("TID2y");
133  localPositionResolution_TID3x = conf.getParameter<double>("TID3x");
134  localPositionResolution_TID3y = conf.getParameter<double>("TID3y");
135  //
136  // TOB
137  localPositionResolution_TOB1x = conf.getParameter<double>("TOB1x");
138  localPositionResolution_TOB1y = conf.getParameter<double>("TOB1y");
139  localPositionResolution_TOB2x = conf.getParameter<double>("TOB2x");
140  localPositionResolution_TOB2y = conf.getParameter<double>("TOB2y");
141  localPositionResolution_TOB3x = conf.getParameter<double>("TOB3x");
142  localPositionResolution_TOB3y = conf.getParameter<double>("TOB3y");
143  localPositionResolution_TOB4x = conf.getParameter<double>("TOB4x");
144  localPositionResolution_TOB4y = conf.getParameter<double>("TOB4y");
145  localPositionResolution_TOB5x = conf.getParameter<double>("TOB5x");
146  localPositionResolution_TOB5y = conf.getParameter<double>("TOB5y");
147  localPositionResolution_TOB6x = conf.getParameter<double>("TOB6x");
148  localPositionResolution_TOB6y = conf.getParameter<double>("TOB6y");
149  //
150  // TEC
151  localPositionResolution_TEC1x = conf.getParameter<double>("TEC1x");
152  localPositionResolution_TEC1y = conf.getParameter<double>("TEC1y");
153  localPositionResolution_TEC2x = conf.getParameter<double>("TEC2x");
154  localPositionResolution_TEC2y = conf.getParameter<double>("TEC2y");
155  localPositionResolution_TEC3x = conf.getParameter<double>("TEC3x");
156  localPositionResolution_TEC3y = conf.getParameter<double>("TEC3y");
157  localPositionResolution_TEC4x = conf.getParameter<double>("TEC4x");
158  localPositionResolution_TEC4y = conf.getParameter<double>("TEC4y");
159  localPositionResolution_TEC5x = conf.getParameter<double>("TEC5x");
160  localPositionResolution_TEC5y = conf.getParameter<double>("TEC5y");
161  localPositionResolution_TEC6x = conf.getParameter<double>("TEC6x");
162  localPositionResolution_TEC6y = conf.getParameter<double>("TEC6y");
163  localPositionResolution_TEC7x = conf.getParameter<double>("TEC7x");
164  localPositionResolution_TEC7y = conf.getParameter<double>("TEC7y");
165  //
166  localPositionResolution_z = 0.0001; // not to be changed, set to minimum (1 um), Kalman Filter will crash if errors are exactly 0, setting 1 um means 0
167  //
168 #ifdef FAMOS_DEBUG
169  std::cout << "RecHit local position error set to" << "\n"
170  << "\tTIB1\tx = " << localPositionResolution_TIB1x
171  << " cm\ty = " << localPositionResolution_TIB1y << " cm" << "\n"
172  << "\tTIB2\tx = " << localPositionResolution_TIB2x
173  << " cm\ty = " << localPositionResolution_TIB2y << " cm" << "\n"
174  << "\tTIB3\tx = " << localPositionResolution_TIB3x
175  << " cm\ty = " << localPositionResolution_TIB3y << " cm" << "\n"
176  << "\tTIB4\tx = " << localPositionResolution_TIB4x
177  << " cm\ty = " << localPositionResolution_TIB4y << " cm" << "\n"
178  << "\tTID1\tx = " << localPositionResolution_TID1x
179  << " cm\ty = " << localPositionResolution_TID1y << " cm" << "\n"
180  << "\tTID2\tx = " << localPositionResolution_TID2x
181  << " cm\ty = " << localPositionResolution_TID2y << " cm" << "\n"
182  << "\tTID3\tx = " << localPositionResolution_TID3x
183  << " cm\ty = " << localPositionResolution_TID3y << " cm" << "\n"
184  << "\tTOB1\tx = " << localPositionResolution_TOB1x
185  << " cm\ty = " << localPositionResolution_TOB1y << " cm" << "\n"
186  << "\tTOB2\tx = " << localPositionResolution_TOB2x
187  << " cm\ty = " << localPositionResolution_TOB2y << " cm" << "\n"
188  << "\tTOB3\tx = " << localPositionResolution_TOB3x
189  << " cm\ty = " << localPositionResolution_TOB3y << " cm" << "\n"
190  << "\tTOB4\tx = " << localPositionResolution_TOB4x
191  << " cm\ty = " << localPositionResolution_TOB4y << " cm" << "\n"
192  << "\tTOB5\tx = " << localPositionResolution_TOB5x
193  << " cm\ty = " << localPositionResolution_TOB5y << " cm" << "\n"
194  << "\tTOB6\tx = " << localPositionResolution_TOB6x
195  << " cm\ty = " << localPositionResolution_TOB6y << " cm" << "\n"
196  << "\tTEC1\tx = " << localPositionResolution_TEC1x
197  << " cm\ty = " << localPositionResolution_TEC1y << " cm" << "\n"
198  << "\tTEC2\tx = " << localPositionResolution_TEC2x
199  << " cm\ty = " << localPositionResolution_TEC2y << " cm" << "\n"
200  << "\tTEC3\tx = " << localPositionResolution_TEC3x
201  << " cm\ty = " << localPositionResolution_TEC3y << " cm" << "\n"
202  << "\tTEC4\tx = " << localPositionResolution_TEC4x
203  << " cm\ty = " << localPositionResolution_TEC4y << " cm" << "\n"
204  << "\tTEC5\tx = " << localPositionResolution_TEC5x
205  << " cm\ty = " << localPositionResolution_TEC5y << " cm" << "\n"
206  << "\tTEC6\tx = " << localPositionResolution_TEC6x
207  << " cm\ty = " << localPositionResolution_TEC6y << " cm" << "\n"
208  << "\tTEC7\tx = " << localPositionResolution_TEC7x
209  << " cm\ty = " << localPositionResolution_TEC7y << " cm" << "\n"
210  << "\tAll:\tz = " << localPositionResolution_z << " cm"
211  << std::endl;
212 #endif
213 
214  //--- Number of histograms for alpha/beta barrel/forward multiplicity
215  if(useCMSSWPixelParameterization) {
216  nAlphaBarrel = conf.getParameter<int>("AlphaBarrelMultiplicityNew");
217  nBetaBarrel = conf.getParameter<int>("BetaBarrelMultiplicityNew");
218  nAlphaForward = conf.getParameter<int>("AlphaForwardMultiplicityNew");
219  nBetaForward = conf.getParameter<int>("BetaForwardMultiplicityNew");
220  } else {
221  nAlphaBarrel = conf.getParameter<int>("AlphaBarrelMultiplicity");
222  nBetaBarrel = conf.getParameter<int>("BetaBarrelMultiplicity");
223  nAlphaForward = conf.getParameter<int>("AlphaForwardMultiplicity");
224  nBetaForward = conf.getParameter<int>("BetaForwardMultiplicity");
225  }
226 #ifdef FAMOS_DEBUG
227  std::cout << "Pixel maximum multiplicity set to "
228  << "\nBarrel" << "\talpha " << nAlphaBarrel
229  << "\tbeta " << nBetaBarrel
230  << "\nForward" << "\talpha " << nAlphaForward
231  << "\tbeta " << nBetaForward
232  << std::endl;
233 #endif
234 
235  // Resolution Barrel
236  if(useCMSSWPixelParameterization) {
237  resAlphaBarrel_binMin = conf.getParameter<double>("AlphaBarrel_BinMinNew" );
238  resAlphaBarrel_binWidth = conf.getParameter<double>("AlphaBarrel_BinWidthNew");
239  resAlphaBarrel_binN = conf.getParameter<int>( "AlphaBarrel_BinNNew" );
240  resBetaBarrel_binMin = conf.getParameter<double>("BetaBarrel_BinMinNew" );
241  resBetaBarrel_binWidth = conf.getParameter<double>("BetaBarrel_BinWidthNew" );
242  resBetaBarrel_binN = conf.getParameter<int>( "BetaBarrel_BinNNew" );
243  } else {
244  resAlphaBarrel_binMin = conf.getParameter<double>("AlphaBarrel_BinMin" );
245  resAlphaBarrel_binWidth = conf.getParameter<double>("AlphaBarrel_BinWidth");
246  resAlphaBarrel_binN = conf.getParameter<int>( "AlphaBarrel_BinN" );
247  resBetaBarrel_binMin = conf.getParameter<double>("BetaBarrel_BinMin" );
248  resBetaBarrel_binWidth = conf.getParameter<double>("BetaBarrel_BinWidth" );
249  resBetaBarrel_binN = conf.getParameter<int>( "BetaBarrel_BinN" );
250  }
251 
252  // Resolution Forward
253  if(useCMSSWPixelParameterization) {
254  resAlphaForward_binMin = conf.getParameter<double>("AlphaForward_BinMinNew" );
255  resAlphaForward_binWidth = conf.getParameter<double>("AlphaForward_BinWidthNew" );
256  resAlphaForward_binN = conf.getParameter<int>( "AlphaForward_BinNNew" );
257  resBetaForward_binMin = conf.getParameter<double>("BetaForward_BinMinNew" );
258  resBetaForward_binWidth = conf.getParameter<double>("BetaForward_BinWidthNew" );
259  resBetaForward_binN = conf.getParameter<int>( "BetaForward_BinNNew" );
260  } else {
261  resAlphaForward_binMin = conf.getParameter<double>("AlphaForward_BinMin" );
262  resAlphaForward_binWidth = conf.getParameter<double>("AlphaForward_BinWidth" );
263  resAlphaForward_binN = conf.getParameter<int>( "AlphaForward_BinN" );
264  resBetaForward_binMin = conf.getParameter<double>("BetaForward_BinMin" );
265  resBetaForward_binWidth = conf.getParameter<double>("BetaForward_BinWidth" );
266  resBetaForward_binN = conf.getParameter<int>( "BetaForward_BinN" );
267  }
268 
269  // Hit Finding Probability
270  theHitFindingProbability_PXB = conf.getParameter<double>("HitFindingProbability_PXB" );
271  theHitFindingProbability_PXF = conf.getParameter<double>("HitFindingProbability_PXF" );
272  theHitFindingProbability_TIB1 = conf.getParameter<double>("HitFindingProbability_TIB1");
273  theHitFindingProbability_TIB2 = conf.getParameter<double>("HitFindingProbability_TIB2");
274  theHitFindingProbability_TIB3 = conf.getParameter<double>("HitFindingProbability_TIB3");
275  theHitFindingProbability_TIB4 = conf.getParameter<double>("HitFindingProbability_TIB4");
276  theHitFindingProbability_TID1 = conf.getParameter<double>("HitFindingProbability_TID1");
277  theHitFindingProbability_TID2 = conf.getParameter<double>("HitFindingProbability_TID2");
278  theHitFindingProbability_TID3 = conf.getParameter<double>("HitFindingProbability_TID3");
279  theHitFindingProbability_TOB1 = conf.getParameter<double>("HitFindingProbability_TOB1");
280  theHitFindingProbability_TOB2 = conf.getParameter<double>("HitFindingProbability_TOB2");
281  theHitFindingProbability_TOB3 = conf.getParameter<double>("HitFindingProbability_TOB3");
282  theHitFindingProbability_TOB4 = conf.getParameter<double>("HitFindingProbability_TOB4");
283  theHitFindingProbability_TOB5 = conf.getParameter<double>("HitFindingProbability_TOB5");
284  theHitFindingProbability_TOB6 = conf.getParameter<double>("HitFindingProbability_TOB6");
285  theHitFindingProbability_TEC1 = conf.getParameter<double>("HitFindingProbability_TEC1");
286  theHitFindingProbability_TEC2 = conf.getParameter<double>("HitFindingProbability_TEC2");
287  theHitFindingProbability_TEC3 = conf.getParameter<double>("HitFindingProbability_TEC3");
288  theHitFindingProbability_TEC4 = conf.getParameter<double>("HitFindingProbability_TEC4");
289  theHitFindingProbability_TEC5 = conf.getParameter<double>("HitFindingProbability_TEC5");
290  theHitFindingProbability_TEC6 = conf.getParameter<double>("HitFindingProbability_TEC6");
291  theHitFindingProbability_TEC7 = conf.getParameter<double>("HitFindingProbability_TEC7");
292  //
293 #ifdef FAMOS_DEBUG
294  std::cout << "RecHit finding probability set to" << "\n"
295  << "\tPXB = " << theHitFindingProbability_PXB << "\n"
296  << "\tPXF = " << theHitFindingProbability_PXF << "\n"
297  << "\tTIB1 = " << theHitFindingProbability_TIB1 << "\n"
298  << "\tTIB2 = " << theHitFindingProbability_TIB2 << "\n"
299  << "\tTIB3 = " << theHitFindingProbability_TIB3 << "\n"
300  << "\tTIB4 = " << theHitFindingProbability_TIB4 << "\n"
301  << "\tTID1 = " << theHitFindingProbability_TID1 << "\n"
302  << "\tTID2 = " << theHitFindingProbability_TID2 << "\n"
303  << "\tTID3 = " << theHitFindingProbability_TID3 << "\n"
304  << "\tTOB1 = " << theHitFindingProbability_TOB1 << "\n"
305  << "\tTOB2 = " << theHitFindingProbability_TOB2 << "\n"
306  << "\tTOB3 = " << theHitFindingProbability_TOB3 << "\n"
307  << "\tTOB4 = " << theHitFindingProbability_TOB4 << "\n"
308  << "\tTOB5 = " << theHitFindingProbability_TOB5 << "\n"
309  << "\tTOB6 = " << theHitFindingProbability_TOB6 << "\n"
310  << "\tTEC1 = " << theHitFindingProbability_TEC1 << "\n"
311  << "\tTEC2 = " << theHitFindingProbability_TEC2 << "\n"
312  << "\tTEC3 = " << theHitFindingProbability_TEC3 << "\n"
313  << "\tTEC4 = " << theHitFindingProbability_TEC4 << "\n"
314  << "\tTEC5 = " << theHitFindingProbability_TEC5 << "\n"
315  << "\tTEC6 = " << theHitFindingProbability_TEC6 << "\n"
316  << "\tTEC7 = " << theHitFindingProbability_TEC7 << "\n"
317  << std::endl;
318 #endif
319 
320  // Initialize the si strip error parametrization
323 
324  // Initialization of pixel parameterization posponed to beginRun(), since it depends on the magnetic field
325 
326 }
327 
328 
330  // load multiplicity cumulative probabilities
331  // root files
332  thePixelDataFile = new TFile ( edm::FileInPath( thePixelMultiplicityFileName ).fullPath().c_str() , "READ" );
335  //
336 
337  // alpha barrel
339  nAlphaBarrel ,
340  std::string("hist_alpha_barrel") ,
342  //
343  // beta barrel
345  nBetaBarrel ,
346  std::string("hist_beta_barrel") ,
348  //
349  // alpha forward
351  nAlphaForward ,
352  std::string("hist_alpha_forward") ,
354  //
355  // beta forward
357  nBetaForward ,
358  std::string("hist_beta_forward") ,
360 
361  // Load also big pixel data if CMSSW parametrization is on
362  // They are pushed back into the vectors after the normal pixels data:
363  // [0, ..., (size/2)-1] -> Normal pixels
364  // [size/2, ..., size-1] -> Big pixels
366  // alpha barrel
368  nAlphaBarrel ,
369  std::string("hist_alpha_barrel_big") ,
371  true );
372  //
373  // beta barrel
375  nBetaBarrel ,
376  std::string("hist_beta_barrel_big") ,
378  true );
379  //
380  // alpha forward
382  nAlphaForward ,
383  std::string("hist_alpha_forward_big") ,
385  true );
386  //
387  // beta forward
389  nBetaForward ,
390  std::string("hist_beta_forward_big") ,
392  true );
393  }
394  //
395 }
396 
398  TFile* pixelDataFile,
399  unsigned int nMultiplicity,
400  std::string histName,
401  std::vector<TH1F*>& theMultiplicityCumulativeProbabilities,
402  bool bigPixels)
403 {
404 
405  std::string histName_i = histName + "_%u"; // needed to open histograms with a for
406  if(!bigPixels)
407  theMultiplicityCumulativeProbabilities.clear();
408  //
409  // What's this vector? Not needed - MG
410 // std::vector<double> mult; // vector with fixed multiplicity
411  for(unsigned int i = 0; i<nMultiplicity; ++i) {
412  TH1F addHist = *((TH1F*) pixelDataFile->Get( Form( histName_i.c_str() ,i+1 )));
413  if(i==0) {
414  theMultiplicityCumulativeProbabilities.push_back( new TH1F(addHist) );
415  } else {
416  TH1F sumHist;
417  if(bigPixels)
418  sumHist = *(theMultiplicityCumulativeProbabilities[nMultiplicity+i-1]);
419  else
420  sumHist = *(theMultiplicityCumulativeProbabilities[i-1]);
421  sumHist.Add(&addHist);
422  theMultiplicityCumulativeProbabilities.push_back( new TH1F(sumHist) );
423  }
424  }
425 
426  // Logger
427 #ifdef FAMOS_DEBUG
428  const unsigned int maxMult = theMultiplicityCumulativeProbabilities.size();
429  unsigned int iMult, multSize;
431  if(bigPixels) {
432  iMult = maxMult / 2;
433  multSize = maxMult ;
434  } else {
435  iMult = 0;
436  multSize = maxMult;
437  }
438  } else {
439  iMult = 0;
440  multSize = maxMult ;
441  }
442  std::cout << " Multiplicity cumulated probability " << histName << std::endl;
443  for(/* void */; iMult<multSize; ++iMult) {
444  for(int iBin = 1; iBin<=theMultiplicityCumulativeProbabilities[iMult]->GetNbinsX(); ++iBin) {
445  std::cout
446  << " Multiplicity " << iMult+1
447  << " bin " << iBin
448  << " low edge = "
449  << theMultiplicityCumulativeProbabilities[iMult]->GetBinLowEdge(iBin)
450  << " prob = "
451  << (theMultiplicityCumulativeProbabilities[iMult])->GetBinContent(iBin)
452  // remember in ROOT bin starts from 1 (0 underflow, nBin+1 overflow)
453  << std::endl;
454  }
455  }
456 #endif
457 
458 }
459 
460 // Destructor
466 
473 
475 }
476 
477 void
479 {
480 
481  // Initialize the Tracker Geometry
482  edm::ESHandle<TrackerGeometry> theGeometry;
483  es.get<TrackerDigiGeometryRecord> ().get (theGeometry);
484  geometry = &(*theGeometry);
485 
486  edm::ESHandle<TrackerGeometry> theMisAlignedGeometry;
487  es.get<TrackerDigiGeometryRecord>().get("MisAligned",theMisAlignedGeometry);
488  misAlignedGeometry = &(*theMisAlignedGeometry);
489 
490  const MagneticField* magfield;
492  es.get<IdealMagneticFieldRecord>().get(magField);
493  magfield=&(*magField);
494  GlobalPoint center(0.0, 0.0, 0.0);
495  double magFieldAtCenter = magfield->inTesla(center).mag();
496 
497  // For new parameterization: select multiplicity and resolution files according to magnetic field
499  if(magFieldAtCenter > 3.9) {
500  thePixelMultiplicityFileName = pset_.getParameter<std::string>( "PixelMultiplicityFile40T");
501  thePixelBarrelResolutionFileName = pset_.getParameter<std::string>( "PixelBarrelResolutionFile40T");
502  thePixelForwardResolutionFileName = pset_.getParameter<std::string>( "PixelForwardResolutionFile40T");
503  } else {
504  thePixelMultiplicityFileName = pset_.getParameter<std::string>( "PixelMultiplicityFile38T");
505  thePixelBarrelResolutionFileName = pset_.getParameter<std::string>( "PixelBarrelResolutionFile38T");
506  thePixelForwardResolutionFileName = pset_.getParameter<std::string>( "PixelForwardResolutionFile38T");
507  }
508  } else {
509  thePixelMultiplicityFileName = pset_.getParameter<std::string>( "PixelMultiplicityFile" );
510  thePixelBarrelResolutionFileName = pset_.getParameter<std::string>( "PixelBarrelResolutionFile");
511  thePixelForwardResolutionFileName = pset_.getParameter<std::string>( "PixelForwardResolutionFile");
512  }
513 
514 
515  // Reading the list of dead pixel modules from DB:
516  edm::ESHandle<SiPixelQuality> siPixelBadModule;
517  es.get<SiPixelQualityRcd>().get(siPixelBadModule);
519  if (doDisableChannels) {
520  disabledModules = new std::vector<SiPixelQuality::disabledModuleType> ( siPixelBadModule->getBadComponentList() );
522  size_t numberOfRecoverableModules = 0;
523  for (size_t id=0;id<numberOfDisabledModules;id++) {
525  // errortype "whole" = int 0 in DB //
526  // errortype "tbmA" = int 1 in DB //
527  // errortype "tbmB" = int 2 in DB //
528  // errortype "none" = int 3 in DB //
530  if ( (*disabledModules)[id-numberOfRecoverableModules].errorType != 0 ){
531  // Disable only the modules totally in error:
532  disabledModules->erase(disabledModules->begin()+id-numberOfRecoverableModules);
533  numberOfRecoverableModules++;
534  }
535  }
536  numberOfDisabledModules = disabledModules->size();
537  }
538 
539 
540 
541 #ifdef FAMOS_DEBUG
542  std::cout << "Pixel multiplicity data are taken from file " << thePixelMultiplicityFileName << std::endl;
543 
544  std::cout << "Pixel maximum multiplicity set to "
545  << "\nBarrel" << "\talpha " << nAlphaBarrel
546  << "\tbeta " << nBetaBarrel
547  << "\nForward" << "\talpha " << nAlphaForward
548  << "\tbeta " << nBetaForward
549  << std::endl;
550 
551  std::cout << "Barrel Pixel resolution data are taken from file "
553  << "Alpha bin min = " << resAlphaBarrel_binMin
554  << "\twidth = " << resAlphaBarrel_binWidth
555  << "\tbins = " << resAlphaBarrel_binN
556  << "\n"
557  << " Beta bin min = " << resBetaBarrel_binMin
558  << "\twidth = " << resBetaBarrel_binWidth
559  << "\tbins = " << resBetaBarrel_binN
560  << std::endl;
561 
562  std::cout << "Forward Pixel resolution data are taken from file "
564  << "Alpha bin min = " << resAlphaForward_binMin
565  << "\twidth = " << resAlphaForward_binWidth
566  << "\tbins = " << resAlphaForward_binN
567  << "\n"
568  << " Beta bin min = " << resBetaForward_binMin
569  << "\twidth = " << resBetaForward_binWidth
570  << "\tbins = " << resBetaForward_binN
571  << std::endl;
572 #endif
573  //
574 
575  //
576  // load pixel data
577  loadPixelData();
578  //
579 
580  // Initialize and open relevant files for the pixel barrel error parametrization
583  pset_,
585  // Initialize and open relevant files for the pixel forward error parametrization
588  pset_,
590 }
591 
593 {
595 
596  //Retrieve tracker topology from geometry
598  es.get<IdealGeometryRecord>().get(tTopoHand);
599  const TrackerTopology *tTopo=tTopoHand.product();
600 
601 
602  // Step 0: Declare Ref and RefProd
604 
605  // Step A: Get Inputs (PSimHit's)
606  /*
607  edm::Handle<CrossingFrame<PSimHit> > cf_simhit;
608  std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
609  for(uint32_t i=0; i<trackerContainers.size(); i++){
610  e.getByLabel(trackerContainers[i], cf_simhit);
611  cf_simhitvec.push_back(cf_simhit.product());
612  }
613  std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
614  */
615 
616  edm::Handle<edm::PSimHitContainer> allTrackerHits_handle;
617  e.getByToken(simHitToken,allTrackerHits_handle);
618  const edm::PSimHitContainer& allTrackerHits=*allTrackerHits_handle;
619 
620  // Step B: create temporary RecHit collection and fill it with Gaussian smeared RecHit's
621 
622  std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> > temporaryRecHits;
623  std::map<unsigned, edm::OwnVector<FastTrackerCluster> > theClusters ;
624 
625  smearHits( allTrackerHits, temporaryRecHits, theClusters, tTopo, &random);
626 
627  // Step C: match rechits on stereo layers
628  std::map<unsigned, edm::OwnVector<SiTrackerGSMatchedRecHit2D> > temporaryMatchedRecHits ;
629  if(doMatching) matchHits( temporaryRecHits, temporaryMatchedRecHits);//, allTrackerHits);
630 
631  // Step D: from the temporary RecHit collection, create the real one.
632  std::auto_ptr<SiTrackerGSRecHit2DCollection> recHitCollection(new SiTrackerGSRecHit2DCollection);
633  std::auto_ptr<SiTrackerGSMatchedRecHit2DCollection> recHitCollectionMatched(new SiTrackerGSMatchedRecHit2DCollection);
634  if(doMatching){
635  loadMatchedRecHits(temporaryMatchedRecHits, *recHitCollectionMatched);
636  loadRecHits(temporaryRecHits, *recHitCollection);
637  }
638  else {
639  //might need to have a "matched" hit collection containing the simple hits
640  loadRecHits(temporaryRecHits, *recHitCollection);
641  }
642 
643 
644 
645  //std::cout << "****** TrackerGSRecHits hits are =\t" << (*recHitCollection).size()<<std::endl;
646  //std::cout << "****** TrackerGSRecHitsMatched hits are =\t" << (*recHitCollectionMatched).size()<< std::endl;
647 
648 
649 
650  // Step E: write output to file
651  e.put(recHitCollection,"TrackerGSRecHits");
652  e.put(recHitCollectionMatched,"TrackerGSMatchedRecHits");
653 
654  //STEP F: write clusters
655  std::auto_ptr<FastTrackerClusterCollection> clusterCollection(new FastTrackerClusterCollection);
656  loadClusters(theClusters, *clusterCollection);
657  e.put(clusterCollection,"TrackerClusters");
658 }
659 
660 
661 
662 //void SiTrackerGaussianSmearingRecHitConverter::smearHits(MixCollection<PSimHit>& input,
664  std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >& temporaryRecHits,
665  std::map<unsigned, edm::OwnVector<FastTrackerCluster> >& theClusters,
666  const TrackerTopology *tTopo,
668 {
669 
670  int numberOfPSimHits = 0;
671 
672 
673  // MixCollection<PSimHit>::iterator isim = input.begin();
674  // MixCollection<PSimHit>::iterator lastSimHit = input.end();
675  edm::PSimHitContainer::const_iterator isim = input.begin();
676  edm::PSimHitContainer::const_iterator lastSimHit = input.end();
677 
678 
679 
680  correspondingSimHit.resize(input.size());
683  LocalError inflatedError;
684 
685  int simHitCounter = -1;
686  int recHitCounter = 0;
687 
688 
689  // loop on PSimHits
690 
691  for ( ; isim != lastSimHit; ++isim ) {
692  ++simHitCounter;
693 
694  DetId det((*isim).detUnitId());
695  const GeomDetUnit & theDetUnit = *geometry->idToDetUnit(det);
696  unsigned trackID = (*isim).trackId();
697  uint32_t eeID = (*isim).eventId().rawId(); //get the rawId of the eeid for pileup treatment
698 
699 
700 
701 
703 
704  // unsigned int subdetId = det.subdetId();
705  // unsigned int disk = tTopo->pxfDisk(det);
706  // unsigned int side = tTopo->pxfSide(det);
707  // std::cout<< " Pixel Forward Disk Number : "<< disk << " Side : "<<side<<std::endl;
708  // if(subdetId==1 || subdetId==2) std::cout<<" Pixel GSRecHits "<<std::endl;
709  // else if(subdetId==3|| subdetId==4 || subdetId==5 || subdetId == 6) std::cout<<" Strip GSRecHits "<<std::endl;
710 
711  bool isBad = false;
712  unsigned int geoId = det.rawId();
713  for (size_t id=0;id<numberOfDisabledModules;id++) {
714  if(geoId==(*disabledModules)[id].DetID){
715  // Already selected in the beginRun() the ones with errorType = 0
716  // if((*disabledModules)[id].errorType == 0) isBad = true;
717  isBad = true;
718  break;
719  }
720  }
721  if(isBad) continue;
722 
723 
724  ++numberOfPSimHits;
725  // gaussian smearing
726  unsigned int alphaMult = 0;
727  unsigned int betaMult = 0;
728  bool isCreated = gaussianSmearing(*isim, position, error, alphaMult, betaMult, tTopo, random);
729  // std::cout << "Error as simulated " << error.xx() << " " << error.xy() << " " << error.yy() << std::endl;
730  //
731  unsigned int subdet = det.subdetId();
732 
733  //
734  if(isCreated) {
735  // double dist = theDet->surface().toGlobal((*isim).localPosition()).mag2();
736  // create RecHit
737  // Fill the temporary RecHit on the current DetId collection
738  // temporaryRecHits[trackID].push_back(
739 
740  // Fix by P.Azzi, A.Schmidt:
741  // if this hit is on a glued detector with radial topology,
742  // the x-coordinate needs to be translated correctly to y=0.
743  // this is necessary as intermediate step for the matching of hits
744 
745  // do it only if we do rec hit matching
746 // if(doMatching){
747 // StripSubdetector specDetId=StripSubdetector(det);
748 
749 // if(specDetId.glued()) if(subdet==6 || subdet==4){ // check if on double layer in TEC or TID
750 
751 // const GeomDetUnit* theDetUnit = geometry->idToDetUnit(det);
752 // const StripTopology& topol=(const StripTopology&)theDetUnit->type().topology();
753 
754 // // check if radial topology
755 // if(dynamic_cast <const RadialStripTopology*>(&topol)){
756 
757 // const RadialStripTopology *rtopol = dynamic_cast <const RadialStripTopology*>(&topol);
758 
759 // // translate to measurement coordinates
760 // MeasurementPoint mpoint=rtopol->measurementPosition(position);
761 // // set y=0
762 // MeasurementPoint mpoint0=MeasurementPoint(mpoint.x(),0.);
763 // // translate back to local coordinates with y=0
764 // LocalPoint lpoint0 = rtopol->localPosition(mpoint0);
765 // position = Local3DPoint(lpoint0.x(),0.,0.);
766 
767 // }
768 // } // end if( specDetId.glued()...
769 // } // end if(doMatching)
770 
771  // set y=0 in single-sided strip detectors
772  if(doMatching && (subdet>2)){
773  StripSubdetector specDetId=StripSubdetector(det);
774  if( !specDetId.glued() ){ // this is a single-sided module
775  position = Local3DPoint(position.x(),0.,0.); // set y to 0 on single-sided modules
776  }
777  }
778  else{ if(subdet>2) position = Local3DPoint(position.x(),0.,0.); } // no matching, set y=0 on strips
779 
780 
781  // Inflate errors in case of geometry misaligniment
782  // (still needed! what done in constructor of BaseTrackerRecHit is not effective ad geometry is not missaligned)
783  auto theMADet = misAlignedGeometry->idToDet(det);
784  auto const & lape = theMADet->localAlignmentError();
785  if ( lape.valid() )
786  error = LocalError ( error.xx()+lape.xx(),
787  error.xy()+lape.xy(),
788  error.yy()+lape.yy() );
789 
790  float chargeADC = (*isim).energyLoss()/(GevPerElectron * ElectronsPerADC);
791 
792  //create cluster
793  if(subdet > 2) theClusters[trackID].push_back(
794  new FastTrackerCluster(LocalPoint(position.x(), 0.0, 0.0), error, det,
795  simHitCounter, trackID,
796  eeID,
797  //(*isim).energyLoss())
798  chargeADC)
799  );
800  else theClusters[trackID].push_back(
801  new FastTrackerCluster(position, error, det,
802  simHitCounter, trackID,
803  eeID,
804  //(*isim).energyLoss())
805  chargeADC)
806  );
807 
808  // std::cout << "CLUSTER for simhit " << simHitCounter << "\t energy loss = " <<chargeADC << std::endl;
809 
810  // std::cout << "Error as reconstructed " << error.xx() << " " << error.xy() << " " << error.yy() << std::endl;
811 
812  // create rechit
813  temporaryRecHits[trackID].push_back(
814  new SiTrackerGSRecHit2D(position, error, theDetUnit,
815  simHitCounter, trackID,
816  eeID,
817  ClusterRef(FastTrackerClusterRefProd, simHitCounter),
818  alphaMult, betaMult)
819  );
820 
821  // This a correpondence map between RecHits and SimHits
822  // (for later use in matchHits)
823  correspondingSimHit[recHitCounter++] = isim;
824 
825 
826  } // end if(isCreated)
827 
828  } // end loop on PSimHits
829 
830 
831 }
832 
835  LocalError& error,
836  unsigned& alphaMult,
837  unsigned& betaMult,
838  const TrackerTopology *tTopo,
840 {
841 
842  // A few caracteritics of the detid the SimHit belongs to.
843  unsigned int subdet = DetId(simHit.detUnitId()).subdetId();
844  unsigned int detid = DetId(simHit.detUnitId()).rawId();
845  const GeomDetUnit* theDetUnit = geometry->idToDetUnit((DetId)simHit.detUnitId());
846  const BoundPlane& theDetPlane = theDetUnit->surface();
847  const Bounds& theBounds = theDetPlane.bounds();
848  double boundX = theBounds.width()/2.;
849  double boundY = theBounds.length()/2.;
850 
851 #ifdef FAMOS_DEBUG
852  std::cout << "\tSubdetector " << subdet
853  << " rawid " << detid
854  << std::endl;
855 #endif
856  if(trackingPSimHits) {
857  // z is fixed for all detectors, in case of errors resolution is fixed also for x and y to 1 um (zero)
858  // The Matrix is the Covariance Matrix, sigma^2 on diagonal!!!
860  0.0 ,
861  localPositionResolution_z * localPositionResolution_z );
862  //
863  // starting from PSimHit local position
864  position = simHit.localPosition();
865 #ifdef FAMOS_DEBUG
866  std::cout << " Tracking PSimHit position set to " << position;
867 #endif
868  return true; // RecHit == PSimHit with 100% hit finding efficiency
869  }
870  //
871 
872  // hit finding probability --> RecHit will be created if and only if hitFindingProbability <= theHitFindingProbability_###
873  double hitFindingProbability = random->flatShoot();
874 #ifdef FAMOS_DEBUG
875  std::cout << " Hit finding probability draw: " << hitFindingProbability << std::endl;;
876 #endif
877 
878  switch (subdet) {
879  // Pixel Barrel
880  case 1:
881  {
882 #ifdef FAMOS_DEBUG
883 
884  unsigned int theLayer = tTopo->pxbLayer(detid);
885  std::cout << "\tPixel Barrel Layer " << theLayer << std::endl;
886 #endif
887  if( hitFindingProbability > theHitFindingProbability_PXB ) return false;
888  // Hit smearing
889  const PixelGeomDetUnit* pixelDetUnit = dynamic_cast<const PixelGeomDetUnit*>(theDetUnit);
890  thePixelBarrelParametrization->smearHit(simHit, pixelDetUnit, boundX, boundY, random);
895  return true;
896  break;
897  }
898  // Pixel Forward
899  case 2:
900  {
901 #ifdef FAMOS_DEBUG
902 
903  unsigned int theDisk = tTopo->pxfDisk(detid);
904  std::cout << "\tPixel Forward Disk " << theDisk << std::endl;
905 #endif
906  if( hitFindingProbability > theHitFindingProbability_PXF ) return false;
907  // Hit smearing
908  const PixelGeomDetUnit* pixelDetUnit = dynamic_cast<const PixelGeomDetUnit*>(theDetUnit);
909  thePixelEndcapParametrization->smearHit(simHit, pixelDetUnit, boundX, boundY, random);
914  return true;
915  break;
916  }
917  // TIB
918  case 3:
919  {
920 
921  unsigned int theLayer = tTopo->tibLayer(detid);
922 #ifdef FAMOS_DEBUG
923  std::cout << "\tTIB Layer " << theLayer << std::endl;
924 #endif
925  //
926  double resolutionX, resolutionY, resolutionZ;
927  resolutionZ = localPositionResolution_z;
928 
929  switch (theLayer) {
930  case 1:
931  {
932  resolutionX = localPositionResolution_TIB1x;
933  resolutionY = localPositionResolution_TIB1y;
934  if( hitFindingProbability > theHitFindingProbability_TIB1 ) return false;
935  break;
936  }
937  case 2:
938  {
939  resolutionX = localPositionResolution_TIB2x;
940  resolutionY = localPositionResolution_TIB2y;
941  if( hitFindingProbability > theHitFindingProbability_TIB2 ) return false;
942  break;
943  }
944  case 3:
945  {
946  resolutionX = localPositionResolution_TIB3x;
947  resolutionY = localPositionResolution_TIB3y;
948  if( hitFindingProbability > theHitFindingProbability_TIB3 ) return false;
949  break;
950  }
951  case 4:
952  {
953  resolutionX = localPositionResolution_TIB4x;
954  resolutionY = localPositionResolution_TIB4y;
955  if( hitFindingProbability > theHitFindingProbability_TIB4 ) return false;
956  break;
957  }
958  default:
959  {
960  edm::LogError ("SiTrackerGaussianSmearingRecHits")
961  << "\tTIB Layer not valid " << theLayer << std::endl;
962  return false;
963  break;
964  }
965  }
966 
967  // Gaussian smearing
968  theSiStripErrorParametrization->smearHit(simHit, resolutionX, resolutionY, resolutionZ, boundX, boundY, random);
971  alphaMult = 0;
972  betaMult = 0;
973  return true;
974  break;
975  } // TIB
976 
977  // TID
978  case 4:
979  {
980 
981  unsigned int theRing = tTopo->tidRing(detid);
982  double resolutionFactorY =
983  1. - simHit.localPosition().y() / theDetPlane.position().perp();
984 
985 #ifdef FAMOS_DEBUG
986  std::cout << "\tTID Ring " << theRing << std::endl;
987 #endif
988  double resolutionX, resolutionY, resolutionZ;
989  resolutionZ = localPositionResolution_z;
990 
991  switch (theRing) {
992  case 1:
993  {
994  resolutionX = localPositionResolution_TID1x * resolutionFactorY;
995  resolutionY = localPositionResolution_TID1y;
996  if( hitFindingProbability > theHitFindingProbability_TID1 ) return false;
997  break;
998  }
999  case 2:
1000  {
1001  resolutionX = localPositionResolution_TID2x * resolutionFactorY;
1002  resolutionY = localPositionResolution_TID2y;
1003  if( hitFindingProbability > theHitFindingProbability_TID2 ) return false;
1004  break;
1005  }
1006  case 3:
1007  {
1008  resolutionX = localPositionResolution_TID3x * resolutionFactorY;
1009  resolutionY = localPositionResolution_TID3y;
1010  if( hitFindingProbability > theHitFindingProbability_TID3 ) return false;
1011  break;
1012  }
1013  default:
1014  {
1015  edm::LogError ("SiTrackerGaussianSmearingRecHits")
1016  << "\tTID Ring not valid " << theRing << std::endl;
1017  return false;
1018  break;
1019  }
1020  }
1021 
1022  boundX *= resolutionFactorY;
1023 
1024  theSiStripErrorParametrization->smearHit(simHit, resolutionX, resolutionY, resolutionZ, boundX, boundY, random);
1027  alphaMult = 0;
1028  betaMult = 0;
1029  return true;
1030  break;
1031  } // TID
1032 
1033  // TOB
1034  case 5:
1035  {
1036 
1037  unsigned int theLayer = tTopo->tobLayer(detid);
1038 #ifdef FAMOS_DEBUG
1039  std::cout << "\tTOB Layer " << theLayer << std::endl;
1040 #endif
1041  double resolutionX, resolutionY, resolutionZ;
1042  resolutionZ = localPositionResolution_z;
1043 
1044  switch (theLayer) {
1045  case 1:
1046  {
1047  resolutionX = localPositionResolution_TOB1x;
1048  resolutionY = localPositionResolution_TOB1y;
1049  if( hitFindingProbability > theHitFindingProbability_TOB1 ) return false;
1050  break;
1051  }
1052  case 2:
1053  {
1054  resolutionX = localPositionResolution_TOB2x;
1055  resolutionY = localPositionResolution_TOB2y;
1056  if( hitFindingProbability > theHitFindingProbability_TOB2 ) return false;
1057  break;
1058  }
1059  case 3:
1060  {
1061  resolutionX = localPositionResolution_TOB3x;
1062  resolutionY = localPositionResolution_TOB3y;
1063  if( hitFindingProbability > theHitFindingProbability_TOB3 ) return false;
1064  break;
1065  }
1066  case 4:
1067  {
1068  resolutionX = localPositionResolution_TOB4x;
1069  resolutionY = localPositionResolution_TOB4y;
1070  if( hitFindingProbability > theHitFindingProbability_TOB4 ) return false;
1071  break;
1072  }
1073  case 5:
1074  {
1075  resolutionX = localPositionResolution_TOB5x;
1076  resolutionY = localPositionResolution_TOB5y;
1077  if( hitFindingProbability > theHitFindingProbability_TOB5 ) return false;
1078  break;
1079  }
1080  case 6:
1081  {
1082  resolutionX = localPositionResolution_TOB6x;
1083  resolutionY = localPositionResolution_TOB6y;
1084  if( hitFindingProbability > theHitFindingProbability_TOB6 ) return false;
1085  break;
1086  }
1087  default:
1088  {
1089  edm::LogError ("SiTrackerGaussianSmearingRecHits")
1090  << "\tTOB Layer not valid " << theLayer << std::endl;
1091  return false;
1092  break;
1093  }
1094  }
1095  theSiStripErrorParametrization->smearHit(simHit, resolutionX, resolutionY, resolutionZ, boundX, boundY, random);
1098  alphaMult = 0;
1099  betaMult = 0;
1100  return true;
1101  break;
1102  } // TOB
1103 
1104  // TEC
1105  case 6:
1106  {
1107 
1108  unsigned int theRing = tTopo->tecRing(detid);
1109  double resolutionFactorY =
1110  1. - simHit.localPosition().y() / theDetPlane.position().perp();
1111 
1112 #ifdef FAMOS_DEBUG
1113  std::cout << "\tTEC Ring " << theRing << std::endl;
1114 #endif
1115  double resolutionX, resolutionY, resolutionZ;
1117 
1118  switch (theRing) {
1119  case 1:
1120  {
1121  resolutionX = localPositionResolution_TEC1x * resolutionFactorY;
1122  resolutionY = localPositionResolution_TEC1y;
1123  if( hitFindingProbability > theHitFindingProbability_TEC1 ) return false;
1124  break;
1125  }
1126  case 2:
1127  {
1128  resolutionX = localPositionResolution_TEC2x * resolutionFactorY;
1129  resolutionY = localPositionResolution_TEC2y;
1130  if( hitFindingProbability > theHitFindingProbability_TEC2 ) return false;
1131  break;
1132  }
1133  case 3:
1134  {
1135  resolutionX = localPositionResolution_TEC3x * resolutionFactorY;
1136  resolutionY = localPositionResolution_TEC3y;
1137  if( hitFindingProbability > theHitFindingProbability_TEC3 ) return false;
1138  break;
1139  }
1140  case 4:
1141  {
1142  resolutionX = localPositionResolution_TEC4x * resolutionFactorY;
1143  resolutionY = localPositionResolution_TEC4y;
1144  if( hitFindingProbability > theHitFindingProbability_TEC4 ) return false;
1145  break;
1146  }
1147  case 5:
1148  {
1149  resolutionX = localPositionResolution_TEC5x * resolutionFactorY;
1150  resolutionY = localPositionResolution_TEC5y;
1151  if( hitFindingProbability > theHitFindingProbability_TEC5 ) return false;
1152  break;
1153  }
1154  case 6:
1155  {
1156  resolutionX = localPositionResolution_TEC6x * resolutionFactorY;
1157  resolutionY = localPositionResolution_TEC6y;
1158  if( hitFindingProbability > theHitFindingProbability_TEC6 ) return false;
1159  break;
1160  }
1161  case 7:
1162  {
1163  resolutionX = localPositionResolution_TEC7x * resolutionFactorY;
1164  resolutionY = localPositionResolution_TEC7y;
1165  if( hitFindingProbability > theHitFindingProbability_TEC7 ) return false;
1166  break;
1167  }
1168  default:
1169  {
1170  edm::LogError ("SiTrackerGaussianSmearingRecHits")
1171  << "\tTEC Ring not valid " << theRing << std::endl;
1172  return false;
1173  break;
1174  }
1175  }
1176 
1177  boundX *= resolutionFactorY;
1178  theSiStripErrorParametrization->smearHit(simHit, resolutionX, resolutionY, resolutionZ, boundX, boundY, random);
1181  alphaMult = 0;
1182  betaMult = 0;
1183  return true;
1184  break;
1185  } // TEC
1186 
1187  default:
1188  {
1189  edm::LogError ("SiTrackerGaussianSmearingRecHits") << "\tTracker subdetector not valid " << subdet << std::endl;
1190  return false;
1191  break;
1192  }
1193 
1194  } // subdetector case
1195  //
1196 }
1197 
1198 
1199 
1200 void
1202  std::map<unsigned,edm::OwnVector<FastTrackerCluster> >& theClusterMap,
1203  FastTrackerClusterCollection& theClusterCollection) const
1204 {
1205  std::map<unsigned,edm::OwnVector<FastTrackerCluster> >::const_iterator
1206  it = theClusterMap.begin();
1207  std::map<unsigned,edm::OwnVector<FastTrackerCluster> >::const_iterator
1208  lastCluster = theClusterMap.end();
1209 
1210  for( ; it != lastCluster ; ++it ) {
1211  theClusterCollection.put(it->first,(it->second).begin(),(it->second).end());
1212  }
1213 }
1214 
1215 
1216 
1217 void
1219  std::map<unsigned,edm::OwnVector<SiTrackerGSRecHit2D> >& theRecHits,
1220  SiTrackerGSRecHit2DCollection& theRecHitCollection) const
1221 {
1222  std::map<unsigned,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
1223  it = theRecHits.begin();
1224  std::map<unsigned,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
1225  lastRecHit = theRecHits.end();
1226 
1227  for( ; it != lastRecHit ; ++it ) {
1228  theRecHitCollection.put(it->first,(it->second).begin(),(it->second).end());
1229  }
1230 
1231 }
1232 
1233 void
1235  std::map<unsigned,edm::OwnVector<SiTrackerGSMatchedRecHit2D> >& theRecHits,
1236  SiTrackerGSMatchedRecHit2DCollection& theRecHitCollection) const
1237 {
1238  std::map<unsigned,edm::OwnVector<SiTrackerGSMatchedRecHit2D> >::const_iterator
1239  it = theRecHits.begin();
1240  std::map<unsigned,edm::OwnVector<SiTrackerGSMatchedRecHit2D> >::const_iterator
1241  lastRecHit = theRecHits.end();
1242 
1243  for( ; it != lastRecHit ; ++it ) {
1244  theRecHitCollection.put(it->first,(it->second).begin(),(it->second).end());
1245  }
1246 
1247 }
1248 
1249 
1250 void
1252  std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >& theRecHits,
1253  std::map<unsigned, edm::OwnVector<SiTrackerGSMatchedRecHit2D> >& matchedMap) {//,
1254  // MixCollection<PSimHit>& simhits ) {
1255 // const edm::PSimHitContainer& simhits ) { // not used in the function??? (AG)
1256 
1257 
1258  std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >::iterator it = theRecHits.begin();
1259  std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >::iterator lastTrack = theRecHits.end();
1260 
1261 
1262  int recHitCounter = 0;
1263 
1264 
1265  //loop over single sided tracker RecHit
1266  for( ; it != lastTrack; ++it ) {
1267 
1268  edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator rit = it->second.begin();
1269  edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator firstRecHit = it->second.begin();
1270  edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator lastRecHit = it->second.end();
1271 
1272  //loop over rechits in track
1273  for ( ; rit != lastRecHit; ++rit,++recHitCounter){
1274 
1275  DetId detid = rit->geographicalId();
1276  unsigned int subdet = detid.subdetId();
1277  // if in the strip (subdet>2)
1278  if(subdet>2){
1279 
1280  StripSubdetector specDetId=StripSubdetector(detid);
1281 
1282  // if this is on a glued, then place only one hit in vector
1283  if(specDetId.glued()){
1284 
1285  // get the track direction from the simhit
1286  LocalVector simtrackdir = correspondingSimHit[recHitCounter]->localDirection();
1287 
1288  const GluedGeomDet* gluedDet = (const GluedGeomDet*)geometry->idToDet(DetId(specDetId.glued()));
1289  const StripGeomDetUnit* stripdet =(StripGeomDetUnit*) gluedDet->stereoDet();
1290 
1291  // global direction of track
1292  GlobalVector globaldir= stripdet->surface().toGlobal(simtrackdir);
1293  LocalVector gluedsimtrackdir=gluedDet->surface().toLocal(globaldir);
1294 
1295  // get partner layer, it is the next one or previous one in the vector
1299  partnerNext++; partnerPrev--;
1300 
1301  // check if this hit is on a stereo layer (== the second layer of a double sided module)
1302  if( specDetId.stereo() ) {
1303 
1304  int partnersFound = 0;
1305  // check next one in vector
1306  // safety check first
1307  if(partnerNext != it->second.end() )
1308  if( StripSubdetector( partnerNext->geographicalId() ).partnerDetId() == detid.rawId() ) {
1309  partner= partnerNext;
1310  partnersFound++;
1311  }
1312  // check prevoius one in vector
1313  if( rit != it->second.begin())
1314  if( StripSubdetector( partnerPrev->geographicalId() ).partnerDetId() == detid.rawId() ) {
1315  partnersFound++;
1316  partner= partnerPrev;
1317  }
1318 
1319 
1320  // in case partner has not been found this way, need to loop over all rechits in track to be sure
1321  // (rare cases fortunately)
1322  if(partnersFound==0){
1323  for(edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator iter = firstRecHit; iter != lastRecHit; ++iter ){
1324  if( StripSubdetector( iter->geographicalId() ).partnerDetId() == detid.rawId()){
1325  partnersFound++;
1326  partner = iter;
1327  }
1328  }
1329  }
1330 
1331  if(partnersFound == 1) {
1332  SiTrackerGSMatchedRecHit2D * theMatchedHit =GSRecHitMatcher().match( &(*partner), &(*rit), gluedDet , gluedsimtrackdir );
1333 
1334 
1335  // std::cout << "Matched hit: isMatched =\t" << theMatchedHit->isMatched() << ", "
1336  // << theMatchedHit->monoHit() << ", " << theMatchedHit->stereoHit() << std::endl;
1337 
1338  matchedMap[it->first].push_back( theMatchedHit );
1339  }
1340  else{
1341  // no partner to match, place projected one in map
1342  SiTrackerGSMatchedRecHit2D * theProjectedHit = GSRecHitMatcher().projectOnly( &(*rit), geometry->idToDet(detid),gluedDet, gluedsimtrackdir );
1343  matchedMap[it->first].push_back( theProjectedHit );
1344  //there is no partner here
1345  }
1346  } // end if stereo
1347  else { // we are on a mono layer
1348  // usually this hit is already matched, but not if stereo hit is missing (rare cases)
1349  // check if stereo hit is missing
1350  int partnersFound = 0;
1351  // check next one in vector
1352  // safety check first
1353  if(partnerNext != it->second.end() )
1354  if( StripSubdetector( partnerNext->geographicalId() ).partnerDetId() == detid.rawId() ) {
1355  partnersFound++;
1356  }
1357  // check prevoius one in vector
1358  if( rit != it->second.begin())
1359  if( StripSubdetector( partnerPrev->geographicalId() ).partnerDetId() == detid.rawId() ) {
1360  partnersFound++;
1361  }
1362 
1363  if(partnersFound==0){ // no partner hit found this way, need to iterate over all hits to be sure (rare cases)
1364  for(edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator iter = firstRecHit; iter != lastRecHit; ++iter ){
1365  if( StripSubdetector( iter->geographicalId() ).partnerDetId() == detid.rawId()){
1366  partnersFound++;
1367  }
1368  }
1369  }
1370 
1371 
1372  if(partnersFound==0){ // no partner hit found
1373  // no partner to match, place projected one one in map
1374  SiTrackerGSMatchedRecHit2D * theProjectedHit =
1375  GSRecHitMatcher().projectOnly( &(*rit), geometry->idToDet(detid),gluedDet, gluedsimtrackdir );
1376 
1377  //std::cout << "Projected hit: isMatched =\t" << theProjectedHit->isMatched() << ", "
1378  // << theProjectedHit->monoHit() << ", " << theProjectedHit->stereoHit() << std::endl;
1379 
1380  matchedMap[it->first].push_back( theProjectedHit );
1381  }
1382  } // end we are on a a mono layer
1383  } // end if glued
1384  // else matchedMap[it->first].push_back( rit->clone() ); // if not glued place the original one in vector
1385  else{ //need to copy the original in a "matched" type rechit
1386 
1387  SiTrackerGSMatchedRecHit2D* rit_copy = new SiTrackerGSMatchedRecHit2D(rit->localPosition(), rit->localPositionError(),
1388  *rit->det(),
1389  rit->simhitId(), rit->simtrackId(), rit->eeId(),
1390  rit->cluster(),
1391  rit->simMultX(), rit->simMultY());
1392  //std::cout << "Simple hit hit: isMatched =\t" << rit_copy->isMatched() << ", "
1393  // << rit_copy->monoHit() << ", " << rit_copy->stereoHit() << std::endl;
1394 
1395  matchedMap[it->first].push_back( rit_copy ); // if not strip place the original one in vector (making it into a matched)
1396  }
1397 
1398  }// end if strip
1399  // else matchedMap[it->first].push_back( rit->clone() ); // if not strip place the original one in vector
1400  else { //need to copy the original in a "matched" type rechit
1401 
1402  SiTrackerGSMatchedRecHit2D* rit_copy = new SiTrackerGSMatchedRecHit2D(rit->localPosition(), rit->localPositionError(),
1403  *rit->det(),
1404  rit->simhitId(), rit->simtrackId(), rit->eeId(),
1405  rit->cluster(),
1406  rit->simMultX(), rit->simMultY());
1407 
1408  //std::cout << "Simple hit hit: isMatched =\t" << rit_copy->isMatched() << ", "
1409  // << rit_copy->monoHit() << ", " << rit_copy->stereoHit() << std::endl;
1410  matchedMap[it->first].push_back( rit_copy ); // if not strip place the original one in vector (makining it into a matched)
1411  }
1412 
1413  } // end loop over rechits
1414 
1415  }// end loop over tracks
1416 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
T getParameter(std::string const &) const
virtual const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
void loadRecHits(std::map< unsigned, edm::OwnVector< SiTrackerGSRecHit2D > > &theRecHits, SiTrackerGSRecHit2DCollection &theRecHitCollection) const
SiStripGaussianSmearingRecHitConverterAlgorithm * theSiStripErrorParametrization
virtual float length() const =0
unsigned int tibLayer(const DetId &id) const
unsigned int tidRing(const DetId &id) const
bool gaussianSmearing(const PSimHit &simHit, Local3DPoint &position, LocalError &error, unsigned &alphaMult, unsigned &betaMult, const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
SiPixelGaussianSmearingRecHitConverterAlgorithm * thePixelEndcapParametrization
double flatShoot(double xmin=0.0, double xmax=1.0) const
SiTrackerGSMatchedRecHit2D * match(const SiTrackerGSRecHit2D *monoRH, const SiTrackerGSRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector &trackdirection) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
unsigned int pxfDisk(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
tuple magfield
Definition: HLT_ES_cff.py:2311
T y() const
Definition: PV3DBase.h:63
void smearHits(const edm::PSimHitContainer &input, std::map< unsigned, edm::OwnVector< SiTrackerGSRecHit2D > > &theRecHits, std::map< unsigned, edm::OwnVector< FastTrackerCluster > > &theClusters, const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
void loadClusters(std::map< unsigned, edm::OwnVector< FastTrackerCluster > > &theClusterMap, FastTrackerClusterCollection &theClusterCollection) const
TRandom random
Definition: MVATrainer.cc:138
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
static std::string const input
Definition: EdmProvDump.cc:43
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
float xy() const
Definition: LocalError.h:25
unsigned int glued() const
glued
T mag() const
Definition: PV3DBase.h:67
float yy() const
Definition: LocalError.h:26
Local3DPoint localPosition() const
Definition: PSimHit.h:44
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
LocalPoint toLocal(const GlobalPoint &gp) const
void loadMatchedRecHits(std::map< unsigned, edm::OwnVector< SiTrackerGSMatchedRecHit2D > > &theRecHits, SiTrackerGSMatchedRecHit2DCollection &theRecHitCollection) const
#define end
Definition: vmac.h:37
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
SiPixelGaussianSmearingRecHitConverterAlgorithm * thePixelBarrelParametrization
std::vector< SiPixelQuality::disabledModuleType > * disabledModules
RefProd< PROD > getRefBeforePut()
Definition: Event.h:133
tuple conf
Definition: dbtoconf.py:185
void put(ID id, CI begin, CI end)
insert an object range with specified identifier
Definition: RangeMap.h:117
unsigned int pxbLayer(const DetId &id) const
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
Definition: DetId.h:18
unsigned int stereo() const
stereo
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
virtual void beginRun(edm::Run const &run, const edm::EventSetup &es) override
const T & get() const
Definition: EventSetup.h:55
SiTrackerGSMatchedRecHit2D * projectOnly(const SiTrackerGSRecHit2D *monoRH, const GeomDet *monoDet, const GluedGeomDet *gluedDet, LocalVector &ldir) const
void matchHits(std::map< unsigned, edm::OwnVector< SiTrackerGSRecHit2D > > &theRecHits, std::map< unsigned, edm::OwnVector< SiTrackerGSMatchedRecHit2D > > &matchedMap)
void smearHit(const PSimHit &simHit, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, RandomEngineAndDistribution const *)
static int position[264][3]
Definition: ReadPGInfo.cc:509
StreamID streamID() const
Definition: Event.h:72
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
tuple cout
Definition: gather_cfg.py:121
std::vector< PSimHit > PSimHitContainer
Definition: Bounds.h:22
T x() const
Definition: PV3DBase.h:62
virtual float width() const =0
LocalError const & localAlignmentError() const
Return local alligment error.
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
unsigned int detUnitId() const
Definition: PSimHit.h:93
unsigned int tobLayer(const DetId &id) const
Definition: Run.h:41
void smearHit(const PSimHit &simHit, double localPositionResolutionX, double localPositionResolutionY, double localPositionResolutionZ, double boundX, double boundY, RandomEngineAndDistribution const *)
virtual const TrackerGeomDet * idToDet(DetId) const