本文整理汇总了C++中TChain::GetEntries方法的典型用法代码示例。如果您正苦于以下问题:C++ TChain::GetEntries方法的具体用法?C++ TChain::GetEntries怎么用?C++ TChain::GetEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TChain
的用法示例。
在下文中一共展示了TChain::GetEntries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: splitStopSamples
//.........这里部分代码省略.........
// T2bw 50 R2
// mg.push_back(350); ml.push_back(0);
// mg.push_back(375); ml.push_back(50);
// mg.push_back(400); ml.push_back(100);
// T2bw 50 R3
// mg.push_back(450); ml.push_back(0);
// mg.push_back(500); ml.push_back(50);
// mg.push_back(550); ml.push_back(100);
// T2bw 25 R2
// mg.push_back(400); ml.push_back(0);
// mg.push_back(500); ml.push_back(100);
// mg.push_back(600); ml.push_back(200);
// T2bw 25 R3
mg.push_back(500); ml.push_back(0);
mg.push_back(550); ml.push_back(50);
mg.push_back(600); ml.push_back(100);
// cut-and-count T2tt
// mg.push_back(600); ml.push_back(25);
// mg.push_back(500); ml.push_back(200);
// mg.push_back(300); ml.push_back(100);
// R4
// mg.push_back(200); ml.push_back(100);
// mg.push_back(300); ml.push_back(200);
// mg.push_back(400); ml.push_back(300);
// R4
// mg.push_back(550); ml.push_back(25);
// mg.push_back(650); ml.push_back(50);
// mg.push_back(750); ml.push_back(100);
// R3
// mg.push_back(500); ml.push_back(100);
// mg.push_back(600); ml.push_back(200);
// mg.push_back(650); ml.push_back(250);
// R2
// mg.push_back(350); ml.push_back(75);
// mg.push_back(400); ml.push_back(125);
// mg.push_back(450); ml.push_back(175);
// R1
//mg.push_back(250); ml.push_back(25);
//mg.push_back(300); ml.push_back(25);
//mg.push_back(300); ml.push_back(75);
const unsigned int npoints = mg.size();
//-------------------------------------
// skim grid points
//-------------------------------------
TFile *file[npoints];
TTree *tree[npoints];
TChain* pretest = new TChain("t");
TChain* posttest = new TChain("t");
for( unsigned int i = 0 ; i < npoints ; ++i ){
//char* filename = Form("%s/T2ttPoint_%i_%i.root",path,mg.at(i),ml.at(i));
//char* filename = Form("%s/T2bw75Point_%i_%i.root",path,mg.at(i),ml.at(i));
//char* filename = Form("%s/T2bw50Point_%i_%i.root",path,mg.at(i),ml.at(i));
char* filename = Form("%s/T2bw25Point_%i_%i.root",path,mg.at(i),ml.at(i));
TCut cut(Form("mg==%i && ml==%i",mg.at(i),ml.at(i)));
cout << endl;
cout << "Skimming input file : " << infilename << endl;
cout << "Using selection : " << cut.GetTitle() << endl;
cout << "Skim filename : " << filename << endl;
file[i] = TFile::Open(filename, "RECREATE");
assert( file[i] != 0 );
tree[i] = chain->CopyTree( cut );
tree[i]->Write();
file[i]->Close();
pretest->Add(infilename);
posttest->Add(filename);
cout << "Pre total : " << pretest->GetEntries() << endl;
cout << "Pre skim : " << pretest->GetEntries(cut) << endl;
cout << "Post total : " << posttest->GetEntries() << endl;
cout << "Post skim : " << posttest->GetEntries(cut) << endl;
pretest->Reset();
posttest->Reset();
}
}
示例2: makeBSM_MCFM_single
//.........这里部分代码省略.........
tree->SetBranchAddress("GenZZMass", &GenHMass);
tree->SetBranchAddress("GenLep1Id", &GenLep1Id);
tree->SetBranchAddress("GenLep2Id", &GenLep2Id);
tree->SetBranchAddress("GenLep3Id", &GenLep3Id);
tree->SetBranchAddress("GenLep4Id", &GenLep4Id);
tree->SetBranchAddress("GenLep1Pt", &GenLep1Pt);
tree->SetBranchAddress("GenLep2Pt", &GenLep2Pt);
tree->SetBranchAddress("GenLep3Pt", &GenLep3Pt);
tree->SetBranchAddress("GenLep4Pt", &GenLep4Pt);
tree->SetBranchAddress("GenLep1Phi", &GenLep1Phi);
tree->SetBranchAddress("GenLep2Phi", &GenLep2Phi);
tree->SetBranchAddress("GenLep3Phi", &GenLep3Phi);
tree->SetBranchAddress("GenLep4Phi", &GenLep4Phi);
tree->SetBranchAddress("GenLep1Eta", &GenLep1Eta);
tree->SetBranchAddress("GenLep2Eta", &GenLep2Eta);
tree->SetBranchAddress("GenLep3Eta", &GenLep3Eta);
tree->SetBranchAddress("GenLep4Eta", &GenLep4Eta);
tree->SetBranchAddress("GenLep1E", &GenLep1E);
tree->SetBranchAddress("GenLep2E", &GenLep2E);
tree->SetBranchAddress("GenLep3E", &GenLep3E);
tree->SetBranchAddress("GenLep4E", &GenLep4E);
if (tFitD != 0){
if (tree->GetBranchStatus(strFitDim[tFitD])){
tree->SetBranchAddress("Dgg10_VAMCFM", &fitYval);
templateTree->Branch(strFitDim[tFitD], &fitYval);
}
else{
cerr << "Could NOT find branch named " << strFitDim[tFitD] << "!!! Setting strFitDim[" << tFitD << "] = 0." << endl;
fitYval = 0;
}
}
nEntries = tree->GetEntries();
double xsec = 1./nEntries;
if (t==0) xsec *= xsec_ggHZZ_MCFM[EnergyIndex];
else if (t==1) xsec *= xsec_ggZZ_MCFM[EnergyIndex];
else if (t==2) xsec *= xsec_ggHZZ_BSI_MCFM[EnergyIndex];
else if (t==3) xsec *= xsec_ggHZZ_BSI25_MCFM[EnergyIndex];
else xsec = 1;
if (folder<2) xsec *= 0.25;
else xsec *= 0.5;
// for (int ev = 0; ev < 100; ev++){
for (int ev = 0; ev < nEntries; ev++){
tree->GetEntry(ev);
ZZMass = GenHMass;
MC_weight = xsec;
if (fitYval != fitYval) continue;
// Protect against any KD exceeding boundaries
if (tFitD!=0 && fitYval>=1){
cout << "Found fitYval == " << fitYval;
fitYval = 0.999;
cout << ". Fixed to " << fitYval << endl;
}
if (tFitD!=0 && fitYval<0) fitYval = 0;
if (t < 4 && erg_tev==7){
if (folder==1){
GenLep1Id=11;
GenLep2Id=-11;
GenLep3Id=11;
GenLep4Id=-11;
}
示例3: makeTable
void makeTable(int nbins = 40, const string label = "HFhits", const char * tag = "Preliminary_NoEffCor_AMPT_d1107", const char* dataset = "DATA"){
bool DATA = false;
bool SIM = true;
bool MC = false;
double EFF = 1;
double MXS = 1. - EFF;
// Retrieving data
int maxEvents = -200;
vector<int> runnums;
// const char* infileName = Form("/net/hisrv0001/home/yetkin/hidsk0001/analysis/prod/%s_RECO_391/test.root",dataset);
const char* infileName = Form("/net/hisrv0001/home/yetkin/hidsk0001/centrality/prod/%s/test.root",dataset);
// TFile* infile = new TFile(infileName,"read");
TChain* t = new TChain("HltTree");
// TChain* t = new TChain("hltanalysis/HltTree");
t->Add(infileName);
// Creating output table
TFile* outFile = new TFile("tables_d1108.root","update");
TDirectory* dir = outFile->mkdir(tag);
dir->cd();
TNtuple* nt = new TNtuple("nt","","hf:bin:b:npart:ncoll:nhard");
CentralityBins* bins = new CentralityBins("noname","Test tag", nbins);
bins->table_.reserve(nbins);
TH1D::SetDefaultSumw2();
int runMC = 1;
TFile * inputMCfile;
CentralityBins* inputMCtable;
if(DATA){
inputMCfile = new TFile("tables_d1103.root","read");
inputMCtable = (CentralityBins*)inputMCfile->Get("CentralityTable_HFhits40_AMPT2760GeV_v1_mc_MC_38Y_V12/run1");
}
// Setting up variables & branches
double binboundaries[nbinsMax+1];
vector<float> values;
float b,npart,ncoll,nhard,hf,hfhit,eb,ee,etmr,parameter;
int npix,ntrks;
// TTree* t = (TTree*)infile->Get("HltTree");
int run;
if(SIM){
t->SetBranchAddress("b",&b);
t->SetBranchAddress("Npart",&npart);
t->SetBranchAddress("Ncoll",&ncoll);
t->SetBranchAddress("Nhard",&nhard);
}
t->SetBranchAddress("hiHFhit",&hfhit);
t->SetBranchAddress("hiHF",&hf);
t->SetBranchAddress("hiEB",&eb);
t->SetBranchAddress("hiEE",&ee);
t->SetBranchAddress("hiET",&etmr);
t->SetBranchAddress("hiNpix",&npix);
t->SetBranchAddress("hiNtracks",&ntrks);
t->SetBranchAddress("Run",&run);
bool binNpart = label.compare("Npart") == 0;
bool binNcoll = label.compare("Ncoll") == 0;
bool binNhard = label.compare("Nhard") == 0;
bool binB = label.compare("b") == 0;
bool binHF = label.compare("HFtowers") == 0;
bool binHFhit = label.compare("HFhits") == 0;
bool binEB = label.compare("EB") == 0;
bool binEE = label.compare("EE") == 0;
bool binETMR = label.compare("ETMR") == 0;
bool binNpix = label.compare("PixelHits") == 0;
bool binNtrks = label.compare("Ntracks") == 0;
// Determining bins of cross section
// loop over events
unsigned int events=t->GetEntries();
for(unsigned int iev = 0; iev < events && (maxEvents < 0 || iev< maxEvents); ++iev){
if( iev % 100 == 0 ) cout<<"Processing event : "<<iev<<endl;
t->GetEntry(iev);
if(binNpart) parameter = npart;
if(binNcoll) parameter = ncoll;
if(binNhard) parameter = nhard;
if(binB) parameter = b;
if(binHF) parameter = hf;
if(binHFhit) parameter = hfhit;
if(binEB) parameter = eb;
if(binEE) parameter = ee;
if(binETMR) parameter = etmr;
if(binNpix) parameter = npix;
if(binNtrks) parameter = ntrks;
values.push_back(parameter);
if(runnums.size() == 0 || runnums[runnums.size()-1] != run) runnums.push_back(run);
}
//.........这里部分代码省略.........
示例4: mergeDATA
void mergeDATA(TString Tree="/afs/cern.ch/work/s/shuai/public/diboson/trees/productionv7_newMJ/fullallrange")
{
TFile * outputfile = new TFile(Tree+"/treeEDBR_data_xww.root","RECREATE");
TString treename;
treename = "SelectedCandidates";
TChain * chain_SingleEle = new TChain(treename);
TChain * chain_SingleMu = new TChain(treename);
/*
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012A_13Jul2012_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012A_recover_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012B_13Jul2012_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012C_24Aug2012_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012C_EcalRecove_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012C_PromptReco_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012D_PromptReco_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012A_13Jul2012_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012A_recover_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012B_13Jul2012_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012C_24Aug2012_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012C_EcalRecove_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012C_PromptReco_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012D_PromptReco_xww.root");
*/
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012A-22Jan2013_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012B-22Jan2013_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012C-22Jan2013_xww.root");
chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012D-22Jan2013_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012A-22Jan2013_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012B-22Jan2013_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012C-22Jan2013_xww.root");
chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012D-22Jan2013_xww.root");
TChain * chain = new TChain(treename);
chain->Add(chain_SingleEle);
int nele = chain->GetEntries();
chain->Add(chain_SingleMu);
int ntotal = chain->GetEntries();
int nmu = ntotal - nele;
cout<<"ele entries: "<<nele<<endl;
cout<<"mu entries: "<<nmu<<endl;
cout<<"ele+mu entries: "<<ntotal<<endl;
TTree * outTree = chain->CloneTree(0);
double lep[99];
int nLooseEle;
int nLooseMu;
chain->SetBranchAddress("lep", lep);
chain->SetBranchAddress("nLooseMu", &nLooseMu);
chain->SetBranchAddress("nLooseEle",&nLooseEle);
//fill only lep==0 for SingEle
for(int i=0; i<nele; i++)
{
chain->GetEntry(i);
if(nLooseEle+nLooseMu!=1)continue;
if(lep[0]==0)outTree->Fill();
}
//fill only lep==1 for SingMu
for(int i=nele; i<ntotal; i++)
{
chain->GetEntry(i);
if(nLooseEle+nLooseMu!=1)continue;
if(lep[0]==1)outTree->Fill();
}
cout<<"output entries: "<<outTree->GetEntries()<<endl;
outputfile->cd();
outTree->Write();
outputfile->Close();
}
示例5: InConeLeadFrag_AJ
void InConeLeadFrag_AJ(
//TString algo="akpu3pf"
TString algo="icpu5"
)
{
TH1::SetDefaultSumw2();
TString infnamedata = Form("histntff_tv1data_%s_cv3.root",algo.Data());
TString infnamemc = Form("histntff_tv1mc80_%s_cv3.root",algo.Data());
TCut evtSel;
if (algo=="akpu3pf")
evtSel = "cent<20&&jtpt[0]>90&&jtpt[1]>40&&abs(jteta[0])<1.6&&abs(jteta[1])<1.6&&abs(jdphi)>2.09";
if (algo=="icpu5")
evtSel = "cent<20&&jtpt[0]>120&&jtpt[1]>50&&abs(jteta[0])<1.6&&abs(jteta[1])<1.6&&abs(jdphi)>2.09";
TChain * tdata = new TChain("tjfrRec");
tdata->Add(infnamedata);
TChain * tmc = new TChain("tjfrRec");
tmc->Add(infnamemc);
cout << "Cut: " << TString(evtSel) << endl;
cout << infnamedata << " " << tdata->GetEntries(evtSel) << endl;
cout << infnamemc << " " << tmc->GetEntries(evtSel) << endl;
TProfile * hLFJ1Data = new TProfile("hLFJ1Data","",5,0,0.5);
TProfile * hLFJ1Mc = new TProfile("hLFJ1Mc","",5,0,0.5);
TProfile * hLFJ2Data = new TProfile("hLFJ2Data","",5,0,0.5);
TProfile * hLFJ2Mc = new TProfile("hLFJ2Mc","",5,0,0.5);
cout << "========== LF ana ==========" << endl;
TCut jet1Sel = evtSel&&"clppt[0]>0";
TCut jet2Sel = evtSel&&"clppt[1]>0";
cout << "Cut: " << TString(jet1Sel) << endl;
cout << infnamedata << " " << tdata->GetEntries(jet1Sel) << endl;
cout << infnamemc << " " << tmc->GetEntries(jet1Sel) << endl;
cout << "Cut: " << TString(jet2Sel) << endl;
cout << infnamedata << " " << tdata->GetEntries(jet2Sel) << endl;
cout << infnamemc << " " << tmc->GetEntries(jet2Sel) << endl;
tdata->Project("hLFJ1Data","clppt[0]/jtpt[0]:Aj",jet1Sel*"cltrkwt","prof");
tmc->Project("hLFJ1Mc","clppt[0]/jtpt[0]:Aj",jet1Sel*"cltrkwt","prof");
tdata->Project("hLFJ2Data","clppt[1]/jtpt[1]:Aj",jet2Sel*"cltrkwt","prof");
tmc->Project("hLFJ2Mc","clppt[1]/jtpt[1]:Aj",jet2Sel*"cltrkwt","prof");
TCanvas * c2 = new TCanvas("c2","c2",500,500);
hLFJ1Mc->SetAxisRange(0,0.3,"Y");
hLFJ1Mc->SetTitle(";A_{J};<z^{lead}>=<p_{T}^{Leading Trk}/p_{T}^{Jet}>;");
hLFJ1Mc->GetXaxis()->CenterTitle();
hLFJ1Mc->GetYaxis()->CenterTitle();
hLFJ1Mc->SetLineColor(kRed);
hLFJ1Mc->SetLineStyle(2);
hLFJ2Mc->SetLineColor(kRed);
hLFJ1Data->SetMarkerStyle(kOpenCircle);
hLFJ1Mc->Draw("hist");
hLFJ2Mc->Draw("samehist");
hLFJ1Data->Draw("sameE");
hLFJ2Data->Draw("sameE");
TLegend *leg = new TLegend(0.18,0.18,0.68,0.38);
leg->SetFillStyle(0);
leg->SetBorderSize(0);
leg->SetTextSize(0.035);
leg->AddEntry(hLFJ1Data,"0-20%, "+algo,"");
leg->AddEntry(hLFJ1Data,"Data J1","p");
leg->AddEntry(hLFJ2Data,"Data J2","p");
leg->AddEntry(hLFJ1Mc,"PYTHIA+HYDJET J1","l");
leg->AddEntry(hLFJ2Mc,"PYTHIA+HYDJET J2","l");
leg->Draw();
c2->Print(Form("InConeLeadingFragment_vs_AJ_%s.gif",algo.Data()));
}
示例6: run_TSelector_SusyNtuple_excess_n0150_Egamma_L
void run_TSelector_SusyNtuple_excess_n0150_Egamma_L() {
// TString options = TString(""); //TString(tag.c_str()) ;
// // TString outputfile = "test.root";
// string richtigerString = InputPath;
// // int Position = richtigerString.find("mc12_8TeV.");
// // outputfile = "histos_ZTauTau_" + richtigerString.substr(Position+10,6) + "_proof.root";
//
// int Position = -1;
// Position = richtigerString.find("45_bg");
// if (Position>0){
// outputfile = "histos_test_" + richtigerString.substr(Position+6,2) + ".root";
// }
// else{
// Position = richtigerString.find("45_signal");
// if (Position>0){
// outputfile = "histos_test_" + richtigerString.substr(Position+3,2) + ".root";
// }
// }
// if(outputfile == ""){
// cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
// cout << "EMPTY OUPTPUTFILE STRING" << endl;
// cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
// abort();
// }
// cout << "outputfile= " << outputfile << endl;
cout<<"Have you set up RootCore via \"source RootCore/scripts/setup.sh\" ?"<<endl;
gSystem->Setenv("ROOTCOREDIR", "/data/etp3/jwittkow/analysis_SUSYTools_03_04_SusyNt_01_16/RootCore");
gSystem->SetIncludePath("-I$ROOTCOREDIR/include/");
gROOT->ProcessLine(".x $ROOTCOREDIR/scripts/load_packages.C+");
TString selectorName = "TSelector_SusyNtuple_excess"; // !!! enter the name of your Selector (without _C.so)
TChain *ch;
ch = new TChain("susyNt");
TString processLine = ".L " + selectorName + ".cpp++g";
TString execLine;
gROOT->ProcessLine(processLine); // need to add this, or PoD at LRZ will not be able to load the .so
gROOT->ProcessLine(".x $ROOTCOREDIR/scripts/load_packages.C+");
// ch->Add(InputPath);
// ch->Add("/nobackup/etp2/Josephine.Wittkowski/SusyNtuples_n0150/WH/user.gerbaudo.mc12_8TeV.177501.Herwigpp_sM_wA_noslep_notauhad_WH_2Lep_1.SusyNt.e2149_s1581_s1586_r3658_r3549_p1512_n0150.140109072637/*");
ch->Add("/nobackup/etp2/Josephine.Wittkowski/SusyNtuples_n0150/Egamma/user.gerbaudo.group.phys-susy.data12_8TeV.periodL.physics_Egamma.PhysCont.SusyNt.t0pro14_v01_p1542_n0150.131226172851/*");
ch->Add("/nobackup/etp2/Josephine.Wittkowski/SusyNtuples_n0150/Egamma/user.gerbaudo.group.phys-susy.data12_8TeV.periodL.physics_Egamma.PhysCont.SusyNt.t0pro14_v01_p1542_n0150.131226172939/*");
ch->Add("/nobackup/etp2/Josephine.Wittkowski/SusyNtuples_n0150/Egamma/user.gerbaudo.group.phys-susy.data12_8TeV.periodL.physics_Egamma.PhysCont.SusyNt.t0pro14_v01_p1542_n0150.131226173027/*");
ch->Add("/nobackup/etp2/Josephine.Wittkowski/SusyNtuples_n0150/Egamma/user.gerbaudo.group.phys-susy.data12_8TeV.periodL.physics_Egamma.PhysCont.SusyNt.t0pro14_v01_p1542_n0150.131226173125/*");
ch->Add("/nobackup/etp2/Josephine.Wittkowski/SusyNtuples_n0150/Egamma/user.gerbaudo.group.phys-susy.data12_8TeV.periodL.physics_Egamma.PhysCont.SusyNt.t0pro14_v01_p1542_n0150.131226212707/*");
Long64_t nEntries = ch->GetEntries();
ch->ls();
cout << "all entries: " << nEntries << endl;
TSelector_SusyNtuple_excess* SusyNtupleObject = new TSelector_SusyNtuple_excess();
SusyNtupleObject->buildSumwMap(ch);
// TString options="NtSys_NOM";
ch->Process(SusyNtupleObject);
delete SusyNtupleObject;
if (ch) {delete ch; ch=0;}
abort();
}
开发者ID:JosephineWittkowski,项目名称:WH_analysis_TSelector,代码行数:78,代码来源:run_TSelector_SusyNtuple_excess_n0150_Egamma_L.C
示例7: builtVetoCal
void builtVetoCal(string Input = ""){
int mode = 1; // switch: 0 for local files, 1 for pdsf files
UInt_t card1 = 13; // 11: prototype, 13: module 1
UInt_t card2 = 18;
Bool_t useThresh = true; // if true, also enables fitting LED peaks
// "low" qdc threshold values
//Int_t thresh[numPanels] = {123,115,95,93,152,115,105,103,119,91,108,103,94,107,95,167,
// 53,150,89,120,65,85,132,62,130,101,80,108,145,164,119,82};
// "high" qdc threshold values
Int_t thresh[numPanels] = {124,117,96,93,155,115,112,105,120,91,109,108,95,112,96,168,
63,157,100,127,72,100,140,65,145,125,82,112,151,168,122,94};
// Input a list of run numbers
Char_t InputName[200];
string def = "builtVeto_DebugList"; // default
if (Input == "") strcpy(InputName,def.c_str());
else strcpy(InputName,Input.c_str());
Char_t InputFile[200];
sprintf(InputFile,"%s.txt",InputName);
ifstream InputList;
InputList.open(InputFile);
Char_t TheFile[200];
// Set up output file(s)
Char_t OutputFile[200];
sprintf(OutputFile,"./output/%s.root",InputName);
TFile *RootFile = new TFile(OutputFile, "RECREATE");
TH1::AddDirectory(kFALSE); // Global flag: "When a (root) file is closed, all histograms in memory associated with this file are automatically deleted."
ofstream calib;
Char_t CalibFile[200];
sprintf(CalibFile,"./output/%s_CalibrationTable.txt",InputName);
calib.open(CalibFile);
//=== Global counters / variables / plots ===
Int_t run = 0;
Float_t duration = 0;
Float_t durationTotal = 0;
// get number of files in dataset for the TGraph
Int_t filesToScan = 0;
Int_t filesScanned = 0;
while(!InputList.eof()) { InputList >> run; filesToScan++; }
cout << "Scanning " << filesToScan << " files." << endl;
InputList.close();
InputList.open(InputFile);
run=0;
TGraph *SCorruption = new TGraph(filesToScan);
Int_t BadTSTotal = 0;
TH1D *TotalCorruptionInTime = new TH1D("TotalCorruptionInTime","corrupted entries during run (entry method)",(Int_t)3600/5,0,3600);
TotalCorruptionInTime->GetXaxis()->SetTitle("time (5 sec / bin)");
Bool_t PlotCorruptedEntries = false; // flag for plotting corrupted entries in time for EACH RUN
TH1D *TotalMultiplicity = new TH1D("TotalMultiplicity","Events over threshold",32,0,32);
TotalMultiplicity->GetXaxis()->SetTitle("number of panels hit");
Bool_t PlotMultiplicity = false; // flag to plot multiplicity for EACH RUN
const Int_t nqdc_bins=1400; // this gives 3 qdc / bin
const Float_t ll_qdc=0.;
const Float_t ul_qdc=4200.;
Char_t hname[50];
for (Int_t i=0; i<numPanels; i++){
sprintf(hname,"hRawQDC%d",i);
hRawQDC[i] = new TH1F(hname,hname,nqdc_bins,ll_qdc,ul_qdc);
sprintf(hname,"hCutQDC%d",i);
hCutQDC[i] = new TH1F(hname,hname,nqdc_bins,ll_qdc,ul_qdc);
sprintf(hname,"hThreshQDC%d",i);
hThreshQDC[i] = new TH1F(hname,hname,500,ll_qdc,500);
sprintf(hname,"hLEDCutQDC%d",i);
hLEDCutQDC[i] = new TH1F(hname,hname,500,ll_qdc,500);
}
Long64_t CountsBelowThresh[numPanels] = {0};
Long64_t TotalCounts[numPanels] = {0};
//=== End ===
// Loop over files
while(!InputList.eof()){
// initialize
InputList >> run;
if (mode==0) sprintf(TheFile,"~/dev/datasets/muFinder/OR_run%i.root",run);
else if (mode==1) sprintf(TheFile,"/global/project/projectdirs/majorana/data/mjd/surfmjd/data/built/P3JDY/OR_run%u.root",run);
TChain *VetoTree = new TChain("VetoTree");
VetoTree->AddFile(TheFile);
TChain *MGTree = new TChain("MGTree");
MGTree->AddFile(TheFile);
MJTRun *MyRun = new MJTRun();
MGTree->SetBranchAddress("run",&MyRun);
Long64_t nentries = VetoTree->GetEntries();
//.........这里部分代码省略.........
示例8: Calc_Eff_200
void Calc_Eff_200(int cen) {
const float PI = TMath::Pi();
const float mean = 0.01166;
const float rms = 0.05312;
TFile *f1 = new TFile("cen6.ntuple_result_v2_11_subEP_dca1_pt015_eta1_noP_pionDca1_higherEP.root");
TH1* h_pt = (TH1*)f1->Get("Hist_Pt");
float real[9][7] = {{1.68441e+07,1.94857e+07,1.91433e+07,1.76339e+07,1.57031e+07,1.3709e+07,1.18246e+07},
{3.87595e+07,4.43888e+07,4.34577e+07,4.00144e+07,3.57267e+07,3.13252e+07,2.71556e+07},
{8.04378e+07,9.2009e+07,9.01896e+07,8.33911e+07,7.47927e+07,6.59201e+07,5.74707e+07},
{1.28651e+08,1.47865e+08,1.45606e+08,1.3528e+08,1.2199e+08,1.08084e+08,9.47436e+07},
{1.9998e+08,2.31542e+08,2.29316e+08,2.14124e+08,1.94076e+08,1.72786e+08,1.52079e+08},
{2.91541e+08,3.40818e+08,3.39637e+08,3.1877e+08,2.90097e+08,2.59203e+08,2.29072e+08},
{3.94517e+08,4.66796e+08,4.68155e+08,4.41467e+08,4.03254e+08,3.61425e+08,3.20203e+08},
{2.3895e+08,2.85928e+08,2.88314e+08,2.72767e+08,2.49768e+08,2.24261e+08,1.98897e+08},
{2.70925e+08,3.27361e+08,3.31383e+08,3.14285e+08,2.88208e+08,2.5899e+08,2.29898e+08}};
float emrc[9][7] = {{127.287,180.108,180.46,203.105,201.325,185.72,183.217},
{111.057,137.61,163.772,151.6,161.841,157.728,178.696},
{157.959,196.018,206.222,184.609,183.632,238.975,225.804},
{294.14,355.613,355.514,396.844,397.958,385.601,425},
{499,551,666,616,706,750,677},
{715,916,988,992,1031,1047,1070},
{1045,1247,1393,1414,1523,1589,1527},
{653,853,898,928,1016,1073,996},
{863,975,1199,1263,1262,1258,1314}};
const int cenDef[9] = {10, 22, 43, 76, 125, 193, 281, 396, 466};
float Eweight = 1;
TChain* chain = new TChain("McV0PicoDst");
int nfile = 0;
nfile += chain->Add("output_p/*.root");
nfile += chain->Add("output_pbar/*.root");
// nfile += chain->Add("output_test/*.root");
// nfile += chain->Add("output_km/*.root");
// nfile += chain->Add("output_kp/*.root");
cout <<"Added "<<nfile<<" files"<<endl;
cout<<"# entries in chain: "<<chain->GetEntries()<<endl;
char fname_out[200];
sprintf(fname_out,"cen%d.eff_200_p.root",cen);
TFile fout(fname_out,"RECREATE");
TH1D* Hist_RefMult = new TH1D("Hist_RefMult","Hist_RefMult",500,-0.5,499.5);
TH2D* Hist_mc_pt = new TH2D("Hist_mc_pt","Hist_mc_pt",28,0,560,200,0,10);
TH1D* Hist_mc_pt_cen = new TH1D("Hist_mc_pt_cen","Hist_mc_pt_cen",200,0,10);
TH1D* Hist_mc_pt_L = new TH1D("Hist_mc_pt_L","Hist_mc_pt_Lokesh",200,0,10);
TH1D* Hist_mc_eta = new TH1D("Hist_mc_eta","Hist_mc_eta",200,-1,1);
TH1D* Hist_rc_flag = new TH1D("Hist_rc_flag","Hist_rc_flag",3000,-1000+0.5,2000.5);
TH2D* Hist_rc_pt = new TH2D("Hist_rc_pt","Hist_rc_pt",28,0,560,200,0,10);
TH1D* Hist_rc_pt_cen = new TH1D("Hist_rc_pt_cen","Hist_rc_pt_cen",200,0,10);
TH1D* Hist_rc_pt_scale = new TH1D("Hist_rc_pt_scale","Hist_rc_pt_scale",200,0,10);
TH1D* Hist_rc_pt_L = new TH1D("Hist_rc_pt_L","Hist_rc_pt_Lokesh",200,0,10);
TH1D* Hist_rc_eta = new TH1D("Hist_rc_eta","Hist_rc_eta",200,-1,1);
TH1D* Hist_rc_dca = new TH1D("Hist_rc_dca","Hist_rc_dca",200,0,20);
TH1D* Hist_rc_dca_scale = new TH1D("Hist_rc_dca_scale","Hist_rc_dca_scale",200,0,20);
TH1D* Hist_rc_nfit = new TH1D("Hist_rc_nfit","Hist_rc_nfit",100,0,100);
TH1D* Hist_rc_rat = new TH1D("Hist_rc_rat","Hist_rc_rat",100,0,2);
TH1D* Hist_dphi = new TH1D("Hist_dphi","Hist_dphi",128,-3.2,3.2);
TH1D* Hist_dphi1 = new TH1D("Hist_dphi1","Hist_dphi1",128,-3.2,3.2);
TH1D* Hist_dphi2 = new TH1D("Hist_dphi2","Hist_dphi2",128,-3.2,3.2);
TH1D* Hist_dphi3 = new TH1D("Hist_dphi3","Hist_dphi3",128,-3.2,3.2);
TH1D* Hist_dphi4 = new TH1D("Hist_dphi4","Hist_dphi4",128,-3.2,3.2);
TH1D* Hist_dphi_pion = new TH1D("Hist_dphi_pion","Hist_dphi_pion",128,-3.2,3.2);
TH1D* Hist_ddphi = new TH1D("Hist_ddphi","Hist_ddphi",128,-3.2,3.2);
TProfile* p_dphi = new TProfile("p_dphi","p_dphi",4,0.5,4.5,-100,100);
TProfile* p_dphi_pt = new TProfile("p_dphi_pt","p_dphi_pt",200,0,10,-100,100);
TProfile* p_dphi_L = new TProfile("p_dphi_L","p_dphi_L",4,0.5,4.5,-100,100);
TProfile* p_dphi_LM= new TProfile("p_dphi_LM","p_dphi_LM",4,0.5,4.5,-100,100);
TProfile* p_dphi_M = new TProfile("p_dphi_M","p_dphi_M",4,0.5,4.5,-100,100);
TProfile* p_dphi_RM= new TProfile("p_dphi_RM","p_dphi_RM",4,0.5,4.5,-100,100);
TProfile* p_dphi_R = new TProfile("p_dphi_R","p_dphi_R",4,0.5,4.5,-100,100);
TProfile* p_ddphi = new TProfile("p_ddphi","p_ddphi",4,0.5,4.5,-100,100);
TProfile* p_ddphi_L = new TProfile("p_ddphi_L","p_ddphi_L",4,0.5,4.5,-100,100);
TProfile* p_ddphi_LM= new TProfile("p_ddphi_LM","p_ddphi_LM",4,0.5,4.5,-100,100);
TProfile* p_ddphi_M = new TProfile("p_ddphi_M","p_ddphi_M",4,0.5,4.5,-100,100);
TProfile* p_ddphi_RM= new TProfile("p_ddphi_RM","p_ddphi_RM",4,0.5,4.5,-100,100);
TProfile* p_ddphi_R = new TProfile("p_ddphi_R","p_ddphi_R",4,0.5,4.5,-100,100);
TH1D* Hist_asym = new TH1D("Hist_asym","Hist_asym",600,-1.5+0.0025,1.5+0.0025);
TH1D* Hist_asym_L = new TH1D("Hist_asym_L","Hist_asym_L",600,-1.5+0.0025,1.5+0.0025);
TH1D* Hist_asym_LM= new TH1D("Hist_asym_LM","Hist_asym_LM",600,-1.5+0.0025,1.5+0.0025);
TH1D* Hist_asym_M = new TH1D("Hist_asym_M","Hist_asym_M",600,-1.5+0.0025,1.5+0.0025);
TH1D* Hist_asym_RM= new TH1D("Hist_asym_RM","Hist_asym_RM",600,-1.5+0.0025,1.5+0.0025);
TH1D* Hist_asym_R = new TH1D("Hist_asym_R","Hist_asym_R",600,-1.5+0.0025,1.5+0.0025);
Int_t nentries = chain->GetEntries();
for(int i = 0; i < nentries; i++){
if((i+1)%1000==0) cout<<"Processing entry == "<< i+1 <<" == out of "<<nentries<<".\n";
chain->GetEntry(i);
TLeaf* leaf_RunId = chain->GetLeaf("runnumber");
TLeaf* leaf_RefMult = chain->GetLeaf("nrefmult");
TLeaf* leaf_Px = chain->GetLeaf("primvertexX");
TLeaf* leaf_Py = chain->GetLeaf("primvertexY");
TLeaf* leaf_Pz = chain->GetLeaf("primvertexZ");
TLeaf* leaf_ZDCrate = chain->GetLeaf("zdcrate");
TLeaf* leaf_nmcv0 = chain->GetLeaf("nmcv0");
TLeaf* leaf_nv0 = chain->GetLeaf("nv0");
TLeaf* leaf_Np = chain->GetLeaf("numberP");
//.........这里部分代码省略.........
示例9: conv2CaloGeoView
void conv2CaloGeoView(const Char_t *input, const Char_t *output)
{
TChain *rootChain = new TChain("CollectionTree");
rootChain->Add(input);
const Int_t nevent = rootChain->GetEntries();
cout << "Formating " << nevent << " events..." << endl;
//Input vectors.
UInt_t nClusters;
vector<UInt_t> *rootNCells = new vector<UInt_t>;
vector<UChar_t> *rootLayers = new vector<UChar_t>;
vector<Float_t> *rootEnergy = new vector<Float_t>;
vector<Float_t> *rootEta = new vector<Float_t>;
vector<Float_t> *rootPhi = new vector<Float_t>;
vector<UInt_t> *rootLVL1Id = new vector<UInt_t>;
vector<UInt_t> *rootRoIId = new vector<UInt_t>;
vector<Float_t> *rootLVL1Eta = new vector<Float_t>;
vector<Float_t> *rootLVL1Phi = new vector<Float_t>;
vector<Float_t> *rootLVL2Eta = new vector<Float_t>;
vector<Float_t> *rootLVL2Phi = new vector<Float_t>;
vector<Float_t> *rootLVL2Et = new vector<Float_t>;
// Output vectors.
UInt_t nCellsEM;
vector<UChar_t> *layersEM = new vector<UChar_t>;
vector<Float_t> *energyEM = new vector<Float_t>;
vector<Float_t> *etaEM = new vector<Float_t>;
vector<Float_t> *phiEM = new vector<Float_t>;
UInt_t nCellsHAD;
vector<UChar_t> *layersHAD = new vector<UChar_t>;
vector<Float_t> *energyHAD = new vector<Float_t>;
vector<Float_t> *etaHAD = new vector<Float_t>;
vector<Float_t> *phiHAD = new vector<Float_t>;
UInt_t lvl1Id;
UInt_t roiId;
Float_t lvl1Eta;
Float_t lvl1Phi;
Float_t lvl2Eta;
Float_t lvl2Phi;
Float_t lvl2Et;
//Creating the output tree.
TTree *outTree = new TTree("CollectionTree", "RoI for CaloGeoView.");
outTree->Branch("NCellsLRoI", &nCellsEM, "NCellsLRoI/i");
outTree->Branch("DetCellsLRoI", &layersEM);
outTree->Branch("ECellsLRoI", &energyEM);
outTree->Branch("EtaCellsLRoI", &etaEM);
outTree->Branch("PhiCellsLRoI", &phiEM);
outTree->Branch("NCellsTRoI", &nCellsHAD, "NCellsTRoI/i");
outTree->Branch("DetCellsTRoI", &layersHAD);
outTree->Branch("ECellsTRoI", &energyHAD);
outTree->Branch("EtaCellsTRoI", &etaHAD);
outTree->Branch("PhiCellsTRoI", &phiHAD);
outTree->Branch("LVL1_Id", &lvl1Id, "LVL1_Id/i");
outTree->Branch("RoI_Id", &roiId, "RoI_Id/i");
outTree->Branch("LVL1_Eta", &lvl1Eta, "LVL1_Eta/f");
outTree->Branch("LVL1_Phi", &lvl1Phi, "LVL1_Phi/f");
outTree->Branch("LVL2_Eta", &lvl2Eta, "LVL2_Eta/f");
outTree->Branch("LVL2_Phi", &lvl2Phi, "LVL2_Phi/f");
outTree->Branch("LVL2_Et", &lvl2Et, "LVL2_Et/f");
//Selecting the branches we want to read.
rootChain->SetBranchStatus("*",0); // disable all branches
rootChain->SetBranchStatus("Ringer_NClusters",1);
rootChain->SetBranchStatus("Ringer_NCells",1);
rootChain->SetBranchStatus("Ringer_DetCells",1);
rootChain->SetBranchStatus("Ringer_ECells",1);
rootChain->SetBranchStatus("Ringer_EtaCells",1);
rootChain->SetBranchStatus("Ringer_PhiCells",1);
rootChain->SetBranchStatus("Ringer_LVL1_Id",1);
rootChain->SetBranchStatus("Ringer_Roi_Id",1);
rootChain->SetBranchStatus("Ringer_LVL1_Eta",1);
rootChain->SetBranchStatus("Ringer_LVL1_Phi",1);
rootChain->SetBranchStatus("Ringer_LVL2_Eta",1);
rootChain->SetBranchStatus("Ringer_LVL2_Phi",1);
rootChain->SetBranchStatus("Ringer_LVL2_Et",1);
// Associating branches with the input vectors.
rootChain->SetBranchAddress("Ringer_NClusters", &nClusters);
rootChain->SetBranchAddress("Ringer_NCells", &rootNCells);
rootChain->SetBranchAddress("Ringer_DetCells", &rootLayers);
rootChain->SetBranchAddress("Ringer_ECells", &rootEnergy);
rootChain->SetBranchAddress("Ringer_EtaCells", &rootEta);
rootChain->SetBranchAddress("Ringer_PhiCells", &rootPhi);
rootChain->SetBranchAddress("Ringer_LVL1_Id", &rootLVL1Id);
rootChain->SetBranchAddress("Ringer_Roi_Id", &rootRoIId);
rootChain->SetBranchAddress("Ringer_LVL1_Eta", &rootLVL1Eta);
rootChain->SetBranchAddress("Ringer_LVL1_Phi", &rootLVL1Phi);
rootChain->SetBranchAddress("Ringer_LVL2_Eta", &rootLVL2Eta);
rootChain->SetBranchAddress("Ringer_LVL2_Phi", &rootLVL2Phi);
rootChain->SetBranchAddress("Ringer_LVL2_Et", &rootLVL2Et);
for (Int_t ev=0; ev<nevent; ev++)
{
rootChain->GetEntry(ev);
if (!nClusters) continue;
UInt_t roiCellBegin = 0;
nCellsEM = nCellsHAD = 0;
//.........这里部分代码省略.........
示例10: MC_Ratio
int MC_Ratio(TString _filetag,int leptonId, double* par1, int npar1bins, double* par2, int npar2bins, TString sel_den , TString sel_num, double cut_num , TString par_x , TString par_y , TString option ){
setTDRStyle();
option.Append(" ");
option.Prepend(" ");
///////////////
//Get the TTree
///////////////
//Location of the .root file
TString location = "/Users/GLP/Desktop/CERN_data/2014-11-13_skim2ll-mva-softbtag/postprocessed/matched2/";
TString location2 = "/Users/GLP/Desktop/CERN_data/dyjetsnew/postprocessed/matched/";
//Reading the tree
//
TChain* tree = new TChain("treeProducerSusyMultilepton");
//DY events
if(option.Contains("oldtree")){tree->Add(location+"DYJetsToLLM50_PU_S14_POSTLS170.root");}
else{tree->Add(location2+"dyjetsnew.root");}
//Plot the result
Long64_t n = tree->GetEntries();
//Path for input and output file. Written in FitDataPath.txt
TString _path = "/Users/GLP/Dropbox/Physique/Master_Thesis/plots_root/MC_ratio/";
//////////////////////
//Name for the plots//
//////////////////////
TString pname;
TString _pname;
TString _par;
TString _sel_num;
TString _sel_den;
TString _option;
////Writing string
//particle string
if(abs(leptonId) == 11){pname = "e"; _pname = "e";}
if(abs(leptonId) == 13){pname = " #mu"; _pname = "mu";}
//Parameter string
if(par_x == "Pt"){_par = "P_{t}";}
else if(par_x == "eta"){_par = "#eta";}
else if(par_x == "phi"){_par = "#phi";}
//sel_den string
if((sel_den == "tightmva")&&(leptonId == 13)){cout<<"ERROR: no tightId MVA defined for the muon !"<<endl;return 1;}
if(sel_den == "tightcut"){_sel_den = "tightcut";}
else if(sel_den == "tightmva"){_sel_den = "tightmva";}
else if(sel_den == "loose"){_sel_den = "loose";}
else if(sel_den == ""){_sel_den = "";}
else{cout<<"ERROR: wrong sel_denion !";return 1;}
//sel_num string
if((sel_num == "tightmva")&&(leptonId == 13)){cout<<"ERROR: no tightId MVA defined for the muon !"<<endl;return 1;}
if(sel_num == "tightcut"){_sel_num = "tightcut";}
else if(sel_num == "tightmva"){_sel_num = "tightmva";}
else if(sel_num == ""){_sel_num = "";}
else if(sel_num == "loose"){_sel_num = "loose";}
else if(sel_num == "reliso3"){_sel_num = Form("reliso3_%0.3lf",cut_num);}
else if(sel_num == "reliso4"){_sel_num = Form("reliso4_%0.3lf",cut_num);}
else if(sel_num == "chiso3"){_sel_num = Form("chiso3_%0.3lf",cut_num);}
else if(sel_num == "chiso4"){_sel_num = Form("chiso4_%0.3lf",cut_num);}
else if(sel_num == "dxy"){_sel_num = Form("dxy_%0.3lf",cut_num);}
else if(sel_num == "dz"){_sel_num = Form("dz_%0.3lf",cut_num);}
else{cout<<"ERROR: wrong numerator name !";return 1;}
//option string
if(option.Contains(" ll ")){_option += "_ll";}
if(option.Contains(" unmatched ")){_option += "_unmatched";}
if(option.Contains(" alleta ")){_option += "_alleta";}
if(option.Contains(" short ")){_option += "_short";}
if(option.Contains(" loose ")){_option += "_loose";}
if(option.Contains(" oldtree ")){_option += "_oldtree";}
_option += "_";
//parameter range string
TString _par1range;
_par1range = Form("%0.3f_"+par_x+"%0.3f",par1[0],par1[npar1bins]);
TString _par2range;
_par2range = Form("%0.3f_"+par_y+"%0.3f",par2[0],par2[npar2bins]);
/////////////////////////////////////
//Write the name of the output file//
/////////////////////////////////////
TString _fname = "eff"+_filetag+_option+_pname+_par1range+"_"+_par2range+"_den_"+_sel_den+"_num_"+_sel_num;
//Output file
TFile* file_out = new TFile(_path+_fname+".root","recreate");
//Declaration of histogram
TH1D **histo_num = new TH1D*[npar2bins];
TH1D **histo_den = new TH1D*[npar2bins];
TH1D **eff = new TH1D*[npar2bins];
//Par1 distribution histogram
TH1D** histo_par1 = new TH1D*[npar2bins];
//.........这里部分代码省略.........
示例11: builtVetoMult2reader
//.........这里部分代码省略.........
hMuonCutQDC[j][i] = new TH1F(hname,hname,nqdc_bins,ll_qdc,ul_qdc);
}
}
*/
for (Int_t i=0; i<numFiles; i++){
sprintf(hname,"ledTime_run%d",i);
ledTime[i] = new TH1F(hname,hname,nqdc_bins,ll_qdc,ul_qdc);
}
for (Int_t i=0; i<numPanels; i++){
sprintf(hname,"MuonMultiplicityGT%d",i);
hMuonMult[i] = new TH1F(hname,hname,32,0,32);
sprintf(hname,"MuonManyTrigQDCPanel%d",i);
hMuonManyQDC[i] = new TH1F(hname,hname,3600,0,3600);
sprintf(hname,"hLEDAvgQDCPanel%d",i);
hLEDAvgQDCPanel[i] = new TH1F(hname,hname,runspace,runmin,runmax);
sprintf(hname,"hLEDrmsQDCPanel%d",i);
hLEDrmsQDCPanel[i] = new TH1F(hname,hname,runspace,runmin,runmax);
}
//=== End ===
// Loop over files
while(true){
// initialize
InputList >> run;
if (InputList.eof()) break;
sprintf(TheFile,"/global/project/projectdirs/majorana/data/mjd/surfmjd/data/built/P3JDY/OR_run%u.root",run);
TChain *VetoTree = new TChain("VetoTree");
VetoTree->AddFile(TheFile);
Long64_t nentries = VetoTree->GetEntries();
MJTRun *VetoRun = new MJTRun();
MGTBasicEvent *vetoEvent = new MGTBasicEvent();
UInt_t mVeto = 0;
//set branch addresses
VetoTree->SetBranchAddress("run",&VetoRun);
VetoTree->SetBranchAddress("mVeto",&mVeto);
VetoTree->SetBranchAddress("vetoEvent",&vetoEvent);
// Unsigned int from MGTypes.hh -- kData=0, kTest=1, kCalibration=2, kMC=3, kUndefined=4
printf("Run Type: %u\n",VetoRun->GetRunType());
//-------------
//=== Single-file counters / variables / plots
Bool_t IsEmpty = false;
Int_t BadTSInFile = 0;
Float_t corruption = 0;
if (PlotCorruptedEntries) {
TH1D *CorruptionInTime = new TH1D("CorruptionInTime","corrupted entries during run (entry method)",(Int_t)duration/5,0,(Int_t)duration);
CorruptionInTime->GetXaxis()->SetTitle("time (5 sec / bin)");
}
Int_t lednumPanelsHit = 0;
Int_t muonnumPanelsHit = 0;
runnum[filesScanned] = run;
示例12: revCalSimulation
void revCalSimulation (Int_t runNumber, string b, string A)
{
int numFiles = 180;//(b==std::string("inf")?200:(A==std::string("-1")?200:20));
bool allEvtsTrigg = false; //This just removes the use of the trigger function for an initial calibration.
// Once a calibration is established (or if running on Betas), you can keep this false
bool simProperStatistics = false; // If True, this uses the actual data run to determine the number of Type 0s to simulate
cout << "Running reverse calibration for run " << runNumber << endl;
UInt_t BetaEvents = 0; //Holds the number of electron like Type 0 events to process
Char_t temp[500],tempE[500],tempW[500];
//First get the number of total electron events around the source position from the data file and also the length of the run
//sprintf(temp,"%s/replay_pass4_%i.root",getenv("REPLAY_PASS4"),runNumber);
sprintf(temp,"%s/replay_pass3_%i.root",getenv("REPLAY_PASS3"),runNumber);
TFile *dataFile = new TFile(temp,"READ");
TTree *data = (TTree*)(dataFile->Get("pass3"));
sprintf(tempE,"Type<4 && Type>=0 && PID==1 && Side==0 && (xE.center*xE.center+yE.center*yE.center)<2500. && (xW.center*xW.center+yW.center*yW.center)<2500.");
sprintf(tempW,"Type<4 && Type>=0 && PID==1 && Side==1 && (xW.center*xW.center+yW.center*yW.center)<2500. && (xE.center*xE.center+yE.center*yE.center)<2500.");
BetaEvents = data->GetEntries(tempE) + data->GetEntries(tempW);
cout << "Electron Events in Data file: " << BetaEvents << endl;
cout << "East: " << data->GetEntries(tempE) << "\tWest: " << data->GetEntries(tempW) << endl;
delete data;
dataFile->Close();
//If we have a Beta run and we don't want exact statistics, simulate 16 times the number of events
if ( !simProperStatistics ) {
BetaEvents = 100*BetaEvents;
}
std::cout << "Processing " << BetaEvents << " events...\n";
///////////////////////// SETTING GAIN OF FIRST and second DYNYODE
Double_t g_d = 16.;
Double_t g_rest = 12500.;
/////// Loading other run dependent quantities
vector <Int_t> pmtQuality = getEreconPMTQuality(runNumber); // Get the quality of the PMTs for that run
UInt_t calibrationPeriod = getSrcRunPeriod(runNumber); // retrieve the calibration period for this run
UInt_t XePeriod = getXeRunPeriod(runNumber); // Get the proper Xe run period for the Trigger functions
//GetPositionMap(XePeriod);
PositionMap posmap(5.0,50.); //Load position map with 5 mm bins
posmap.readPositionMap(XePeriod,"endpoint");
vector <Double_t> alpha = GetAlphaValues(calibrationPeriod); // fill vector with the alpha (nPE/keV) values for this run period
/////////////// Load trigger functions //////////////////
TriggerFunctions trigger(runNumber);
std::vector < std::vector <Double_t> > pedestals = loadPMTpedestals(runNumber);
std::vector < Double_t > PMTgain = loadGainFactors(runNumber);
//Load the simulated relationship between EQ and Etrue
EreconParameterization eRecon(runNumber);
// Int_t pol = source=="Beta" ? getPolarization(runNumber) : 1;
LinearityCurve linCurve(calibrationPeriod,false);
std::cout << "Loaded Linearity Curves\n";
//Decide which simulation to use...
TChain *chain = new TChain("anaTree");
std::string geom;
if (runNumber<20000) geom = "2011-2012_geom";
else if (runNumber>=21087 && runNumber<21679) geom = "2012-2013_isobutane_geom";
else geom = "2012-2013_geom";
TString fileLocation = TString::Format("/extern/mabrow05/ucna/xuan_stuff/AbFit_Fierz_2011-2013/%s/A_%s_b_%s/",
geom.c_str(),A.c_str(),b.c_str());
std::cout << "Using simulation from " << fileLocation << "...\n";
//Read in simulated data and put in a TChain
TRandom3 *randFile = new TRandom3(runNumber*2);
int fileNum = (int)(randFile->Rndm()*numFiles);
delete randFile;
for (int i=0; i<numFiles; i++) {
if (fileNum==numFiles) fileNum=0;
chain->AddFile(TString::Format("%s/xuan_analyzed_%i.root",fileLocation.Data(),fileNum));
fileNum++;
}
// Set the addresses of the information read in from the simulation file
/*chain->SetBranchAddress("MWPCEnergy",&mwpcE); x
chain->SetBranchAddress("time",&Time); x
chain->SetBranchAddress("Edep",&edep); x
chain->SetBranchAddress("EdepQ",&edepQ); x
chain->SetBranchAddress("MWPCPos",&mwpc_pos); x
//.........这里部分代码省略.........
示例13: compareMET
void compareMET( bool printgif = false ){
printgif_ = printgif;
gStyle->SetOptStat(0);
char* path = "output/PVT/promptreco/dcsonly";
TChain *dymm = new TChain("Events");
dymm->Add(Form("%s/dymm_default_baby.root",path));
TChain *dyee = new TChain("Events");
dyee->Add(Form("%s/dyee_default_baby.root",path));
TChain *zjets = new TChain("Events");
zjets->Add(Form("%s/zjets_default_baby.root",path));
TChain *tt = new TChain("Events");
tt->Add(Form("%s/tt_default_baby.root",path));
TChain *h130 = new TChain("Events");
h130->Add(Form("%s/h130_default_baby.root",path));
TChain *chdata = new TChain("Events");
chdata->Add(Form("%s/data_default_baby.root",path));
cout << "DATA " << chdata->GetEntries() << endl;
TChain *chmc = new TChain("Events");
chmc->Add(Form("%s/dymm_default_baby.root",path));
chmc->Add(Form("%s/dyee_default_baby.root",path));
//chmc->Add(Form("%s/zjets_spring11_default_baby.root",path));
//chmc->Add(Form("%s/tt_spring11_default_baby.root",path));
cout << "MC " << chmc->GetEntries() << endl;
TCut sel("njets30==1&&dilep.mass()>76&&dilep.mass()<106");
//TCut sel("njets30==1&&dilep.mass()>76&&dilep.mass()<106");
//TCut sel("njets30==0&&dilep.mass()>81&&dilep.mass()<101");
TCut type("leptype==0||(leptype==3&&lep1.pt()>27)");
//TCut type("leptype==3&&lep1.pt()>27");
//TCut type("leptype==0");
//TCut weight("weight*vtxweight");
//TCut weight("weight");
TCut weight("(7429./6555.1)*weight*davtxweight"); //powheg
//TCut weight("(7429./6352)*10*weight*vtxweight"); //MG
TCut seltype = sel+type;
/*
TCanvas *ctemp = new TCanvas();
ctemp->cd();
int nbins = 100;
float xmin = 0.;
float xmax = 100.;
TH1F* hmc_tcmet = new TH1F("hmc_tcmet", "", nbins,xmin,xmax);
TH1F* hdata_tcmet = new TH1F("hdata_tcmet","", nbins,xmin,xmax);
hmc_tcmet->Sumw2();
hdata_tcmet->Sumw2();
TH1F* hmc_pfmet = new TH1F("hmc_pfmet", "", nbins,xmin,xmax);
TH1F* hdata_pfmet = new TH1F("hdata_pfmet","", nbins,xmin,xmax);
hmc_pfmet->Sumw2();
hdata_pfmet->Sumw2();
TH1F* hmc_hmetpf = new TH1F("hmc_hmetpf", "", nbins,xmin,xmax);
TH1F* hdata_hmetpf = new TH1F("hdata_hmetpf","", nbins,xmin,xmax);
hmc_hmetpf->Sumw2();
hdata_hmetpf->Sumw2();
TH1F* hmc_hmetpf4 = new TH1F("hmc_hmetpf4", "", nbins,xmin,xmax);
TH1F* hdata_hmetpf4 = new TH1F("hdata_hmetpf4","", nbins,xmin,xmax);
hmc_hmetpf4->Sumw2();
hdata_hmetpf4->Sumw2();
TH1F* hmc_jetzmet = new TH1F("hmc_jetzmet", "", nbins,xmin,xmax);
TH1F* hdata_jetzmet = new TH1F("hdata_jetzmet","", nbins,xmin,xmax);
hmc_jetzmet->Sumw2();
hdata_jetzmet->Sumw2();
//char* met1 = "tcmet";
//char* met1 = "hmetpf";
//char* met1 = "TMath::Min(pfmet,hmetpf)";
chmc->Draw ("TMath::Min(tcmet,99.9) >> hmc_tcmet" ,(sel+type)*weight);
chdata->Draw("TMath::Min(tcmet,99.9) >> hdata_tcmet",(sel+type) );
chmc->Draw ("TMath::Min(pfmet,99.9) >> hmc_pfmet" ,(sel+type)*weight);
chdata->Draw("TMath::Min(pfmet,99.9) >> hdata_pfmet",(sel+type) );
chmc->Draw ("TMath::Min(hmetpf,99.9) >> hmc_hmetpf" ,(sel+type)*weight);
chdata->Draw("TMath::Min(hmetpf,99.9) >> hdata_hmetpf",(sel+type) );
chmc->Draw ("TMath::Min(hmetpf4,99.9) >> hmc_hmetpf4" ,(sel+type)*weight);
//.........这里部分代码省略.........
示例14: analyzeJES
//.........这里部分代码省略.........
anajesForest->SetGenJetsName("akt4Gen");
anajesForest->SetRecJetsName(jetName);
anajesForest->SetNCentBins(4);
anajesForest->SetUseForestMatching(true);
//anajesForest->SetMaxDistance(0.2);
handler->Add(anajesForest);
anaJetEnergyScale *anajesForestQuarks = new anaJetEnergyScale("anaJESForestQuarks","anaJESForestQuarks");
anajesForestQuarks->ConnectEventObject(fEventObjects);
anajesForestQuarks->SetHiEvtName("hiEventContainer");
anajesForestQuarks->SetGenJetsName("akt4Gen");
anajesForestQuarks->SetRecJetsName(jetName);
anajesForestQuarks->SetNCentBins(4);
anajesForestQuarks->SetUseForestMatching(true);
//anajesForestQuarks->SetMaxDistance(0.2);
anajesForestQuarks->SetRefPartonFlavor(0,2);
handler->Add(anajesForestQuarks);
anaJetEnergyScale *anajesForestGluons = new anaJetEnergyScale("anaJESForestGluons","anaJESForestGluons");
anajesForestGluons->ConnectEventObject(fEventObjects);
anajesForestGluons->SetHiEvtName("hiEventContainer");
anajesForestGluons->SetGenJetsName("akt4Gen");
anajesForestGluons->SetRecJetsName(jetName);
anajesForestGluons->SetNCentBins(4);
anajesForestGluons->SetUseForestMatching(true);
//anajesForestGluons->SetMaxDistance(0.2);
anajesForestGluons->SetRefPartonFlavor(21,21);
handler->Add(anajesForestGluons);
anaJetEnergyScale *anajesForestRaw = new anaJetEnergyScale("anaJESForestRaw","anaJESForestRaw");
anajesForestRaw->ConnectEventObject(fEventObjects);
anajesForestRaw->SetHiEvtName("hiEventContainer");
anajesForestRaw->SetGenJetsName("");
anajesForestRaw->SetRecJetsName(jetName);
anajesForestRaw->SetNCentBins(4);
anajesForestRaw->SetUseForestMatching(true);
anajesForestRaw->SetUseRawPt(true);
//handler->Add(anajesForestRaw);
//particle-detector-level jet matching
anaJetMatching *match = new anaJetMatching("jetMatching","jetMatching");
match->ConnectEventObject(fEventObjects);
match->SetHiEvtName("hiEventContainer");
//match->SetJetsNameBase(jetName);
//match->SetJetsNameTag("akt4Gen");
match->SetJetsNameTag(jetName);
match->SetJetsNameBase("akt4Gen");
match->SetMatchingType(0);
//handler->Add(match);
anaJetEnergyScale *anajes = new anaJetEnergyScale("anaJES","anaJES");
anajes->ConnectEventObject(fEventObjects);
anajes->SetHiEvtName("hiEventContainer");
anajes->SetGenJetsName("akt4Gen");
anajes->SetRecJetsName(jetName);
anajes->SetNCentBins(4);
//handler->Add(anajes);
anaJetEnergyScale *anajesRaw = new anaJetEnergyScale("anaJESRaw","anaJESRaw");
anajesRaw->ConnectEventObject(fEventObjects);
anajesRaw->SetHiEvtName("hiEventContainer");
anajesRaw->SetGenJetsName("akt4Gen");
anajesRaw->SetRecJetsName(jetName);
anajesRaw->SetNCentBins(4);
anajesRaw->SetUseForestMatching(false);
anajesRaw->SetUseRawPt(true);
//handler->Add(anajesRaw);
//---------------------------------------------------------------
//Event loop
//---------------------------------------------------------------
Long64_t entries_tot = chain->GetEntries(); //93064
if(nentries<0) lastEvent = chain->GetEntries();
Printf("nentries: %lld tot: %lld",nentries,entries_tot);
for (Long64_t jentry=firstEvent; jentry<lastEvent; ++jentry) {
if(jentry%10000==0) cout << "entry: "<< jentry << endl;
//Run producers
//Printf("produce hiEvent");
p_evt->Run(jentry); //hi event properties
//Printf("produce PU jets");
p_PUJet->Run(jentry); //forest jets
//Execute all analysis tasks
handler->ExecuteTask();
}
fEventObjects->Print();
TFile *out = new TFile(outname,"RECREATE");
TList *tasks = handler->GetListOfTasks();
TIter next(tasks);
anaBaseTask *obj;
while ((obj = dynamic_cast<anaBaseTask*>(next()) ))
if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey);
out->Write();
out->Close();
}
示例15: main
//.........这里部分代码省略.........
double Gain,F,Corr;
double min,max;
TVector3 vin;
int Nx,Ny;
TDetector *m_detector=new TDetector(fDetName);
TMarocSetupHandler *m_setup=new TMarocSetupHandler(fSetupName);
TDetectorUtils *m_utils=0;
/*MC DATA INPUT CASE*/
TChain *cMC;
vector < TH1D* > hSimChargeMC[6][MAX_DETECTORS];
vector < double > chargeMC[6][MAX_DETECTORS];
TEvent *event = 0;
TClonesArray *digi;
int NeventsMC;
int Nhits,faceNumber,detNumber,pixelNumber;
int nBckCut,nSigCut;
double qMeanMC;
m_setup->Print(1);
m_detector->PrintPixels();
m_detector->Print();
if (fDoRoot){
cMC=new TChain("Event"); //must have the TTree name I am going to read
cMC->Add(fReconName.c_str());
NeventsMC=cMC->GetEntries(); //1 entry=1 event
cMC->SetBranchAddress("Event", &event);
}
m_utils=new TDetectorUtils(m_detector);
/*Set the first gain, i.e. the Hamamatsu one. The index is the H8500ID!!!*/
double PmtDA0359[TMarocSetupHandler::nH8500Pixels]={76,79,86,96,100,95,88,83,76,71,80,89,95,89,87,82,75,68,82,87,92,91,81,77,71,64,79,83,88,88,75,74,69,63,74,79,78,83,73,70,68,61,71,75,76,73,68,65,63,60,65,69,66,62,59,60,61,64,66,70,65,60,56,52};
double PmtDA0361[TMarocSetupHandler::nH8500Pixels]={56,71,76,81,89,87,78,82,61,66,72,77,82,78,76,85,60,64,72,74,75,81,80,88,61,65,70,72,73,82,82,93,63,66,71,72,73,85,86,99,68,68,77,75,82,91,89,100,73,75,83,88,95,97,92,99,60,73,80,85,92,99,90,71};
for (int ii=0;ii<TMarocSetupHandler::nH8500Pixels;ii++){
iReconPixel=m_setup->getPixelReconId(32,ii);
iMarocChannel=m_setup->getMarocChannelFromH8500(ii);
iReconFace=m_setup->getReconstructionDetectorFace(32);
iReconDet=m_setup->getReconstructionDetectorID(32);
m_setup->setPixelGain(iReconFace,iReconDet,iReconPixel,1,PmtDA0359[ii]/100.);
m_setup->setPixelGain(iReconFace,iReconDet,iReconPixel,3,0.718); /*This is the gain configuration PMT359 vs PMT361*/
m_setup->setPixelGain(iReconFace,iReconDet,iReconPixel,2,.5);
// if (iMarocChannel<=31) m_setup->setPixelGain(iReconFace,iReconDet,iReconPixel,2,.5);
// else if (iMarocChannel<=47) m_setup->setPixelGain(iReconFace,iReconDet,iReconPixel,2,.375);
// else if (iMarocChannel<=63) m_setup->setPixelGain(iReconFace,iReconDet,iReconPixel,2,.25);
iReconPixel=m_setup->getPixelReconId(33,ii);
iMarocChannel=m_setup->getMarocChannelFromH8500(ii);
iReconFace=m_setup->getReconstructionDetectorFace(33);
iReconDet=m_setup->getReconstructionDetectorID(33);
m_setup->setPixelGain(iReconFace,iReconDet,iReconPixel,1,PmtDA0361[ii]/100.);