CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTrack.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <istream>
4 #include <fstream>
5 #include <iomanip>
6 #include <string>
7 #include <cmath>
8 #include <functional>
9 #include <stdlib.h>
10 #include <string.h>
11 
14 
16  evtCounter=0;
17 
18  //set parameter defaults
19  _Monte=false;
20  _Debug=false;
21 }
22 
23 /* Setup the analysis to put the branch-variables into the tree. */
24 void HLTTrack::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
25 
26  edm::ParameterSet myEmParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
27  std::vector<std::string> parameterNames = myEmParams.getParameterNames() ;
28 
29  for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
30  iParam != parameterNames.end(); iParam++ ){
31  if ( (*iParam) == "Monte" ) _Monte = myEmParams.getParameter<bool>( *iParam );
32  else if ( (*iParam) == "Debug" ) _Debug = myEmParams.getParameter<bool>( *iParam );
33  }
34 
35  //common
36  const int kMaxTrackL3 = 10000;
37  //isoPixel
38  isopixeltrackL3pt = new float[kMaxTrackL3];
39  isopixeltrackL3eta = new float[kMaxTrackL3];
40  isopixeltrackL3phi = new float[kMaxTrackL3];
41  isopixeltrackL3maxptpxl = new float[kMaxTrackL3];
42  isopixeltrackL3energy = new float[kMaxTrackL3];
43  isopixeltrackL2pt = new float[kMaxTrackL3];
44  isopixeltrackL2eta = new float[kMaxTrackL3];
45  isopixeltrackL2dXY = new float[kMaxTrackL3];
46 
47  //minBiasPixel
48  pixeltracksL3pt = new float[kMaxTrackL3];
49  pixeltracksL3eta = new float[kMaxTrackL3];
50  pixeltracksL3phi = new float[kMaxTrackL3];
51  pixeltracksL3vz = new float[kMaxTrackL3];
52 
53  // Track-specific branches of the tree
54  //isoPixel
55  HltTree->Branch("NohIsoPixelTrackL3",&nisopixeltrackL3,"NohIsoPixelTrackL3/I");
56  HltTree->Branch("ohIsoPixelTrackL3Pt",isopixeltrackL3pt,"ohIsoPixelTrackL3Pt[NohIsoPixelTrackL3]/F");
57  HltTree->Branch("ohIsoPixelTrackL3Eta",isopixeltrackL3eta,"ohIsoPixelTrackL3Eta[NohIsoPixelTrackL3]/F");
58  HltTree->Branch("ohIsoPixelTrackL3Phi",isopixeltrackL3phi,"ohIsoPixelTrackL3Phi[NohIsoPixelTrackL3]/F");
59  HltTree->Branch("ohIsoPixelTrackL3MaxPtPxl",isopixeltrackL3maxptpxl,"ohIsoPixelTrackL3MaxPtPxl[NohIsoPixelTrackL3]/F");
60  HltTree->Branch("ohIsoPixelTrackL3Energy",isopixeltrackL3energy,"ohIsoPixelTrackL3Energy[NohIsoPixelTrackL3]/F");
61  HltTree->Branch("ohIsoPixelTrackL2pt",isopixeltrackL2pt,"ohIsoPixelTrackL2pt[NohIsoPixelTrackL3]/F");
62  HltTree->Branch("ohIsoPixelTrackL2eta",isopixeltrackL2eta,"ohIsoPixelTrackL2eta[NohIsoPixelTrackL3]/F");
63  HltTree->Branch("ohIsoPixelTrackL2dXY",isopixeltrackL2dXY,"ohIsoPixelTrackL2dXY[NohIsoPixelTrackL3]/F");
64 
65  //minBiasPixel
66  HltTree->Branch("NohPixelTracksL3",&npixeltracksL3,"NohPixelTracksL3/I");
67  HltTree->Branch("ohPixelTracksL3Pt",pixeltracksL3pt,"ohPixelTracksL3Pt[NohPixelTracksL3]/F");
68  HltTree->Branch("ohPixelTracksL3Eta",pixeltracksL3eta,"ohPixelTracksL3Eta[NohPixelTracksL3]/F");
69  HltTree->Branch("ohPixelTracksL3Phi",pixeltracksL3phi,"ohPixelTracksL3Phi[NohPixelTracksL3]/F");
70  HltTree->Branch("ohPixelTracksL3Vz",pixeltracksL3vz,"ohPixelTracksL3Vz[NohPixelTracksL3]/F");
71 
72  HltTree->Branch("ohPixelFEDSize",&pixelfedsize,"ohPixelFEDSize/I");
73  HltTree->Branch("NohPixelClusters",&npixelclusters,"NohPixelClusters/I");
74 }
75 
76 /* **Analyze the event** */
84  TTree* HltTree) {
85 
86  //isoPixel
87  if (IsoPixelTrackL3.isValid()) {
88  // Ref to Candidate object to be recorded in filter object
90 
91  nisopixeltrackL3 = IsoPixelTrackL3->size();
92 
93  for (unsigned int i=0; i<IsoPixelTrackL3->size(); i++)
94  {
95  candref = edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(IsoPixelTrackL3, i);
96 
97  isopixeltrackL3maxptpxl[i] = candref->maxPtPxl();
98  isopixeltrackL3pt[i] = candref->pt();
99  isopixeltrackL3eta[i] = candref->track()->eta();
100  isopixeltrackL3phi[i] = candref->phi();
101  isopixeltrackL3energy[i] = (candref->pt())*cosh(candref->track()->eta());
102  }
103  }
104  else {nisopixeltrackL3 = 0;}
105 
106  //minBiasPixel
107  if (PixelTracksL3.isValid()) {
108  // Ref to Candidate object to be recorded in filter object
110 
111  npixeltracksL3 = PixelTracksL3->size();
112 
113  for (unsigned int i=0; i<PixelTracksL3->size(); i++)
114  {
115  candref = edm::Ref<reco::RecoChargedCandidateCollection>(PixelTracksL3, i);
116 
117  pixeltracksL3pt[i] = candref->pt();
118  pixeltracksL3eta[i] = candref->eta();
119  pixeltracksL3phi[i] = candref->phi();
120  pixeltracksL3vz[i] = candref->vz();
121 
122  if (IsoPixelTrackL2.isValid()) {
123  double minDR=100;
126  for (unsigned int j=0; j<IsoPixelTrackL2->size(); j++)
127  {
128  candrefl2 = edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(IsoPixelTrackL2, j);
129  double drL3L2 = deltaR(candrefl2->eta(), candrefl2->phi(),candref->eta(), candref->phi());
130  if (drL3L2<minDR)
131  {
132  candrefl2matched=candrefl2;
133  minDR=drL3L2;
134  }
135  }
136  if (candrefl2matched.isNonnull())
137  {
138  isopixeltrackL2pt[i]=candrefl2matched->pt();
139  isopixeltrackL2eta[i]=candrefl2matched->eta();
140  if (pixelVertices.isValid())
141  {
142  double minDZ=100;
144  edm::Ref<reco::VertexCollection> vertrefMatched;
145  for (unsigned int k=0; k<pixelVertices->size(); k++)
146  {
148  double dz=fabs(candrefl2matched->track()->dz(vertref->position()));
149  if (dz<minDZ)
150  {
151  minDZ=dz;
152  vertrefMatched=vertref;
153  }
154  }
155  if (vertrefMatched.isNonnull()) isopixeltrackL2dXY[i] = candrefl2matched->track()->dxy(vertref->position());
156  else isopixeltrackL2dXY[i]=0;
157  }
158  }
159  }
160  }
161  }
162  else {npixeltracksL3 = 0;}
163 
164  //Pixel FED activity
165  const FEDRawDataCollection theRaw = * hfedraw;
166  int sumoffeds = 0;
167 
168  for (unsigned int i = 0; i <= 39; i++)
169  {
170  sumoffeds = sumoffeds + (theRaw.FEDData(i).size());
171  }
172 
173  pixelfedsize = sumoffeds;
174 
175  npixelclusters = pixelClusters->dataSize();
176 
178 
179 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
float * isopixeltrackL3pt
Definition: HLTTrack.h:55
bool _Monte
Definition: HLTTrack.h:64
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
float * pixeltracksL3eta
Definition: HLTTrack.h:58
float * pixeltracksL3pt
Definition: HLTTrack.h:58
int nisopixeltrackL3
Definition: HLTTrack.h:56
void analyze(const edm::Handle< reco::IsolatedPixelTrackCandidateCollection > &IsoPixelTrackL3, const edm::Handle< reco::IsolatedPixelTrackCandidateCollection > &IsoPixelTrackL2, const edm::Handle< reco::VertexCollection > &pixelVertices, const edm::Handle< reco::RecoChargedCandidateCollection > &PixelTracksL3, const edm::Handle< FEDRawDataCollection > hfedraw, const edm::Handle< edmNew::DetSetVector< SiPixelCluster > > &pixelClusters, TTree *tree)
Definition: HLTTrack.cc:77
float * isopixeltrackL3maxptpxl
Definition: HLTTrack.h:55
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
float * isopixeltrackL2pt
Definition: HLTTrack.h:55
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
float * isopixeltrackL2eta
Definition: HLTTrack.h:55
float * isopixeltrackL3eta
Definition: HLTTrack.h:55
float * isopixeltrackL2dXY
Definition: HLTTrack.h:55
int j
Definition: DBlmapReader.cc:9
void setup(const edm::ParameterSet &pSet, TTree *tree)
Definition: HLTTrack.cc:24
std::vector< std::string > getParameterNames() const
int npixelclusters
Definition: HLTTrack.h:61
bool isValid() const
Definition: HandleBase.h:75
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
int npixeltracksL3
Definition: HLTTrack.h:59
float * pixeltracksL3vz
Definition: HLTTrack.h:58
float * isopixeltrackL3phi
Definition: HLTTrack.h:55
float * pixeltracksL3phi
Definition: HLTTrack.h:58
float * isopixeltrackL3energy
Definition: HLTTrack.h:55
int pixelfedsize
Definition: HLTTrack.h:60
HLTTrack()
Definition: HLTTrack.cc:15
int evtCounter
Definition: HLTTrack.h:66
bool _Debug
Definition: HLTTrack.h:64