Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:10

0001 // Class Header
0002 #include "MuonSeedParaFillHisto.h"
0003 
0004 #include "TFile.h"
0005 #include "TVector3.h"
0006 
0007 #include <iostream>
0008 #include <fstream>
0009 #include <map>
0010 #include <utility>
0011 #include <string>
0012 #include <stdio.h>
0013 #include <algorithm>
0014 
0015 //DEFINE_FWK_MODULE(MuonSeedParaFillHisto);
0016 using namespace std;
0017 using namespace edm;
0018 
0019 // constructors
0020 MuonSeedParaFillHisto::MuonSeedParaFillHisto() {}
0021 
0022 // destructor
0023 MuonSeedParaFillHisto::~MuonSeedParaFillHisto() {}
0024 
0025 void MuonSeedParaFillHisto::FillCSCSegmentPair(
0026     H2DRecHit2* histo2, double pt1[5], double chi2_dof1[5], double dPhiP1[2][5][5], double EtaP1[2][5]) {
0027   double ptIn = (pt1[1] != 0.) ? pt1[1] : pt1[2];
0028   if (ptIn == 0)
0029     ptIn = pt1[0];
0030 
0031   // fill the information for CSC pT parameterization from segment pair
0032   if (dPhiP1[1][0][1] != 99.0 && chi2_dof1[0] < 2000.0 && chi2_dof1[1] < 2000.0) {
0033     histo2->Fill5_0(dPhiP1[0][0][1],
0034                     dPhiP1[1][0][1],
0035                     ptIn * dPhiP1[0][0][1],
0036                     ptIn * dPhiP1[1][0][1],
0037                     fabs(EtaP1[0][0]),
0038                     fabs(EtaP1[1][0]));
0039   }
0040   if (dPhiP1[1][0][2] != 99.0 && chi2_dof1[0] < 2000.0 && chi2_dof1[2] < 2000.0) {
0041     histo2->Fill5_1(dPhiP1[0][0][2],
0042                     dPhiP1[1][0][2],
0043                     ptIn * dPhiP1[0][0][2],
0044                     ptIn * dPhiP1[1][0][2],
0045                     fabs(EtaP1[0][0]),
0046                     fabs(EtaP1[1][0]));
0047   }
0048   if (dPhiP1[1][0][3] != 99.0 && chi2_dof1[0] < 2000.0 && chi2_dof1[3] < 2000.0) {
0049     histo2->Fill5_2(dPhiP1[0][0][3],
0050                     dPhiP1[1][0][3],
0051                     ptIn * dPhiP1[0][0][3],
0052                     ptIn * dPhiP1[1][0][3],
0053                     fabs(EtaP1[0][0]),
0054                     fabs(EtaP1[1][0]));
0055   }
0056   if (dPhiP1[1][0][4] != 99.0 && chi2_dof1[0] < 2000.0 && chi2_dof1[4] < 2000.0) {
0057     histo2->Fill5_3(dPhiP1[0][0][4],
0058                     dPhiP1[1][0][4],
0059                     ptIn * dPhiP1[0][0][4],
0060                     ptIn * dPhiP1[1][0][4],
0061                     fabs(EtaP1[0][0]),
0062                     fabs(EtaP1[1][0]));
0063   }
0064   if (dPhiP1[1][1][2] != 99.0 && chi2_dof1[1] < 2000.0 && chi2_dof1[2] < 2000.0) {
0065     histo2->Fill5_1(dPhiP1[0][1][2],
0066                     dPhiP1[1][1][2],
0067                     ptIn * dPhiP1[0][1][2],
0068                     ptIn * dPhiP1[1][1][2],
0069                     fabs(EtaP1[0][1]),
0070                     fabs(EtaP1[1][1]));
0071   }
0072   if (dPhiP1[1][1][3] != 99.0 && chi2_dof1[1] < 2000.0 && chi2_dof1[3] < 2000.0) {
0073     histo2->Fill5_2(dPhiP1[0][1][3],
0074                     dPhiP1[1][1][3],
0075                     ptIn * dPhiP1[0][1][3],
0076                     ptIn * dPhiP1[1][1][3],
0077                     fabs(EtaP1[0][1]),
0078                     fabs(EtaP1[1][1]));
0079   }
0080   if (dPhiP1[1][1][4] != 99.0 && chi2_dof1[1] < 2000.0 && chi2_dof1[4] < 2000.0) {
0081     histo2->Fill5_3(dPhiP1[0][1][4],
0082                     dPhiP1[1][1][4],
0083                     ptIn * dPhiP1[0][1][4],
0084                     ptIn * dPhiP1[1][1][4],
0085                     fabs(EtaP1[0][1]),
0086                     fabs(EtaP1[1][1]));
0087   }
0088   if (dPhiP1[1][2][3] != 99.0 && chi2_dof1[2] < 2000.0 && chi2_dof1[3] < 2000.0) {
0089     histo2->Fill5_4(dPhiP1[0][2][3],
0090                     dPhiP1[1][2][3],
0091                     ptIn * dPhiP1[0][2][3],
0092                     ptIn * dPhiP1[1][2][3],
0093                     fabs(EtaP1[0][2]),
0094                     fabs(EtaP1[1][2]));
0095   }
0096   if (dPhiP1[1][2][4] != 99.0 && chi2_dof1[2] < 2000.0 && chi2_dof1[4] < 2000.0) {
0097     histo2->Fill5_5(dPhiP1[0][2][4],
0098                     dPhiP1[1][2][4],
0099                     ptIn * dPhiP1[0][2][4],
0100                     ptIn * dPhiP1[1][2][4],
0101                     fabs(EtaP1[0][2]),
0102                     fabs(EtaP1[1][2]));
0103   }
0104   if (dPhiP1[1][3][4] != 99.0 && chi2_dof1[3] < 2000.0 && chi2_dof1[4] < 2000.0) {
0105     histo2->Fill5_6(dPhiP1[0][3][4],
0106                     dPhiP1[1][3][4],
0107                     ptIn * dPhiP1[0][3][4],
0108                     ptIn * dPhiP1[1][3][4],
0109                     fabs(EtaP1[0][3]),
0110                     fabs(EtaP1[1][3]));
0111   }
0112 }
0113 
0114 void MuonSeedParaFillHisto::FillDTSegmentPair(
0115     H2DRecHit3* histo3, double pt1[5], double chi2_dof3[5], double dPhiP3[2][5][5], double EtaP3[2][5]) {
0116   double ptIn = (pt1[1] != 0.) ? pt1[1] : pt1[2];
0117   if (ptIn == 0)
0118     ptIn = pt1[0];
0119 
0120   /// For DT
0121   //  fill the information for DT pT parameterization from segment pair
0122   if (dPhiP3[1][1][2] != 99.0 && chi2_dof3[1] < 2000.0 && chi2_dof3[2] < 2000.0) {
0123     histo3->Fill6_1(dPhiP3[0][1][2],
0124                     dPhiP3[1][1][2],
0125                     ptIn * dPhiP3[0][1][2],
0126                     ptIn * dPhiP3[1][1][2],
0127                     fabs(EtaP3[0][1]),
0128                     fabs(EtaP3[1][1]));
0129   }
0130   if (dPhiP3[1][1][3] != 99.0 && chi2_dof3[1] < 2000.0 && chi2_dof3[3] < 2000.0) {
0131     histo3->Fill6_2(dPhiP3[0][1][3],
0132                     dPhiP3[1][1][3],
0133                     ptIn * dPhiP3[0][1][3],
0134                     ptIn * dPhiP3[1][1][3],
0135                     fabs(EtaP3[0][1]),
0136                     fabs(EtaP3[1][1]));
0137   }
0138   if (dPhiP3[1][1][4] != 99.0 && chi2_dof3[1] < 2000.0 && chi2_dof3[4] < 2000.0) {
0139     histo3->Fill6_3(dPhiP3[0][1][4],
0140                     dPhiP3[1][1][4],
0141                     ptIn * dPhiP3[0][1][4],
0142                     ptIn * dPhiP3[1][1][4],
0143                     fabs(EtaP3[0][1]),
0144                     fabs(EtaP3[1][1]));
0145   }
0146   if (dPhiP3[1][2][3] != 99.0 && chi2_dof3[2] < 2000.0 && chi2_dof3[3] < 2000.0) {
0147     histo3->Fill6_4(dPhiP3[0][2][3],
0148                     dPhiP3[1][2][3],
0149                     ptIn * dPhiP3[0][2][3],
0150                     ptIn * dPhiP3[1][2][3],
0151                     fabs(EtaP3[0][2]),
0152                     fabs(EtaP3[1][2]));
0153   }
0154   if (dPhiP3[1][2][4] != 99.0 && chi2_dof3[2] < 2000.0 && chi2_dof3[4] < 2000.0) {
0155     histo3->Fill6_5(dPhiP3[0][2][4],
0156                     dPhiP3[1][2][4],
0157                     ptIn * dPhiP3[0][2][4],
0158                     ptIn * dPhiP3[1][2][4],
0159                     fabs(EtaP3[0][2]),
0160                     fabs(EtaP3[1][2]));
0161   }
0162   if (dPhiP3[1][3][4] != 99.0 && chi2_dof3[3] < 2000.0 && chi2_dof3[4] < 2000.0) {
0163     histo3->Fill6_6(dPhiP3[0][3][4],
0164                     dPhiP3[1][3][4],
0165                     ptIn * dPhiP3[0][3][4],
0166                     ptIn * dPhiP3[1][3][4],
0167                     fabs(EtaP3[0][3]),
0168                     fabs(EtaP3[1][3]));
0169   }
0170 }
0171 
0172 void MuonSeedParaFillHisto::FillCSCSegmentPairByChamber(H2DRecHit4* hME1[15],
0173                                                         double pt1[5],
0174                                                         double dPhiP1[2][5][5],
0175                                                         double EtaP1[2][5],
0176                                                         bool MEPath[2][5][4],
0177                                                         double dEtaP1[2][5][5]) {
0178   H2DRecHit4* histo4 = 0;
0179   //  Look at different Bxdl btw. stations & rings
0180   /// All possible segment pairs in CSC
0181   ///                 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14
0182   int csc1[2][15] = {{1, 1, 12, 12, 13, 1, 1, 12, 13, 1, 21, 21, 22, 21, 31},
0183                      {12, 21, 21, 22, 22, 31, 32, 32, 32, 41, 31, 32, 32, 41, 41}};
0184 
0185   double ptIn = (pt1[1] != 0.) ? pt1[1] : pt1[2];
0186   if (ptIn == 0)
0187     ptIn = pt1[0];
0188 
0189   for (int l = 0; l < 15; l++) {
0190     int s1 = csc1[0][l] / 10;  // 0 0 1 1 1 0 0 1 1 0 2 2 2 2 3
0191     int r1 = csc1[0][l] % 10;  // 1 1 2 2 3 1 1 2 3 1 1 1 2 1 1
0192     int s2 = csc1[1][l] / 10;
0193     int r2 = csc1[1][l] % 10;
0194     if (MEPath[1][s1][r1] && MEPath[1][s2][r2] && MEPath[0][s1][r1] && MEPath[0][s2][r2] && ptIn > 0.) {
0195       double ME_Resol = dPhiP1[0][s1][s2] - dPhiP1[1][s1][s2];
0196       histo4 = hME1[l];
0197       histo4->Fill8((ptIn * dPhiP1[0][s1][s2]), dPhiP1[0][s1][s2], dEtaP1[0][s1][s2], fabs(EtaP1[0][s2]), ptIn);
0198       histo4->Fill8a(
0199           (ptIn * dPhiP1[1][s1][s2]), dPhiP1[1][s1][s2], dEtaP1[1][s1][s2], fabs(EtaP1[1][s2]), ptIn, ME_Resol);
0200     }
0201   }
0202 }
0203 
0204 void MuonSeedParaFillHisto::FillDTSegmentPairByChamber(H2DRecHit5* hMB1[26],
0205                                                        double pt1[5],
0206                                                        double dPhiP3[2][5][5],
0207                                                        double EtaP3[2][5],
0208                                                        bool MBPath[2][5][3],
0209                                                        double dEtaP3[2][5][5]) {
0210   H2DRecHit5* histo5 = 0;
0211   //  Look at different Bxdl btw. stations & rings
0212   /// All possible segment pair in DT
0213   ///               0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
0214   int dt1[2][26] = {
0215       {10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 20, 20, 20, 21, 21, 21, 21, 22, 22, 30, 31, 31, 32},
0216       {20, 30, 31, 40, 41, 21, 22, 31, 32, 41, 42, 22, 32, 30, 40, 41, 31, 32, 41, 42, 32, 42, 40, 41, 42, 42}};
0217   for (int l = 0; l < 26; l++) {
0218     int s1 = dt1[0][l] / 10;
0219     int w1 = dt1[0][l] % 10;
0220     int s2 = dt1[1][l] / 10;
0221     int w2 = dt1[1][l] % 10;
0222 
0223     double ptIn = (pt1[1] != 0.) ? pt1[1] : pt1[2];
0224     if (ptIn == 0)
0225       ptIn = pt1[0];
0226 
0227     if (MBPath[1][s1][w1] && MBPath[1][s2][w2] && MBPath[0][s1][w1] && MBPath[0][s2][w2] && ptIn > 0.) {
0228       double MB_Resol = dPhiP3[0][s1][s2] - dPhiP3[1][s1][s2];
0229       if (s2 != 4) {
0230         histo5 = hMB1[l];
0231         histo5->Fill9((ptIn * dPhiP3[0][s1][s2]), dPhiP3[0][s1][s2], dEtaP3[0][s1][s2], fabs(EtaP3[0][s2]), ptIn);
0232         histo5->Fill9a(
0233             (ptIn * dPhiP3[1][s1][s2]), dPhiP3[1][s1][s2], dEtaP3[1][s1][s2], fabs(EtaP3[1][s2]), ptIn, MB_Resol);
0234       }
0235       if (s2 == 4) {
0236         histo5 = hMB1[l];
0237         histo5->Fill9((ptIn * dPhiP3[0][s1][s2]), dPhiP3[0][s1][s2], dEtaP3[0][s1][s2], fabs(EtaP3[0][s1]), ptIn);
0238         histo5->Fill9a(
0239             (ptIn * dPhiP3[1][s1][s2]), dPhiP3[1][s1][s2], dEtaP3[1][s1][s2], fabs(EtaP3[1][s1]), ptIn, MB_Resol);
0240       }
0241     }
0242   }
0243 }
0244 
0245 void MuonSeedParaFillHisto::FillOLSegmentPairByChamber(H2DRecHit10* hOL1[6],
0246                                                        double pt1[5],
0247                                                        double dPhiP2[2][5][5],
0248                                                        double EtaP3[2][5],
0249                                                        bool MBPath[2][5][3],
0250                                                        bool MEPath[2][5][4],
0251                                                        double dEtaP2[2][5][5]) {
0252   //H2DRecHit10 *histo10;
0253   //  Look at different Bxdl in overlap region
0254   /// All possible segment pairs in overlap region
0255   ///              0  1  2  3  4  5
0256   int olp[2][6] = {{12, 12, 12, 22, 22, 32}, {13, 22, 32, 13, 22, 13}};
0257   for (int l = 0; l < 6; l++) {
0258     int s1 = olp[0][l] / 10;
0259     int w1 = olp[0][l] % 10;
0260     int s2 = olp[1][l] / 10;
0261     int w2 = olp[1][l] % 10;
0262     if (MBPath[1][s1][w1] && MEPath[1][s2][w2]) {
0263       double OL_Resol = dPhiP2[s1][s2] - dPhiP2[s1][s2];
0264       //histo10 = hOL1[l];
0265       hOL1[l]->Fill12((pt1[1] * dPhiP2[0][s1][s2]), dPhiP2[0][s1][s2], dEtaP2[0][s1][s2], fabs(EtaP3[0][s1]), pt1[1]);
0266       hOL1[l]->Fill12a(
0267           (pt1[1] * dPhiP2[1][s1][s2]), dPhiP2[1][s1][s2], dEtaP2[1][s1][s2], fabs(EtaP3[1][s1]), pt1[1], OL_Resol);
0268     }
0269   }
0270 }
0271 
0272 void MuonSeedParaFillHisto::FillCSCSegmentSingle(
0273     H2DRecHit6* hME2[8], double pt1[5], double ME_phi[2][5][4], double ME_eta[2][5][4], bool MEPath[2][5][4]) {
0274   // Fill  the 1 segment case for CSC and DT
0275   int csc2[8] = {1, 12, 13, 21, 22, 31, 32, 41};
0276   for (int l = 0; l < 8; l++) {
0277     int s1 = csc2[l] / 10;
0278     int r1 = csc2[l] % 10;
0279     if (MEPath[1][s1][r1] && MEPath[0][s1][r1]) {
0280       double dME_phi = ME_phi[1][s1][r1] - ME_phi[0][s1][r1];
0281       double dME_eta = ME_eta[1][s1][r1] - ME_eta[0][s1][r1];
0282       hME2[l]->Fill8b((pt1[0] * ME_phi[0][s1][r1]), ME_phi[0][s1][r1], ME_eta[0][s1][r1], pt1[0]);
0283       hME2[l]->Fill8c((pt1[0] * ME_phi[1][s1][r1]), ME_phi[1][s1][r1], dME_phi, dME_eta, ME_eta[1][s1][r1], pt1[0]);
0284     }
0285   }
0286 }
0287 
0288 void MuonSeedParaFillHisto::FillDTSegmentSingle(
0289     H2DRecHit7* hMB2[12], double pt1[5], double MB_phi[2][5][3], double MB_eta[2][5][3], bool MBPath[2][5][3]) {
0290   int dt2[12] = {10, 11, 12, 20, 21, 22, 30, 31, 32, 40, 41, 42};
0291   for (int l = 0; l < 12; l++) {
0292     int s1 = dt2[l] / 10;
0293     int w1 = dt2[l] % 10;
0294     if (MBPath[1][s1][w1] && MBPath[0][s1][w1]) {
0295       double dMB_phi = MB_phi[1][s1][w1] - MB_phi[0][s1][w1];
0296       double dMB_eta = MB_eta[1][s1][w1] - MB_eta[0][s1][w1];
0297       hMB2[l]->Fill9b((pt1[0] * MB_phi[0][s1][w1]), MB_phi[0][s1][w1], MB_eta[0][s1][w1], pt1[0]);
0298       hMB2[l]->Fill9c((pt1[0] * MB_phi[1][s1][w1]), MB_phi[1][s1][w1], dMB_phi, dMB_eta, MB_eta[1][s1][w1], pt1[0]);
0299     }
0300   }
0301 }
0302 /// For reco-segment treea
0303 /*
0304   tt = tr_muon;
0305   if ( MEPath[1][1] && MEPath[1][2] && MEPath[1][3] ) {
0306       tt->Fill_b1(fabs(EtaP1[1][1]),fabs(EtaP1[1][2]),fabs(EtaP1[1][3]),fabs(EtaP1[1][4]), 
0307                   EtaP1[1][1], EtaP1[1][2], EtaP1[1][3], EtaP1[1][4], pt1[0]);
0308       tt->Fill_l1(pa[0]);
0309   }
0310   if ( MBPath[1][1] && MBPath[1][2] && MBPath[1][3] ) {
0311       tt->Fill_b2(fabs(EtaP3[1][1]),fabs(EtaP3[1][2]),fabs(EtaP3[1][3]),fabs(EtaP3[1][4]), 
0312                   EtaP3[1][1], EtaP3[1][2], EtaP3[1][3], EtaP3[1][4], pt1[0]);
0313       tt->Fill_l1(pa[0]);
0314   }
0315   tt->FillTree();
0316   */