CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
Utilities.cc File Reference
#include "L1Trigger/L1TMuonEndCap/interface/Utilities.h"
#include "TRandom3.h"
#include "TStopwatch.h"
#include "TTree.h"
#include "TNtuple.h"
#include "TFile.h"
#include "TChain.h"
#include "TMath.h"

Go to the source code of this file.

Functions

void mergeNtuples (const char *ntuplename, const char *filestomerge, const char *outputfile)
 
float processPrediction (float BDTPt, int Quality, float PrelimFit)
 
void sortNtupleByEvent (const char *ntuplename, const char *filenametosort, const char *outputfile)
 

Variables

const Double_t ptscale [31]
 
const std::vector< Double_t > ptScale = std::vector<Double_t>(ptscale, ptscale + sizeof ptscale / sizeof ptscale[0])
 
const Double_t twoJets_scale [16]
 
const std::vector< Double_t > twoJetsScale = std::vector<Double_t>(twoJets_scale, twoJets_scale + sizeof twoJets_scale / sizeof twoJets_scale[0])
 

Function Documentation

void mergeNtuples ( const char *  ntuplename,
const char *  filestomerge,
const char *  outputfile 
)

Definition at line 85 of file Utilities.cc.

86 {
87  TChain chain(ntuplename);
88  chain.Add(filestomerge);
89  chain.Merge(outputfile);
90 }
float processPrediction ( float  BDTPt,
int  Quality,
float  PrelimFit 
)

Definition at line 47 of file Utilities.cc.

References RPCpg::pts, and ptscale.

48 {
49 // Discretize and scale the BDTPt prediction
50 
51  // Fix terrible predictions
52  if(BDTPt < 0) BDTPt = PrelimFit;
53  if(BDTPt > 250) BDTPt = PrelimFit;
54 
55  float BDTPt1 = BDTPt;
56  float scaleF = 1.0;
57 
58  // Scale based upon quality
59  if (Quality == 3) scaleF = 1.15;
60  if (Quality == 2) scaleF = 1.3;
61  if (Quality == 1) scaleF = 1.7;
62 
63  BDTPt1 = scaleF*BDTPt1;
64 
65  // Discretize based upon ptscale
66  for (int pts=0; pts<31; pts++)
67  {
68  if (ptscale[pts]<=BDTPt1 && ptscale[pts+1]>BDTPt1)
69  {
70  BDTPt1 = ptscale[pts];
71  break;
72  }
73  }
74 
75  if (BDTPt1 > 140) BDTPt1 = 140;
76  if (BDTPt1 < 0) BDTPt1 = 0;
77 
78  return BDTPt1;
79 }
const Double_t ptscale[31]
Definition: Utilities.cc:26
static const double pts[33]
Definition: Constants.h:30
void sortNtupleByEvent ( const char *  ntuplename,
const char *  filenametosort,
const char *  outputfile 
)

Definition at line 96 of file Utilities.cc.

References f, validate-o2o-wbm::f2, i, cmsHarvester::index, and MainPageGenerator::tree.

97 {
98  //TFile f("../../all_test_redux_post.root");
99  TFile f(filenametosort);
100  TNtuple *tree = (TNtuple*)f.Get(ntuplename);
101  Int_t nentries = (Int_t)tree->GetEntries();
102  //Drawing variable pz with no graphics option.
103  //variable pz stored in array fV1 (see TTree::Draw)
104  tree->Draw("Event","","goff");
105  Int_t *index = new Int_t[nentries];
106  //sort array containing pz in decreasing order
107  //The array index contains the entry numbers in decreasing order
108  TMath::Sort(nentries,tree->GetV1(),index);
109 
110  //open new file to store the sorted Tree
111  //TFile f2("../../test_events_sorted.root","recreate");
112  TFile f2(outputfile,"recreate");
113 
114  //Create an empty clone of the original tree
115  TTree *tsorted = (TTree*)tree->CloneTree(0);
116  for (Int_t i=0;i<nentries;i++) {
117  tree->GetEntry(index[i]);
118  tsorted->Fill();
119  }
120  tsorted->Write();
121  delete [] index;
122 }
int i
Definition: DBlmapReader.cc:9
double f[11][100]

Variable Documentation

const Double_t ptscale[31]
Initial value:
=
{ 0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0,
4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0,
16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0,
50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 140.0 }

Definition at line 26 of file Utilities.cc.

Referenced by L1TGMT::bookHistograms(), and processPrediction().

const std::vector<Double_t> ptScale = std::vector<Double_t>(ptscale, ptscale + sizeof ptscale / sizeof ptscale[0])

Definition at line 32 of file Utilities.cc.

Referenced by CSCTFPtLUT::CSCTFPtLUT(), and CSCTFTrackProducer::produce().

const Double_t twoJets_scale[16]
Initial value:
=
{ 0, 0.5, 1.0, 2.0, 3.0,
4.0, 5.0, 10.0, 20.0, 50.0,
100, 500, 1000, 5000, 7500, 50000}

Definition at line 35 of file Utilities.cc.

const std::vector<Double_t> twoJetsScale = std::vector<Double_t>(twoJets_scale, twoJets_scale + sizeof twoJets_scale / sizeof twoJets_scale[0])

Definition at line 40 of file Utilities.cc.