本文整理汇总了C++中TBenchmark类的典型用法代码示例。如果您正苦于以下问题:C++ TBenchmark类的具体用法?C++ TBenchmark怎么用?C++ TBenchmark使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TBenchmark类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AuxFchTemplateFitsData_SIHIH
void AuxFchTemplateFitsData_SIHIH(TString strChannel, TString strVGamma)
{
TBenchmark time;
time.Start("time");
std::cout<<"CPU time = "<<time.GetCpuTime("time")<<", Real time = "<<time.GetRealTime("time")<<std::endl;
FullChain fch;
TConfiguration::AnalysisParameters anPars;
fch.SetDefaultFullChainParameters(anPars,"phoEt");
TConfiguration conf;
int channel;
int vgamma;
if (strChannel=="MUON") anPars.channel=conf.MUON;
if (strChannel=="ELECTRON") anPars.channel=conf.ELECTRON;
if (strVGamma=="WGamma") anPars.vgamma=conf.W_GAMMA;
if (strVGamma=="ZGamma") anPars.vgamma=conf.Z_GAMMA;
anPars.templFits=conf.TEMPL_SIHIH;
AuxTemplates(anPars,0);
time.Stop("time");
std::cout<<"CPU time = "<<time.GetCpuTime("time")<<", Real time = "<<time.GetRealTime("time")<<std::endl;
}
示例2: mergeHadoopFiles
void mergeHadoopFiles(const TString& indir, const TString& outpath) {
// Benchmark
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
//gSystem->Load("../libMiniFWLite.so");
TChain *chain = new TChain("Events");
chain->SetMaxTreeSize(5000000000LL); //default is 100000000000LL
std::cout << "Merging files from dir: " << indir << std::endl
<< "Ouputting to: " << outpath << std::endl;
chain->Add(indir + "/*.root");
chain->Merge(outpath, "fast");
std::cout << "Total events merged: " << chain->GetEntries() << std::endl;
bmark->Stop("benchmark");
cout << "------------------------------" << endl;
cout << "CPU Time: " << Form( "%.01f s", bmark->GetCpuTime("benchmark") ) << endl;
cout << "Real Time: " << Form( "%.01f s", bmark->GetRealTime("benchmark") ) << endl;
cout << endl;
delete bmark;
}
示例3: AuxFchBkgEtoGamma_NoWMtCut
void AuxFchBkgEtoGamma_NoWMtCut()
{
TBenchmark time;
time.Start("time");
std::cout<<"CPU time = "<<time.GetCpuTime("time")<<", Real time = "<<time.GetRealTime("time")<<std::endl;
TConfiguration conf;
FullChain fch;
TConfiguration::AnalysisParameters anPars;
fch.SetDefaultFullChainParameters(anPars,"phoEt");
anPars.channel=conf.ELECTRON;
anPars.vgamma=conf.W_GAMMA;
TEtoGamma etg(anPars,conf.PRELIMINARY_FOR_E_TO_GAMMA_WITH_PSV_NO_WMT_CUT,0);
etg.ComputePlotSave();
time.Stop("time");
std::cout<<"CPU time = "<<time.GetCpuTime("time")<<", Real time = "<<time.GetRealTime("time")<<std::endl;
}
示例4: ScanChain
int ScanChain( TChain* chain, bool fast = true, int nEvents = -1, string skimFilePrefix = "test") {
// Benchmark
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
// Example Histograms
TDirectory *rootdir = gDirectory->GetDirectory("Rint:");
map<string, TH1F*> histos;
vector<string> histonames; histonames.clear();
vector<int> hbins; hbins.clear();
vector<float> hlow; hlow.clear();
vector<float> hup; hup.clear();
histonames.push_back("MT"); hbins.push_back(18); hlow.push_back( 50.); hup.push_back(500);
histonames.push_back("MT_harder"); hbins.push_back(18); hlow.push_back( 50.); hup.push_back(500);
histonames.push_back("MT2W"); hbins.push_back(20); hlow.push_back( 0.); hup.push_back(500);
histonames.push_back("MT2W_4j"); hbins.push_back(20); hlow.push_back( 0.); hup.push_back(500);
histonames.push_back("MET"); hbins.push_back(26); hlow.push_back(100.); hup.push_back(750);
histonames.push_back("MET_3j"); hbins.push_back(26); hlow.push_back(100.); hup.push_back(750);
histonames.push_back("MET_4j"); hbins.push_back(26); hlow.push_back(100.); hup.push_back(750);
histonames.push_back("MET_hMT2W"); hbins.push_back(26); hlow.push_back(100.); hup.push_back(750);
histonames.push_back("MET_hMT2W_4j"); hbins.push_back(26); hlow.push_back(100.); hup.push_back(750);
histonames.push_back("MinDPhi"); hbins.push_back(16); hlow.push_back( 0.); hup.push_back(3.2);
histonames.push_back("MinDPhi_harder"); hbins.push_back(16); hlow.push_back( 0.); hup.push_back(3.2);
histonames.push_back("MinDPhi_3j"); hbins.push_back(16); hlow.push_back( 0.); hup.push_back(3.2);
histonames.push_back("MinDPhi_4j"); hbins.push_back(16); hlow.push_back( 0.); hup.push_back(3.2);
histonames.push_back("NJets"); hbins.push_back(6 ); hlow.push_back( 2.); hup.push_back(8);
histonames.push_back("NJets_hard"); hbins.push_back(6 ); hlow.push_back( 2.); hup.push_back(8);
histonames.push_back("NJets_harder"); hbins.push_back(6 ); hlow.push_back( 2.); hup.push_back(8);
histonames.push_back("tMod"); hbins.push_back(30); hlow.push_back(-15.); hup.push_back(15);
histonames.push_back("tMod_2j"); hbins.push_back(30); hlow.push_back(-15.); hup.push_back(15);
for(unsigned int b = 0; b<2; ++b){
string samplename = skimFilePrefix;
if(skimFilePrefix!="TTbar"&&b>0) continue;
if(skimFilePrefix=="TTbar"&&b==0) samplename = "TTbar1l";
if(skimFilePrefix=="TTbar"&&b==1) samplename = "TTbar2l";
for(unsigned int i = 0; i<histonames.size(); ++i){
string mapname = histonames[i] + "_"+samplename;
if(histos.count(mapname) == 0 ) histos[mapname] = new TH1F(mapname.c_str(), "", hbins[i], hlow[i], hup[i]);
histos[mapname]->Sumw2(); histos[mapname]->SetDirectory(rootdir);
}
}
// Loop over events to Analyze
unsigned int nEventsTotal = 0;
unsigned int nEventsChain = chain->GetEntries();
if( nEvents >= 0 ) nEventsChain = nEvents;
TObjArray *listOfFiles = chain->GetListOfFiles();
TIter fileIter(listOfFiles);
TFile *currentFile = 0;
TH1D* counterhist;
double count1(0), count2(0);
double count3(0), count4(0);
// File Loop
while ( (currentFile = (TFile*)fileIter.Next()) ) {
// Get File Content
TFile *file = new TFile( currentFile->GetTitle() );
TTree *tree = (TTree*)file->Get("t");
if(fast) TTreeCache::SetLearnEntries(10);
if(fast) tree->SetCacheSize(128*1024*1024);
cms3.Init(tree);
// Loop over Events in current file
if( nEventsTotal >= nEventsChain ) continue;
unsigned int nEventsTree = tree->GetEntriesFast();
for( unsigned int event = 0; event < nEventsTree; ++event) {
// Get Event Content
if( nEventsTotal >= nEventsChain ) continue;
if(fast) tree->LoadTree(event);
cms3.GetEntry(event);
++nEventsTotal;
// Progress
CMS3::progress( nEventsTotal, nEventsChain );
float weight = cms3.scale1fb()*2.26;
if(event==0) cout << "weight " << weight << " nEvents " << cms3.nEvents() << " filename " << currentFile->GetTitle() << endl;
//ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<float> > metlv;
//metlv.SetPxPyPzE(pfmet()*TMath::Cos(pfmet_phi()),pfmet()*TMath::Sin(pfmet_phi()),0.,pfmet());
int NSLeps = 0;
int NAddVetoLeps = 0;
if(lep1_is_mu()){
if(lep1_pt()>20&&fabs(lep1_eta())<2.4) {++NSLeps;}
} else if (lep1_is_el()){
if(lep1_pt()>20&&fabs(lep1_eta())<1.4442) {++NSLeps; }
} if(lep2_is_mu()){
if(lep2_pt()>20&&fabs(lep2_eta())<2.4) {++NSLeps;}
} else if (lep2_is_el()){
if(lep2_pt()>20&&fabs(lep2_eta())<1.4442) {++NSLeps; }
//.........这里部分代码省略.........
示例5: ScanChain
int ScanChain( TChain* chain, TString outfile, TString option="", bool fast = true, int nEvents = -1, string skimFilePrefix = "test") {
// Benchmark
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
bool noSIP = false;
if (option.Contains("noSIP")) noSIP = true;
bool usePtRel = false;
if (option.Contains("ptRel")) usePtRel = true;
bool doBonly = false;
if (option.Contains("doBonly")) doBonly = true;
bool doConly = false;
if (option.Contains("doConly")) doConly = true;
bool doLightonly = false;
if (option.Contains("doLightonly")) doLightonly = true;
// Example Histograms
TDirectory *rootdir = gDirectory->GetDirectory("Rint:");
TH2D *pTrelvsIso_histo_el = new TH2D("pTrelvsIso_histo_el", "pTrel vs Iso (Electrons)", 10, 0., 1., 15, 0., 30.);
pTrelvsIso_histo_el->SetDirectory(rootdir);
pTrelvsIso_histo_el->Sumw2();
TH2D *pTrelvsIso_histo_mu = new TH2D("pTrelvsIso_histo_mu", "pTrel vs Iso (Muons)", 10, 0., 1., 15, 0., 30.);
pTrelvsIso_histo_mu->SetDirectory(rootdir);
pTrelvsIso_histo_mu->Sumw2();
//----------------------
// Loop over events to Analyze
unsigned int nEventsTotal = 0;
unsigned int nEventsChain = chain->GetEntries();
if( nEvents >= 0 ) nEventsChain = nEvents;
TObjArray *listOfFiles = chain->GetListOfFiles();
TIter fileIter(listOfFiles);
TFile *currentFile = 0;
// File Loop
while ( (currentFile = (TFile*)fileIter.Next()) ) {
// Get File Content
TFile *file = new TFile( currentFile->GetTitle() );
TTree *tree = (TTree*)file->Get("t");
if(fast) TTreeCache::SetLearnEntries(10);
if(fast) tree->SetCacheSize(128*1024*1024);
ss.Init(tree);
// Loop over Events in current file //ACTUALLY A LEPTON "EVENT" LOOP
if( nEventsTotal >= nEventsChain ) continue;
unsigned int nEventsTree = tree->GetEntriesFast();
for( unsigned int event = 0; event < nEventsTree; ++event) {
// Get Event Content
if( nEventsTotal >= nEventsChain ) continue;
if(fast) tree->LoadTree(event);
ss.GetEntry(event);
++nEventsTotal;
// Progress
lepfilter::progress( nEventsTotal, nEventsChain );
// Analysis Code
float weight = ss.scale1fb()*10.0;
if(ss.scale1fb() > 100000.) continue; //excludes 5to10 and 10to20 EM Enriched
bool jetptcut = false;
int jetidx = 0;
while( (jetidx < ss.jets().size()) && !jetptcut) //check to see if at least one jet w/ pt > 40
{
if( ss.jets()[jetidx].pt() > 40. )
{jetptcut = true;}
jetidx++;
}
if( !(jetptcut && ss.met() < 20. && ss.mt() < 20) )
{continue;}
// if(ss.nFOs() != 1) //if more than 1 FO in event
// {continue;}
int nbtags = 0;
for(int i = 0; i < ss.jets().size(); i++){
if(ss.jets_disc()[i] > 0.814) nbtags++;
}
if (nbtags > 2.) nbtags = 2;
if(ss.p4().pt() > 100. || ss.p4().pt() < 10. || fabs(ss.p4().eta()) > 2.4) //What do we want here?
{continue;}
//------------------------------------------------------------------------------------------
//---------------------------------Find e = f(Pt,eta)---------------------------------------
//------------------------------------------------------------------------------------------
//Find ratio of nonprompt leps passing tight to nonprompt leps passing at least loose. This is the fake rate
// Use lep_passes_id to see if num. Use FO to see if Fakable Object (denom)
//.........这里部分代码省略.........
示例6: ScanChain
int ScanChain( TChain* chain, bool fast = true, int nEvents = -1, string skimFilePrefix = "test") {
// Benchmark
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
// Example Histograms
TDirectory *rootdir = gDirectory->GetDirectory("Rint:");
// samplehisto->SetDirectory(rootdir);
TH1F *h_muonCount = new TH1F("h_muonCount", "Number of Muons in this event", 90, 0, 5);
// MuonTagAndProbe: define the trigger to check here
vector<string> triggerNames;
triggerNames.push_back("HLT_IsoMu24");
triggerNames.push_back("HLT_IsoTkMu24");
// triggerNames.push_back("HLT_IsoMu20");
// triggerNames.push_back("HLT_IsoTkMu20");
// triggerNames.push_back("HLT_Ele27_eta2p1_WPLoose_Gsf");
// triggerNames.push_back("HLT_Ele22_eta2p1_WPLoose_Gsf");
// Separate vector to store the pt cut to be used for eta and phi
vector<float> triggerPtCuts(triggerNames.size(), 50);
// triggerPtCuts[2] = 25;
// triggerPtCuts[3] = 25;
vector<map<histType,TH1F*>> muonHists = creatMuonHists(triggerNames);
vector<map<histType,TH1F*>> muonHists1 = creatMuonHists(triggerNames, "_1");
vector<map<histType,TH1F*>> muonHists2 = creatMuonHists(triggerNames, "_2");
vector<map<histType,TH1F*>> muonHists3 = creatMuonHists(triggerNames, "_3");
// Loop over events to Analyze
unsigned int nEventsTotal = 0;
unsigned int nEventsChain = chain->GetEntries();
if (nEvents >= 0) nEventsChain = nEvents;
TObjArray *listOfFiles = chain->GetListOfFiles();
TIter fileIter(listOfFiles);
TFile *currentFile = 0;
// File Loop
while ( (currentFile = (TFile*)fileIter.Next()) ) {
// Get File Content
TFile file( currentFile->GetTitle() );
TTree *tree = (TTree*)file.Get("t");
if (fast) TTreeCache::SetLearnEntries(10);
if (fast) tree->SetCacheSize(128*1024*1024);
t.Init(tree);
int evt_num = -1;
int nMuonCount = 0;
int isTriggerMuon = 0;
LorentzVector p4mu;
LorentzVector tag_p4mu;
vector<TBranch*> trigBranches = setupTriggerBranches(triggerNames, tree);
vector<TBranch*> tagTrigBranches = setupTagTriggerBranches(triggerNames, tree);
// Loop over Events in current file
if (nEventsTotal >= nEventsChain) continue;
unsigned int nEventsTree = tree->GetEntriesFast();
for (unsigned int event = 0; event < nEventsTree; ++event) {
// Get Event Content
if (nEventsTotal >= nEventsChain) continue;
if (fast) tree->LoadTree(event);
t.GetEntry(event);
++nEventsTotal;
// Progress
LepTree::progress(nEventsTotal, nEventsChain);
// Analysis Code
if (evt_isRealData() && evt_run() < 273423) continue; // Get runs after fixing the L1 interface problem
int nevt = evt_event();
if (nevt != evt_num) {
h_muonCount->Fill(nMuonCount);
nMuonCount = 0;
isTriggerMuon = 0;
}
// --- New Tag & Probe ---
if (abs(id()) != 13) continue;
if (p4().pt() < 10) continue;
if (fabs(p4().eta()) > 2.4 ) continue;
if (charge()*tag_charge() > 0) continue;
if (tag_p4().pt() < 25) continue;
if (tag_RelIso03EA() > 0.1) continue;
if (dilep_mass() < 81.2 || dilep_mass() > 101.2) continue;
if (!pid_PFMuon()) continue;
++nMuonCount;
// if (nMuonCount > 2) continue;
for (unsigned int i=0; i<triggerNames.size(); i++) {
if (getTriggerValue(tagTrigBranches[i], event) <= 0) continue;
fillTagMuonHists(muonHists[i], triggerPtCuts[i]);
//.........这里部分代码省略.........
示例7: AliCFSingleTrackTask
Bool_t AliCFSingleTrackTask(
const Bool_t useGrid = 1,
const Bool_t readAOD = 0,
const Bool_t readTPCTracks = 0,
const char * kTagXMLFile="wn.xml" // XML file containing tags
)
{
TBenchmark benchmark;
benchmark.Start("AliSingleTrackTask");
AliLog::SetGlobalDebugLevel(0);
Load() ; //load the required libraries
TChain * analysisChain ;
if (useGrid) { //data located on AliEn
TGrid::Connect("alien://") ; // Create an AliRunTagCuts and an AliEventTagCuts Object
// and impose some selection criteria
AliRunTagCuts *runCuts = new AliRunTagCuts();
AliEventTagCuts *eventCuts = new AliEventTagCuts();
AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
eventCuts->SetMultiplicityRange(0,2000);
// Create an AliTagAnalysis Object and chain the tags
AliTagAnalysis *tagAna = new AliTagAnalysis();
if (readAOD) tagAna->SetType("AOD"); //for aliroot > v4-05
else tagAna->SetType("ESD"); //for aliroot > v4-05
TAlienCollection *coll = TAlienCollection::Open(kTagXMLFile);
TGridResult *tagResult = coll->GetGridResult("",0,0);
tagResult->Print();
tagAna->ChainGridTags(tagResult);
// Create a new esd chain and assign the chain that is returned by querying the tags
analysisChain = tagAna->QueryTags(runCuts,lhcCuts,detCuts,eventCuts);
}
else {// local data
//here put your input data path
printf("\n\nRunning on local file, please check the path\n\n");
if (readAOD) {
analysisChain = new TChain("aodTree");
analysisChain->Add("your_data_path/001/AliAOD.root");
analysisChain->Add("your_data_path/002/AliAOD.root");
}
else {
analysisChain = new TChain("esdTree");
analysisChain->Add("your_data_path/001/AliESDs.root");
analysisChain->Add("your_data_path/002/AliESDs.root");
}
}
Info("AliCFSingleTrackTask",Form("CHAIN HAS %d ENTRIES",(Int_t)analysisChain->GetEntries()));
//CONTAINER DEFINITION
Info("AliCFSingleTrackTask","SETUP CONTAINER");
//the sensitive variables (2 in this example), their indices
UInt_t ipt = 0;
UInt_t iy = 1;
//Setting up the container grid...
UInt_t nstep = 4 ; //number of selection steps MC
const Int_t nvar = 2 ; //number of variables on the grid:pt,y
const Int_t nbin1 = 8 ; //bins in pt
const Int_t nbin2 = 8 ; //bins in y
//arrays for the number of bins in each dimension
Int_t iBin[nvar];
iBin[0]=nbin1;
iBin[1]=nbin2;
//arrays for lower bounds :
Double_t *binLim1=new Double_t[nbin1+1];
Double_t *binLim2=new Double_t[nbin2+1];
//values for bin lower bounds
for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)ptmin + (ptmax-ptmin)/nbin1*(Double_t)i ;
for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)ymin + (ymax-ymin) /nbin2*(Double_t)i ;
//one "container" for MC
AliCFContainer* container = new AliCFContainer("container","container for tracks",nstep,nvar,iBin);
//setting the bin limits
container -> SetBinLimits(ipt,binLim1);
container -> SetBinLimits(iy,binLim2);
container -> SetVarTitle(ipt,"pt");
container -> SetVarTitle(iy, "y");
container -> SetStepTitle(0, "generated");
container -> SetStepTitle(1, "in acceptance");
container -> SetStepTitle(2, "reconstructed");
container -> SetStepTitle(3, "after PID");
// SET TLIST FOR QA HISTOS
TList* qaList = new TList();
//CREATE THE CUTS -----------------------------------------------
//Event-level cuts:
AliCFEventRecCuts* evtRecCuts = new AliCFEventRecCuts("evtRecCuts","Rec-event cuts");
//.........这里部分代码省略.........
示例8: EmbeddingReco
//.........这里部分代码省略.........
StTpcHitMaker *TpxRaw = (StTpcHitMaker *)chain1->GetMaker("TpxRaw");
chain3->AddBefore("TpcMixer", TpxRaw);
chain3->AddBefore("TpcMixer", TpcRS);
#if 0
// Turn on debugging of DB maker
St_db_Maker *db = (St_db_Maker *)chain1->GetMaker("db");
db->SetDebug(2);
#endif
//--------------------------------------------------------------------------
TString trgfile = gSystem->BaseName(fzdFile.c_str());
trgfile.ReplaceAll(".fzd", ".trig.root");
TFile *ofile = TFile::Open(trgfile, "recreate");
assert(ofile);
TH2F *hBarrelHighTowerSimu = new TH2F("hBarrelHighTowerSimu", "BEMC high tower simu;trigger patch;high tower", 300, 0, 300, 64, 0, 64);
TH2F *hBarrelPatchSumSimu = new TH2F("hBarrelPatchSumSimu", "BEMC patch sum simu;trigger patch;patch sum", 300, 0, 300, 64, 0, 64);
TH2F *hEndcapHighTowerSimu = new TH2F("hEndcapHighTowerSimu", "EEMC high tower simu;trigger patch;high tower", 90, 0, 90, 64, 0, 64);
TH2F *hEndcapPatchSumSimu = new TH2F("hEndcapPatchSumSimu", "EEMC patch sum simu;trigger patch;patch sum", 90, 0, 90, 64, 0, 64);
TH2F *hBarrelJetPatchSimu = new TH2F("hBarrelJetPatchSimu", "BEMC jet patch;jet patch;adc", 18, 0, 18, 160, 0, 160);
TH2F *hEndcapJetPatchSimu = new TH2F("hEndcapJetPatchSimu", "EEMC jet patch;jet patch;adc", 6, 0, 6, 160, 0, 160);
TH2F *hOverlapJetPatchSimu = new TH2F("hOverlapJetPatchSimu", "BEMC-EEMC-overlap;jet patch;adc", 6, 0, 6, 160, 0, 160);
}
//--------------------------------------------------------------------------
// Initialize chain
Chain->Init();
PrintTimer(Chain);
puts("Order of makers in BFCMIXER:");
StMaker::lsMakers(Chain);
// Event loop
int mNTotal = 0;
int mNFailed = 0;
TBenchmark evnt;
StIOMaker *inputStream = (StIOMaker *)chain1->GetMaker("inputStream");
for (int iEvent = 1; iEvent <= nEvents; ++iEvent) {
evnt.Reset();
evnt.Start("QAInfo:");
Chain->Clear();
int iMake = Chain->Make(iEvent);
if (iMake == kStErr) ++mNFailed;
if (inputStream->GetMakeReturn() % 10 == kStEOF) {
inputStream->Rewind();
--iEvent;
continue;
}
//if (iMake == kStSkip) continue;
if (iMake % 10 == kStEOF || iMake % 10 == kStFatal) break;
++mNTotal;
PrintTimer(Chain);
//--------------------------------------------------------------------------
if (flag == "Jet") {
// BEMC high towers and trigger patches
for (int triggerpatch = 0; triggerpatch < 300; ++triggerpatch) {
hBarrelHighTowerSimu->Fill(triggerpatch, trgsim->bemc->getBEMC_FEE_HT_ADC()[triggerpatch]);
hBarrelPatchSumSimu->Fill(triggerpatch, trgsim->bemc->getBEMC_FEE_TP_ADC()[triggerpatch]);
} // for triggerpatch
// BEMC jet patches
for (int jetpatch = 0; jetpatch < 18; ++jetpatch) {
示例9: bfcMixer_pp2006
//.........这里部分代码省略.........
chain3->Load();
chain3->Instantiate();
//............. begin of EMC embedding makers................
//.............. Add BEmc stuff here ....................
StMcEventMaker* mcEventMaker = new StMcEventMaker();
StEmcSimulatorMaker *bemcSim = new StEmcSimulatorMaker();
StEmcMixerMaker *bemcMixer = new StEmcMixerMaker();
chain3->AddAfter("emcRaw",bemcMixer);
chain3->AddAfter("emcRaw",bemcSim);
chain3->AddAfter("emcRaw",mcEventMaker);
bemcMixer->SetDebug(0); // set it to 1 for more printouts
// note, Barrel slow sim is always ON, said Adam
//........... Add EEmc Stuff ( Simu, and Mixer) here ..............
StEEmcFastMaker *eemcFastSim = new StEEmcFastMaker();
StEEmcMixerMaker *eemcMixer = new StEEmcMixerMaker();
/* position B+E EMC makers in the chain
(order is reverse because 'After' is used - looks funny but is right)
*/
chain3->AddAfter("emcRaw",eemcMixer);
chain3->AddAfter("emcRaw",eemcFastSim);
eemcFastSim->SetEmbeddingMode();
// eemcFastSim->SetDebug();
// eemcMixer->SetDebug();
if(useEndcapSlowSim) { // turn Endcap slow simu On/Off
StEEmcSlowMaker *slowSim=new StEEmcSlowMaker();
chain3->AddAfter("EEmcFastSim",slowSim);
slowSim->setEmbeddingMode();
}
//............. end of EMC embedding makers................
St_geant_Maker *geantMk = (St_geant_Maker *) chain->GetMaker("geant");
geantMk->SetActive(kTRUE);
StMaker *tpcdaqMk = chain3->GetMaker("tpc_raw");
if(!tpcdaqMk ) {
cout <<" Error: no tpc daq maker. End. "<<endl;
return;
}
tpcdaqMk->SetMode(1); // Trs
tpcdaqMk->SetInput("Event","MixerEvent");
saveMk->cd(); {
TDatime t;
printf ("QAInfo:Run is started at Date/Time%i/%i\n",t.GetDate(),t.GetTime());
}
printf ("QAInfo:Run on %s in %s\n",
gSystem->HostName(),
gSystem->WorkingDirectory());
printf ("QAInfo: with %s\n", chain->GetCVS());
// Init the chain and all its makers
if (Nevents >= 0) {
Int_t iInit = chain->Init();
chain->ls(5); // list the final chain
}
// chain->SetDEBUG();
treeMk = chain->GetMaker("tree");
TBenchmark evnt;
Int_t iMake = 0, i = 1, iBad = 0;
StIOMaker *inpMk = (StIOMaker *)chain1->GetMaker("inputStream");
Int_t ncols, eventnumber, mult, skip=0, oldskip = 0, skiptest=0;
cout <<"BFC - Entering Event Loop"<<endl;
EventLoop: if (i <= Nevents && iMake != kStEOF && iMake != kStFatal) {
evnt.Reset();
evnt.Start("QAInfo:");
chain->Clear();
iMake = chain->Make(i);
if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
StEvtHddr *fEvtHddr = (StEvtHddr*)chain->GetDataSet("EvtHddr");
StEvtHddr *fEvtHddrDaq = (StEvtHddr*)chain1->GetDataSet("EvtHddr");
*fEvtHddr = *fEvtHddrDaq;
// gSystem->Exec("ps ux");
evnt.Stop("QAInfo:");
// evnt->Show("QAInfo:");
printf ("QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time%d.%d/sta %d] Real Time = %10.2f seconds Cpu Time = %10.2f seconds \n", i,chain->GetRunNumber(),chain->GetEventNumber(),chain->GetDate(), chain->GetTime(),
iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
i++;
goto EventLoop;
}
fflush(stdout);
printf ("QAInfo:Run completed ");
gSystem->Exec("date");
}
示例10: looper
//
// Functions
//
int looper( sampleInfo::ID sampleID, std::vector<analyzer*> analyzers, int nEvents, bool readFast ) {
//
// Intro
//
cout << "====================================================" << endl;
cout << endl;
cout << " WELCOME TO STOP BABY ANALYZER! " << endl;
cout << endl;
cout << "====================================================" << endl;
cout << endl;
//
// Benchmark
//
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
//
// Input SampleInfo
//
sampleInfo::sampleUtil sample( sampleID );
bool sampleIsTTbar = false;
if( sample.id == sampleInfo::k_ttbar_powheg_pythia8 ||
sample.id == sampleInfo::k_ttbar_powheg_pythia8_ext4 ||
sample.id == sampleInfo::k_ttbar_singleLeptFromT_madgraph_pythia8 ||
sample.id == sampleInfo::k_ttbar_singleLeptFromT_madgraph_pythia8_ext1 ||
sample.id == sampleInfo::k_ttbar_singleLeptFromTbar_madgraph_pythia8 ||
sample.id == sampleInfo::k_ttbar_singleLeptFromTbar_madgraph_pythia8_ext1 ||
sample.id == sampleInfo::k_ttbar_diLept_madgraph_pythia8 ||
sample.id == sampleInfo::k_ttbar_diLept_madgraph_pythia8_ext1 ) {
sampleIsTTbar = true;
}
//
// Input chain
//
TChain *chain = new TChain("t");
cout << " Processing the following: " << endl;
for(int iFile=0; iFile<(int)sample.inputBabies.size(); iFile++) {
// input directory
string input = sample.baby_i_o.first;
// input file
input += sample.inputBabies[iFile];
chain->Add( input.c_str() );
cout << " " << input << endl;
}
cout << endl;
//
// Output File
//
// output dir
string f_output_name = "";
f_output_name += sample.baby_i_o.second;
// output name
f_output_name += sample.label;
f_output_name += ".root";
// output file
TFile *f_output = new TFile( f_output_name.c_str(), "recreate" );
// print output location
cout << " Output Written to: " << endl;
cout << " " << f_output_name << endl;
cout << endl;
//
// JSON File Tools
//
const char* json_file = "../StopCORE/inputs/json_files/Cert_271036-284044_13TeV_23Sep2016ReReco_Collisions16_JSON.txt"; // 35.876fb final 2016 run
if( sample.isData ) set_goodrun_file_json(json_file);
//
// Event Weight Utilities
//
cout << " Loading eventWeight Utilities..." << endl << endl;
wgtInfo.setUp( sample.id, useBTagSFs_fromFiles_, useLepSFs_fromFiles_, add2ndLepToMet_ );
wgtInfo.apply_cr2lTrigger_sf = (apply_cr2lTrigger_sf_ && add2ndLepToMet_);
wgtInfo.apply_bTag_sf = apply_bTag_sf_;
wgtInfo.apply_lep_sf = apply_lep_sf_;
wgtInfo.apply_vetoLep_sf = apply_vetoLep_sf_;
wgtInfo.apply_tau_sf = apply_tau_sf_;
wgtInfo.apply_lepFS_sf = apply_lepFS_sf_;
//.........这里部分代码省略.........
示例11: ScanChain
int ScanChain( TChain* chain, bool fast = true, int nEvents = -1, string skimFilePrefix = "test") {
// Benchmark
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
// Example Histograms
TDirectory *rootdir = gDirectory->GetDirectory("Rint:");
/*
// This loads the library
TMVA::Tools::Instance();
// to get access to the GUI and all tmva macros
TString thisdir = gSystem->DirName(gInterpreter->GetCurrentMacroName());
gROOT->SetMacroPath(thisdir + ":" + gROOT->GetMacroPath());
gROOT->ProcessLine(".L TMVAGui.C");
*/
map<string, TH1F*> histos; //massive
vector<string> histonames; histonames.clear();
vector<string> histonameshelp; histonameshelp.clear();
vector<int> histobinn; histobinn.clear();
vector<double> histobinl; histobinl.clear();
vector<double> histobinu; histobinu.clear();
map<string, float> value;
histonames.push_back("MT2W"); histobinn.push_back(25); histobinl.push_back(0.); histobinu.push_back(500.);
//histonames.push_back("MT2_b_b"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
histonames.push_back("MT2_lb_b"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
//histonames.push_back("MT2_lb_bq"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
histonames.push_back("MT2_lb_bqq"); histobinn.push_back(25); histobinl.push_back(0.); histobinu.push_back(1000.);
//histonames.push_back("MT2_l_q"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(300.);
histonames.push_back("MT2_lb_b_mless"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
//histonames.push_back("MT2_lb_bq_mless"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
histonames.push_back("MT2_lb_bqq_mless"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
//histonames.push_back("MT2_l_qq_mless"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
histonames.push_back("Mlb"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
//histonames.push_back("Mlbb"); histobinn.push_back(25); histobinl.push_back(0.); histobinu.push_back(1000.);
histonames.push_back("M3b"); histobinn.push_back(25); histobinl.push_back(0.); histobinu.push_back(1000.);
histonames.push_back("MTb"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
//histonames.push_back("MTq"); histobinn.push_back(20); histobinl.push_back(0.); histobinu.push_back(500.);
histonames.push_back("MTqmax"); histobinn.push_back(25); histobinl.push_back(0.); histobinu.push_back(1500.);
//histonames.push_back("MTq_boostmax"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(1500.);
//histonames.push_back("MTq_boost300"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(1500.);
histonames.push_back("MTq_boostLeadJet"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(1500.);
//histonames.push_back("MTqq"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
histonames.push_back("Topness"); histobinn.push_back(30); histobinl.push_back(-15.); histobinu.push_back(15.);
histonames.push_back("MT"); histobinn.push_back(40); histobinl.push_back(0.); histobinu.push_back(400.);
histonames.push_back("MET"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
histonames.push_back("HT"); histobinn.push_back(25); histobinl.push_back(0.); histobinu.push_back(1000.);
histonames.push_back("METoverSqrtHT"); histobinn.push_back(20); histobinl.push_back(0.); histobinu.push_back(40.);
histonames.push_back("HTratio"); histobinn.push_back(20); histobinl.push_back(0.); histobinu.push_back(1.);
histonames.push_back("dRLepBJet"); histobinn.push_back(25); histobinl.push_back(0.); histobinu.push_back(10.);
histonames.push_back("dRbb"); histobinn.push_back(25); histobinl.push_back(0.); histobinu.push_back(10.);
histonames.push_back("chi2"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(30.);
histonames.push_back("NBJets"); histobinn.push_back( 5); histobinl.push_back(0.); histobinu.push_back(5.);
histonames.push_back("NJets"); histobinn.push_back(10); histobinl.push_back(0.); histobinu.push_back(10.);
//histonames.push_back("minDPhi"); histobinn.push_back(32); histobinl.push_back(0.); histobinu.push_back(3.2);
histonames.push_back("minDPhiJ3"); histobinn.push_back(32); histobinl.push_back(0.); histobinu.push_back(3.2);
//histonames.push_back("minDPhiB"); histobinn.push_back(32); histobinl.push_back(0.); histobinu.push_back(3.2);
//histonames.push_back("pTlb"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(600.);
histonames.push_back("pTlbb"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(600.);
histonames.push_back("pTl"); histobinn.push_back(27); histobinl.push_back(0.); histobinu.push_back(405.);
histonames.push_back("pTleadj"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
histonames.push_back("pTleadb"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
//histonames.push_back("pTtrailb"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
//histonames.push_back("sumak8prunedmass"); histobinn.push_back(30); histobinl.push_back(0.); histobinu.push_back(750.);
histonames.push_back("DeltaPhiWl"); histobinn.push_back(32); histobinl.push_back(0.); histobinu.push_back(3.2);
TFile *outfile[3];
TTree *outtree[3];
for(unsigned int b = 0; b<histonames.size(); ++b){
value[histonames[b] ] = -99;
histonameshelp.push_back(histonames[b]+(string)"/F");
}
for(unsigned int b = 0; b<3; ++b){
string samplename = skimFilePrefix;
if(skimFilePrefix!="TTbar"&&b>0) continue;
if(skimFilePrefix=="TTbar"&&b==0) samplename = "TTbar1l";
if(skimFilePrefix=="TTbar"&&b==1) samplename = "TTbar2l";
if(skimFilePrefix=="TTbar"&&b==2) samplename = "TTbarH";
TString fileName = "rootfiles/TestmysmallBDTvartree_"+samplename+".root";
outfile[b] = new TFile(fileName,"RECREATE");
outtree[b] = new TTree(samplename.c_str(),"");
for(unsigned int a = 0; a<histonames.size(); ++a){
outtree[b]->Branch(histonames[a].c_str(), &value[histonames[a] ], histonameshelp[a].c_str() );
}
}
// Loop over events to Analyze
unsigned int nEventsTotal = 0;
unsigned int nEventsChain = chain->GetEntries();
if( nEvents >= 0 ) nEventsChain = nEvents;
TObjArray *listOfFiles = chain->GetListOfFiles();
TIter fileIter(listOfFiles);
TFile *currentFile = 0;
// File Loop
//.........这里部分代码省略.........
示例12: bfcZ
//_____________________________________________________________________
void bfcZ(const Int_t First,
const Int_t Last,
const Char_t *Chain="gstar Cy2b tfs -NoHits TpcHitFilter",
const Char_t *infile=0,
const Double_t zmin=-200, const Double_t zmax=-100,
const Char_t *outfile=0,
const Char_t *TreeFile=0){
gROOT->LoadMacro("bfc.C");
bfc(-1,Chain,infile,outfile,TreeFile);
if (chain->GetOption("TpcHitFilter")) {
StTpcHitFilterMaker *filtMk = (StTpcHitFilterMaker *) chain->GetMaker("tpc_hit_filter");
if (filtMk) {
// St_tcl_Maker *tclMk= (St_tcl_Maker *) chain->GetMaker("tpc_hits");
if (zmin < 0 && zmax < 0) filtMk->WestOff();
if (zmin > 0 && zmax > 0) filtMk->EastOff();
filtMk->SetZrange(zmin,zmax);
}
}
{
TDatime t;
printf ("QAInfo:Run is started at Date/Time %i/%i\n",t.GetDate(),t.GetTime());
printf ("QAInfo:Run on %s in %s\n",
gSystem->HostName(),
gSystem->WorkingDirectory());
printf ("QAInfo: with %s\n", chain->GetCVS());
}
// Init the chain and all its makers
Int_t iTotal = 0, iBad = 0;
St_XDFFile *xdf_out = 0;
TBenchmark evnt;
Int_t iMake = 0, i = First;
if (Last >= 0) {
Int_t iInit = chain->Init();
if (iInit >= kStEOF) {
chain->Fatal(iInit,"on init");
goto END;
}
StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr");
if (hd) hd->SetRunNumber(-2); // to be sure that InitRun calls at least once
// skip if any
if (First > 1) {
if (chain->GetOption("fzin")) {
geant = (St_geant_Maker *) chain->GetMaker("geant");
if (geant) {
if (geant->IsActive()) geant->Skip(First-1);
}
}
else {
StIOMaker *inpMk = (StIOMaker *) chain->GetMaker("inputStream");
if (inpMk) {printf ("Skip %i Events\n",First-1);inpMk->Skip(First-1);}
}
}
}
xdf_out = chain->GetXdfOut();
if (chain->GetOption("Event")) evMk = (StEventMaker *) chain->GetMaker("StEventMaker");
treeMk = chain->GetMaker("OutputStream");
EventLoop: if (i <= Last && iMake != kStEOF && iMake != kStFatal) {
evnt.Reset();
evnt.Start("QAInfo:");
chain->Clear();
iMake = chain->Make(i);
if (iMake <kStEOF) {
if (xdf_out){
St_DataSet *dstSet = chain->GetInputDS("dst");
if (dstSet) xdf_out->NextEventPut(dstSet); // xdf output
}
iTotal++;
if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
// gSystem->Exec("ps ux");
evnt.Stop("QAInfo:");
// evnt.Show("QAInfo:");
printf ("QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time %d.%d/sta %d] Real Time = %10.2f seconds Cpu Time = %10.2f seconds \n",
i,chain->GetRunNumber(),chain->GetEventNumber(),chain->GetDate(), chain->GetTime(),
iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
}
i++; goto EventLoop;
}
END:
fflush(stdout);
printf ("QAInfo:Run completed ");
gSystem->Exec("date");
if (evMk) Event = (StEvent *) chain->GetInputDS("StEvent");
{
TDatime t;
printf ("\nQAInfo:Run is finished at Date/Time %i/%i; Total events processed :%i and not completed: %i\n",
t.GetDate(),t.GetTime(),iTotal,iBad);
}
}
示例13: ScanChain
int ScanChain( TChain* chain, bool fast = true, int nEvents = -1, string skimFilePrefix = "test") {
set_goodrun_file("Merged_190456-208686_8TeV_PromptReReco_Collisions12_goodruns.txt");
// Benchmark
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
// Example Histograms
TDirectory *rootdir = gDirectory->GetDirectory("Rint:");
//add hists
TH1F *h_mll_ee_inc = new TH1F("h_mll_ee_inc", "ee Dilepton Mass", 200,0,200);//200,0,2000
h_mll_ee_inc->SetDirectory(rootdir);
h_mll_ee_inc->Sumw2();
TH1F* h_mll_mumu_inc = new TH1F("h_mll_mumu_inc","MuMu Dilepton Mass",200,0,200);
h_mll_mumu_inc->SetDirectory(rootdir);
h_mll_mumu_inc->Sumw2();
TH1F* h_mll_ee_tar = new TH1F("h_mll_ee_tar","ee Dilepton Mass (Targeted)",200,0,200);
h_mll_ee_tar->SetDirectory(rootdir);
h_mll_ee_tar->Sumw2();
TH1F* h_mll_mumu_tar = new TH1F("h_mll_mumu_tar","MuMu Dilepton Mass (Targeted)",200,0,200);
h_mll_mumu_tar->SetDirectory(rootdir);
h_mll_mumu_tar->Sumw2();
TH1F* h_met_ee_inc = new TH1F("h_met_ee_inc","ee MET (Inclusive)",350,0,350);//350,0,350 for all met histos
h_met_ee_inc->SetDirectory(rootdir);
h_met_ee_inc->Sumw2();
TH1F* h_met_mumu_inc = new TH1F("h_met_mumu_inc","mumu MET (Inclusive)",350,0,350);
h_met_mumu_inc->SetDirectory(rootdir);
h_met_mumu_inc->Sumw2();
TH2F* h_met_ll_inc = new TH2F("h_met_ll_inc","ee+mumu MET (Inclusive)",700,-350,350,700,-350,350);//positive and negative met. 2D!
h_met_ll_inc->SetDirectory(rootdir);
h_met_ll_inc->Sumw2();
TH2F* h_met_emu2_inc = new TH2F("h_met_emu2_inc","emu MET (Inclusive)",700,-350,350,700,-350,350);//positive and negative met. 2D!
h_met_emu2_inc->SetDirectory(rootdir);
h_met_emu2_inc->Sumw2();
TH1F* h_met_emu_inc = new TH1F("h_met_emu_inc","emu MET (Inclusive)",350,0,350);
h_met_emu_inc->SetDirectory(rootdir);
h_met_emu_inc->Sumw2();
TH1F* h_met_ee_tar_njets0 = new TH1F("h_met_ee_tar_njets0","ee MET (Targeted, no jets)",350,0,350);
h_met_ee_tar_njets0->SetDirectory(rootdir);
h_met_ee_tar_njets0->Sumw2();
TH1F* h_met_mumu_tar_njets0 = new TH1F("h_met_mumu_tar_njets0","mumu MET (Targeted, no jets)",350,0,350);
h_met_mumu_tar_njets0->SetDirectory(rootdir);
h_met_mumu_tar_njets0->Sumw2();
TH2F* h_met_ll_tar_njets0 = new TH2F("h_met_ll_tar_njets0","ee+mumu MET (Targeted, no jets)",700,-350,350,700,-350,350);//positive and negative met. 2D!
h_met_ll_tar_njets0->SetDirectory(rootdir);
h_met_ll_tar_njets0->Sumw2();
TH2F* h_met_emu2_tar_njets0 = new TH2F("h_met_emu2_tar_njets0","emu MET (Targeted, no jets)",700,-350,350,700,-350,350);//positive and negative met. 2D!
h_met_emu2_tar_njets0->SetDirectory(rootdir);
h_met_emu2_tar_njets0->Sumw2();
TH1F* h_met_emu_tar_njets0 = new TH1F("h_met_emu_tar_njets0","emu MET (Targeted, no jets)",350,0,350);
h_met_emu_tar_njets0->SetDirectory(rootdir);
h_met_emu_tar_njets0->Sumw2();
TH1F* h_met_ee_tar_njets2 = new TH1F("h_met_ee_tar_njets2","ee MET (Targeted, njets >= 2)",350,0,350);
h_met_ee_tar_njets2->SetDirectory(rootdir);
h_met_ee_tar_njets2->Sumw2();
TH1F* h_met_mumu_tar_njets2 = new TH1F("h_met_mumu_tar_njets2","mumu MET (Targeted, njets >= 2)",350,0,350);
h_met_mumu_tar_njets2->SetDirectory(rootdir);
h_met_mumu_tar_njets2->Sumw2();
TH2F* h_met_ll_tar_njets2 = new TH2F("h_met_ll_tar_njets2","ee+mumu MET (Targeted, njets >= 2)",700,-350,350,700,-350,350);//positive and negative met. 2D!
h_met_ll_tar_njets2->SetDirectory(rootdir);
h_met_ll_tar_njets2->Sumw2();
TH2F* h_met_emu2_tar_njets2 = new TH2F("h_met_emu2_tar_njets2","emu MET (Targeted, njets >= 2)",700,-350,350,700,-350,350);//positive and negative met. 2D!
h_met_emu2_tar_njets2->SetDirectory(rootdir);
h_met_emu2_tar_njets2->Sumw2();
TH1F* h_met_emu_tar_njets2 = new TH1F("h_met_emu_tar_njets2","emu MET (Targeted, njets >= 2)",350,0,350);
h_met_emu_tar_njets2->SetDirectory(rootdir);
h_met_emu_tar_njets2->Sumw2();
TH1F* h_nvtx_scaled= new TH1F("h_nvtx_scaled","Number of Vertices (scaled)",35,0,35);
h_nvtx_scaled->SetDirectory(rootdir);
h_nvtx_scaled->Sumw2();
TH1F* h_nvtx_unscaled= new TH1F("h_nvtx_unscaled","Number of Vertices (unscaled)",35,0,35);
h_nvtx_unscaled->SetDirectory(rootdir);
h_nvtx_unscaled->Sumw2();
TH1F* h_phi= new TH1F("h_phi","phi distribution",40,-TMath::Pi(),TMath::Pi());
h_phi->SetDirectory(rootdir);
h_phi->Sumw2();
//-------
//.........这里部分代码省略.........
示例14: ScanChain
int ScanChain( TChain* chain, bool fast = true, int nEvents = -1, string skimFilePrefix = "test") {
int version = 4;
// Benchmark
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
// Example Histograms
TDirectory *rootdir = gDirectory->GetDirectory("Rint:");
map<string, TH1F*> histos;
vector<string> histonames; histonames.clear();
int nbins = 9; float blow = 0.5; float bup = 9.5; bool storeh = true;
if(version== 1){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version== 2){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version== 3){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version== 4){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version== 5){ nbins = 6; blow = 0.5; bup = 6.5; storeh = true; }
if(version== 6){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version== 7){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version== 8){ nbins = 7; blow = 0.5; bup = 7.5; storeh = true; }
if(version== 9){ nbins = 7; blow = 0.5; bup = 7.5; storeh = true; }
if(version==10){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version==11){ nbins = 6; blow = 0.5; bup = 6.5; storeh = true; }
if(version==12){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version==13){ nbins = 6; blow = 0.5; bup = 6.5; storeh = true; }
if(version==14){ nbins = 8; blow = 0.5; bup = 8.5; storeh = true; }
if(version==15){ nbins = 5; blow = 0.5; bup = 5.5; storeh = true; }
if(version==16){ nbins = 9; blow = 0.5; bup = 9.5; storeh = true; }
if(version==17){ nbins = 11; blow = 0.5; bup = 11.5; storeh = true; }
//AllBGCorr
//CorrName1Name2Name3 with NameX being sampleX
//CorrAllBG CorrAll means correlated among all backgrounds, or everything (bg+sig)
histonames.push_back("SRyield");
histonames.push_back("CRyield");
histonames.push_back("StatUnc");
histonames.push_back("SystUnc");
for(unsigned int b = 0; b<2; ++b){
string samplename = skimFilePrefix;
TString helper = TString(samplename);
//cout << helper << endl;
if(skimFilePrefix!="TTbar"&&b>0) continue;
if(skimFilePrefix=="TTbar"&&b==0) samplename = "TTbar1l";
if(skimFilePrefix=="TTbar"&&b==1) samplename = "TTbar2l";
if(skimFilePrefix=="TTbar"&&b==2) samplename = "TTbarH";
string mapname;
for(unsigned int i = 0; i<histonames.size();++i){
mapname = histonames[i] + "_" + samplename;
//cout << mapname << " " << nbins << " " << blow << " " << bup << endl;
if(histos.count(mapname) == 0 ) histos[mapname] = new TH1F(mapname.c_str(), "", nbins, blow, bup);
histos[mapname]->Sumw2(); histos[mapname]->SetDirectory(rootdir);
//cout << mapname << endl;
//cout << mapname << endl;
}
}
// Loop over events to Analyze
unsigned int nEventsTotal = 0;
unsigned int nEventsChain = chain->GetEntries();
if( nEvents >= 0 ) nEventsChain = nEvents;
TObjArray *listOfFiles = chain->GetListOfFiles();
TIter fileIter(listOfFiles);
TFile *currentFile = 0;
// File Loop
while ( (currentFile = (TFile*)fileIter.Next()) ) {
// Get File Content
TFile *file = new TFile( currentFile->GetTitle() );
TTree *tree = (TTree*)file->Get("t");
if(fast) TTreeCache::SetLearnEntries(10);
if(fast) tree->SetCacheSize(128*1024*1024);
cms3.Init(tree);
// Loop over Events in current file
if( nEventsTotal >= nEventsChain ) continue;
unsigned int nEventsTree = tree->GetEntriesFast();
for( unsigned int event = 0; event < nEventsTree; ++event) {
// Get Event Content
if( nEventsTotal >= nEventsChain ) continue;
if(fast) tree->LoadTree(event);
cms3.GetEntry(event);
++nEventsTotal;
// Progress
CMS3::progress( nEventsTotal, nEventsChain );
string samplename = skimFilePrefix;
if(skimFilePrefix=="TTbar"){
if(genlepsfromtop() ==2) samplename = "TTbar2l";
else if(genlepsfromtop() ==1) samplename = "TTbar1l";
else { samplename = "TTbarH"; continue; }// cout << "no gen lep" << " " << genlepsfromtop() << endl; }
}
TString helper = TString(samplename);
/*if(helper.Contains("Signal")){
if(helper.Contains("T2tt")){
//.........这里部分代码省略.........
示例15: ScanChain
int ScanChain( TChain* chain, bool fast = true, int nEvents = -1, string skimFilePrefix = "test") {
// Benchmark
TBenchmark *bmark = new TBenchmark();
bmark->Start("benchmark");
////////////////////////////////////////////////////////////////////////////////////////////
int mt2_l_bin = 0;
int mt2_h_bin = 200;
int mt2_n_bin = 20;
int mt_l_bin = 0;
int mt_h_bin = 300;
int mt_n_bin = 30;
int met_l_bin = 0;
int met_h_bin = 225;
int met_n_bin = 45;
int jet_n_bin = 10;
int jet_h_bin = 10;
TH1F *fake_wpt_h = new TH1F("fake_w_pt_","fake_W_pt",50,0,100);
TH1F *landau_h = new TH1F("landau_h_","landau_H",60,0,mt_h_bin);
TH1F *gammaM_h = new TH1F("gammaM_","gamma",120,1,6);
TH1F *mt2_h_data = new TH1F("mt2_data_","MT2_data",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_data = new TH1F("mt_data_", "MT_data",mt_n_bin,0,mt_h_bin);
TH1F *met_data = new TH1F("met_data_","met_data",met_n_bin,0,met_h_bin);
TH1F *jets_data= new TH1F("jets_data_","Jets_data",jet_n_bin,0,jet_h_bin);
TH1F *data_w_pt = new TH1F("data_w_pt_","data_W_pt",60,0,mt_h_bin);
TH1F *data_lep_pt = new TH1F("data_lep_pt_","data_Lep_pt",60,0,mt_h_bin);
TH1F *mt2_h_ttbar = new TH1F("mt2_ttbar_","MT2_ttbar",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_ttbar = new TH1F("mt_ttbar_", "MT_ttbar",mt_n_bin,0,mt_h_bin);
TH1F *met_ttbar = new TH1F("met_ttbar_","met_ttbar",met_n_bin,0,met_h_bin);
TH1F *jets_ttbar = new TH1F("jets_ttbar_","Jets_ttbar",jet_n_bin,0,jet_h_bin);
TH1F *ttbar_w_pt = new TH1F("ttbar_w_pt_","ttbar_W_pt",60,0,mt_h_bin);
TH1F *ttbar_lep_pt = new TH1F("ttbar_lep_pt_","ttbar_Lep_pt",60,0,mt_h_bin);
TH1F *mt2_h_wjets = new TH1F("mt2_wjets_","MT2_wjets",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_wjets = new TH1F("mt_wjets_", "MT_wjets",mt_n_bin,0,mt_h_bin);
TH1F *met_wjets = new TH1F("met_wjets_","met_wjets",met_n_bin,0,met_h_bin);
TH1F *jets_wjets = new TH1F("jets_wjets_","Jets_wjets",jet_n_bin,0,jet_h_bin);
TH1F *wjets_w_pt = new TH1F("wjets_w_pt_","wjets_W_pt",60,0,mt_h_bin);
TH1F *wjets_lep_pt = new TH1F("wjets_lep_pt_","wjets_Lep_pt",60,0,mt_h_bin);
wjets_lep_pt->SetLineColor(kRed);
data_lep_pt->SetLineColor(kYellow);
ttbar_lep_pt->SetLineColor(kCyan);
wjets_lep_pt->SetLineWidth(4);
data_lep_pt->SetLineWidth(4);
ttbar_lep_pt->SetLineWidth(4);
////MUONS////
TH1F *mt2_h_data_mu = new TH1F("mt2_data_mu_","MT2_data_mu",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_data_mu = new TH1F("mt_data_mu_", "MT_data_mu",mt_n_bin,0,mt_h_bin);
TH1F *met_data_mu = new TH1F("met_data_mu_","met_data_mu",met_n_bin,0,met_h_bin);
TH1F *jets_data_mu= new TH1F("jets_data_mu_","Jets_data_mu",jet_n_bin,0,jet_h_bin);
TH1F *data_w_pt_mu = new TH1F("data_w_pt_mu_","data_W_pt_mu",60,0,mt_h_bin);
TH1F *data_lep_pt_mu = new TH1F("data_lep_pt_mu_","data_Lep_pt_mu",60,0,mt_h_bin);
TH1F *mt2_h_ttbar_mu = new TH1F("mt2_ttbar_mu_","MT2_ttbar_mu",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_ttbar_mu = new TH1F("mt_ttbar_mu_", "MT_ttbar_mu",mt_n_bin,0,mt_h_bin);
TH1F *met_ttbar_mu = new TH1F("met_ttbar_mu_","met_ttbar_mu",met_n_bin,0,met_h_bin);
TH1F *jets_ttbar_mu = new TH1F("jets_ttbar_mu_","Jets_ttbar_mu",jet_n_bin,0,jet_h_bin);
TH1F *ttbar_w_pt_mu = new TH1F("ttbar_w_pt_mu_","ttbar_W_pt_mu",60,0,mt_h_bin);
TH1F *ttbar_lep_pt_mu = new TH1F("ttbar_lep_pt_mu_","ttbar_Lep_pt_mu",60,0,mt_h_bin);
TH1F *mt2_h_wjets_mu = new TH1F("mt2_wjets_mu_","MT2_wjets_mu",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_wjets_mu = new TH1F("mt_wjets_mu_", "MT_wjets_mu",mt_n_bin,0,mt_h_bin);
TH1F *met_wjets_mu = new TH1F("met_wjets_mu_","met_wjets_mu",met_n_bin,0,met_h_bin);
TH1F *jets_wjets_mu = new TH1F("jets_wjets_mu_","Jets_wjets_mu",jet_n_bin,0,jet_h_bin);
TH1F *wjets_w_pt_mu = new TH1F("wjets_w_pt_mu_","wjets_W_pt_mu",60,0,mt_h_bin);
TH1F *wjets_lep_pt_mu = new TH1F("wjets_lep_pt_mu_","wjets_Lep_pt_mu",60,0,mt_h_bin);
////ELECTRONS////
TH1F *mt2_h_data_el = new TH1F("mt2_data_el_","MT2_data_el",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_data_el = new TH1F("mt_data_el_", "MT_data_el",mt_n_bin,0,mt_h_bin);
TH1F *met_data_el = new TH1F("met_data_el_","met_data_el",met_n_bin,0,met_h_bin);
TH1F *jets_data_el= new TH1F("jets_data_el_","Jets_data_el",jet_n_bin,0,jet_h_bin);
TH1F *data_w_pt_el = new TH1F("data_w_pt_el_","data_W_pt_el",60,0,mt_h_bin);
TH1F *data_lep_pt_el = new TH1F("data_lep_pt_el_","data_Lep_pt_el",60,0,mt_h_bin);
TH1F *mt2_h_ttbar_el = new TH1F("mt2_ttbar_el_","MT2_ttbar_el",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_ttbar_el = new TH1F("mt_ttbar_el_", "MT_ttbar_el",mt_n_bin,0,mt_h_bin);
TH1F *met_ttbar_el = new TH1F("met_ttbar_el_","met_ttbar_el",met_n_bin,0,met_h_bin);
TH1F *jets_ttbar_el = new TH1F("jets_ttbar_el_","Jets_ttbar_el",jet_n_bin,0,jet_h_bin);
TH1F *ttbar_w_pt_el = new TH1F("ttbar_w_pt_el_","ttbar_W_pt_el",60,0,mt_h_bin);
TH1F *ttbar_lep_pt_el = new TH1F("ttbar_lep_pt_el_","ttbar_Lep_pt_el",60,0,mt_h_bin);
TH1F *mt2_h_wjets_el = new TH1F("mt2_wjets_el_","MT2_wjets_el",mt2_n_bin,0,mt2_h_bin);
TH1F *mt_h_wjets_el = new TH1F("mt_wjets_el_", "MT_wjets_el",mt_n_bin,0,mt_h_bin);
TH1F *met_wjets_el = new TH1F("met_wjets_el_","met_wjets_el",met_n_bin,0,met_h_bin);
TH1F *jets_wjets_el = new TH1F("jets_wjets_el_","Jets_wjets_el",jet_n_bin,0,jet_h_bin);
TH1F *wjets_w_pt_el = new TH1F("wjets_w_pt_el_","wjets_W_pt_el",60,0,mt_h_bin);
TH1F *wjets_lep_pt_el = new TH1F("wjets_lep_pt_el_","wjets_Lep_pt_el",60,0,mt_h_bin);
/*
TFile* f1 = new TFile("/home/users/sanil/single/may15hists/data_w_pt.root");
TH1F* wp_dist = (TH1F*) f1->Get("w_pt_"); //
//.........这里部分代码省略.........