27 theDoPedestalSubtraction(theConf.getUntrackedParameter<
bool>(
"SubtractPedestals",
true)),
28 theUseMinuitAlgorithm(theConf.getUntrackedParameter<
bool>(
"RunMinuitAlignmentTubeAlgorithm",
false)),
29 theApplyBeamKinkCorrections(theConf.getUntrackedParameter<
bool>(
"ApplyBeamKinkCorrections",
true)),
30 peakFinderThreshold(theConf.getUntrackedParameter<double>(
"PeakFinderThreshold", 10.)),
31 enableJudgeZeroFilter(theConf.getUntrackedParameter<
bool>(
"EnableJudgeZeroFilter",
true)),
32 judgeOverdriveThreshold(theConf.getUntrackedParameter<unsigned
int>(
"JudgeOverdriveThreshold", 220)),
33 updateFromInputGeometry(theConf.getUntrackedParameter<
bool>(
"UpdateFromInputGeometry",
false)),
34 misalignedByRefGeometry(theConf.getUntrackedParameter<
bool>(
"MisalignedByRefGeometry",
false)),
35 theStoreToDB(theConf.getUntrackedParameter<
bool>(
"SaveToDbase",
false)),
37 theSaveHistograms(theConf.getUntrackedParameter<
bool>(
"SaveHistograms",
false)),
38 theCompression(theConf.getUntrackedParameter<
int>(
"ROOTFileCompression", 1)),
39 theFileName(theConf.getUntrackedParameter<
std::
string>(
"ROOTFileName",
"test.root")),
40 theMaskTecModules(theConf.getUntrackedParameter<
std::
vector<unsigned
int> >(
"MaskTECModules")),
41 theMaskAtModules(theConf.getUntrackedParameter<
std::
vector<unsigned
int> >(
"MaskATModules")),
42 theSetNominalStrips(theConf.getUntrackedParameter<
bool>(
"ForceFitterToNominalStrips",
false)),
45 theAlignableTracker(),
46 theAlignRecordName(
"TrackerAlignmentRcd"),
47 theErrorRecordName(
"TrackerAlignmentErrorExtendedRcd"),
50 std::cout <<
"=============================================================="
51 <<
"\n=== LaserAlignment module configuration ==="
64 <<
"\n Number of TEC modules masked = " <<
theMaskTecModules.size() <<
" (s. below list if > 0)"
65 <<
"\n Number of AT modules masked = " <<
theMaskAtModules.size() <<
" (s. below list if > 0)"
66 <<
"\n Store to database = " << (
theStoreToDB ?
"true" :
"false")
67 <<
"\n ----------------------------------------------- ----------"
69 <<
"\n=============================================================" << std::endl;
73 std::cout <<
" ===============================================================================================\n"
76 <<
" TEC modules have been masked out and will not be considered by the TEC algorithm:\n " << std::flush;
82 std::cout <<
" ===============================================================================================\n\n"
86 std::cout <<
" ===============================================================================================\n"
89 <<
" AT modules have been masked out and will not be considered by the AT algorithm:\n " << std::flush;
95 std::cout <<
" ===============================================================================================\n\n"
103 produces<TkLasBeamCollection, edm::Transition::EndRun>(
"tkLaserBeams").setBranchAlias(
alias +
"TkLasBeamCollection");
141 <<
" ** ERROR: could not open file:" <<
theFileName.c_str() <<
" for writing." << std::endl;
152 std::stringstream nameBuilder;
175 nameBuilder <<
"TEC";
180 nameBuilder <<
"_Ring";
185 nameBuilder <<
"_Beam" <<
beam;
186 nameBuilder <<
"_Disk" << disk;
191 nameBuilder <<
"_Histo";
193 det,
ring,
beam, disk,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
217 nameBuilder <<
"TIB";
219 nameBuilder <<
"TOB";
220 nameBuilder <<
"_Beam" <<
beam;
221 nameBuilder <<
"_Zpos" <<
pos;
227 nameBuilder <<
"_Histo";
229 det,
beam,
pos,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
252 nameBuilder <<
"TEC(AT)";
257 nameBuilder <<
"_Beam" <<
beam;
258 nameBuilder <<
"_Disk" << disk;
263 nameBuilder <<
"_Histo";
265 det,
beam, disk,
new TH1D(nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512));
314 LogDebug(
"LaserAlignment") <<
"==========================================================="
315 <<
"\n Private analysis of event #" << theEvent.
id().
event() <<
" in run #"
316 << theEvent.
id().
run();
332 for (det = 0; det < 2; ++det) {
334 for (disk = 0; disk < 9; ++disk) {
365 std::cout <<
" [LaserAlignment::produce] -- LaserAlignment::isTECBeam declares this event "
366 << (isTECMode ?
"" :
"NOT ") <<
"a TEC event." << std::endl;
370 std::cout <<
" [LaserAlignment::produce] -- LaserAlignment::isATBeam declares this event " << (isATMode ?
"" :
"NOT ")
371 <<
"an AT event." << std::endl;
385 LogDebug(
"[LaserAlignment::produce]")
425 LogDebug(
"[LaserAlignment::produce]")
444 LogDebug(
"[LaserAlignment::produce]")
486 std::cout <<
" [LaserAlignment::endRun] -- Total number of events processed: " <<
theEvents << std::endl;
503 std::pair<double, double> peakFinderResults;
529 std::cout <<
" [LaserAlignment::endRun] ** WARNING: Fit failed for TEC det: " << det <<
", ring: " <<
ring
531 <<
")." << std::endl;
537 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
546 const float positionInStrips =
549 : peakFinderResults.first;
551 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
559 measuredStripPositions.
GetTECEntry(det,
ring,
beam, disk) = std::pair<float, float>(256., 1000.);
561 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(256.));
582 std::cout <<
" [LaserAlignment::endJob] ** WARNING: Fit failed for TIB/TOB det: " << det <<
", beam: " <<
beam
589 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
597 const float positionInStrips =
600 : peakFinderResults.first;
602 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
608 const GlobalPoint& globalPoint = theStripDet->surface().toGlobal(
629 std::cout <<
" [LaserAlignment::endRun] ** WARNING: Fit failed for TEC2TEC det: " << det <<
", beam: " <<
beam
636 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
644 const float positionInStrips =
647 : peakFinderResults.first;
649 theStripDet->surface().toGlobal(theStripDet->specificTopology().localPosition(positionInStrips));
655 const GlobalPoint& globalPoint = theStripDet->surface().toGlobal(
706 const unsigned int nIterations = 30;
718 endcapParameters.
Print();
722 geometryUpdater.
EndcapUpdate(endcapParameters, measuredCoordinates);
752 const unsigned int nIterations = 30;
768 alignmentTubeParameters.
Print();
779 auto laserBeams = std::make_unique<TkLasBeamCollection>();
782 for (det = 0; det < 2; ++det) {
789 const int firstDisk = det == 0 ? 0 : 8;
790 const int lastDisk = det == 0 ? 8 : 0;
793 for (disk = firstDisk; det == 0 ? disk <= lastDisk : disk >= lastDisk; det == 0 ? ++disk : --disk) {
799 dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
804 theStripDet->specificTopology().localError(
812 laserBeams->push_back(currentBeam);
826 for (disk = 4; disk >= 0; --disk) {
831 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
835 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first),
836 theStripDet->specificTopology().localError(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first,
844 for (det = 2; det < 4; ++det) {
851 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
855 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTIBTOBEntry(det,
beam,
pos).first),
856 theStripDet->specificTopology().localError(measuredStripPositions.
GetTIBTOBEntry(det,
beam,
pos).first,
866 for (disk = 0; disk < 5; ++disk) {
871 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
875 theStripDet->specificTopology().localPosition(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first),
876 theStripDet->specificTopology().localError(measuredStripPositions.
GetTEC2TECEntry(det,
beam, disk).first,
884 laserBeams->push_back(currentBeam);
897 std::cout <<
" [LaserAlignment::endRun] -- Storing the calculated alignment parameters to the DataBase:"
903 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
923 std::cout <<
" [LaserAlignment::endRun] -- Storing done." << std::endl;
941 bool isRawDigi =
false;
944 int det = 0,
ring = 0,
beam = 0, disk = 0,
pos = 0;
947 for (std::vector<edm::ParameterSet>::iterator itDigiProducersList =
theDigiProducersList.begin();
949 ++itDigiProducersList) {
956 if (digiType ==
"Raw") {
959 }
else if (digiType ==
"Processed") {
964 <<
" ** ERROR: Invalid digi type: \"" << digiType <<
"\" specified in configuration." << std::endl;
983 if (detSetIter == theStripRawDigis->end()) {
985 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
993 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
995 const int channel =
distance(digiRangeStart, digiRangeIterator);
996 if (channel >= 0 && channel < 512)
1000 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1012 if (detSetIter == theStripDigis->end())
1018 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1020 if (digi.
strip() < 512)
1024 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1046 if (detSetIter == theStripRawDigis->end()) {
1048 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
1056 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1058 const int channel =
distance(digiRangeStart, digiRangeIterator);
1059 if (channel >= 0 && channel < 512)
1063 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1075 if (detSetIter == theStripDigis->end())
1081 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1083 if (digi.
strip() < 512)
1087 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1109 if (detSetIter == theStripRawDigis->end()) {
1111 <<
" ** ERROR: No raw DetSet found for det: " << detRawId <<
"." << std::endl;
1119 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1121 const int channel =
distance(digiRangeStart, digiRangeIterator);
1122 if (channel >= 0 && channel < 512)
1126 <<
" ** ERROR: raw digi channel: " << channel <<
" out of range for det: " << detRawId <<
"."
1138 if (detSetIter == theStripDigis->end())
1144 for (; digiRangeIterator != detSetIter->data.
end(); ++digiRangeIterator) {
1146 if (digi.
strip() < 512)
1150 <<
" ** ERROR: digi strip: " << digi.
strip() <<
" out of range for det: " << detRawId <<
"."
1180 if (thePedestal > 895)
1181 thePedestal -= 1024;
1194 if (thePedestal > 895)
1195 thePedestal -= 1024;
1208 if (thePedestal > 895)
1209 thePedestal -= 1024;
1221 int numberOfProfiles = 0;
1224 for (
int det = 0; det < 2; ++det) {
1226 for (
int disk = 0; disk < 9; ++disk) {
1233 LogDebug(
"[LaserAlignment::isTECBeam]") <<
" Found: " << numberOfProfiles <<
"hits." << std::endl;
1234 std::cout <<
" [LaserAlignment::isTECBeam] -- Found: " << numberOfProfiles <<
" hits." << std::endl;
1236 if (numberOfProfiles > 10)
1248 int numberOfProfiles = 0;
1258 LogDebug(
"[LaserAlignment::isATBeam]") <<
" Found: " << numberOfProfiles <<
"hits." << std::endl;
1259 std::cout <<
" [LaserAlignment::isATBeam] -- Found: " << numberOfProfiles <<
" hits." << std::endl;
1261 if (numberOfProfiles > 10)
1275 if (det < 2 || det > 3 ||
beam > 7 ||
pos > 5) {
1276 throw cms::Exception(
"[LaserAlignment::getTIBTOBNominalBeamOffset]")
1277 <<
" ERROR ** Called with nonexisting parameter set: det " << det <<
" beam " <<
beam <<
" pos " <<
pos <<
"."
1281 const double nominalOffsetsTIB[8] = {
1282 0.00035, 2.10687, -2.10827, -0.00173446, 2.10072, -0.00135114, 2.10105, -2.10401};
1287 const int orientationPattern[6] = {-1, 1, 1, -1, -1, 1};
1288 const double nominalOffsetsTOB[8] = {0.00217408, 1.58678, 117.733, 119.321, 120.906, 119.328, 117.743, 1.58947};
1291 return (-1. * nominalOffsetsTIB[
beam]);
1295 return (nominalOffsetsTOB[
beam] * orientationPattern[
pos]);
1297 return (-1. * nominalOffsetsTOB[
beam] * orientationPattern[
pos]);
1310 if (det > 1 ||
beam > 7 || disk > 5) {
1311 throw cms::Exception(
"[LaserAlignment::getTEC2TECNominalBeamOffset]")
1312 <<
" ERROR ** Called with nonexisting parameter set: det " << det <<
" beam " <<
beam <<
" disk " << disk <<
"."
1316 const double nominalOffsets[8] = {0., 2.220, -2.221, 0., 2.214, 0., 2.214, -2.217};
1319 return -1. * nominalOffsets[
beam];
1321 return nominalOffsets[
beam];
1333 const double tecPhiPositions[8] = {
1334 0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486};
1335 const double atPhiPositions[8] = {
1336 0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784};
1339 const double tobRPosition = 600.;
1340 const double tibRPosition = 514.;
1341 const double tecRPosition[2] = {564., 840.};
1344 const double tobZPosition[6] = {1040., 580., 220., -140., -500., -860.};
1345 const double tibZPosition[6] = {620., 380., 180., -100., -340., -540.};
1348 const double tecZPosition[9] = {1322.5, 1462.5, 1602.5, 1742.5, 1882.5, 2057.5, 2247.5, 2452.5, 2667.5};
1378 tecPhiPositions[
beam], 0., tecRPosition[
ring], 0., -1. * tecZPosition[disk], 0.));
1411 LASCoordinateSet(atPhiPositions[
beam], 0., tecRPosition[0], 0., -1. * tecZPosition[disk], 0.));
1422 if (angle < -1. * M_PI || angle >
M_PI) {
1424 <<
"** ERROR: Called with illegal input angle: " <<
angle <<
"." << std::endl;
1440 std::cout << std::endl <<
" [LaserAlignment::DumpPosFileSet] -- Dump: " << std::endl;
1448 std::cout <<
"POS " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t" <<
ring <<
"\t"
1469 std::cout <<
"POS " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t"
1473 }
while (
loop.TEC2TECLoop(det,
beam, disk));
1475 std::cout << std::endl <<
" [LaserAlignment::DumpPosFileSet] -- End dump: " << std::endl;
1485 std::cout << std::endl <<
" [LaserAlignment::DumpStripFileSet] -- Dump: " << std::endl;
1493 std::cout <<
"STRIP " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t" <<
ring <<
"\t"
1494 << measuredStripPositions.GetTECEntry(det,
ring,
beam, disk).first <<
"\t"
1495 << measuredStripPositions.GetTECEntry(det,
ring,
beam, disk).second << std::endl;
1505 <<
"\t" << measuredStripPositions.GetTIBTOBEntry(det,
beam,
pos).first <<
"\t"
1506 << measuredStripPositions.GetTIBTOBEntry(det,
beam,
pos).second << std::endl;
1514 std::cout <<
"STRIP " << det <<
"\t" <<
beam <<
"\t" << disk <<
"\t"
1516 <<
"\t" << measuredStripPositions.GetTEC2TECEntry(det,
beam, disk).first <<
"\t"
1517 << measuredStripPositions.GetTEC2TECEntry(det,
beam, disk).second << std::endl;
1518 }
while (
loop.TEC2TECLoop(det,
beam, disk));
1520 std::cout << std::endl <<
" [LaserAlignment::DumpStripFileSet] -- End dump: " << std::endl;
1527 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC+:" << std::endl;
1528 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
1529 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1533 for (
int disk = 0; disk < 9; ++disk) {
1539 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
1540 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1544 for (
int disk = 0; disk < 9; ++disk) {
1550 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC-:" << std::endl;
1551 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
1552 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1556 for (
int disk = 0; disk < 9; ++disk) {
1562 std::cout <<
" [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
1563 std::cout <<
" disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8" << std::endl;
1567 for (
int disk = 0; disk < 9; ++disk) {
1573 std::cout <<
" [LaserAlignment::DumpHitmaps] -- End of dump." << std::endl << std::endl;
1646 const double phiCorrection =
1666 const double phiCorrection =
1685 const double atPhiPositions[8] = {0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784};
1686 const double tecPhiPositions[8] = {0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486};
1687 const double zPositions[9] = {125.0, 139.0, 153.0, 167.0, 181.0, 198.5, 217.5, 238.0, 259.5};
1688 const double zPositionsTIB[6] = {62.0, 38.0, 18.0, -10.0, -34.0, -54.0};
1689 const double zPositionsTOB[6] = {104.0, 58.0, 22.0, -14.0, -50.0, -86.0};
1703 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1708 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1709 std::cout <<
"__TEC: " << 256. - theStripDet->specificTopology().strip(lp)
1721 (det == 2 ? 51.4 : 58.4);
1722 const double theZ = (det == 2 ? zPositionsTIB[
pos] : zPositionsTOB[
pos]);
1726 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1731 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1732 std::cout <<
"__TIBTOB det " << det <<
" beam " <<
beam <<
" pos " <<
pos <<
" "
1733 << 256. - theStripDet->specificTopology().strip(lp);
1734 std::cout <<
" " << theStripDet->position().perp() << std::endl;
1744 const double radius = 56.4;
1748 const StripGeomDetUnit*
const theStripDet = dynamic_cast<const StripGeomDetUnit*>(theTracker.
idToDet(theDetId));
1753 const LocalPoint lp(theStripDet->surface().toLocal(
gp));
1754 std::cout <<
"__TEC2TEC det " << det <<
" beam " <<
beam <<
" disk " << disk <<
" "
1755 << 256. - theStripDet->specificTopology().strip(lp) << std::endl;