21 theDoPedestalSubtraction(theConf.getUntrackedParameter<
bool>(
"SubtractPedestals",
true)),
22 theUseMinuitAlgorithm(theConf.getUntrackedParameter<
bool>(
"RunMinuitAlignmentTubeAlgorithm",
false)),
23 theApplyBeamKinkCorrections(theConf.getUntrackedParameter<
bool>(
"ApplyBeamKinkCorrections",
true)),
24 peakFinderThreshold(theConf.getUntrackedParameter<double>(
"PeakFinderThreshold", 10.)),
25 enableJudgeZeroFilter(theConf.getUntrackedParameter<
bool>(
"EnableJudgeZeroFilter",
true)),
26 judgeOverdriveThreshold(theConf.getUntrackedParameter<unsigned
int>(
"JudgeOverdriveThreshold", 220)),
27 updateFromInputGeometry(theConf.getUntrackedParameter<
bool>(
"UpdateFromInputGeometry",
false)),
28 misalignedByRefGeometry(theConf.getUntrackedParameter<
bool>(
"MisalignedByRefGeometry",
false)),
29 theStoreToDB(theConf.getUntrackedParameter<
bool>(
"SaveToDbase",
false)),
31 theSaveHistograms(theConf.getUntrackedParameter<
bool>(
"SaveHistograms",
false)),
32 theCompression(theConf.getUntrackedParameter<
int>(
"ROOTFileCompression", 1)),
33 theFileName(theConf.getUntrackedParameter<
std::
string>(
"ROOTFileName",
"test.root")),
34 theMaskTecModules(theConf.getUntrackedParameter<
std::
vector<unsigned
int> >(
"MaskTECModules")),
35 theMaskAtModules(theConf.getUntrackedParameter<
std::
vector<unsigned
int> >(
"MaskATModules")),
36 theSetNominalStrips(theConf.getUntrackedParameter<
bool>(
"ForceFitterToNominalStrips",
false)),
39 theAlignableTracker(),
40 theAlignRecordName(
"TrackerAlignmentRcd"),
41 theErrorRecordName(
"TrackerAlignmentErrorExtendedRcd"),
44 std::cout <<
"=============================================================="
45 <<
"\n=== LaserAlignment module configuration ==="
58 <<
"\n Number of TEC modules masked = " <<
theMaskTecModules.size() <<
" (s. below list if > 0)"
59 <<
"\n Number of AT modules masked = " <<
theMaskAtModules.size() <<
" (s. below list if > 0)"
60 <<
"\n Store to database = " << (
theStoreToDB ?
"true" :
"false")
61 <<
"\n ----------------------------------------------- ----------"
63 <<
"\n=============================================================" << std::endl;
67 std::cout <<
" ===============================================================================================\n"
70 <<
" TEC modules have been masked out and will not be considered by the TEC algorithm:\n " << std::flush;
76 std::cout <<
" ===============================================================================================\n\n"
80 std::cout <<
" ===============================================================================================\n"
83 <<
" AT modules have been masked out and will not be considered by the AT algorithm:\n " << std::flush;
89 std::cout <<
" ===============================================================================================\n\n"
97 produces<TkLasBeamCollection, edm::Transition::EndRun>(
"tkLaserBeams").setBranchAlias(
alias +
"TkLasBeamCollection");
135 <<
" ** ERROR: could not open file:" <<
theFileName.c_str() <<
" for writing." << std::endl;
146 std::stringstream nameBuilder;
169 nameBuilder <<
"TEC";
174 nameBuilder <<
"_Ring";
179 nameBuilder <<
"_Beam" <<
beam;
180 nameBuilder <<
"_Disk" << disk;
185 nameBuilder <<
"_Histo";
187 det,
ring,
beam, disk,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
211 nameBuilder <<
"TIB";
213 nameBuilder <<
"TOB";
214 nameBuilder <<
"_Beam" <<
beam;
215 nameBuilder <<
"_Zpos" <<
pos;
221 nameBuilder <<
"_Histo";
223 det,
beam,
pos,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
246 nameBuilder <<
"TEC(AT)";
251 nameBuilder <<
"_Beam" <<
beam;
252 nameBuilder <<
"_Disk" << disk;
257 nameBuilder <<
"_Histo";
259 det,
beam, disk,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
312 LogDebug(
"LaserAlignment") <<
"==========================================================="
313 <<
"\n Private analysis of event #" << theEvent.
id().
event() <<
" in run #"
314 << theEvent.
id().
run();
330 for (det = 0; det < 2; ++det) {
332 for (disk = 0; disk < 9; ++disk) {
363 std::cout <<
" [LaserAlignment::produce] -- LaserAlignment::isTECBeam declares this event "
364 << (isTECMode ?
"" :
"NOT ") <<
"a TEC event." << std::endl;
368 std::cout <<
" [LaserAlignment::produce] -- LaserAlignment::isATBeam declares this event " << (isATMode ?
"" :
"NOT ")
369 <<
"an AT event." << std::endl;
383 LogDebug(
"[LaserAlignment::produce]")
423 LogDebug(
"[LaserAlignment::produce]")
442 LogDebug(
"[LaserAlignment::produce]")
484 std::cout <<
" [LaserAlignment::endRun] -- Total number of events processed: " <<
theEvents << std::endl;
501 std::pair<double, double> peakFinderResults;
527 std::cout <<
" [LaserAlignment::endRun] ** WARNING: Fit failed for TEC det: " << det <<
", ring: " <<
ring
529 <<
")." << std::endl;
535 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
544 const float positionInStrips =
547 : peakFinderResults.first;
549 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
557 measuredStripPositions.
GetTECEntry(det,
ring,
beam, disk) = std::pair<float, float>(256., 1000.);
559 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(256.));
580 std::cout <<
" [LaserAlignment::endJob] ** WARNING: Fit failed for TIB/TOB det: " << det <<
", beam: " <<
beam
587 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
595 const float positionInStrips =
598 : peakFinderResults.first;
600 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
606 const GlobalPoint& globalPoint = theStripDet->surface().toGlobal(
627 std::cout <<
" [LaserAlignment::endRun] ** WARNING: Fit failed for TEC2TEC det: " << det <<
", beam: " <<
beam
634 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
642 const float positionInStrips =
645 : peakFinderResults.first;
647 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
653 const GlobalPoint& globalPoint = theStripDet->surface().toGlobal(
704 const unsigned int nIterations = 30;
716 endcapParameters.
Print();
720 geometryUpdater.
EndcapUpdate(endcapParameters, measuredCoordinates);
750 const unsigned int nIterations = 30;
766 alignmentTubeParameters.
Print();
777 auto laserBeams = std::make_unique<TkLasBeamCollection>();
780 for (det = 0; det < 2; ++det) {
787 const int firstDisk = det == 0 ? 0 : 8;
788 const int lastDisk = det == 0 ? 8 : 0;
791 for (disk = firstDisk; det == 0 ? disk <= lastDisk : disk >= lastDisk; det == 0 ? ++disk : --disk) {
797 dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
802 theStripDet->specificTopology().localError(
824 for (disk = 4; disk >= 0; --disk) {
829 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
833 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first),
834 theStripDet->specificTopology().localError(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first,
842 for (det = 2; det < 4; ++det) {
849 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
853 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTIBTOBEntry(det,
beam,
pos).first),
854 theStripDet->specificTopology().localError(measuredStripPositions.
GetTIBTOBEntry(det,
beam,
pos).first,
864 for (disk = 0; disk < 5; ++disk) {
869 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
873 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first),
874 theStripDet->specificTopology().localError(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first,
895 std::cout <<
" [LaserAlignment::endRun] -- Storing the calculated alignment parameters to the DataBase:"
901 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
921 std::cout <<
" [LaserAlignment::endRun] -- Storing done." << std::endl;
939 bool isRawDigi =
false;
942 int det = 0,
ring = 0,
beam = 0, disk = 0,
pos = 0;
945 for (std::vector<edm::ParameterSet>::iterator itDigiProducersList =
theDigiProducersList.begin();
947 ++itDigiProducersList) {
954 if (digiType ==
"Raw") {
957 }
else if (digiType ==
"Processed") {
962 <<
" ** ERROR: Invalid digi type: \"" << digiType <<
"\" specified in configuration." << std::endl;
981 if (detSetIter == theStripRawDigis->end()) {
983 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
991 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
993 const int channel =
distance(digiRangeStart, digiRangeIterator);
994 if (channel >= 0 && channel < 512)
998 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1010 if (detSetIter == theStripDigis->end())
1016 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1018 if (digi.
strip() < 512)
1022 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1044 if (detSetIter == theStripRawDigis->end()) {
1046 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
1054 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1056 const int channel =
distance(digiRangeStart, digiRangeIterator);
1057 if (channel >= 0 && channel < 512)
1061 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1073 if (detSetIter == theStripDigis->end())
1079 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1081 if (digi.
strip() < 512)
1085 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1107 if (detSetIter == theStripRawDigis->end()) {
1109 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
1117 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1119 const int channel =
distance(digiRangeStart, digiRangeIterator);
1120 if (channel >= 0 && channel < 512)
1124 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1136 if (detSetIter == theStripDigis->end())
1142 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1144 if (digi.
strip() < 512)
1148 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1178 if (thePedestal > 895)
1179 thePedestal -= 1024;
1192 if (thePedestal > 895)
1193 thePedestal -= 1024;
1206 if (thePedestal > 895)
1207 thePedestal -= 1024;
1219 int numberOfProfiles = 0;
1222 for (
int det = 0; det < 2; ++det) {
1224 for (
int disk = 0; disk < 9; ++disk) {
1231 LogDebug(
"[LaserAlignment::isTECBeam]") <<
" Found: " << numberOfProfiles <<
"hits." << std::endl;
1232 std::cout <<
" [LaserAlignment::isTECBeam] -- Found: " << numberOfProfiles <<
" hits." << std::endl;
1234 if (numberOfProfiles > 10)
1246 int numberOfProfiles = 0;
1256 LogDebug(
"[LaserAlignment::isATBeam]") <<
" Found: " << numberOfProfiles <<
"hits." << std::endl;
1257 std::cout <<
" [LaserAlignment::isATBeam] -- Found: " << numberOfProfiles <<
" hits." << std::endl;
1259 if (numberOfProfiles > 10)
1273 if (det < 2 || det > 3 ||
beam > 7 ||
pos > 5) {
1274 throw cms::Exception(
"[LaserAlignment::getTIBTOBNominalBeamOffset]")
1275 <<
" ERROR ** Called with nonexisting parameter set: det " << det <<
" beam " <<
beam <<
" pos " <<
pos <<
"."
1279 const double nominalOffsetsTIB[8] = {
1280 0.00035, 2.10687, -2.10827, -0.00173446, 2.10072, -0.00135114, 2.10105, -2.10401};
1285 const int orientationPattern[6] = {-1, 1, 1, -1, -1, 1};
1286 const double nominalOffsetsTOB[8] = {0.00217408, 1.58678, 117.733, 119.321, 120.906, 119.328, 117.743, 1.58947};
1289 return (-1. * nominalOffsetsTIB[
beam]);
1293 return (nominalOffsetsTOB[
beam] * orientationPattern[
pos]);
1295 return (-1. * nominalOffsetsTOB[
beam] * orientationPattern[
pos]);
1308 if (det > 1 ||
beam > 7 || disk > 5) {
1309 throw cms::Exception(
"[LaserAlignment::getTEC2TECNominalBeamOffset]")
1310 <<
" ERROR ** Called with nonexisting parameter set: det " << det <<
" beam " <<
beam <<
" disk " << disk <<
"."
1314 const double nominalOffsets[8] = {0., 2.220, -2.221, 0., 2.214, 0., 2.214, -2.217};
1317 return -1. * nominalOffsets[
beam];
1319 return nominalOffsets[
beam];
1331 const double tecPhiPositions[8] = {
1332 0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486};
1333 const double atPhiPositions[8] = {
1334 0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784};
1337 const double tobRPosition = 600.;
1338 const double tibRPosition = 514.;
1339 const double tecRPosition[2] = {564., 840.};
1342 const double tobZPosition[6] = {1040., 580., 220., -140., -500., -860.};
1343 const double tibZPosition[6] = {620., 380., 180., -100., -340., -540.};
1346 const double tecZPosition[9] = {1322.5, 1462.5, 1602.5, 1742.5, 1882.5, 2057.5, 2247.5, 2452.5, 2667.5};
1376 tecPhiPositions[
beam], 0., tecRPosition[
ring], 0., -1. * tecZPosition[disk], 0.));
1409 LASCoordinateSet(atPhiPositions[
beam], 0., tecRPosition[0], 0., -1. * tecZPosition[disk], 0.));
1420 if (angle < -1. * M_PI || angle >
M_PI) {
1422 <<
"** ERROR: Called with illegal input angle: " <<
angle <<
"." << std::endl;
1438 std::cout << std::endl <<
" [LaserAlignment::DumpPosFileSet] -- Dump: " << std::endl;
1446 std::cout <<
"POS " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t" <<
ring <<
"\t"
1467 std::cout <<
"POS " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t"
1471 }
while (
loop.TEC2TECLoop(det,
beam, disk));
1473 std::cout << std::endl <<
" [LaserAlignment::DumpPosFileSet] -- End dump: " << std::endl;
1483 std::cout << std::endl <<
" [LaserAlignment::DumpStripFileSet] -- Dump: " << std::endl;
1491 std::cout <<
"STRIP " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t" <<
ring <<
"\t"
1492 << measuredStripPositions.GetTECEntry(det,
ring,
beam, disk).first <<
"\t"
1493 << measuredStripPositions.GetTECEntry(det,
ring,
beam, disk).second << std::endl;
1503 <<
"\t" << measuredStripPositions.GetTIBTOBEntry(det,
beam,
pos).first <<
"\t"
1504 << measuredStripPositions.GetTIBTOBEntry(det,
beam,
pos).second << std::endl;
1512 std::cout <<
"STRIP " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t"
1514 <<
"\t" << measuredStripPositions.GetTEC2TECEntry(det,
beam, disk).first <<
"\t"
1515 << measuredStripPositions.GetTEC2TECEntry(det,
beam, disk).second << std::endl;
1516 }
while (
loop.TEC2TECLoop(det,
beam, disk));
1518 std::cout << std::endl <<
" [LaserAlignment::DumpStripFileSet] -- End dump: " << std::endl;
1525 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC+:" << std::endl;
1526 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
1527 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1531 for (
int disk = 0; disk < 9; ++disk) {
1537 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
1538 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1542 for (
int disk = 0; disk < 9; ++disk) {
1548 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC-:" << std::endl;
1549 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
1550 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1554 for (
int disk = 0; disk < 9; ++disk) {
1560 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
1561 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1565 for (
int disk = 0; disk < 9; ++disk) {
1571 std::cout <<
" [LaserAlignment::DumpHitmaps] -- End of dump." << std::endl << std::endl;
1644 const double phiCorrection =
1664 const double phiCorrection =
1683 const double atPhiPositions[8] = {0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784};
1684 const double tecPhiPositions[8] = {0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486};
1685 const double zPositions[9] = {125.0, 139.0, 153.0, 167.0, 181.0, 198.5, 217.5, 238.0, 259.5};
1686 const double zPositionsTIB[6] = {62.0, 38.0, 18.0, -10.0, -34.0, -54.0};
1687 const double zPositionsTOB[6] = {104.0, 58.0, 22.0, -14.0, -50.0, -86.0};
1701 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1706 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1707 std::cout <<
"__TEC: " << 256. - theStripDet->specificTopology().strip(lp)
1719 (det == 2 ? 51.4 : 58.4);
1720 const double theZ = (det == 2 ? zPositionsTIB[
pos] : zPositionsTOB[
pos]);
1724 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1729 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1730 std::cout <<
"__TIBTOB det " << det <<
" beam " <<
beam <<
" pos " <<
pos <<
" "
1731 << 256. - theStripDet->specificTopology().strip(lp);
1732 std::cout <<
" " << theStripDet->position().perp() << std::endl;
1742 const double radius = 56.4;
1746 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1751 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1752 std::cout <<
"__TEC2TEC det " << det <<
" beam " <<
beam <<
" disk " << disk <<
" "
1753 << 256. - theStripDet->specificTopology().strip(lp) << std::endl;