CMS 3D CMS Logo

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