Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:20

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1TwinMuxAlgortithm
0004 //
0005 //   L1TwinMuxAlgortithm
0006 //
0007 //
0008 //   Author :
0009 //   G. Flouris               U Ioannina    Feb. 2015
0010 //   modifications: G Karathanasis
0011 //--------------------------------------------------
0012 
0013 #include <iostream>
0014 #include <iomanip>
0015 #include <iterator>
0016 
0017 #include "L1Trigger/L1TTwinMux/interface/L1TTwinMuxAlgorithm.h"
0018 #include "Geometry/RPCGeometry/interface/RPCRoll.h"
0019 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
0020 #include "CondFormats/DataRecord/interface/RPCEMapRcd.h"
0021 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0022 #include "L1Trigger/L1TTwinMux/interface/AlignTrackSegments.h"
0023 #include "L1Trigger/L1TTwinMux/interface/RPCtoDTTranslator.h"
0024 #include "L1Trigger/L1TTwinMux/interface/DTRPCBxCorrection.h"
0025 #include "L1Trigger/L1TTwinMux/interface/DTLowQMatching.h"
0026 #include "L1Trigger/L1TTwinMux/interface/RPCHitCleaner.h"
0027 #include "L1Trigger/L1TTwinMux/interface/IOPrinter.h"
0028 #include "L1Trigger/L1TTwinMux/interface/L1MuTMChambPhContainer.h"
0029 
0030 using namespace std;
0031 
0032 void L1TTwinMuxAlgorithm::run(edm::Handle<L1MuDTChambPhContainer> inphiDigis,
0033                               edm::Handle<L1MuDTChambThContainer> thetaDigis,
0034                               edm::Handle<RPCDigiCollection> rpcDigis,
0035                               const L1TTwinMuxParams& tmParams,
0036                               const RPCGeometry& rpcGeometry) {
0037   ///ES Parameters
0038   bool onlyRPC = tmParams.get_UseOnlyRPC();
0039   bool onlyDT = tmParams.get_UseOnlyDT();
0040   bool useLowQDT = tmParams.get_UseLowQDT();
0041   bool correctBX = tmParams.get_CorrectDTBxwRPC();
0042   bool verbose = tmParams.get_Verbose();
0043 
0044   ///Align track segments that are coming in bx-1.
0045   AlignTrackSegments alignedDTs{*inphiDigis};
0046   alignedDTs.run();
0047   L1MuDTChambPhContainer const& phiDigis = alignedDTs.getDTContainer();
0048   //if only DTs are required without bx correction
0049   //return the aligned track segments
0050   if (onlyDT && !correctBX && !useLowQDT) {
0051     m_tm_phi_output = phiDigis;
0052     return;
0053   }
0054   ///Clean RPC hits
0055   RPCHitCleaner rpcHitCl{*rpcDigis};
0056   rpcHitCl.run();
0057   RPCDigiCollection const& rpcDigisCleaned = rpcHitCl.getRPCCollection();
0058 
0059   ///Translate RPC digis to DT primitives.
0060   RPCtoDTTranslator dt_from_rpc{rpcDigisCleaned};
0061   dt_from_rpc.run(rpcGeometry);
0062   L1MuDTChambPhContainer const& rpcPhiDigis =
0063       dt_from_rpc.getDTContainer();  //Primitves used for RPC->DT (only station 1 and 2)
0064   L1MuDTChambPhContainer const& rpcHitsPhiDigis =
0065       dt_from_rpc.getDTRPCHitsContainer();  //Primitves used for bx correction
0066 
0067   ///Match low q DT primitives with RPC hits in dphiWindow
0068   DTLowQMatching dtlowq{&phiDigis, rpcHitsPhiDigis};
0069   dtlowq.run(tmParams);
0070 
0071   if (onlyDT && !correctBX && useLowQDT) {
0072     m_tm_phi_output = phiDigis;
0073     if (verbose) {
0074       IOPrinter ioPrinter;
0075       cout << "======DT========" << endl;
0076       ioPrinter.run(inphiDigis, m_tm_phi_output, rpcDigis, rpcGeometry);
0077       cout << "======RPC========" << endl;
0078       ioPrinter.run(&rpcHitsPhiDigis, m_tm_phi_output, &rpcDigisCleaned, rpcGeometry);
0079       cout << "+++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
0080     }
0081 
0082     return;
0083   }
0084 
0085   ///Correct(in bx) DT primitives by comparing them to RPC.
0086   //  DTRPCBxCorrection *rpc_dt_bx = new DTRPCBxCorrection(phiDigis,rpcHitsPhiDigis);
0087   DTRPCBxCorrection rpc_dt_bx{phiDigis, rpcHitsPhiDigis};
0088   rpc_dt_bx.run(tmParams);
0089 
0090   L1MuDTChambPhContainer const& phiDigiscp = rpc_dt_bx.getDTContainer();
0091 
0092   ///Add RPC primitives in case that there are no DT primitives.
0093   std::vector<L1MuDTChambPhDigi> l1ttma_out;
0094 
0095   int bx = 0, wheel = 0, sector = 0, station = 1;
0096 
0097   for (bx = -3; bx <= 3; bx++) {
0098     for (wheel = -2; wheel <= 2; wheel++) {
0099       for (sector = 0; sector < 12; sector++) {
0100         for (station = 1; station <= 4; station++) {
0101           L1MuDTChambPhDigi const* dtts1 = phiDigiscp.chPhiSegm1(wheel, station, sector, bx);
0102           L1MuDTChambPhDigi const* dtts2 = phiDigiscp.chPhiSegm2(wheel, station, sector, bx);
0103           L1MuDTChambPhDigi const* rpcts1 = rpcPhiDigis.chPhiSegm1(wheel, station, sector, bx);
0104 
0105           if (!onlyRPC) {
0106             if (!dtts1 && !dtts2 && !rpcts1)
0107               continue;
0108             if (dtts1 && dtts1->code() != 7) {
0109               l1ttma_out.push_back(*dtts1);
0110             }
0111             if (dtts2 && dtts2->code() != 7) {
0112               l1ttma_out.push_back(*dtts2);
0113             }
0114             if (!onlyDT) {
0115               if (!dtts1 && !dtts2 && rpcts1 && station <= 2) {
0116                 l1ttma_out.emplace_back(rpcts1->bxNum(),
0117                                         rpcts1->whNum(),
0118                                         rpcts1->scNum(),
0119                                         rpcts1->stNum(),
0120                                         rpcts1->phi(),
0121                                         rpcts1->phiB(),
0122                                         rpcts1->code(),
0123                                         rpcts1->Ts2Tag(),
0124                                         rpcts1->BxCnt(),
0125                                         2);
0126               }
0127             }
0128           }
0129 
0130           else if (onlyRPC) {
0131             if (rpcts1 && station <= 2) {
0132               l1ttma_out.emplace_back(rpcts1->bxNum(),
0133                                       rpcts1->whNum(),
0134                                       rpcts1->scNum(),
0135                                       rpcts1->stNum(),
0136                                       rpcts1->phi(),
0137                                       rpcts1->phiB(),
0138                                       rpcts1->code(),
0139                                       rpcts1->Ts2Tag(),
0140                                       rpcts1->BxCnt(),
0141                                       2);
0142             }
0143           }
0144         }
0145       }
0146     }
0147   }
0148 
0149   m_tm_phi_output.setContainer(l1ttma_out);
0150 
0151   if (verbose) {
0152     IOPrinter ioPrinter;
0153     cout << "======DT========" << endl;
0154     ioPrinter.run(inphiDigis, m_tm_phi_output, rpcDigis, rpcGeometry);
0155     cout << "======RPC========" << endl;
0156     ioPrinter.run(&rpcHitsPhiDigis, m_tm_phi_output, &rpcDigisCleaned, rpcGeometry);
0157     cout << "+++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
0158   }
0159 }