コード例 #1
0
ファイル: create_smalltuple.C プロジェクト: thomasbird/eta
void create_smalltuple()
{
	TFile *oldfile = new TFile("/afs/cern.ch/work/t/tbird/eta/pipipi/DPiPiPi_NTuple.root");
	TTree *oldtree = (TTree*)oldfile->Get("subTree");
	Double_t nEntries = oldtree->GetEntries();

	TFile *newfile = new TFile("dataForPhiFit.root", "recreate");
	TTree *newtree = oldtree->CloneTree(0);
	
	Float_t M_12_MuMu;

	oldtree->SetBranchAddress("M_12_MuMu", &M_12_MuMu);

	for (Int_t i = 0; i < 100000000; i++)
	{
		oldtree->GetEntry(i);
		if (abs(M_12_MuMu - 1020) < 100)
		{
			newtree->Fill();
		}
	}
	newtree->AutoSave();
	delete oldfile;
	delete newfile;
}
コード例 #2
0
ファイル: TreeEnshorter.C プロジェクト: agapitos/SOS8
void MakeNewTree(int M1,int M2, TString FILE){
  //TFile    *oldfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/TChiWZ_2J_1.root");  
  //TFile    *oldfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/T2degTest.root");
  //TFile    *oldfile = new TFile("/afs/cern.ch/work/a/astakia/public/TChiSlepSnuDemo_2J_3.root");
  //TFile    *oldfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/TChiSlepSnuTauEn_2J_2.root");
  //TFile    *oldfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/"+FILE+".root");
  TFile    *oldfile = new TFile("/afs/cern.ch/work/a/astakia/public/"+FILE+".root");

  TTree *oldtree=(TTree*)oldfile->Get("treeProducerSusySoftlepton");
  Long64_t nentries = oldtree->GetEntries();
  Float_t  met_pt,  Jet_pt[12];  
  Int_t  GenSusyMChargino, GenSusyMNeutralino, GenSusyMStop, nLepGood;
  TBranch *b_GenSusyMChargino,*b_GenSusyMNeutralino, *b_GenSusyMStop, *b_met_pt, *b_nLepGood,  *b_Jet_pt ;
  oldtree->SetBranchAddress("GenSusyMNeutralino", &GenSusyMNeutralino, &b_GenSusyMNeutralino);
  oldtree->SetBranchAddress("GenSusyMChargino"  , &GenSusyMChargino  , &b_GenSusyMChargino  );
  oldtree->SetBranchAddress("GenSusyMStop"      , &GenSusyMStop      , &b_GenSusyMStop      );
  oldtree->SetBranchAddress("met_pt"            , &met_pt            , &b_met_pt            );
  oldtree->SetBranchAddress("nLepGood"          , &nLepGood          , &b_nLepGood          );
  oldtree->SetBranchAddress("Jet_pt"            , Jet_pt             , &b_Jet_pt            );

  TFile *newfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/SUSY_"+cInt(M1)+"_"+cInt(M2)+"_s2.root","recreate");
  //TFile *newfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/TChiWZ_"+cInt(M1)+"_"+cInt(M2)+".root","recreate");
  //TFile *newfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/SUSY_"+cInt(M1)+"_"+cInt(M2)+".root","recreate");
  //TFile *newfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/TChiSlepSnuTauEn_2J_2_220.root","recreate");
  //TFile *newfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/TChiSlepSnuDemo_2J_3_220.root","recreate");
  //TFile *newfile = new TFile("/afs/cern.ch/work/a/agapitos/public/THE_ROOT_FILES_OF_SOS/nTuples_New_Set_002/"+FILE+"_s2.root","recreate");
  TTree *newtree = oldtree->CloneTree(0);  int a=M1-5, b=M1+5, c=M2-5, d=M2+5;    //nentries=2000000;
  for( Long64_t i=0;i<nentries; i++ ){  if(i%200000==0&&i!=0)cout<<100*i/nentries<<"%"<<endl;
    oldtree->GetEntry(i);
    GenSusyMChargino=GenSusyMStop;// For stop scan 
    if( a <= GenSusyMChargino&&GenSusyMChargino <= b  &&  c <= GenSusyMNeutralino&&GenSusyMNeutralino <= d   && met_pt>170.0 &&  nLepGood>1 && Jet_pt[0]>120.0  ) newtree->Fill();
    //if( met_pt>170.0 &&  nLepGood>1 && Jet_pt[0]>120.0 )newtree->Fill();
  }
  newtree->Print();  newtree->AutoSave();  delete oldfile; delete newfile;
}
コード例 #3
0
ファイル: KVEventSelector.cpp プロジェクト: pwigg/kaliveda
void KVEventSelector::SlaveBegin(TTree * /*tree*/)
{
	// The SlaveBegin() function is called after the Begin() function.
   // When running with PROOF SlaveBegin() is called on each slave server.
   // The tree argument is deprecated (on PROOF 0 is passed).
   //
	// ParseOptions : Manage options passed as arguments
	//
	// Called user method InitAnalysis where users can create trees or histos
	// using the appropiate methods :
	// CreateTrees and CreateMethods
	// 
	// Test the presence or not of such histo or tree
	// to manage it properly
	
	ParseOptions();

    if(IsOptGiven("CombinedOutputFile")) {
        fCombinedOutputFile=GetOpt("CombinedOutputFile");
        Info("SlaveBegin", "Output file name = %s", fCombinedOutputFile.Data());
    }

	InitAnalysis();
	
	if (ltree->GetEntries()>0)
		for (Int_t ii=0;ii<ltree->GetEntries();ii+=1){
			TTree* tt = (TTree* )ltree->At(ii);
			tt->SetDirectory(writeFile);
			tt->AutoSave();
		}
	
}
コード例 #4
0
void skim_trees_triggers::Loop(TString filename, TString input_filename, int trigger, int current_sample, int data)
{
	
	TString denominator_trigger_names[3] = { "HLT_BIT_HLT_PFJet60_v"};
	if (data==1) denominator_trigger_names[0] = {"HLT_BIT_HLT_DiPFJetAve60_v"};

   if (fChain == 0) return;

   Long64_t nentries = fChain->GetEntriesFast();

   Long64_t nbytes = 0, nb = 0;

	TFile *output = new TFile(filename+"_"+denominator_trigger_names[trigger]+".root","recreate");
	fChain->SetBranchStatus("*",0);
	fChain->SetBranchStatus("nJet",1);
	fChain->SetBranchStatus("Jet_pt",1);
	fChain->SetBranchStatus("Jet_pt*",1);
	fChain->SetBranchStatus("Jet_eta",1);
	fChain->SetBranchStatus("Jet_phi",1);
	fChain->SetBranchStatus("Jet_mass",1);
	fChain->SetBranchStatus("Jet_btagCSV",1);
	fChain->SetBranchStatus("*id",1);
	fChain->SetBranchStatus("*blike*",1);
	fChain->SetBranchStatus("*type",1);
   fChain->SetBranchStatus("*eight",1);
   fChain->SetBranchStatus("json",1);
	fChain->SetBranchStatus("HLT_*VBF*",1);
	fChain->SetBranchStatus("HLT_*PFJet*",1);
	
	TTree *tree = fChain->CloneTree(0);
	TFile *input_file = TFile::Open(input_filename);
	TH1F*	Count = (TH1F*)input_file->Get("Count");
	TH1F*	CountPosWeight = (TH1F*)input_file->Get("CountPosWeight");
	TH1F*	CountNegWeight =(TH1F*)input_file->Get("CountNegWeight");
	TH1F* CountWeighted = (TH1F*)input_file->Get("CountWeighted");


   for (Long64_t jentry=0; jentry<nentries;jentry++) {
	   Long64_t ientry = LoadTree(jentry);
	   if (ientry < 0) break;
	   nb = fChain->GetEntry(jentry);   nbytes += nb;
		Float_t denominator_trigger[4] = { HLT_BIT_HLT_PFJet60_v};
		if (data==1) denominator_trigger[0] = {HLT_BIT_HLT_DiPFJetAve60_v};
	 
		if (denominator_trigger[trigger]!=1) continue;

		tree->Fill();		

	}  
	output->cd();
	tree->AutoSave();
	Count->Write();
	CountPosWeight->Write();
	CountNegWeight->Write();
	CountWeighted->Write();
	output->Close();
	delete output;

}
コード例 #5
0
int Fitter::Save_sWeights()
{
	struct NameValTuple {string name; double val;};
	TFile* pFile = new TFile(outputSweights.c_str(), "RECREATE");
	TChain* pChain = new TChain;
	TTree* pTree = NULL;
	Long64_t nEntries = 0, iEntry=0;
	BranchProxy<double> bp;
	vector<NameValTuple> nameValTuples;
	
	if(!pFile){ cerr << "Error creating file" << endl; return 1; }
	if(InitChain(pChain)) return 1;	
	
	// Deactivate branches that would have the same name as the added branches
	for(auto& pVec_pdfs : {&sigPdfs, &bkgPdfs})
	for(auto& pdf : *pVec_pdfs)
	{
		NameValTuple nv = {pdf.GetYld().GetName()};
		string swBranchName = nv.name+"_sw";
		if(pChain->GetBranch(swBranchName.c_str()))
			pChain->SetBranchStatus(swBranchName.c_str(), 0);
		nameValTuples.push_back(nv);
	}
	
	pTree = pChain->CloneTree(0);
	bp.Connect(pChain, branchName.c_str());
	nEntries = pChain->GetEntries();
	
	for(auto& nv : nameValTuples)
	{
		string swBranchName = nv.name + "_sw";
		string branchTitle = swBranchName + "/D";
		
		pTree->Branch(swBranchName.c_str(), &nv.val, branchTitle.c_str());	
	}
	
	for(Long64_t i=0; i<nEntries; ++i)
	{
		pChain->GetEntry(i);
		if(!range.In(bp)) continue;
		
		for(auto& nv : nameValTuples) 
			nv.val = pSPlot->GetSWeight(iEntry, (nv.name+"_sw").c_str());
		
		++iEntry;
		pTree->Fill();
	}
	pTree->AutoSave();
	
	delete pFile;
	delete pChain;
	
	return 0;
}
コード例 #6
0
void selectK40fromData()
{

// --- read in contents of the rootfiles
   TChain chain("PSTree");
   chain.Add("calibrated.data_aug02_01.root");
   chain.Add("calibrated.data_aug02_02.root");
   chain.Add("calibrated.data_aug02_03.root");
   cout<<"TChain was set up."<<endl;
   
   Float_t Cha_Energy[20];
   chain.SetBranchAddress("Cha_Energy",Cha_Energy);

   Int_t Neve=chain.GetEntries();
   cout<<" total entries = "<<Neve<<endl;

   //Create a new file + a clone of old tree in new file
   TFile *newfile = new TFile("singleK40.root","recreate");
   TTree *newtree = chain.CloneTree(0);

// ---- loop over all events
   Int_t NsingleSeg=0;
   Int_t NK40=0;

   for (Int_t i=0; i<Neve; i++) {
     if (i%10000==0) cout<<" now event "<<i<<endl;
     chain.GetEntry(i);
     
     Int_t Nseg=0;
     for (Int_t k=1; k<=18; k++) {
       if (Cha_Energy[k]>10) {
      	 Nseg += 1;
       }
     }
     
// select the K40 line (1460,83 keV)
     if (Nseg==1) {
       NsingleSeg++;
       if(Cha_Energy[0]>1456.8&&Cha_Energy[0]<1464.8){
	 newtree->Fill();
	 NK40 +=1;
       }
     }
   }

   newtree->Print();
   cout<<"Number of single segment events: "<<NsingleSeg<<endl;
   cout<<"Number of single segment events with 1456.8<Cha_Energy[0]<1464.8: "<<NK40<<endl;

   newtree->AutoSave();
   delete newfile;

}
コード例 #7
0
ファイル: TreeSplitter.C プロジェクト: peruzzim/diphoton
 void donewfile(){
   if (newtree){
     newtree->Print();
     newtree->AutoSave();
     newfile->Close();
   }
   counter_files++;
   thisentries = 0;
   newfile = new TFile(Form("splitted_%d.root",counter_files),"recreate");
   newfile->cd();
   newtree = oldtree->CloneTree(0);
 }
コード例 #8
0
ファイル: runPEvent.C プロジェクト: asmagina1995/roottest
void runPEvent() {

#ifndef ClingWorkAroundMissingDynamicScope
   gROOT->ProcessLine(".L PEvent.cc+");
#endif

    const Int_t n = 100;
    UInt_t *array = new UInt_t[n];

#ifdef ClingWorkAroundJITandInline
    for(Int_t i(0); i<n; i++)
        array[i] = 300*TMath::Abs(sin(6.28318530717959*i/n));
#else
   for(Int_t i(0); i<n; i++)
      array[i] = 300*TMath::Abs(TMath::Sin(TMath::TwoPi()*i/n));
#endif
    QRawTriggerPulse* tp = new QRawTriggerPulse(n,array);

    TFile *f = new TFile("myTest.root","recreate");
    TTree *t = new TTree("t","mytree");

    PEvent *q = new PEvent(*tp);
    t->Branch("event.","PEvent",&q);
    //t->Branch("thepulse",&tp);


    t->Fill();
    t->AutoSave();

    for(Int_t i(0); i<n; i++)
        cout << i << "   " << tp->GetSample()[i] << endl;

    f->Close();
    delete f;
    delete q;
    delete tp;

#ifdef ClingReinstateRedeclarationAllowed
   TFile *f = new TFile("myTest.root");
   TTree *t = (TTree*)f->Get("t");   
#else
   f = new TFile("myTest.root");
   t = (TTree*)f->Get("t");
#endif
    t->StartViewer();
    t->Draw("event.fRawTriggerPulse.fSample");

}
コード例 #9
0
void skimMET2016DataSet()
{
  TChain* chain = new TChain("cutFlowAnalyzer_Data/Events");
  // B-v2 missing
  // H missing
  // F missing

  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016B-23Sep2016-v3-20170213/170213_161511/0000/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016B-23Sep2016-v3-20170213/170213_161511/0001/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016B-23Sep2016-v3-20170213/170213_161511/0002/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016B-23Sep2016-v3-20170213/170213_161511/0003/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016B-23Sep2016-v3-20170213/170213_161511/0004/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016B-23Sep2016-v3-20170213/170213_161511/0005/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016B-23Sep2016-v3-20170213/170213_161511/0006/out_ana*.root");
  
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016C-23Sep2016-v1-20170213/170213_161533/0000/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016C-23Sep2016-v1-20170213/170213_161533/0001/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016C-23Sep2016-v1-20170213/170213_161533/0002/out_ana*.root");

  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016D-23Sep2016-v1-20170213/170213_161605/0000/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016D-23Sep2016-v1-20170213/170213_161605/0001/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016D-23Sep2016-v1-20170213/170213_161605/0002/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016D-23Sep2016-v1-20170213/170213_161605/0003/out_ana*.root");

  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016E-23Sep2016-v1-20170213/170213_161626/0000/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016E-23Sep2016-v1-20170213/170213_161626/0001/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016E-23Sep2016-v1-20170213/170213_161626/0002/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016E-23Sep2016-v1-20170213/170213_161626/0003/out_ana*.root");
    
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016F-23Sep2016-v1-20170213/170213_161647/0000/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016F-23Sep2016-v1-20170213/170213_161647/0001/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016F-23Sep2016-v1-20170213/170213_161647/0002/out_ana*.root");

  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016G-23Sep2016-v1-20170213/170213_161713/0000/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016G-23Sep2016-v1-20170213/170213_161713/0001/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016G-23Sep2016-v1-20170213/170213_161713/0002/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016G-23Sep2016-v1-20170213/170213_161713/0003/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016G-23Sep2016-v1-20170213/170213_161713/0004/out_ana*.root");
  chain->Add("/fdata/hepx/store/user/dildick/MET/crab_MET-Run2016G-23Sep2016-v1-20170213/170213_161713/0005/out_ana*.root");

  TFile* newFile = TFile::Open("out_ana_selected_170213_161713.root","RECREATE"); 
  TTree* newChain = chain->CopyTree("nRecoMu>=3");
  newChain->AutoSave();
  newFile->Close();
}
コード例 #10
0
ファイル: TreeCutter.cpp プロジェクト: scasasso/usercode
// main
int main(int argc, char *argv[]){
  
  TString fileNameTree = argv[1];
  TString minMass = argv[2];
  TString maxMass = argv[3];

  Int_t maxEntries = atoi(argv[4]);


  //std::cout << "maxEntries = " << maxEntries << std::endl;

  TChain *chain = new TChain("T");
  chain->Add(fileNameTree);
  chain->GetEntry(0); 
  
  int nentries = int(chain->GetEntries());
  cout << "+++++ No. of entries in the input tree: " << nentries << endl;

  // string for the cut on the selected invariant mass windowm    
  TString mass_cut=minMass+"*"+minMass+"<2*(event.mu1.fP4.fCoordinates.fT*event.mu2.fP4.fCoordinates.fT-event.mu1.fP4.fCoordinates.fX*event.mu2.fP4.fCoordinates.fX-event.mu1.fP4.fCoordinates.fY*event.mu2.fP4.fCoordinates.fY-event.mu1.fP4.fCoordinates.fZ*event.mu2.fP4.fCoordinates.fZ) && 2*(event.mu1.fP4.fCoordinates.fT*event.mu2.fP4.fCoordinates.fT-event.mu1.fP4.fCoordinates.fX*event.mu2.fP4.fCoordinates.fX-event.mu1.fP4.fCoordinates.fY*event.mu2.fP4.fCoordinates.fY-event.mu1.fP4.fCoordinates.fZ*event.mu2.fP4.fCoordinates.fZ)<"+maxMass+"*"+maxMass;
  //std::cout<<"String for cut: "+mass_cut<<std::endl;
  
  TString outFileName =  ((TObjString*)((((TObjString*)(fileNameTree.Tokenize("/"))->Last())->String().Tokenize("."))->At(0)))->String();


  TFile* fileTreeOut = TFile::Open(outFileName+"_Mass_"+minMass+"_"+maxMass+".root","RECREATE");
  fileTreeOut->cd();
  
  TTree *newtree = chain->CopyTree(mass_cut,"",maxEntries); // use a sub-sample this when debugging
  //TTree *newtree = chain->CopyTree(mass_cut);
  newtree->AutoSave();

  nentries = int(newtree->GetEntries());
  cout << "+++++ No. of entries in the output tree: " << nentries << endl;

  fileTreeOut->Write();
  fileTreeOut->Close();

  delete chain;

  
  return 0;
}
コード例 #11
0
void correlationTreeLoop(int run,char *baseDir, char *corTreeDir, char *outputDir) {
// antTimeOffset[0] = 0.292591; deltaR[0] = -0.0384839; deltaPhi[ 0] = -0.0100608; deltaZ[0] = 0;
// antTimeOffset[1] = 0.172375; deltaR[1] = 0.00634697; deltaPhi[ 1] = -0.00313443; deltaZ[1] = 0;
// antTimeOffset[2] = 0.342454; deltaR[2] = -0.0861167; deltaPhi[ 2] = -0.015312; deltaZ[2] = 0;
// antTimeOffset[3] = 0.0248334; deltaR[3] = 0.0461873; deltaPhi[ 3] = 0.00206827; deltaZ[3] = 0;
// antTimeOffset[4] = 0.0372539; deltaR[4] = 0.0153388; deltaPhi[ 4] = -0.0227948; deltaZ[4] = 0;
// antTimeOffset[5] = 0.137506; deltaR[5] = -0.00927728; deltaPhi[ 5] = 0.00750385; deltaZ[5] = 0;
// antTimeOffset[6] = 0.0475841; deltaR[6] = 0.0239867; deltaPhi[ 6] = 0.00388065; deltaZ[6] = 0;
// antTimeOffset[7] = 0.123741; deltaR[7] = 0.0125282; deltaPhi[ 7] = -0.00131021; deltaZ[7] = 0;
// antTimeOffset[8] = 0.380551; deltaR[8] = -0.0111636; deltaPhi[ 8] = -0.0299233; deltaZ[8] = 0;
// antTimeOffset[9] = 0.445956; deltaR[9] = -0.0959452; deltaPhi[ 9] = -0.00165365; deltaZ[9] = 0;
// antTimeOffset[10] = 0.439757; deltaR[10] = -0.0330808; deltaPhi[ 10] = -0.0107407; deltaZ[10] = 0;
// antTimeOffset[11] = 0.244031; deltaR[11] = -0.0475617; deltaPhi[ 11] = 0.0145914; deltaZ[11] = 0;
// antTimeOffset[12] = 0.321419; deltaR[12] = 0.0196292; deltaPhi[ 12] = -0.0150373; deltaZ[12] = 0;
// antTimeOffset[13] = 0.118473; deltaR[13] = -0.0190837; deltaPhi[ 13] = -0.0121967; deltaZ[13] = 0;
// antTimeOffset[14] = 0.27363; deltaR[14] = -0.00922367; deltaPhi[ 14] = -0.0038106; deltaZ[14] = 0;
// antTimeOffset[15] = 0.187377; deltaR[15] = -0.0294811; deltaPhi[ 15] = 0.0106842; deltaZ[15] = 0;
// antTimeOffset[16] = 0.0682454; deltaR[16] = 0.0140245; deltaPhi[ 16] = -0.0087849; deltaZ[16] = 0;
// antTimeOffset[17] = 0.296899; deltaR[17] = -0.0621836; deltaPhi[ 17] = 0.000682206; deltaZ[17] = 0;
// antTimeOffset[18] = 0.180588; deltaR[18] = -0.0379325; deltaPhi[ 18] = -0.00516052; deltaZ[18] = 0;
// antTimeOffset[19] = 0.165257; deltaR[19] = -0.0108062; deltaPhi[ 19] = -0.00770935; deltaZ[19] = 0;
// antTimeOffset[20] = 0.176423; deltaR[20] = -0.0601935; deltaPhi[ 20] = -0.00862535; deltaZ[20] = 0;
// antTimeOffset[21] = 0.301777; deltaR[21] = -0.0968276; deltaPhi[ 21] = -0.00920648; deltaZ[21] = 0;
// antTimeOffset[22] = 0.0969425; deltaR[22] = -0.0348523; deltaPhi[ 22] = 0.00037431; deltaZ[22] = 0;
// antTimeOffset[23] = 0.0422886; deltaR[23] = 0.0121726; deltaPhi[ 23] = 0.00310935; deltaZ[23] = 0;
// antTimeOffset[24] = -0.01737; deltaR[24] = 0.0405193; deltaPhi[ 24] = -0.00546085; deltaZ[24] = 0;
// antTimeOffset[25] = 0.0412981; deltaR[25] = 0.0239992; deltaPhi[ 25] = -0.00901249; deltaZ[25] = 0;
// antTimeOffset[26] = 0.166311; deltaR[26] = -0.0405203; deltaPhi[ 26] = -0.0145529; deltaZ[26] = 0;
// antTimeOffset[27] = 0.139405; deltaR[27] = -0.00401756; deltaPhi[ 27] = -0.00666063; deltaZ[27] = 0;
// antTimeOffset[28] = 0.104575; deltaR[28] = -0.0362955; deltaPhi[ 28] = -0.00372999; deltaZ[28] = 0;
// antTimeOffset[29] = 0.0345155; deltaR[29] = -0.00587152; deltaPhi[ 29] = 0.00197442; deltaZ[29] = 0;
// antTimeOffset[30] = 0.082859; deltaR[30] = -0.00611182; deltaPhi[ 30] = -0.000789595; deltaZ[30] = 0;
// antTimeOffset[31] = 0.078192; deltaR[31] = -0.00321244; deltaPhi[ 31] = 0.000188257; deltaZ[31] = 0;
// antTimeOffset[32] = 0.0143052; deltaR[32] = -0.0437687; deltaPhi[ 32] = -0.00289577; deltaZ[32] = 0;
// antTimeOffset[33] = 0.0671887; deltaR[33] = -0.0643475; deltaPhi[ 33] = -0.0203117; deltaZ[33] = 0;
// antTimeOffset[34] = 0.0819606; deltaR[34] = -0.0804245; deltaPhi[ 34] = -0.00503387; deltaZ[34] = 0;
// antTimeOffset[35] = -0.0659071; deltaR[35] = -0.0112675; deltaPhi[ 35] = -0.000220575; deltaZ[35] = 0;
// antTimeOffset[36] = -0.212624; deltaR[36] = 0.0337428; deltaPhi[ 36] = -0.00416114; deltaZ[36] = 0;
// antTimeOffset[37] = -0.00431668; deltaR[37] = -0.0525977; deltaPhi[ 37] = -0.0223176; deltaZ[37] = 0;
// antTimeOffset[38] = 0.0899397; deltaR[38] = -0.101587; deltaPhi[ 38] = 0.0058874; deltaZ[38] = 0;
// antTimeOffset[39] = 0.0294537; deltaR[39] = -0.0401037; deltaPhi[ 39] = 0.00899651; deltaZ[39] = 0;

// antTimeOffset[0] = 0.16044; deltaR[0] = -0.0618352; deltaPhi[ 0] = -0.00280991; deltaZ[0] = 0.0287513;
// antTimeOffset[1] = 0.290365; deltaR[1] = -0.110188; deltaPhi[ 1] = -0.00372876; deltaZ[1] = 0.0170052;
// antTimeOffset[2] = 0.349607; deltaR[2] = -0.140583; deltaPhi[ 2] = -0.024769; deltaZ[2] = 0.0623979;
// antTimeOffset[3] = 0.033917; deltaR[3] = -0.0260668; deltaPhi[ 3] = 0.00113633; deltaZ[3] = 0.0423352;
// antTimeOffset[4] = -0.074643; deltaR[4] = -0.0356161; deltaPhi[ 4] = -0.0141947; deltaZ[4] = -0.00394529;
// antTimeOffset[5] = 0.156259; deltaR[5] = -0.095648; deltaPhi[ 5] = 0.0117896; deltaZ[5] = 0.0105241;
// antTimeOffset[6] = 0.212836; deltaR[6] = -0.0907411; deltaPhi[ 6] = -0.0122972; deltaZ[6] = 0.0516748;
// antTimeOffset[7] = 0.541271; deltaR[7] = -0.157934; deltaPhi[ 7] = -0.00368077; deltaZ[7] = 0.130464;
// antTimeOffset[8] = -0.128575; deltaR[8] = 0.0582477; deltaPhi[ 8] = -0.0111813; deltaZ[8] = -0.035067;
// antTimeOffset[9] = -0.122485; deltaR[9] = -0.0119241; deltaPhi[ 9] = -0.00668961; deltaZ[9] = -0.0579302;
// antTimeOffset[10] = -0.263916; deltaR[10] = 0.0811694; deltaPhi[ 10] = -0.00717066; deltaZ[10] = -0.0897962;
// antTimeOffset[11] = -0.229033; deltaR[11] = 0.00897635; deltaPhi[ 11] = -5.65709e-05; deltaZ[11] = -0.0366053;
// antTimeOffset[12] = -0.222093; deltaR[12] = 0.0800239; deltaPhi[ 12] = -0.00901442; deltaZ[12] = -0.0750748;
// antTimeOffset[13] = -0.68459; deltaR[13] = 0.108285; deltaPhi[ 13] = -0.0148342; deltaZ[13] = -0.133195;
// antTimeOffset[14] = -0.516002; deltaR[14] = 0.107793; deltaPhi[ 14] = -0.00133016; deltaZ[14] = -0.143198;
// antTimeOffset[15] = -0.749822; deltaR[15] = 0.145538; deltaPhi[ 15] = -0.00448024; deltaZ[15] = -0.118927;
// antTimeOffset[16] = 0.0961751; deltaR[16] = -0.0564912; deltaPhi[ 16] = -0.00220892; deltaZ[16] = 0.0532255;
// antTimeOffset[17] = -0.166225; deltaR[17] = 0.00298098; deltaPhi[ 17] = 0.00128378; deltaZ[17] = -0.0263557;
// antTimeOffset[18] = 0.178941; deltaR[18] = -0.0972098; deltaPhi[ 18] = -0.00837075; deltaZ[18] = 0.0461125;
// antTimeOffset[19] = 0.171386; deltaR[19] = -0.0643506; deltaPhi[ 19] = -0.00831496; deltaZ[19] = 0.0592813;
// antTimeOffset[20] = -0.0204964; deltaR[20] = -0.0803763; deltaPhi[ 20] = -0.00428327; deltaZ[20] = -0.00602899;
// antTimeOffset[21] = 0.160323; deltaR[21] = -0.101956; deltaPhi[ 21] = -0.0151547; deltaZ[21] = 0.0514858;
// antTimeOffset[22] = 0.053953; deltaR[22] = -0.0773129; deltaPhi[ 22] = -0.00414444; deltaZ[22] = 0.0562807;
// antTimeOffset[23] = 0.00325878; deltaR[23] = -0.0378326; deltaPhi[ 23] = 0.000528826; deltaZ[23] = 0.0517299;
// antTimeOffset[24] = -0.0670197; deltaR[24] = -0.0225655; deltaPhi[ 24] = -0.00391848; deltaZ[24] = 0.0263552;
// antTimeOffset[25] = 0.0035097; deltaR[25] = -0.0427118; deltaPhi[ 25] = -0.00285503; deltaZ[25] = 0.0211308;
// antTimeOffset[26] = -0.0337735; deltaR[26] = -0.062921; deltaPhi[ 26] = -0.00747562; deltaZ[26] = -0.0138518;
// antTimeOffset[27] = -0.110361; deltaR[27] = -0.0144298; deltaPhi[ 27] = -0.0028118; deltaZ[27] = -0.0318333;
// antTimeOffset[28] = -0.227861; deltaR[28] = -0.0389804; deltaPhi[ 28] = -0.0012114; deltaZ[28] = -0.0674168;
// antTimeOffset[29] = -0.081439; deltaR[29] = -0.0449712; deltaPhi[ 29] = -0.00826954; deltaZ[29] = 0.00548985;
// antTimeOffset[30] = 0.17098; deltaR[30] = -0.0938958; deltaPhi[ 30] = -0.00969672; deltaZ[30] = 0.0597671;
// antTimeOffset[31] = 0.0258336; deltaR[31] = -0.052614; deltaPhi[ 31] = -0.000359792; deltaZ[31] = 0.044548;
// antTimeOffset[32] = -0.425254; deltaR[32] = -0.0372025; deltaPhi[ 32] = -0.00536103; deltaZ[32] = -0.0978299;
// antTimeOffset[33] = -0.440596; deltaR[33] = -0.0534945; deltaPhi[ 33] = -0.0144455; deltaZ[33] = -0.136331;
// antTimeOffset[34] = -0.256048; deltaR[34] = -0.0884831; deltaPhi[ 34] = -0.00580407; deltaZ[34] = -0.0676089;
// antTimeOffset[35] = -0.601107; deltaR[35] = 0.0224642; deltaPhi[ 35] = -0.00283517; deltaZ[35] = -0.115955;
// antTimeOffset[36] = -0.472965; deltaR[36] = 0.0023781; deltaPhi[ 36] = -0.00319073; deltaZ[36] = -0.049661;
// antTimeOffset[37] = -0.498374; deltaR[37] = -0.0241109; deltaPhi[ 37] = -0.0168551; deltaZ[37] = -0.102832;
// antTimeOffset[38] = -0.466373; deltaR[38] = -0.0623884; deltaPhi[ 38] = 0.00665517; deltaZ[38] = -0.131102;
// antTimeOffset[39] = -0.382128; deltaR[39] = -0.040161; deltaPhi[ 39] = 0.00508923; deltaZ[39] = -0.100047;

   AnitaGeomTool *fGeomTool = AnitaGeomTool::Instance();
   fGeomTool->useKurtAnitaIINumbers(1);
   char eventName[FILENAME_MAX];
   char headerName[FILENAME_MAX];
   char gpsName[FILENAME_MAX];
   char corrName[FILENAME_MAX];
   char outName[FILENAME_MAX];

   //   sprintf(baseDir,"http://www.hep.ucl.ac.uk/uhen/anita/private/monitor2/runs/fromLoki/");
   sprintf(eventName,"%s/run%d/eventFile%d.root",baseDir,run,run);
   sprintf(headerName,"%s/run%d/headFile%d.root",baseDir,run,run);
   sprintf(gpsName,"%s/run%d/gpsEvent%d.root",baseDir,run,run);
   sprintf(corrName,"%s/corRun%d.root",corTreeDir,run);
   sprintf(outName,"%s/deltaTFile%d.root",outputDir,run);

   
   RawAnitaHeader *header =0;
   Adu5Pat *pat =0;
   CorrelationSummary *corSum =0;
   
   
   TFile *fpHead = TFile::Open(headerName);
   TTree *headTree = (TTree*) fpHead->Get("headTree");
   headTree->SetBranchAddress("header",&header);
   headTree->BuildIndex("eventNumber");
   
   TFile *fpGps = TFile::Open(gpsName);
   TTree *adu5PatTree = (TTree*) fpGps->Get("adu5PatTree");
   adu5PatTree->BuildIndex("realTime");
   adu5PatTree->SetBranchAddress("pat",&pat);
   
   Int_t labChip;
   UInt_t expTaylorTime;
   TFile *fpCor = new TFile(corrName);
   TTree *corTree = (TTree*) fpCor->Get("corTree");
   corTree->SetBranchAddress("cor",&corSum);
   corTree->SetBranchAddress("labChip",&labChip);
   corTree->SetBranchAddress("expTaylorTime",&expTaylorTime);

   Long64_t numEntries=corTree->GetEntries();
   int counter=0;

   TFile *fpOut = new TFile(outName,"RECREATE");

   Long64_t entry=0;
   UInt_t eventNumber, triggerTime, triggerTimeNs;
   Int_t firstAnt,secondAnt,maxAnt,corInd;
   Double_t deltaT,deltaTExpected;
   Double_t phiWave, phiMaxAnt;
   Double_t thetaWave;
   Double_t corPeak, corRMS;
   Double_t balloonLat, balloonLon, balloonAlt;
   Double_t heading,pitch,roll;
   //   Double_t deltaZ;
   //   Double_t deltaR;
   Double_t meanPhiAntPair;
   Double_t deltaPhiAntPair;
   


   TTree *deltaTTree = new TTree("deltaTTree","Tree of Delta T's");
   deltaTTree->Branch("entry",&entry,"entry/L");
   deltaTTree->Branch("firstAnt",&firstAnt,"firstAnt/I");
   deltaTTree->Branch("secondAnt",&secondAnt,"secondAnt/I");
   deltaTTree->Branch("maxAnt",&maxAnt,"maxAnt/I");
   deltaTTree->Branch("labChip",&labChip,"labChip/I");
   deltaTTree->Branch("deltaT",&deltaT,"deltaT/D");
   deltaTTree->Branch("deltaTExpected",&deltaTExpected,"deltaTExpected/D");
   deltaTTree->Branch("corPeak",&corPeak,"corPeak/D");
   deltaTTree->Branch("corRMS",&corRMS,"corRMS/D");
   deltaTTree->Branch("phiMaxAnt",&phiMaxAnt,"phiMaxAnt/D");
   deltaTTree->Branch("phiWave",&phiWave,"phiWave/D");
   deltaTTree->Branch("thetaWave",&thetaWave,"thetaWave/D");
   deltaTTree->Branch("eventNumber",&eventNumber,"eventNumber/i");
   deltaTTree->Branch("triggerTime",&triggerTime,"triggerTime/i");
   deltaTTree->Branch("triggerTimeNs",&triggerTimeNs,"triggerTimeNs/i");
   deltaTTree->Branch("corInd",&corInd,"corInd/I");
   deltaTTree->Branch("balloonLat",&balloonLat,"balloonLat/D");
   deltaTTree->Branch("balloonLon",&balloonLon,"balloonLon/D");
   deltaTTree->Branch("balloonAlt",&balloonAlt,"balloonAlt/D");
   deltaTTree->Branch("heading",&heading,"heading/D");
   deltaTTree->Branch("pitch",&pitch,"pitch/D");
   deltaTTree->Branch("roll",&roll,"roll/D");
   //   deltaTTree->Branch("deltaZ",&deltaZ,"deltaZ/D");
   //   deltaTTree->Branch("deltaR",&deltaR,"deltaR/D");
   deltaTTree->Branch("meanPhiAntPair",&meanPhiAntPair,"meanPhiAntPair/D");
   deltaTTree->Branch("deltaPhiAntPair",&deltaPhiAntPair,"deltaPhiAntPair/D");
   deltaTTree->Branch("expTaylorTime",&expTaylorTime,"expTaylorTime/i");

  // Double_t thetaWave;

   for(entry=0;entry<numEntries;entry++) { 
  

      corTree->GetEntry(entry);
      Long64_t headEntry=headTree->GetEntryNumberWithIndex(corSum->eventNumber);
      if(headEntry<0) 
	continue;
      headTree->GetEntry(headEntry);
     
      // if(header->triggerTimeNs*1e-9< 0.097 || header->triggerTimeNs*1e-9>0.1)

      triggerTimeNs=header->triggerTimeNs;
      triggerTime=header->triggerTime;
      eventNumber=header->eventNumber;

      adu5PatTree->GetEntry(headEntry);
      
      
   // PrettyAnitaEvent realEvent(event,WaveCalType::kVTFullAGCrossCorClock,header);
      balloonLat=pat->latitude;
      balloonLon=pat->longitude;
      balloonAlt=pat->altitude;
      heading=pat->heading;
      pitch=pat->pitch;
      roll=pat->roll;

	//Simon 30/04/09 numbers     
      //      pat->pitch=0.64;
      //      pat->roll=0.14;


	//Simon 02/05/09 numbers     
      //      pat->pitch=0.76;
      //      pat->roll=0.13;

      //Test heading offset
      //      pat->heading+=0.19;
      //      if(pat->heading>=360) pat->heading-=360;
      //      if(pat->heading<0) pat->heading+=360;

     // 

      //      pat->pitch=0.5;
      //      pat->roll=-0.1;


      //Kurt numbers 
      pat->pitch=-0.29;
      pat->roll=0.89;
//       //Test heading offset
//      pat->heading-=0.32;
      if(pat->heading>=360) pat->heading-=360;
      if(pat->heading<0) pat->heading+=360;

      UsefulAdu5Pat usefulPat(pat);
     
      for(corInd=0;corInd<35;corInd++) {

	 firstAnt=corSum->firstAnt[corInd];
	 secondAnt=corSum->secondAnt[corInd];
	 deltaT=corSum->maxCorTimes[corInd];
	 maxAnt=corSum->centreAntenna;
	 phiMaxAnt=fGeomTool->getAntPhiPositionRelToAftFore(corSum->centreAntenna,AnitaPol::kHorizontal)*TMath::RadToDeg();
	 
	 //Default values
	 deltaTExpected=usefulPat.getDeltaTTaylor(corSum->firstAnt[corInd],corSum->secondAnt[corInd],AnitaPol::kHorizontal);
	 deltaTExpected=usefulPat.getDeltaTWillySeavey(corSum->firstAnt[corInd],corSum->secondAnt[corInd],AnitaPol::kHorizontal);

	 //These two lines are for use with Simon's array of numbers
	 //	 deltaTExpected=usefulPat.getDeltaTTaylorOpt(corSum->firstAnt[corInd],corSum->secondAnt[corInd],deltaR,deltaZ,deltaPhi);
	 //	 deltaT+=(antTimeOffset[firstAnt]-antTimeOffset[secondAnt]);



	 phiWave=usefulPat.getPhiWave();
	 thetaWave=usefulPat.getThetaWave();
	 corPeak=corSum->maxCorVals[corInd];
	 corRMS=corSum->rmsCorVals[corInd];
	 
	 meanPhiAntPair=fGeomTool->getMeanAntPairPhiRelToAftFore(firstAnt,secondAnt,AnitaPol::kHorizontal);
	 deltaPhiAntPair=fGeomTool->getPhiDiff(phiWave,meanPhiAntPair);//,AnitaPol::kHorizontal);
	 
	 //	 std::cout << phiWave << "\t" << meanPhiAntPair << "\t" << deltaPhiAntPair << "\n";

	 //Convert to degrees
	 deltaPhiAntPair*=TMath::RadToDeg();
	 phiWave*=TMath::RadToDeg();
	 thetaWave*=TMath::RadToDeg();	       

	 //Actually fill the tree
	 deltaTTree->Fill();
      }


      counter++; 
      if(counter%100==0)
	 cerr << "*";
   }
   deltaTTree->AutoSave();
   fpOut->Close();
   //   histSimpleDtDiff->Draw();
}
コード例 #12
0
ファイル: SkimNtuple_month.cpp プロジェクト: bparida/CVS
int main(int argc, char ** argv)
{
  // select fed
  int month = atoi(argv[1]);
  string month_name [12] = {"Gen","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

  if (month < 0 || month > 12) {
   cout << "Give as argument a number between 1 and 12 corresponding to the chosen month" << endl;
   return 0;
  }

  if (month > 10) {
   cout << "No data corresponding to the chosen month..yet!" << endl;
   return 0;
  }


  //Get old tree 
  TChain *tx = new TChain("x");
  tx->Add(argv[2]);
 
  init_ttree(tx, &x);

  TTree *oldtree = (TTree*)tx;

  Long64_t nentries = oldtree->GetEntries();
  cout<< "Number of entries in the tree : " << nentries << endl;


  //Create a new file + a clone of old tree in new file
  char fname[1000];
  sprintf(fname,argv[3],(month_name[month - 1]).c_str());
  TFile *newfile = new TFile(fname,"recreate");
  TTree *newtree = oldtree->CloneTree(0);

  int lowerRun, upperRun = 0;

  if (month == 1) {
    lowerRun = 153941;
    upperRun = 156054;
  }

  if (month == 2) {
    lowerRun = 156225;
    upperRun = 159130;
  }

  if (month == 3) {
    lowerRun = 159248;
    upperRun = 161732;
  }

  if (month == 4) {
    lowerRun = 161846;
    upperRun = 163726;
  }

  if (month == 5) {
    lowerRun = 163762;
    upperRun = 166139;
  }

  if (month == 6) {
    lowerRun = 166243;
    upperRun = 168148;
  }

  if (month == 7) {
    lowerRun = 168266;
    upperRun = 172266;
  }

  if (month == 8) {
    lowerRun = 172319;
    upperRun = 174912;
  }

  if (month == 9) {
    lowerRun = 175118;
    upperRun = 177519;
  }

  if (month == 10) {
    lowerRun = 177624;
    upperRun = 179998;
  }


  for (int i=0; i<nentries; i++) {

    if (i%10000000==0) cout << "Analyzing entry " << i << endl;
    oldtree->GetEntry(i);

    if ( x.run > lowerRun && x.run < upperRun ) newtree->Fill();
  }
  
  newtree->Print();
  newtree->AutoSave();
  
  delete newfile;


}
コード例 #13
0
ファイル: TMVAapply_double.C プロジェクト: chernyavskaya/Hbb
void TMVAapply_double::Loop(TString inputfile, TString output_dir,  int sample_type)
{
   if (fChain == 0) return;
   Long64_t nentries = fChain->GetEntriesFast();
   Long64_t nbytes = 0, nb = 0;

	Int_t presel=0;
	Int_t loopJet_max;
	TFile *output = new TFile("main_tmva_v13_Data_4_"+output_dir+".root","recreate");
	TTree *tree = fChain->CloneTree(0);
	float BDT_VBF;
	TBranch *branchBDT_VBF = tree->Branch("BDT_VBF",&BDT_VBF,"BDT_VBF/F");
	TString weightfile = "../weights/TMVAClassification_BDTG_double_all_4.weights.xml";
   TMVA::Reader *reader = new TMVA::Reader("Silent");
	float var1,var2,var3,var4,var5,var6,var7,var8,var9,var10, var11, var12;
	reader->AddVariable("Mqq",&var1);
	reader->AddVariable("DeltaEtaQQ",&var2);
	reader->AddVariable("DeltaPhiQQ",&var3);
	reader->AddVariable("SoftN5",&var4);
	reader->AddVariable("HTsoft",&var5);
	reader->AddVariable("CSV1",&var6);
   reader->AddVariable( "CSV2", &var7 );
	reader->AddVariable( "cosOqqbb", &var8 );
   reader->AddVariable( "DeltaEtaQB1", &var9 );
   reader->AddVariable( "DeltaEtaQB2", &var10 );
  	reader->AddVariable("qgl1",&var11);
   reader->AddVariable("qgl2",&var12);
	reader->BookMVA("BDTG", weightfile);


	TFile *input_file = new TFile(inputfile);
	TH1F*	Count = (TH1F*)input_file->Get("Count");
	TH1F*	CountPosWeight = (TH1F*)input_file->Get("CountPosWeight");
	TH1F*	CountNegWeight =(TH1F*)input_file->Get("CountNegWeight");
		

	int events_saved=0;
   for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      nb = fChain->GetEntry(jentry);   nbytes += nb;
		
		int btag_max1_number = -1;
		int btag_max2_number = -1;
		int pt_max1_number = -1;
		int pt_max2_number = -1;
		TLorentzVector Bjet1;
		TLorentzVector Bjet2;
		TLorentzVector Qjet1;
		TLorentzVector Qjet2;
		TLorentzVector qq;

		if (preselection_double(nJet, Jet_pt,Jet_eta, Jet_phi, Jet_mass, Jet_btagCSV, Jet_id, btag_max1_number, btag_max2_number, pt_max1_number, pt_max2_number, HLT_BIT_HLT_QuadPFJet_DoubleBTagCSV_VBF_Mqq200_v, Bjet1, Bjet2, Qjet1, Qjet2, qq) !=0) continue;

		Float_t Mqq = qq.M();
		Float_t bbDeltaPhi = TMath::Abs(Bjet1.DeltaPhi(Bjet2));
		Double_t qqDeltaPhi = TMath::Abs(Qjet1.DeltaPhi(Qjet2));
		Float_t qqDeltaEta = TMath::Abs(Qjet1.Eta()-Qjet2.Eta());
		TLorentzVector bb;
		bb = Bjet1+Bjet2;
		Float_t Mbb = bb.M();
		TLorentzVector bbqq;
		bbqq = Bjet1 + Bjet2 + Qjet1 + Qjet2;
		Float_t cosOqqbb =TMath::Cos( ( ( Bjet1.Vect() ).Cross(Bjet2.Vect()) ).Angle( ( Qjet1.Vect() ).Cross(Qjet2.Vect()) ) );	


		Float_t EtaBQ1;
	 	Float_t EtaBQ2;
		Float_t PhiBQ1; 	
		Float_t PhiBQ2;
		 if (Qjet1.Eta() >= Qjet2.Eta()) {
			if (Bjet1.Eta() >= Bjet2.Eta())  {
				EtaBQ1 = Qjet1.Eta()-Bjet1.Eta();
				PhiBQ1 = TMath::Abs(Bjet1.DeltaPhi(Qjet1));		
			}
			else {
				EtaBQ1 = Qjet1.Eta()-Bjet2.Eta();
				PhiBQ1 = TMath::Abs(Bjet2.DeltaPhi(Qjet1));	
			}	
		} else if (Bjet1.Eta() >= Bjet2.Eta()) {
				EtaBQ1 = Qjet2.Eta()-Bjet1.Eta();
				PhiBQ1 = TMath::Abs(Bjet1.DeltaPhi(Qjet2));	
				
				}
			else {
				EtaBQ1 = Qjet2.Eta()-Bjet2.Eta();
				PhiBQ1 = TMath::Abs(Bjet2.DeltaPhi(Qjet2));	
			}


		 if (Qjet1.Eta() <= Qjet2.Eta()) {
			if (Bjet1.Eta() <= Bjet2.Eta())  {
				EtaBQ2 = Qjet1.Eta()-Bjet1.Eta();
				PhiBQ2 = TMath::Abs(Bjet1.DeltaPhi(Qjet1));		
			}
			else {
				EtaBQ2 = Qjet1.Eta()-Bjet2.Eta();
				PhiBQ2 = TMath::Abs(Bjet2.DeltaPhi(Qjet1));	
			}	
		} else if (Bjet1.Eta() <= Bjet2.Eta()) {
				EtaBQ2 = Qjet2.Eta()-Bjet1.Eta();
				PhiBQ2 = TMath::Abs(Bjet1.DeltaPhi(Qjet2));	
				
				}
			else {
				EtaBQ2 = Qjet2.Eta()-Bjet2.Eta();
				PhiBQ2 = TMath::Abs(Bjet2.DeltaPhi(Qjet2));	
			}
		


		Float_t Etot = Bjet1.E()+Bjet2.E()+Qjet1.E()+Qjet2.E();
		Float_t PzTot = Bjet1.Pz()+Bjet2.Pz()+Qjet1.Pz()+Qjet2.Pz();
		Float_t PxTot = Bjet1.Px()+Bjet2.Px()+Qjet1.Px()+Qjet2.Px();
		Float_t PyTot = Bjet1.Py()+Bjet2.Py()+Qjet1.Py()+Qjet2.Py();
	
		Float_t x1 = 0.;
		Float_t x2 = 0.;
		x1 = (Etot + PzTot)/2./13000.;
		x2 = (Etot - PzTot)/2./13000.;

		TLorentzVector q1,q2,q1_after,q2_after, VB1, VB2;
		q1.SetPxPyPzE(0.,0.,13000./2.*x1,13000./2.*x1);
		q2.SetPxPyPzE(0.,0.,-13000./2.*x2,13000./2.*x2);
		q1_after.SetPxPyPzE(Qjet1.Px()/Qjet1.Beta(),Qjet1.Py()/Qjet1.Beta(),Qjet1.Pz()/Qjet1.Beta(),Qjet1.E());
		q2_after.SetPxPyPzE(Qjet2.Px()/Qjet2.Beta(),Qjet2.Py()/Qjet2.Beta(),Qjet2.Pz()/Qjet2.Beta(),Qjet2.E());
		if (q1_after.Eta()>=0.) {
			VB1 = -q1_after+q1;
			VB2 = -q2_after+q2;
		} else {
			VB1 = -q2_after+q1;
			VB2 = -q1_after+q2;
		} 
		Float_t VB1_mass, VB2_mass;
		VB1_mass = TMath::Abs(VB1.M());
		VB2_mass = TMath::Abs(VB2.M());

		for (int i=0;i<nJet;i++){
			if (Jet_btagCSV[i]>1) Jet_btagCSV[i]=1.;
			if (Jet_btagCSV[i]<0) Jet_btagCSV[i]=0.;
		}

		var1= Mqq;
		var6= Jet_btagCSV[btag_max1_number];	
		var7= Jet_btagCSV[btag_max2_number];	
		var2= qqDeltaEta;
		var3= qqDeltaPhi;
		var4= softActivity_njets5;
		var5= softActivity_HT;
		var9= EtaBQ1;
		var10= EtaBQ2;
		var8= cosOqqbb;
		var11=Jet_qgl[pt_max1_number];
		var12 = Jet_qgl[pt_max2_number];
	
		BDT_VBF = reader->EvaluateMVA("BDTG");


	tree->Fill();
	//	events_saved++;		
//		if (sample_type==2) 
//			if (events_saved>=108767) break; //for 500-700

	}
	delete reader;
	output->cd();
	tree->AutoSave();
	Count->Write();
	CountPosWeight->Write();
	CountNegWeight->Write();
	output->Close();
}
コード例 #14
0
void quickPulserSearch(char *baseName, int run, int templateEntry,int startEntry, int numEntries) {
  char eventName[FILENAME_MAX];
  char headerName[FILENAME_MAX];
  //  char hkName[FILENAME_MAX];
  sprintf(eventName,"%s/run%d/eventFile%d.root",baseName,run,run);
  sprintf(headerName,"%s/run%d/headFile%d.root",baseName,run,run);
  //  sprintf(hkName,"/unix/anita1/webData/firstDay/run%d/prettyHkFile%d.root",run,run);

  RawAnitaEvent *event = 0;
  RawAnitaHeader *header =0;
  //  PrettyAnitaHk *hk = 0;
  
  TChain *eventChain = new TChain("eventTree");
  eventChain->Add(eventName);
  eventChain->SetBranchAddress("event",&event);

   for(int extra=1;extra<100;extra++) {
     sprintf(eventName,"%s/run%d/eventFile%d_%d.root",baseName,run,run,extra);
    TFile *fpTest = TFile::Open(eventName);
    if(!fpTest) 
      break;
    else {
      delete fpTest;
      eventChain->Add(eventName);
    }
  }

  TFile *fpHead = TFile::Open(headerName);
  TTree *headTree = (TTree*) fpHead->Get("headTree");
  headTree->SetBranchAddress("header",&header);

  //  TFile *fpHk = new TFile(hkName);
  //  TTree *prettyHkTree = (TTree*) fpHk->Get("prettyHkTree");
  //  prettyHkTree->SetBranchAddress("hk",&hk);


  //Friends only seem to work with TTree::Draw and similar commands
  //if you are manually calling GetEntry (i.e in a loop) you must call
  //the GetEntry for each tree separately.
  //  eventChain->AddFriend(headTree);
  //  eventChain->AddFriend(prettyHkTree);


  //  char textLabel[180];
  //  char pngName[180];
  //  TGraph *gr[9]={0};

  
  Long64_t nentries=eventChain->GetEntries();
  
  Long64_t maxEntry=startEntry+numEntries;
  if(nentries<maxEntry)
     maxEntry=nentries;

  char outName[180];
  sprintf(outName,"corTree%d.root",run);

  TFile *fpOut = new TFile(outName,"RECREATE");
  Double_t peakVal[4];
  Int_t peakBin[4];
  UInt_t triggerTime;
  UInt_t triggerTimeNs;
  UInt_t eventNumber=0;
  TTree *corTree = new TTree("corTree","Tree of correlations");
  corTree->Branch("peakVal",&peakVal,"peakVal[4]/D");
  corTree->Branch("peakBin",&peakBin,"peakBin[4]/I");
  corTree->Branch("eventNumber",&eventNumber,"eventNumber/i");
  corTree->Branch("triggerTime",&triggerTime,"triggerTime/i");
  corTree->Branch("triggerTimeNs",&triggerTimeNs,"triggerTimeNs/i");


  Double_t deltaT=1./(2.6*8);

  Long64_t starEvery=maxEntry/40;
  if(starEvery==0) starEvery++;

  Int_t antNums[4]={1,9,18,19};
  TGraph *grTemplate[4]={0};

  eventChain->GetEntry(templateEntry);
  UsefulAnitaEvent templateEvent(event,WaveCalType::kVoltageTime);
  for(int ant=0;ant<4;ant++) {
    grTemplate[ant]=templateEvent.getGraph(antNums[ant],AnitaPol::kVertical);
  }
  for(Long64_t entry=startEntry;entry<maxEntry;entry++) {
    
    if(entry%starEvery==0) 
      cerr << "*";

    //Stupidly must do this to be perfectly safe  
    eventChain->GetEntry(entry);
    headTree->GetEntry(entry);
    //    prettyHkTree->GetEntry(entry);
   
    
    
    UsefulAnitaEvent realEvent(event,WaveCalType::kVoltageTime);
    //    if((entry-startEntry)%100==0)
    //      cout << realEvent.eventNumber << endl;
    
    
    
    for(int ant=0;ant<4;ant++) {
      TGraph *grEvent=realEvent.getGraph(antNums[ant],AnitaPol::kVertical);
    
      //    TGraph *grCor = FFTtools::getInterpolatedCorrelationGraph(grTemplate,grEvent,deltaT);
      TGraph *grCor = FFTtools::getCorrelationGraph(grTemplate[ant],grEvent);
      peakVal[ant]=FFTtools::getPeakVal(grCor);
      peakBin[ant]=FFTtools::getPeakBin(grCor);
      delete grEvent;
      delete grCor;
    }
    triggerTime=header->triggerTime;
    triggerTimeNs=header->triggerTimeNs;
    corTree->Fill();

  }
  corTree->AutoSave();

}
コード例 #15
0
ファイル: skimTree.C プロジェクト: ramankhurana/usercode
void skimTree(std::string inputFile_)
{

  
  TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(inputFile_.data());
  if (!f) {
    f = new TFile(inputFile_.data());
    f->cd(Form("%s:/tree",inputFile_.data()));
  }
  TTree* fChain = (TTree*)gDirectory->Get("tree");
  cout << "Input file is " << inputFile_ << endl;

  // rename the output file
  std::string remword=".root";
  size_t pos = inputFile_.find(remword);
  std::string forOutput = inputFile_;  
  if(pos!= std::string::npos)
    forOutput.swap(forOutput.erase(pos,remword.length()));   
  std::string endfix = "_filteredtree.root";
  std::string outputFile = forOutput + endfix;
  // now open new root file
  TFile* newfile_data = new TFile(outputFile.data(),"recreate");
  cout << "Output file " << outputFile << endl;

  // clone tree
  TTree* newtree = fChain->CloneTree(0);
  newtree->SetMaxTreeSize(4000000000);
  cout << "Saving "  << endfix << " tree" << endl;

  Long64_t nentries = fChain->GetEntries();
  cout << "nentries = " << nentries << endl;

  Int_t           eventNo=-1;
  Int_t           runNo=-1;

  vector<int>*     trigResults;
  vector<string>*  trigName;


  bool isData=false;
  if(forOutput.find("DoubleElectron")!= std::string::npos || forOutput.find("DoubleMu")!= std::string::npos)
    isData=true;


  fChain->SetBranchAddress("EvtInfo_EventNum",&eventNo);
  fChain->SetBranchAddress("EvtInfo_RunNum",&runNo);
  if(isData){
    fChain->SetBranchAddress("trigResults", &trigResults);
    fChain->SetBranchAddress("trigName", &trigName);
  }

  Long64_t nlines=0;

  vector<runInfo> myList;

  ifstream fin;

  if(forOutput.find("DoubleElectron")!= std::string::npos)
    fin.open("/data4/syu/52X_533_validation/DoubleElectron_common.txt");
  else if(forOutput.find("DoubleMu")!= std::string::npos)
    fin.open("/data4/syu/52X_533_validation/DoubleMu_common.txt");
  else if(forOutput.find("GluGlu")!= std::string::npos)
    fin.open("/data4/syu/52X_533_validation/MC_common.txt");
  runInfo tempInfo;
  fin >> tempInfo.run >> tempInfo.evt;
  while(!fin.eof())
    {
      nlines++;
      myList.push_back(tempInfo);
      fin >> tempInfo.run >> tempInfo.evt;
    }
  fin.close();

  cout << "There are " << nlines << " lines" << endl;

  ofstream fout;
  fout.open(Form("%s_updated",forOutput.data()));

  Long64_t nPassEvt=0;

  for (Long64_t jentry=0; jentry<nentries;jentry++) {

    
    eventNo = -1;
    runNo = -1;
    trigName = 0;
    trigResults = 0;
    
    fChain->GetEntry(jentry);


    bool passTrigger=false;
    if(isData){

      for(int it=0; it< trigName->size(); it++)
	{
	  std::string thisTrig= trigName->at(it);
	  int results = trigResults->at(it);
//   	  cout << thisTrig << "\t" << results << endl;

	  if(forOutput.find("DoubleElectron")!= std::string::npos && 
	     thisTrig.find("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL")
	     != std::string::npos && results==1)
	    {
	      passTrigger=true;
// 	      cout << "Find HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL" << endl;
	      break;
	    }	  

	  if(forOutput.find("DoubleMu")!= std::string::npos && thisTrig.find("HLT_Mu17_Mu8")!= std::string::npos && results==1)
	    {
	      passTrigger=true;
// 	      cout << "Find HLT_Mu17_Mu8" << endl;
	      break;
	    }

	  if(forOutput.find("DoubleMu")!= std::string::npos && thisTrig.find("HLT_Mu17_TkMu8")!= std::string::npos && results==1)
	    {
	      passTrigger=true;
// 	      cout << "Find HLT_Mu17_TkMu8" << endl;
	      break;
	    }

	}

    }
    if(!passTrigger && isData)continue;

    bool pass=false;

    runInfo thisInfo;
    thisInfo.run = runNo;
    thisInfo.evt = eventNo;

    vector<runInfo>::const_iterator location = std::find(myList.begin(), myList.end(), thisInfo);
    if(location != myList.end()) pass=true;

    if(!pass)continue;
    newtree->Fill();
    nPassEvt++;
    fout << runNo << "\t" << eventNo << endl;

    if (jentry%100==0)
      printf("%4.1f%% done.\r",(float)jentry/(float)nentries*100.);		

  }
 
  newtree->Print();
  newtree->AutoSave();
  delete newfile_data;

  fout.close();

  cout << "Number of passed events = " << nPassEvt << endl;
}
コード例 #16
0
void skimTree1_2ndSkim::Loop()
{
   if (fChain == 0) return;
  std::string remword=".root";
  size_t pos = inputFile_.find(remword);
  std::string forOutput = inputFile_;  
  if(pos!= std::string::npos)
    forOutput.swap(forOutput.erase(pos,remword.length()));   
  std::string endfix = "_filtered.root";
  std::string outputFile = forOutput + endfix;
   // now open new root file
  TFile* newfile_data = new TFile(outputFile.data(),"recreate");

  // clone tree
  TTree* newtree = fChain->CloneTree(0);
  newtree->SetMaxTreeSize(5000000000);
  cout << "Saving "  << outputFile       << " tree" << endl;

  ofstream fout;
  fout.open("wrong.dat");
  Long64_t nentries = fChain->GetEntriesFast();
  Long64_t nPassEvt=0;
  Long64_t nbytes = 0, nb = 0;
  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%100==0)
      printf("%4.1f%% done.\r",(float)jentry/(float)nentries*100.);		

    // require events have CA8jet pt >200
/*
    bool hasCA8jet=false;

    for(int i=0; i < CA8nJet; i++){

	double jet_pt = CA8jetPt->at(i);
      	
	if(jet_pt >200)
	{
		hasCA8jet=true;
		cout<<"ev: "<< jentry << " jet pt: "<<jet_pt<<endl;
		break;
        }


    } // end of loop over ca8 jet
*/
    // require gen muon (status=3) <- W <- top

    //           cout<<"ev: "<< jentry <<endl;

    bool hasGenMuon=false;

    for(int i=0; i < nGenPar; i++){

	if(genParId->at(i) !=13 && genParId->at(i) != -13  ){continue;}
	if(genParSt->at(i)!=3){continue;}

	       //cout<<"ev: "<< jentry <<endl;
               //cout<<" ID : "<< genParId->at(i)<<" status: " <<genParSt->at(i)<<endl;

	int mother_index = genMo1->at(i);
        if(genParId->at(mother_index) !=24 && genParId->at(mother_index) != -24  ){continue;}

              //cout<<" mother ID : "<< genParId->at(mother_index)<<endl;

        int grandmother_index = genMo1->at(mother_index);
        if(genParId->at(grandmother_index) !=6 && genParId->at(grandmother_index) != -6  ){continue;}

              //cout<<" grand mother ID : "<< genParId->at(grandmother_index)<<endl;
    
                hasGenMuon=true;
//                cout<<"ev: "<< jentry << " jet pt: "<<jet_pt<<endl;
                break;


    } // end of loop over gen




    if(!hasGenMuon)continue;
    newtree->Fill();
    nPassEvt++;
  }
  
  // newtree->Print();
  newtree->AutoSave();
  delete newfile_data;
  fout.close();


 cout << "nentries = " << nentries << endl;
 cout << "Number of passed events = " << nPassEvt << endl;
 cout << "Reduction rate = " << (double)nPassEvt/(double)nentries << endl;

}
コード例 #17
0
ファイル: applypieeSel.C プロジェクト: dcraik/lhcb
void applypieeSel(TString file) {
	TString fname   = "/Disk/ecdf-nfs-ppe/lhcb/dcraik/Kee/"; fname+=file; fname+=".root";
	TString outname = "/Disk/ecdf-nfs-ppe/lhcb/dcraik/Kee/"; outname+=file; outname+="_presel_piee.root";

	TFile* fin = TFile::Open(fname);
	TTree* tin = dynamic_cast<TTree*>(fin->Get("DecayTree"));

	TFile* fout = new TFile(outname,"RECREATE");
	TTree* tout = tin->CloneTree(0);

	Bool_t B_plus_L0ElectronDecision_TOS, B_plus_L0HadronDecision_TOS, B_plus_L0ElectronDecision_TIS, B_plus_L0HadronDecision_TIS, B_plus_L0MuonDecision_TIS, B_plus_L0PhotonDecision_TIS;
	Bool_t B_plus_Hlt1TrackAllL0Decision_TOS, B_plus_Hlt2TopoE3BodyBBDTDecision_TOS, B_plus_Hlt2TopoE2BodyBBDTDecision_TOS, B_plus_Hlt2Topo3BodyBBDTDecision_TOS, B_plus_Hlt2Topo2BodyBBDTDecision_TOS;

	Double_t K_Kst_TRACK_GhostProb, e_plus_TRACK_GhostProb, e_minus_TRACK_GhostProb, K_Kst_ProbNNk, K_Kst_PIDe, e_plus_PIDe, e_minus_PIDe;
	Double_t B_plus_M, B_plus_M02_Subst0_e2pi, B_plus_M02, J_psi_1S_M;
	Float_t B_plus_DTFM_M;
	Double_t B_plus_HOP_M, B_plus_FDCHI2_OWNPV;
	Double_t e_plus_BremMultiplicity, e_minus_BremMultiplicity;

	Int_t category;

	//L0 trigger
	tin->SetBranchAddress("B_plus_L0ElectronDecision_TOS", &B_plus_L0ElectronDecision_TOS);
	tin->SetBranchAddress("B_plus_L0HadronDecision_TOS",   &B_plus_L0HadronDecision_TOS);
	tin->SetBranchAddress("B_plus_L0ElectronDecision_TIS", &B_plus_L0ElectronDecision_TIS);
	tin->SetBranchAddress("B_plus_L0HadronDecision_TIS",   &B_plus_L0HadronDecision_TIS);
	tin->SetBranchAddress("B_plus_L0MuonDecision_TIS",     &B_plus_L0MuonDecision_TIS);
	tin->SetBranchAddress("B_plus_L0PhotonDecision_TIS",   &B_plus_L0PhotonDecision_TIS);

	//HLT
	tin->SetBranchAddress("B_plus_Hlt1TrackAllL0Decision_TOS",     &B_plus_Hlt1TrackAllL0Decision_TOS);
	tin->SetBranchAddress("B_plus_Hlt2TopoE3BodyBBDTDecision_TOS", &B_plus_Hlt2TopoE3BodyBBDTDecision_TOS);
	tin->SetBranchAddress("B_plus_Hlt2TopoE2BodyBBDTDecision_TOS", &B_plus_Hlt2TopoE2BodyBBDTDecision_TOS);
	tin->SetBranchAddress("B_plus_Hlt2Topo3BodyBBDTDecision_TOS",  &B_plus_Hlt2Topo3BodyBBDTDecision_TOS);
	tin->SetBranchAddress("B_plus_Hlt2Topo2BodyBBDTDecision_TOS",  &B_plus_Hlt2Topo2BodyBBDTDecision_TOS);

	//ghost prob
	tin->SetBranchAddress("K_Kst_TRACK_GhostProb",                 &K_Kst_TRACK_GhostProb);
	tin->SetBranchAddress("e_plus_TRACK_GhostProb",                &e_plus_TRACK_GhostProb);
	tin->SetBranchAddress("e_minus_TRACK_GhostProb",               &e_minus_TRACK_GhostProb);
	
	//PID
	tin->SetBranchAddress("K_Kst_ProbNNk",                         &K_Kst_ProbNNk);
	tin->SetBranchAddress("K_Kst_PIDe",                            &K_Kst_PIDe);
	tin->SetBranchAddress("e_plus_PIDe",                           &e_plus_PIDe);
	tin->SetBranchAddress("e_minus_PIDe",                          &e_minus_PIDe);

	//masses
	tin->SetBranchAddress("B_plus_M",                              &B_plus_M);
	tin->SetBranchAddress("B_plus_M02_Subst0_e2pi",                &B_plus_M02_Subst0_e2pi);
	tin->SetBranchAddress("B_plus_M02",                            &B_plus_M02);
	tin->SetBranchAddress("J_psi_1S_M",                            &J_psi_1S_M);
	tin->SetBranchAddress("B_plus_DTFM_M",                         &B_plus_DTFM_M);

	//hop
	tin->SetBranchAddress("B_plus_HOP_M",                          &B_plus_HOP_M);
	tin->SetBranchAddress("B_plus_FDCHI2_OWNPV",                   &B_plus_FDCHI2_OWNPV);

	//brem
	tin->SetBranchAddress("e_plus_BremMultiplicity",               &e_plus_BremMultiplicity);
	tin->SetBranchAddress("e_minus_BremMultiplicity",              &e_minus_BremMultiplicity);

	tout->Branch("category", &category);

	Int_t nEntries = tin->GetEntries();

	for(Int_t i=0; i<nEntries; ++i) {
		if(i%10000==0) std::cout << "Entry " << i << " of " << nEntries << "..." << std::endl;
		tin->GetEntry(i);

		//category for binning in L0 cat and brem multiplicity
		category = 0;

		switch(e_plus_BremMultiplicity+e_minus_BremMultiplicity) {
			case 0:
				break;
			case 1:
				category+=1;
				break;
			default:
				category+=2;
		}

		//L0
		if(B_plus_L0ElectronDecision_TOS==1) category+=6;
		else if(B_plus_L0HadronDecision_TOS==1) category+=3;
		else if((B_plus_L0ElectronDecision_TIS==1) || (B_plus_L0HadronDecision_TIS==1) || (B_plus_L0MuonDecision_TIS==1) || (B_plus_L0PhotonDecision_TIS)) category+=0;
		else continue;

		//HLT
		if(B_plus_Hlt1TrackAllL0Decision_TOS!=1) continue;
		if(!((B_plus_Hlt2TopoE3BodyBBDTDecision_TOS==1) || (B_plus_Hlt2TopoE2BodyBBDTDecision_TOS==1) || 
		     (B_plus_Hlt2Topo3BodyBBDTDecision_TOS==1)  || (B_plus_Hlt2Topo2BodyBBDTDecision_TOS==1))  ) continue;
		
		//ghost prob
		if(K_Kst_TRACK_GhostProb>0.3 || e_plus_TRACK_GhostProb>0.3 || e_minus_TRACK_GhostProb>0.3) continue;

		//PID
		if(K_Kst_ProbNNk>0.2 || K_Kst_PIDe>0 || e_plus_PIDe<3 || e_minus_PIDe<3) continue;

		tout->Fill();

	}

	tout->AutoSave();
	fout->Close();
}
コード例 #18
0
ファイル: Slimmer.C プロジェクト: RohanBhandari/MJ
void Slimmer(TString InputCfAName, TString output_filename)
{
    
  TChain * chainA = new TChain("/configurableAnalysis/eventA");   
  TChain * chainB = new TChain("/configurableAnalysis/eventB");    
  chainA->Add(InputCfAName);
  chainB->Add(InputCfAName);

  InitializeA(chainA);
  InitializeB(chainB);
  
  chainA->SetBranchStatus("*",0);
  chainB->SetBranchStatus("*",0);

  chainA->SetBranchStatus("els_conversion_dist",1);
  chainA->SetBranchStatus("els_conversion_dcot",1);
  chainA->SetBranchStatus("PU_TrueNumInteractions",1);
  chainA->SetBranchStatus("rho_kt6PFJetsForIsolation2011",1);
  chainA->SetBranchStatus("els_PFphotonIsoR03",1);
  chainA->SetBranchStatus("els_PFneutralHadronIsoR03",1);
  chainA->SetBranchStatus("els_PFchargedHadronIsoR03",1);
  chainA->SetBranchStatus("els_hasMatchedConversion",1);

  chainB->SetBranchStatus("mus_charge",1);
  chainB->SetBranchStatus("mus_pt",1);
  chainB->SetBranchStatus("mus_eta",1);
  chainB->SetBranchStatus("mus_et",1);
  chainB->SetBranchStatus("mus_phi",1);
  chainB->SetBranchStatus("mus_px",1);
  chainB->SetBranchStatus("mus_py",1);
  chainB->SetBranchStatus("mus_pz",1);
  chainB->SetBranchStatus("mus_tk_chi2",1);
  chainB->SetBranchStatus("mus_tk_ndof",1);
  chainB->SetBranchStatus("mus_tk_numvalhits",1);
  chainB->SetBranchStatus("mus_tk_numvalPixelhits",1);
  chainB->SetBranchStatus("mus_tk_px",1);
  chainB->SetBranchStatus("mus_tk_py",1);
  chainB->SetBranchStatus("mus_tk_pz",1);
  chainB->SetBranchStatus("mus_tk_pt",1);
  chainB->SetBranchStatus("mus_tk_ptErr",1);
  chainB->SetBranchStatus("mus_tk_numpixelWthMeasr",1);
  chainB->SetBranchStatus("mus_tk_vx",1);
  chainB->SetBranchStatus("mus_tk_vy",1);
  chainB->SetBranchStatus("mus_tk_vz",1);
  chainB->SetBranchStatus("mus_tk_d0dum",1);
  chainB->SetBranchStatus("mus_tk_phi",1);
  chainB->SetBranchStatus("mus_cm_pt",1);
  chainB->SetBranchStatus("mus_cm_ptErr",1);
  chainB->SetBranchStatus("mus_cm_chi2",1);
  chainB->SetBranchStatus("mus_cm_ndof",1);
  chainB->SetBranchStatus("mus_stamu_pt",1);
  chainB->SetBranchStatus("mus_stamu_ptErr",1);
  chainB->SetBranchStatus("mus_tIso",1);
  chainB->SetBranchStatus("mus_cIso",1);
  chainB->SetBranchStatus("mus_energy",1);
  chainB->SetBranchStatus("mus_ecalIso",1);
  chainB->SetBranchStatus("mus_hcalIso",1);
  chainB->SetBranchStatus("mus_ecalvetoDep",1);
  chainB->SetBranchStatus("mus_hcalvetoDep",1);
  chainB->SetBranchStatus("mus_id_GlobalMuonPromptTight",1);
  chainB->SetBranchStatus("mus_id_AllTrackerMuons",1);
  chainB->SetBranchStatus("mus_id_AllGlobalMuons",1);
  chainB->SetBranchStatus("mus_isTrackerMuon",1);
  chainB->SetBranchStatus("mus_isGlobalMuon",1);
  chainB->SetBranchStatus("mus_num_matches",1);
  chainB->SetBranchStatus("mus_isPFMuon",1);
  chainB->SetBranchStatus("mus_numberOfMatchedStations",1);
  chainB->SetBranchStatus("mus_pfIsolationR03_sumChargedHadronPt",1);
  chainB->SetBranchStatus("mus_pfIsolationR03_sumChargedParticlePt",1);
  chainB->SetBranchStatus("mus_pfIsolationR03_sumNeutralHadronEt",1);
  chainB->SetBranchStatus("mus_pfIsolationR03_sumNeutralHadronEtHighThreshold",1);
  chainB->SetBranchStatus("mus_pfIsolationR03_sumPhotonEt",1);
  chainB->SetBranchStatus("mus_pfIsolationR03_sumPhotonEtHighThreshold",1);
  chainB->SetBranchStatus("mus_pfIsolationR03_sumPUPt",1);
  chainB->SetBranchStatus("mus_pfIsolationR04_sumChargedHadronPt",1);
  chainB->SetBranchStatus("mus_pfIsolationR04_sumChargedParticlePt",1);
  chainB->SetBranchStatus("mus_pfIsolationR04_sumNeutralHadronEt",1);
  chainB->SetBranchStatus("mus_pfIsolationR04_sumNeutralHadronEtHighThreshold",1);
  chainB->SetBranchStatus("mus_pfIsolationR04_sumPhotonEt",1);
  chainB->SetBranchStatus("mus_pfIsolationR04_sumPhotonEtHighThreshold",1);
  chainB->SetBranchStatus("mus_pfIsolationR04_sumPUPt",1);
  chainB->SetBranchStatus("mus_dB",1);

  chainB->SetBranchStatus("pfcand_pdgId",1);
  chainB->SetBranchStatus("pfcand_particleId",1);
  chainB->SetBranchStatus("pfcand_pt",1);
  chainB->SetBranchStatus("pfcand_pz",1);
  chainB->SetBranchStatus("pfcand_px",1);
  chainB->SetBranchStatus("pfcand_py",1);
  chainB->SetBranchStatus("pfcand_eta",1);
  chainB->SetBranchStatus("pfcand_phi",1);
  chainB->SetBranchStatus("pfcand_theta",1);
  chainB->SetBranchStatus("pfcand_energy",1);
  chainB->SetBranchStatus("pfcand_charge",1);

  chainB->SetBranchStatus("pf_mus_pt",1);
  chainB->SetBranchStatus("pf_mus_eta",1);
  chainB->SetBranchStatus("pf_mus_et",1);
  chainB->SetBranchStatus("pf_mus_tk_chi2",1);
  chainB->SetBranchStatus("pf_mus_tk_ndof",1);
  chainB->SetBranchStatus("pf_mus_tk_numvalhits",1);
  chainB->SetBranchStatus("pf_mus_tk_numvalPixelhits",1);
  chainB->SetBranchStatus("pf_mus_tk_pt",1);
  chainB->SetBranchStatus("pf_mus_tk_ptErr",1);
  chainB->SetBranchStatus("pf_mus_cm_pt",1);
  chainB->SetBranchStatus("pf_mus_cm_ptErr",1);
  chainB->SetBranchStatus("pf_mus_cm_chi2",1);
  chainB->SetBranchStatus("pf_mus_cm_ndof",1);
  chainB->SetBranchStatus("pf_mus_stamu_pt",1);
  chainB->SetBranchStatus("pf_mus_stamu_ptErr",1);
  chainB->SetBranchStatus("pf_mus_tIso",1);
  chainB->SetBranchStatus("pf_mus_cIso",1);
  chainB->SetBranchStatus("pf_mus_energy",1);
  chainB->SetBranchStatus("pf_mus_ecalIso",1);
  chainB->SetBranchStatus("pf_mus_hcalIso",1);
  chainB->SetBranchStatus("pf_mus_tk_d0dum",1);
  chainB->SetBranchStatus("pf_mus_tk_phi",1);
  chainB->SetBranchStatus("pf_mus_phi",1);
  chainB->SetBranchStatus("pf_mus_px",1);
  chainB->SetBranchStatus("pf_mus_py",1);
  chainB->SetBranchStatus("pf_mus_pz",1);
  chainB->SetBranchStatus("pf_mus_id_GlobalMuonPromptTight",1);
  chainB->SetBranchStatus("pf_mus_charge",1);
  chainB->SetBranchStatus("pf_mus_num_matches",1);
  chainB->SetBranchStatus("pf_mus_tk_numpixelWthMeasr",1);
  chainB->SetBranchStatus("pf_mus_tk_vz",1);
  chainB->SetBranchStatus("mus_tk_LayersWithMeasurement",1);
  chainB->SetBranchStatus("pf_mus_isTrackerMuon",1);
  chainB->SetBranchStatus("pf_mus_isGlobalMuon",1);
  chainB->SetBranchStatus("pf_mus_chargedHadronIso",1);
  chainB->SetBranchStatus("pf_mus_neutralHadronIso",1);
  chainB->SetBranchStatus("pf_mus_photonIso",1);

  chainB->SetBranchStatus("els_pt",1);
  chainB->SetBranchStatus("els_ptError",1);
  chainB->SetBranchStatus("els_n_inner_layer");
  chainB->SetBranchStatus("els_px",1);
  chainB->SetBranchStatus("els_py",1);
  chainB->SetBranchStatus("els_pz",1);
  chainB->SetBranchStatus("els_et",1);
  chainB->SetBranchStatus("els_eta",1);
  chainB->SetBranchStatus("els_phi",1);
  chainB->SetBranchStatus("els_charge",1);
  chainB->SetBranchStatus("els_isEB",1);
  chainB->SetBranchStatus("els_isEE",1);
  chainB->SetBranchStatus("els_simpleEleId70relIso",1);
  chainB->SetBranchStatus("els_simpleEleId70cIso",1);
  chainB->SetBranchStatus("els_simpleEleId80cIso",1);
  chainB->SetBranchStatus("els_simpleEleId80relIso",1);
  chainB->SetBranchStatus("els_simpleEleId85cIso",1);
  chainB->SetBranchStatus("els_simpleEleId85relIso",1);
  chainB->SetBranchStatus("els_simpleEleId90cIso",1);
  chainB->SetBranchStatus("els_simpleEleId90relIso",1);
  chainB->SetBranchStatus("els_simpleEleId95cIso",1);
  chainB->SetBranchStatus("els_simpleEleId95relIso",1);
  chainB->SetBranchStatus("els_tIso",1);
  chainB->SetBranchStatus("els_cIso",1);
  chainB->SetBranchStatus("els_hcalIso",1);
  chainB->SetBranchStatus("els_ecalIso",1);
  chainB->SetBranchStatus("els_d0dum",1);
  chainB->SetBranchStatus("els_tk_phi",1);
  chainB->SetBranchStatus("els_tk_pt",1);
  chainB->SetBranchStatus("els_tk_pz",1);
  chainB->SetBranchStatus("els_robustTightId",1);
  chainB->SetBranchStatus("els_dr03EcalRecHitSumEt",1);
  chainB->SetBranchStatus("els_dr03TkSumPt",1);
  chainB->SetBranchStatus("els_dr03HcalTowerSumEt",1);
  chainB->SetBranchStatus("els_sigmaIEtaIEta",1);
  chainB->SetBranchStatus("els_dPhiIn",1);
  chainB->SetBranchStatus("els_dEtaIn",1);
  chainB->SetBranchStatus("els_dPhiOut",1);
  chainB->SetBranchStatus("els_dEtaOut",1);
  chainB->SetBranchStatus("els_scEta",1);
  chainB->SetBranchStatus("els_hadOverEm",1);
  chainB->SetBranchStatus("els_isEB",1);
  chainB->SetBranchStatus("els_isEE",1);
  chainB->SetBranchStatus("els_energy",1);
  chainB->SetBranchStatus("els_scEnergy",1);
  chainB->SetBranchStatus("els_scE2x5Max",1);
  chainB->SetBranchStatus("els_scE5x5",1);
  chainB->SetBranchStatus("els_scE1x5",1);
  chainB->SetBranchStatus("els_dr03HcalDepth1TowerSumEt",1);
  chainB->SetBranchStatus("els_dr03HcalDepth2TowerSumEt",1);
  chainB->SetBranchStatus("els_eOverPIn",1);
  chainB->SetBranchStatus("els_numlosthits",1);
  chainB->SetBranchStatus("els_vx",1);
  chainB->SetBranchStatus("els_vy",1);
  chainB->SetBranchStatus("els_vz",1);
  chainB->SetBranchStatus("els_caloEnergy",1);

  chainB->SetBranchStatus("pf_els_pt",1);
  chainB->SetBranchStatus("pf_els_ptError",1);
  chainB->SetBranchStatus("pf_els_n_inner_layer");
  chainB->SetBranchStatus("pf_els_px",1);
  chainB->SetBranchStatus("pf_els_py",1);
  chainB->SetBranchStatus("pf_els_pz",1);
  chainB->SetBranchStatus("pf_els_et",1);
  chainB->SetBranchStatus("pf_els_eta",1);
  chainB->SetBranchStatus("pf_els_phi",1);
  chainB->SetBranchStatus("pf_els_charge",1);
  chainB->SetBranchStatus("pf_els_isEB",1);
  chainB->SetBranchStatus("pf_els_isEE",1);
  chainB->SetBranchStatus("pf_els_simpleEleId70relIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId70cIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId80cIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId80relIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId85cIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId85relIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId90cIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId90relIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId95cIso",1);
  chainB->SetBranchStatus("pf_els_simpleEleId95relIso",1);
  chainB->SetBranchStatus("pf_els_tIso",1);
  chainB->SetBranchStatus("pf_els_cIso",1);
  chainB->SetBranchStatus("pf_els_hcalIso",1);
  chainB->SetBranchStatus("pf_els_ecalIso",1);
  chainB->SetBranchStatus("pf_els_d0dum",1);
  chainB->SetBranchStatus("pf_els_tk_phi",1);
  chainB->SetBranchStatus("pf_els_robustTightId",1);
  chainB->SetBranchStatus("pf_els_dr03EcalRecHitSumEt",1);
  chainB->SetBranchStatus("pf_els_dr03TkSumPt",1);
  chainB->SetBranchStatus("pf_els_dr03HcalTowerSumEt",1);
  chainB->SetBranchStatus("pf_els_sigmaIEtaIEta",1);
  chainB->SetBranchStatus("pf_els_dPhiIn",1);
  chainB->SetBranchStatus("pf_els_dEtaIn",1);
  chainB->SetBranchStatus("pf_els_dPhiOut",1);
  chainB->SetBranchStatus("pf_els_dEtaOut",1);
  chainB->SetBranchStatus("pf_els_scEta",1);
  chainB->SetBranchStatus("pf_els_hadOverEm",1);
  chainB->SetBranchStatus("pf_els_isEB",1);
  chainB->SetBranchStatus("pf_els_isEE",1);
  chainB->SetBranchStatus("pf_els_energy",1);
  chainB->SetBranchStatus("pf_els_scEnergy",1);
  chainB->SetBranchStatus("pf_els_scE2x5Max",1);
  chainB->SetBranchStatus("pf_els_scE5x5",1);
  chainB->SetBranchStatus("pf_els_scE1x5",1);
  chainB->SetBranchStatus("pf_els_dr03HcalDepth1TowerSumEt",1);
  chainB->SetBranchStatus("pf_els_dr03HcalDepth2TowerSumEt",1);
  chainB->SetBranchStatus("pf_els_eOverPIn",1);
  chainB->SetBranchStatus("pf_els_numlosthits",1);
  chainB->SetBranchStatus("pf_els_vx",1);
  chainB->SetBranchStatus("pf_els_vy",1);
  chainB->SetBranchStatus("pf_els_vz",1);
  chainB->SetBranchStatus("pf_els_chargedHadronIso",1);
  chainB->SetBranchStatus("pf_els_neutralHadronIso",1);
  chainB->SetBranchStatus("pf_els_photonIso",1);

  chainB->SetBranchStatus("jets_AK5PFclean_rawPt",1);
  chainB->SetBranchStatus("jets_AK5PFclean_et",1);
  chainB->SetBranchStatus("jets_AK5PFclean_btag_TC_highPur",1);
  chainB->SetBranchStatus("jets_AK5PFclean_btag_TC_highEff",1);
  chainB->SetBranchStatus("jets_AK5PFclean_btag_secVertexHighPur",1);
  chainB->SetBranchStatus("jets_AK5PFclean_btag_secVertexHighEff",1);
  chainB->SetBranchStatus("jets_AK5PFclean_btag_secVertexCombined",1);
  chainB->SetBranchStatus("jets_AK5PFclean_btag_jetProb",1);
  chainB->SetBranchStatus("jets_AK5PFclean_btag_jetBProb",1);
  chainB->SetBranchStatus("jets_AK5PFclean_jetCharge",1);
  chainB->SetBranchStatus("jets_AK5PFclean_partonFlavour",1);
  chainB->SetBranchStatus("jets_AK5PFclean_parton_Id",1);
  chainB->SetBranchStatus("jets_AK5PFclean_parton_motherId",1);
  chainB->SetBranchStatus("jets_AK5PFclean_energy",1);
  chainB->SetBranchStatus("jets_AK5PFclean_pt",1);
  chainB->SetBranchStatus("jets_AK5PFclean_px",1);
  chainB->SetBranchStatus("jets_AK5PFclean_py",1);
  chainB->SetBranchStatus("jets_AK5PFclean_gen_pt",1);
  chainB->SetBranchStatus("jets_AK5PFclean_gen_phi",1);
  chainB->SetBranchStatus("jets_AK5PFclean_pz",1);
  chainB->SetBranchStatus("jets_AK5PFclean_eta",1);
  chainB->SetBranchStatus("jets_AK5PFclean_ehf",1);
  chainB->SetBranchStatus("jets_AK5PFclean_phi",1);
  chainB->SetBranchStatus("jets_AK5PFclean_neutralEmE",1);
  chainB->SetBranchStatus("jets_AK5PFclean_chgEmE",1);
  chainB->SetBranchStatus("jets_AK5PFclean_neutralHadE",1);
  chainB->SetBranchStatus("jets_AK5PFclean_chgHadE",1);
  chainB->SetBranchStatus("jets_AK5PFclean_mu_Mult",1);
  chainB->SetBranchStatus("jets_AK5PFclean_neutral_Mult",1);
  chainB->SetBranchStatus("jets_AK5PFclean_chg_Mult",1);
  chainB->SetBranchStatus("jets_AK5PFclean_corrFactorRaw",1);
  chainB->SetBranchStatus("jets_AK5PFclean_photonEnergy",1);

  chainB->SetBranchStatus("jets_AK5PF_et",1);
  chainB->SetBranchStatus("jets_AK5PF_btag_TC_highPur",1);
  chainB->SetBranchStatus("jets_AK5PF_btag_TC_highEff",1);
  chainB->SetBranchStatus("jets_AK5PF_btag_secVertexHighPur",1);
  chainB->SetBranchStatus("jets_AK5PF_btag_secVertexHighEff",1);
  chainB->SetBranchStatus("jets_AK5PF_btag_secVertexCombined",1);
  chainB->SetBranchStatus("jets_AK5PF_btag_jetProb",1);
  chainB->SetBranchStatus("jets_AK5PF_btag_jetBProb",1);
  chainB->SetBranchStatus("jets_AK5PF_jetCharge",1);
  chainB->SetBranchStatus("jets_AK5PF_partonFlavour",1);
  chainB->SetBranchStatus("jets_AK5PF_parton_Id",1);
  chainB->SetBranchStatus("jets_AK5PF_parton_motherId",1);
  chainB->SetBranchStatus("jets_AK5PF_energy",1);
  chainB->SetBranchStatus("jets_AK5PF_pt",1);
  chainB->SetBranchStatus("jets_AK5PF_px",1);
  chainB->SetBranchStatus("jets_AK5PF_py",1);
  chainB->SetBranchStatus("jets_AK5PF_gen_pt",1);
  chainB->SetBranchStatus("jets_AK5PF_gen_phi",1);
  chainB->SetBranchStatus("jets_AK5PF_pz",1);
  chainB->SetBranchStatus("jets_AK5PF_eta",1);
  chainB->SetBranchStatus("jets_AK5PF_ehf",1);
  chainB->SetBranchStatus("jets_AK5PF_phi",1);
  chainB->SetBranchStatus("jets_AK5PF_neutralEmE",1);
  chainB->SetBranchStatus("jets_AK5PF_chgEmE",1);
  chainB->SetBranchStatus("jets_AK5PF_neutralHadE",1);
  chainB->SetBranchStatus("jets_AK5PF_chgHadE",1);
  chainB->SetBranchStatus("jets_AK5PF_mu_Mult",1);
  chainB->SetBranchStatus("jets_AK5PF_neutral_Mult",1);
  chainB->SetBranchStatus("jets_AK5PF_chg_Mult",1);
  chainB->SetBranchStatus("jets_AK5PF_corrFactorRaw",1);
  chainB->SetBranchStatus("jets_AK5PF_photonEnergy",1);	
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_nconstituents",1);
  

  chainB->SetBranchStatus("pfmets_et",1);
  chainB->SetBranchStatus("pfmets_ex",1);
  chainB->SetBranchStatus("pfmets_ey",1);
  chainB->SetBranchStatus("pfmets_phi",1);
  chainB->SetBranchStatus("pfmets_sumEt",1);
  chainB->SetBranchStatus("pfmets_gen_et",1);
  chainB->SetBranchStatus("pfmets_gen_phi",1);

  chainB->SetBranchStatus("pfTypeImets_et",1);
  chainB->SetBranchStatus("pfTypeImets_ex",1);
  chainB->SetBranchStatus("pfTypeImets_ey",1);
  chainB->SetBranchStatus("pfTypeImets_phi",1);
  chainB->SetBranchStatus("pfTypeImets_sumEt",1);
  chainB->SetBranchStatus("pfTypeImets_gen_et",1);
  chainB->SetBranchStatus("pfTypeImets_gen_phi",1);

  chainB->SetBranchStatus("pv_x",1);
  chainB->SetBranchStatus("pv_y",1);
  chainB->SetBranchStatus("pv_z",1);
  chainB->SetBranchStatus("pv_tracksSize",1);
  chainB->SetBranchStatus("pv_ndof",1);
  chainB->SetBranchStatus("pv_isFake",1);
  chainB->SetBranchStatus("Npv",1);

  chainB->SetBranchStatus("run",1);
  chainB->SetBranchStatus("event",1);
  chainB->SetBranchStatus("lumiblock",1);
  chainB->SetBranchStatus("bunchCrossing",1);

  chainB->SetBranchStatus("beamSpot_y",1);
  chainB->SetBranchStatus("beamSpot_x",1);

  chainB->SetBranchStatus("weight",1);
  chainB->SetBranchStatus("model_params",1);

  // Make the new file
  TFile *newFile = new TFile(output_filename.Data(),"RECREATE");
  TDirectoryFile *dir = new TDirectoryFile("configurableAnalysis","configurableAnalysis");
  dir->cd();
  TTree *newtreeA = chainA->CloneTree(0);
  TTree *newtreeB = chainB->CloneTree(0);

  Int_t nentries = (Int_t)chainB->GetEntries();

  for (int iEnt = 0; iEnt<nentries; iEnt++) {
    chainA->GetEntry(iEnt);
    chainB->GetEntry(iEnt);
    newtreeA->Fill();
    newtreeB->Fill();
  }

  newtreeA->AutoSave();
  newtreeB->AutoSave();
  newFile->Write();
  newFile->Close();

}
コード例 #19
0
ファイル: MakeB_qlike.C プロジェクト: chernyavskaya/Hbb
void MakeB_qlike::Loop()
{
   if (fChain == 0) return;
   Long64_t nentries = fChain->GetEntriesFast();
   Long64_t nbytes = 0, nb = 0;

	Int_t presel=0;
	TreeJets TreeJet;
	Int_t loopJet_max;
	TFile *output = new TFile("b_likelihood_powheg_4var_bbqq5eta_125_08_qlike.root","recreate");
	TTree *tree = fChain->CloneTree(0);
	TBranch *blike_b = tree->Branch("Jet_blikelihood_b",TreeJet.blike_b,"Jet_blikelihood_b[nJet]/F");
	TBranch *blike_q = tree->Branch("Jet_blikelihood_q",TreeJet.blike_q,"Jet_blikelihood_q[nJet]/F");
	TBranch *b_matched = tree->Branch("Jet_b_matched",TreeJet.b_matched,"Jet_b_matched[nJet]/I");
	TBranch *q_matched = tree->Branch("Jet_q_matched",TreeJet.q_matched,"Jet_q_matched[nJet]/I");
	TBranch *qq_chosen = tree->Branch("Jet_qq_chosen",&TreeJet.qq_chosen,"Jet_qq_chosen/I");
	TString weightfile_q = "weights/TMVAClassification_BDTG_4var_qq5eta_125_08_qlike.weights.xml";
	float var1,var2,var3,var4,var5,var6,var7,var8,var9,var10, var11,var12;
   /*TMVA::Reader *reader_b = new TMVA::Reader("Silent");
	reader_b->AddVariable("Jet_pt",&var1);
	reader_b->AddVariable("Jet_eta",&var2);
	reader_b->AddVariable("Jet_btagCSV",&var3);
	reader_b->AddVariable("Jet_pt_idx",&var4);
	reader_b->AddVariable("Jet_eta_idx",&var5);
	reader_b->AddVariable("Jet_btagCSV_idx",&var6);
//   reader_b->AddVariable( "Jet_chMult", &var7 );
//  reader_b->AddVariable( "Jet_ptd", &var8 );
  // reader_b->AddVariable( "Jet_axis2", &var9 );
 //  reader_b->AddVariable( "Jet_leadTrPt", &var10 );
  // 	reader_b->AddVariable("Jet_btag_idx",&var11);
	reader_b->BookMVA("BDTG", weightfile_b);*/
	
   TMVA::Reader *reader_q = new TMVA::Reader("Silent");
	reader_q->AddVariable("Jet_pt",&var1);
//	reader_q->AddVariable("Jet_eta",&var2);
//	reader_q->AddVariable("Jet_btagCSV",&var3);
//	reader_q->AddVariable("Jet_pt_idx",&var4);
	reader_q->AddVariable("Jet_eta_idx",&var5);
	reader_q->AddVariable("Jet_btagCSV_idx",&var6);
	reader_q->AddVariable("Jet_deltaEtaBQ",&var12);
	reader_q->BookMVA("BDTG", weightfile_q);	

   for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      nb = fChain->GetEntry(jentry);   nbytes += nb;

	   JetList jetList_CSV, jetList_pt, jetList_eta , jetList_ql; 

		int loopJet_min = 6;
		if (nJet<6) loopJet_min=nJet;
		if (!((Jet_pt[0]>92.)&&(Jet_pt[1]>76.)&&(Jet_pt[2]>64.)&&(Jet_pt[3]>30.))) continue;

		for (int i=0;i<nJet;i++){
			TreeJet.blike_b[i] = -2;
			TreeJet.blike_q[i] = -2;
			TreeJet.b_matched[i] = 0.;	
			TreeJet.q_matched[i] = 0.;	
			TreeJet.qq_chosen = 0.;	
		}



		Double_t btag_max = 0.4;
		int btag_max1_number = -1;
		int btag_max2_number = -1;
		for (int i=0;i<loopJet_min;i++){
			if ((Jet_btagCSV[i]>btag_max)&&(Jet_id[i]>0)){
				btag_max=Jet_btagCSV[i];
				btag_max1_number=i;
			}
		}
		btag_max = 0.4;
		for (int i=0;i<loopJet_min;i++){
			if ((Jet_btagCSV[i]>btag_max)&&(i!=btag_max1_number)&&(Jet_id[i]>0)) {
				btag_max=Jet_btagCSV[i];
				btag_max2_number=i;
			} 
		}
		if (!((btag_max1_number>=0)&&(btag_max2_number>=0))) continue;
		TLorentzVector Bjet1;
		Bjet1.SetPtEtaPhiM(Jet_pt[btag_max1_number],Jet_eta[btag_max1_number],Jet_phi[btag_max1_number],Jet_mass[btag_max1_number]);
		
		TLorentzVector Bjet2;
		Bjet2.SetPtEtaPhiM(Jet_pt[btag_max2_number],Jet_eta[btag_max2_number],Jet_phi[btag_max2_number],Jet_mass[btag_max2_number]);


		Double_t pt_max = 20.;
		int pt_max1_number = -1;
		int pt_max2_number = -1;
		for (int i=0;i<loopJet_min;i++){
			if ((Jet_pt[i]>pt_max)&&(i!=btag_max1_number)&&(i!=btag_max2_number)&&(Jet_id[i]>0)) {
				pt_max=Jet_pt[i];
				pt_max1_number=i;	
			}
		}
		pt_max = 20.;
		for (int i=0;i<loopJet_min;i++){
			if ((Jet_pt[i]>pt_max)&&(i!=btag_max1_number)&&(i!=btag_max2_number)&&(i!=pt_max1_number)&&(Jet_id[i]>0)) {
				pt_max=Jet_pt[i];
				pt_max2_number=i;	
			}
		}
		
		if (!((pt_max1_number>=0)&&(pt_max2_number>=0))) continue;
			
		TLorentzVector Qjet1;
		Qjet1.SetPtEtaPhiM(Jet_pt[pt_max1_number],Jet_eta[pt_max1_number],Jet_phi[pt_max1_number],Jet_mass[pt_max1_number]);
	
		TLorentzVector Qjet2;
		Qjet2.SetPtEtaPhiM(Jet_pt[pt_max2_number],Jet_eta[pt_max2_number],Jet_phi[pt_max2_number],Jet_mass[pt_max2_number]);


		TLorentzVector qq;
		qq = Qjet1+Qjet2;
		Double_t Mqq = qq.M();
		Double_t bbDeltaPhi = TMath::Abs(Bjet1.DeltaPhi(Bjet2));
		Double_t qqDeltaEta = TMath::Abs(Qjet1.Eta()-Qjet2.Eta());
		if (!((Mqq>200)&&(qqDeltaEta>1.2)&&(bbDeltaPhi<2.4))) continue;

		if (HLT_BIT_HLT_QuadPFJet_DoubleBTagCSV_VBF_Mqq200_v!=1) continue;

		presel+=TMath::Sign(1.,genWeight);

		int loopJet_max = 5;
		if (nJet<5) loopJet_max = nJet; 

		for(int i=0; i<loopJet_max; i++){
			if ((i==btag_max1_number)||(i==btag_max2_number)) continue;
		   if(Jet_pt[i]<20 || Jet_id[i] <0) continue;
			if (Jet_btagCSV[i]==-10) Jet_btagCSV[i]=0; 
			if (Jet_btagCSV[i]>1.) Jet_btagCSV[i]=1.; 
		   jetList_CSV[Jet_btagCSV[i]]=i;
		   jetList_pt[Jet_pt[i]]=i;
         jetList_eta[TMath::Abs(Jet_eta[i])]=i;
	   }


		Float_t eta_sort[30];
		Float_t btag_sort[30];
		for (int i=0;i<loopJet_max;i++){
			if ((i==btag_max1_number)||(i==btag_max2_number)) continue;
			if ((Jet_pt[i]>20)&&(Jet_id[i]>0)) {
				TreeJet.eta[i] = TMath::Abs(Jet_eta[i]);
				eta_sort[i] = TMath::Abs(Jet_eta[i]);
		   	TreeJet.btagCSV[i]=Jet_btagCSV[i];
				btag_sort[i] = Jet_btagCSV[i];
			}
		}

		bubblesort(eta_sort,loopJet_max);
		bubblesort2(btag_sort,loopJet_max);
		int btag_0_num = 0;

	   for(int i=0; i<loopJet_max; i++){
			if ((i==btag_max1_number)||(i==btag_max2_number)) continue;
		   if(Jet_pt[i]<20 || Jet_id[i] <0) continue;
		   TreeJet.pt[i]=Jet_pt[i];
		   TreeJet.eta[i]=TMath::Abs(Jet_eta[i]); 
		   TreeJet.btagCSV[i]=Jet_btagCSV[i];
			TreeJet.ptd[i]=Jet_ptd[i];
			TreeJet.ch_mult[i]=Jet_chMult[i];
			TreeJet.axis2[i]=Jet_axis2[i];
			TreeJet.leadTrPt[i]=Jet_leadTrackPt[i];
			TreeJet.pt_idx[i] = i;
			TreeJet.eta_idx[i] = find(eta_sort,TreeJet.eta[i],loopJet_max);
			TreeJet.btagCSV_idx[i] = find(btag_sort,TreeJet.btagCSV[i],loopJet_max);
			if ((TreeJet.btagCSV[i]==0)&&(btag_0_num==0)) {
				btag_0_num =  find(btag_sort,TreeJet.btagCSV[i],loopJet_max);
				TreeJet.btagCSV_idx[i] = btag_0_num;
			} else 
			if ((TreeJet.btagCSV[i]==0)&&(btag_0_num!=0)) {
				btag_0_num++;
				TreeJet.btagCSV_idx[i] = btag_0_num;
			}
			TreeJet.btag_idx[i] = Jet_btagIdx[i];
			TreeJet.deltaEtaBQ[i] = TMath::Abs((Jet_eta[btag_max1_number]+Jet_eta[btag_max2_number])/2. - Jet_eta[i] );
		   TLorentzVector hJ0;
		   hJ0.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]);	
		   for(int j =0; j<2; j++){
			   if(TMath::Abs(GenBQuarkFromH_pdgId[j])==5){
            	TLorentzVector hQQ;
               hQQ.SetPtEtaPhiM(GenBQuarkFromH_pt[j],GenBQuarkFromH_eta[j],GenBQuarkFromH_phi[j],GenBQuarkFromH_mass[j]);
              	if(hQQ.DeltaR(hJ0)<0.8){ TreeJet.b_matched[i] =1.;  }
            } 
		   }
		   for(int j =0; j<2; j++){
				TLorentzVector hQ;
				hQ.SetPtEtaPhiM(GenHiggsSisters_pt[j],GenHiggsSisters_eta[j],GenHiggsSisters_phi[j],GenHiggsSisters_mass[j]);
				if(hQ.DeltaR(hJ0)<0.8) {TreeJet.q_matched[i] = 1.;}
		   }

		}



	for (int i=0;i<loopJet_max;i++){
			if ((i==btag_max1_number)||(i==btag_max2_number)) continue;
		   if(Jet_pt[i]<20 || Jet_id[i] <0) continue; 
			var1 = TreeJet.pt[i];
			var2 = TreeJet.eta[i];
	//		var3 = TreeJet.btagCSV[i];
			var4 = TreeJet.pt_idx[i];
			var5 = TreeJet.eta_idx[i];
			var6 = TreeJet.btagCSV_idx[i];
			var12 = TreeJet.deltaEtaBQ[i];
		//	var7 = TreeJet.ch_mult[i];
		//	var8 = TreeJet.ptd[i];
	//		var11 = TreeJet.btag_idx[i];
		//	TreeJet.blike_b[i] = reader_b->EvaluateMVA("BDTG");
	//		cout<<var3<<"   "<<var6<< "  "<<i<< "   "<<TreeJet.blike_b[i]<<  endl;

		//	var1 = TreeJet.pt[i];
		//	var2 = TreeJet.eta[i];
		//	var3 = TreeJet.btagCSV[i];
	//		var4 = TreeJet.pt_idx[i];
	//		var5 = TreeJet.eta_idx[i];
	//		var6 = TreeJet.btagCSV_idx[i];
			TreeJet.blike_q[i] = reader_q->EvaluateMVA("BDTG");
	}
	
        for(int i=0; i<loopJet_max; i++){
			if ((i==btag_max1_number)||(i==btag_max2_number)) continue;
                   if(Jet_pt[i]<20 || Jet_id[i] <0) continue;
                   jetList_ql[TreeJet.blike_q[i]]=i;
			}
	int cont=0;
	TLorentzVector hJ0, hJ1;
	JetList::reverse_iterator iJet=jetList_ql.rbegin();
	do{
 		int i = iJet->second;
		if(cont==0) hJ0.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]);
		if(cont==1) hJ1.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]);
		cont++;
		iJet++;
	}while (cont<2);
	int jet_isMatched=0;
	for(int j =0; j<2; j++){
			TLorentzVector hQ;
			hQ.SetPtEtaPhiM(GenHiggsSisters_pt[j],GenHiggsSisters_eta[j],GenHiggsSisters_phi[j],GenHiggsSisters_mass[j]);
			if((hQ.DeltaR(hJ1)<0.8 || hQ.DeltaR(hJ0)<0.8)) jet_isMatched++; 
	}
	if (jet_isMatched==2) 	TreeJet.qq_chosen=1;

	tree->Fill();
	}
	cout<<presel<<endl;
//	delete reader_b;
	delete reader_q;
	output->cd();
	tree->AutoSave();
	output->Close();
}
コード例 #20
0
//call this macro via root -l -b -q AddBranchEventsMT2tree.C++
//This code takes a text file containing run:lumisection:event:taggervalue (tagger value is a new filter you want to add to your tree),
//an old MT2tree file that does not contain that tagger
// and creates a new MT2tree file, which is a copy of the old one and contains additionally that tagger.
void AddBranchEventsMT2tree() {
// Example of Root macro to copy a subset of a Tree to a new Tree
// Only selected entries are copied to the new Tree.
// The input file has been generated by the program in $ROOTSYS/test/Event
// with   Event 1000 1 99 1
//Author: Rene Brun
   
//modified: Hannsjoerg Weber, 28/08/2013

   //make cleaning
   // get eventlist to clean
   // vector contains <run, < <lumisection, event>, taggervalue > >
   vector<pair<pair<int,pair<int,int> >,float> > rls; rls.clear();
   char buffer[200];
   ifstream filterdat("/shome/haweber/AODFiles_MT2SR/taggerlist/ControlRegionSinglePhotonPart1.dat");
   while( filterdat.getline(buffer, 200, '\n') ){
	int rrun(-1), lls(-1), eevent(-1), d1(-1); float ttagger(-1);
	sscanf(buffer, "*\t%d\t*\t%d\t*\t%d\t*\t%d\t*\t%f", &d1, &eevent, &lls, &rrun, &ttagger);
	pair<int,int> t1(lls,eevent);
	pair<int,pair<int,int> > t2(rrun,t1);
        pair<pair<int,pair<int,int> >, float> t3(t2,ttagger);
	rls.push_back(t3);
   }
cout << "Events for filtering " << rls.size() << endl;

   // get the old rootfile including events that should be tagged and define new event file including tagger variable
   TString oldfilename = "/shome/haweber/MT2Analysis/MT2trees/MT2_V02-03-02/20130914_8TeV_1g_removed/lowHT/SinglePhoton-Run2012C-PromptReco-v2-2.root";
   TString newfilename = "/shome/haweber/MT2Analysis/MT2trees/MT2_V02-03-02/20130914_8TeV_1g_removed/lowHT/SinglePhoton-Run2012C-PromptReco-v2-2_Filter.root";

	// if you want to apply an additional event selection, define cuts here
	std::ostringstream cutStream;
	std::ostringstream cutStreamBase;
	cutStream << " " 
		<< "NTausIDLoose3Hits+NMuons+NEles==0"                   << "&&"
		<< "misc.Jet0Pass==1&&misc.Jet1Pass==1"                  << "&&"
		<< "misc.Vectorsumpt<70&& misc.MinMetJetDPhi4Pt40 >0.3";
		cutStream << "&&((misc.MET>200&&misc.HT<=750&&misc.HT>=450&&misc.MT2>200)||(misc.HT>750&&misc.MET>30&&misc.MT2>=100))";
	cutStreamBase << " " 
      << "misc.PassJet40ID ==1"                             << "&&"
      << "(misc.HBHENoiseFlag == 0 || misc.ProcessID==10)"  << "&&" // not there for fastsim (i.e. signal)
      << "misc.CSCTightHaloIDFlag == 0"                     << "&&"
      << "misc.trackingFailureFlag==0"                      << "&&"
      << "misc.eeBadScFlag==0"                              << "&&"
      << "misc.EcalDeadCellTriggerPrimitiveFlag==0"         << "&&"
      << "misc.TrackingManyStripClusFlag==0"                << "&&"
      << "misc.TrackingTooManyStripClusFlag==0"             << "&&"
      << "misc.TrackingLogErrorTooManyClustersFlag==0"      << "&&"
      << "misc.CrazyHCAL==0";

	TString cuts = cutStream.str().c_str();
	TString basecuts = cutStreamBase.str().c_str();
//	TString myCuts = cuts + "&&" + basecuts;// if cuts should be applied DO NOT comment this line
	TString myCuts = "";// if no cuts should be applied DO NOT comment this line

   //Get old file, old tree and set top branch address
   TFile *oldfile = new TFile(oldfilename.Data());
   TTree *oldtree = (TTree*)oldfile->Get("MassTree");

   MT2tree* fMT2tree = new MT2tree();
   oldtree->SetBranchAddress("MT2tree", &fMT2tree);
   Long64_t nentries =  oldtree->GetEntries();
   Long64_t nbytes = 0, nb = 0;
   int nev =0;

   //Create a new file + a clone of old tree in new file
   Float_t TOBTECTagger(-1);
   Float_t HOTagger(-1);
   Bool_t ExtraBeamHaloFilter(false);
   TFile *newfile = new TFile(newfilename.Data(),"RECREATE");
   TTree *newtree = oldtree->CloneTree(0);//clone all branches, but no event
   TBranch *newBranch  = newtree->Branch("TOBTECTagger", &TOBTECTagger, "TOBTECTagger/F");
   TBranch *newBranch2 = newtree->Branch("ExtraBeamHaloFilter", &ExtraBeamHaloFilter, "ExtraBeamHaloFilter/O");
   TBranch *newBranch3 = newtree->Branch("HOTagger", &HOTagger, "HOTagger/F");

   oldtree->Draw(">>selList", myCuts);
   TEventList *myEvtList = (TEventList*)gDirectory->Get("selList");
   oldtree->SetEventList(myEvtList);
   int counter=0;
   int numEvt = myEvtList->GetN();
   int printEvt = 100000;
   if(myEvtList->GetN()<1000000) printEvt = myEvtList->GetN()/25;
   cout << "Filtering done, size=" <<myEvtList->GetN()  << endl;
   while(myEvtList->GetEntry(counter++) !=-1){
	int jentry = myEvtList->GetEntry(counter-1);
	nb =  oldtree->GetEntry(jentry);   nbytes += nb;
	oldtree->SetBranchAddress("MT2tree", &fMT2tree);
	if(counter%printEvt==0) cout << "Process event " << counter << endl;	

	//make cleaning
	bool keep = true;
	int p=-1;
	for(int nn=0; nn<rls.size();++nn){
		if((rls[nn].first).first!=fMT2tree->misc.Run) continue; // --> run over matching 
		if(((rls[nn].first).second).first!=fMT2tree->misc.LumiSection) continue; // --> LS over matching 
		if(fMT2tree->misc.Event>0){
			if(((rls[nn].first).second).second==fMT2tree->misc.Event) { 
				TOBTECTagger = rls[nn].second;
				keep=false; p=nn; break;
			}
		}
		else{	//if event > INT_MAX correct overflow back.
			int evtt = ((rls[nn].first).second).second + INT_MAX;
			evtt = evtt - INT_MAX;
			if(evtt==fMT2tree->misc.Event) {keep=false; p=nn; break;}
		}
	}
	//two additional taggers
	bool beamhalo = false;
	float ho = fMT2tree->misc.MET/fMT2tree->misc.CaloMETRaw;
	if(fMT2tree->misc.CaloMETRaw<=0) ho=999.;
	HOTagger = ho;
	if(fMT2tree->jet[0].lv.DeltaPhi(fMT2tree->jet[1].lv)<0.2 && !(fMT2tree->jet[0].isPFIDMedium)) beamhalo = true;
	ExtraBeamHaloFilter = beamhalo;

	if(keep) TOBTECTagger = -1;
	newtree->Fill();
	if(!keep){
		//remove event from rls vector --> increases speed.
		int tt = p;
		rls.erase(rls.begin()+p);
	}
   }
   newtree->Print();
   newtree->AutoSave();
   delete oldfile;
   delete newfile;
}
コード例 #21
0
int main(int nargs, char** args) {
    if(nargs<=1||nargs>2) {
        usage();
        return 0;
    }
    cout << "Going to skim " << args[1] << endl;
    
    string filename = string(args[1]);
    TFile *f1 = new TFile(filename.c_str());
    
    if(f1->IsZombie()) {
        cout << "FILE INVALID!" << endl;
        return 0;
    }
    TTree *t1 = (TTree*)f1->Get("events");
    TTree *info = (TTree*)f1->Get("info");
    TH1F *weight_histo = (TH1F*)f1->Get("weight_histo");
    weight_histo->SetEntries(0);
    
    float weight;
    t1->SetBranchAddress("weight",&weight);
    
    string thefilename=ExtractFilename(filename);
    string directory=ExtractDirectory(filename);
    
    stringstream Command;
    Command << "mkdir -p /scratch/" << directory << "Skim2/";
    gSystem->Exec(Command.str().c_str());
    
    stringstream b_file;
    b_file << "/scratch/" << directory << "Skim2/" << thefilename;
    cout << "Storing output at " << b_file.str() << endl;
    
    //  stringstream b_file2;
    //  b_file2 << directory << "Skim/DROPPED_" << thefilename;
    
    TFile *fb = new TFile(b_file.str().c_str(),"RECREATE");
    TTree *tb = t1->CloneTree(0);
    
    unsigned int NEvents=t1->GetEntries();
    unsigned int registered=0;
    
    
    for (Int_t i=0; i<t1->GetEntries(); i++) {
        t1->GetEntry(i);
        weight=1.0;
        tb->Fill();

    }
    
    cout << endl;
    
    tb->AutoSave();
    
    weight_histo->SetEntries(t1->GetEntries());
    fb->cd();
    weight_histo->Write();
    if(info) info->Write();
    fb->Close();
    
    f1->Close();
    
    return 0;
}
コード例 #22
0
ファイル: MakeB_single.C プロジェクト: chernyavskaya/Hbb
void MakeB_single::Loop()
{
   if (fChain == 0) return;
   Long64_t nentries = fChain->GetEntriesFast();
   Long64_t nbytes = 0, nb = 0;

	Int_t presel=0;
	TreeJets TreeJet;
	Int_t loopJet_max;
	TFile *output = new TFile("blikelihood_vbf_singlebtag_cmssw76_h21btrained.root","recreate");
	TTree *tree = fChain->CloneTree(0);
	TBranch *blike_b = tree->Branch("Jet_blikelihood_b",TreeJet.blike_b,"Jet_blikelihood_b[nJet]/F");
//	TBranch *blike_q = tree->Branch("Jet_blikelihood_q",TreeJet.blike_q,"Jet_blikelihood_q[nJet]/F");
//	TBranch *b_matched = tree->Branch("Jet_b_matched",TreeJet.b_matched,"Jet_b_matched[nJet]/I");
//	TBranch *q_matched = tree->Branch("Jet_q_matched",TreeJet.q_matched,"Jet_q_matched[nJet]/I");
//	TBranch *bb_chosen = tree->Branch("Jet_bb_chosen",&TreeJet.bb_chosen,"Jet_bb_chosen/I");
	TString weightfile_b = "weights/TMVA_blikelihood_vbf_cmssw76_h21trained.weights.xml";
//	TString weightfile_q = "weights/TMVAClassification_BDTG_6var_qq_125_08_single.weights.xml";
   TMVA::Reader *reader_b = new TMVA::Reader("Silent");
	float var1,var2,var3,var4,var5,var6,var7,var8,var9,var10, var11;
	reader_b->AddVariable("Jet_pt",&var1);
	reader_b->AddVariable("Jet_eta",&var2);
	reader_b->AddVariable("Jet_btagCSV",&var3);
	reader_b->AddVariable("Jet_pt_idx",&var4);
	reader_b->AddVariable("Jet_eta_idx",&var5);
	reader_b->AddVariable("Jet_btagCSV_idx",&var6);
//	reader_b->AddVariable("Jet_btagBDT",&var7);
//   reader_b->AddVariable( "Jet_chMult", &var7 );
//  reader_b->AddVariable( "Jet_ptd", &var8 );
  // reader_b->AddVariable( "Jet_axis2", &var9 );
 //  reader_b->AddVariable( "Jet_leadTrPt", &var10 );
  // 	reader_b->AddVariable("Jet_btag_idx",&var11);
	reader_b->BookMVA("BDTG", weightfile_b);
/*	
   TMVA::Reader *reader_q = new TMVA::Reader("Silent");
	reader_q->AddVariable("Jet_pt",&var1);
	reader_q->AddVariable("Jet_eta",&var2);
	reader_q->AddVariable("Jet_btagCSV",&var3);
	reader_q->AddVariable("Jet_pt_idx",&var4);
	reader_q->AddVariable("Jet_eta_idx",&var5);
	reader_q->AddVariable("Jet_btagCSV_idx",&var6);
	reader_q->BookMVA("BDTG", weightfile_q);	*/

   for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      nb = fChain->GetEntry(jentry);   nbytes += nb;

	   JetList jetList_CSV, jetList_pt, jetList_eta , jetList_bl; 


		for (int i=0;i<nJet;i++){
			TreeJet.blike_b[i] = -2;
			TreeJet.blike_q[i] = -2;
			TreeJet.b_matched[i] = 0.;	
			TreeJet.q_matched[i] = 0.;	
			TreeJet.bb_chosen = 0.;	
		}


		int btag_max1_number = -1;
		int btag_max2_number = -1;
		int pt_max1_number = -1;
		int pt_max2_number = -1;
		TLorentzVector Bjet1;
		TLorentzVector Bjet2;
		TLorentzVector Qjet1;
		TLorentzVector Qjet2;
		TLorentzVector qq;

		if (preselection_single(nJet, Jet_pt,Jet_eta, Jet_phi, Jet_mass, Jet_btagCSV, Jet_id, btag_max1_number, btag_max2_number, pt_max1_number, pt_max2_number, HLT_BIT_HLT_QuadPFJet_SingleBTagCSV_VBF_Mqq460_v, Bjet1, Bjet2, Qjet1, Qjet2, qq) ==0) {


		

////////////////////////////////////////////	
		presel+=TMath::Sign(1.,genWeight);

		int loopJet_max = 7;
		if (nJet<7) loopJet_max = nJet; 

		for(int i=0; i<loopJet_max; i++){
		   if(Jet_pt[i]<20/* || Jet_id[i] <=0*/) continue;
			if (Jet_btagCSV[i]==-10) Jet_btagCSV[i]=0; 
			if (Jet_btagCSV[i]>1.) Jet_btagCSV[i]=1.; 
		   jetList_CSV[Jet_btagCSV[i]]=i;
		   jetList_pt[Jet_pt[i]]=i;
         jetList_eta[TMath::Abs(Jet_eta[i])]=i;
	   }

		int actual_jets=0;
		Float_t eta_sort[30];
		Float_t btag_sort[30];
		for (int i=0;i<loopJet_max;i++){
			if ((Jet_pt[i]>20)/*&&(Jet_id[i]>0)*/) {
				TreeJet.eta[i] = TMath::Abs(Jet_eta[i]);
				eta_sort[i] = TMath::Abs(Jet_eta[i]);
				actual_jets++;
		   	TreeJet.btagCSV[i]=Jet_btagCSV[i];
				btag_sort[i] = Jet_btagCSV[i];
			}
		}

		bubblesort(eta_sort,actual_jets);
		bubblesort2(btag_sort,actual_jets);
		int btag_0_num = 0;

	   for(int i=0; i<loopJet_max; i++){
		   if(Jet_pt[i]<20 /*|| Jet_id[i] <=0*/) continue;
		   TreeJet.pt[i]=Jet_pt[i];
		   TreeJet.eta[i]=TMath::Abs(Jet_eta[i]); 
		   TreeJet.btagCSV[i]=Jet_btagCSV[i];
		   TreeJet.btagBDT[i]=Jet_btagBDT[i];
			TreeJet.ptd[i]=Jet_ptd[i];
			TreeJet.ch_mult[i]=Jet_chMult[i];
			TreeJet.axis2[i]=Jet_axis2[i];
			TreeJet.leadTrPt[i]=Jet_leadTrackPt[i];
			TreeJet.pt_idx[i] = i;
			TreeJet.eta_idx[i] = find(eta_sort,TreeJet.eta[i],loopJet_max);
			TreeJet.btagCSV_idx[i] = find(btag_sort,TreeJet.btagCSV[i],loopJet_max);
			if ((TreeJet.btagCSV[i]==0)&&(btag_0_num==0)) {
				btag_0_num =  find(btag_sort,TreeJet.btagCSV[i],loopJet_max);
				TreeJet.btagCSV_idx[i] = btag_0_num;
			} else 
			if ((TreeJet.btagCSV[i]==0)&&(btag_0_num!=0)) {
				btag_0_num++;
				TreeJet.btagCSV_idx[i] = btag_0_num;
			}
			TreeJet.btag_idx[i] = Jet_btagIdx[i];
		   TLorentzVector hJ0;
		   hJ0.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]);	
		   for(int j =0; j<2; j++){
			   if(TMath::Abs(GenBQuarkFromH_pdgId[j])==5){
            	TLorentzVector hQQ;
               hQQ.SetPtEtaPhiM(GenBQuarkFromH_pt[j],GenBQuarkFromH_eta[j],GenBQuarkFromH_phi[j],GenBQuarkFromH_mass[j]);
              	if(hQQ.DeltaR(hJ0)<0.8){ TreeJet.b_matched[i] =1.;  }
            } 
		   }
		   for(int j =0; j<2; j++){
				TLorentzVector hQ;
				hQ.SetPtEtaPhiM(GenHiggsSisters_pt[j],GenHiggsSisters_eta[j],GenHiggsSisters_phi[j],GenHiggsSisters_mass[j]);
			//	if(hQ.DeltaR(hJ0)<0.8) {TreeJet.q_matched[i] = 1.;}
		   }

		}




	for (int i=0;i<loopJet_max;i++){
		   if(Jet_pt[i]<20/* || Jet_id[i] <=0*/) continue; 
			var1 = TreeJet.pt[i];
			var2 = TreeJet.eta[i];
			var3 = TreeJet.btagCSV[i];
			var4 = TreeJet.pt_idx[i];
			var5 = TreeJet.eta_idx[i];
			var6 = TreeJet.btagCSV_idx[i];
//			var7=TreeJet.btagBDT[i];
			TreeJet.blike_b[i] = reader_b->EvaluateMVA("BDTG");
		}

	
	}
	
	

/*	
        for(int i=0; i<loopJet_max; i++){
                   if(Jet_pt[i]<20 || Jet_id[i] <0) continue;
                   jetList_bl[TreeJet.blike_b[i]]=i;
			}
	int cont=0;
	TLorentzVector hJ0, hJ1;
	JetList::reverse_iterator iJet=jetList_bl.rbegin();
	do{
 		int i = iJet->second;
		if(cont==0) hJ0.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]);
		if(cont==1) hJ1.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]);
		cont++;
		iJet++;
	}while (cont<2);
	int jet_isMatched=0;
	for(int j =0; j<2; j++){
		if(TMath::Abs(GenBQuarkFromH_pdgId[j])==5)
		{
			TLorentzVector hQ;
			hQ.SetPtEtaPhiM(GenBQuarkFromH_pt[j],GenBQuarkFromH_eta[j],GenBQuarkFromH_phi[j],GenBQuarkFromH_mass[j]);
			if((hQ.DeltaR(hJ1)<0.8 || hQ.DeltaR(hJ0)<0.8)) jet_isMatched++; 
		}
	}
	//if (jet_isMatched==2) 	TreeJet.bb_chosen=1;
*/
	tree->Fill();
	}
	cout<<presel<<endl;
	delete reader_b;
//	delete reader_q;
	output->cd();
	tree->AutoSave();
	output->Close();
}
コード例 #23
0
ファイル: SkimTree.C プロジェクト: MarcoAndreaBuchmann/CBAF
int main(int nargs, char** args) {
  if(nargs<=1||nargs>2) {
    usage();
    return 0;
  }
  cout << "Going to skim " << args[1] << endl;
  
  string filename = string(args[1]);
  TFile *f1 = new TFile(filename.c_str());
  
  if(f1->IsZombie()) {
    cout << "FILE INVALID!" << endl;
    return 0;
  }
  TTree *t1 = (TTree*)f1->Get("events");
  TTree *info = (TTree*)f1->Get("info");
  TH1F *weight_histo = (TH1F*)f1->Get("weight_histo");
  
  int pfJetGoodNum30;
  float mll;
  int leptonNum;
  int pfJetGoodNum40n1sigma;
  t1->SetBranchAddress("leptonNum",&leptonNum);
  t1->SetBranchAddress("pfJetGoodNum30",&pfJetGoodNum30);
  t1->SetBranchAddress("pfJetGoodNum40n1sigma",&pfJetGoodNum40n1sigma);
  t1->SetBranchAddress("mll",&mll);
  
  string thefilename=ExtractFilename(filename);
  string directory=ExtractDirectory(filename);
  
  stringstream Command;
  Command << "mkdir -p /scratch/" << directory << "Skim2/";
  gSystem->Exec(Command.str().c_str());
  
  stringstream b_file;
  b_file << "/scratch/" << directory << "Skim2/" << thefilename;
  cout << "Storing output at " << b_file.str() << endl;
  
//  stringstream b_file2;
//  b_file2 << directory << "Skim/DROPPED_" << thefilename;
  
  TFile *fb = new TFile(b_file.str().c_str(),"RECREATE");
  TTree *tb = t1->CloneTree(0);

  unsigned int NEvents=t1->GetEntries();
  unsigned int registered=0;
  
  
  for (Int_t i=0;i<t1->GetEntries(); i++) {
    t1->GetEntry(i);
    if(i%100000==0) cout << "\r Working, currently " << ((float)100*i)/NEvents << " % done " << std::flush;
    if(leptonNum>2) {
      //if the event has more than 2 leptons it is a good candidate for WZ so we need it!
      tb->Fill();
      registered++;
    } else {
      //2 or less leptons - only keep it if mll>0 and there's enough jets
      if(mll==0) {
	continue;
      }
      if(pfJetGoodNum30==0 && pfJetGoodNum40n1sigma==0) {
	continue;
      }
      tb->Fill();
      registered++;
    }
  }
  
  cout << endl;
  
  cout << "Statistics: Skimmed a total of " << t1->GetEntries() << endl;
  cout << "  Accepted : " << registered << " \t \t i.e. " << 100.0 * (float)(tb->GetEntries())/NEvents << " % )" << endl;
  cout << "  Rejected : " << NEvents-registered << " \t \t i.e. " << 100.0 * (float)(NEvents-tb->GetEntries())/NEvents << " % )" << endl;
  
  tb->AutoSave();
//  tb->OptimizeBaskets();

    
  fb->cd();
  weight_histo->Write();
  if(info) info->Write();
  fb->Close();
    
  f1->Close();
  
  return 0;
}
コード例 #24
0
ファイル: skims.C プロジェクト: jhugon/UfHMuMuCode
// default is Drell-Yan MC with minimal cuts
void skims(int dataset = 0,
           int whichSkims = 1) {

  if      ( whichSkims == 0 ) std::cout << " \n*** MERGING ALL THE FILES ***\n\n";
  else if ( whichSkims == 1 ) std::cout << " \n*** APPLYING MINIMAL CUTS ***\n\n";
  else if ( whichSkims == 2 ) std::cout << " \n*** APPLYING TIGHT CUTS, BUT ACCEPTANCE AND TRIGGER SELECTIONS ***\n\n";
  else {
    std::cout << "NO SKIMS TYPE DEFINED!\n";
    return;
  }


  TChain* tree = new TChain("tree");

  // ======== Monte Carlo ==========
  if ( dataset == 0 ) {
    std::cout << "DYJetsToLL_M50 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDYJetsToLL
    #include "scripts/htomm/skims/V00-01-10/chainDYJetsToLL"
  }
  
  else if ( dataset == 1 ) {
    std::cout << "DYToMuMu DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYToMuMu_M-20_CT10_TuneZ2star_v2_8TeV-powheg-pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYToMuMu_M-20_CT10_TuneZ2star_v2_8TeV-powheg-pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDYToMuMu
    #include "scripts/htomm/skims/V00-01-10/chainDYToMuMu"
  }
  
  else if ( dataset == 2 ) {
    std::cout << "TTJets DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCTTJets_MassiveBinDECAY_TuneZ2star_8TeV-madgraph-tauola_Summer12_DR53X-PU_S10_START53_V7C-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCTTJets_MassiveBinDECAY_TuneZ2star_8TeV-madgraph-tauola_Summer12_DR53X-PU_S10_START53_V7C-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainTTJets
    #include "scripts/htomm/skims/V00-01-10/chainTTJets"
  }

  else if ( dataset == 3 ) {
    std::cout << "DYToTauTau DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYToTauTau_M-20_CT10_TuneZ2star_8TeV-powheg-pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYToTauTau_M-20_CT10_TuneZ2star_8TeV-powheg-pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDYToTauTau
    #include "scripts/htomm/skims/V00-01-10/chainDYToTauTau"
  }

  else if ( dataset == 4 ) {
    std::cout << "WJetsToLNu DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCWJetsToLNu_TuneZ2Star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCWJetsToLNu_TuneZ2Star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainWJetsToLNu
    #include "scripts/htomm/skims/V00-01-10/chainWJetsToLNu"
  }

  else if ( dataset == 5 ) {
    std::cout << "WW DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCWW_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCWW_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainWW
    #include "scripts/htomm/skims/V00-01-10/chainWW"
  }

  else if ( dataset == 6 ) {
    std::cout << "WZ DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCWZ_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCWZ_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainWZ
    #include "scripts/htomm/skims/V00-01-10/chainWZ"
  }

  else if ( dataset == 7 ) {
    std::cout << "ZZ DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCZZ_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCZZ_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainZZ
    #include "scripts/htomm/skims/V00-01-10/chainZZ"
  }

  else if ( dataset == 8 ) {
    std::cout << "QCD DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCQCD_Pt_20_MuEnrichedPt_15_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v3/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCQCD_Pt_20_MuEnrichedPt_15_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v3/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainQCD_Pt_20_MuEnrichedPt_15
    #include "scripts/htomm/skims/V00-01-10/chainQCD_Pt_20_MuEnrichedPt_15"
  }
  else if ( dataset == 9 ) {
    std::cout << "DY2JetsToLL_M50 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDY2JetsToLL_M-50_TuneZ2Star_8TeV-madgraph_Summer12_DR53X-PU_S10_START53_V7A-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDY2JetsToLL_M-50_TuneZ2Star_8TeV-madgraph_Summer12_DR53X-PU_S10_START53_V7A-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDY2JetsToLL
    #include "scripts/htomm/skims/V00-01-10/chainDY2JetsToLL"
  }


  // ======== Special Monte Carlo =========
  else if ( dataset == 9990 ) {
    std::cout << "DYJetsToLL_PtZ-50To70 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYJetsToLL_PtZ-50To70_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYJetsToLL_PtZ-50To70_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDYJetsToLL_PtZ-50To70
    #include "scripts/htomm/skims/V00-01-10/chainDYJetsToLL_PtZ-50To70"
  }

  else if ( dataset == 9991 ) {
    std::cout << "DYJetsToLL_PtZ-70To100 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYJetsToLL_PtZ-70To100_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYJetsToLL_PtZ-70To100_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDYJetsToLL_PtZ-70To100
    #include "scripts/htomm/skims/V00-01-10/chainDYJetsToLL_PtZ-70To100"
  }

  else if ( dataset == 9992 ) {
    std::cout << "DYJetsToLL_PtZ-100 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYJetsToLL_PtZ-100_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesMCDYJetsToLL_PtZ-100_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDYJetsToLL_PtZ-100
    #include "scripts/htomm/skims/V00-01-10/chainDYJetsToLL_PtZ-100"
  }



  // ======== Data ==========
  // Single Muon Dataset
  else if ( dataset == 10 ) {
    std::cout << "SingleMu 2012A-13Jul2012-v1 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012A-13Jul2012-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012A-13Jul2012-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainSingleMuRun2012A-13Jul2012-v1
    #include "scripts/htomm/skims/V00-01-10/chainSingleMuRun2012A-13Jul2012-v1"
  }

  else if ( dataset == 11 ) {
    std::cout << "SingleMu 2012A-recover-06Aug2012-v1 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012A-recover-06Aug2012-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012A-recover-06Aug2012-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainSingleMuRun2012A-recover-06Aug2012-v1
    #include "scripts/htomm/skims/V00-01-10/chainSingleMuRun2012A-recover-06Aug2012-v1"
  }

  else if ( dataset == 12 ) {
    std::cout << "SingleMu 2012B-13Jul2012-v1 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012B-13Jul2012-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012B-13Jul2012-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainSingleMuRun2012B-13Jul2012-v1
    #include "scripts/htomm/skims/V00-01-10/chainSingleMuRun2012B-13Jul2012-v1"
  }

  else if ( dataset == 13 ) {
    std::cout << "SingleMu 2012C-24Aug2012-v1 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012C-24Aug2012-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012C-24Aug2012-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainSingleMuRun2012C-24Aug2012-v1
    #include "scripts/htomm/skims/V00-01-10/chainSingleMuRun2012C-24Aug2012-v1"
  }

  else if ( dataset == 14 ) {
    std::cout << "SingleMu 2012C-PromptReco-v2 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012C-PromptReco-v2/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012C-PromptReco-v2/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainSingleMuRun2012C-PromptReco-v2
    #include "scripts/htomm/skims/V00-01-10/chainSingleMuRun2012C-PromptReco-v2"
  }

  else if ( dataset == 15 ) {
    std::cout << "SingleMu 2012D-PromptReco-v1 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012D-PromptReco-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataSingleMuRun2012D-PromptReco-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainSingleMuRun2012D-PromptReco-v1
    #include "scripts/htomm/skims/V00-01-10/chainSingleMuRun2012D-PromptReco-v1"
  }


  // Double Muon Dataset
  else if ( dataset == 20 ) {
    std::cout << "DoubleMu 2012A-13Jul2012-v1 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataDoubleMuRun2012A-13Jul2012-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataDoubleMuRun2012A-13Jul2012-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDoubleMuRun2012A-13Jul2012-v1
    #include "scripts/htomm/skims/V00-01-10/chainDoubleMuRun2012A-13Jul2012-v1"
  }

  else if ( dataset == 21 ) {
    std::cout << "DoubleMu 2012B-13Jul2012-v4 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataDoubleMuRun2012B-13Jul2012-v4/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataDoubleMuRun2012B-13Jul2012-v4/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDoubleMuRun2012B-13Jul2012-v4
    #include "scripts/htomm/skims/V00-01-10/chainDoubleMuRun2012B-13Jul2012-v4"
  }

  else if ( dataset == 22 ) {
    std::cout << "DoubleMu 2012C-24Aug2012-v1 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataDoubleMuRun2012C-24Aug2012-v1/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataDoubleMuRun2012C-24Aug2012-v1/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDoubleMuRun2012C-24Aug2012-v1
    #include "scripts/htomm/skims/V00-01-10/chainDoubleMuRun2012C-24Aug2012-v1"
  }

  else if ( dataset == 23 ) {
    std::cout << "DoubleMu 2012C-PromptReco-v2 DATASET\n";
    //ls /data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataDoubleMuRun2012C-PromptReco-v2/ | grep root | awk '{print "tree->AddFile(\"/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/NtuplesDataDoubleMuRun2012C-PromptReco-v2/"$1"\");"}' >> scripts/htomm/skims/V00-01-10/chainDoubleMuRun2012C-PromptReco-v2
    #include "scripts/htomm/skims/V00-01-10/chainDoubleMuRun2012C-PromptReco-v2"
  }

  else {
    std::cout << "NO DATASET DEFINED!\n";
    return;
  }


  // ======== DEFINE THE FILENAME ========
  TString path = "/data/uftrig01b/digiovan/root/higgs/CMSSW_5_3_5/V00-01-10/";

  TFile *newfile;

  if      ( dataset == 0 ) path+= "NtuplesMCDYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v1/";
  else if ( dataset == 1 ) path+= "NtuplesMCDYToMuMu_M-20_CT10_TuneZ2star_v2_8TeV-powheg-pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1/";
  else if ( dataset == 2 ) path+= "NtuplesMCTTJets_MassiveBinDECAY_TuneZ2star_8TeV-madgraph-tauola_Summer12_DR53X-PU_S10_START53_V7C-v1/";
  else if ( dataset == 3 ) path+= "NtuplesMCDYToTauTau_M-20_CT10_TuneZ2star_8TeV-powheg-pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1/";
  else if ( dataset == 4 ) path+= "NtuplesMCWJetsToLNu_TuneZ2Star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/";
  else if ( dataset == 5 ) path+= "NtuplesMCWW_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/";
  else if ( dataset == 6 ) path+= "NtuplesMCWZ_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/";
  else if ( dataset == 7 ) path+= "NtuplesMCZZ_TuneZ2star_8TeV_pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1/";
  else if ( dataset == 8 ) path+= "NtuplesMCQCD_Pt_20_MuEnrichedPt_15_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v3/";
  else if ( dataset == 9 ) path+= "NtuplesMCDY2JetsToLL_M-50_TuneZ2Star_8TeV-madgraph_Summer12_DR53X-PU_S10_START53_V7A-v1/";

  else if ( dataset == 9990 ) path+="NtuplesMCDYJetsToLL_PtZ-50To70_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v1/";
  else if ( dataset == 9990 ) path+="NtuplesMCDYJetsToLL_PtZ-70To100_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/";
  else if ( dataset == 9992 ) path+="NtuplesMCDYJetsToLL_PtZ-100_TuneZ2star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v2/";

  else if ( dataset == 10 ) path+="NtuplesDataSingleMuRun2012A-13Jul2012-v1/";
  else if ( dataset == 11 ) path+="NtuplesDataSingleMuRun2012A-recover-06Aug2012-v1/";
  else if ( dataset == 12 ) path+="NtuplesDataSingleMuRun2012B-13Jul2012-v1/";
  else if ( dataset == 13 ) path+="NtuplesDataSingleMuRun2012C-24Aug2012-v1/";
  else if ( dataset == 14 ) path+="NtuplesDataSingleMuRun2012C-PromptReco-v2/";
  else if ( dataset == 15 ) path+="NtuplesDataSingleMuRun2012D-PromptReco-v1/";
                                 
  else if ( dataset == 20 ) path+="NtuplesDataDoubleMuRun2012A-13Jul2012-v1/";
  else if ( dataset == 21 ) path+="NtuplesDataDoubleMuRun2012B-13Jul2012-v4/";
  else if ( dataset == 22 ) path+="NtuplesDataDoubleMuRun2012C-24Aug2012-v1/";
  else if ( dataset == 23 ) path+="NtuplesDataDoubleMuRun2012C-PromptReco-v2/";

  else {
    std::cout << "NO DATASET DEFINED!\n";
    return;
  }



  if      (whichSkims == 0) path += "merged/";
  else if (whichSkims == 1) path += "minimal/";
  else if (whichSkims == 2) path += "complete/";
  else {
    std::cout << "NO SKIMS TYPE DEFINED!\n";
    return;
  }



  if      ( dataset == 0 ) path += "DYJetsToLL_";
  else if ( dataset == 1 ) path += "DYToMuMu_";
  else if ( dataset == 2 ) path += "TTJets_";
  else if ( dataset == 3 ) path += "DYToTauTau_";
  else if ( dataset == 4 ) path += "WJetsToLNu_";
  else if ( dataset == 5 ) path += "WW_";
  else if ( dataset == 6 ) path += "WZ_";
  else if ( dataset == 7 ) path += "ZZ_";
  else if ( dataset == 8 ) path += "QCD_Pt_20_MuEnrichedPt_15_";
  else if ( dataset == 9 ) path += "DY2JetsToLL_";


  else if ( dataset == 9990 ) path += "DYJetsToLL_PtZ-50To70_";
  else if ( dataset == 9990 ) path += "DYJetsToLL_PtZ-70To100_";
  else if ( dataset == 9992 ) path += "DYJetsToLL_PtZ-100_";


  else if ( dataset == 10 ) path += "SingleMuRun2012A-13Jul2012-v1_";
  else if ( dataset == 11 ) path += "SingleMuRun2012A-recover-06Aug2012-v1_";
  else if ( dataset == 12 ) path += "SingleMuRun2012B-13Jul2012-v1_";
  else if ( dataset == 13 ) path += "SingleMuRun2012C-24Aug2012-v1_";
  else if ( dataset == 14 ) path += "SingleMuRun2012C-PromptReco-v2_";
  else if ( dataset == 15 ) path += "SingleMuRun2012D-PromptReco-v1_";


  else if ( dataset == 20 ) path += "DoubleMuRun2012A-13Jul2012-v1_";
  else if ( dataset == 21 ) path += "DoubleMuRun2012B-13Jul2012-v4_";
  else if ( dataset == 22 ) path += "DoubleMuRun2012C-24Aug2012-v1_";
  else if ( dataset == 23 ) path += "DoubleMuRun2012C-PromptReco-v2_";

  else {
    std::cout << "NO DATASET DEFINED!\n";
    return;
  }


  if      (whichSkims == 0) newfile = new TFile(path+"merged.root","recreate");
  else if (whichSkims == 1) newfile = new TFile(path+"minimal.root","recreate");
  else if (whichSkims == 2) newfile = new TFile(path+"complete.root","recreate");
  else {
    std::cout << "NO SKIMS TYPE DEFINED!\n";
    return;
  }


  std::cout << "saving in file " << newfile -> GetName() << std::endl;
  TTree *newtree = tree->CloneTree(0);


  // ======== GET THE HANDLES FOR SKIMMING ========
  float recoCandMass;
  tree->SetBranchAddress("recoCandMass", &recoCandMass);

  float vertexNormChiSquare, angleDiMuons;

  tree->SetBranchAddress("vertexNormChiSquare", &vertexNormChiSquare);
  tree->SetBranchAddress("angleDiMuons"       , &angleDiMuons );
  
  _MuonInfo reco1, reco2;
  
  tree->SetBranchAddress("reco1", &reco1);
  tree->SetBranchAddress("reco2", &reco2);


  // ======== PERFORM THE SKIMMING ========
  cout<<"Loop over the " << tree->GetEntries() << " entries ...\n";
  for (int iEvt=0; iEvt < tree->GetEntries(); iEvt++) {
    
    if ( (iEvt % 500000)==0 ) cout << "event " << iEvt << endl;
    tree -> GetEntry(iEvt);

    // additional selection cuts
    if (recoCandMass <  60 && whichSkims > 0) continue;
    //if (recoCandMass > 160 && whichSkims > 0) continue;
    if (vertexNormChiSquare > 10 && whichSkims > 0) continue; 
    if (angleDiMuons > TMath::Pi()-0.02 && whichSkims > 0) continue;

    if (!isKinTight_2012_noAcc(reco1) && whichSkims > 1) continue;
    if (!isKinTight_2012_noAcc(reco2) && whichSkims > 1) continue;

    newtree->Fill(); 
  }

  newtree->Print();
  newtree->AutoSave();
  
  std::cout << "new tree has " << newtree -> GetEntries() << std::endl;
  delete newfile;
}
コード例 #25
0
ファイル: makeReducedTrees_P.C プロジェクト: dcraik/lhcb
void makeReducedTrees_P(Int_t bin) {

	TString binStr; binStr+=bin;
	Double_t minQ(0.), maxQ(0.);

	switch(bin) {
	case 0:
		minQ = TMath::Sqrt(0.1e6);
		maxQ = TMath::Sqrt(0.98e6);
		break;
	case 1:
		minQ = TMath::Sqrt(1.1e6);
		maxQ = TMath::Sqrt(2.e6);
		break;
	case 2:
		minQ = TMath::Sqrt(2.e6);
		maxQ = TMath::Sqrt(3.e6);
		break;
	case 3:
		minQ = TMath::Sqrt(3.e6);
		maxQ = TMath::Sqrt(4.e6);
		break;
	case 4:
		minQ = TMath::Sqrt(4.e6);
		maxQ = TMath::Sqrt(5.e6);
		break;
	case 5:
		minQ = TMath::Sqrt(5.e6);
		maxQ = TMath::Sqrt(6.e6);
		break;
	case 6:
		minQ = TMath::Sqrt(6.e6);
		maxQ = TMath::Sqrt(7.e6);
		break;
	case 7:
		minQ = TMath::Sqrt(7.e6);
		maxQ = TMath::Sqrt(8.e6);
		break;
	case 8:
		minQ = TMath::Sqrt(11.e6);
		maxQ = TMath::Sqrt(11.75e6);
		break;
	case 9:
		minQ = TMath::Sqrt(11.75e6);
		maxQ = TMath::Sqrt(12.5e6);
		break;
	case 10:
		minQ = TMath::Sqrt(15.e6);
		maxQ = TMath::Sqrt(16.e6);
		break;
	case 11:
		minQ = TMath::Sqrt(16.e6);
		maxQ = TMath::Sqrt(17.e6);
		break;
	case 12:
		minQ = TMath::Sqrt(17.e6);
		maxQ = TMath::Sqrt(18.e6);
		break;
	case 13:
		minQ = TMath::Sqrt(18.e6);
		maxQ = TMath::Sqrt(19.e6);
		break;
	case 14:
		minQ = TMath::Sqrt(19.e6);
		maxQ = TMath::Sqrt(20.e6);
		break;
	case 15:
		minQ = TMath::Sqrt(20.e6);
		maxQ = TMath::Sqrt(21.e6);
		break;
	case 16:
		minQ = TMath::Sqrt(21.e6);
		maxQ = TMath::Sqrt(22.e6);
		break;
	case 17:
		minQ = TMath::Sqrt(1.1e6);
		maxQ = TMath::Sqrt(6.e6);
		break;
	case 18:
		minQ = TMath::Sqrt(15.e6);
		maxQ = TMath::Sqrt(22.e6);
		break;
	case 19:
		minQ = TMath::Sqrt( 8.e6);
		maxQ = TMath::Sqrt(11.e6);
		break;
	case 20:
		minQ = TMath::Sqrt(12.5e6);
		maxQ = TMath::Sqrt(15.e6);
		break;
	default:
		return;
	}

	TFile * f = TFile::Open("/Home/dcraik/lhcb/rd/Kll/tuples/fromPatrick/Kmm.root");
	TTree * tree = dynamic_cast<TTree*>(f->Get("finalTree_KMuMu"));

	TFile* fs = TFile::Open("fromPatrick/Kmm_Q"+binStr+"_sWeights.root");
	TTree* stree = dynamic_cast<TTree*>(fs->Get("sWeights"));

	TFile* fn = new TFile("fromPatrick/Kmm_Q"+binStr+"_reduced.root","RECREATE");
	TTree* newtree = tree->CloneTree(0);

	TLorentzVector mup_4mom;
	TLorentzVector mum_4mom;
	TLorentzVector Psi_4mom;
	TLorentzVector K_4mom;
	TLorentzVector B_4mom;
	
	TVector3 B_boost;
	TVector3 Psi_boost;
	TVector3 mup_boost;
	TVector3 mum_boost;

	Double_t K_PE(0.),   K_PX(0.),   K_PY(0.),   K_PZ(0.);
	Double_t mup_PE(0.), mup_PX(0.), mup_PY(0.), mup_PZ(0.);
	Double_t mum_PE(0.), mum_PX(0.), mum_PY(0.), mum_PZ(0.);

	Double_t B_M(0.), Psi_M(0.);

	Double_t cosThetaL(0.);

	Double_t sWeight(0.);

	newtree->Branch("cosThetaL"  ,&cosThetaL);
	newtree->Branch("sWeight"     ,&sWeight);

	tree->SetBranchAddress("Bplus_M",  &B_M);
	tree->SetBranchAddress("Jpsi_M",  &Psi_M);

	tree->SetBranchAddress("Kplus_PE",   &K_PE);
	tree->SetBranchAddress("Kplus_PX",   &K_PX);
	tree->SetBranchAddress("Kplus_PY",   &K_PY);
	tree->SetBranchAddress("Kplus_PZ",   &K_PZ);
	tree->SetBranchAddress("muplus_PE",  &mup_PE);
	tree->SetBranchAddress("muplus_PX",  &mup_PX);
	tree->SetBranchAddress("muplus_PY",  &mup_PY);
	tree->SetBranchAddress("muplus_PZ",  &mup_PZ);
	tree->SetBranchAddress("muminus_PE", &mum_PE);
	tree->SetBranchAddress("muminus_PX", &mum_PX);
	tree->SetBranchAddress("muminus_PY", &mum_PY);
	tree->SetBranchAddress("muminus_PZ", &mum_PZ);



	stree->SetBranchAddress("Nsig_sw", &sWeight);

	Int_t i(0), is(0);

	Int_t n = tree->GetEntries();
	Int_t ns = stree->GetEntries();

	while( i<n && is<ns ) {
		if(is % 100 == 0) std::cout << "Entry " << is << " of " << ns << "..." << std::endl;
		do {
			++i;
			if(i==n) {//i cannot iterate past n because is would have already hit ns.
				std::cout << "This was supposed to be impossible. The two trees don't match!" << std::endl;
				std::cout << is << "\t" << ns << std::endl;
				return;
			}
			tree->GetEntry(i);
		} while(B_M<5170 || B_M>5970 || Psi_M<minQ || Psi_M>maxQ);

		++is;
		stree->GetEntry(is);

		//Get 4 momentum of each track
		K_4mom.SetPxPyPzE(   K_PX/1000,   K_PY/1000,   K_PZ/1000,   K_PE/1000);
		mup_4mom.SetPxPyPzE( mup_PX/1000, mup_PY/1000, mup_PZ/1000, mup_PE/1000);
		mum_4mom.SetPxPyPzE( mum_PX/1000, mum_PY/1000, mum_PZ/1000, mum_PE/1000);

		//Make 4 momenta of composites
		Psi_4mom = mup_4mom + mum_4mom;
		B_4mom   = Psi_4mom + K_4mom;

		//boost into B frame
		B_boost = B_4mom.BoostVector();
		Psi_4mom.Boost(-B_boost);
		mup_4mom.Boost(-B_boost);
		
		//Boost into Psi frame
		Psi_boost = Psi_4mom.BoostVector();
		mup_4mom.Boost(-Psi_boost);
		
		//cosThetaL is the angle between the Psi and the mu+ in the Psi rest frame
		mup_boost  = mup_4mom.BoostVector();
		cosThetaL  = Psi_boost.Dot(mup_boost)/(Psi_boost.Mag()*mup_boost.Mag());

		newtree->Fill();
	}
	std::cout << is << "\t" << ns << std::endl;


	newtree->AutoSave();
        fn->Close();
}
コード例 #26
0
int main(int argc, char** argv)
{ 
 
 std::cout << "           " << std::endl;
 std::cout << "           " << std::endl;
 std::cout << "           " << std::endl;
 std::cout << "           |        _)             __ \\          |          " << std::endl;
 std::cout << "           |   _ \\   |  __ \\       |   |   _` |  __|   _` | " << std::endl; 
 std::cout << "       \\   |  (   |  |  |   |      |   |  (   |  |    (   | " << std::endl; 
 std::cout << "      \\___/  \\___/  _| _|  _|     ____/  \\__,_| \\__| \\__,_| " << std::endl; 
 std::cout << "           " << std::endl;                                                            
 std::cout << "           " << std::endl;     
 std::cout << "           " << std::endl;
 std::cout << "           " << std::endl;
 
 char normal[] = { 0x1b, '[', '0', ';', '3', '9', 'm', 0 };
 char black[] = { 0x1b, '[', '0', ';', '3', '0', 'm', 0 };
 char red[] = { 0x1b, '[', '0', ';', '3', '1', 'm', 0 };
 char green[] = { 0x1b, '[', '0', ';', '3', '2', 'm', 0 };
 char yellow[] = { 0x1b, '[', '0', ';', '3', '3', 'm', 0 };
 char blue[] = { 0x1b, '[', '0', ';', '3', '4', 'm', 0 };
 char purple[] = { 0x1b, '[', '0', ';', '3', '5', 'm', 0 };
 char cyan[] = { 0x1b, '[', '0', ';', '3', '6', 'm', 0 };
 char Lgray[] = { 0x1b, '[', '0', ';', '3', '7', 'm', 0 };
 char Dgray[] = { 0x1b, '[', '0', ';', '3', '8', 'm', 0 };
 char Bred[] = { 0x1b, '[', '1', ';', '3', '1', 'm', 0 };
 
 if(argc != 2)
 {
  std::cerr << ">>>>> analysis.cpp::usage: " << argv[0] << " configFileName" << std::endl ;
  return 1;
 }
 
 // Parse the config file                                                                                                                                                          
 parseConfigFile (argv[1]) ;
 
 std::string treeName  = gConfigParser -> readStringOption("Input::treeName");
 std::string fileSamples = gConfigParser -> readStringOption("Input::fileSamples");
 std::string inputDirectory = gConfigParser -> readStringOption("Input::inputDirectory");
 
 std::string inputBeginningFile = "out_NtupleProducer_"; 
 try {
  inputBeginningFile = gConfigParser -> readStringOption("Input::inputBeginningFile");
 }
 catch (char const* exceptionString){
  std::cerr << " exception = " << exceptionString << std::endl;
 }
 std::cout << ">>>>> Input::inputBeginningFile  " << inputBeginningFile  << std::endl;  
 
 
 TTree *treeJetLepVect;
 
 char *nameSample[1000];
 char *nameHumanReadable[1000];
 char* xsectionName[1000];
 
 double Normalization[1000];
 double xsection[1000];
 char nameFileIn[1000];
 sprintf(nameFileIn,"%s",fileSamples.c_str());
 
 int numberOfSamples = ReadFile(nameFileIn, nameSample, nameHumanReadable, xsectionName);
 
 ///==== output file ====
 std::string OutFileName    = gConfigParser -> readStringOption("Output::outFileName");
 std::cout << ">>>>> Output::outFileName  " << OutFileName  << std::endl;  
  
 ///==== debug flag ====
 
 bool  debug = false; 
 try {
  debug = gConfigParser -> readBoolOption("Input::debug");
 }
 catch (char const* exceptionString){
  std::cerr << " exception = " << exceptionString << std::endl;
 }
 std::cout << ">>>>> input::debug  " << debug  << std::endl;  
 
 
 ///==== program ====
 
 //==== remove previous output file 
 TString CommandToExec = Form ("rm %s",OutFileName.c_str());
 std::cout << " CommandToExec = " << CommandToExec.Data() << std::endl;
 gSystem->Exec(CommandToExec);  
 CommandToExec = Form ("rm temp_join_data_file.root");
 std::cout << " CommandToExec = " << CommandToExec.Data() << std::endl;
 gSystem->Exec(CommandToExec);  
 
 //==== add files together
 CommandToExec = Form ("hadd temp_join_data_file.root");
 for (int iSample=0; iSample<numberOfSamples; iSample++){
  char nameFile[20000];
  sprintf(nameFile,"%s/%s%s.root",inputDirectory.c_str(),inputBeginningFile.c_str(),nameSample[iSample]);  
  CommandToExec += " ";
  CommandToExec += nameFile;
  CommandToExec += " ";
 }
 std::cout << " CommandToExec = " << CommandToExec.Data() << std::endl;
 gSystem->Exec(CommandToExec);  
 
 
 TString fakeInputFile = Form ("temp_join_data_file.root");
 TFile* f = new TFile(fakeInputFile.Data(), "READ");  
 treeJetLepVect = (TTree*) f->Get(treeName.c_str());
 
 UInt_t run;
 UInt_t lumi;
 UInt_t event;
 
 treeJetLepVect -> SetBranchAddress("run",  &run);
 treeJetLepVect -> SetBranchAddress("lumi", &lumi);
 treeJetLepVect -> SetBranchAddress("event",&event);
 
 //Create a new file + a clone of old tree in new file
 TFile outFile(OutFileName.c_str(),"RECREATE");
 outFile.cd();
 TTree *newtree = treeJetLepVect -> CloneTree(0);
 
 // define map with events
 std::map<std::pair<uint,std::pair<uint,uint> >,int> eventsMap;  
 
 Long64_t nEvent = treeJetLepVect -> GetEntries();
 
 std::cout << " nEvent = " << nEvent << std::endl;
 std::cout.precision (2) ;
 
 Long64_t counter = 0;
 for (Long64_t iEvent = 0; iEvent<nEvent; iEvent++) {
  treeJetLepVect->GetEntry(iEvent);
  
  std::cout << "Processing: " << blue << (((double) iEvent)/nEvent)*100. << "% \r"  << normal << std::flush;   
  
  std::pair<uint,uint> eventLSandID(lumi, event);
  std::pair<uint,std::pair<uint,uint> > eventRUNandLSandID(run, eventLSandID);   
  if( eventsMap[eventRUNandLSandID] == 1 ) continue;
  else eventsMap[eventRUNandLSandID] = 1;
  
  counter++;
  newtree->Fill();
 }
 newtree->AutoSave();

 //==== remove temporary file
 CommandToExec = Form ("rm temp_join_data_file.root");
 std::cout << " CommandToExec = " << CommandToExec.Data() << std::endl;
 gSystem->Exec(CommandToExec);  
 
 
 std::cout << std::endl;
 std::cout << " counter = " << counter << " / " << nEvent << " = " << (double) counter / nEvent << std::endl;
 std::cout << std::endl;
 std::cout << " **** end **** " << std::endl;
 std::cout << std::endl;
 
}
コード例 #27
0
ファイル: MakeB.C プロジェクト: chernyavskaya/Hbb
void MakeB::Loop()
{
   if (fChain == 0) return;
   Long64_t nentries = fChain->GetEntriesFast();
   Long64_t nbytes = 0, nb = 0;

	TreeJets TreeJet;
	Int_t loopJet_max;
	TFile *output = new TFile("b_likelihood_speedup_04_caterinaidx_b.root","recreate");
	TTree *tree = fChain->CloneTree();
	TBranch *blike_b = tree->Branch("Jet_blikelihood_b",TreeJet.blike_b,"Jet_blikelihood_b[15]/F");
//	TBranch *blike_q = tree->Branch("Jet_blikelihood_q",TreeJet.blike_q,"Jet_blikelihood_q[15]/F");
	TString weightfile_b = "weights/TMVAClassification_BDTG_bjet_04_catidx_b.weights.xml";
//	TString weightfile_q = "weights/TMVAClassification_BDTG_qjet_04_catidx.weights.xml";
   TMVA::Reader *reader_b = new TMVA::Reader("Silent");
	float var1,var2,var3,var4,var5,var6,var7,var8;
//	reader_b->AddVariable("Jet_pt",&var1);
	reader_b->AddVariable("Jet_eta",&var2);
	reader_b->AddVariable("Jet_btagCSV",&var3);
//	reader_b->AddVariable("Jet_pt_idx",&var4);
	reader_b->AddVariable("Jet_eta_idx",&var5);
//	reader_b->AddVariable("Jet_btagCSV_idx",&var6);
   reader_b->AddVariable( "Jet_chMult", &var7 );
   reader_b->AddVariable( "Jet_ptd", &var8 );
	reader_b->BookMVA("BDTG", weightfile_b);	/*
   TMVA::Reader *reader_q = new TMVA::Reader("Silent");
	reader_q->AddVariable("Jet_pt",&var1);
	reader_q->AddVariable("Jet_eta",&var2);
	reader_q->AddVariable("Jet_btagCSV",&var3);
//	reader_q->AddVariable("Jet_pt_idx",&var4);
	reader_q->AddVariable("Jet_eta_idx",&var5);
//	reader_q->AddVariable("Jet_btagCSV_idx",&var6);
	reader_q->BookMVA("BDTG", weightfile_q);	*/

   for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      nb = fChain->GetEntry(jentry);   nbytes += nb;

	   JetList jetList_CSV, jetList_pt, jetList_eta; 


		int loopJet_max;
		if (nJet<6) loopJet_max = nJet; 
		else loopJet_max = 6; 

	   for(int i=0; i<nJet; i++){
		   if(Jet_pt[i]<20 || Jet_id[i] <0) continue; 
			if (Jet_btagCSV[i]==-10) Jet_btagCSV[i]=0; 
		   jetList_CSV[Jet_btagCSV[i]]=i;
		   jetList_pt[Jet_pt[i]]=i;
         jetList_eta[TMath::Abs(Jet_eta[i])]=i;
	   }

		for (int i=0;i<nJet;i++){
			TreeJet.blike_b[i] = -2;
		//	TreeJet.blike_q[i] = -2;
		   TreeJet.pt[i]=Jet_pt[i];
		   TreeJet.eta[i]=Jet_eta[i]; 
		   TreeJet.btagCSV[i]=Jet_btagCSV[i]; 
			TreeJet.ch_mult[i]=Jet_chMult[i];
			TreeJet.ptd[i]=Jet_ptd[i];
		

		   for (JetList::reverse_iterator iJet=jetList_CSV.rbegin(); iJet!=jetList_CSV.rend(); ++iJet){
			   if(iJet->first==Jet_btagCSV[i]) { TreeJet.btagCSV_idx[i] = iJet->second; }
		   } 	
		
		   for (JetList::reverse_iterator iJet=jetList_pt.rbegin(); iJet!=jetList_pt.rend(); ++iJet){
         	if(iJet->first==Jet_pt[i]) { TreeJet.pt_idx[i] = iJet->second; }
         }	

		   for (JetList::reverse_iterator iJet=jetList_eta.rbegin(); iJet!=jetList_eta.rend(); ++iJet){
         	if(iJet->first==TMath::Abs(Jet_eta[i])) { TreeJet.eta_idx[i] = iJet->second; }
         }	

		}




	for (int i=0;i<nJet;i++){
		   if(Jet_pt[i]<20 || Jet_id[i] <0) continue; 
		//	var1 = TreeJet.pt[i];
			var2 = TreeJet.eta[i];
			var3 = TreeJet.btagCSV[i];
		//	var4 = TreeJet.pt_idx[i];
			var5 = TreeJet.eta_idx[i];
		//	var6 = TreeJet.btagCSV_idx[i];
			var7 = TreeJet.ch_mult[i];
			var8 = TreeJet.ptd[i];
			TreeJet.blike_b[i] = reader_b->EvaluateMVA("BDTG");
/*
			var1 = TreeJet.pt[i];
			var2 = TreeJet.eta[i];
			var3 = TreeJet.btagCSV[i];
			var4 = TreeJet.pt_idx[i];
			var5 = TreeJet.eta_idx[i];
			var6 = TreeJet.btagCSV_idx[i];
			TreeJet.blike_q[i] = reader_q->EvaluateMVA("BDTG");*/
	}
	blike_b->Fill();
//	blike_q->Fill();
	}
	delete reader_b;
//	delete reader_q;
	output->cd();
	tree->AutoSave();
	output->Close();
}
コード例 #28
0
ファイル: skimTree1.C プロジェクト: syuvivida/xtozh_common
void skimTree1::Loop()
{
   if (fChain == 0) return;
  std::string remword=".root";
  size_t pos = inputFile_.find(remword);
  std::string forOutput = inputFile_;  
  if(pos!= std::string::npos)
    forOutput.swap(forOutput.erase(pos,remword.length()));   
  std::string endfix = "_filtered.root";
  std::string outputFile = forOutput + endfix;
   // now open new root file
  TFile* newfile_data = new TFile(outputFile.data(),"recreate");

  // clone tree
  TTree* newtree = fChain->CloneTree(0);
  newtree->SetMaxTreeSize(5000000000);
  cout << "Saving "  << outputFile       << " tree" << endl;

  ofstream fout;
  fout.open("wrong.dat");
  Long64_t nentries = fChain->GetEntriesFast();
  Long64_t nPassEvt=0;
  Long64_t nbytes = 0, nb = 0;
  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%100==0)
      printf("%4.1f%% done.\r",(float)jentry/(float)nentries*100.);		

    // require events have CA8jet pt >200

    bool hasCA8jet=false;

    for(int i=0; i < CA8nJet; i++){

	double jet_pt = CA8jetPt->at(i);
      	
	if(jet_pt >200)
	{
		hasCA8jet=true;
		cout<<"ev: "<< jentry << " jet pt: "<<jet_pt<<endl;
		break;
        }


    } // end of loop over ca8 jet




/*
    // require events have two electrons or two muons
    // with mass = 60-120 GeV, pt > 60 GeV

    if(nEle < 2 && nMu < 2)continue;

    bool hasDoubleEle=false;

    for(int i=0; i < nEle; i++){
      
      TLorentzVector i_l4(0,0,0,0);
      i_l4.SetPtEtaPhiM(
			elePt->at(i),
			eleEta->at(i),
			elePhi->at(i),
			eleM->at(i)
			);
      for(int j=0; j< i; j++){
	
	TLorentzVector j_l4(0,0,0,0);
	j_l4.SetPtEtaPhiM(
			  elePt->at(j),
			  eleEta->at(j),
			  elePhi->at(j),
			  eleM->at(j)
			  );
	double Zpt = (i_l4+j_l4).Pt();
	double ZM = (i_l4+j_l4).M();

	if(Zpt > 60 && ZM > 60 && ZM < 120)
	  {
	    hasDoubleEle=true;
	    break;
	  }

      }
    } // end of double loop over electrons

    bool hasDoubleMuo=false;
    for(int i=0; i < nMu; i++){
      
      TLorentzVector i_l4(0,0,0,0);
      i_l4.SetPtEtaPhiM(
			muPt->at(i),
			muEta->at(i),
			muPhi->at(i),
			muM->at(i)
			);
      for(int j=0; j< i; j++){
	
	TLorentzVector j_l4(0,0,0,0);
	j_l4.SetPtEtaPhiM(
			  muPt->at(j),
			  muEta->at(j),
			  muPhi->at(j),
			  muM->at(j)
			  );
	double Zpt = (i_l4+j_l4).Pt();
	double ZM = (i_l4+j_l4).M();

	if(Zpt > 60 && ZM > 60 && ZM < 120)
	  {
	    hasDoubleMuo=true;
	    break;
	  }

      }
    } // end of double loop over double muons

    if(!hasDoubleEle && !hasDoubleMuo)continue;   
*/
    if(!hasCA8jet)continue;
    newtree->Fill();
    nPassEvt++;
  }
  
  // newtree->Print();
  newtree->AutoSave();
  delete newfile_data;
  fout.close();


 cout << "nentries = " << nentries << endl;
 cout << "Number of passed events = " << nPassEvt << endl;
 cout << "Reduction rate = " << (double)nPassEvt/(double)nentries << endl;

}