CMS 3D CMS Logo

Functions | Variables
Utilities.cc File Reference
#include "L1Trigger/L1TMuonEndCap/interface/bdt/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 std::vector< double > ptScale = std::vector<double>(ptscale, ptscale + sizeof ptscale / sizeof ptscale[0])
 

Function Documentation

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

Definition at line 90 of file Utilities.cc.

Referenced by emtf::numToStr().

91 {
92  TChain chain(ntuplename);
93  chain.Add(filestomerge);
94  chain.Merge(outputfile);
95 }
Definition: chain.py:1
float processPrediction ( float  BDTPt,
int  Quality,
float  PrelimFit 
)

Definition at line 50 of file Utilities.cc.

References RPCpg::pts, and emtf::ptscale.

Referenced by emtf::numToStr().

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

Definition at line 101 of file Utilities.cc.

References f, connectstrParser::f2, mps_fire::i, and createfilelist::int.

Referenced by emtf::numToStr().

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

Variable Documentation

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

Definition at line 35 of file Utilities.cc.

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