Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:48

0001 #include "L1Trigger/CSCTrackFinder/test/src/Track.h"
0002 #include <iostream>
0003 using namespace std;
0004 namespace csctf_analysis
0005 {
0006 Track::Track()
0007 {
0008       matched = false;
0009       matchedIndex = -1;
0010       R = 20;
0011       ghost = false;
0012       TFPt=-1;
0013       Quality=-1;
0014       ghostMatchedToIndex = new std::vector<unsigned int>;
0015       ghostR = new std::vector<double>;
0016       ghostQ = new std::vector<double>;
0017 }
0018 Track::Track(const Track& track)
0019 {
0020       ghostMatchedToIndex = new std::vector<unsigned int>;
0021       ghostR = new std::vector<double>;
0022       ghostQ = new std::vector<double>;
0023       *ghostMatchedToIndex= *track.ghostMatchedToIndex;
0024       *ghostR = *track.ghostR;
0025       *ghostQ = *track.ghostQ;
0026       matched=track.matched;
0027       matchedIndex=track.matchedIndex;
0028       R=track.R;
0029       histlist=track.histlist;
0030       ghost=track.ghost;
0031       Quality=track.Quality;
0032       TFPt=track.TFPt;
0033 }
0034 Track::~Track() 
0035 {
0036       delete ghostMatchedToIndex;
0037       delete ghostR;
0038       delete ghostQ;
0039 }
0040 void Track::matchedTo(int i, double newR)
0041 {
0042       if(matched==false || newR<R)
0043       {
0044               matched=true;
0045               R=newR;
0046               matchedIndex=i;
0047       }
0048 }
0049 void Track::unMatch()
0050 {
0051       matched = false;
0052       matchedIndex = -1;
0053       R = 20;
0054       TFPt=-1;
0055       Quality=-1;
0056 }
0057 void Track::loseBestGhostCand(std::string param)
0058 {
0059       int loseindex=0;
0060       int size=ghostMatchedToIndex->size();
0061       if(param == 'Q')        
0062       {
0063               for(int i=0;i<size;i++)
0064               {
0065                   if (ghostQ->at(i)< ghostQ->at(loseindex))
0066                   {       
0067                       loseindex=i;
0068                   }
0069               }
0070       }
0071       else if(param == 'R')   
0072       {
0073               for(int i=0;i<size;i++)
0074               {
0075                   if(ghostR->at(i)>ghostR->at(loseindex))
0076                   {
0077                       loseindex=i;
0078                   }
0079               }
0080       }
0081       else
0082       {
0083               std::cout <<"\nChoose Q or R for ghost Candidate parameter!!!\n";
0084       }
0085       ghostMatchedToIndex->erase(ghostMatchedToIndex->begin()+loseindex);
0086       ghostQ->erase(ghostQ->begin()+loseindex);
0087       ghostR->erase(ghostR->begin()+loseindex);
0088 }
0089 void Track::fillSimvTFHist(const Track& simtrack, const Track& tftrack) const
0090 {
0091       double simfabsEta=fabs(simtrack.getEta());
0092       double simpt=simtrack.getPt();
0093       double tfpt=tftrack.getPt();        
0094       if(simfabsEta>=0.9) 
0095       {
0096               histlist->SimPt_vs_TFPt_FWD->Fill(simpt,tfpt);
0097       }
0098       if(simfabsEta<=0.9) 
0099       {
0100               histlist->SimPt_vs_TFPt_DT->Fill(simpt,tfpt);
0101       }
0102 }
0103 void Track::fillHist() 
0104 {
0105       int qual=getQuality();
0106       double pt=getPt();
0107       double mode=getMode();
0108       double fabsEta=fabs(getEta());
0109 
0110       
0111       //for phi mod 10 deg histograms
0112       double phi_deg=getPhi()*180/3.1415927;
0113       double result=phi_deg-5;    
0114       if(result<0) {result+=360;}
0115       while(result>=10){result-=10.0;}
0116       double phi_bar=result;
0117       
0118 
0119       histlist->Eta->Fill(fabsEta);
0120       histlist->signedEta->Fill(getEta());
0121 
0122       histlist->Phi->Fill(getPhi());
0123 
0124 
0125       if(getEta()>0.9 && getEta()<2.4)
0126       {
0127               histlist->Phi_mod_10_endcap1->Fill(phi_bar);
0128       }       
0129       if(getEta()<-0.9 && getEta()>-2.4)
0130       {
0131               histlist->Phi_mod_10_endcap2->Fill(phi_bar);
0132       }         
0133       histlist->Pt->Fill(pt);    
0134       histlist->Pz->Fill(getPz());    
0135       histlist->P->Fill(getP());      
0136       histlist->Radius->Fill(getRadius());    
0137       histlist->Quality->Fill(qual);
0138       histlist->modeOcc->Fill(mode);
0139       histlist->BX->Fill(getBX());
0140       histlist->FR->Fill(getFR());
0141       histlist->ptDenOverall->Fill(pt);
0142 
0143       //DT Region
0144       if( fabsEta >= 0 && fabsEta <= 0.9 )// getEta() changed to fabsEta
0145       {
0146               histlist->ptDenDTOnly->Fill(pt);
0147               //histlist->fidPtDen->Fill(pt);
0148               histlist->modeOccDT->Fill(mode);
0149       }
0150       //CSC Only
0151       if( fabsEta >= 1.2 && fabsEta <= 2.4)
0152       {
0153               histlist->ptDenCSCOnly->Fill(pt);
0154               histlist->modeOccCSCOnly->Fill(mode);
0155       }
0156       //CSC Restricted
0157       if( fabsEta >= 1.2 && fabsEta <= 2.1)
0158       {
0159               histlist->ptDenCSCRestricted->Fill(pt);
0160       }       
0161       //Overlap
0162       if( fabsEta <= 1.2 && fabsEta >= 0.9)
0163       {
0164               histlist->ptDenOverlap->Fill(pt);       
0165               histlist->modeOccOverlap->Fill(mode);
0166       }
0167       if(fabsEta >= 2.1)
0168       {
0169               histlist->ptDenHighEta->Fill(pt);       
0170               histlist->modeOccHighEta->Fill(mode);
0171       }
0172 }
0173 void Track::fillMatchHist() 
0174 {
0175       int i=0;
0176       int qual=getQuality();
0177       double tfpt=getTFPt();
0178       double simpt=getPt();
0179       double mode=getMode();
0180       double fabsEta = fabs(getEta());
0181       double phi_deg = getPhi()*180/3.1415926;        
0182       double result=phi_deg-5;
0183       if(result<0)
0184       {
0185               result+=360;
0186       }
0187       while(result>=10)
0188       {
0189               result-=10.0;
0190               i++;
0191       }
0192       double phi_bar=result;
0193       if(fabsEta>=0.9) 
0194       {
0195               histlist->matchedRefPt_FWD->Fill(simpt);
0196       }
0197       if(fabsEta<=0.9) 
0198       {
0199               histlist->matchedRefPt_DT->Fill(simpt);
0200       }
0201       histlist->matchEta->Fill(fabsEta);      
0202       histlist->signedMatchEta->Fill(getEta());       
0203       histlist->matchPhi->Fill(getPhi());
0204       histlist->matchRadius->Fill(getRadius());
0205       histlist->matchMode->Fill(mode);       
0206       if(qual>0)
0207       {
0208               histlist->EtaQ1->Fill(fabsEta); 
0209               histlist->signedEtaQ1->Fill(getEta());  
0210               histlist->PhiQ1->Fill(getPhi());        
0211               histlist->PtQ1->Fill(simpt);  
0212       }
0213       if(qual>1)
0214       {
0215               histlist->EtaQ2->Fill(fabsEta); 
0216               histlist->signedEtaQ2->Fill(getEta());  
0217               histlist->PhiQ2->Fill(getPhi());        
0218               histlist->PtQ2->Fill(simpt);  
0219               if(getEta()>0.9&&getEta()<2.4)
0220               {
0221                   histlist->matchPhi_mod_10_Q2_endcap1->Fill(phi_bar);
0222               }       
0223               if(getEta()<-0.9&&getEta()>-2.4)
0224               {
0225                   histlist->matchPhi_mod_10_Q2_endcap2->Fill(phi_bar);
0226               }       
0227       }
0228       if(qual>2)
0229       {
0230               histlist->EtaQ3->Fill(fabsEta); 
0231               histlist->signedEtaQ3->Fill(getEta());  
0232               histlist->PhiQ3->Fill(getPhi());        
0233               histlist->PtQ3->Fill(simpt);  
0234               if(getEta()>0.9 && getEta()<2.4)
0235               {
0236                   histlist->matchPhi_mod_10_Q3_endcap1->Fill(phi_bar);
0237               }       
0238               if(getEta()<-0.9 && getEta()>-2.4)
0239               {
0240                   histlist->matchPhi_mod_10_Q3_endcap2->Fill(phi_bar);
0241               }
0242       }
0243       ///////////////////////////
0244       //  Section filling pt
0245       ///////////////////////////
0246       //Overall
0247       
0248       if(qual>1)
0249       {
0250                 histlist->matchPtOverall->Fill(simpt);  
0251                 if (tfpt>10)
0252                 {
0253                 histlist->matchTFPt10Overall->Fill(simpt);
0254                 }
0255             if (tfpt>12)
0256                 {
0257                     histlist->matchTFPt12Overall->Fill(simpt);
0258                 }
0259             if (tfpt>16)
0260                 {
0261                     histlist->matchTFPt16Overall->Fill(simpt);
0262                 }
0263                 if (tfpt>20)
0264                 {
0265                     histlist->matchTFPt20Overall->Fill(simpt);
0266                 }
0267                 if (tfpt>40)
0268                 {
0269                     histlist->matchTFPt40Overall->Fill(simpt);
0270                 }
0271                 if (tfpt>60)
0272                 {
0273                     histlist->matchTFPt60Overall->Fill(simpt);
0274                 }
0275       }
0276       //DT Region
0277       if(fabsEta>=0&&fabsEta<=0.9&&qual>1)
0278       { 
0279               //histlist->matchPt->Fill(simpt);
0280               histlist->matchPtDTOnly->Fill(simpt);   
0281               if (tfpt>10)
0282               {
0283                   histlist->matchTFPt10DTOnly->Fill(simpt);
0284               }
0285           if (tfpt>12)
0286               {
0287                   histlist->matchTFPt12DTOnly->Fill(simpt);
0288               }
0289           if (tfpt>16)
0290               {
0291                   histlist->matchTFPt16DTOnly->Fill(simpt);
0292               }
0293               if (tfpt>20)
0294               {
0295                   histlist->matchTFPt20DTOnly->Fill(simpt);
0296               }
0297               if (tfpt>40)
0298               {
0299                   histlist->matchTFPt40DTOnly->Fill(simpt);
0300               }
0301               if (tfpt>60)
0302               {
0303                   histlist->matchTFPt60DTOnly->Fill(simpt);
0304               }
0305       }
0306       //CSC Only
0307       if(fabsEta>=1.2&&fabsEta<=2.4&&qual>1)
0308       {
0309               histlist->matchPtCSCOnly->Fill(simpt);  
0310               if (tfpt>10)
0311               {
0312                   histlist->matchTFPt10CSCOnly->Fill(simpt);
0313               }
0314           if (tfpt>12)
0315               {
0316                   histlist->matchTFPt12CSCOnly->Fill(simpt);
0317               }
0318           if (tfpt>16)
0319               {
0320                   histlist->matchTFPt16CSCOnly->Fill(simpt);
0321               }
0322               if (tfpt>20)
0323               {
0324                   histlist->matchTFPt20CSCOnly->Fill(simpt);
0325               }
0326               if (tfpt>40)
0327               {
0328                   histlist->matchTFPt40CSCOnly->Fill(simpt);
0329               }
0330               if (tfpt>60)
0331               {
0332                   histlist->matchTFPt60CSCOnly->Fill(simpt);
0333               }
0334       }
0335       //CSC Restricted
0336       if(fabsEta>=1.2&&fabsEta<=2.1&&qual>1)
0337       {
0338               histlist->matchPtCSCRestricted->Fill(simpt);    
0339               if (tfpt>10)
0340               {
0341                   histlist->matchTFPt10CSCRestricted->Fill(simpt);
0342               }
0343           if (tfpt>12)
0344               {
0345                   histlist->matchTFPt12CSCRestricted->Fill(simpt);
0346               }
0347           if (tfpt>16)
0348               {
0349                   histlist->matchTFPt16CSCRestricted->Fill(simpt);
0350               }
0351               if (tfpt>20)
0352               {
0353                   histlist->matchTFPt20CSCRestricted->Fill(simpt);
0354               }
0355               if (tfpt>40)
0356               {
0357                   histlist->matchTFPt40CSCRestricted->Fill(simpt);
0358               }
0359               if (tfpt>60)
0360               {
0361                   histlist->matchTFPt60CSCRestricted->Fill(simpt);
0362               }
0363       }
0364       //Overlap
0365       if(fabsEta<=1.2&&fabsEta>=0.9&&qual>1)
0366       {
0367               histlist->matchPtOverlap->Fill(simpt);  
0368               if (tfpt>10)
0369               {
0370                   histlist->matchTFPt10Overlap->Fill(simpt);
0371               }
0372           if (tfpt>12)
0373               {
0374                   histlist->matchTFPt12Overlap->Fill(simpt);
0375               }
0376           if (tfpt>16)
0377               {
0378                   histlist->matchTFPt16Overlap->Fill(simpt);
0379               }
0380               if (tfpt>20)
0381               {
0382                   histlist->matchTFPt20Overlap->Fill(simpt);
0383               }
0384               if (tfpt>40)
0385               {
0386                   histlist->matchTFPt40Overlap->Fill(simpt);
0387               }
0388               if (tfpt>60)
0389               {
0390                   histlist->matchTFPt60Overlap->Fill(simpt);
0391               }
0392       }
0393       //High Eta
0394       if(fabsEta>=2.1&&qual>1)
0395       {
0396               histlist->matchPtHighEta->Fill(simpt);  
0397               if (tfpt>10)
0398               {
0399                   histlist->matchTFPt10HighEta->Fill(simpt);
0400               }
0401           if (tfpt>12)
0402               {
0403                   histlist->matchTFPt12HighEta->Fill(simpt);
0404               }
0405           if (tfpt>16)
0406               {
0407                   histlist->matchTFPt16HighEta->Fill(simpt);
0408               }
0409               if (tfpt>20)
0410               {
0411                   histlist->matchTFPt20HighEta->Fill(simpt);
0412               }
0413               if (tfpt>40)
0414               {
0415                   histlist->matchTFPt40HighEta->Fill(simpt);
0416               }
0417               if (tfpt>60)
0418               {
0419                   histlist->matchTFPt60HighEta->Fill(simpt);
0420               }
0421       }
0422       
0423 }
0424   void Track::fillGhostHist()
0425 {
0426       int qual=getQuality();
0427       double Eta=getEta();
0428       double fabsEta=fabs(Eta);
0429       double simpt=getPt(); 
0430       double Phi=getPhi();
0431       histlist->ghostEta->Fill(fabsEta);      
0432       histlist->ghostSignedEta->Fill(Eta);       
0433       histlist->ghostPhi->Fill(Phi);     
0434       histlist->ghostPt->Fill(simpt);       
0435       histlist->ghostRadius->Fill(getRadius());       
0436       //histlist->ghostQuality->Fill(qual);     
0437 
0438       if (qual>0)
0439       {
0440               histlist->ghostEtaQ1->Fill(fabsEta);    
0441               histlist->ghostSignedEtaQ1->Fill(Eta);     
0442               histlist->ghostPhiQ1->Fill(Phi);   
0443               histlist->ghostPtQ1->Fill(simpt);     
0444       }
0445       if (qual>1)
0446       {
0447               histlist->ghostEtaQ2->Fill(fabsEta);    
0448               histlist->ghostSignedEtaQ2->Fill(Eta);     
0449               histlist->ghostPhiQ2->Fill(Phi);   
0450               histlist->ghostPtQ2->Fill(simpt);     
0451       }
0452       if (qual>2)
0453       {
0454               histlist->ghostEtaQ3->Fill(fabsEta);    
0455               histlist->ghostSignedEtaQ3->Fill(Eta);     
0456               histlist->ghostPhiQ3->Fill(Phi);   
0457               histlist->ghostPtQ3->Fill(simpt);     
0458       }
0459   }
0460   void Track::fillRateHist()
0461   {
0462     double pt=getPt()+0.001; //addition of 0.001 is to ensure the Pt is not on the border of a bin- which causes problems with the iterative stepping through bins
0463     double stepPt=histlist->getPtStep();
0464     
0465     for(double threshold=pt;threshold>=-1;threshold-=stepPt)
0466     {
0467         histlist->rateHist->Fill(threshold);
0468     }
0469   
0470   
0471   }
0472 }