Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:09:43

0001 // <author>Cristovao Beirao da Cruz e Silva</author>
0002 // <email>cbeiraod@cern.ch</email>
0003 // <created>2017-10-26</created>
0004 // <description>
0005 // HLT filter module to select events with tracks in the CTPPS detector
0006 // </description>
0007 
0008 // system include files
0009 
0010 // user include files
0011 #include "HLTCTPPSLocalTrackFilter.h"
0012 
0013 #include "DataFormats/Common/interface/Ref.h"
0014 #include "DataFormats/Common/interface/Handle.h"
0015 
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 
0018 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0019 
0020 #include "DataFormats/Common/interface/DetSet.h"
0021 #include "DataFormats/Common/interface/DetSetVector.h"
0022 
0023 #include "DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h"
0024 #include "DataFormats/CTPPSDetId/interface/TotemRPDetId.h"
0025 #include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
0026 
0027 //
0028 // fill discriptions
0029 //
0030 void HLTCTPPSLocalTrackFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0031   edm::ParameterSetDescription desc;
0032 
0033   desc.add<edm::InputTag>("pixelLocalTrackInputTag", edm::InputTag("ctppsPixelLocalTracks"))
0034       ->setComment("input tag of the pixel local track collection");
0035   desc.add<edm::InputTag>("stripLocalTrackInputTag", edm::InputTag("totemRPLocalTrackFitter"))
0036       ->setComment("input tag of the strip local track collection");
0037   desc.add<edm::InputTag>("diamondLocalTrackInputTag", edm::InputTag("ctppsDiamondLocalTracks"))
0038       ->setComment("input tag of the diamond local track collection");
0039 
0040   desc.add<bool>("usePixel", true)->setComment("whether to consider the pixel detectors");
0041   desc.add<bool>("useStrip", false)->setComment("whether to consider the strip detectors");
0042   desc.add<bool>("useDiamond", false)->setComment("whether to consider the diamond detectors");
0043 
0044   desc.add<int>("minTracks", 2)->setComment("minimum number of tracks");
0045   desc.add<int>("minTracksPerArm", 1)->setComment("minimum number of tracks per arm of the CTPPS detector");
0046 
0047   desc.add<int>("maxTracks", -1)->setComment("maximum number of tracks, if smaller than minTracks it will be ignored");
0048   desc.add<int>("maxTracksPerArm", -1)
0049       ->setComment(
0050           "maximum number of tracks per arm of the CTPPS detector, if smaller than minTrackPerArm it will be ignored");
0051   desc.add<int>("maxTracksPerPot", -1)
0052       ->setComment("maximum number of tracks per roman pot of the CTPPS detector, if negative it will be ignored");
0053 
0054   desc.add<int>("triggerType", trigger::TriggerTrack);
0055 
0056   descriptions.add("hltCTPPSLocalTrackFilter", desc);
0057   return;
0058 }
0059 
0060 //
0061 // destructor and constructor
0062 //
0063 HLTCTPPSLocalTrackFilter::~HLTCTPPSLocalTrackFilter() = default;
0064 
0065 HLTCTPPSLocalTrackFilter::HLTCTPPSLocalTrackFilter(const edm::ParameterSet& iConfig)
0066     : pixelLocalTrackInputTag_(iConfig.getParameter<edm::InputTag>("pixelLocalTrackInputTag")),
0067       stripLocalTrackInputTag_(iConfig.getParameter<edm::InputTag>("stripLocalTrackInputTag")),
0068       diamondLocalTrackInputTag_(iConfig.getParameter<edm::InputTag>("diamondLocalTrackInputTag")),
0069       usePixel_(iConfig.getParameter<bool>("usePixel")),
0070       useStrip_(iConfig.getParameter<bool>("useStrip")),
0071       useDiamond_(iConfig.getParameter<bool>("useDiamond")),
0072       minTracks_(iConfig.getParameter<int>("minTracks")),
0073       minTracksPerArm_(iConfig.getParameter<int>("minTracksPerArm")),
0074       maxTracks_(iConfig.getParameter<int>("maxTracks")),
0075       maxTracksPerArm_(iConfig.getParameter<int>("maxTracksPerArm")),
0076       maxTracksPerPot_(iConfig.getParameter<int>("maxTracksPerPot")) {
0077   if (usePixel_)
0078     pixelLocalTrackToken_ = consumes<edm::DetSetVector<CTPPSPixelLocalTrack>>(pixelLocalTrackInputTag_);
0079   if (useStrip_)
0080     stripLocalTrackToken_ = consumes<edm::DetSetVector<TotemRPLocalTrack>>(stripLocalTrackInputTag_);
0081   if (useDiamond_)
0082     diamondLocalTrackToken_ = consumes<edm::DetSetVector<CTPPSDiamondLocalTrack>>(diamondLocalTrackInputTag_);
0083 
0084   LogDebug("") << "HLTCTPPSLocalTrackFilter: "
0085                   "pixelTag/stripTag/diamondTag/usePixel/useStrip/useDiamond/minTracks/minTracksPerArm/maxTracks/"
0086                   "maxTracksPerArm/maxTracksPerPot : "
0087                << pixelLocalTrackInputTag_.encode() << " " << stripLocalTrackInputTag_.encode() << " "
0088                << diamondLocalTrackInputTag_.encode() << " " << usePixel_ << " " << useStrip_ << " " << useDiamond_
0089                << " " << minTracks_ << " " << minTracksPerArm_ << " " << maxTracks_ << " " << maxTracksPerArm_ << " "
0090                << maxTracksPerPot_;
0091 }
0092 
0093 //
0094 // member functions
0095 //
0096 bool HLTCTPPSLocalTrackFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0097   int arm45Tracks = 0;
0098   int arm56Tracks = 0;
0099   std::map<uint32_t, int> tracksPerPot;
0100 
0101   //   Note that there is no matching between the tracks from the several roman pots
0102   // so tracks from separate pots might correspond to the same particle.
0103   // When the pixels are used in more than one RP (in 2018), then the same situation can
0104   // happen within the pixels themselves.
0105   if (usePixel_)  // Pixels correspond to RP 220 in 2017 data
0106   {
0107     edm::Handle<edm::DetSetVector<CTPPSPixelLocalTrack>> pixelTracks;
0108     iEvent.getByToken(pixelLocalTrackToken_, pixelTracks);
0109 
0110     for (const auto& rpv : (*pixelTracks)) {
0111       const CTPPSPixelDetId id(rpv.id);
0112       if (tracksPerPot.count(rpv.id) == 0)
0113         tracksPerPot[rpv.id] = 0;
0114 
0115       for (auto& track : rpv) {
0116         if (track.isValid()) {
0117           if (id.arm() == 0)
0118             ++arm45Tracks;
0119           if (id.arm() == 1)
0120             ++arm56Tracks;
0121           ++tracksPerPot[rpv.id];
0122         }
0123       }
0124     }
0125   }
0126 
0127   if (useStrip_)  // Strips correspond to RP 210 in 2017 data
0128   {
0129     edm::Handle<edm::DetSetVector<TotemRPLocalTrack>> stripTracks;
0130     iEvent.getByToken(stripLocalTrackToken_, stripTracks);
0131 
0132     for (const auto& rpv : (*stripTracks)) {
0133       const TotemRPDetId id(rpv.id);
0134       if (tracksPerPot.count(rpv.id) == 0)
0135         tracksPerPot[rpv.id] = 0;
0136 
0137       for (auto& track : rpv) {
0138         if (track.isValid()) {
0139           if (id.arm() == 0)
0140             ++arm45Tracks;
0141           if (id.arm() == 1)
0142             ++arm56Tracks;
0143           ++tracksPerPot[rpv.id];
0144         }
0145       }
0146     }
0147   }
0148 
0149   if (useDiamond_) {
0150     edm::Handle<edm::DetSetVector<CTPPSDiamondLocalTrack>> diamondTracks;
0151     iEvent.getByToken(diamondLocalTrackToken_, diamondTracks);
0152 
0153     for (const auto& rpv : (*diamondTracks)) {
0154       const CTPPSDiamondDetId id(rpv.id);
0155       if (tracksPerPot.count(rpv.id) == 0)
0156         tracksPerPot[rpv.id] = 0;
0157 
0158       for (auto& track : rpv) {
0159         if (track.isValid()) {
0160           if (id.arm() == 0)
0161             ++arm45Tracks;
0162           if (id.arm() == 1)
0163             ++arm56Tracks;
0164           ++tracksPerPot[rpv.id];
0165         }
0166       }
0167     }
0168   }
0169 
0170   if (arm45Tracks + arm56Tracks < minTracks_ || arm45Tracks < minTracksPerArm_ || arm56Tracks < minTracksPerArm_)
0171     return false;
0172 
0173   if (maxTracks_ >= minTracks_ && arm45Tracks + arm56Tracks > maxTracks_)
0174     return false;
0175 
0176   if (maxTracksPerArm_ >= minTracksPerArm_ && (arm45Tracks > maxTracksPerArm_ || arm56Tracks > maxTracksPerArm_))
0177     return false;
0178 
0179   if (maxTracksPerPot_ >= 0) {
0180     for (auto& pot : tracksPerPot) {
0181       if (pot.second > maxTracksPerPot_) {
0182         return false;
0183       }
0184     }
0185   }
0186 
0187   return true;
0188 }
0189 
0190 // define as a framework module
0191 #include "FWCore/Framework/interface/MakerMacros.h"
0192 DEFINE_FWK_MODULE(HLTCTPPSLocalTrackFilter);