当前位置: 首页>>代码示例>>C++>>正文


C++ TBenchmark::Start方法代码示例

本文整理汇总了C++中TBenchmark::Start方法的典型用法代码示例。如果您正苦于以下问题:C++ TBenchmark::Start方法的具体用法?C++ TBenchmark::Start怎么用?C++ TBenchmark::Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TBenchmark的用法示例。


在下文中一共展示了TBenchmark::Start方法的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;  
}
开发者ID:eavdeeva,项目名称:usercode,代码行数:25,代码来源:AuxFchTemplateFitsData_SIHIH.C

示例2: benchmarkBinIndex

void testJetCorrectorParameters::benchmarkBinIndex(bool is3D) {
    float oldCPU = 0, newCPU = 0, oldReal = 0, newReal = 0;
    unsigned int ntests = (is3D) ? 100000 : 1000000;
    if(is3D) fX = {5.0,50.0,100.0};
    else     fX = {5.0};
    setupCorrector(is3D);

    cout << endl << "testJetCorrectorParameters::benchmarkBinIndex NTests = " << ntests << endl;
    cout << "testJetCorrectorParameters::benchmarkBinIndex benchmarking binIndex with file " << filename << " ... " << flush;
    m_benchmark->Reset();
    m_benchmark->Start("event");
    for(unsigned int i=0; i<ntests; i++) {
       L1JetPar->binIndex(fX);
    }
    m_benchmark->Stop("event");
    cout << "DONE" << endl << "testJetCorrectorParameters::benchmarkBinIndex" << endl 
         << "\tCPU time = " << m_benchmark->GetCpuTime("event")/double(ntests) << " s" << endl
         << "\tReal time = " << m_benchmark->GetRealTime("event")/double(ntests) << " s" << endl;
    oldCPU = m_benchmark->GetCpuTime("event")/double(ntests);
    oldReal = m_benchmark->GetRealTime("event")/double(ntests);

    cout << "testJetCorrectorParameters::benchmarkBinIndex benchmarking binIndexN with file " << filename << " ... " << flush;
    m_benchmark->Reset();
    m_benchmark->Start("event");
    for(unsigned int i=0; i<ntests; i++) {
       L1JetPar->binIndexN(fX);
    }
    m_benchmark->Stop("event");
    cout << "DONE" << endl << "testJetCorrectorParameters::benchmarkBinIndex" << endl
         << "\tCPU time = " << m_benchmark->GetCpuTime("event")/double(ntests) << " s" << endl
         << "\tReal time = " << m_benchmark->GetRealTime("event")/double(ntests) << " s" << endl;
    newCPU = m_benchmark->GetCpuTime("event")/double(ntests);
    newReal = m_benchmark->GetRealTime("event")/double(ntests);

    cout << "testJetCorrectorParameters::benchmarkBinIndex" << endl
         << "\tCPU speedup = " << oldCPU/newCPU << endl
         << "\tReal speedup = " << oldReal/newReal << endl;

    CPPUNIT_ASSERT(oldCPU/newCPU >= 1.0);
    //CPPUNIT_ASSERT(oldReal/newReal >= 1.0); //this might fail not due to longer L1JetPar->binIndexN(fX) execution
    if (oldReal/newReal >= 1.0)
    cout << "newReal value increased oldReal, which might be due to system load" << endl;

    destroyCorrector();
}
开发者ID:BetterWang,项目名称:cmssw,代码行数:45,代码来源:JetCorrectorParameters_t.cpp

示例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;  
}
开发者ID:eavdeeva,项目名称:usercode,代码行数:19,代码来源:AuxFchBkgEtoGamma_NoWMtCut.C

示例4: 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;
}
开发者ID:bjmarsh,项目名称:JetResponseTemplates,代码行数:23,代码来源:mergeHadoopFiles.C

示例5: 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; }
//.........这里部分代码省略.........
开发者ID:haweber,项目名称:OneLepStop,代码行数:101,代码来源:GetSomePASHistos.C

示例6: 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)
//.........这里部分代码省略.........
开发者ID:iandyckes,项目名称:scripts,代码行数:101,代码来源:ScanChain_pTrelVsIso.C

示例7: 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]);
//.........这里部分代码省略.........
开发者ID:wsicheng,项目名称:MuonTagAndProbe,代码行数:101,代码来源:ScanChain.C

示例8: 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");
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:AliCFSingleTrackTask.C

示例9: EmbeddingReco


//.........这里部分代码省略.........
#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) {
            hBarrelJetPatchSimu->Fill(jetpatch, trgsim->bemc->barrelJetPatchAdc(jetpatch));
         } // for jetpatch

         // EEMC high towers and trigger patches
         for (int triggerpatch = 0; triggerpatch < 90; ++triggerpatch) {
            hEndcapHighTowerSimu->Fill(triggerpatch, trgsim->eemc->getEndcapHighTower(triggerpatch));
            hEndcapPatchSumSimu->Fill(triggerpatch, trgsim->eemc->getEndcapPatchSum(triggerpatch));
         } // for triggerpatch

         // EEMC jet patches
         for (int jetpatch = 0; jetpatch < 6; ++jetpatch) {
            hEndcapJetPatchSimu->Fill(jetpatch, trgsim->eemc->endcapJetPatchAdc(jetpatch));
         } // for jetpatch

         // BEMC-EEMC-overlap jet patches
         for (int i = 0; i < 2; ++i) {
            int jetpatch, adc;
            trgsim->emc->getOverlapJetPatchAdc(i, jetpatch, adc);
            hOverlapJetPatchSimu->Fill(jetpatch, adc);
         } // for i
      } //end of if("jet")

      //--------------------------------------------------------------------------
      evnt.Stop("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", iEvent, Chain->GetRunNumber(), Chain->GetEventNumber(), Chain->GetDate(), Chain->GetTime(), chain3->GetMakeReturn(), evnt.GetRealTime("QAInfo:"), evnt.GetCpuTime("QAInfo:"));
   } // End event loop

   printf("QAInfo:EventLoop completed code %d\n", iMake);
   gSystem->Exec("date");
   TDatime t;
   printf("QAInfo:Run is finished at Date/Time %i/%i; Total events processed: %i and not completed: %i\n", t.GetDate(), t.GetTime(), mNTotal, mNFailed);

   //--------------------------------------------------------------------------
   if (flag == "Jet") {
      ofile->Write();
      ofile->Close();
   }
}
开发者ID:star-bnl,项目名称:star-travex,代码行数:101,代码来源:bfcMixer_pythia.C

示例10: 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");

}
开发者ID:star-bnl,项目名称:star-emc,代码行数:101,代码来源:bfcMixer_pp2006.C

示例11: 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_;
//.........这里部分代码省略.........
开发者ID:haweber,项目名称:StopAnalysis,代码行数:101,代码来源:stopBabyLooper.C

示例12: 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
//.........这里部分代码省略.........
开发者ID:mialiu149,项目名称:OneLepStop,代码行数:101,代码来源:TestBDTcreatetrees_needsupdate.C

示例13: 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);
  }
}
开发者ID:star-bnl,项目名称:star-macros,代码行数:89,代码来源:bfcZ.C

示例14: 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();
  //-------
//.........这里部分代码省略.........
开发者ID:iandyckes,项目名称:DrawPlots,代码行数:101,代码来源:ScanChain.C

示例15: 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")){
//.........这里部分代码省略.........
开发者ID:mialiu149,项目名称:AnalysisLoopers2015,代码行数:101,代码来源:MakeDataCardInputsT2bW.C


注:本文中的TBenchmark::Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。