CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTrigger/HLTanalyzers/src/HLTTrack.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <sstream>
00003 #include <istream>
00004 #include <fstream>
00005 #include <iomanip>
00006 #include <string>
00007 #include <cmath>
00008 #include <functional>
00009 #include <stdlib.h>
00010 #include <string.h>
00011 
00012 #include "HLTrigger/HLTanalyzers/interface/HLTTrack.h"
00013 #include "DataFormats/Math/interface/deltaR.h"
00014 
00015 HLTTrack::HLTTrack() {
00016   evtCounter=0;
00017 
00018   //set parameter defaults 
00019   _Monte=false;
00020   _Debug=false;
00021 }
00022 
00023 /*  Setup the analysis to put the branch-variables into the tree. */
00024 void HLTTrack::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
00025 
00026   edm::ParameterSet myEmParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
00027   std::vector<std::string> parameterNames = myEmParams.getParameterNames() ;
00028   
00029   for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
00030         iParam != parameterNames.end(); iParam++ ){
00031     if  ( (*iParam) == "Monte" ) _Monte =  myEmParams.getParameter<bool>( *iParam );
00032     else if ( (*iParam) == "Debug" ) _Debug =  myEmParams.getParameter<bool>( *iParam );
00033   }
00034 
00035    //common
00036   const int kMaxTrackL3 = 10000;
00037    //isoPixel
00038   isopixeltrackL3pt = new float[kMaxTrackL3];
00039   isopixeltrackL3eta = new float[kMaxTrackL3];
00040   isopixeltrackL3phi = new float[kMaxTrackL3]; 
00041   isopixeltrackL3maxptpxl = new float[kMaxTrackL3];
00042   isopixeltrackL3energy = new float[kMaxTrackL3]; 
00043   isopixeltrackL2pt = new float[kMaxTrackL3];
00044   isopixeltrackL2eta = new float[kMaxTrackL3];
00045   isopixeltrackL2dXY = new float[kMaxTrackL3];
00046 
00047    //minBiasPixel
00048   pixeltracksL3pt = new float[kMaxTrackL3];
00049   pixeltracksL3eta = new float[kMaxTrackL3];
00050   pixeltracksL3phi = new float[kMaxTrackL3]; 
00051   pixeltracksL3vz = new float[kMaxTrackL3];
00052 
00053   // Track-specific branches of the tree 
00054    //isoPixel
00055   HltTree->Branch("NohIsoPixelTrackL3",&nisopixeltrackL3,"NohIsoPixelTrackL3/I");
00056   HltTree->Branch("ohIsoPixelTrackL3Pt",isopixeltrackL3pt,"ohIsoPixelTrackL3Pt[NohIsoPixelTrackL3]/F");
00057   HltTree->Branch("ohIsoPixelTrackL3Eta",isopixeltrackL3eta,"ohIsoPixelTrackL3Eta[NohIsoPixelTrackL3]/F");
00058   HltTree->Branch("ohIsoPixelTrackL3Phi",isopixeltrackL3phi,"ohIsoPixelTrackL3Phi[NohIsoPixelTrackL3]/F"); 
00059   HltTree->Branch("ohIsoPixelTrackL3MaxPtPxl",isopixeltrackL3maxptpxl,"ohIsoPixelTrackL3MaxPtPxl[NohIsoPixelTrackL3]/F");
00060   HltTree->Branch("ohIsoPixelTrackL3Energy",isopixeltrackL3energy,"ohIsoPixelTrackL3Energy[NohIsoPixelTrackL3]/F");
00061   HltTree->Branch("ohIsoPixelTrackL2pt",isopixeltrackL2pt,"ohIsoPixelTrackL2pt[NohIsoPixelTrackL3]/F");
00062   HltTree->Branch("ohIsoPixelTrackL2eta",isopixeltrackL2eta,"ohIsoPixelTrackL2eta[NohIsoPixelTrackL3]/F");
00063   HltTree->Branch("ohIsoPixelTrackL2dXY",isopixeltrackL2dXY,"ohIsoPixelTrackL2dXY[NohIsoPixelTrackL3]/F");
00064 
00065    //minBiasPixel
00066   HltTree->Branch("NohPixelTracksL3",&npixeltracksL3,"NohPixelTracksL3/I");
00067   HltTree->Branch("ohPixelTracksL3Pt",pixeltracksL3pt,"ohPixelTracksL3Pt[NohPixelTracksL3]/F");
00068   HltTree->Branch("ohPixelTracksL3Eta",pixeltracksL3eta,"ohPixelTracksL3Eta[NohPixelTracksL3]/F");
00069   HltTree->Branch("ohPixelTracksL3Phi",pixeltracksL3phi,"ohPixelTracksL3Phi[NohPixelTracksL3]/F"); 
00070   HltTree->Branch("ohPixelTracksL3Vz",pixeltracksL3vz,"ohPixelTracksL3Vz[NohPixelTracksL3]/F");
00071 }
00072 
00073 /* **Analyze the event** */
00074 void HLTTrack::analyze(
00075                        const edm::Handle<reco::IsolatedPixelTrackCandidateCollection> & IsoPixelTrackL3,
00076                        const edm::Handle<reco::IsolatedPixelTrackCandidateCollection> & IsoPixelTrackL2,
00077                        const edm::Handle<reco::VertexCollection> & pixelVertices,
00078                        const edm::Handle<reco::RecoChargedCandidateCollection> & PixelTracksL3,
00079                        TTree* HltTree) {
00080 
00081   //isoPixel
00082   if (IsoPixelTrackL3.isValid()) { 
00083     // Ref to Candidate object to be recorded in filter object 
00084     edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candref; 
00085     
00086     nisopixeltrackL3 = IsoPixelTrackL3->size();
00087     
00088     for (unsigned int i=0; i<IsoPixelTrackL3->size(); i++) 
00089       { 
00090         candref = edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(IsoPixelTrackL3, i); 
00091         
00092         isopixeltrackL3maxptpxl[i] = candref->maxPtPxl();
00093         isopixeltrackL3pt[i] = candref->pt();
00094         isopixeltrackL3eta[i] = candref->track()->eta();
00095         isopixeltrackL3phi[i] = candref->phi();   
00096         isopixeltrackL3energy[i] = (candref->pt())*cosh(candref->track()->eta());
00097       } 
00098   }
00099   else {nisopixeltrackL3 = 0;} 
00100 
00101   //minBiasPixel  
00102   if (PixelTracksL3.isValid()) { 
00103     // Ref to Candidate object to be recorded in filter object 
00104     edm::Ref<reco::RecoChargedCandidateCollection> candref; 
00105     
00106     npixeltracksL3 = PixelTracksL3->size();
00107     
00108     for (unsigned int i=0; i<PixelTracksL3->size(); i++) 
00109       { 
00110         candref = edm::Ref<reco::RecoChargedCandidateCollection>(PixelTracksL3, i); 
00111         
00112         pixeltracksL3pt[i] = candref->pt();
00113         pixeltracksL3eta[i] = candref->eta();
00114         pixeltracksL3phi[i] = candref->phi();   
00115         pixeltracksL3vz[i] = candref->vz();
00116         
00117         if (IsoPixelTrackL2.isValid()) {
00118           double minDR=100;
00119           edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candrefl2;
00120           edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candrefl2matched;
00121           for (unsigned int j=0; j<IsoPixelTrackL2->size(); j++) 
00122             { 
00123               candrefl2 = edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(IsoPixelTrackL2, j);
00124               double drL3L2 = deltaR(candrefl2->eta(), candrefl2->phi(),candref->eta(), candref->phi());
00125               if (drL3L2<minDR)
00126                 {
00127                   candrefl2matched=candrefl2;
00128                   minDR=drL3L2;
00129                 }
00130             }
00131           if (candrefl2matched.isNonnull())
00132             {
00133               isopixeltrackL2pt[i]=candrefl2matched->pt();
00134               isopixeltrackL2eta[i]=candrefl2matched->eta();
00135               if (pixelVertices.isValid()) 
00136                 {
00137                   double minDZ=100;
00138                   edm::Ref<reco::VertexCollection> vertref; 
00139                   edm::Ref<reco::VertexCollection> vertrefMatched;
00140                   for (unsigned int k=0; k<pixelVertices->size(); k++)
00141                     {
00142                       vertref=edm::Ref<reco::VertexCollection>(pixelVertices, k);
00143                       double dz=fabs(candrefl2matched->track()->dz(vertref->position()));
00144                       if (dz<minDZ)
00145                         {
00146                           minDZ=dz;
00147                           vertrefMatched=vertref;
00148                         }
00149                     }
00150                   if (vertrefMatched.isNonnull()) isopixeltrackL2dXY[i] = candrefl2matched->track()->dxy(vertref->position());
00151                   else isopixeltrackL2dXY[i]=0;
00152                 }
00153             }
00154         }
00155       } 
00156   }
00157   else {npixeltracksL3 = 0;} 
00158 
00159 
00161   
00162 }