** Warning **

Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle dbname=lxr at /lxr/lib/LXR/Common.pm line 1103.

Last-Modified: Tue, 26 Sep 2022 03:55:57 GMT Content-Type: text/html; charset=utf-8 /CMSSW_12_6_X_2022-09-25-2300/RecoPPS/Local/src/CTPPSDiamondRecHitProducerAlgorithm.cc
Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-23 02:49:34

0001 /****************************************************************************
0002 *
0003 * This is a part of PPS offline software.
0004 * Authors:
0005 *   Laurent Forthomme (laurent.forthomme@cern.ch)
0006 *
0007 ****************************************************************************/
0008 
0009 #include "FWCore/Utilities/interface/isFinite.h"
0010 
0011 #include "RecoPPS/Local/interface/CTPPSDiamondRecHitProducerAlgorithm.h"
0012 #include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
0013 
0014 //----------------------------------------------------------------------------------------------------
0015 
0016 void CTPPSDiamondRecHitProducerAlgorithm::build(const CTPPSGeometry& geom,
0017                                                 const edm::DetSetVector<CTPPSDiamondDigi>& input,
0018                                                 edm::DetSetVector<CTPPSDiamondRecHit>& output) {
0019   for (const auto& vec : input) {
0020     const CTPPSDiamondDetId detid(vec.detId());
0021 
0022     if (detid.channel() > MAX_CHANNEL)  // VFAT-like information, to be ignored
0023       continue;
0024 
0025     // retrieve the geometry element associated to this DetID
0026     const DetGeomDesc* det = geom.sensor(detid);
0027 
0028     const float x_pos = det->translation().x(), y_pos = det->translation().y();
0029     float z_pos = 0.;
0030     z_pos = det->parentZPosition();  // retrieve the plane position;
0031 
0032     // parameters stand for half the size
0033     const auto& diamondDimensions = det->getDiamondDimensions();
0034     const float x_width = 2.0 * diamondDimensions.xHalfWidth;
0035     const float y_width = 2.0 * diamondDimensions.yHalfWidth;
0036     const float z_width = 2.0 * diamondDimensions.zHalfWidth;
0037 
0038     const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel();
0039     //LUT calibration
0040     std::vector<double> lut;
0041     if (apply_calib_)
0042       lut = calibLUT_->bins(sector, station, plane, channel);
0043     if (lut.size() != 1024)
0044       lut = std::vector<double>(1024, 0.0);
0045 
0046     // retrieve the timing calibration part for this channel
0047     const auto& ch_params =
0048         (apply_calib_) ? calib_->parameters(sector, station, plane, channel) : std::vector<double>{};
0049     // default values for offset + time precision if calibration object not found
0050     const double ch_t_offset = (apply_calib_) ? calib_->timeOffset(sector, station, plane, channel) : 0.;
0051     const double ch_t_precis = (apply_calib_) ? calib_->timePrecision(sector, station, plane, channel) : 0.;
0052 
0053     edm::DetSet<CTPPSDiamondRecHit>& rec_hits = output.find_or_insert(detid);
0054 
0055     for (const auto& digi : vec) {
0056       const int t_lead = digi.leadingEdge(), t_trail = digi.trailingEdge();
0057       // skip invalid digis
0058       if (t_lead == 0 && t_trail == 0)
0059         continue;
0060 
0061       double tot = -1., ch_t_twc = 0.;
0062       if (t_lead != 0 && t_trail != 0) {
0063         tot = (t_trail - t_lead) * ts_to_ns_;  // in ns
0064         if (calib_fct_ && apply_calib_ && !ch_params.empty()) {
0065           // compute the time-walk correction
0066           ch_t_twc = calib_fct_->evaluate(std::vector<double>{tot}, ch_params);
0067           if (edm::isNotFinite(ch_t_twc))
0068             ch_t_twc = 0.;
0069         }
0070       }
0071 
0072       const int time_slice =
0073           (t_lead != 0) ? (t_lead - ch_t_offset / ts_to_ns_) / 1024 : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING;
0074 
0075       // calibrated time of arrival
0076       const double t0 = (t_lead % 1024) * ts_to_ns_ + lut[t_lead % 1024] - ch_t_twc;
0077       rec_hits.emplace_back(
0078           // spatial information
0079           x_pos,
0080           x_width,
0081           y_pos,
0082           y_width,
0083           z_pos,
0084           z_width,
0085           // timing information
0086           t0,
0087           tot,
0088           ch_t_precis,
0089           time_slice,
0090           // readout information
0091           digi.hptdcErrorFlags(),
0092           digi.multipleHit());
0093     }
0094   }
0095 }