CMS 3D CMS Logo

LaserAlignment.cc
Go to the documentation of this file.
1 
17 
22  : topoToken_(esConsumes()),
23  geomToken_(esConsumes()),
24  geomDetToken_(esConsumes()),
25  ptpToken_(esConsumes()),
26  gprToken_(esConsumes()),
27  stripPedestalsToken_(esConsumes()),
28  theEvents(0),
29  theDoPedestalSubtraction(theConf.getUntrackedParameter<bool>("SubtractPedestals", true)),
30  theUseMinuitAlgorithm(theConf.getUntrackedParameter<bool>("RunMinuitAlignmentTubeAlgorithm", false)),
31  theApplyBeamKinkCorrections(theConf.getUntrackedParameter<bool>("ApplyBeamKinkCorrections", true)),
32  peakFinderThreshold(theConf.getUntrackedParameter<double>("PeakFinderThreshold", 10.)),
33  enableJudgeZeroFilter(theConf.getUntrackedParameter<bool>("EnableJudgeZeroFilter", true)),
34  judgeOverdriveThreshold(theConf.getUntrackedParameter<unsigned int>("JudgeOverdriveThreshold", 220)),
35  updateFromInputGeometry(theConf.getUntrackedParameter<bool>("UpdateFromInputGeometry", false)),
36  misalignedByRefGeometry(theConf.getUntrackedParameter<bool>("MisalignedByRefGeometry", false)),
37  theStoreToDB(theConf.getUntrackedParameter<bool>("SaveToDbase", false)),
38  theDigiProducersList(theConf.getParameter<std::vector<edm::ParameterSet> >("DigiProducersList")),
39  theSaveHistograms(theConf.getUntrackedParameter<bool>("SaveHistograms", false)),
40  theCompression(theConf.getUntrackedParameter<int>("ROOTFileCompression", 1)),
41  theFileName(theConf.getUntrackedParameter<std::string>("ROOTFileName", "test.root")),
42  theMaskTecModules(theConf.getUntrackedParameter<std::vector<unsigned int> >("MaskTECModules")),
43  theMaskAtModules(theConf.getUntrackedParameter<std::vector<unsigned int> >("MaskATModules")),
44  theSetNominalStrips(theConf.getUntrackedParameter<bool>("ForceFitterToNominalStrips", false)),
45  theLasConstants(theConf.getUntrackedParameter<std::vector<edm::ParameterSet> >("LaserAlignmentConstants")),
46  theFile(),
47  theAlignableTracker(),
48  theAlignRecordName("TrackerAlignmentRcd"),
49  theErrorRecordName("TrackerAlignmentErrorExtendedRcd"),
50  firstEvent_(true) {
51  std::cout << std::endl;
52  std::cout << "=============================================================="
53  << "\n=== LaserAlignment module configuration ==="
54  << "\n"
55  << "\n Write histograms to file = " << (theSaveHistograms ? "true" : "false")
56  << "\n Histogram file name = " << theFileName
57  << "\n Histogram file compression = " << theCompression
58  << "\n Subtract pedestals = " << (theDoPedestalSubtraction ? "true" : "false")
59  << "\n Run Minuit AT algorithm = " << (theUseMinuitAlgorithm ? "true" : "false")
60  << "\n Apply beam kink corrections = " << (theApplyBeamKinkCorrections ? "true" : "false")
61  << "\n Peak Finder Threshold = " << peakFinderThreshold
62  << "\n EnableJudgeZeroFilter = " << (enableJudgeZeroFilter ? "true" : "false")
63  << "\n JudgeOverdriveThreshold = " << judgeOverdriveThreshold
64  << "\n Update from input geometry = " << (updateFromInputGeometry ? "true" : "false")
65  << "\n Misalignment from ref geometry = " << (misalignedByRefGeometry ? "true" : "false")
66  << "\n Number of TEC modules masked = " << theMaskTecModules.size() << " (s. below list if > 0)"
67  << "\n Number of AT modules masked = " << theMaskAtModules.size() << " (s. below list if > 0)"
68  << "\n Store to database = " << (theStoreToDB ? "true" : "false")
69  << "\n ----------------------------------------------- ----------"
70  << (theSetNominalStrips ? "\n Set strips to nominal = true" : "\n")
71  << "\n=============================================================" << std::endl;
72 
73  // tell about masked modules
74  if (!theMaskTecModules.empty()) {
75  std::cout << " ===============================================================================================\n"
76  << std::flush;
77  std::cout << " The following " << theMaskTecModules.size()
78  << " TEC modules have been masked out and will not be considered by the TEC algorithm:\n " << std::flush;
79  for (std::vector<unsigned int>::iterator moduleIt = theMaskTecModules.begin(); moduleIt != theMaskTecModules.end();
80  ++moduleIt) {
81  std::cout << *moduleIt << (moduleIt != --theMaskTecModules.end() ? ", " : "") << std::flush;
82  }
83  std::cout << std::endl << std::flush;
84  std::cout << " ===============================================================================================\n\n"
85  << std::flush;
86  }
87  if (!theMaskAtModules.empty()) {
88  std::cout << " ===============================================================================================\n"
89  << std::flush;
90  std::cout << " The following " << theMaskAtModules.size()
91  << " AT modules have been masked out and will not be considered by the AT algorithm:\n " << std::flush;
92  for (std::vector<unsigned int>::iterator moduleIt = theMaskAtModules.begin(); moduleIt != theMaskAtModules.end();
93  ++moduleIt) {
94  std::cout << *moduleIt << (moduleIt != --theMaskAtModules.end() ? ", " : "") << std::flush;
95  }
96  std::cout << std::endl << std::flush;
97  std::cout << " ===============================================================================================\n\n"
98  << std::flush;
99  }
100 
101  // alias for the Branches in the root files
102  std::string alias(theConf.getParameter<std::string>("@module_label"));
103 
104  // declare the product to produce
105  produces<TkLasBeamCollection, edm::Transition::EndRun>("tkLaserBeams").setBranchAlias(alias + "TkLasBeamCollection");
106 
107  // switch judge's zero filter depending on cfg
109 
110  // set the upper threshold for zero suppressed data
112 }
113 
118  if (theSaveHistograms)
119  theFile->Write();
120  if (theFile) {
121  delete theFile;
122  }
123  if (theAlignableTracker) {
124  delete theAlignableTracker;
125  }
126 }
127 
132  // write sumed histograms to file (if selected in cfg)
133  if (theSaveHistograms) {
134  // creating a new file
135  theFile = new TFile(theFileName.c_str(), "RECREATE", "CMS ROOT file");
136 
137  // initialize the histograms
138  if (theFile) {
139  theFile->SetCompressionLevel(theCompression);
140  singleModulesDir = theFile->mkdir("single modules");
141  } else
142  throw cms::Exception(" [LaserAlignment::beginJob]")
143  << " ** ERROR: could not open file:" << theFileName.c_str() << " for writing." << std::endl;
144  }
145 
146  // detector id maps (hard coded)
147  fillDetectorId();
148 
149  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150  // PROFILE, HISTOGRAM & FITFUNCTION INITIALIZATION
151  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152 
153  // object used to build various strings for names and labels
154  std::stringstream nameBuilder;
155 
156  // loop variables for use with LASGlobalLoop object
157  int det, ring, beam, disk, pos;
158 
159  // loop TEC modules
160  det = 0;
161  ring = 0;
162  beam = 0;
163  disk = 0;
164  do { // loop using LASGlobalLoop functionality
165  // init the profiles
169 
170  // init the hit maps
171  isAcceptedProfile.SetTECEntry(det, ring, beam, disk, 0);
173 
174  // create strings for histo names
175  nameBuilder.clear();
176  nameBuilder.str("");
177  nameBuilder << "TEC";
178  if (det == 0)
179  nameBuilder << "+";
180  else
181  nameBuilder << "-";
182  nameBuilder << "_Ring";
183  if (ring == 0)
184  nameBuilder << "4";
185  else
186  nameBuilder << "6";
187  nameBuilder << "_Beam" << beam;
188  nameBuilder << "_Disk" << disk;
189  theProfileNames.SetTECEntry(det, ring, beam, disk, nameBuilder.str());
190 
191  // init the histograms
192  if (theSaveHistograms) {
193  nameBuilder << "_Histo";
195  det, ring, beam, disk, new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
196  summedHistograms.GetTECEntry(det, ring, beam, disk)->SetDirectory(singleModulesDir);
197  }
198 
199  } while (moduleLoop.TECLoop(det, ring, beam, disk));
200 
201  // TIB & TOB section
202  det = 2;
203  beam = 0;
204  pos = 0;
205  do { // loop using LASGlobalLoop functionality
206  // init the profiles
210 
211  // init the hit maps
214 
215  // create strings for histo names
216  nameBuilder.clear();
217  nameBuilder.str("");
218  if (det == 2)
219  nameBuilder << "TIB";
220  else
221  nameBuilder << "TOB";
222  nameBuilder << "_Beam" << beam;
223  nameBuilder << "_Zpos" << pos;
224 
225  theProfileNames.SetTIBTOBEntry(det, beam, pos, nameBuilder.str());
226 
227  // init the histograms
228  if (theSaveHistograms) {
229  nameBuilder << "_Histo";
231  det, beam, pos, new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
233  }
234 
235  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
236 
237  // TEC2TEC AT section
238  det = 0;
239  beam = 0;
240  disk = 0;
241  do { // loop using LASGlobalLoop functionality
242  // init the profiles
246 
247  // init the hit maps
248  isAcceptedProfile.SetTEC2TECEntry(det, beam, disk, 0);
250 
251  // create strings for histo names
252  nameBuilder.clear();
253  nameBuilder.str("");
254  nameBuilder << "TEC(AT)";
255  if (det == 0)
256  nameBuilder << "+";
257  else
258  nameBuilder << "-";
259  nameBuilder << "_Beam" << beam;
260  nameBuilder << "_Disk" << disk;
261  theProfileNames.SetTEC2TECEntry(det, beam, disk, nameBuilder.str());
262 
263  // init the histograms
264  if (theSaveHistograms) {
265  nameBuilder << "_Histo";
267  det, beam, disk, new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
268  summedHistograms.GetTEC2TECEntry(det, beam, disk)->SetDirectory(singleModulesDir);
269  }
270 
271  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
272 
273  firstEvent_ = true;
274 }
275 
279 void LaserAlignment::produce(edm::Event& theEvent, edm::EventSetup const& theSetup) {
280  if (firstEvent_) {
281  //Retrieve tracker topology from geometry
282  const TrackerTopology* const tTopo = &theSetup.getData(topoToken_);
283 
284  // access the tracker
285  gD = theSetup.getHandle(geomDetToken_);
287 
288  // access pedestals (from db..) if desired
289  edm::ESHandle<SiStripPedestals> pedestalsHandle;
291  pedestalsHandle = theSetup.getHandle(stripPedestalsToken_);
292  fillPedestalProfiles(pedestalsHandle);
293  }
294 
295  // global positions
297 
298  // select the reference geometry
300  // the AlignableTracker object is initialized with the ideal geometry
301  const GeometricDet* theGeometricDet = &theSetup.getData(geomDetToken_);
302  const PTrackerParameters* ptp = &theSetup.getData(ptpToken_);
303 
304  TrackerGeomBuilderFromGeometricDet trackerBuilder;
305  TrackerGeometry* theRefTracker = trackerBuilder.build(&*theGeometricDet, *ptp, tTopo);
306 
307  theAlignableTracker = new AlignableTracker(&(*theRefTracker), tTopo);
308  } else {
309  // the AlignableTracker object is initialized with the input geometry from DB
311  }
312 
313  firstEvent_ = false;
314  }
315 
316  LogDebug("LaserAlignment") << "==========================================================="
317  << "\n Private analysis of event #" << theEvent.id().event() << " in run #"
318  << theEvent.id().run();
319 
320  // do the Tracker Statistics to retrieve the current profiles
321  fillDataProfiles(theEvent, theSetup);
322 
323  // index variables for the LASGlobalLoop object
324  int det, ring, beam, disk, pos;
325 
326  //
327  // first pre-loop on selected entries to find out
328  // whether the TEC or the AT beams have fired
329  // (pedestal profiles are left empty if false in cfg)
330  //
331 
332  // TEC+- (only ring 6)
333  ring = 1;
334  for (det = 0; det < 2; ++det) {
335  for (beam = 0; beam < 8; ++beam) {
336  for (disk = 0; disk < 9; ++disk) {
338  pedestalProfiles.GetTECEntry(det, ring, beam, disk),
339  0)) {
340  isAcceptedProfile.SetTECEntry(det, ring, beam, disk, 1);
341  } else { // assume no initialization
342  isAcceptedProfile.SetTECEntry(det, ring, beam, disk, 0);
343  }
344  }
345  }
346  }
347 
348  // TIBTOB
349  det = 2;
350  beam = 0;
351  pos = 0;
352  do {
353  // add current event's data and subtract pedestals
354  if (judge.IsSignalIn(
358  } else { // dto.
360  }
361 
362  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
363 
364  // now come the beam finders
365  bool isTECMode = isTECBeam();
366  // LogDebug( " [LaserAlignment::produce]" ) << "LaserAlignment::isTECBeam declares this event " << ( isTECMode ? "" : "NOT " ) << "a TEC event." << std::endl;
367  std::cout << " [LaserAlignment::produce] -- LaserAlignment::isTECBeam declares this event "
368  << (isTECMode ? "" : "NOT ") << "a TEC event." << std::endl;
369 
370  bool isATMode = isATBeam();
371  // LogDebug( " [LaserAlignment::produce]" ) << "LaserAlignment::isATBeam declares this event " << ( isATMode ? "" : "NOT " ) << "an AT event." << std::endl;
372  std::cout << " [LaserAlignment::produce] -- LaserAlignment::isATBeam declares this event " << (isATMode ? "" : "NOT ")
373  << "an AT event." << std::endl;
374 
375  //
376  // now pass the pedestal subtracted profiles to the judge
377  // if they're accepted, add them on the collectedDataProfiles
378  // (pedestal profiles are left empty if false in cfg)
379  //
380 
381  // loop TEC+- modules
382  det = 0;
383  ring = 0;
384  beam = 0;
385  disk = 0;
386  do {
387  LogDebug("[LaserAlignment::produce]")
388  << "Profile is: " << theProfileNames.GetTECEntry(det, ring, beam, disk) << "." << std::endl;
389 
390  // this now depends on the AT/TEC mode, is this a doubly hit module? -> look for it in vector<int> tecDoubleHitDetId
391  // (ring == 0 not necessary but makes it a little faster)
392  if (ring == 0 &&
393  find(tecDoubleHitDetId.begin(), tecDoubleHitDetId.end(), detectorId.GetTECEntry(det, ring, beam, disk)) !=
394  tecDoubleHitDetId.end()) {
395  if (isTECMode) { // add profile to TEC collection
396  // add current event's data and subtract pedestals
398  pedestalProfiles.GetTECEntry(det, ring, beam, disk),
399  0)) {
402  pedestalProfiles.GetTECEntry(det, ring, beam, disk);
404  }
405  }
406  }
407 
408  else { // not a doubly hit module, don't care about the mode
409  // add current event's data and subtract pedestals
411  pedestalProfiles.GetTECEntry(det, ring, beam, disk),
412  0)) {
415  pedestalProfiles.GetTECEntry(det, ring, beam, disk);
417  }
418  }
419 
420  } while (moduleLoop.TECLoop(det, ring, beam, disk));
421 
422  // loop TIB/TOB modules
423  det = 2;
424  beam = 0;
425  pos = 0;
426  do {
427  LogDebug("[LaserAlignment::produce]")
428  << "Profile is: " << theProfileNames.GetTIBTOBEntry(det, beam, pos) << "." << std::endl;
429 
430  // add current event's data and subtract pedestals
431  if (judge.JudgeProfile(
437  }
438 
439  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
440 
441  // loop TEC2TEC modules
442  det = 0;
443  beam = 0;
444  disk = 0;
445  do {
446  LogDebug("[LaserAlignment::produce]")
447  << "Profile is: " << theProfileNames.GetTEC2TECEntry(det, beam, disk) << "." << std::endl;
448 
449  // this again depends on the AT/TEC mode, is this a doubly hit module?
450  // (ring == 0 not necessary but makes it a little faster)
451  if (ring == 0 &&
452  find(tecDoubleHitDetId.begin(), tecDoubleHitDetId.end(), detectorId.GetTECEntry(det, ring, beam, disk)) !=
453  tecDoubleHitDetId.end()) {
454  if (isATMode) { // add profile to TEC2TEC collection
455  // add current event's data and subtract pedestals
458  0)) {
462  }
463  }
464 
465  }
466 
467  else { // not a doubly hit module, don't care about the mode
468  // add current event's data and subtract pedestals
469  if (judge.JudgeProfile(
471  0)) {
475  }
476  }
477 
478  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
479 
480  // total event number counter
481  theEvents++;
482 }
483 
488  std::cout << " [LaserAlignment::endRun] -- Total number of events processed: " << theEvents << std::endl;
489 
490  // for debugging only..
492 
493  // index variables for the LASGlobalLoop objects
494  int det, ring, beam, disk, pos;
495 
496  // measured positions container for the algorithms
497  LASGlobalData<LASCoordinateSet> measuredCoordinates;
498 
499  // fitted peak positions in units of strips (pair for value,error)
500  LASGlobalData<std::pair<float, float> > measuredStripPositions;
501 
502  // the peak finder, a pair (pos/posErr in units of strips) for its results, and the success confirmation
503  LASPeakFinder peakFinder;
505  std::pair<double, double> peakFinderResults;
506  bool isGoodFit;
507 
508  // tracker geom. object for calculating the global beam positions
509  const TrackerGeometry& theTracker(*theTrackerGeometry);
510 
511  // fill LASGlobalData<LASCoordinateSet> nominalCoordinates
513 
514  // for determining the phi errors
515  // ErrorFrameTransformer errorTransformer; // later...
516 
517  // do the fits for TEC+- internal
518  det = 0;
519  ring = 0;
520  beam = 0;
521  disk = 0;
522  do {
523  // do the fit
524  isGoodFit = peakFinder.FindPeakIn(collectedDataProfiles.GetTECEntry(det, ring, beam, disk),
525  peakFinderResults,
526  summedHistograms.GetTECEntry(det, ring, beam, disk),
527  0); // offset is 0 for TEC
528 
529  // now we have the measured positions in units of strips.
530  if (!isGoodFit)
531  std::cout << " [LaserAlignment::endRun] ** WARNING: Fit failed for TEC det: " << det << ", ring: " << ring
532  << ", beam: " << beam << ", disk: " << disk << " (id: " << detectorId.GetTECEntry(det, ring, beam, disk)
533  << ")." << std::endl;
534 
535  // <- here we will later implement the kink corrections
536 
537  // access the tracker geometry for this module
538  const DetId theDetId(detectorId.GetTECEntry(det, ring, beam, disk));
539  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
540 
541  if (theStripDet) {
542  // first, set the measured coordinates to their nominal values
543  measuredCoordinates.SetTECEntry(det, ring, beam, disk, nominalCoordinates.GetTECEntry(det, ring, beam, disk));
544 
545  if (isGoodFit) { // convert strip position to global phi and replace the nominal phi value/error
546 
547  measuredStripPositions.GetTECEntry(det, ring, beam, disk) = peakFinderResults;
548  const float positionInStrips =
550  ? 256.
551  : peakFinderResults.first; // implementation of "ForceFitterToNominalStrips" config parameter
552  const GlobalPoint& globalPoint =
553  theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
554  measuredCoordinates.GetTECEntry(det, ring, beam, disk).SetPhi(ConvertAngle(globalPoint.barePhi()));
555 
556  // const GlobalError& globalError = errorTransformer.transform( theStripDet->specificTopology().localError( peakFinderResults.first, pow( peakFinderResults.second, 2 ) ), theStripDet->surface() );
557  // measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhiError( globalError.phierr( globalPoint ) );
558  measuredCoordinates.GetTECEntry(det, ring, beam, disk).SetPhiError(0.00046); // PRELIMINARY ESTIMATE
559 
560  } else { // keep nominal position (middle-of-module) but set a giant phi error so that the module can be ignored by the alignment algorithm
561  measuredStripPositions.GetTECEntry(det, ring, beam, disk) = std::pair<float, float>(256., 1000.);
562  const GlobalPoint& globalPoint =
563  theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(256.));
564  measuredCoordinates.GetTECEntry(det, ring, beam, disk).SetPhi(ConvertAngle(globalPoint.barePhi()));
565  measuredCoordinates.GetTECEntry(det, ring, beam, disk).SetPhiError(1000.);
566  }
567  }
568 
569  } while (moduleLoop.TECLoop(det, ring, beam, disk));
570 
571  // do the fits for TIB/TOB
572  det = 2;
573  beam = 0;
574  pos = 0;
575  do {
576  // do the fit
577  isGoodFit = peakFinder.FindPeakIn(collectedDataProfiles.GetTIBTOBEntry(det, beam, pos),
578  peakFinderResults,
581 
582  // now we have the measured positions in units of strips.
583  if (!isGoodFit)
584  std::cout << " [LaserAlignment::endJob] ** WARNING: Fit failed for TIB/TOB det: " << det << ", beam: " << beam
585  << ", pos: " << pos << " (id: " << detectorId.GetTIBTOBEntry(det, beam, pos) << ")." << std::endl;
586 
587  // <- here we will later implement the kink corrections
588 
589  // access the tracker geometry for this module
590  const DetId theDetId(detectorId.GetTIBTOBEntry(det, beam, pos));
591  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
592 
593  if (theStripDet) {
594  // first, set the measured coordinates to their nominal values
595  measuredCoordinates.SetTIBTOBEntry(det, beam, pos, nominalCoordinates.GetTIBTOBEntry(det, beam, pos));
596 
597  if (isGoodFit) { // convert strip position to global phi and replace the nominal phi value/error
598  measuredStripPositions.GetTIBTOBEntry(det, beam, pos) = peakFinderResults;
599  const float positionInStrips =
601  ? 256. + getTIBTOBNominalBeamOffset(det, beam, pos)
602  : peakFinderResults.first; // implementation of "ForceFitterToNominalStrips" config parameter
603  const GlobalPoint& globalPoint =
604  theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
605  measuredCoordinates.GetTIBTOBEntry(det, beam, pos).SetPhi(ConvertAngle(globalPoint.barePhi()));
606  measuredCoordinates.GetTIBTOBEntry(det, beam, pos).SetPhiError(0.00028); // PRELIMINARY ESTIMATE
607  } else { // keep nominal position but set a giant phi error so that the module can be ignored by the alignment algorithm
608  measuredStripPositions.GetTIBTOBEntry(det, beam, pos) =
609  std::pair<float, float>(256. + getTIBTOBNominalBeamOffset(det, beam, pos), 1000.);
610  const GlobalPoint& globalPoint = theStripDet->surface().toGlobal(
611  theStripDet->specificTopology().localPosition(256. + getTIBTOBNominalBeamOffset(det, beam, pos)));
612  measuredCoordinates.GetTIBTOBEntry(det, beam, pos).SetPhi(ConvertAngle(globalPoint.barePhi()));
613  measuredCoordinates.GetTIBTOBEntry(det, beam, pos).SetPhiError(1000.);
614  }
615  }
616 
617  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
618 
619  // do the fits for TEC AT
620  det = 0;
621  beam = 0;
622  disk = 0;
623  do {
624  // do the fit
625  isGoodFit = peakFinder.FindPeakIn(collectedDataProfiles.GetTEC2TECEntry(det, beam, disk),
626  peakFinderResults,
628  getTEC2TECNominalBeamOffset(det, beam, disk));
629  // now we have the positions in units of strips.
630  if (!isGoodFit)
631  std::cout << " [LaserAlignment::endRun] ** WARNING: Fit failed for TEC2TEC det: " << det << ", beam: " << beam
632  << ", disk: " << disk << " (id: " << detectorId.GetTEC2TECEntry(det, beam, disk) << ")." << std::endl;
633 
634  // <- here we will later implement the kink corrections
635 
636  // access the tracker geometry for this module
637  const DetId theDetId(detectorId.GetTEC2TECEntry(det, beam, disk));
638  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
639 
640  if (theStripDet) {
641  // first, set the measured coordinates to their nominal values
642  measuredCoordinates.SetTEC2TECEntry(det, beam, disk, nominalCoordinates.GetTEC2TECEntry(det, beam, disk));
643 
644  if (isGoodFit) { // convert strip position to global phi and replace the nominal phi value/error
645  measuredStripPositions.GetTEC2TECEntry(det, beam, disk) = peakFinderResults;
646  const float positionInStrips =
648  ? 256. + getTEC2TECNominalBeamOffset(det, beam, disk)
649  : peakFinderResults.first; // implementation of "ForceFitterToNominalStrips" config parameter
650  const GlobalPoint& globalPoint =
651  theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
652  measuredCoordinates.GetTEC2TECEntry(det, beam, disk).SetPhi(ConvertAngle(globalPoint.barePhi()));
653  measuredCoordinates.GetTEC2TECEntry(det, beam, disk).SetPhiError(0.00047); // PRELIMINARY ESTIMATE
654  } else { // keep nominal position but set a giant phi error so that the module can be ignored by the alignment algorithm
655  measuredStripPositions.GetTEC2TECEntry(det, beam, disk) =
656  std::pair<float, float>(256. + getTEC2TECNominalBeamOffset(det, beam, disk), 1000.);
657  const GlobalPoint& globalPoint = theStripDet->surface().toGlobal(
658  theStripDet->specificTopology().localPosition(256. + getTEC2TECNominalBeamOffset(det, beam, disk)));
659  measuredCoordinates.GetTEC2TECEntry(det, beam, disk).SetPhi(ConvertAngle(globalPoint.barePhi()));
660  measuredCoordinates.GetTEC2TECEntry(det, beam, disk).SetPhiError(1000.);
661  }
662  }
663 
664  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
665 
666  // see what we got (for debugging)
667  // DumpStripFileSet( measuredStripPositions );
668  // DumpPosFileSet( measuredCoordinates );
669 
670  // CALCULATE PARAMETERS AND UPDATE DB OBJECT
671  // for beam kink corrections, reconstructing the geometry and updating the db object
673 
674  // apply all beam corrections
676  geometryUpdater.ApplyBeamKinkCorrections(measuredCoordinates);
677 
678  // if we start with input geometry instead of IDEAL,
679  // reverse the adjustments in the AlignableTracker object
681  geometryUpdater.SetReverseDirection(true);
682 
683  // if we have "virtual" misalignment which is introduced via the reference geometry,
684  // tell the LASGeometryUpdater to reverse x & y adjustments
686  geometryUpdater.SetMisalignmentFromRefGeometry(true);
687 
688  // run the endcap algorithm
689  LASEndcapAlgorithm endcapAlgorithm;
690  LASEndcapAlignmentParameterSet endcapParameters;
691 
692  // this basically sets all the endcap modules to be masked
693  // to their nominal positions (since endcapParameters is overall zero)
694  if (!theMaskTecModules.empty()) {
695  ApplyEndcapMaskingCorrections(measuredCoordinates, nominalCoordinates, endcapParameters);
696  }
697 
698  // run the algorithm
699  endcapParameters = endcapAlgorithm.CalculateParameters(measuredCoordinates, nominalCoordinates);
700 
701  //
702  // loop to mask out events
703  // DESCRIPTION:
704  //
705 
706  // do this only if there are modules to be masked..
707  if (!theMaskTecModules.empty()) {
708  const unsigned int nIterations = 30;
709  for (unsigned int iteration = 0; iteration < nIterations; ++iteration) {
710  // set the endcap modules to be masked to their positions
711  // according to the reconstructed parameters
712  ApplyEndcapMaskingCorrections(measuredCoordinates, nominalCoordinates, endcapParameters);
713 
714  // modifications applied, so re-run the algorithm
715  endcapParameters = endcapAlgorithm.CalculateParameters(measuredCoordinates, nominalCoordinates);
716  }
717  }
718 
719  // these are now final, so:
720  endcapParameters.Print();
721 
722  // do a pre-alignment of the endcaps (TEC2TEC only)
723  // so that the alignment tube algorithms finds orderly disks
724  geometryUpdater.EndcapUpdate(endcapParameters, measuredCoordinates);
725 
726  // the alignment tube algorithms, choose from config
727  LASBarrelAlignmentParameterSet alignmentTubeParameters;
728  // the MINUIT-BASED alignment tube algorithm
729  LASBarrelAlgorithm barrelAlgorithm;
730  // the ANALYTICAL alignment tube algorithm
731  LASAlignmentTubeAlgorithm alignmentTubeAlgorithm;
732 
733  // this basically sets all the modules to be masked
734  // to their nominal positions (since alignmentTubeParameters is overall zero)
735  if (!theMaskAtModules.empty()) {
736  ApplyATMaskingCorrections(measuredCoordinates, nominalCoordinates, alignmentTubeParameters);
737  }
738 
739  if (theUseMinuitAlgorithm) {
740  // run the MINUIT-BASED alignment tube algorithm
741  alignmentTubeParameters = barrelAlgorithm.CalculateParameters(measuredCoordinates, nominalCoordinates);
742  } else {
743  // the ANALYTICAL alignment tube algorithm
744  alignmentTubeParameters = alignmentTubeAlgorithm.CalculateParameters(measuredCoordinates, nominalCoordinates);
745  }
746 
747  //
748  // loop to mask out events
749  // DESCRIPTION:
750  //
751 
752  // do this only if there are modules to be masked..
753  if (!theMaskAtModules.empty()) {
754  const unsigned int nIterations = 30;
755  for (unsigned int iteration = 0; iteration < nIterations; ++iteration) {
756  // set the AT modules to be masked to their positions
757  // according to the reconstructed parameters
758  ApplyATMaskingCorrections(measuredCoordinates, nominalCoordinates, alignmentTubeParameters);
759 
760  // modifications applied, so re-run the algorithm
761  if (theUseMinuitAlgorithm) {
762  alignmentTubeParameters = barrelAlgorithm.CalculateParameters(measuredCoordinates, nominalCoordinates);
763  } else {
764  alignmentTubeParameters = alignmentTubeAlgorithm.CalculateParameters(measuredCoordinates, nominalCoordinates);
765  }
766  }
767  }
768 
769  // these are now final, so:
770  alignmentTubeParameters.Print();
771 
772  // combine the results and update the db object
773  geometryUpdater.TrackerUpdate(endcapParameters, alignmentTubeParameters, *theAlignableTracker);
774 
779 
780  // the collection container
781  auto laserBeams = std::make_unique<TkLasBeamCollection>();
782 
783  // first for the endcap internal beams
784  for (det = 0; det < 2; ++det) {
785  for (ring = 0; ring < 2; ++ring) {
786  for (beam = 0; beam < 8; ++beam) {
787  // the beam and its identifier (see TkLasTrackBasedInterface TWiki)
788  TkLasBeam currentBeam(100 * det + 10 * beam + ring);
789 
790  // order the hits in the beam by increasing z
791  const int firstDisk = det == 0 ? 0 : 8;
792  const int lastDisk = det == 0 ? 8 : 0;
793 
794  // count upwards or downwards
795  for (disk = firstDisk; det == 0 ? disk <= lastDisk : disk >= lastDisk; det == 0 ? ++disk : --disk) {
796  // detId for the SiStripLaserRecHit2D
797  const SiStripDetId theDetId(detectorId.GetTECEntry(det, ring, beam, disk));
798 
799  // need this to calculate the localPosition and its error
800  const StripGeomDetUnit* const theStripDet =
801  dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
802 
803  // the hit container
804  const SiStripLaserRecHit2D currentHit(theStripDet->specificTopology().localPosition(
805  measuredStripPositions.GetTECEntry(det, ring, beam, disk).first),
806  theStripDet->specificTopology().localError(
807  measuredStripPositions.GetTECEntry(det, ring, beam, disk).first,
808  measuredStripPositions.GetTECEntry(det, ring, beam, disk).second),
809  theDetId);
810 
811  currentBeam.push_back(currentHit);
812  }
813 
814  laserBeams->push_back(currentBeam);
815  }
816  }
817  }
818 
819  // then, following the convention in TkLasTrackBasedInterface TWiki, the alignment tube beams;
820  // they comprise hits in TIBTOB & TEC2TEC
821 
822  for (beam = 0; beam < 8; ++beam) {
823  // the beam and its identifier (see TkLasTrackBasedInterface TWiki)
824  TkLasBeam currentBeam(100 * 2 /*beamGroup=AT=2*/ + 10 * beam + 0 /*ring=0*/);
825 
826  // first: tec-
827  det = 1;
828  for (disk = 4; disk >= 0; --disk) {
829  // detId for the SiStripLaserRecHit2D
830  const SiStripDetId theDetId(detectorId.GetTEC2TECEntry(det, beam, disk));
831 
832  // need this to calculate the localPosition and its error
833  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
834 
835  // the hit container
836  const SiStripLaserRecHit2D currentHit(
837  theStripDet->specificTopology().localPosition(measuredStripPositions.GetTEC2TECEntry(det, beam, disk).first),
838  theStripDet->specificTopology().localError(measuredStripPositions.GetTEC2TECEntry(det, beam, disk).first,
839  measuredStripPositions.GetTEC2TECEntry(det, beam, disk).second),
840  theDetId);
841 
842  currentBeam.push_back(currentHit);
843  }
844 
845  // now TIB and TOB in one go
846  for (det = 2; det < 4; ++det) {
847  for (pos = 5; pos >= 0; --pos) { // stupidly, pos is defined from +z to -z in LASGlobalLoop
848 
849  // detId for the SiStripLaserRecHit2D
850  const SiStripDetId theDetId(detectorId.GetTIBTOBEntry(det, beam, pos));
851 
852  // need this to calculate the localPosition and its error
853  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
854 
855  // the hit container
856  const SiStripLaserRecHit2D currentHit(
857  theStripDet->specificTopology().localPosition(measuredStripPositions.GetTIBTOBEntry(det, beam, pos).first),
858  theStripDet->specificTopology().localError(measuredStripPositions.GetTIBTOBEntry(det, beam, pos).first,
859  measuredStripPositions.GetTIBTOBEntry(det, beam, pos).second),
860  theDetId);
861 
862  currentBeam.push_back(currentHit);
863  }
864  }
865 
866  // then: tec+
867  det = 0;
868  for (disk = 0; disk < 5; ++disk) {
869  // detId for the SiStripLaserRecHit2D
870  const SiStripDetId theDetId(detectorId.GetTEC2TECEntry(det, beam, disk));
871 
872  // need this to calculate the localPosition and its error
873  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
874 
875  // the hit container
876  const SiStripLaserRecHit2D currentHit(
877  theStripDet->specificTopology().localPosition(measuredStripPositions.GetTEC2TECEntry(det, beam, disk).first),
878  theStripDet->specificTopology().localError(measuredStripPositions.GetTEC2TECEntry(det, beam, disk).first,
879  measuredStripPositions.GetTEC2TECEntry(det, beam, disk).second),
880  theDetId);
881 
882  currentBeam.push_back(currentHit);
883  }
884 
885  // save this beam to the beamCollection
886  laserBeams->push_back(currentBeam);
887 
888  } // (close beam loop)
889 
890  // now attach the collection to the run
891  theRun.put(std::move(laserBeams), "tkLaserBeams");
892 
893  // store the estimated alignment parameters into the DB
894  // first get them
895  Alignments alignments = *(theAlignableTracker->alignments());
897 
898  if (theStoreToDB) {
899  std::cout << " [LaserAlignment::endRun] -- Storing the calculated alignment parameters to the DataBase:"
900  << std::endl;
901 
902  // Call service
904  if (!poolDbService.isAvailable()) // Die if not available
905  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
906 
907  // Store
908 
909  // if ( poolDbService->isNewTagRequest(theAlignRecordName) ) {
910  // poolDbService->createOneIOV<Alignments>( alignments, poolDbService->currentTime(), theAlignRecordName );
911  // }
912  // else {
913  // poolDbService->appendOneIOV<Alignments>( alignments, poolDbService->currentTime(), theAlignRecordName );
914  // }
915  poolDbService->writeOneIOV<Alignments>(alignments, poolDbService->beginOfTime(), theAlignRecordName);
916 
917  // if ( poolDbService->isNewTagRequest(theErrorRecordName) ) {
918  // poolDbService->createOneIOV<AlignmentErrorsExtended>( alignmentErrors, poolDbService->currentTime(), poolDbService->endOfTime(), theErrorRecordName );
919  // }
920  // else {
921  // poolDbService->appendOneIOV<AlignmentErrorsExtended>( alignmentErrors, poolDbService->currentTime(), theErrorRecordName );
922  // }
923  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
924  alignmentErrors, poolDbService->beginOfTime(), theErrorRecordName);
925 
926  std::cout << " [LaserAlignment::endRun] -- Storing done." << std::endl;
927  }
928 }
929 
934 
939 void LaserAlignment::fillDataProfiles(edm::Event const& theEvent, edm::EventSetup const& theSetup) {
940  // two handles for the two different kinds of digis
943 
944  bool isRawDigi = false;
945 
946  // indices for the LASGlobalLoop object
947  int det = 0, ring = 0, beam = 0, disk = 0, pos = 0;
948 
949  // query config set and loop over all PSets in the VPSet
950  for (std::vector<edm::ParameterSet>::iterator itDigiProducersList = theDigiProducersList.begin();
951  itDigiProducersList != theDigiProducersList.end();
952  ++itDigiProducersList) {
953  std::string digiProducer = itDigiProducersList->getParameter<std::string>("DigiProducer");
954  std::string digiLabel = itDigiProducersList->getParameter<std::string>("DigiLabel");
955  std::string digiType = itDigiProducersList->getParameter<std::string>("DigiType");
956 
957  // now branch according to digi type (raw or processed);
958  // first we go for raw digis => SiStripRawDigi
959  if (digiType == "Raw") {
960  theEvent.getByLabel(digiProducer, digiLabel, theStripRawDigis);
961  isRawDigi = true;
962  } else if (digiType == "Processed") {
963  theEvent.getByLabel(digiProducer, digiLabel, theStripDigis);
964  isRawDigi = false;
965  } else {
966  throw cms::Exception(" [LaserAlignment::fillDataProfiles]")
967  << " ** ERROR: Invalid digi type: \"" << digiType << "\" specified in configuration." << std::endl;
968  }
969 
970  // loop TEC internal modules
971  det = 0;
972  ring = 0;
973  beam = 0;
974  disk = 0;
975  do {
976  // first clear the profile
978 
979  // retrieve the raw id of that module
980  const int detRawId = detectorId.GetTECEntry(det, ring, beam, disk);
981 
982  if (isRawDigi) { // we have raw SiStripRawDigis
983 
984  // search the digis for the raw id
985  edm::DetSetVector<SiStripRawDigi>::const_iterator detSetIter = theStripRawDigis->find(detRawId);
986  if (detSetIter == theStripRawDigis->end()) {
987  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
988  << " ** ERROR: No raw DetSet found for det: " << detRawId << "." << std::endl;
989  }
990 
991  // fill the digis to the profiles
992  edm::DetSet<SiStripRawDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
993  edm::DetSet<SiStripRawDigi>::const_iterator digiRangeStart = digiRangeIterator; // save starting positions
994 
995  // loop all digis
996  for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator) {
997  const SiStripRawDigi& digi = *digiRangeIterator;
998  const int channel = distance(digiRangeStart, digiRangeIterator);
999  if (channel >= 0 && channel < 512)
1000  currentDataProfiles.GetTECEntry(det, ring, beam, disk).SetValue(channel, digi.adc());
1001  else
1002  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
1003  << " ** ERROR: raw digi channel: " << channel << " out of range for det: " << detRawId << "."
1004  << std::endl;
1005  }
1006 
1007  }
1008 
1009  else { // we have zero suppressed SiStripDigis
1010 
1011  // search the digis for the raw id
1012  edm::DetSetVector<SiStripDigi>::const_iterator detSetIter = theStripDigis->find(detRawId);
1013 
1014  // processed DetSets may be missing, just skip
1015  if (detSetIter == theStripDigis->end())
1016  continue;
1017 
1018  // fill the digis to the profiles
1019  edm::DetSet<SiStripDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
1020 
1021  for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator) {
1022  const SiStripDigi& digi = *digiRangeIterator;
1023  if (digi.strip() < 512)
1024  currentDataProfiles.GetTECEntry(det, ring, beam, disk).SetValue(digi.strip(), digi.adc());
1025  else
1026  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
1027  << " ** ERROR: digi strip: " << digi.strip() << " out of range for det: " << detRawId << "."
1028  << std::endl;
1029  }
1030  }
1031 
1032  } while (moduleLoop.TECLoop(det, ring, beam, disk));
1033 
1034  // loop TIBTOB modules
1035  det = 2;
1036  beam = 0;
1037  pos = 0;
1038  do {
1039  // first clear the profile
1041 
1042  // retrieve the raw id of that module
1043  const int detRawId = detectorId.GetTIBTOBEntry(det, beam, pos);
1044 
1045  if (isRawDigi) { // we have raw SiStripRawDigis
1046 
1047  // search the digis for the raw id
1048  edm::DetSetVector<SiStripRawDigi>::const_iterator detSetIter = theStripRawDigis->find(detRawId);
1049  if (detSetIter == theStripRawDigis->end()) {
1050  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
1051  << " ** ERROR: No raw DetSet found for det: " << detRawId << "." << std::endl;
1052  }
1053 
1054  // fill the digis to the profiles
1055  edm::DetSet<SiStripRawDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
1056  edm::DetSet<SiStripRawDigi>::const_iterator digiRangeStart = digiRangeIterator; // save starting positions
1057 
1058  // loop all digis
1059  for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator) {
1060  const SiStripRawDigi& digi = *digiRangeIterator;
1061  const int channel = distance(digiRangeStart, digiRangeIterator);
1062  if (channel >= 0 && channel < 512)
1063  currentDataProfiles.GetTIBTOBEntry(det, beam, pos).SetValue(channel, digi.adc());
1064  else
1065  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
1066  << " ** ERROR: raw digi channel: " << channel << " out of range for det: " << detRawId << "."
1067  << std::endl;
1068  }
1069 
1070  }
1071 
1072  else { // we have zero suppressed SiStripDigis
1073 
1074  // search the digis for the raw id
1075  edm::DetSetVector<SiStripDigi>::const_iterator detSetIter = theStripDigis->find(detRawId);
1076 
1077  // processed DetSets may be missing, just skip
1078  if (detSetIter == theStripDigis->end())
1079  continue;
1080 
1081  // fill the digis to the profiles
1082  edm::DetSet<SiStripDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
1083 
1084  for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator) {
1085  const SiStripDigi& digi = *digiRangeIterator;
1086  if (digi.strip() < 512)
1087  currentDataProfiles.GetTIBTOBEntry(det, beam, pos).SetValue(digi.strip(), digi.adc());
1088  else
1089  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
1090  << " ** ERROR: digi strip: " << digi.strip() << " out of range for det: " << detRawId << "."
1091  << std::endl;
1092  }
1093  }
1094 
1095  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
1096 
1097  // loop TEC AT modules
1098  det = 0;
1099  beam = 0;
1100  disk = 0;
1101  do {
1102  // first clear the profile
1104 
1105  // retrieve the raw id of that module
1106  const int detRawId = detectorId.GetTEC2TECEntry(det, beam, disk);
1107 
1108  if (isRawDigi) { // we have raw SiStripRawDigis
1109 
1110  // search the digis for the raw id
1111  edm::DetSetVector<SiStripRawDigi>::const_iterator detSetIter = theStripRawDigis->find(detRawId);
1112  if (detSetIter == theStripRawDigis->end()) {
1113  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
1114  << " ** ERROR: No raw DetSet found for det: " << detRawId << "." << std::endl;
1115  }
1116 
1117  // fill the digis to the profiles
1118  edm::DetSet<SiStripRawDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
1119  edm::DetSet<SiStripRawDigi>::const_iterator digiRangeStart = digiRangeIterator; // save starting positions
1120 
1121  // loop all digis
1122  for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator) {
1123  const SiStripRawDigi& digi = *digiRangeIterator;
1124  const int channel = distance(digiRangeStart, digiRangeIterator);
1125  if (channel >= 0 && channel < 512)
1126  currentDataProfiles.GetTEC2TECEntry(det, beam, disk).SetValue(channel, digi.adc());
1127  else
1128  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
1129  << " ** ERROR: raw digi channel: " << channel << " out of range for det: " << detRawId << "."
1130  << std::endl;
1131  }
1132 
1133  }
1134 
1135  else { // we have zero suppressed SiStripDigis
1136 
1137  // search the digis for the raw id
1138  edm::DetSetVector<SiStripDigi>::const_iterator detSetIter = theStripDigis->find(detRawId);
1139 
1140  // processed DetSets may be missing, just skip
1141  if (detSetIter == theStripDigis->end())
1142  continue;
1143 
1144  // fill the digis to the profiles
1145  edm::DetSet<SiStripDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
1146 
1147  for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator) {
1148  const SiStripDigi& digi = *digiRangeIterator;
1149  if (digi.strip() < 512)
1150  currentDataProfiles.GetTEC2TECEntry(det, beam, disk).SetValue(digi.strip(), digi.adc());
1151  else
1152  throw cms::Exception("[Laser Alignment::fillDataProfiles]")
1153  << " ** ERROR: digi strip: " << digi.strip() << " out of range for det: " << detRawId << "."
1154  << std::endl;
1155  }
1156  }
1157 
1158  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
1159 
1160  } // theDigiProducersList loop
1161 }
1162 
1172  int det, ring, beam, disk, pos;
1173 
1174  // loop TEC modules (yet without AT)
1175  det = 0;
1176  ring = 0;
1177  beam = 0;
1178  disk = 0;
1179  do { // loop using LASGlobalLoop functionality
1180  SiStripPedestals::Range pedRange = pedestalsHandle->getRange(detectorId.GetTECEntry(det, ring, beam, disk));
1181  for (int strip = 0; strip < 512; ++strip) {
1182  int thePedestal = int(pedestalsHandle->getPed(strip, pedRange));
1183  if (thePedestal > 895)
1184  thePedestal -= 1024;
1185  pedestalProfiles.GetTECEntry(det, ring, beam, disk).SetValue(strip, thePedestal);
1186  }
1187  } while (moduleLoop.TECLoop(det, ring, beam, disk));
1188 
1189  // TIB & TOB section
1190  det = 2;
1191  beam = 0;
1192  pos = 0;
1193  do { // loop using LASGlobalLoop functionality
1194  SiStripPedestals::Range pedRange = pedestalsHandle->getRange(detectorId.GetTIBTOBEntry(det, beam, pos));
1195  for (int strip = 0; strip < 512; ++strip) {
1196  int thePedestal = int(pedestalsHandle->getPed(strip, pedRange));
1197  if (thePedestal > 895)
1198  thePedestal -= 1024;
1199  pedestalProfiles.GetTIBTOBEntry(det, beam, pos).SetValue(strip, thePedestal);
1200  }
1201  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
1202 
1203  // TEC2TEC AT section
1204  det = 0;
1205  beam = 0;
1206  disk = 0;
1207  do { // loop using LASGlobalLoop functionality
1208  SiStripPedestals::Range pedRange = pedestalsHandle->getRange(detectorId.GetTEC2TECEntry(det, beam, disk));
1209  for (int strip = 0; strip < 512; ++strip) {
1210  int thePedestal = int(pedestalsHandle->getPed(strip, pedRange));
1211  if (thePedestal > 895)
1212  thePedestal -= 1024;
1213  pedestalProfiles.GetTEC2TECEntry(det, beam, disk).SetValue(strip, thePedestal);
1214  }
1215  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
1216 }
1217 
1224  int numberOfProfiles = 0;
1225 
1226  int ring = 1; // search all ring6 modules for signals
1227  for (int det = 0; det < 2; ++det) {
1228  for (int beam = 0; beam < 8; ++beam) {
1229  for (int disk = 0; disk < 9; ++disk) {
1230  if (isAcceptedProfile.GetTECEntry(det, ring, beam, disk) == 1)
1231  numberOfProfiles++;
1232  }
1233  }
1234  }
1235 
1236  LogDebug("[LaserAlignment::isTECBeam]") << " Found: " << numberOfProfiles << "hits." << std::endl;
1237  std::cout << " [LaserAlignment::isTECBeam] -- Found: " << numberOfProfiles << " hits." << std::endl;
1238 
1239  if (numberOfProfiles > 10)
1240  return (true);
1241  return (false);
1242 }
1243 
1249 
1251  int numberOfProfiles = 0;
1252 
1253  int det = 2;
1254  int beam = 0;
1255  int pos = 0; // search all TIB/TOB for signals
1256  do {
1257  if (isAcceptedProfile.GetTIBTOBEntry(det, beam, pos) == 1)
1258  numberOfProfiles++;
1259  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
1260 
1261  LogDebug("[LaserAlignment::isATBeam]") << " Found: " << numberOfProfiles << "hits." << std::endl;
1262  std::cout << " [LaserAlignment::isATBeam] -- Found: " << numberOfProfiles << " hits." << std::endl;
1263 
1264  if (numberOfProfiles > 10)
1265  return (true);
1266  return (false);
1267 }
1268 
1277 double LaserAlignment::getTIBTOBNominalBeamOffset(unsigned int det, unsigned int beam, unsigned int pos) {
1278  if (det < 2 || det > 3 || beam > 7 || pos > 5) {
1279  throw cms::Exception("[LaserAlignment::getTIBTOBNominalBeamOffset]")
1280  << " ERROR ** Called with nonexisting parameter set: det " << det << " beam " << beam << " pos " << pos << "."
1281  << std::endl;
1282  }
1283 
1284  const double nominalOffsetsTIB[8] = {
1285  0.00035, 2.10687, -2.10827, -0.00173446, 2.10072, -0.00135114, 2.10105, -2.10401};
1286 
1287  // in tob, modules have alternating orientations along the rods.
1288  // this is described by the following pattern.
1289  // (even more confusing, this pattern is inversed for beams 0, 5, 6, 7)
1290  const int orientationPattern[6] = {-1, 1, 1, -1, -1, 1};
1291  const double nominalOffsetsTOB[8] = {0.00217408, 1.58678, 117.733, 119.321, 120.906, 119.328, 117.743, 1.58947};
1292 
1293  if (det == 2)
1294  return (-1. * nominalOffsetsTIB[beam]);
1295 
1296  else {
1297  if (beam == 0 or beam > 4)
1298  return (nominalOffsetsTOB[beam] * orientationPattern[pos]);
1299  else
1300  return (-1. * nominalOffsetsTOB[beam] * orientationPattern[pos]);
1301  }
1302 }
1303 
1312 double LaserAlignment::getTEC2TECNominalBeamOffset(unsigned int det, unsigned int beam, unsigned int disk) {
1313  if (det > 1 || beam > 7 || disk > 5) {
1314  throw cms::Exception("[LaserAlignment::getTEC2TECNominalBeamOffset]")
1315  << " ERROR ** Called with nonexisting parameter set: det " << det << " beam " << beam << " disk " << disk << "."
1316  << std::endl;
1317  }
1318 
1319  const double nominalOffsets[8] = {0., 2.220, -2.221, 0., 2.214, 0., 2.214, -2.217};
1320 
1321  if (det == 0)
1322  return -1. * nominalOffsets[beam];
1323  else
1324  return nominalOffsets[beam];
1325 }
1326 
1331  //
1332  // hard coded data yet...
1333  //
1334 
1335  // nominal phi values of tec beam / alignment tube hits (parameter is beam 0-7)
1336  const double tecPhiPositions[8] = {
1337  0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486}; // new values calculated by maple
1338  const double atPhiPositions[8] = {
1339  0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784}; // new values calculated by maple
1340 
1341  // nominal r values (mm) of hits
1342  const double tobRPosition = 600.;
1343  const double tibRPosition = 514.;
1344  const double tecRPosition[2] = {564., 840.}; // ring 4,6
1345 
1346  // nominal z values (mm) of hits in barrel (parameter is pos 0-6)
1347  const double tobZPosition[6] = {1040., 580., 220., -140., -500., -860.};
1348  const double tibZPosition[6] = {620., 380., 180., -100., -340., -540.};
1349 
1350  // nominal z values (mm) of hits in tec (parameter is disk 0-8); FOR TEC-: (* -1.)
1351  const double tecZPosition[9] = {1322.5, 1462.5, 1602.5, 1742.5, 1882.5, 2057.5, 2247.5, 2452.5, 2667.5};
1352 
1353  //
1354  // now we fill these into the nominalCoordinates container;
1355  // errors are zero for nominal values..
1356  //
1357 
1358  // loop object and its variables
1360  int det, ring, beam, disk, pos;
1361 
1362  // TEC+- section
1363  det = 0;
1364  ring = 0, beam = 0;
1365  disk = 0;
1366  do {
1367  if (det == 0) { // this is TEC+
1369  det,
1370  ring,
1371  beam,
1372  disk,
1373  LASCoordinateSet(tecPhiPositions[beam], 0., tecRPosition[ring], 0., tecZPosition[disk], 0.));
1374  } else { // now TEC-
1376  det,
1377  ring,
1378  beam,
1379  disk,
1381  tecPhiPositions[beam], 0., tecRPosition[ring], 0., -1. * tecZPosition[disk], 0.)); // just * -1.
1382  }
1383 
1384  } while (moduleLoop.TECLoop(det, ring, beam, disk));
1385 
1386  // TIB & TOB section
1387  det = 2;
1388  beam = 0;
1389  pos = 0;
1390  do {
1391  if (det == 2) { // this is TIB
1393  det, beam, pos, LASCoordinateSet(atPhiPositions[beam], 0., tibRPosition, 0., tibZPosition[pos], 0.));
1394  } else { // now TOB
1396  det, beam, pos, LASCoordinateSet(atPhiPositions[beam], 0., tobRPosition, 0., tobZPosition[pos], 0.));
1397  }
1398 
1399  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
1400 
1401  // TEC2TEC AT section
1402  det = 0;
1403  beam = 0;
1404  disk = 0;
1405  do {
1406  if (det == 0) { // this is TEC+, ring4 only
1408  det, beam, disk, LASCoordinateSet(atPhiPositions[beam], 0., tecRPosition[0], 0., tecZPosition[disk], 0.));
1409  } else { // now TEC-
1411  det,
1412  beam,
1413  disk,
1414  LASCoordinateSet(atPhiPositions[beam], 0., tecRPosition[0], 0., -1. * tecZPosition[disk], 0.)); // just * -1.
1415  }
1416 
1417  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
1418 }
1419 
1425  if (angle < -1. * M_PI || angle > M_PI) {
1426  throw cms::Exception(" [LaserAlignment::ConvertAngle] ")
1427  << "** ERROR: Called with illegal input angle: " << angle << "." << std::endl;
1428  }
1429 
1430  if (angle >= 0.)
1431  return angle;
1432  else
1433  return (angle + 2. * M_PI);
1434 }
1435 
1441  int det, ring, beam, disk, pos;
1442 
1443  std::cout << std::endl << " [LaserAlignment::DumpPosFileSet] -- Dump: " << std::endl;
1444 
1445  // TEC INTERNAL
1446  det = 0;
1447  ring = 0;
1448  beam = 0;
1449  disk = 0;
1450  do {
1451  std::cout << "POS " << det << "\t" << beam << "\t" << disk << "\t" << ring << "\t"
1452  << coordinates.GetTECEntry(det, ring, beam, disk).GetPhi() << "\t"
1453  << coordinates.GetTECEntry(det, ring, beam, disk).GetPhiError() << std::endl;
1454  } while (loop.TECLoop(det, ring, beam, disk));
1455 
1456  // TIBTOB
1457  det = 2;
1458  beam = 0;
1459  pos = 0;
1460  do {
1461  std::cout << "POS " << det << "\t" << beam << "\t" << pos << "\t"
1462  << "-1"
1463  << "\t" << coordinates.GetTIBTOBEntry(det, beam, pos).GetPhi() << "\t"
1464  << coordinates.GetTIBTOBEntry(det, beam, pos).GetPhiError() << std::endl;
1465  } while (loop.TIBTOBLoop(det, beam, pos));
1466 
1467  // TEC2TEC
1468  det = 0;
1469  beam = 0;
1470  disk = 0;
1471  do {
1472  std::cout << "POS " << det << "\t" << beam << "\t" << disk << "\t"
1473  << "-1"
1474  << "\t" << coordinates.GetTEC2TECEntry(det, beam, disk).GetPhi() << "\t"
1475  << coordinates.GetTEC2TECEntry(det, beam, disk).GetPhiError() << std::endl;
1476  } while (loop.TEC2TECLoop(det, beam, disk));
1477 
1478  std::cout << std::endl << " [LaserAlignment::DumpPosFileSet] -- End dump: " << std::endl;
1479 }
1480 
1484 void LaserAlignment::DumpStripFileSet(LASGlobalData<std::pair<float, float> >& measuredStripPositions) {
1486  int det, ring, beam, disk, pos;
1487 
1488  std::cout << std::endl << " [LaserAlignment::DumpStripFileSet] -- Dump: " << std::endl;
1489 
1490  // TEC INTERNAL
1491  det = 0;
1492  ring = 0;
1493  beam = 0;
1494  disk = 0;
1495  do {
1496  std::cout << "STRIP " << det << "\t" << beam << "\t" << disk << "\t" << ring << "\t"
1497  << measuredStripPositions.GetTECEntry(det, ring, beam, disk).first << "\t"
1498  << measuredStripPositions.GetTECEntry(det, ring, beam, disk).second << std::endl;
1499  } while (loop.TECLoop(det, ring, beam, disk));
1500 
1501  // TIBTOB
1502  det = 2;
1503  beam = 0;
1504  pos = 0;
1505  do {
1506  std::cout << "STRIP " << det << "\t" << beam << "\t" << pos << "\t"
1507  << "-1"
1508  << "\t" << measuredStripPositions.GetTIBTOBEntry(det, beam, pos).first << "\t"
1509  << measuredStripPositions.GetTIBTOBEntry(det, beam, pos).second << std::endl;
1510  } while (loop.TIBTOBLoop(det, beam, pos));
1511 
1512  // TEC2TEC
1513  det = 0;
1514  beam = 0;
1515  disk = 0;
1516  do {
1517  std::cout << "STRIP " << det << "\t" << beam << "\t" << disk << "\t"
1518  << "-1"
1519  << "\t" << measuredStripPositions.GetTEC2TECEntry(det, beam, disk).first << "\t"
1520  << measuredStripPositions.GetTEC2TECEntry(det, beam, disk).second << std::endl;
1521  } while (loop.TEC2TECLoop(det, beam, disk));
1522 
1523  std::cout << std::endl << " [LaserAlignment::DumpStripFileSet] -- End dump: " << std::endl;
1524 }
1525 
1529 void LaserAlignment::DumpHitmaps(LASGlobalData<int>& numberOfAcceptedProfiles) {
1530  std::cout << " [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC+:" << std::endl;
1531  std::cout << " [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
1532  std::cout << " disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1533 
1534  for (int beam = 0; beam < 8; ++beam) {
1535  std::cout << " beam" << beam << ":";
1536  for (int disk = 0; disk < 9; ++disk) {
1537  std::cout << "\t" << numberOfAcceptedProfiles.GetTECEntry(0, 0, beam, disk);
1538  }
1539  std::cout << std::endl;
1540  }
1541 
1542  std::cout << " [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
1543  std::cout << " disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1544 
1545  for (int beam = 0; beam < 8; ++beam) {
1546  std::cout << " beam" << beam << ":";
1547  for (int disk = 0; disk < 9; ++disk) {
1548  std::cout << "\t" << numberOfAcceptedProfiles.GetTECEntry(0, 1, beam, disk);
1549  }
1550  std::cout << std::endl;
1551  }
1552 
1553  std::cout << " [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC-:" << std::endl;
1554  std::cout << " [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
1555  std::cout << " disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1556 
1557  for (int beam = 0; beam < 8; ++beam) {
1558  std::cout << " beam" << beam << ":";
1559  for (int disk = 0; disk < 9; ++disk) {
1560  std::cout << "\t" << numberOfAcceptedProfiles.GetTECEntry(1, 0, beam, disk);
1561  }
1562  std::cout << std::endl;
1563  }
1564 
1565  std::cout << " [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
1566  std::cout << " disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1567 
1568  for (int beam = 0; beam < 8; ++beam) {
1569  std::cout << " beam" << beam << ":";
1570  for (int disk = 0; disk < 9; ++disk) {
1571  std::cout << "\t" << numberOfAcceptedProfiles.GetTECEntry(1, 1, beam, disk);
1572  }
1573  std::cout << std::endl;
1574  }
1575 
1576  std::cout << " [LaserAlignment::DumpHitmaps] -- End of dump." << std::endl << std::endl;
1577 }
1578 
1584  LASGlobalData<LASCoordinateSet>& nominalCoordinates,
1585  LASEndcapAlignmentParameterSet& endcapParameters) {
1586  // loop the list of modules to be masked
1587  for (std::vector<unsigned int>::iterator moduleIt = theMaskTecModules.begin(); moduleIt != theMaskTecModules.end();
1588  ++moduleIt) {
1589  // loop variables
1591  int det, ring, beam, disk;
1592 
1593  // this will calculate the corrections from the alignment parameters
1594  LASEndcapAlgorithm endcapAlgorithm;
1595 
1596  // find the location of the respective module in the container with this loop
1597  det = 0;
1598  ring = 0;
1599  beam = 0;
1600  disk = 0;
1601  do {
1602  // here we got it
1603  if (detectorId.GetTECEntry(det, ring, beam, disk) == *moduleIt) {
1604  // the nominal phi value for this module
1605  const double nominalPhi = nominalCoordinates.GetTECEntry(det, ring, beam, disk).GetPhi();
1606 
1607  // the offset from the alignment parameters
1608  const double phiCorrection = endcapAlgorithm.GetAlignmentParameterCorrection(
1609  det, ring, beam, disk, nominalCoordinates, endcapParameters);
1610 
1611  // apply the corrections
1612  measuredCoordinates.GetTECEntry(det, ring, beam, disk).SetPhi(nominalPhi - phiCorrection);
1613  }
1614 
1615  } while (moduleLoop.TECLoop(det, ring, beam, disk));
1616  }
1617 }
1618 
1624  LASGlobalData<LASCoordinateSet>& nominalCoordinates,
1625  LASBarrelAlignmentParameterSet& atParameters) {
1626  // loop the list of modules to be masked
1627  for (std::vector<unsigned int>::iterator moduleIt = theMaskAtModules.begin(); moduleIt != theMaskAtModules.end();
1628  ++moduleIt) {
1629  // loop variables
1631  int det, beam, disk, pos;
1632 
1633  // this will calculate the corrections from the alignment parameters
1634  LASAlignmentTubeAlgorithm atAlgorithm;
1635 
1636  // find the location of the respective module in the container with these loops:
1637 
1638  // first TIB+TOB
1639  det = 2;
1640  beam = 0;
1641  pos = 0;
1642  do {
1643  // here we got it
1644  if (detectorId.GetTIBTOBEntry(det, beam, pos) == *moduleIt) {
1645  // the nominal phi value for this module
1646  const double nominalPhi = nominalCoordinates.GetTIBTOBEntry(det, beam, pos).GetPhi();
1647 
1648  // the offset from the alignment parameters
1649  const double phiCorrection =
1650  atAlgorithm.GetTIBTOBAlignmentParameterCorrection(det, beam, pos, nominalCoordinates, atParameters);
1651 
1652  // apply the corrections
1653  measuredCoordinates.GetTIBTOBEntry(det, beam, pos).SetPhi(nominalPhi - phiCorrection);
1654  }
1655 
1656  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
1657 
1658  // then TEC(AT)
1659  det = 0;
1660  beam = 0;
1661  disk = 0;
1662  do {
1663  // here we got it
1664  if (detectorId.GetTEC2TECEntry(det, beam, disk) == *moduleIt) {
1665  // the nominal phi value for this module
1666  const double nominalPhi = nominalCoordinates.GetTEC2TECEntry(det, beam, disk).GetPhi();
1667 
1668  // the offset from the alignment parameters
1669  const double phiCorrection =
1670  atAlgorithm.GetTEC2TECAlignmentParameterCorrection(det, beam, disk, nominalCoordinates, atParameters);
1671 
1672  // apply the corrections
1673  measuredCoordinates.GetTEC2TECEntry(det, beam, disk).SetPhi(nominalPhi - phiCorrection);
1674  }
1675 
1676  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
1677  }
1678 }
1679 
1685  // tracker geom. object for calculating the global beam positions
1686  const TrackerGeometry& theTracker(*theTrackerGeometry);
1687 
1688  const double atPhiPositions[8] = {0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784};
1689  const double tecPhiPositions[8] = {0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486};
1690  const double zPositions[9] = {125.0, 139.0, 153.0, 167.0, 181.0, 198.5, 217.5, 238.0, 259.5};
1691  const double zPositionsTIB[6] = {62.0, 38.0, 18.0, -10.0, -34.0, -54.0};
1692  const double zPositionsTOB[6] = {104.0, 58.0, 22.0, -14.0, -50.0, -86.0};
1693 
1694  int det, beam, disk, pos, ring;
1695 
1696  // loop TEC+- internal
1697  det = 0;
1698  ring = 0;
1699  beam = 0;
1700  disk = 0;
1701  do {
1702  const double radius = ring ? 84.0 : 56.4;
1703 
1704  // access the tracker geometry for this module
1705  const DetId theDetId(detectorId.GetTECEntry(det, ring, beam, disk));
1706  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
1707 
1708  if (theStripDet) {
1709  const GlobalPoint gp(GlobalPoint::Cylindrical(radius, tecPhiPositions[beam], zPositions[disk]));
1710 
1711  const LocalPoint lp(theStripDet->surface().toLocal(gp));
1712  std::cout << "__TEC: " << 256. - theStripDet->specificTopology().strip(lp)
1713  << std::endl;
1714  }
1715 
1716  } while (moduleLoop.TECLoop(det, ring, beam, disk));
1717 
1718  // loop TIBTOB
1719  det = 2;
1720  beam = 0;
1721  pos = 0;
1722  do {
1723  const double radius =
1724  (det == 2 ? 51.4 : 58.4);
1725  const double theZ = (det == 2 ? zPositionsTIB[pos] : zPositionsTOB[pos]);
1726 
1727  // access the tracker geometry for this module
1728  const DetId theDetId(detectorId.GetTIBTOBEntry(det, beam, pos));
1729  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
1730 
1731  if (theStripDet) {
1732  const GlobalPoint gp(GlobalPoint::Cylindrical(radius, atPhiPositions[beam], theZ));
1733 
1734  const LocalPoint lp(theStripDet->surface().toLocal(gp));
1735  std::cout << "__TIBTOB det " << det << " beam " << beam << " pos " << pos << " "
1736  << 256. - theStripDet->specificTopology().strip(lp);
1737  std::cout << " " << theStripDet->position().perp() << std::endl;
1738  }
1739 
1740  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
1741 
1742  // loop TEC2TEC
1743  det = 0;
1744  beam = 0;
1745  disk = 0;
1746  do {
1747  const double radius = 56.4;
1748 
1749  // access the tracker geometry for this module
1750  const DetId theDetId(detectorId.GetTEC2TECEntry(det, beam, disk));
1751  const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.idToDet(theDetId));
1752 
1753  if (theStripDet) {
1754  const GlobalPoint gp(GlobalPoint::Cylindrical(radius, atPhiPositions[beam], zPositions[disk]));
1755 
1756  const LocalPoint lp(theStripDet->surface().toLocal(gp));
1757  std::cout << "__TEC2TEC det " << det << " beam " << beam << " disk " << disk << " "
1758  << 256. - theStripDet->specificTopology().strip(lp) << std::endl;
1759  }
1760 
1761  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
1762 }
1763 
1764 // define the SEAL module
1766 
1768 
1769 // the ATTIC
bool IsSignalIn(const LASModuleProfile &, double)
bool isATBeam(void)
void SetTEC2TECEntry(int subdetector, int beam, int tecDisk, T)
T theZ
void SetPhi(double aPhi)
unsigned int judgeOverdriveThreshold
config parameters for the LASProfileJudge
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void fillDataProfiles(edm::Event const &, edm::EventSetup const &)
fill profiles from SiStrip(Raw)Digi container
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void beginJob() override
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
const Range getRange(const uint32_t &detID) const
bool theSaveHistograms
config switch
void SetPhiError(double aPhiError)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
void ApplyEndcapMaskingCorrections(LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &, LASEndcapAlignmentParameterSet &)
apply endcap correction to masked modules in TEC
Alignments * alignments() const override
Return alignments, sorted by DetId.
void produce(edm::Event &, edm::EventSetup const &) override
const edm::ESGetToken< SiStripPedestals, SiStripPedestalsRcd > stripPedestalsToken_
void TrackerUpdate(LASEndcapAlignmentParameterSet &, LASBarrelAlignmentParameterSet &, AlignableTracker &)
void SetMisalignmentFromRefGeometry(bool)
bool misalignedByRefGeometry
config switch
std::string theAlignRecordName
bool isTECBeam(void)
decide whether TEC or AT beams have fired
LaserAlignment(edm::ParameterSet const &theConf)
double getTIBTOBNominalBeamOffset(unsigned int, unsigned int, unsigned int)
returns the nominal beam position (strips) in TOB for the profileJudge
edm::ESHandle< TrackerGeometry > theTrackerGeometry
double peakFinderThreshold
config parameter
bool TEC2TECLoop(int &, int &, int &) const
void DumpHitmaps(LASGlobalData< int > &)
for debugging only, will disappear
void DumpPosFileSet(LASGlobalData< LASCoordinateSet > &)
for debugging only, will disappear
LASGlobalData< int > numberOfAcceptedProfiles
void SetAllValuesTo(const double &)
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
std::pair< ContainerIterator, ContainerIterator > Range
bool theDoPedestalSubtraction
config switch
LASGlobalData< LASModuleProfile > currentDataProfiles
data profiles for the current event
std::vector< unsigned int > theMaskTecModules
config parameters
bool theUseMinuitAlgorithm
config switch
TFile * theFile
Tree stuff.
double GetPhiError(void) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
uint16_t adc() const
LASGlobalData< int > isAcceptedProfile
void ApplyBeamKinkCorrections(LASGlobalData< LASCoordinateSet > &) const
std::vector< edm::ParameterSet > theDigiProducersList
void DumpStripFileSet(LASGlobalData< std::pair< float, float > > &)
for debugging only, will disappear
float getPed(const uint16_t &strip, const Range &range) const
void fillPedestalProfiles(edm::ESHandle< SiStripPedestals > &)
fill pedestals from dbase
T barePhi() const
Definition: PV3DBase.h:65
~LaserAlignment() override
const uint16_t & strip() const
Definition: SiStripDigi.h:33
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
const uint16_t & adc() const
Definition: SiStripDigi.h:34
LASGlobalData< TH1D * > summedHistograms
bool FindPeakIn(const LASModuleProfile &, std::pair< double, double > &, TH1D *, const double)
TDirectory * singleModulesDir
void push_back(const SiStripLaserRecHit2D &aHit)
insert a hit in the data vector
Definition: TkLasBeam.h:35
double ConvertAngle(double)
convert an angle in the [-pi,pi] range to the [0,2*pi] range
bool TECLoop(int &, int &, int &, int &) const
LASBarrelAlignmentParameterSet CalculateParameters(LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &)
edm::ESHandle< Alignments > theGlobalPositionRcd
std::string theFileName
config parameter (histograms file output name)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Tokens for ESconsumes.
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
void endJob() override
std::vector< unsigned int > tecDoubleHitDetId
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void SetAmplitudeThreshold(double)
edm::EventID id() const
Definition: EventBase.h:63
void endRunProduce(edm::Run &, const edm::EventSetup &) override
bool theApplyBeamKinkCorrections
config switch
T & GetTIBTOBEntry(int subdetector, int beam, int tibTobPosition)
bool JudgeProfile(const LASModuleProfile &, double)
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
void SetTIBTOBEntry(int subdetector, int beam, int tibTobPosition, T)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
void CalculateNominalCoordinates(void)
fills a LASGlobalData<LASCoordinateSet> with nominal module positions
const TrackerGeomDet * idToDet(DetId) const override
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:316
LASEndcapAlignmentParameterSet CalculateParameters(LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &)
std::string theErrorRecordName
#define M_PI
double GetTEC2TECAlignmentParameterCorrection(int, int, int, LASGlobalData< LASCoordinateSet > &, LASBarrelAlignmentParameterSet &)
bool TIBTOBLoop(int &, int &, int &) const
void SetValue(unsigned int theStripNumber, const double &theValue)
bool theStoreToDB
config switch
double GetPhi(void) const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
RunNumber_t run() const
Definition: EventID.h:38
Definition: DetId.h:17
LASGlobalData< LASModuleProfile > pedestalProfiles
T & GetTEC2TECEntry(int subdetector, int beam, int tecDisk)
LASGlobalData< LASCoordinateSet > nominalCoordinates
AlignableTracker * theAlignableTracker
int theEvents
counter for the total number of events processed
LASBarrelAlignmentParameterSet CalculateParameters(LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &)
LASConstants theLasConstants
double getTEC2TECNominalBeamOffset(unsigned int, unsigned int, unsigned int)
returns the nominal beam position (strips) in TEC (AT) for the profileJudge
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:106
void SetOverdriveThreshold(unsigned int)
T & GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk)
Definition: LASGlobalData.h:84
LASGlobalData< std::string > theProfileNames
double GetAlignmentParameterCorrection(int, int, int, int, LASGlobalData< LASCoordinateSet > &, LASEndcapAlignmentParameterSet &)
std::vector< unsigned int > theMaskAtModules
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
void ApplyATMaskingCorrections(LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &, LASBarrelAlignmentParameterSet &)
same for alignment tube modules
void testRoutine(void)
for debugging & testing only, will disappear..
LASGlobalData< LASModuleProfile > collectedDataProfiles
void fillDetectorId(void)
fill hard coded detIds
HLT enums.
int theCompression
config parameter (histograms file compression level)
void EnableZeroFilter(bool)
LASGlobalData< unsigned int > detectorId
const edm::ESGetToken< Alignments, GlobalPositionRcd > gprToken_
bool isAvailable() const
Definition: Service.h:40
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:305
bool enableJudgeZeroFilter
config switch
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
double GetTIBTOBAlignmentParameterCorrection(int, int, int, LASGlobalData< LASCoordinateSet > &, LASBarrelAlignmentParameterSet &)
void SetTECEntry(int subdetector, int tecRing, int beam, int tecDisk, T)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:498
edm::ESHandle< GeometricDet > gD
tracker geometry;
def move(src, dest)
Definition: eostools.py:511
EventNumber_t event() const
Definition: EventID.h:40
void EndcapUpdate(LASEndcapAlignmentParameterSet &, LASGlobalData< LASCoordinateSet > &)
Definition: Run.h:45
LASGlobalLoop moduleLoop
#define LogDebug(id)
LASProfileJudge judge
bool updateFromInputGeometry
config switch
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
bool theSetNominalStrips
config switch