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


C++ TDirectory::cd方法代码示例

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


在下文中一共展示了TDirectory::cd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ST_Monitoring_Eff

// File: ST_Monitoring_Efficiency.C
// Last Modified: 05/27/2015
// Creator: Mahmoud Kamel [email protected]
// Purpose: Displaying histograms for online monitoring purposes
void ST_Monitoring_Eff () {
  // Define the directory that contains the histograms
  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("st_tracking");
  if(dir) dir->cd();
  // Grab 1D histograms 
  TH1D *MacropEff     = (TH1D*)dir->FindObjectAny("MacropEff");
  TH1D *MacropEff_adc     = (TH1D*)dir->FindObjectAny("MacropEff_adc");
  TH1D *h_phi_sec_pred_hit_cntr = (TH1D*)dir->FindObjectAny("h_phi_sec_pred_hit_cntr");
  TH1D *h_phi_sec_hit_cntr  = (TH1D*)dir->FindObjectAny("h_phi_sec_hit_cntr");
  TH1D *h_phi_sec_adc_cntr = (TH1D*)dir->FindObjectAny("h_phi_sec_adc_cntr");

  // get Binomial errors in an efficiency plot
  // hit object efficiency
  h_phi_sec_hit_cntr->Sumw2();
  h_phi_sec_pred_hit_cntr->Sumw2();
  MacropEff->Sumw2();
  MacropEff->Divide(h_phi_sec_hit_cntr,h_phi_sec_pred_hit_cntr,1,1,"B");

  // adc efficiency
  h_phi_sec_adc_cntr->Sumw2();
  MacropEff_adc->Sumw2();
  MacropEff_adc->Divide(h_phi_sec_adc_cntr,h_phi_sec_pred_hit_cntr,1,1,"B");

  //Create the canvas
  if(gPad == NULL)
    {
      TCanvas *c1 = new TCanvas("c1","Start Counter 1D Histograms", 200, 10, 600, 480);
      c1->cd(0);
      c1->Draw();
      c1->Update();
    }
  if(!gPad) return;
  TCanvas *c1 = gPad->GetCanvas();
  c1->Divide(2,1);
  // ST ADC Efficiency histogram
  c1->cd(1);
  gStyle->SetOptStat(0);
  gStyle->SetErrorX(0); 
  gPad->SetTicks();
  gPad->SetGrid();
  if (MacropEff_adc) {
   MacropEff_adc->Draw("E1");
   MacropEff_adc->SetMarkerStyle(21);
   MacropEff_adc->SetMarkerSize(1.5);
   MacropEff_adc->SetMarkerColor(4.0);
   MacropEff_adc->SetAxisRange(0., 1.,"Y");
   MacropEff_adc->GetYaxis()->SetTitleOffset(1.26);
   Double_t TWA_adc=0;
   Double_t sumE_adc=0;
   Double_t Final_adc=0;
   Double_t error_adc=0.;
   Double_t BC_adc=0.;
   Double_t WA_adc=0.;
   //Double_t Final_adc=0.;
   for (int i = 0; i < 30; i++)
     {
       error_adc =   MacropEff_adc->GetBinError(i+2);
       sumE_adc = sumE_adc + error_adc;
       BC_adc =   MacropEff_adc->GetBinContent(i+2);
       WA_adc = BC_adc*error_adc;
       TWA_adc = TWA_adc + WA_adc ;
       Final_adc = TWA_adc/sumE_adc;
       // cout << "error_adc =  "<< error_adc << endl;
       // cout << "BC_adc =  "<< BC_adc << endl;
       // cout << "Final_adc =  "<< Final_adc << endl;
     } 
   TLine *line = new TLine(1,Final_adc,30,Final_adc);
   line->SetLineWidth(3);
   line->SetLineColor(2);
   //Write the eff value on the histogram 
   char tFinal_adc[40];
   char terror_adc[40];
   sprintf(tFinal_adc,"ADC Efficiency (%%) = %g",Final_adc*100);
   sprintf(terror_adc,"ADC Efficiency error (%%) = %g",error_adc*100);
   line->Draw();
   TPaveLabel *p = new TPaveLabel(0.3,0.6,0.7,0.7,tFinal_adc,"brNDC");
   p->Draw();
   TPaveLabel *p1 = new TPaveLabel(0.3,0.5,0.7,0.6,terror_adc,"brNDC");
   p1->Draw();
  }
  // ST Hit Efficiency histogram
  c1->cd(2);
  gPad->SetTicks();
  gPad->SetGrid();
  if (MacropEff) {
    MacropEff->Draw("E1");
    MacropEff->SetMarkerStyle(21);
    MacropEff->SetMarkerSize(1.5);
    MacropEff->SetMarkerColor(4.0);
    MacropEff->SetAxisRange(0., 1.,"Y");
    MacropEff->GetYaxis()->SetTitleOffset(1.26);
    Double_t TWA=0;
    Double_t sumE=0;
    Double_t Final=0; 
    Double_t error=0.;
    Double_t BC=0.;
//.........这里部分代码省略.........
开发者ID:JeffersonLab,项目名称:sim-recon,代码行数:101,代码来源:ST_Monitoring_Eff.C

示例2: if

mainClass(int luminosity=5000){ // luminosity is in /pb unit



  cutname[0]="nocut";cutname[1]="Njet_4";cutname[2]="ht_500" ;cutname[3]="mht_200";
  cutname[4]="delphi";cutname[5]="iso";
  cutname[6]="CSVM_0";
  cutname[7]="CSVM_1";
  cutname[8]="CSVM_2";
  cutname[9]="CSVM_3";

  WJtype[0]="EventsWith_1RecoMuon_0RecoElectron";
  TTbartype[0]="EventsWith_1RecoMuon_0RecoElectron";



// .....................................................................................................................................................//
// WJ Section
// .....................................................................................................................................................//

  //build a vector of scale factors
  //first load the cross sections into a vector
  vector<double> WJ_xs_vec;

  WJ_xs_vec.push_back(1817.0); // HT 100-200
  WJ_xs_vec.push_back(471.6);  // HT 200-400
  WJ_xs_vec.push_back(55.61);  // HT 400-600
  WJ_xs_vec.push_back(18.81);  // HT 600-Inf

  const int wjnHT = (int) WJ_xs_vec.size();   // Total number of HT bin samples

  for(int i=1; i<=wjnHT ; i++){
    if(i==1)sprintf(tempname,"../Results/results_WJ_HT-100to200_.root");
    else if(i==2)sprintf(tempname,"../Results/results_WJ_HT-200to400_.root");
    else if(i==3)sprintf(tempname,"../Results/results_WJ_HT-400to600_.root");
    else if(i==4)sprintf(tempname,"../Results/results_WJ_HT-600toInf_.root");
    else{cout << " Error!! There are only 4 WJet ht binned sample " << endl;}
    file = new TFile(tempname, "R");
    sprintf(tempname,"allEvents/nocut/MHT_nocut_allEvents");
    tempvalue = (luminosity*WJ_xs_vec[i-1])/((* (TH1D* ) file->Get(tempname)).GetEntries());

printf("Scale: %g, N: %g, Lum: %d, XS: %g \n ",tempvalue,((* (TH1D* ) file->Get(tempname)).GetEntries()),luminosity,WJ_xs_vec[i-1]);

    WJ_scalevec.push_back(tempvalue);
  }//end of loop over HTbins 
  std::cout << "WJ normalization scale factor determination done \n " << std::endl;




//..........................................//
// main histograms like HT, MHT, ...
//..........................................//

  // Load the files to a vector 
  // These are the HT, MHT, .. variables
  for(int i=1; i<=wjnHT ; i++){
    if(i==1)sprintf(tempname,"HadTauEstimation_WJ_HT-100to200_.root");
    else if(i==2)sprintf(tempname,"HadTauEstimation_WJ_HT-200to400_.root");
    else if(i==3)sprintf(tempname,"HadTauEstimation_WJ_HT-400to600_.root");
    else if(i==4)sprintf(tempname,"HadTauEstimation_WJ_HT-600toInf_.root");
    else{cout << " Error!! There are only 4 WJet ht binned sample " << endl;}
    WJ_inputfilevec.push_back(TFile::Open(tempname,"R"));
  }//end of loop over HTbins 

  // Stack
  tempstack = new THStack("stack","Binned Sample Stack");
  sprintf(tempname,"HadTauEstimation_WJ_stacked.root");
  file = new TFile(tempname,"RECREATE");
  histname.clear();
  histname[0]="weight";
  histname[1]="HT";
  histname[2]="MHT";
  histname[3]="NJet";
  histname[4]="NBtag";
  histname[5]="MuonPt";
  histname[6]="MtW";

  for(map<int , string >::iterator itt=WJtype.begin(); itt!=WJtype.end();itt++){        // loop over different event types

    cdtoitt = file->mkdir((itt->second).c_str());
    cdtoitt->cd();

    for(map<int , string >::iterator it=cutname.begin(); it!=cutname.end();it++){   // loop over different cutnames

      cdtoit =  cdtoitt->mkdir((it->second).c_str());
      cdtoit->cd();

      for(int j=0; j<histname.size(); j++){                                        // loop over different histograms

        for(int i=0; i<wjnHT ; i++){                                                  // loop over different HT bins

          //cout << "================================" << endl;
          //cout << "HT#: " <<i << ", WJtype: " << itt->second << ", cutname: " << it->second << ", hist#: " << j << endl;  
          sprintf(tempname,"%s/%s/%s_%s_%s",(itt->second).c_str(),(it->second).c_str(),(histname[j]).c_str(),(it->second).c_str(),(itt->second).c_str());
          temphist = (TH1D *) WJ_inputfilevec.at(i)->Get(tempname)->Clone();
          temphist->Scale(WJ_scalevec[i]);
          temphist->SetFillColor(i+2);
          tempstack->Add(temphist);

//.........这里部分代码省略.........
开发者ID:hatakeyamak,项目名称:RA2-RA2b-2015,代码行数:101,代码来源:Stack.cpp

示例3: getResvsub


//.........这里部分代码省略.........
	TH2F* heff = (TH2F*)feff->Get("rTotalEff3D");
      	TH1D* hpteff = (TH1D*)heff->ProjectionY("hpteff",heff->GetXaxis()->FindBin(-2.4),heff->GetXaxis()->FindBin(2.4)-1,"o");
	TArrayD *ptarr = (TArrayD*)heff->GetYaxis()->GetXbins();
	double *ptbinhisto = ptarr->GetArray();
	int NbinX = heff->GetXaxis()->GetNbins();
	int NbinY = heff->GetYaxis()->GetNbins();
	hpteff->Scale(1.0/NbinX);
        
		for(int itheta=0;itheta<ntheta;itheta++)
			dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin][isample];
	
		avgmultall[ibin]=1.0*totmultall[ibin][isample]/Nevent[ibin][isample];
                hpt[ibin] = (TH1D*)fhisto->Get(Form("D_%d/hpt",ibin));
                //TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,"hptre",ptbinhisto);
                //hpteffcorr[ibin] = (TH1D*)hptre->Clone(Form("hpteffcorr_%d",ibin));
                //hpteffcorr[ibin]->Divide(hpteff);
		for(int ivbin=0;ivbin<nvv; ivbin++){
			vmean[ibin][ivbin]=0;
			deltavmean[ibin][ivbin]=0;
			avgmult[ibin][ivbin]=1.0*totmult[ibin][ivbin]/Nevent[ibin][isample];
			avgpt[ibin][ivbin]=1.0*totpt[ibin][ivbin]/totmult[ibin][ivbin];
			avgeta[ibin][ivbin]=1.0*toteta[ibin][ivbin]/totmult[ibin][ivbin];
			for(int itheta=0;itheta<ntheta;itheta++){
				dN[ibin][itheta][ivbin]/=totmult[ibin][ivbin];
				TComplex Res=dN[ibin][itheta][ivbin]/dD[ibin][itheta];
				v[ibin][itheta][ivbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re();
				vmean[ibin][ivbin]+=v[ibin][itheta][ivbin];
				deltav[ibin][itheta][ivbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][ivbin]*(TMath::Exp(j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)));
				deltavmean[ibin][ivbin]+=deltav[ibin][itheta][ivbin];
			//	fstrv<<itheta<<"\t"<<v[ibin][itheta][ivbin]<<"\t"<<deltav[ibin][itheta][ivbin]<<endl;
			}
		deltavmean[ibin][ivbin]=TMath::Sqrt(deltavmean[ibin][ivbin])/2./Besselj01(mm);
		//fstrv<<endl;
		vmean[ibin][ivbin]/=ntheta;
		deltavmean[ibin][ivbin]/=TMath::Sqrt(ntheta);
		fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t"<<vmean[ibin][ivbin]<<"\t"<<deltavmean[ibin][ivbin]<<endl;
                if(ispt){
		if(binv[ivbin+1]>3.0) continue;
                totmulthisto[ibin][ivbin]=hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(binv[ivbin]),hpt[ibin]->GetXaxis()->FindBin(binv[ivbin+1])-1);
//                totmulthistocorr[ibin][ivbin]=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[ivbin]),hpteffcorr[ibin]->GetXaxis()->FindBin(binv[ivbin+1])-1);
                totmulthistocorr[ibin][ivbin]=totmulthisto[ibin][ivbin]/hpteff->GetBinContent(hpteff->FindBin((binv[ivbin]+binv[ivbin+1])/2));
		V_int[ibin][isample]+=vmean[ibin][ivbin]*totmult[ibin][ivbin];
		V_interr[ibin][isample]+=deltavmean[ibin][ivbin]*totmult[ibin][ivbin];
		V_intcorr[ibin][isample]+=vmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin];
		V_intcorrerr[ibin][isample]+=deltavmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin];
                }
		totmultall_[ibin][isample]+=totmult[ibin][ivbin];
		}
		V_int[ibin][isample]/=totmultall_[ibin][isample];
		V_interr[ibin][isample]/=totmultall_[ibin][isample];
		//V_intcorr[ibin][isample]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1);
		//V_intcorr[ibin][isample]/=totmulthistocorr[ibin];
		//V_intcorrerr[ibin][isample]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1);

                if(ispt){
        fstrv<<endl<<"pt range\t\t"<<"totmult"<<"\t\t"<<"totmult from histo"<<"\t"<<"totmult corrected"<<endl;
		for(int ivbin=0;ivbin<nvv; ivbin++){
                fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t\t"<<totmult[ibin][ivbin]<<"\t"<<totmulthisto[ibin][ivbin]<<"\t"<<totmulthistocorr[ibin][ivbin]<<endl;
		}
		//fstrv<<"Integral\t\t"<<totmultall[ibin][isample]<<"\t"<<hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(binv[0]),hpt[ibin]->GetXaxis()->FindBin(3.0)-1)<<"\t"<<hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1)<<endl;
		fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin][isample]<<"\t"<<"V int corr="<<V_intcorr[ibin][isample]<<endl;
		fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin][isample]<<"\t"<<"V int corr err="<<V_intcorrerr[ibin][isample]<<endl;
                }
	TDirectory *dirsample = dir0->mkdir(Form("s_%d",isample));
        dirsample->cd();
	avgpt[ibin].Write("avgpt");
	avgeta[ibin].Write("avgeta");
	totmult[ibin].Write("totmult");
	vmean[ibin].Write("vmean");
	deltavmean[ibin].Write("deltavmean");
	for(int ivbin=0;ivbin<nvv; ivbin++){
		avgavgpt[ibin][ivbin]+=avgpt[ibin][ivbin]*Nevent[ibin][isample];
		avgavgeta[ibin][ivbin]+=avgeta[ibin][ivbin]*Nevent[ibin][isample];
		vmeanmean[ibin][ivbin]+=vmean[ibin][ivbin]/nsamples;
        	deltavmeanmean[ibin][ivbin]+=deltavmean[ibin][ivbin]/nsamples;
	        sigmavmeanmean[ibin][ivbin]+=TMath::Power(vmean[ibin][ivbin]/nsamples,2);
	}
	}//subsample loop
	dir0->cd();
        IFILE[ibin].Write("IFILE");
	V_int[ibin].Write("V_int");
	V_interr[ibin].Write("V_interr");
	V_intcorr[ibin].Write("V_intcorr");
	V_intcorrerr[ibin].Write("V_intcorrerr");
	Nevent[ibin].Write("Nevent");
	totmultall[ibin].Write("totmultall");
	for(int ivbin=0;ivbin<nvv; ivbin++){
		avgavgpt[ibin][ivbin]/=Nevent_[ibin];
		avgavgeta[ibin][ivbin]/=Nevent_[ibin];
        	sigmavmeanmean[ibin][ivbin]=TMath::Sqrt(sigmavmeanmean[ibin][ivbin]*nsamples-vmeanmean[ibin][ivbin]*vmeanmean[ibin][ivbin])/TMath::Sqrt(nsamples);
		}
	avgavgpt[ibin].Write("avgavgpt");
	avgavgeta[ibin].Write("avgavgeta");
        vmeanmean[ibin].Write("vmeanmean");
	deltavmeanmean[ibin].Write("deltavmeanmean");
        sigmavmeanmean[ibin].Write("sigmavmeanmean");
	}//ntrk bin loop
	infile->Close();
	fout->Close();
}
开发者ID:satan1028,项目名称:HI,代码行数:101,代码来源:getResVsub.C

示例4: InputForLimits


//.........这里部分代码省略.........
      btagBCPercenth = new TH2F( *systematics[1]->sysh);
      btagBCPercenth->SetName("btagBCPercent");
      btagBCPercenth->SetTitle("btagBCPercent");
      btagBCPercenth->Divide( sigh);
      btagBCPercenth->Scale( 100.);   

      btagLightPercenth = new TH2F( *systematics[2]->sysh);
      btagLightPercenth->SetName("btagLightPercent");
      btagLightPercenth->SetTitle("btagLightPercent");
      btagLightPercenth->Divide( sigh);
      btagLightPercenth->Scale( 100.);   

      btagPercenth = new TH2F( *btagBCh);
      btagPercenth->Reset();
      btagPercenth->SetName("btagPercent");
      btagPercenth->SetTitle("btagPercent");
 
      sysPercenth = new TH2F( *jesh);
      sysPercenth->Reset();
      sysPercenth->SetName("sysPercent");
      sysPercenth->SetTitle("sysPercent");

      uncPercenth = new TH2F( *jesh);
      uncPercenth->Reset();
      uncPercenth->SetName("uncPercent");
      uncPercenth->SetTitle("uncPercent");

      for (int ibin = 0; ibin < sigh->GetSize(); ibin++){	
	sig = sigh->GetBinContent( ibin);
	stat = sigh->GetBinError( ibin);

	jes = jesh->GetBinContent(ibin);
	bc = btagBCh->GetBinContent(ibin);
	light = btagLighth->GetBinContent(ibin);
    
	unc = sqrt( bc * bc + light * light);
	btagh->SetBinContent( ibin, unc);
	btagPercenth->SetBinContent( ibin, unc / sig * 100.);
	
	unc = sqrt( jes * jes + bc * bc + light * light +
		    sig * sig * (0.044 * 0.044 + // Lumi
				 0.03  * 0.03  + // Trigger
				 0.05  * 0.05    // Lep Id
				 )
		    );       
	sysh->SetBinContent( ibin, unc);
	sysPercenth->SetBinContent( ibin, unc / sig * 100.);
	
	unc = sqrt( jes * jes + bc * bc + light * light + stat * stat +  
		    sig * sig * (0.044 * 0.044 + // Lumi
				 0.03  * 0.03  + // Trigger
				 0.05  * 0.05    // Lep Id
				 )
		    );	
	unch->SetBinContent( ibin, unc);
	uncPercenth->SetBinContent( ibin, unc / sig * 100.);
      }
      outSRDir->cd();

      datah->Write();
      bkgh->Write();

      sig_toth->Write();
      sigh->Write();
      effh->Write();
      
      sigLh->Write();
      effLh->Write();

      sigRh->Write();
      effRh->Write();

      jesh->Write();
      btagBCh->Write(); 
      btagLighth->Write();
      btagh->Write();
      
      sysh->Write();
      unch->Write();

      jesPercenth->Write();
      btagBCPercenth->Write(); 
      btagLightPercenth->Write();
      btagPercenth->Write();
      
      sysPercenth->Write();
      uncPercenth->Write();
    }
  }

  delete systematics[0];
  delete systematics[1];
  delete systematics[2];

  outFile->Close();
  sigFile->Close();
  bkgFile->Close();

  return 0;
}
开发者ID:fcostanz,项目名称:StopAnalysis,代码行数:101,代码来源:InputForLimits.C

示例5: GenerateTree

//_____________________________________________________________________________
Int_t ProofAux::GenerateTree(const char *fnt, Long64_t ent, TString &fn)
{
   // Generate the main tree for the 'friends' tutorial; the tree is called
   // 'Tmain', has 'ent' entries and is saved to file 'fnt'.
   // The full file path is returned in 'fn'.
   // Return 0 on success, -1 on error.

   Int_t rc = -1;

   // Check the filename
   fn = fnt;
   if (fn.IsNull()) {
      Error("GenerateTree", "file name undefined!");
      return rc;
   }
   TUrl uu(fn, kTRUE);
   if (!strcmp(uu.GetProtocol(), "file") && !fn.BeginsWith("/")) {
      // Local file with relative path: create under the data directory
      if (!gProofServ ||
          !(gProofServ->GetDataDir()) || strlen(gProofServ->GetDataDir()) <= 0) {
         Error("GenerateTree", "data directory undefined!");
         return rc;
      }
      // Insert data directory
      fn.Insert(0, TString::Format("%s/", gProofServ->GetDataDir()));
      // Make sure the directory exists
      TString dir = gSystem->DirName(fn);
      if (gSystem->AccessPathName(dir, kWritePermission)) {
         if (gSystem->mkdir(dir, kTRUE) != 0) {
            Error("GenerateTree", "problems creating directory %s to store the file", dir.Data());
            return rc;
         }
      }
   }

   // Create the file
   TDirectory* savedir = gDirectory;
   TFile *f = new TFile(fn, "RECREATE");
   if (!f || f->IsZombie()) {
      Error("GenerateTree", "problems opening file %s", fn.Data());
      return rc;
   }
   savedir->cd();
   rc = 0;

   // Create the tree
   TTree *T = new TTree("Tmain","Main tree for tutorial friends");
   T->SetDirectory(f);
   Int_t Run = 1;
   T->Branch("Run",&Run,"Run/I");
   Long64_t Event = 0;
   T->Branch("Event",&Event,"Event/L");
   Float_t x = 0., y = 0., z = 0.;
   T->Branch("x",&x,"x/F");
   T->Branch("y",&y,"y/F");
   T->Branch("z",&z,"z/F");
   TRandom r;
   for (Long64_t i = 0; i < ent; i++) {
      if (i > 0 && i%1000 == 0) Run++;
      Event = i;
      x = r.Gaus(10,1);
      y = r.Gaus(20,2);
      z = r.Landau(2,1);
      T->Fill();
   }
   T->Print();
   f->cd();
   T->Write();
   T->SetDirectory(0);
   f->Close();
   delete f;
   delete T;

   // Notify success
   Info("GenerateTree", "file '%s' successfully created", fn.Data());

   // Add to the list
   TString fds(fn);
   if (!strcmp(uu.GetProtocol(), "file")) {
      if (gSystem->Getenv("LOCALDATASERVER")) {
         if (strcmp(TUrl(gSystem->Getenv("LOCALDATASERVER"), kTRUE).GetProtocol(), "file"))
            fds.Insert(0, TString::Format("%s/", gSystem->Getenv("LOCALDATASERVER")));
      } else {
         fds.Insert(0, TString::Format("root://%s/", gSystem->HostName()));
      }
   }
   fMainList->Add(new TObjString(fds));

   // Done
   return rc;
}
开发者ID:gganis,项目名称:proof,代码行数:92,代码来源:ProofAux.C

示例6: combineDataCardsSM

void combineDataCardsSM(Int_t channel, Int_t cat, TString mass){

  TString ChannelName;
  if(channel==1)ChannelName="muTau";
  else if(channel==2)ChannelName="eleTau";
  else return;
  

  TFile nominal(ChannelName+"_SM"+(long)cat+"_"+mass+"_.root","read");
  TFile nominaltUp(ChannelName+"_SM"+(long)cat+"_"+mass+"_tUp.root","read");
  TFile nominaltDown(ChannelName+"_SM"+(long)cat+"_"+mass+"_tDown.root","read");


  TString scaleUp="CMS_scale_t_mutau_8TeVUp";
  TString scaleDown="CMS_scale_t_mutau_8TeVDown";
  if(channel==2)scaleUp="CMS_scale_t_etau_8TeVUp";
  if(channel==2)scaleDown="CMS_scale_t_etau_8TeVDown";


  TFile output(ChannelName+"_SM"+(long)cat+"_"+mass+".root","recreate");
  for(long sm=0;sm<NCAT;sm++){
    if(cat==13 && (sm==2 || sm==4))continue;//skip boost_low and vbf
    if(cat==20 && (sm==3 || sm==4))continue;//skip boost_high and vbf
    if(cat==23 && (sm==4))continue;//skip vbf
    if(cat==15 && (sm==2 || sm==3))continue;//skip boost_low and boost_high
    
    cout<<catdirname[sm]<<endl;

    TDirectory* dir = output.mkdir(ChannelName+"_"+catdirname[sm]);  
    dir->cd();


    /////////////Nominal histos:
    TH1F* ZTT = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/ZTT");
    TH1F* QCD = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/QCD");
    TH1F* W = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/W");
    TH1F* TT = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/TT");
    TH1F* ZL = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/ZL");
    TH1F* ZJ = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/ZJ");
    TH1F* VV = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/VV");
    TH1F* ZLL = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/ZLL");
    TH1F* data_obs = (TH1F*)nominal.Get(ChannelName+"_"+catdirname[sm]+"/data_obs");

    ZTT->Write();
    ZL->Write();
    ZJ->Write();
    ZLL->Write();
    W->Write();
    TT->Write();
    VV->Write();
    QCD->Write();
    data_obs->Write();

    /////////////tUp histos
    TH1F* ZTT_CMS_scale_tUp =  (TH1F*)nominaltUp.Get(ChannelName+"_"+catdirname[sm]+"/ZTT");
    ZTT_CMS_scale_tUp->SetName(TString("ZTT_")+scaleUp);

    TH1F* QCD_CMS_scale_tUp = (TH1F*)nominaltUp.Get(ChannelName+"_"+catdirname[sm]+"/QCD");
    QCD_CMS_scale_tUp->SetName(TString("QCD_")+scaleUp);

    TH1F* W_CMS_scale_tUp =  (TH1F*)nominaltUp.Get(ChannelName+"_"+catdirname[sm]+"/W");
    W_CMS_scale_tUp->SetName(TString("W_")+scaleUp);

    TH1F* TT_CMS_scale_tUp = (TH1F*)nominaltUp.Get(ChannelName+"_"+catdirname[sm]+"/TT");
    TT_CMS_scale_tUp->SetName(TString("TT_")+scaleUp);

    TH1F* ZL_CMS_scale_tUp = (TH1F*)nominaltUp.Get(ChannelName+"_"+catdirname[sm]+"/ZL");
    ZL_CMS_scale_tUp->SetName(TString("ZL_")+scaleUp);

    TH1F* ZJ_CMS_scale_tUp = (TH1F*)nominaltUp.Get(ChannelName+"_"+catdirname[sm]+"/ZJ");
    ZJ_CMS_scale_tUp->SetName(TString("ZJ_")+scaleUp);

    TH1F* VV_CMS_scale_tUp = (TH1F*)nominaltUp.Get(ChannelName+"_"+catdirname[sm]+"/VV");
    VV_CMS_scale_tUp->SetName(TString("VV_")+scaleUp);

    TH1F* ZLL_CMS_scale_tUp= (TH1F*)nominaltUp.Get(ChannelName+"_"+catdirname[sm]+"/ZLL");
    ZLL_CMS_scale_tUp->SetName(TString("ZLL_")+scaleUp);

    ZTT_CMS_scale_tUp->Write();
    ZL_CMS_scale_tUp->Write();
    ZJ_CMS_scale_tUp->Write();
    ZLL_CMS_scale_tUp->Write();
    W_CMS_scale_tUp->Write();
    TT_CMS_scale_tUp->Write();
    VV_CMS_scale_tUp->Write();
    QCD_CMS_scale_tUp->Write();


    /////////////tDown histos
    TH1F* ZTT_CMS_scale_tDown =  (TH1F*)nominaltDown.Get(ChannelName+"_"+catdirname[sm]+"/ZTT");
    ZTT_CMS_scale_tDown->SetName(TString("ZTT_")+scaleDown);

    TH1F* QCD_CMS_scale_tDown = (TH1F*)nominaltDown.Get(ChannelName+"_"+catdirname[sm]+"/QCD");
    QCD_CMS_scale_tDown->SetName(TString("QCD_")+scaleDown);

    TH1F* W_CMS_scale_tDown =  (TH1F*)nominaltDown.Get(ChannelName+"_"+catdirname[sm]+"/W");
    W_CMS_scale_tDown->SetName(TString("W_")+scaleDown);

    TH1F* TT_CMS_scale_tDown = (TH1F*)nominaltDown.Get(ChannelName+"_"+catdirname[sm]+"/TT");
    TT_CMS_scale_tDown->SetName(TString("TT_")+scaleDown);
//.........这里部分代码省略.........
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:101,代码来源:combineDataCardsSM.C

示例7: recurseFile

void recurseFile(TDirectory *indir, TDirectory *outdir,
                 double etawid, double etamid) {

  TDirectory *curdir = gDirectory;

  // Automatically go through the list of keys (directories)
  TList *keys = indir->GetListOfKeys();
  TListIter itkey(keys);
  TObject *key, *obj;
  TDirectory *dir;

  while ( (key = itkey.Next()) ) {

    if (_debug) cout << key->GetName() << endl << flush;
    obj = ((TKey*)key)->ReadObj(); assert(obj);
    dir = indir;

    // Found a subdirectory: copy it to output and go deeper
    if (obj->InheritsFrom("TDirectory")) {

      //assert(outdir->mkdir(obj->GetName()));
      outdir->mkdir(obj->GetName());
      assert(outdir->cd(obj->GetName()));
      TDirectory *outdir2 = outdir->GetDirectory(obj->GetName()); assert(outdir2);
      outdir2->cd();

      assert(indir->cd(obj->GetName()));
      TDirectory *indir2 = indir->GetDirectory(obj->GetName());
      indir2->cd();

      // Check if directory name contains information on eta bin width
      float etamin, etamax;
      if ( (sscanf(indir->GetName(),"Eta_%f-%f",&etamin,&etamax)==2)
           && (etamax>etamin) ) {
        etawid = 2.*(etamax-etamin);
        etamid = 0.5*(etamax+etamin);
        //cout << "Eta bin width: " << etawid << flush << endl;
      }

      recurseFile(indir2, outdir2, etawid, etamid);
      //outdir2->Write(); // does this speedup or slow down?
    } // inherits from TDirectory

    // Found a plot: normalize if hpt, then copy to output
    if (obj->InheritsFrom("TH1")) {

      outdir->cd();
      TObject *obj2 = obj->Clone(obj->GetName());

      // Normalize hpt and hselpt histograms
      // Same for hbpt
      if (string(obj2->GetName())=="hpt" ||
          string(obj2->GetName())=="hpt_evt" ||
          string(obj2->GetName())=="hpt_jet" ||
          string(obj2->GetName())=="hpt_pre" ||
          string(obj2->GetName())=="hpt0" ||
          string(obj2->GetName())=="hpt1" ||
          string(obj2->GetName())=="hpt2" ||
          string(obj2->GetName())=="hpt3" ||
          string(obj2->GetName())=="hpt_jk1" ||
          string(obj2->GetName())=="hpt_jk2" ||
          string(obj2->GetName())=="hpt_jk3" ||
          string(obj2->GetName())=="hpt_jk4" ||
          string(obj2->GetName())=="hpt_jk5" ||
          string(obj2->GetName())=="hpt_jk6" ||
          string(obj2->GetName())=="hpt_jk7" ||
          string(obj2->GetName())=="hpt_jk8" ||
          string(obj2->GetName())=="hpt_jk9" ||
          string(obj2->GetName())=="hpt_jk10" ||
          string(obj2->GetName())=="hpt_l1off" ||
          string(obj2->GetName())=="hpt_l1fast" ||
          string(obj2->GetName())=="hpt_plus" ||
          string(obj2->GetName())=="hpt_minus" ||
          string(obj2->GetName())=="hpt0_plus" ||
          string(obj2->GetName())=="hpt0_minus" ||
          string(obj2->GetName())=="hpt_noid" ||
          string(obj2->GetName())=="hpt_noevtid" ||
          string(obj2->GetName())=="hpt_nojetid" ||
          string(obj2->GetName())=="hpt_ak5calo" ||
          string(obj2->GetName())=="hpt_ak5pf" ||
          string(obj2->GetName())=="hpt_evt_ak5pf" ||
          string(obj2->GetName())=="hpt_jet_ak5pf" ||
          string(obj2->GetName())=="hselpt" ||
          string(obj2->GetName())=="hpt_r" ||
          string(obj2->GetName())=="hpt_g" ||
          string(obj2->GetName())=="hpt_gg" ||
          string(obj2->GetName())=="hpt_g0" ||
          string(obj2->GetName())=="hpt_g0tw" ||
          string(obj2->GetName())=="hdjmass" ||
          string(obj2->GetName())=="hdjmass0" ||
          string(obj2->GetName())=="hdjmass0_hgg") {

          cout << "." << flush;

        TH1D *hpt = (TH1D*)obj2;
        bool isgen = TString(obj2->GetName()).Contains("pt_g");
        bool isoth = (TString(obj2->GetName()).Contains("pt_no") ||
                      TString(obj2->GetName()).Contains("djmass") ||
                      TString(obj2->GetName()).Contains("hpt0") ||
                      TString(obj2->GetName()).Contains("l1off") ||
//.........这里部分代码省略.........
开发者ID:miquork,项目名称:jetphys,代码行数:101,代码来源:normalizeHistos.C

示例8: ScanChain

void makeVictorTemplates::ScanChain (TChain* chain){

  
  int npass = 0;
  bookHistos();
  
  TObjArray *listOfFiles = chain->GetListOfFiles();

  unsigned int nEventsChain = 0;

  unsigned int nEvents = chain->GetEntries();
  nEventsChain = nEvents;
  unsigned int nEventsTotal = 0;

  if(debug) cout << "Begin file loop" << endl;

  // file loop
  TIter fileIter(listOfFiles);

  TFile* currentFile = 0;

  while ((currentFile = (TFile*)fileIter.Next())){

    TFile f(currentFile->GetTitle());
    TTree *tree = (TTree*)f.Get("jetTree");
    //cms2.Init(tree);
    setBranches(tree);

    // event loop
    //unsigned int nEvents = tree->GetEntries();
    nEvents = tree->GetEntries();

    for (unsigned int event = 0 ; event < nEvents; ++event){
   
      tree->GetEntry(event);
      ++nEventsTotal;

      // progress feedback to user
      if (nEventsTotal % 1000 == 0){
            
        // xterm magic from L. Vacavant and A. Cerri
        if (isatty(1)){
                
          printf("\015\033[32m ---> \033[1m\033[31m%4.1f%%"
                 "\033[0m\033[32m <---\033[0m\015", (float)nEventsTotal/(nEventsChain*0.01));
          fflush(stdout);
        }
      }

      if( nJets_ < 2 )        continue;
      if( maxjetpt_ < 30. )   continue;

      int iJetBin          = getJetBin( nJets_ );
      int iSumJetPtBin     = getSumJetPtBin( sumJetPt_ );
      //int iBosonPtBin      = getBosonPtBin( etg_ );
      int iVtxBin          = getVtxBin( nvtx_ );
      float templateWeight = 1;//jet15U_L1Prescale_ * jet15U_HLTPrescale_;

      //fill templates binned by njets, sumjetpt, boson pt        
      //fillUnderOverFlow( tcmetTemplate[ iJetBin ][ iSumJetPtBin ][ iBosonPtBin ]    ,  tcmet_    , templateWeight );
      //fillUnderOverFlow( pfmetTemplate[ iJetBin ][ iSumJetPtBin ][ iBosonPtBin ]    ,  pfmet_    , templateWeight );
      
      //fill templates binned by njets, sumjetpt, nVtx
      fillUnderOverFlow( tcmetTemplate_njets_ht_nvtx[ iJetBin ][ iSumJetPtBin ][ iVtxBin ]    ,  tcmet_    , templateWeight );
      fillUnderOverFlow( pfmetTemplate_njets_ht_nvtx[ iJetBin ][ iSumJetPtBin ][ iVtxBin ]    ,  pfmet_    , templateWeight );
    
      //fill templates binned by njets, sumjetpt
      fillUnderOverFlow( tcmetTemplate_combined[ iJetBin ][ iSumJetPtBin ]    ,  tcmet_    , templateWeight );
      fillUnderOverFlow( pfmetTemplate_combined[ iJetBin ][ iSumJetPtBin ]    ,  pfmet_    , templateWeight );
      
      ++npass;

      int iTrigBin = -1;

      if( firedJet15U_ == 1 ){
        
        templateWeight = jet15U_L1Prescale_ * jet15U_HLTPrescale_;
        iTrigBin = 0;

        fillUnderOverFlow( tcmetTemplate_qcd[ iTrigBin ][ iJetBin ][ iSumJetPtBin ]    ,  tcmet_    , templateWeight );
        fillUnderOverFlow( pfmetTemplate_qcd[ iTrigBin ][ iJetBin ][ iSumJetPtBin ]    ,  pfmet_    , templateWeight );

        fillUnderOverFlow( hleadJetPt15 , maxjetpt_ , templateWeight );
      }

      if( firedJet30U_ == 1 ){
        
        templateWeight = jet30U_L1Prescale_ * jet30U_HLTPrescale_;
        iTrigBin = 1;

        fillUnderOverFlow( tcmetTemplate_qcd[ iTrigBin ][ iJetBin ][ iSumJetPtBin ]    ,  tcmet_    , templateWeight );
        fillUnderOverFlow( pfmetTemplate_qcd[ iTrigBin ][ iJetBin ][ iSumJetPtBin ]    ,  pfmet_    , templateWeight );

        fillUnderOverFlow( hleadJetPt30 , maxjetpt_ , templateWeight );
      }
      
      if( firedJet50U_ == 1 ){
        
        templateWeight = jet50U_L1Prescale_ * jet50U_HLTPrescale_;
        iTrigBin = 2;
//.........这里部分代码省略.........
开发者ID:hooberman,项目名称:UserCode,代码行数:101,代码来源:makeVictorTemplates.C

示例9: main

int main(int argc, char *argv[]){

	OptionParser(argc,argv);
	

	RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR);
	RooMsgService::instance().setSilentMode(true);


  
	system(Form("mkdir -p %s",outdir_.c_str()));

	vector<string> procs;
	split(infilenames_,infilenamesStr_,boost::is_any_of(","));
  
   TPython::Exec("import os,imp,re");
   for (unsigned int i =0 ; i<infilenames_.size() ; i++){
     TFile *infile =  TFile::Open(infilenames_[i].c_str());
	   string outname  =(string) TPython::Eval(Form("'%s'.split(\"/\")[-1].replace('root','_reduced.root')",infilenames_[i].c_str())); 
     TFile *outfile = TFile::Open(outname.c_str(),"RECREATE") ;
    TDirectory* saveDir = outfile->mkdir("tagsDumper");
    saveDir->cd();

    RooWorkspace *inWS = (RooWorkspace*) infile->Get("tagsDumper/cms_hgg_13TeV");
    RooRealVar *intLumi = (RooRealVar*)inWS->var("IntLumi");
    RooWorkspace *outWS = new RooWorkspace("cms_hgg_13TeV");
    outWS->import(*intLumi);
    std::list<RooAbsData*> data =  (inWS->allData()) ;
    std::cout <<" [INFO] Reading WS dataset contents: "<< std::endl;
        for (std::list<RooAbsData*>::const_iterator iterator = data.begin(), end = data.end(); iterator != end; ++iterator )  {
              RooDataSet *dataset = dynamic_cast<RooDataSet *>( *iterator );
              if (dataset) {
              RooDataSet *datasetReduced = (RooDataSet*) dataset->emptyClone(dataset->GetName(),dataset->GetName());
                TRandom3 r;
                r.Rndm();
                double x[dataset->numEntries()];
                r.RndmArray(dataset->numEntries(),x);
                int desiredEntries = floor(0.5+ dataset->numEntries()*fraction_);
                int modFraction = floor(0.5+ 1/fraction_);
                int finalEventCount=0;
                for (int j =0; j < dataset->numEntries() ; j++){
                    if( j%modFraction==0){
                      finalEventCount++;
                    }
                 }
                float average_weight= dataset->sumEntries()/finalEventCount;
                for (int j =0; j < dataset->numEntries() ; j++){
                    if( j%modFraction==0){
                    dataset->get(j);
                    datasetReduced->add(*(dataset->get(j)),average_weight);
                    }
                }
              float entriesIN =dataset->sumEntries();
              float entriesOUT =datasetReduced->sumEntries();
           if(verbose_){
              std::cout << "Original dataset " << *dataset <<std::endl;
              std::cout << "Reduced       dataset " << *datasetReduced <<std::endl;
              std::cout << "********************************************" <<std::endl;
              std::cout << "fraction (obs) : " << entriesOUT/entriesIN << std::endl;
              std::cout << "fraction (exp) : " << fraction_ << std::endl;
              std::cout << "********************************************" <<std::endl;
              std::cout << "" <<std::endl;
              std::cout << "" <<std::endl;
              std::cout << "" <<std::endl;
              std::cout << "********************************************" <<std::endl;
              }
               outWS->import(*datasetReduced);
                }
                
             RooDataHist *datahist = dynamic_cast<RooDataHist *>( *iterator );

              if (datahist) {
              RooDataHist *datahistOUT = (RooDataHist*) datahist->emptyClone(datahist->GetName(),datahist->GetName());
                TRandom3 r;
                r.Rndm();
                for (int j =0; j < datahist->numEntries() ; j++){
                    
                    datahistOUT->add(*(datahist->get(j)),datahist->weight());
                }
              float w =datahistOUT->sumEntries();
              float z =datahist->sumEntries();
           if(verbose_){
              std::cout << "Original datahist " << *datahist <<std::endl;
              std::cout << "Reduced  datahist " << *datahistOUT<<std::endl;
              std::cout << "********************************************" <<std::endl;
              std::cout << "WH fraction (obs) : " << w/(z) <<std::endl;
              std::cout << "WH fraction (exp) : " << fraction_ << std::endl;
              std::cout << "********************************************" <<std::endl;
              std::cout << "" <<std::endl;
              std::cout << "" <<std::endl;
              std::cout << "" <<std::endl;
              std::cout << "********************************************" <<std::endl;
              }
               outWS->import(*datahistOUT);
                }
                  }
   saveDir->cd();
   outWS->Write();
   outfile->Close();
   infile->Close();
//.........这里部分代码省略.........
开发者ID:ArnabPurohit,项目名称:flashggFinalFit,代码行数:101,代码来源:reduceSamples.cpp

示例10: getResv


//.........这里部分代码省略.........
	TVectorD avgpt[nbin];
	TVectorD v[nbin][ntheta],vmean[nbin],deltav[nbin][ntheta],deltavmean[nbin];
	if(isSum)	TFile *infile = TFile::Open("mergedV_Sum.root");
	else	TFile *infile = TFile::Open("mergedV_Prod.root");
	Nevent.ResizeTo(nbin);	Nevent.Zero();
	totmultall.ResizeTo(nbin);	totmultall.Zero();
	avgmultall.ResizeTo(nbin);
	V_int.ResizeTo(nbin);	V_int.Zero();
	for(int ibin=0;ibin<nbin;ibin++){
		totmult[ibin].ResizeTo(nptv);	totmult[ibin].Zero();
		avgmult[ibin].ResizeTo(nptv);	avgpt[ibin].ResizeTo(nptv);
		totpt[ibin].ResizeTo(nptv);	totpt[ibin].Zero();
		vmean[ibin].ResizeTo(nptv);	deltavmean[ibin].ResizeTo(nptv);
		V[ibin] = (TVectorD*) infile->Get(Form("D_%d/D_0/V",ibin));
		chi[ibin] = (TVectorD*) infile->Get(Form("D_%d/chi",ibin));
		V_mean = (TVectorD*) infile->Get(Form("D_%d/Vmean",ibin));
		for(int itheta=0;itheta<ntheta;itheta++){
			v[ibin][itheta].ResizeTo(nptv);	deltav[ibin][itheta].ResizeTo(nptv);
			dD[ibin][itheta]=0;
			for(int iptbin=0;iptbin<nptv;iptbin++){
				dN[ibin][itheta][iptbin]=0;
			}
		}
	}

        for(int ifile=0; ifile<nFileAll; ifile++){
	        if(isSum) f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/theta8/pPbDataV205m150/Anav_Prod_%d.root",ifile));
	        else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/theta8/pPbDataV205m150/Anav_Prod2_%d.root",ifile));
		TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get("Nevent");	
		TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get("totmultall");
		for(int ibin=0;ibin<nbin;ibin++){
			TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin));
			TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin));
			dDRe[ibin] = (TVectorD*)f[ifile]->Get(Form("dDRe_%d",ibin));
			dDIm[ibin] = (TVectorD*)f[ifile]->Get(Form("dDIm_%d",ibin));
			Nevent[ibin]+=(*Nevent_t)[ibin];
			totmultall[ibin]+=(*totmultall_t)[ibin];
			for(int iptbin=0;iptbin<nptv;iptbin++){
				totmult[ibin][iptbin]+=(*totmult_t)[iptbin];
				totpt[ibin][iptbin]+=(*totpt_t)[iptbin];
			}
			for(int itheta=0;itheta<ntheta;itheta++){
				dNRe[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNRe_%d_%d",ibin,itheta));
				dNIm[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNIm_%d_%d",ibin,itheta));
				dD[ibin][itheta]+=TComplex((*dDRe[ibin])[itheta],(*dDIm[ibin])[itheta]);
				for(int iptbin=0;iptbin<nptv;iptbin++)
					dN[ibin][itheta][iptbin]+=TComplex((*dNRe[ibin][itheta])[iptbin],(*dNIm[ibin][itheta])[iptbin]);
			}
		}
	f[ifile]->Close();
	}

	for(int ibin=0;ibin<nbin;ibin++)
		for(int itheta=0;itheta<ntheta;itheta++)
			dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin];
	
	for(int ibin=0;ibin<nbin;ibin++){
			avgmultall[ibin]=1.0*totmultall[ibin]/Nevent[ibin];
		for(int iptbin=0;iptbin<nptv; iptbin++){
			vmean[ibin][iptbin]=0;
			deltavmean[ibin][iptbin]=0;
			avgmult[ibin][iptbin]=1.0*totmult[ibin][iptbin]/Nevent[ibin];
			avgpt[ibin][iptbin]=1.0*totpt[ibin][iptbin]/totmult[ibin][iptbin];
			for(int itheta=0;itheta<ntheta;itheta++){
				dN[ibin][itheta][iptbin]/=totmult[ibin][iptbin];
				TComplex Res=dN[ibin][itheta][iptbin]/dD[ibin][itheta];
				v[ibin][itheta][iptbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re();
				vmean[ibin][iptbin]+=v[ibin][itheta][iptbin];
				deltav[ibin][itheta][iptbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][iptbin]*(TMath::Exp(j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)));
				deltavmean[ibin][iptbin]+=deltav[ibin][itheta][iptbin];
			//	fstrv<<itheta<<"\t"<<v[ibin][itheta][iptbin]<<"\t"<<deltav[ibin][itheta][iptbin]<<endl;
			}
		deltavmean[ibin][iptbin]=TMath::Sqrt(deltavmean[ibin][iptbin])/2./Besselj01(mm);
		//fstrv<<endl;
		vmean[ibin][iptbin]/=ntheta;
		deltavmean[ibin][iptbin]/=ntheta;
		fstrv<<ptbinv[iptbin]<<"-"<<ptbinv[iptbin+1]<<"\t"<<vmean[ibin][iptbin]<<"\t"<<deltavmean[ibin][iptbin]<<endl;
		V_int[ibin]+=vmean[ibin][iptbin]*totmult[ibin][iptbin];
		}
		V_int[ibin]/=totmultall[ibin];
		fstrv<<endl<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin]<<endl;
	}
	
	if(isSum)TFile *fout = new TFile("mergedv_Prod.root","Recreate");
	else TFile *fout = new TFile("mergedv_Prod2.root","Recreate");
	for(ibin=0;ibin<nbin;ibin++){
	Nevent.Write("Nevent");
	V_int.Write("V_int");
	TDirectory *dir = fout->mkdir(Form("D_%d",ibin));
	dir->cd();
	avgpt[ibin].Write("avgpt");
	totmult[ibin].Write("totmult");
	vmean[ibin].Write("vmean");
	deltavmean[ibin].Write("deltavmean");
	}
	
	infile->Close();
	fout->Close();
	
}
开发者ID:XuQiao,项目名称:HI,代码行数:101,代码来源:getResv.C

示例11: bookHistos

void makeVictorTemplates::bookHistos(){

  TDirectory *rootdir = gDirectory->GetDirectory("Rint:");
  rootdir->cd();

  hleadJetPt15  = new TH1F("hleadJetPt15", "",100,0,1000);
  hleadJetPt30  = new TH1F("hleadJetPt30", "",100,0,1000);
  hleadJetPt50  = new TH1F("hleadJetPt50", "",100,0,1000);
  hleadJetPt100 = new TH1F("hleadJetPt100","",100,0,1000);

  int maxmet = 200;

  for( int iJetBin = 0 ; iJetBin < nJetBins ; iJetBin++ ){
    for( int iSumJetPtBin = 0 ; iSumJetPtBin < nSumJetPtBins ; iSumJetPtBin++ ){
      for( int iBosonPtBin = 0 ; iBosonPtBin < nBosonPtBins ; iBosonPtBin++ ){
        
        tcmetTemplate[iJetBin][iSumJetPtBin][iBosonPtBin] = new TH1F(Form("tcmetTemplate_%i_%i_%i",iJetBin,iSumJetPtBin,iBosonPtBin),
                                                                     Form("%s, %s, %s",jetString(iJetBin).c_str(),sumJetPtString(iSumJetPtBin).c_str(),
                                                                          bosonPtString(iBosonPtBin).c_str()),maxmet,0,maxmet);
        
        pfmetTemplate[iJetBin][iSumJetPtBin][iBosonPtBin] = new TH1F(Form("pfmetTemplate_%i_%i_%i",iJetBin,iSumJetPtBin,iBosonPtBin),
                                                                     Form("%s, %s, %s",jetString(iJetBin).c_str(),sumJetPtString(iSumJetPtBin).c_str(),
                                                                          bosonPtString(iBosonPtBin).c_str()),maxmet,0,maxmet);
        
        tcmetTemplate[iJetBin][iSumJetPtBin][iBosonPtBin]->Sumw2();
        pfmetTemplate[iJetBin][iSumJetPtBin][iBosonPtBin]->Sumw2();
        
        tcmetTemplate[iJetBin][iSumJetPtBin][iBosonPtBin]->GetXaxis()->SetTitle("tcmet (GeV)");
        pfmetTemplate[iJetBin][iSumJetPtBin][iBosonPtBin]->GetXaxis()->SetTitle("pfmet (GeV)");          
        
      }
    }
  }

  for( int iJetBin = 0 ; iJetBin < nJetBins ; iJetBin++ ){
    for( int iSumJetPtBin = 0 ; iSumJetPtBin < nSumJetPtBins ; iSumJetPtBin++ ){
      for( int iVtxBin = 0 ; iVtxBin < nVtxBins ; iVtxBin++ ){
        
        tcmetTemplate_njets_ht_nvtx[iJetBin][iSumJetPtBin][iVtxBin] = new TH1F(Form("tcmetTemplate_njets_ht_nvtx_%i_%i_%i",iJetBin,iSumJetPtBin,iVtxBin),
                                                                               Form("%s, %s, %s",jetString(iJetBin).c_str(),sumJetPtString(iSumJetPtBin).c_str(),
                                                                                    nVTXString(iVtxBin).c_str()),maxmet,0,maxmet);
                
        pfmetTemplate_njets_ht_nvtx[iJetBin][iSumJetPtBin][iVtxBin] = new TH1F(Form("pfmetTemplate_njets_ht_nvtx_%i_%i_%i",iJetBin,iSumJetPtBin,iVtxBin),
                                                                               Form("%s, %s, %s",jetString(iJetBin).c_str(),sumJetPtString(iSumJetPtBin).c_str(),
                                                                                    nVTXString(iVtxBin).c_str()),maxmet,0,maxmet);
        
        tcmetTemplate_njets_ht_nvtx[iJetBin][iSumJetPtBin][iVtxBin]->Sumw2();
        pfmetTemplate_njets_ht_nvtx[iJetBin][iSumJetPtBin][iVtxBin]->Sumw2();
        
        tcmetTemplate_njets_ht_nvtx[iJetBin][iSumJetPtBin][iVtxBin]->GetXaxis()->SetTitle("tcmet (GeV)");
        pfmetTemplate_njets_ht_nvtx[iJetBin][iSumJetPtBin][iVtxBin]->GetXaxis()->SetTitle("pfmet (GeV)");          
        
      }
    }
  }
  
  
  for( int iJetBin = 0 ; iJetBin < nJetBins ; iJetBin++ ){
    for( int iSumJetPtBin = 0 ; iSumJetPtBin < nSumJetPtBins ; iSumJetPtBin++ ){
      
      
      tcmetTemplate_combined[iJetBin][iSumJetPtBin] = new TH1F(Form("tcmetTemplate_combined_%i_%i",iJetBin,iSumJetPtBin),
                                                               Form("%s, %s",jetString(iJetBin).c_str(),sumJetPtString(iSumJetPtBin).c_str()),maxmet,0,maxmet);
      
      pfmetTemplate_combined[iJetBin][iSumJetPtBin] = new TH1F(Form("pfmetTemplate_combined_%i_%i",iJetBin,iSumJetPtBin),
                                                               Form("%s, %s",jetString(iJetBin).c_str(),sumJetPtString(iSumJetPtBin).c_str()),maxmet,0,maxmet);
      
      tcmetTemplate_combined[iJetBin][iSumJetPtBin]->Sumw2();
      pfmetTemplate_combined[iJetBin][iSumJetPtBin]->Sumw2();
      
      tcmetTemplate_combined[iJetBin][iSumJetPtBin]->GetXaxis()->SetTitle("tcmet (GeV)");
      pfmetTemplate_combined[iJetBin][iSumJetPtBin]->GetXaxis()->SetTitle("pfmet (GeV)");          
      
    }
  }
  
  char* trigName[4]={"15U","30U","50U","100U"};

  for( int iTrigBin = 0 ; iTrigBin < 4 ; iTrigBin++ ){
    for( int iJetBin = 0 ; iJetBin < nJetBins ; iJetBin++ ){
      for( int iSumJetPtBin = 0 ; iSumJetPtBin < nSumJetPtBins ; iSumJetPtBin++ ){
        
        
        tcmetTemplate_qcd[iTrigBin][iJetBin][iSumJetPtBin] = new TH1F(Form("tcmetTemplate_qcd_%i_%i_%i",iTrigBin,iJetBin,iSumJetPtBin),
                                                                      Form("%s, %s, %s",trigName[iTrigBin],
                                                                           jetString(iJetBin).c_str(),sumJetPtString(iSumJetPtBin).c_str()),maxmet,0,maxmet);

        pfmetTemplate_qcd[iTrigBin][iJetBin][iSumJetPtBin] = new TH1F(Form("pfmetTemplate_qcd_%i_%i_%i",iTrigBin,iJetBin,iSumJetPtBin),
                                                                      Form("%s, %s, %s",trigName[iTrigBin],
                                                                           jetString(iJetBin).c_str(),sumJetPtString(iSumJetPtBin).c_str()),maxmet,0,maxmet);
        
 
        
        tcmetTemplate_qcd[iTrigBin][iJetBin][iSumJetPtBin]->Sumw2();
        pfmetTemplate_qcd[iTrigBin][iJetBin][iSumJetPtBin]->Sumw2();
        
        tcmetTemplate_qcd[iTrigBin][iJetBin][iSumJetPtBin]->GetXaxis()->SetTitle("tcmet (GeV)");
        pfmetTemplate_qcd[iTrigBin][iJetBin][iSumJetPtBin]->GetXaxis()->SetTitle("pfmet (GeV)");          
        
      }
//.........这里部分代码省略.........
开发者ID:hooberman,项目名称:UserCode,代码行数:101,代码来源:makeVictorTemplates.C

示例12: plotMergedHisto


//.........这里部分代码省略.........
  std::vector<TH1*>::const_iterator bkgZZEventsNumberTH1vector_itr = bkgZZEventsNumberTH1vector.begin();  
  indexSample = 0;
  for ( ; bkgZZEventsNumberTH1vector_itr != bkgZZEventsNumberTH1vector.end(); ++bkgZZEventsNumberTH1vector_itr,
	                                                                      indexSample++) { 
    double sampleEvents = (*bkgZZEventsNumberTH1vector_itr)->GetMaximum();
    bkgZZCrossSections[indexSample] = bkgZZCrossSections[indexSample]/sampleEvents;
  }
  std::vector<TH1*> bkgZbbEventsNumberTH1vector;
  findObj( bkgZbbEventsNumberTH1vector, 
	   bkgZbbFileList, 
	   "eventsNumber", 
	   &bkgZbbFileSuffix
	   );
  std::vector<TH1*>::const_iterator bkgZbbEventsNumberTH1vector_itr = bkgZbbEventsNumberTH1vector.begin();  
  indexSample = 0;
  for ( ; bkgZbbEventsNumberTH1vector_itr != bkgZbbEventsNumberTH1vector.end(); ++bkgZbbEventsNumberTH1vector_itr,
	                                                                        indexSample++) { 
    double sampleEvents = (*bkgZbbEventsNumberTH1vector_itr)->GetMaximum();
    bkgZbbCrossSections[indexSample] = bkgZbbCrossSections[indexSample]/sampleEvents;
  }


  TFile * outputFile = TFile::Open( outputFileName, "RECREATE" );

  std::vector<TString>::const_iterator varNameVector_itr = varNameVector.begin();
  for ( ; varNameVector_itr != varNameVector.end(); ++varNameVector_itr ) {
    std::vector<TH1*> TH1vector;
    std::vector<TH1*> bkgZZTH1vector;
    std::vector<TH1*> bkgZbbTH1vector;
    findObj( TH1vector, 
	     sgnFileList, 
	     *varNameVector_itr, 
	     &sgnFileSuffix,
	     "TH1",
	     &sgnCrossSections
	     );
    findObj( bkgZZTH1vector, 
	     bkgZZFileList, 
	     *varNameVector_itr, 
	     &bkgZZFileSuffix,
	     "TH1",
	     &bkgZZCrossSections
	     );
    findObj( bkgZbbTH1vector, 
	     bkgZbbFileList, 
	     *varNameVector_itr, 
	     &bkgZbbFileSuffix,
	     "TH1",
	     &bkgZbbCrossSections
	     );

    //    TH1vector.push_back(mergeObj((*varNameVector_itr)+"_ZZNjets", bkgZZTH1vector, &bkgZZCrossSections, "kTRUE","kTRUE"));
    //    TH1vector.push_back(mergeObj((*varNameVector_itr)+"_ZbbNjets",bkgZbbTH1vector,&bkgZbbCrossSections,"kTRUE","kTRUE"));
    TH1vector.push_back(mergeObj((*varNameVector_itr)+"_ZZNjets", bkgZZTH1vector));
    TH1vector.push_back(mergeObj((*varNameVector_itr)+"_ZbbNjets",bkgZbbTH1vector));

    std::cout << "TH1vector.size(): " << TH1vector.size() << std::endl;

    // THStackLegend histogram
    TString Stack( "Stack_" );
    THStackLegend<TH1> * StackLegend_ = new THStackLegend<TH1>( *varNameVector_itr, 0.6,0.68,0.98,0.97 );

    outputFile->cd();
    TDirectory * directory = outputFile->mkdir( *varNameVector_itr, *varNameVector_itr );
    directory->cd();
    std::vector<TH1*>::const_iterator TH1vector_itr = TH1vector.begin();
    for ( ; TH1vector_itr != TH1vector.end(); ++TH1vector_itr ) {
      TH1 * histo = (TH1*)(*TH1vector_itr)->Clone();
      TString histoName = histo->GetName();
      TString sample = histoName.Remove(0,(*varNameVector_itr).Length()+1);
      FashionAttributedHisto<TH1D> * dressedHisto;
      bool dressed = false;
      if (      sample.Contains("VBFH160ZZ") ) { dressedHisto = new H160<TH1D>((TH1D*)histo);       dressed = true; }
      else if ( sample.Contains("VBFH200ZZ") ) { dressedHisto = new H200<TH1D>((TH1D*)histo);	    dressed = true; }
      else if ( sample.Contains("VBFH400ZZ") ) { dressedHisto = new H400<TH1D>((TH1D*)histo);	    dressed = true; }
      else if ( sample.Contains("VBFH800ZZ") ) { dressedHisto = new H800<TH1D>((TH1D*)histo);	    dressed = true; }
      else if ( sample.Contains("ZZ" ) && sample.Contains("jets") ) { dressedHisto = new ZZNjets<TH1D>((TH1D*)histo);  dressed = true; }
      else if ( sample.Contains("Zbb") && sample.Contains("jets") ) { dressedHisto = new ZbbNjets<TH1D>((TH1D*)histo); dressed = true; }
      else if ( sample.Contains("WZ" ) && sample.Contains("jets") ) { dressedHisto = new WZNjets<TH1D>((TH1D*)histo);  dressed = true; }
      else if ( sample.Contains("tt" ) && sample.Contains("jets") ) { dressedHisto = new ttNjets<TH1D>((TH1D*)histo);  dressed = true; }
      else dressedHisto = new FashionAttributedHisto<TH1D>((TH1D*)histo);
      char nev[50];
      sprintf(nev,sample+": %.2f",dressedHisto->Integral());
      StackLegend_->Add(dressedHisto,nev,false,"lf",false,dressed);
      //      StackLegend_->Add(dressedHisto,sample,false,"fl",false,dressed);

      dressedHisto->Write();
    }
    StackLegend_->SetLogY();
    StackLegend_->Print("nostack",*varNameVector_itr+"MergedMultiPlot.jpg");
    StackLegend_->Write("nostackhisto");
    StackLegend_->Draw("nostackhisto");
    //    StackLegend_->SavePrimitive(Stack+*varNameVector_itr+".C","nostackhisto");

    //    TH1vector.clear();
    //    bkgZZTH1vector.clear();
    //    bkgZbbTH1vector.clear();
  }

}
开发者ID:mtosi,项目名称:UserCode,代码行数:101,代码来源:plotMergedHisto.C

示例13: SanityCheck

void SanityCheck() { 
    
    // 
    // Get tree 
    // 
    //TFile *f = TFile::Open("cfA/cfA_QCD_HT-1000ToInf_TuneZ2star_8TeV-madgraph-pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB2029_v71_f1_1_YWH_Test.root", "READ");
    //TFile *f = TFile::Open("cfA/cfA_JetHT_Run2012D-PromptReco-v1_AOD_UCSB2030_v71_f1_1_fip_Test.root", "READ");
    TFile *f = TFile::Open("cfA/NopT10Cut/cfA_QCD_HT-1000ToInf_TuneZ2star_8TeV-madgraph-pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB2048_v71_f1_1_DGh_Test.root", "READ");
    //TFile *f = TFile::Open("cfA/NopT10Cut/cfA_JetHT_Run2012D-PromptReco-v1_AOD_UCSB2049_v71_f1000_1_473_Test.root", "READ");
    TDirectory* dir = f->GetDirectory("configurableAnalysis");
    dir->cd();
    TTree *eventB = (TTree*)dir->Get("eventB");
    
    // 
    // set address of variables to read 
    // 

    // event info
    UInt_t   event_ = 0;
    eventB->SetBranchAddress("event", &event_);
    UInt_t   run_ = 0;
    eventB->SetBranchAddress("run", &run_);
    UInt_t   lumiblock_ = 0;
    eventB->SetBranchAddress("lumiblock", &lumiblock_);
    // jets
    vector<float>   *jets_AK5PFclean_px_ = 0;
    eventB->SetBranchAddress("jets_AK5PFclean_px", &jets_AK5PFclean_px_);
    vector<float>   *jets_AK5PFclean_py_ = 0;
    eventB->SetBranchAddress("jets_AK5PFclean_py", &jets_AK5PFclean_py_);
    vector<float>   *jets_AK5PFclean_pz_ = 0;
    eventB->SetBranchAddress("jets_AK5PFclean_pz", &jets_AK5PFclean_pz_);
    vector<float>   *jets_AK5PFclean_energy_ = 0;
    eventB->SetBranchAddress("jets_AK5PFclean_energy", &jets_AK5PFclean_energy_);
    vector<float>   *jets_AK5PFclean_phi_ = 0;
    eventB->SetBranchAddress("jets_AK5PFclean_phi", &jets_AK5PFclean_phi_);
    vector<float>   *jets_AK5PFclean_eta_ = 0;
    eventB->SetBranchAddress("jets_AK5PFclean_eta", &jets_AK5PFclean_eta_);
    vector<float>   *jets_AK5PFclean_rawPt_ = 0;
    eventB->SetBranchAddress("jets_AK5PFclean_rawPt", &jets_AK5PFclean_rawPt_);
    vector<float>   *jets_AK5PF_rawPt_ = 0;
    eventB->SetBranchAddress("jets_AK5PF_rawPt", &jets_AK5PF_rawPt_);
    // fastjets
    vector<float>   *fastjets_AK5PF_px_ = 0;
    eventB->SetBranchAddress("fastjets_AK5PF_px", &fastjets_AK5PF_px_);
    vector<float>   *fastjets_AK5PF_py_ = 0;
    eventB->SetBranchAddress("fastjets_AK5PF_py", &fastjets_AK5PF_py_);
    vector<float>   *fastjets_AK5PF_pz_ = 0;
    eventB->SetBranchAddress("fastjets_AK5PF_pz", &fastjets_AK5PF_pz_);
    vector<float>   *fastjets_AK5PF_energy_ = 0;
    eventB->SetBranchAddress("fastjets_AK5PF_energy", &fastjets_AK5PF_energy_);
    vector<float>   *fastjets_AK5PF_phi_ = 0;
    eventB->SetBranchAddress("fastjets_AK5PF_phi", &fastjets_AK5PF_phi_);
    vector<float>   *fastjets_AK5PF_eta_ = 0;
    eventB->SetBranchAddress("fastjets_AK5PF_eta", &fastjets_AK5PF_eta_);
   
    // 
    //  loop over entries
    // 
    Int_t nentries = (Int_t)eventB->GetEntries();
    cout<<"The number of entries is: "<<nentries<<endl;

    TH1F *h1_pT_jets            = new TH1F("h1_pT_jets","h1_pT_jets", 100, 0, 1000);
    TH1F *h1_pT_fastjets        = new TH1F("h1_pT_fastjets","h1_pT_fastjets", 100, 0, 1000);
    TH1F *h1_eta_jets           = new TH1F("h1_eta_jets","h1_eta_jets", 100, -5, 5);
    TH1F *h1_eta_fastjets       = new TH1F("h1_eta_fastjets","h1_eta_fastjets", 100, -5, 5);
    TH1F *h1_phi_jets           = new TH1F("h1_phi_jets","h1_phi_jets", 100, -0.5, 0.5);
    TH1F *h1_phi_fastjets       = new TH1F("h1_phi_fastjets","h1_phi_fastjets", 100, -0.5, 0.5);
    TH1F *h1_njets_jets         = new TH1F("h1_njets_jets","h1_njets_jets", 15, -0.5, 14.5);
    TH1F *h1_njets_fastjets     = new TH1F("h1_njets_fastjets","h1_njets_fastjets", 15, -0.5, 14.5);
    
    TH1F *h1_pT_diff       = new TH1F("h1_pT_diff","h1_pT_diff", 100, -10, 10);
    //TH1F *h1_pT_diff       = new TH1F("h1_pT_diff","h1_pT_diff", 100, -0.5, 0.5);
    TH1F *h1_eta_diff      = new TH1F("h1_eta_diff","h1_eta_diff", 100, -0.1, 0.1);
    TH1F *h1_phi_diff      = new TH1F("h1_phi_diff","h1_phi_diff", 100, -0.1, 0.1);

    // pT threshold for Njets counting
    const float JetpTthres=30;

    // main event loop
    for(int ib = 0; ib<nentries; ib++) {
    //for(int ib = 0; ib<10; ib++) { // DEBUG
       
        if(ib%500==0) cout << "Entry : " << ib << endl; 

        // get entry of an event 
        eventB->GetEntry(ib);
        // 
        // Before matching 
        // 
        // Number of jets 
        int Njets=0;
        for(int ijet=0; ijet<(int)jets_AK5PFclean_rawPt_->size(); ijet++) {
            if(jets_AK5PFclean_rawPt_->at(ijet)>JetpTthres) Njets++;
        }
        int Nfastjets=0;
        for(int ifastjet=0; ifastjet<(int)fastjets_AK5PF_px_->size(); ifastjet++) {
            float pT = TMath::Sqrt( fastjets_AK5PF_px_->at(ifastjet)*fastjets_AK5PF_px_->at(ifastjet)
                                   +fastjets_AK5PF_py_->at(ifastjet)*fastjets_AK5PF_py_->at(ifastjet));
            if(pT>JetpTthres) Nfastjets++; 
        }
//.........这里部分代码省略.........
开发者ID:RohanBhandari,项目名称:MJ,代码行数:101,代码来源:SanityCheck.C

示例14: Loop

void TagAndProbeAnalysis::Loop()
{
  if (fChain == 0) return;

  readR9Weights();
  
  // output file
  TFile *outFile[5];
  outFile[0] = new TFile(outFileNamePrefix+"_tag"+tagTightnessLevel+(mcMatch==0 ? "" : "_mcMatch"+TString::Format("%d",mcMatch))+"_HLT"+".root","RECREATE");
  outFile[1] = new TFile(outFileNamePrefix+"_tag"+tagTightnessLevel+(mcMatch==0 ? "" : "_mcMatch"+TString::Format("%d",mcMatch))+"_HLT"+"30.root","RECREATE");
  outFile[2] = new TFile(outFileNamePrefix+"_tag"+tagTightnessLevel+(mcMatch==0 ? "" : "_mcMatch"+TString::Format("%d",mcMatch))+"_HLT"+"50.root","RECREATE");
  outFile[3] = new TFile(outFileNamePrefix+"_tag"+tagTightnessLevel+(mcMatch==0 ? "" : "_mcMatch"+TString::Format("%d",mcMatch))+"_HLT"+"75.root","RECREATE");
  outFile[4] = new TFile(outFileNamePrefix+"_tag"+tagTightnessLevel+(mcMatch==0 ? "" : "_mcMatch"+TString::Format("%d",mcMatch))+"_HLT"+"90.root","RECREATE");

  // output trees declaration
  TTree *myTree[5];
  for (int ii=0; ii<5; ii++) {
    outFile[ii]->cd();
    TDirectory* outputDirectory = outFile[ii]->mkdir("myTaPDir");
    outputDirectory->cd();
    myTree[ii] = new TTree();
    myTree[ii] -> SetName("myTree");
  }

  float mass;
  float probe_eta, probe_abseta, probe_phi, probe_pt, probe_r9;
  int numvtx;
  float rho;
  float r9weight_EB;
  float r9weight_EE;
  float puW;
  float puW30, puW50, puW75, puW90;  
  int okLooseElePtEta,  okLooseEleID;
  int okMediumElePtEta, okMediumEleID; 
  int okTightElePtEta,  okTightEleID; 
  int okMVA_005, okMVA_01, okMVA_02;
  int hasPromptElectronMatched;
  

  for (int ii=0; ii<5; ii++) {
    myTree[ii] -> Branch("mass",&mass,"mass/F");
    myTree[ii] -> Branch("probe_eta",&probe_eta,"probe_eta/F");
    myTree[ii] -> Branch("probe_abseta",&probe_abseta,"probe_abseta/F");
    myTree[ii] -> Branch("probe_phi",&probe_phi,"probe_phi/F");
    myTree[ii] -> Branch("probe_pt",&probe_pt,"probe_pt/F");
    myTree[ii] -> Branch("probe_r9",&probe_r9,"probe_r9/F");
    myTree[ii] -> Branch("numvtx",&numvtx,"numvtx/I");
    myTree[ii] -> Branch("rho",&rho,"rho/F");
    myTree[ii] -> Branch("puW",  &puW,  "puW/F");
    myTree[ii] -> Branch("r9WeightEB",  &r9weight_EB,  "r9WeightEB/F");
    myTree[ii] -> Branch("r9WeightEE",  &r9weight_EE,  "r9WeightEE/F");
    myTree[ii] -> Branch("puW30",&puW30,"puW30/F");
    myTree[ii] -> Branch("puW50",&puW50,"puW50/F");
    myTree[ii] -> Branch("puW75",&puW75,"puW75/F");
    myTree[ii] -> Branch("puW90",&puW90,"puW90/F");
    myTree[ii] -> Branch("okLooseElePtEta",&okLooseElePtEta,"okLooseElePtEta/I");
    myTree[ii] -> Branch("okLooseEleID",&okLooseEleID,"okLooseEleID/I");
    myTree[ii] -> Branch("okMediumElePtEta",&okMediumElePtEta,"okMediumElePtEta/I");
    myTree[ii] -> Branch("okMediumEleID",&okMediumEleID,"okMediumEleID/I");
    myTree[ii] -> Branch("okTightElePtEta",&okTightElePtEta,"okTightElePtEta/I");
    myTree[ii] -> Branch("okTightEleID",&okTightEleID,"okTightEleID/I");
    myTree[ii] -> Branch("okMVA_005",&okMVA_005,"okMVA_005/I");
    myTree[ii] -> Branch("okMVA_01",&okMVA_01,"okMVA_01/I");
    myTree[ii] -> Branch("okMVA_02",&okMVA_02,"okMVA_02/I");
    myTree[ii] -> Branch("hasPromptElectronMatched",&hasPromptElectronMatched,"hasPromptElectronMatched/I");
  }

  // Loop over events
  Long64_t nentries = fChain->GetEntriesFast();
  Long64_t nbytes = 0, nb = 0;

  cout << "Going to loop over " << nentries << " events" << endl;
  cout << endl;
  for (Long64_t jentry=0; jentry<nentries;jentry++) {
    Long64_t ientry = LoadTree(jentry);

    if (ientry < 0) break;
    nb = fChain->GetEntry(jentry);   nbytes += nb;

    if (jentry%5000==0) cout << "Read entry " << jentry << endl;

    for (int iEle=0; iEle<nEle; iEle++) {
      if (isMC && mcMatch)
	if (!isGenMatchEle[iEle])
	  continue;

      if (tagTightnessLevel=="Tight")
	{
	  if (!isTagTightEle[iEle])
	    continue;
	}
      else if (tagTightnessLevel=="Medium")
	{
	  if (!isTagMediumEle[iEle])
	    continue;
	}
      else if (tagTightnessLevel=="Loose")
	{
	  if (!isTagLooseEle[iEle])
	    continue;
//.........这里部分代码省略.........
开发者ID:vtavolar,项目名称:GammaJets,代码行数:101,代码来源:TagAndProbeAnalysis.C

示例15: doAll


//.........这里部分代码省略.........
    cout << "Adding all photon data" << endl;

    pickSkimIfExists(chPhotonData,"/hadoop/cms/store/user/yanjuntu/CMSSW_5_2_3_patch3_V05-02-07/DoubleElectron_Run2012A-PromptReco-v1_AOD/unmerged/*root");
    pickSkimIfExists(chPhotonData,"/hadoop/cms/store/user/macneill/CMSSW_5_2_3_patch3_V05-02-07/Photon_Run2012A-PromptReco-v1_AOD/unmerged/*root");
  }

  //----------------------------------------------------------------------------------------------------------
  // run on samples
  //----------------------------------------------------------------------------------------------------------

  if (runData2012A) {
    cout << "Processing all 2012A muon trigger data" << endl;
    looper->ScanChain(chData2012A,"data2012A_mutrig");
    cout << "Done processing all 2012A muon trigger data" << endl;
  }

  if (runData2012B) {
    cout << "Processing all 2012B muon trigger data" << endl;
    looper->ScanChain(chData2012B,"data2012B_mutrig");
    cout << "Done processing all 2012B muon trigger data" << endl;
  }

  if (runData2012C) {
    cout << "Processing all 2012C muon trigger data" << endl;
    looper->ScanChain(chData2012C,"data2012C_mutrig");
    cout << "Done processing all 2012C muon trigger data" << endl;
  }

  if (runData) {
    cout << "Processing all data" << endl;
    looper->ScanChain(chData,"allData");
    cout << "Done processing all data" << endl;
  }

  if (runDoubleMuData) {
    cout << "Processing double muon data" << endl;
    looper->ScanChain(chDoubleMuData,"doubleMuData");
    cout << "Done processing double muon data" << endl;
  }

  if (runSingleMuData) {
    cout << "Processing single muon data" << endl;
    looper->ScanChain(chSingleMuData,"singleMuData");
    cout << "Done processing single muon data" << endl;
  }

  if (runSingleElData) {
    cout << "Processing single electron data" << endl;
    looper->ScanChain(chSingleElData,"singleElData");
    cout << "Done processing single electron data" << endl;
  }

  if (runElHadData) {
    cout << "Processing elhad data" << endl;
    looper->ScanChain(chElHadData,"elHadData");
    cout << "Done processing elhad data" << endl;
  }

  if (runDoubleElData) {
    cout << "Processing double electron data" << endl;
    looper->ScanChain(chDoubleElData,"doubleElData");
    cout << "Done processing double electron data" << endl;
  }

  if (runMuHadData) {
    cout << "Processing muhad data" << endl;
    looper->ScanChain(chMuHadData,"muHadData");
    cout << "Done processing muhad data" << endl;
  }

  if (runElData) {
    cout << "Processing all electron data" << endl;
    looper->ScanChain(chElData,"elData");
    cout << "Done processing all electron data" << endl;
  }

  if (runMuData) {
    cout << "Processing all muon data" << endl;
    looper->ScanChain(chMuData,"muData");
    cout << "Done processing all muon data" << endl;
  }

  if (runPhotonData) {
    cout << "Processing all photon data" << endl;
    looper->ScanChain(chPhotonData,"photonData");
    cout << "Done processing all photon data" << endl;
  }

  //----------------------------------------
  // save all the histograms
  //----------------------------------------

  const char* outFile  = Form("../output/%s/singleLepton.root", version );
  TDirectory *rootdir = gDirectory->GetDirectory("Rint:");
  rootdir->cd();
  saveHist(outFile);
  deleteHistos();
  
  gSystem->Exit(0);
}
开发者ID:hooberman,项目名称:UserCode,代码行数:101,代码来源:doAll.C


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