File indexing completed on 2024-04-06 12:20:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "L1Trigger/L1TMuonEndCap/interface/bdt/Utilities.h"
0013
0014 #include "TRandom3.h"
0015 #include "TStopwatch.h"
0016 #include "TTree.h"
0017 #include "TNtuple.h"
0018 #include "TFile.h"
0019 #include "TChain.h"
0020 #include "TMath.h"
0021
0022 using namespace emtf;
0023
0024
0025
0026
0027
0028
0029 const double emtf::ptscale[31] = {0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0,
0030 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0,
0031 45.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 140.0};
0032
0033 const std::vector<double> ptScale = std::vector<double>(ptscale, ptscale + sizeof ptscale / sizeof ptscale[0]);
0034
0035
0036 const double emtf::twoJets_scale[16] = {
0037 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};
0038
0039 const std::vector<double> emtf::twoJetsScale =
0040 std::vector<double>(twoJets_scale, twoJets_scale + sizeof twoJets_scale / sizeof twoJets_scale[0]);
0041
0042
0043
0044
0045
0046 float processPrediction(float BDTPt, int Quality, float PrelimFit) {
0047
0048
0049
0050 if (BDTPt < 0)
0051 BDTPt = PrelimFit;
0052 if (BDTPt > 250)
0053 BDTPt = PrelimFit;
0054
0055 float BDTPt1 = BDTPt;
0056 float scaleF = 1.0;
0057
0058
0059 if (Quality == 3)
0060 scaleF = 1.15;
0061 if (Quality == 2)
0062 scaleF = 1.3;
0063 if (Quality == 1)
0064 scaleF = 1.7;
0065
0066 BDTPt1 = scaleF * BDTPt1;
0067
0068
0069 for (int pts = 0; pts < 31; pts++) {
0070 if (ptscale[pts] <= BDTPt1 && ptscale[pts + 1] > BDTPt1) {
0071 BDTPt1 = ptscale[pts];
0072 break;
0073 }
0074 }
0075
0076 if (BDTPt1 > 140)
0077 BDTPt1 = 140;
0078 if (BDTPt1 < 0)
0079 BDTPt1 = 0;
0080
0081 return BDTPt1;
0082 }
0083
0084
0085
0086
0087
0088 void mergeNtuples(const char* ntuplename, const char* filestomerge, const char* outputfile) {
0089 TChain chain(ntuplename);
0090 chain.Add(filestomerge);
0091 chain.Merge(outputfile);
0092 }
0093
0094
0095
0096
0097
0098 void sortNtupleByEvent(const char* ntuplename, const char* filenametosort, const char* outputfile) {
0099
0100 TFile f(filenametosort);
0101 TNtuple* tree = (TNtuple*)f.Get(ntuplename);
0102 int nentries = (int)tree->GetEntries();
0103
0104
0105 tree->Draw("Event", "", "goff");
0106 int* index = new int[nentries];
0107
0108
0109 TMath::Sort(nentries, tree->GetV1(), index);
0110
0111
0112
0113 TFile f2(outputfile, "recreate");
0114
0115
0116 TTree* tsorted = (TTree*)tree->CloneTree(0);
0117 for (int i = 0; i < nentries; i++) {
0118 tree->GetEntry(index[i]);
0119 tsorted->Fill();
0120 }
0121 tsorted->Write();
0122 delete[] index;
0123 }