Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:21

0001 #include <cmath>
0002 #include "L1Trigger/L1TNtuples/interface/L1AnalysisDTTF.h"
0003 #include <cmath>
0004 
0005 L1Analysis::L1AnalysisDTTF::L1AnalysisDTTF() {}
0006 
0007 L1Analysis::L1AnalysisDTTF::~L1AnalysisDTTF() {}
0008 
0009 void L1Analysis::L1AnalysisDTTF::SetDTPH(const edm::Handle<L1MuDTChambPhContainer> L1MuDTChambPhContainer,
0010                                          unsigned int maxDTPH) {
0011   const L1MuDTChambPhContainer::Phi_Container *PhContainer = L1MuDTChambPhContainer->getContainer();
0012 
0013   dttf_.phSize = PhContainer->size();
0014   int iphtr = 0;
0015   double pig = acos(-1);
0016   for (L1MuDTChambPhContainer::Phi_Container::const_iterator DTPhDigiItr = PhContainer->begin();
0017        DTPhDigiItr != PhContainer->end();
0018        ++DTPhDigiItr) {
0019     if ((unsigned int)iphtr > maxDTPH - 1)
0020       continue;
0021     dttf_.phBx.push_back(DTPhDigiItr->bxNum() - DTPhDigiItr->Ts2Tag() + 1);
0022     dttf_.phWh.push_back(DTPhDigiItr->whNum());
0023     dttf_.phSe.push_back(DTPhDigiItr->scNum());
0024     dttf_.phSt.push_back(DTPhDigiItr->stNum());
0025     dttf_.phAng.push_back(DTPhDigiItr->phi());
0026     dttf_.phBandAng.push_back(DTPhDigiItr->phiB());
0027     double locphi = (((double)DTPhDigiItr->phi()) / 4096.0);
0028     double newphi = locphi + (DTPhDigiItr->scNum() * (pig / 6.));
0029     if (newphi > 2 * pig)
0030       newphi -= 2 * pig;
0031     if (newphi < 0)
0032       newphi += 2 * pig;
0033     dttf_.phGlobPhi.push_back(newphi);
0034     dttf_.phCode.push_back(DTPhDigiItr->code());
0035     dttf_.phX.push_back(DTPhDigiItr->scNum());
0036     dttf_.phY.push_back(DTPhDigiItr->stNum() + 4 * (DTPhDigiItr->whNum() + 2));
0037 
0038     iphtr++;
0039   }
0040 }
0041 
0042 void L1Analysis::L1AnalysisDTTF::SetDTTH(const edm::Handle<L1MuDTChambThContainer> L1MuDTChambThContainer,
0043                                          unsigned int maxDTTH) {
0044   const L1MuDTChambThContainer::The_Container *ThContainer = L1MuDTChambThContainer->getContainer();
0045 
0046   int ithtr = 0;
0047   dttf_.thSize = ThContainer->size();
0048   dttf_.thTheta.ResizeTo(dttf_.thSize, 7);
0049   dttf_.thCode.ResizeTo(dttf_.thSize, 7);
0050 
0051   for (L1MuDTChambThContainer::The_Container::const_iterator DTThDigiItr = ThContainer->begin();
0052        DTThDigiItr != ThContainer->end();
0053        ++DTThDigiItr) {
0054     if ((unsigned int)ithtr > maxDTTH - 1)
0055       continue;
0056     dttf_.thBx.push_back(DTThDigiItr->bxNum() + 1);
0057     dttf_.thWh.push_back(DTThDigiItr->whNum());
0058     dttf_.thSe.push_back(DTThDigiItr->scNum());
0059     dttf_.thSt.push_back(DTThDigiItr->stNum());
0060     dttf_.thX.push_back(DTThDigiItr->stNum() + 4 * (DTThDigiItr->whNum() + 2));
0061     //    int xpos = iwh*4+ist+1; ????
0062     dttf_.thY.push_back(DTThDigiItr->scNum());
0063     //!
0064 
0065     for (unsigned int j = 0; j < 7; j++) {
0066       dttf_.thTheta[ithtr][j] = DTThDigiItr->position(j);
0067       dttf_.thCode[ithtr][j] = DTThDigiItr->code(j);
0068     }
0069 
0070     ithtr++;
0071   }
0072 }
0073 
0074 void L1Analysis::L1AnalysisDTTF::SetDTTR(const edm::Handle<L1MuDTTrackContainer> L1MuDTTrackContainer,
0075                                          unsigned int maxDTTR) {
0076   double pig = acos(-1);
0077   const L1MuDTTrackContainer::TrackContainer *tr = L1MuDTTrackContainer->getContainer();
0078   int idttr = 0;
0079   dttf_.trSize = tr->size();
0080   for (L1MuDTTrackContainer::TrackContainer::const_iterator i = tr->begin(); i != tr->end(); ++i) {
0081     if ((unsigned int)idttr > maxDTTR - 1)
0082       continue;
0083     dttf_.trBx.push_back(i->bx() + 1);
0084     dttf_.trTag.push_back(i->TrkTag());
0085     dttf_.trQual.push_back(i->quality_packed());
0086     dttf_.trPtPck.push_back(i->pt_packed());
0087     dttf_.trPtVal.push_back(i->ptValue());
0088     dttf_.trPhiPck.push_back(i->phi_packed());
0089     dttf_.trPhiVal.push_back(i->phiValue());
0090     dttf_.trEtaPck.push_back(i->eta_packed());
0091     dttf_.trEtaVal.push_back(i->etaValue());
0092 
0093     int phi_local = i->phi_packed();  //range: 0 < phi_local < 31
0094     if (phi_local > 15)
0095       phi_local -= 32;  //range: -16 < phi_local < 15
0096     double phi_global =
0097         (phi_local * (pig / 72.)) + ((pig / 6.) * i->scNum());  // + 12*i->scNum(); //range: -16 < phi_global < 147
0098     if (phi_global < 0)
0099       phi_global += 2 * pig;  //range: 0 < phi_global < 147
0100     if (phi_global > 2 * pig)
0101       phi_global -= 2 * pig;  //range: 0 < phi_global < 143
0102     dttf_.trPhiGlob.push_back(phi_global);
0103     dttf_.trChPck.push_back(i->charge_packed());
0104     dttf_.trWh.push_back(i->whNum());
0105     dttf_.trSc.push_back(i->scNum());
0106     unsigned int addresses = 0;
0107     for (int KK = 0; KK < 4; KK++) {
0108       addresses |= ((unsigned int)(i->stNum(KK + 1)) << (KK * 4));
0109     }
0110     dttf_.trAddress.push_back(addresses);
0111     idttr++;
0112   }
0113 }