Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-08 03:36:29

0001 #include "RecoMET/METProducers/interface/CSCHaloDataProducer.h"
0002 #include "FWCore/Common/interface/TriggerNames.h"
0003 #include "FWCore/Framework/interface/ConsumesCollector.h"
0004 
0005 /*
0006   [class]:  CSCHaloDataProducer
0007   [authors]: R. Remington, The University of Florida
0008   [description]: See CSCHaloDataProducer.h
0009   [date]: October 15, 2009
0010 */
0011 
0012 using namespace edm;
0013 using namespace std;
0014 using namespace reco;
0015 
0016 CSCHaloDataProducer::CSCHaloDataProducer(const edm::ParameterSet& iConfig) : CSCAlgo(consumesCollector()) {
0017   //Digi Level
0018   IT_L1MuGMTReadout = iConfig.getParameter<edm::InputTag>("L1MuGMTReadoutLabel");
0019 
0020   //HLT Level
0021   IT_HLTResult = iConfig.getParameter<edm::InputTag>("HLTResultLabel");
0022   CSCAlgo.vIT_HLTBit = iConfig.getParameter<std::vector<edm::InputTag> >("HLTBitLabel");
0023 
0024   //RecHit Level
0025   IT_CSCRecHit = iConfig.getParameter<edm::InputTag>("CSCRecHitLabel");
0026 
0027   //Calo RecHit
0028   IT_HBHErh = iConfig.getParameter<edm::InputTag>("HBHErhLabel");
0029   IT_ECALBrh = iConfig.getParameter<edm::InputTag>("ECALBrhLabel");
0030   IT_ECALErh = iConfig.getParameter<edm::InputTag>("ECALErhLabel");
0031   //Higher Level Reco
0032   IT_CSCSegment = iConfig.getParameter<edm::InputTag>("CSCSegmentLabel");
0033   IT_CosmicMuon = iConfig.getParameter<edm::InputTag>("CosmicMuonLabel");
0034   IT_Muon = iConfig.getParameter<edm::InputTag>("MuonLabel");
0035   IT_SA = iConfig.getParameter<edm::InputTag>("SALabel");
0036   IT_ALCT = iConfig.getParameter<edm::InputTag>("ALCTDigiLabel");
0037 
0038   //Muon to Segment Matching
0039   edm::ParameterSet matchParameters = iConfig.getParameter<edm::ParameterSet>("MatchParameters");
0040   edm::ConsumesCollector iC = consumesCollector();
0041   TheMatcher = new MuonSegmentMatcher(matchParameters, iC);
0042 
0043   // Cosmic track selection parameters
0044   CSCAlgo.SetDetaThreshold((float)iConfig.getParameter<double>("DetaParam"));
0045   CSCAlgo.SetDphiThreshold((float)iConfig.getParameter<double>("DphiParam"));
0046   CSCAlgo.SetMinMaxInnerRadius((float)iConfig.getParameter<double>("InnerRMinParam"),
0047                                (float)iConfig.getParameter<double>("InnerRMaxParam"));
0048   CSCAlgo.SetMinMaxOuterRadius((float)iConfig.getParameter<double>("OuterRMinParam"),
0049                                (float)iConfig.getParameter<double>("OuterRMaxParam"));
0050   CSCAlgo.SetNormChi2Threshold((float)iConfig.getParameter<double>("NormChi2Param"));
0051 
0052   // MLR
0053   CSCAlgo.SetMaxSegmentRDiff((float)iConfig.getParameter<double>("MaxSegmentRDiff"));
0054   CSCAlgo.SetMaxSegmentPhiDiff((float)iConfig.getParameter<double>("MaxSegmentPhiDiff"));
0055   CSCAlgo.SetMaxSegmentTheta((float)iConfig.getParameter<double>("MaxSegmentTheta"));
0056   // End MLR
0057 
0058   CSCAlgo.SetMaxDtMuonSegment((float)iConfig.getParameter<double>("MaxDtMuonSegment"));
0059   CSCAlgo.SetMaxFreeInverseBeta((float)iConfig.getParameter<double>("MaxFreeInverseBeta"));
0060   CSCAlgo.SetExpectedBX((short int)iConfig.getParameter<int>("ExpectedBX"));
0061   CSCAlgo.SetRecHitTime0((float)iConfig.getParameter<double>("RecHitTime0"));
0062   CSCAlgo.SetRecHitTimeWindow((float)iConfig.getParameter<double>("RecHitTimeWindow"));
0063   CSCAlgo.SetMinMaxOuterMomentumTheta((float)iConfig.getParameter<double>("MinOuterMomentumTheta"),
0064                                       (float)iConfig.getParameter<double>("MaxOuterMomentumTheta"));
0065   CSCAlgo.SetMatchingDPhiThreshold((float)iConfig.getParameter<double>("MatchingDPhiThreshold"));
0066   CSCAlgo.SetMatchingDEtaThreshold((float)iConfig.getParameter<double>("MatchingDEtaThreshold"));
0067   CSCAlgo.SetMatchingDWireThreshold(iConfig.getParameter<int>("MatchingDWireThreshold"));
0068 
0069   cscGeometry_token = esConsumes<CSCGeometry, MuonGeometryRecord>();
0070   cosmicmuon_token_ = consumes<reco::MuonCollection>(IT_CosmicMuon);
0071   csctimemap_token_ = consumes<reco::MuonTimeExtraMap>(edm::InputTag(IT_CosmicMuon.label(), "csc"));
0072   muon_token_ = consumes<reco::MuonCollection>(IT_Muon);
0073   cscsegment_token_ = consumes<CSCSegmentCollection>(IT_CSCSegment);
0074   cscrechit_token_ = consumes<CSCRecHit2DCollection>(IT_CSCRecHit);
0075   cscalct_token_ = consumes<CSCALCTDigiCollection>(IT_ALCT);
0076   l1mugmtro_token_ = consumes<L1MuGMTReadoutCollection>(IT_L1MuGMTReadout);
0077   hbhereco_token_ = consumes<HBHERecHitCollection>(IT_HBHErh);
0078   EcalRecHitsEB_token_ = consumes<EcalRecHitCollection>(IT_ECALBrh);
0079   EcalRecHitsEE_token_ = consumes<EcalRecHitCollection>(IT_ECALErh);
0080   hltresult_token_ = consumes<edm::TriggerResults>(IT_HLTResult);
0081 
0082   produces<CSCHaloData>();
0083 }
0084 
0085 void CSCHaloDataProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0086   edm::ParameterSetDescription desc;
0087 
0088   //Digi Level
0089   desc.add<edm::InputTag>("L1MuGMTReadoutLabel", edm::InputTag("gtDigis"));
0090 
0091   // HLT
0092   desc.add<edm::InputTag>("HLTResultLabel", edm::InputTag("TriggerResults::HLT"));
0093   desc.add<std::vector<edm::InputTag> >("HLTBitLabel",
0094                                         {edm::InputTag("HLT_CSCBeamHalo"),
0095                                          edm::InputTag("HLT_CSCBeamHaloOverlapRing1"),
0096                                          edm::InputTag("HLT_CSCBeamHaloOverlapRing2"),
0097                                          edm::InputTag("HLT_CSCBeamHaloRing2or3")});
0098 
0099   // RecHit Level
0100   desc.add<edm::InputTag>("CSCRecHitLabel", edm::InputTag("csc2DRecHits"));
0101   desc.add<edm::InputTag>("HBHErhLabel", edm::InputTag("hbhereco"));
0102   desc.add<edm::InputTag>("ECALBrhLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
0103   desc.add<edm::InputTag>("ECALErhLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
0104 
0105   //Higher Level Reco
0106   desc.add<edm::InputTag>("CSCSegmentLabel", edm::InputTag("cscSegments"));
0107   desc.add<edm::InputTag>("CosmicMuonLabel", edm::InputTag("muonsFromCosmics"));
0108   desc.add<edm::InputTag>("MuonLabel", edm::InputTag("muons"));
0109   desc.add<edm::InputTag>("SALabel", edm::InputTag("standAloneMuons"));
0110   desc.add<edm::InputTag>("ALCTDigiLabel", edm::InputTag("muonCSCDigis", "MuonCSCALCTDigi"))
0111       ->setComment("Chamber Level Trigger Primitive");
0112 
0113   {
0114     // Muon-Segment matching
0115     edm::ParameterSetDescription matchParametersPSet;
0116     MuonSegmentMatcher::fillPSetDescription(matchParametersPSet);
0117     desc.add<edm::ParameterSetDescription>("MatchParameters", matchParametersPSet);
0118   }
0119 
0120   desc.add<double>("DetaParam", 0.1);
0121   desc.add<double>("DphiParam", 1.00);
0122   desc.add<double>("InnerRMinParam", 0.);
0123   desc.add<double>("InnerRMaxParam", 99999.);
0124   desc.add<double>("OuterRMinParam", 0.);
0125   desc.add<double>("OuterRMaxParam", 99999.);
0126   desc.add<double>("NormChi2Param", 8.);
0127 
0128   // MLR
0129   // Default values for identifying CSCSegments that are halo-like
0130   desc.add<double>("MaxSegmentRDiff", 10.0);
0131   desc.add<double>("MaxSegmentPhiDiff", 0.1);
0132   desc.add<double>("MaxSegmentTheta", 0.7);
0133   // end MLR
0134 
0135   desc.add<double>("MaxDtMuonSegment", -10.0)
0136       ->setComment("if this is halo we expect ( T_outer_segment - T_inner_segment) to be less than MaxDtMuonSegment");
0137   desc.add<double>("MaxFreeInverseBeta", 0.0)
0138       ->setComment("if this is halo we expect free inverse beta to be less than MaxFreeInverseBeta");
0139   desc.add<int>("ExpectedBX", 6)->setComment("if this is Data, the expected collision bx will be 3 instead of 6");
0140 
0141   // The expected time of a collision recHit will be t = time_0 + time-of-flight
0142   // A recHit more than +/- time_window from collision timing will be declared "out-of-time"
0143   // recHit times are in [ns]
0144   desc.add<double>("RecHitTime0", 0.)->setComment("rechit time in ns");
0145   desc.add<double>("RecHitTimeWindow", 25.)->setComment("rechit time in ns");
0146   desc.add<double>("MinOuterMomentumTheta", .10);
0147   desc.add<double>("MaxOuterMomentumTheta", 3.0);
0148   desc.add<double>("MatchingDPhiThreshold", 0.18);
0149   desc.add<double>("MatchingDEtaThreshold", 0.4);
0150   desc.add<int>("MatchingDWireThreshold", 5);
0151   descriptions.addWithDefaultLabel(desc);
0152 }
0153 
0154 void CSCHaloDataProducer::produce(Event& iEvent, const EventSetup& iSetup) {
0155   //Get CSC Geometry
0156   edm::ESHandle<CSCGeometry> TheCSCGeometry = iSetup.getHandle(cscGeometry_token);
0157 
0158   //Get Muons Collection from Cosmic Reconstruction
0159   edm::Handle<reco::MuonCollection> TheCosmics;
0160   //  iEvent.getByLabel(IT_CosmicMuon, TheCosmics);
0161   iEvent.getByToken(cosmicmuon_token_, TheCosmics);
0162 
0163   //Get Muon Time Information from Cosmic Reconstruction
0164   edm::Handle<reco::MuonTimeExtraMap> TheCSCTimeMap;
0165   //  iEvent.getByLabel(IT_CosmicMuon.label(),"csc",TheCSCTimeMap);
0166   iEvent.getByToken(csctimemap_token_, TheCSCTimeMap);
0167 
0168   //Collision Muon Collection
0169   edm::Handle<reco::MuonCollection> TheMuons;
0170   //  iEvent.getByLabel(IT_Muon, TheMuons);
0171   iEvent.getByToken(muon_token_, TheMuons);
0172 
0173   //Get CSC Segments
0174   edm::Handle<CSCSegmentCollection> TheCSCSegments;
0175   //  iEvent.getByLabel(IT_CSCSegment, TheCSCSegments);
0176   iEvent.getByToken(cscsegment_token_, TheCSCSegments);
0177 
0178   //Get CSC RecHits
0179   Handle<CSCRecHit2DCollection> TheCSCRecHits;
0180   //  iEvent.getByLabel(IT_CSCRecHit, TheCSCRecHits);
0181   iEvent.getByToken(cscrechit_token_, TheCSCRecHits);
0182 
0183   //Get L1MuGMT
0184   edm::Handle<L1MuGMTReadoutCollection> TheL1GMTReadout;
0185   //  iEvent.getByLabel (IT_L1MuGMTReadout, TheL1GMTReadout);
0186   iEvent.getByToken(l1mugmtro_token_, TheL1GMTReadout);
0187 
0188   //Get Chamber Anode Trigger Information
0189   edm::Handle<CSCALCTDigiCollection> TheALCTs;
0190   //  iEvent.getByLabel (IT_ALCT, TheALCTs);
0191   iEvent.getByToken(cscalct_token_, TheALCTs);
0192 
0193   //Calo rec hits
0194   Handle<HBHERecHitCollection> hbhehits;
0195   iEvent.getByToken(hbhereco_token_, hbhehits);
0196   Handle<EcalRecHitCollection> ecalebhits;
0197   iEvent.getByToken(EcalRecHitsEB_token_, ecalebhits);
0198   Handle<EcalRecHitCollection> ecaleehits;
0199   iEvent.getByToken(EcalRecHitsEE_token_, ecaleehits);
0200 
0201   //Get HLT Results
0202   edm::Handle<edm::TriggerResults> TheHLTResults;
0203   //  iEvent.getByLabel( IT_HLTResult , TheHLTResults);
0204   iEvent.getByToken(hltresult_token_, TheHLTResults);
0205 
0206   const edm::TriggerNames* triggerNames = nullptr;
0207   if (TheHLTResults.isValid()) {
0208     triggerNames = &iEvent.triggerNames(*TheHLTResults);
0209   }
0210 
0211   // Put it in the event
0212   iEvent.put(std::make_unique<CSCHaloData>(CSCAlgo.Calculate(*TheCSCGeometry,
0213                                                              TheCosmics,
0214                                                              TheCSCTimeMap,
0215                                                              TheMuons,
0216                                                              TheCSCSegments,
0217                                                              TheCSCRecHits,
0218                                                              TheL1GMTReadout,
0219                                                              hbhehits,
0220                                                              ecalebhits,
0221                                                              ecaleehits,
0222                                                              TheHLTResults,
0223                                                              triggerNames,
0224                                                              TheALCTs,
0225                                                              TheMatcher,
0226                                                              iEvent,
0227                                                              iSetup)));
0228   return;
0229 }