CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/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   HltTree->Branch("ohPixelFEDSize",&pixelfedsize,"ohPixelFEDSize/I");
00073   HltTree->Branch("NohPixelClusters",&npixelclusters,"NohPixelClusters/I");
00074 }
00075 
00076 /* **Analyze the event** */
00077 void HLTTrack::analyze(
00078                        const edm::Handle<reco::IsolatedPixelTrackCandidateCollection> & IsoPixelTrackL3,
00079                        const edm::Handle<reco::IsolatedPixelTrackCandidateCollection> & IsoPixelTrackL2,
00080                        const edm::Handle<reco::VertexCollection> & pixelVertices,
00081                        const edm::Handle<reco::RecoChargedCandidateCollection> & PixelTracksL3,
00082                        const edm::Handle<FEDRawDataCollection> hfedraw,
00083                        const edm::Handle<edmNew::DetSetVector<SiPixelCluster> > & pixelClusters,
00084                        TTree* HltTree) {
00085 
00086   //isoPixel
00087   if (IsoPixelTrackL3.isValid()) { 
00088     // Ref to Candidate object to be recorded in filter object 
00089     edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candref; 
00090     
00091     nisopixeltrackL3 = IsoPixelTrackL3->size();
00092     
00093     for (unsigned int i=0; i<IsoPixelTrackL3->size(); i++) 
00094       { 
00095         candref = edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(IsoPixelTrackL3, i); 
00096         
00097         isopixeltrackL3maxptpxl[i] = candref->maxPtPxl();
00098         isopixeltrackL3pt[i] = candref->pt();
00099         isopixeltrackL3eta[i] = candref->track()->eta();
00100         isopixeltrackL3phi[i] = candref->phi();   
00101         isopixeltrackL3energy[i] = (candref->pt())*cosh(candref->track()->eta());
00102       } 
00103   }
00104   else {nisopixeltrackL3 = 0;} 
00105 
00106   //minBiasPixel  
00107   if (PixelTracksL3.isValid()) { 
00108     // Ref to Candidate object to be recorded in filter object 
00109     edm::Ref<reco::RecoChargedCandidateCollection> candref; 
00110     
00111     npixeltracksL3 = PixelTracksL3->size();
00112     
00113     for (unsigned int i=0; i<PixelTracksL3->size(); i++) 
00114       { 
00115         candref = edm::Ref<reco::RecoChargedCandidateCollection>(PixelTracksL3, i); 
00116         
00117         pixeltracksL3pt[i] = candref->pt();
00118         pixeltracksL3eta[i] = candref->eta();
00119         pixeltracksL3phi[i] = candref->phi();   
00120         pixeltracksL3vz[i] = candref->vz();
00121         
00122         if (IsoPixelTrackL2.isValid()) {
00123           double minDR=100;
00124           edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candrefl2;
00125           edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candrefl2matched;
00126           for (unsigned int j=0; j<IsoPixelTrackL2->size(); j++) 
00127             { 
00128               candrefl2 = edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(IsoPixelTrackL2, j);
00129               double drL3L2 = deltaR(candrefl2->eta(), candrefl2->phi(),candref->eta(), candref->phi());
00130               if (drL3L2<minDR)
00131                 {
00132                   candrefl2matched=candrefl2;
00133                   minDR=drL3L2;
00134                 }
00135             }
00136           if (candrefl2matched.isNonnull())
00137             {
00138               isopixeltrackL2pt[i]=candrefl2matched->pt();
00139               isopixeltrackL2eta[i]=candrefl2matched->eta();
00140               if (pixelVertices.isValid()) 
00141                 {
00142                   double minDZ=100;
00143                   edm::Ref<reco::VertexCollection> vertref; 
00144                   edm::Ref<reco::VertexCollection> vertrefMatched;
00145                   for (unsigned int k=0; k<pixelVertices->size(); k++)
00146                     {
00147                       vertref=edm::Ref<reco::VertexCollection>(pixelVertices, k);
00148                       double dz=fabs(candrefl2matched->track()->dz(vertref->position()));
00149                       if (dz<minDZ)
00150                         {
00151                           minDZ=dz;
00152                           vertrefMatched=vertref;
00153                         }
00154                     }
00155                   if (vertrefMatched.isNonnull()) isopixeltrackL2dXY[i] = candrefl2matched->track()->dxy(vertref->position());
00156                   else isopixeltrackL2dXY[i]=0;
00157                 }
00158             }
00159         }
00160       } 
00161   }
00162   else {npixeltracksL3 = 0;} 
00163 
00164   //Pixel FED activity
00165   const FEDRawDataCollection theRaw = * hfedraw;
00166   int sumoffeds = 0; 
00167 
00168   for (unsigned int i = 0; i <= 39; i++)
00169     {
00170       sumoffeds = sumoffeds + (theRaw.FEDData(i).size());
00171     }
00172 
00173   pixelfedsize = sumoffeds;
00174 
00175   npixelclusters = pixelClusters->dataSize();
00176 
00178   
00179 }