@@ -79,6 +79,17 @@ class CTPPSDiamondDQMSource : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<
7979 void globalEndLuminosityBlock (const edm::LuminosityBlock&, const edm::EventSetup&) override ;
8080
8181private:
82+ // Helper method to transform coordinates to local coordinate system
83+ CTPPSGeometry::Vector transformToLocalCoordinates (const CTPPSDetId& detId_pot,
84+ double x,
85+ double y,
86+ double z = 0 ) const {
87+ auto localVector = CTPPSGeometry::Vector (x, y, z);
88+ localVector -= diamTranslations_.at (detId_pot);
89+ localVector = diamRotations_.at (detId_pot).Inverse () * localVector;
90+ return localVector;
91+ }
92+
8293 // Constants
8394 // / Number of seconds per lumisection: used to compute hit rates in Hz
8495 static constexpr double SEC_PER_LUMI_SECTION = 23.31 ;
@@ -229,6 +240,9 @@ class CTPPSDiamondDQMSource : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<
229240 double global, withPixels;
230241 };
231242 std::unordered_map<CTPPSDetId, DiamondShifts> diamShifts_;
243+ std::unordered_map<CTPPSDetId, double > diamHalfWidths_;
244+ std::unordered_map<CTPPSDetId, ROOT::Math::Rotation3D> diamRotations_;
245+ std::unordered_map<CTPPSDetId, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double >>> diamTranslations_;
232246 std::vector<std::pair<edm::EventRange, int >> runParameters_;
233247 int centralOOT_;
234248 unsigned int verbosity_;
@@ -290,7 +304,7 @@ CTPPSDiamondDQMSource::PotPlots::PotPlots(DQMStore::IBooker& ibooker,
290304 LeadingOnlyCounter(0 ),
291305 TrailingOnlyCounter(0 ),
292306 CompleteCounter(0 ),
293- pixelTracksMap(" Pixel track maps for efficiency" , " Pixel track maps for efficiency" , 25 , 0 , 25 , 16 , -8 , 8 ) {
307+ pixelTracksMap(" Pixel track maps for efficiency" , " Pixel track maps for efficiency" , 25 , 0 , 25 , 24 , -6 , 18 ) {
294308 std::string path, title;
295309 CTPPSDiamondDetId (id).rpName (path, CTPPSDiamondDetId::nPath);
296310 ibooker.setCurrentFolder (path);
@@ -495,9 +509,9 @@ CTPPSDiamondDQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, unsign
495509 25 ,
496510 0 ,
497511 25 ,
498- 16 ,
499- -8 ,
500- 8 ) {
512+ 24 ,
513+ -6 ,
514+ 18 ) {
501515 std::string path, title;
502516 CTPPSDiamondDetId (id).planeName (path, CTPPSDiamondDetId::nPath);
503517 ibooker.setCurrentFolder (path);
@@ -540,7 +554,7 @@ CTPPSDiamondDQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker, unsign
540554 -8 ,
541555 8 );
542556 EfficiencyWRTPixelsInPlane =
543- ibooker.book2D (" Efficiency wrt pixels" , title + " Efficiency wrt pixels;x (mm);y (mm)" , 25 , 0 , 25 , 16 , -8 , 8 );
557+ ibooker.book2D (" Efficiency wrt pixels" , title + " Efficiency wrt pixels;x (mm);y (mm)" , 25 , 0 , 25 , 24 , -6 , 18 );
544558}
545559
546560// ----------------------------------------------------------------------------------------------------
@@ -661,6 +675,10 @@ void CTPPSDiamondDQMSource::dqmBeginRun(const edm::Run& iRun, const edm::EventSe
661675 const CTPPSDiamondDetId diam_id (it->first );
662676 const auto diam = geom.sensor (it->first );
663677 diamShifts_[diam_id].global = diam->translation ().x () - diam->getDiamondDimensions ().xHalfWidth ;
678+ diamRotations_[diam_id] = diam->rotation ();
679+ diamTranslations_[diam_id] = diam->translation ();
680+ diamHalfWidths_[diam_id] = diam->getDiamondDimensions ().xHalfWidth ;
681+
664682 if (iRun.run () > FIRST_RUN_W_PIXELS) { // pixel installed
665683 const CTPPSPixelDetId pixid (diam_id.arm (), CTPPS_PIXEL_STATION_ID, CTPPS_PIXEL_FAR_RP_ID);
666684 auto pix = geom.sensor (pixid);
@@ -934,7 +952,6 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
934952 auto lumiCache = luminosityBlockCache (event.getLuminosityBlock ().index ());
935953 for (const auto & rechits : *diamondRecHits) {
936954 const CTPPSDiamondDetId detId (rechits.detId ()), detId_pot (detId.rpId ());
937- const auto & x_shift = diamShifts_.at (detId_pot);
938955
939956 for (const auto & rechit : rechits) {
940957 planes_inclusive[detId_pot].insert (detId.plane ());
@@ -947,6 +964,9 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
947964 continue ;
948965
949966 potPlots_[detId_pot].recHitTime ->Fill (rechit.time ());
967+ // coordinates of the rechit in the local coordinate system are needed for the rotated pot
968+ auto localRecHit = transformToLocalCoordinates (detId_pot, rechit.x (), rechit.y (), rechit.z ());
969+ auto localRecHitLeftX = localRecHit.x () + diamHalfWidths_.at (detId_pot) - 0.5 * rechit.xWidth ();
950970
951971 float UFSDShift = 0.0 ;
952972 if (rechit.yWidth () < 3 )
@@ -955,15 +975,15 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
955975 if (rechit.toT () != 0 && centralOOT_ != -999 && rechit.ootIndex () == centralOOT_) {
956976 TH2F* hitHistoTmp = potPlots_[detId_pot].hitDistribution2d ->getTH2F ();
957977 TAxis* hitHistoTmpYAxis = hitHistoTmp->GetYaxis ();
958- int startBin = hitHistoTmpYAxis->FindBin (rechit. x () - x_shift. global - 0.5 * rechit. xWidth () );
978+ int startBin = hitHistoTmpYAxis->FindBin (localRecHitLeftX );
959979 int numOfBins = rechit.xWidth () * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
960980 for (int i = 0 ; i < numOfBins; ++i)
961981 hitHistoTmp->Fill (detId.plane () + UFSDShift, hitHistoTmpYAxis->GetBinCenter (startBin + i));
962982
963983 if (!perLSsaving_ && plotOnline_) {
964984 hitHistoTmp = lumiCache->hitDistribution2dMap [detId_pot].get ();
965985 hitHistoTmpYAxis = hitHistoTmp->GetYaxis ();
966- startBin = hitHistoTmpYAxis->FindBin (rechit. x () - x_shift. global - 0.5 * rechit. xWidth () );
986+ startBin = hitHistoTmpYAxis->FindBin (localRecHitLeftX );
967987 numOfBins = rechit.xWidth () * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
968988 for (int i = 0 ; i < numOfBins; ++i)
969989 hitHistoTmp->Fill (detId.plane () + UFSDShift, hitHistoTmpYAxis->GetBinCenter (startBin + i));
@@ -977,7 +997,7 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
977997
978998 TH2F* hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT ->getTH2F ();
979999 TAxis* hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis ();
980- int startBin = hitHistoOOTTmpYAxis->FindBin (rechit. x () - x_shift. global - 0.5 * rechit. xWidth () );
1000+ int startBin = hitHistoOOTTmpYAxis->FindBin (localRecHitLeftX );
9811001 int numOfBins = rechit.xWidth () * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
9821002 for (int i = 0 ; i < numOfBins; ++i)
9831003 hitHistoOOTTmp->Fill (detId.plane () + 1 . / windowsNum_ * rechit.ootIndex (),
@@ -987,7 +1007,7 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
9871007 // Only leading
9881008 TH2F* hitHistoOOTTmp = potPlots_[detId_pot].hitDistribution2dOOT_le ->getTH2F ();
9891009 TAxis* hitHistoOOTTmpYAxis = hitHistoOOTTmp->GetYaxis ();
990- int startBin = hitHistoOOTTmpYAxis->FindBin (rechit. x () - x_shift. global - 0.5 * rechit. xWidth () );
1010+ int startBin = hitHistoOOTTmpYAxis->FindBin (localRecHitLeftX );
9911011 int numOfBins = rechit.xWidth () * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
9921012 for (int i = 0 ; i < numOfBins; ++i)
9931013 hitHistoOOTTmp->Fill (detId.plane () + 1 . / windowsNum_ * rechit.ootIndex (),
@@ -996,9 +1016,6 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
9961016 if (rechit.ootIndex () != CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING &&
9971017 potPlots_[detId_pot].activity_per_bx .count (rechit.ootIndex ()) > 0 )
9981018 potPlots_[detId_pot].activity_per_bx .at (rechit.ootIndex ())->Fill (event.bunchCrossing ());
999-
1000- // if(plotOffline_)
1001- // potPlots_[detId_pot].TOTVsLS->Fill(event.luminosityBlock(),rechit.toT());
10021019 }
10031020 }
10041021
@@ -1012,6 +1029,8 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
10121029 for (const auto & tracks : *diamondLocalTracks) {
10131030 const CTPPSDiamondDetId detId (tracks.detId ()), detId_pot (detId.rpId ());
10141031 const auto & x_shift = diamShifts_.at (detId_pot);
1032+ // extract the rotation angle for the diamond pot
1033+ auto cosRotAngle = diamRotations_.at (detId_pot) * CTPPSGeometry::Vector (1 , 0 , 0 );
10151034
10161035 for (const auto & track : tracks) {
10171036 if (!track.isValid ())
@@ -1032,7 +1051,13 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
10321051
10331052 if (centralOOT_ != -999 && track.ootIndex () == centralOOT_) {
10341053 TH1F* trackHistoInTimeTmp = potPlots_[detId_pot].trackDistribution ->getTH1F ();
1035- int startBin = trackHistoInTimeTmp->FindBin (track.x0 () - x_shift.global - track.x0Sigma ());
1054+
1055+ // X coordinate of the left edge of the track in the local coordinate system
1056+ auto localTrackX =
1057+ (track.x0 () - diamTranslations_.at (detId_pot).x () + diamHalfWidths_.at (detId_pot) - track.x0Sigma ()) /
1058+ cosRotAngle.x ();
1059+
1060+ int startBin = trackHistoInTimeTmp->FindBin ((localTrackX));
10361061 int numOfBins = 2 * track.x0Sigma () * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
10371062 for (int i = 0 ; i < numOfBins; ++i)
10381063 trackHistoInTimeTmp->Fill (trackHistoInTimeTmp->GetBinCenter (startBin + i));
@@ -1195,7 +1220,9 @@ void CTPPSDiamondDQMSource::analyze(const edm::Event& event, const edm::EventSet
11951220 if (planePlots_.count (detId_plane) != 0 ) {
11961221 if (centralOOT_ != -999 && rechit.ootIndex () == centralOOT_) {
11971222 TH1F* hitHistoTmp = planePlots_[detId_plane].hitProfile ->getTH1F ();
1198- int startBin = hitHistoTmp->FindBin (rechit.x () - diamShifts_.at (detId_pot).global - 0.5 * rechit.xWidth ());
1223+ // coordinates of the rechit in the local coordinate system are needed for the rotated pot
1224+ auto localRecHit = transformToLocalCoordinates (detId_pot, rechit.x (), rechit.y (), rechit.z ());
1225+ int startBin = hitHistoTmp->FindBin (localRecHit.x () + diamHalfWidths_.at (detId_pot) - 0.5 * rechit.xWidth ());
11991226 int numOfBins = rechit.xWidth () * INV_DISPLAY_RESOLUTION_FOR_HITS_MM;
12001227 for (int i = 0 ; i < numOfBins; ++i)
12011228 hitHistoTmp->Fill (hitHistoTmp->GetBinCenter (startBin + i));
0 commit comments