Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:36

0001 #include "Adjuster.h"
0002 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0003 #include "DataFormats/TrackerRecHit2D/interface/FastTrackerRecHit.h"
0004 
0005 namespace edm {
0006   namespace detail {
0007     void doTheOffset(
0008         int bunchSpace, int bcr, std::vector<SimTrack>& simtracks, unsigned int evtNr, int vertexOffset, bool wrap) {
0009       EncodedEventId id(bcr, evtNr);
0010       for (auto& item : simtracks) {
0011         item.setEventId(id);
0012         if (!item.noVertex()) {
0013           item.setVertexIndex(item.vertIndex() + vertexOffset);
0014         }
0015       }
0016     }
0017 
0018     void doTheOffset(
0019         int bunchSpace, int bcr, std::vector<SimVertex>& simvertices, unsigned int evtNr, int vertexOffset, bool wrap) {
0020       int timeOffset = bcr * bunchSpace;
0021       EncodedEventId id(bcr, evtNr);
0022       for (auto& item : simvertices) {
0023         item.setEventId(id);
0024         item.setTof(item.position().t() + timeOffset);
0025       }
0026     }
0027 
0028     void doTheOffset(
0029         int bunchSpace, int bcr, std::vector<PSimHit>& simhits, unsigned int evtNr, int vertexOffset, bool wrap) {
0030       int timeOffset = bcr * bunchSpace;
0031       EncodedEventId id(bcr, evtNr);
0032       if (wrap) {  // wrap time for long-lived hits into one beam crossing
0033         for (auto& item : simhits) {
0034           item.setEventId(id);
0035 
0036           float Tfloor = floor(item.timeOfFlight());
0037           float digits = item.timeOfFlight() - Tfloor;
0038           int remainder = int(Tfloor) % bunchSpace;
0039           item.setTof(float(remainder) + digits + timeOffset);
0040         }
0041       } else {
0042         for (auto& item : simhits) {
0043           item.setEventId(id);
0044           item.setTof(item.timeOfFlight() + timeOffset);
0045         }
0046       }
0047     }
0048 
0049     void doTheOffset(
0050         int bunchSpace, int bcr, std::vector<PCaloHit>& calohits, unsigned int evtNr, int vertexOffset, bool wrap) {
0051       int timeOffset = bcr * bunchSpace;
0052       EncodedEventId id(bcr, evtNr);
0053       for (auto& item : calohits) {
0054         item.setEventId(id);
0055         item.setTime(item.time() + timeOffset);
0056       }
0057     }
0058 
0059     void doTheOffset(int bunchSpace,
0060                      int bcr,
0061                      TrackingRecHitCollection& trackingrechits,
0062                      unsigned int evtNr,
0063                      int vertexOffset,
0064                      bool wrap) {
0065       EncodedEventId id(bcr, evtNr);
0066       for (auto it = trackingrechits.begin(); it != trackingrechits.end(); ++it) {
0067         if (trackerHitRTTI::isFast(*it)) {
0068           FastTrackerRecHit* rechit = static_cast<FastTrackerRecHit*>(&(*it));
0069           rechit->setEventId(id.rawId());
0070         }
0071       }
0072     }
0073 
0074   }  // end namespace detail
0075 }  // end namespace edm