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)),
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)),
48 theAlignableTracker(),
49 theAlignRecordName(
"TrackerAlignmentRcd"),
50 theErrorRecordName(
"TrackerAlignmentErrorExtendedRcd"),
53 std::cout <<
"=============================================================="
54 <<
"\n=== LaserAlignment module configuration ==="
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 ----------------------------------------------- ----------"
72 <<
"\n=============================================================" << std::endl;
76 std::cout <<
" ===============================================================================================\n"
79 <<
" TEC modules have been masked out and will not be considered by the TEC algorithm:\n " << std::flush;
85 std::cout <<
" ===============================================================================================\n\n"
89 std::cout <<
" ===============================================================================================\n"
92 <<
" AT modules have been masked out and will not be considered by the AT algorithm:\n " << std::flush;
98 std::cout <<
" ===============================================================================================\n\n"
106 produces<TkLasBeamCollection, edm::Transition::EndRun>(
"tkLaserBeams").setBranchAlias(
alias +
"TkLasBeamCollection");
144 <<
" ** ERROR: could not open file:" <<
theFileName.c_str() <<
" for writing." << std::endl;
155 std::stringstream nameBuilder;
178 nameBuilder <<
"TEC";
183 nameBuilder <<
"_Ring";
188 nameBuilder <<
"_Beam" <<
beam;
189 nameBuilder <<
"_Disk" << disk;
194 nameBuilder <<
"_Histo";
196 det,
ring,
beam, disk,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
220 nameBuilder <<
"TIB";
222 nameBuilder <<
"TOB";
223 nameBuilder <<
"_Beam" <<
beam;
224 nameBuilder <<
"_Zpos" <<
pos;
230 nameBuilder <<
"_Histo";
232 det,
beam,
pos,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
255 nameBuilder <<
"TEC(AT)";
260 nameBuilder <<
"_Beam" <<
beam;
261 nameBuilder <<
"_Disk" << disk;
266 nameBuilder <<
"_Histo";
268 det,
beam, disk,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
318 LogDebug(
"LaserAlignment") <<
"==========================================================="
319 <<
"\n Private analysis of event #" << theEvent.
id().
event() <<
" in run #"
320 << theEvent.
id().
run();
336 for (det = 0; det < 2; ++det) {
338 for (disk = 0; disk < 9; ++disk) {
369 std::cout <<
" [LaserAlignment::produce] -- LaserAlignment::isTECBeam declares this event "
370 << (isTECMode ?
"" :
"NOT ") <<
"a TEC event." << std::endl;
374 std::cout <<
" [LaserAlignment::produce] -- LaserAlignment::isATBeam declares this event " << (isATMode ?
"" :
"NOT ")
375 <<
"an AT event." << std::endl;
389 LogDebug(
"[LaserAlignment::produce]")
429 LogDebug(
"[LaserAlignment::produce]")
448 LogDebug(
"[LaserAlignment::produce]")
490 std::cout <<
" [LaserAlignment::endRun] -- Total number of events processed: " <<
theEvents << std::endl;
507 std::pair<double, double> peakFinderResults;
533 std::cout <<
" [LaserAlignment::endRun] ** WARNING: Fit failed for TEC det: " << det <<
", ring: " <<
ring
535 <<
")." << std::endl;
541 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
550 const float positionInStrips =
553 : peakFinderResults.first;
555 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
563 measuredStripPositions.
GetTECEntry(det,
ring,
beam, disk) = std::pair<float, float>(256., 1000.);
565 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(256.));
586 std::cout <<
" [LaserAlignment::endJob] ** WARNING: Fit failed for TIB/TOB det: " << det <<
", beam: " <<
beam
593 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
601 const float positionInStrips =
604 : peakFinderResults.first;
606 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
612 const GlobalPoint& globalPoint = theStripDet->surface().toGlobal(
633 std::cout <<
" [LaserAlignment::endRun] ** WARNING: Fit failed for TEC2TEC det: " << det <<
", beam: " <<
beam
640 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
648 const float positionInStrips =
651 : peakFinderResults.first;
653 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
659 const GlobalPoint& globalPoint = theStripDet->surface().toGlobal(
710 const unsigned int nIterations = 30;
722 endcapParameters.
Print();
726 geometryUpdater.
EndcapUpdate(endcapParameters, measuredCoordinates);
756 const unsigned int nIterations = 30;
772 alignmentTubeParameters.
Print();
783 auto laserBeams = std::make_unique<TkLasBeamCollection>();
786 for (det = 0; det < 2; ++det) {
793 const int firstDisk = det == 0 ? 0 : 8;
794 const int lastDisk = det == 0 ? 8 : 0;
797 for (disk = firstDisk; det == 0 ? disk <= lastDisk : disk >= lastDisk; det == 0 ? ++disk : --disk) {
803 dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
808 theStripDet->specificTopology().localError(
816 laserBeams->push_back(currentBeam);
830 for (disk = 4; disk >= 0; --disk) {
835 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
839 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first),
840 theStripDet->specificTopology().localError(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first,
848 for (det = 2; det < 4; ++det) {
855 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
859 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTIBTOBEntry(det,
beam,
pos).first),
860 theStripDet->specificTopology().localError(measuredStripPositions.
GetTIBTOBEntry(det,
beam,
pos).first,
870 for (disk = 0; disk < 5; ++disk) {
875 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
879 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first),
880 theStripDet->specificTopology().localError(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first,
888 laserBeams->push_back(currentBeam);
901 std::cout <<
" [LaserAlignment::endRun] -- Storing the calculated alignment parameters to the DataBase:"
907 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
927 std::cout <<
" [LaserAlignment::endRun] -- Storing done." << std::endl;
945 bool isRawDigi =
false;
948 int det = 0,
ring = 0,
beam = 0, disk = 0,
pos = 0;
951 for (std::vector<edm::ParameterSet>::iterator itDigiProducersList =
theDigiProducersList.begin();
953 ++itDigiProducersList) {
960 if (digiType ==
"Raw") {
963 }
else if (digiType ==
"Processed") {
968 <<
" ** ERROR: Invalid digi type: \"" << digiType <<
"\" specified in configuration." << std::endl;
987 if (detSetIter == theStripRawDigis->end()) {
989 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
997 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
999 const int channel =
distance(digiRangeStart, digiRangeIterator);
1000 if (channel >= 0 && channel < 512)
1004 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1016 if (detSetIter == theStripDigis->end())
1022 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1024 if (digi.
strip() < 512)
1028 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1050 if (detSetIter == theStripRawDigis->end()) {
1052 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
1060 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1062 const int channel =
distance(digiRangeStart, digiRangeIterator);
1063 if (channel >= 0 && channel < 512)
1067 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1079 if (detSetIter == theStripDigis->end())
1085 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1087 if (digi.
strip() < 512)
1091 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1113 if (detSetIter == theStripRawDigis->end()) {
1115 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
1123 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1125 const int channel =
distance(digiRangeStart, digiRangeIterator);
1126 if (channel >= 0 && channel < 512)
1130 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1142 if (detSetIter == theStripDigis->end())
1148 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1150 if (digi.
strip() < 512)
1154 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1184 if (thePedestal > 895)
1185 thePedestal -= 1024;
1198 if (thePedestal > 895)
1199 thePedestal -= 1024;
1212 if (thePedestal > 895)
1213 thePedestal -= 1024;
1225 int numberOfProfiles = 0;
1228 for (
int det = 0; det < 2; ++det) {
1230 for (
int disk = 0; disk < 9; ++disk) {
1237 LogDebug(
"[LaserAlignment::isTECBeam]") <<
" Found: " << numberOfProfiles <<
"hits." << std::endl;
1238 std::cout <<
" [LaserAlignment::isTECBeam] -- Found: " << numberOfProfiles <<
" hits." << std::endl;
1240 if (numberOfProfiles > 10)
1252 int numberOfProfiles = 0;
1262 LogDebug(
"[LaserAlignment::isATBeam]") <<
" Found: " << numberOfProfiles <<
"hits." << std::endl;
1263 std::cout <<
" [LaserAlignment::isATBeam] -- Found: " << numberOfProfiles <<
" hits." << std::endl;
1265 if (numberOfProfiles > 10)
1279 if (det < 2 || det > 3 ||
beam > 7 ||
pos > 5) {
1280 throw cms::Exception(
"[LaserAlignment::getTIBTOBNominalBeamOffset]")
1281 <<
" ERROR ** Called with nonexisting parameter set: det " << det <<
" beam " <<
beam <<
" pos " <<
pos <<
"."
1285 const double nominalOffsetsTIB[8] = {
1286 0.00035, 2.10687, -2.10827, -0.00173446, 2.10072, -0.00135114, 2.10105, -2.10401};
1291 const int orientationPattern[6] = {-1, 1, 1, -1, -1, 1};
1292 const double nominalOffsetsTOB[8] = {0.00217408, 1.58678, 117.733, 119.321, 120.906, 119.328, 117.743, 1.58947};
1295 return (-1. * nominalOffsetsTIB[
beam]);
1299 return (nominalOffsetsTOB[
beam] * orientationPattern[
pos]);
1301 return (-1. * nominalOffsetsTOB[
beam] * orientationPattern[
pos]);
1314 if (det > 1 ||
beam > 7 || disk > 5) {
1315 throw cms::Exception(
"[LaserAlignment::getTEC2TECNominalBeamOffset]")
1316 <<
" ERROR ** Called with nonexisting parameter set: det " << det <<
" beam " <<
beam <<
" disk " << disk <<
"."
1320 const double nominalOffsets[8] = {0., 2.220, -2.221, 0., 2.214, 0., 2.214, -2.217};
1323 return -1. * nominalOffsets[
beam];
1325 return nominalOffsets[
beam];
1337 const double tecPhiPositions[8] = {
1338 0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486};
1339 const double atPhiPositions[8] = {
1340 0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784};
1343 const double tobRPosition = 600.;
1344 const double tibRPosition = 514.;
1345 const double tecRPosition[2] = {564., 840.};
1348 const double tobZPosition[6] = {1040., 580., 220., -140., -500., -860.};
1349 const double tibZPosition[6] = {620., 380., 180., -100., -340., -540.};
1352 const double tecZPosition[9] = {1322.5, 1462.5, 1602.5, 1742.5, 1882.5, 2057.5, 2247.5, 2452.5, 2667.5};
1382 tecPhiPositions[
beam], 0., tecRPosition[
ring], 0., -1. * tecZPosition[disk], 0.));
1415 LASCoordinateSet(atPhiPositions[
beam], 0., tecRPosition[0], 0., -1. * tecZPosition[disk], 0.));
1426 if (angle < -1. * M_PI || angle >
M_PI) {
1428 <<
"** ERROR: Called with illegal input angle: " <<
angle <<
"." << std::endl;
1444 std::cout << std::endl <<
" [LaserAlignment::DumpPosFileSet] -- Dump: " << std::endl;
1452 std::cout <<
"POS " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t" <<
ring <<
"\t"
1473 std::cout <<
"POS " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t"
1477 }
while (
loop.TEC2TECLoop(det,
beam, disk));
1479 std::cout << std::endl <<
" [LaserAlignment::DumpPosFileSet] -- End dump: " << std::endl;
1489 std::cout << std::endl <<
" [LaserAlignment::DumpStripFileSet] -- Dump: " << std::endl;
1497 std::cout <<
"STRIP " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t" <<
ring <<
"\t"
1498 << measuredStripPositions.GetTECEntry(det,
ring,
beam, disk).first <<
"\t"
1499 << measuredStripPositions.GetTECEntry(det,
ring,
beam, disk).second << std::endl;
1509 <<
"\t" << measuredStripPositions.GetTIBTOBEntry(det,
beam,
pos).first <<
"\t"
1510 << measuredStripPositions.GetTIBTOBEntry(det,
beam,
pos).second << std::endl;
1518 std::cout <<
"STRIP " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t"
1520 <<
"\t" << measuredStripPositions.GetTEC2TECEntry(det,
beam, disk).first <<
"\t"
1521 << measuredStripPositions.GetTEC2TECEntry(det,
beam, disk).second << std::endl;
1522 }
while (
loop.TEC2TECLoop(det,
beam, disk));
1524 std::cout << std::endl <<
" [LaserAlignment::DumpStripFileSet] -- End dump: " << std::endl;
1531 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC+:" << std::endl;
1532 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
1533 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1537 for (
int disk = 0; disk < 9; ++disk) {
1543 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
1544 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1548 for (
int disk = 0; disk < 9; ++disk) {
1554 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC-:" << std::endl;
1555 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
1556 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1560 for (
int disk = 0; disk < 9; ++disk) {
1566 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
1567 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1571 for (
int disk = 0; disk < 9; ++disk) {
1577 std::cout <<
" [LaserAlignment::DumpHitmaps] -- End of dump." << std::endl << std::endl;
1650 const double phiCorrection =
1670 const double phiCorrection =
1689 const double atPhiPositions[8] = {0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784};
1690 const double tecPhiPositions[8] = {0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486};
1691 const double zPositions[9] = {125.0, 139.0, 153.0, 167.0, 181.0, 198.5, 217.5, 238.0, 259.5};
1692 const double zPositionsTIB[6] = {62.0, 38.0, 18.0, -10.0, -34.0, -54.0};
1693 const double zPositionsTOB[6] = {104.0, 58.0, 22.0, -14.0, -50.0, -86.0};
1707 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1712 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1713 std::cout <<
"__TEC: " << 256. - theStripDet->specificTopology().strip(lp)
1725 (det == 2 ? 51.4 : 58.4);
1726 const double theZ = (det == 2 ? zPositionsTIB[
pos] : zPositionsTOB[
pos]);
1730 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1735 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1736 std::cout <<
"__TIBTOB det " << det <<
" beam " <<
beam <<
" pos " <<
pos <<
" "
1737 << 256. - theStripDet->specificTopology().strip(lp);
1738 std::cout <<
" " << theStripDet->position().perp() << std::endl;
1748 const double radius = 56.4;
1752 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1757 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1758 std::cout <<
"__TEC2TEC det " << det <<
" beam " <<
beam <<
" disk " << disk <<
" "
1759 << 256. - theStripDet->specificTopology().strip(lp) << std::endl;