コード例 #1
0
ファイル: mc2ibd.C プロジェクト: lab305itep/digi
TChain *make_mc_tree(const char *fname = NULL)
{
	int i;
//	const char files[4][256] = {
//		"mc_ibd_235U_transcode_pair.root",
//		"mc_ibd_238U_transcode_pair.root",
//		"mc_ibd_239Pu_transcode_pair.root",
//		"mc_ibd_241Pu_transcode_pair.root"
//	};
	const char files[4][256] = {
		"mc_ibdNewGd_235U_transcode_pair.root",
		"mc_ibdNewGd_238U_transcode_pair.root",
		"mc_ibdNewGd_239Pu_transcode_pair.root",
		"mc_ibdNewGd_241Pu_transcode_pair.root"
	};

	TChain *tMC = new TChain("DanssPair", "DanssPair");
	if (fname != NULL && strcasecmp(fname, "all")) {
		tMC->AddFile(fname);
	} else {
		for (i=0; i<4; i++) tMC->AddFile(files[i]);
	}
	if (!tMC->GetEntries()) return NULL;
	return tMC;
}
コード例 #2
0
ファイル: Run4select.C プロジェクト: jintonic/gerdalinchenII
void pre(Int_t setID)
{
    TChain* pstr = new TChain("PSTree","root");
    if (setID==1) {
        for (Int_t i=1; i<10; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS000%d.root",i));
        for (Int_t i=70; i<85; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    }
    else if (setID==2)
        for (Int_t i=10; i<30; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    else if (setID==3)
        for (Int_t i=30; i<50; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    else if (setID==4)
        for (Int_t i=50; i<70; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile(Form("Run4pre%d.root",setID),"recreate");
    TTree *newtree = pstr->CloneTree(0);

    const Int_t Ncha = 7;

    Int_t Nevt = pstr->GetEntries();
    cout<<"Total Events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"Now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        for (Int_t j=1; j<Ncha-1; j++) {
            if (Cha_MCAEnergy[j]>1000 && Cha_MCAEnergy[j]<7000) {
                Nseg++;
            }
        }
        if (Nseg==1) {
            newtree->Fill();
        }
        if (i%10000==0) newtree->Write();
    }

    newtree->Write();
    foutput->Close();
}
コード例 #3
0
ファイル: Run4select.C プロジェクト: jintonic/gerdalinchenII
void mca()
{
    TChain* pstr = new TChain("PSTree","root");
    pstr->AddFile("Run4selected.root");

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    const Int_t Ncha = 7;
    TH1F *MCA[Ncha];
    MCA[0] = new TH1F("MCA0","MCA Spectrum for the core",3000,1000,7000);
    MCA[1] = new TH1F("MCA1","MCA Spectrum for segment 1",700,3800,5200);
    for (Int_t i=2; i<=3; i++)
        MCA[i] = new TH1F(Form("MCA%d",i),Form("MCA Spectrum for segment %d",i),500,2200,3200);
    for (Int_t i=4; i<=5; i++)
        MCA[i] = new TH1F(Form("MCA%d",i),Form("MCA Spectrum for segment %d",i+12),700,3000,4400);
    MCA[6] = new TH1F("MCA6","MCA Spectrum for segment 18",10000,1000,21000);

    Int_t Nevt = pstr->GetEntries();
    cout<<"Total Events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"Now event: "<<i<<endl;

        pstr->GetEntry(i);

        for (Int_t j=0; j<Ncha; j++)
            MCA[j]->Fill((Float_t) Cha_MCAEnergy[j]);
    }

    TFile* foutput = new TFile("Run4mca.root","recreate");
    for (Int_t i=0; i<Ncha; i++) MCA[i]->Write();
    foutput->Close();
}
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/TauIsoUpgrade/WH_ZH_HToMuMu_M-125_13TeV_PU40bx25_2/tree_1_1_EUG.root");
chain->AddFile("/lustre/cms/store/user/rosma/TauIsoUpgrade/WH_ZH_HToMuMu_M-125_13TeV_PU40bx25_2/tree_12_1_axt.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/WH_PU40CMS2012_ProvaAnalisi/histo_file_WH_PU40CMS2012_ProvaAnalisi0.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #5
0
ファイル: Run4select.C プロジェクト: jintonic/gerdalinchenII
void morestrict()
{
    const Int_t Ncha = 6;

    Float_t N[Ncha]  = {0};
    Float_t dN[Ncha] = {0};

    Float_t ADC[Ncha]  = {0};
    Float_t dADC[Ncha] = {0};

    Float_t ADCw[Ncha]  = {0};
    Float_t dADCw[Ncha] = {0};

    ifstream dat;
    dat.open("Run4Nseg.txt");
    cout<<"channel \t ADC \t dADC \t ADCw \t dADCw \t N \t dN"<<endl;
    for (Int_t i=1; i<Ncha; i++) {
        dat>>ADC[i]>>dADC[i]>>ADCw[i]>>dADCw[i]>>N[i]>>dN[i];
        cout<<i<<" \t "<<ADC[i]<<" \t "<<dADC[i]<<" \t "
            <<ADCw[i]<<" \t "<<dADCw[i]<<" \t "
            <<N[i]<<" \t "<<dN[i]<<endl;
    }
    dat.close();

    TChain* pstr = new TChain("pstree","root");
    pstr->AddFile("Run4selected.root");

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile("Run4smaller.root","recreate");
    TTree *newtree = pstr->CloneTree(0);

    Int_t Nevt = pstr->GetEntries();
    cout<<"total events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        for (Int_t j=1; j<Ncha; j++) {
            if (Cha_MCAEnergy[j]>ADC[j]-ADCw[j] &&
                    Cha_MCAEnergy[j]<ADC[j]+ADCw[j]) {
                Nseg++;
            }
        }

        if (Nseg==1) {
            newtree->Fill();
        }
    }

    newtree->Write();
    foutput->Close();
}
コード例 #6
0
void runTree(char* dir="hist_pAu2", char* filter="16142010", unsigned int neventsIn = 0){  
  // If nEvents is negative, reset to the maximum possible value for an Int_t
  if( neventsIn <= 0 ) neventsIn = 1<<31-1;

  TSystemDirectory DIR(dir, dir);
  TList *files = DIR.GetListOfFiles();
  TChain* trees = new TChain();
  int nfile=0;
  if (files) {
      TSystemFile *file;
      TString fname;
      TIter next(files);
      while ((file=(TSystemFile*)next())) {
	  fname = file->GetName();
	  if (!file->IsDirectory() && fname.BeginsWith(filter) && fname.EndsWith("tree.root")) {
	      cout << Form("Adding %s/%s to TChain",dir,fname.Data())<<endl;
	      trees->AddFile(Form("%s/%s/dipi0",dir,fname.Data()));
	      nfile++;
	  }
      }
  }
  cout << Form("%d files added",nfile) << endl;

  // load the shared libraries
  std::cout << "***** Loading libraries *****" << endl;
  LoadLibs();

  // Create the analysis chain
  analysisChain = new StChain("dipi0Chain");
  
  //cout << "Constructing StFmsDbMaker" << endl;
  //StFmsDbMaker* fmsDbMkr = new StFmsDbMaker( "fmsDb" );
  //fmsDbMkrName = fgtDbMkr->GetName();

  gSystem->Load("StFmsDiPi0");
  StFmsDiPi0* dipi0=new StFmsDiPi0;
  TString filenameDiPi0(Form("%s/%s.dipi0.root",dir,filter));
  cout << "DiPi0 outfile name = " << filenameDiPi0.Data()<<endl;
  dipi0->setFileName(filenameDiPi0.Data());
  dipi0->setReadTree(trees);

  analysisChain->Init();

  Int_t ierr  = kStOK;  // err flag
  Int_t nevents = 0;    // cumulative number of events in
  for( ; nevents < neventsIn && !ierr; ++nevents ){
    if(nevents%10000==0) cout <<"event: "<< nevents <<endl;
    analysisChain->Clear();
    ierr = analysisChain->Make();
  } 
  analysisChain->Finish(); 

  analysisChain->Delete();
  return;
};
コード例 #7
0
ファイル: runmergeWithDir.C プロジェクト: xvallspl/roottest
void runmergeWithDir()
#endif
{
  TChain *tph;
   tph = new TChain("CBNT/t3333");
   tph->AddFile("file1.root");
   tph->AddFile("file2.root");
   tph->Merge("merged.root");
   TFile *fil = new TFile("merged.root");
   fil->ls();
}
コード例 #8
0
ファイル: runGloAlgTask.C プロジェクト: shahor02/align
//________________________________________________________________________________
TChain* CreateChainTXT(const char* inpData)
{
  const char* chName="esdTree";
  TChain* chain = new TChain(chName);
  //
  TString inpDtStr = inpData;
  if (inpDtStr.EndsWith(".root")) {
    chain->AddFile(inpData);
  }
  else {
    //
    ifstream inpf(inpData);
    if (!inpf.good()) {
      printf("Failed on input filename %s\n",inpData);
      return kFALSE;
    }
    //
    TString flName;
    flName.ReadLine(inpf);
    while ( !flName.IsNull() ) {
      flName = flName.Strip(TString::kBoth,' ');
      if (flName.BeginsWith("//") || flName.BeginsWith("#")) {flName.ReadLine(inpf); continue;}
      flName = flName.Strip(TString::kBoth,',');
      flName = flName.Strip(TString::kBoth,'"');
      if (flName.EndsWith("Barrel.root")) barrelFlag = kTRUE;
      printf("Adding %s\n",flName.Data());
      chain->AddFile(flName.Data());
      flName.ReadLine(inpf);
    }
  }
  //
  int n = chain->GetEntries();
  if (n<1) {
    printf("Obtained chain is empty\n");
    return kFALSE;
  }
  printf("Created chain with %d entries in %d trees from %s\n",chain->GetEntries(),chain->GetNtrees(),inpData);
  return chain;
}
コード例 #9
0
ファイル: runLocal.C プロジェクト: bartbutler/ProofAna
void runLocal(TString dataset, TString treename = "", Long64_t nentries=TChain::kBigNumber,  Long64_t firstentry = 0)
{
	ProofAna* ana = new ProofAna();

	//Need to provide a TList for local running
	TList* list = new TList();
	ana->SetInputList(list);

	// Load dataset manager stuff, uses same local datasets as PROOF-Lite by design
	TString defaultdir(gSystem->HomeDirectory());
	defaultdir.Append("/.proof");
	TString dsetdir(gEnv->GetValue("ProofLite.Sandbox",defaultdir.Data()));
	dsetdir.Append("/datasets");
	dsetdir.Prepend("dir:");
	TDataSetManagerFile mgr(dsetdir);

	TString dsetfile(dataset);
	dsetfile.Append(".txt");
	dsetfile.Prepend("../filelists/");

	//Register dataset, if non-existent
	if(!mgr.ExistsDataSet(dataset)) {
		TFileCollection* dset = new TFileCollection(dataset,"",dsetfile);
		mgr.RegisterDataSet(dataset,dset,"V"); //This seems to return true regardless of success or failure at the moment
		if(treename.CompareTo("")!=0) {
			cout << "Setting default tree to " << treename << " (local and lite running)" << endl;
			TProof* lite = TProof::Open("lite://");
			if(lite->SetDataSetTreeName(dataset,treename)) {
				cout << "Failure to set default tree to " << treename << endl;
				return;
			}
			delete lite;
		}
	}
	mgr.ShowDataSets();

	// And yes, all this dataset garbage was to get the default tree name
	TFileCollection* dset = mgr.GetDataSet(dataset);
	TString defaultTree = dset->GetDefaultTreeName();

	// Make TChain from TFileCollection...doesn't seem like there is a more direct way
	if(defaultTree.First("/")==0) defaultTree.Remove(0,1);
	TChain* T = new TChain(defaultTree);
	TList* filelist = (TList*)dset->GetList();
	TIter next(filelist);
	TFileInfo* fileinfo = 0;
	while ((fileinfo = (TFileInfo*)next())) T->AddFile(fileinfo->GetCurrentUrl()->GetUrl());

	// Process TChain
	T->Process(ana,"", nentries, firstentry);
}
コード例 #10
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1073_2_vbl.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1075_2_M4c.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1078_2_lm2.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1079_1_uox.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1080_2_fAf.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1084_2_XeU.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1085_2_lv8.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1087_2_wo7.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1088_1_Ff7.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1089_2_Et5.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM20195.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #11
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1177_1_8v6.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1178_2_hvi.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1179_2_CIL.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1181_1_mqV.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1186_2_jkD.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1191_1_p4C.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1192_2_JQA.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1193_2_2N2.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1194_2_2Ut.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1196_2_q5B.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201912.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #12
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1477_1_QCo.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1478_1_E8A.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1479_2_Yxv.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1480_2_vtK.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1481_1_jTa.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1482_1_UTI.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1483_1_uiq.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1485_2_HWH.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1486_1_13V.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1487_2_lrE.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201933.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #13
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1507_2_DYM.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1508_2_Oeq.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1511_2_gkS.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1512_2_Axw.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1513_2_TVd.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1514_2_hsu.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1516_2_pgs.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1517_2_Ygg.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1518_2_q94.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1521_1_fvd.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201935.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #14
0
ファイル: Run4select.C プロジェクト: jintonic/gerdalinchenII
void again()
{
    TChain* pstr = new TChain("PSTree","root");
    for (Int_t i=1; i<5; i++) pstr->AddFile(Form("Run4pre%d.root",i));

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile("Run4selected.root","recreate");
    TTree *newtree = pstr->CloneTree(0);

    Int_t Nevt = pstr->GetEntries();
    cout<<"Total Events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"Now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        if (Cha_MCAEnergy[1]>3800 && Cha_MCAEnergy[1]<5200) {
            Nseg++;
        }
        for (Int_t j=2; j<=3; j++) {
            if (Cha_MCAEnergy[j]>2200 && Cha_MCAEnergy[j]<3200) {
                Nseg++;
            }
        }
        for (Int_t j=4; j<=5; j++) {
            if (Cha_MCAEnergy[j]>3000 && Cha_MCAEnergy[j]<4400) {
                Nseg++;
            }
        }

        if (Nseg==1) {
            newtree->Fill();
        }
    }

    newtree->Write();
    foutput->Close();

}
コード例 #15
0
 TChain *get_chain(char *tree_name)
 {
   if (chains.find(tree_name) == chains.end())
   {
     TChain *chain = new TChain(tree_name);
     if (!chain)
     {
       return NULL;
     }
     for (vector<string>::iterator it = files.begin();
          it != files.end(); it++)
     {
       if (!chain->AddFile(it->c_str()))
       {
         delete chain;
         return NULL;
       }
     }
     chains[tree_name] = chain;
   }
   return chains[tree_name];
 }
コード例 #16
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1451_2_cYH.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1452_1_vb0.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_145_2_PDO.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1453_1_WtA.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1454_2_ckU.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1457_2_EPT.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1458_2_jqJ.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1460_1_PKj.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1461_1_w2W.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1462_2_MCq.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201931.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #17
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_629_2_cja.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_630_2_mvf.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_632_1_2Do.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_634_1_rda.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_638_2_0Nt.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_641_1_NHJ.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_642_1_sSd.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_64_2_fF3.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_646_1_acn.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_647_1_P7y.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201963.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #18
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1369_2_eR9.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1370_1_ygN.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1372_1_wlo.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_137_2_bBS.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1373_1_p4P.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1374_2_0wl.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1375_2_jfx.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1376_2_mgC.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1377_2_4He.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1378_2_NU1.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201925.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #19
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_522_2_K6A.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_529_2_iiR.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_5_2_CNa.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_533_2_ck7.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_536_2_idk.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_537_2_ArA.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_540_1_Rq3.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_542_2_WF0.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_543_2_s2p.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_549_2_8LQ.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201959.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #20
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_464_2_Epu.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_465_2_ky8.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_468_2_abU.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_469_2_oB9.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_471_2_1dT.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_47_1_V5I.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_472_1_gYm.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_473_2_Ttb.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_475_2_D9s.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_478_2_a2Q.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201956.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #21
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1210_1_IRg.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1211_2_77m.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1212_2_TGi.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_121_2_Wwx.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1213_1_9sU.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1214_2_Qb7.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1215_1_CzK.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1217_2_p2p.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1222_2_wfC.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1225_2_sfJ.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201914.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #22
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_291_2_vFG.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_292_2_0gb.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_29_2_JWy.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_293_1_Nkt.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_294_2_cil.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_295_2_3ZH.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_296_2_VBU.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_300_2_njW.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_301_2_Ktv.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_304_1_yJ2.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201947.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #23
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1027_2_Jd1.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1028_1_MSj.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1030_2_3ns.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1031_2_Y5R.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1032_2_SHr.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_103_2_T5M.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1034_1_zEl.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1035_1_KvP.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1036_2_7s5.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_1037_2_XSE.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM20192.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #24
0
int main() {
   TChain* chain = new TChain("treeCreator/vhtree");
   //WH
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_723_2_TMF.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_724_2_1OJ.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_725_2_rlb.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_726_2_EEm.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_727_2_QfK.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_7_2_9BA.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_735_2_jTt.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_736_2_OlI.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_738_2_b0k.root");
chain->AddFile("/lustre/cms/store/user/rosma/SamplePh2/QCD_Pt-15to3000_Tune4C_Flat_14TeV_GEM2019Upg14DR-PU50bx25/tree_743_2_xJQ.root");
std::string histo_fname ="/lustre/cms/store/user/rvenditti/PostLS2/FullSim/AnalisiGEM/QCDPU50GEM2019/histo_file_QCDPU50GEM201968.root";
  VHAnalyser_Jan13* myanal = new VHAnalyser_Jan13(chain, histo_fname);
  myanal->bookHistograms();
  myanal->Loop();
  myanal->saveHistograms();
  //file->Close();
//  delete chain;
//  delete myanal;
gSystem->Exit(0);
return 0;
}
コード例 #25
0
ファイル: Imp_PID2.C プロジェクト: jtscheuschner/riken
void Improve_PID2(Char_t* path, Char_t* filename, short aoq, short var=0,
		  Float_t A_Lin = 0, Float_t A_Squ = 0,
		  Float_t X_Lin = 0, Float_t X_Squ = 0,
		  Float_t Y_Lin = 0, Float_t Y_Squ = 0,
		  Float_t D_Lin = 0, Float_t D_Squ = 0,

		  Float_t A_Lin1 = 0, Float_t A_Squ1 = 0,
		  Float_t X_Lin1 = 0, Float_t X_Squ1 = 0,
		  Float_t Y_Lin1 = 0, Float_t Y_Squ1 = 0,
		  Float_t D_Lin1 = 0, Float_t D_Squ1 = 0,

		  Float_t B_Lin = 0, Float_t B_Squ = 0
){



  TChain* tree = new TChain("tree");
  std::cout<< Form("%s%s",path,filename) <<std::endl;
  tree->AddFile(Form("%s%s",path,filename));


  short beta_;
  vector<Char_t*> names;
  names = vector<Char_t*> (9);
  Float_t corr[2][9] = { {A_Lin, X_Lin, Y_Lin,D_Lin, A_Lin1, X_Lin1, Y_Lin1, D_Lin, B_Lin},
		      {A_Squ, X_Squ, Y_Squ,D_Squ, A_Squ1, X_Squ1, Y_Squ1, D_Squ, B_Squ} };
  Float_t plane_[2], delta_[2];


  if(aoq == 0){
    names[0]="FA[0]",  names[1]="FX[0]",  names[2]="FY[0]",  names[3]="delta[0]";//First detector
    names[4]="FA[1]",  names[5]="FX[1]",  names[6]="FY[1]",  names[7]="delta[1]";//Second detector
    names[8]="BETA[0]";                                                       //Beta before ([0]) or after ([1]) the target
    beta_ = 0;
    plane_[0] = 0;
    plane_[1] = 1;
    delta_[0] = 0;
    delta_[1] = 1;
  }else if(aoq == 2){
    names[0]="FA[4]",  names[1]="FX[4]",  names[2]="FY[4]",  names[3]="delta[2]";//First detector
    names[4]="FA[5]",  names[5]="FX[5]",  names[6]="FY[5]",  names[7]="delta[4]";//Second detector
    names[8]="BETA[1]";                                                       //Beta before ([0]) or afte
    beta_ = 0;
    plane_[0] = 4;
    plane_[1] = 5;
    delta_[0] = 2;
    delta_[1] = 4;
  }else if(aoq == 5){
    names[0]="FA[3]",  names[1]="FX[3]",  names[2]="FY[3]",  names[3]="delta[2]";//First detector
    names[4]="FA[5]",  names[5]="FX[5]",  names[6]="FY[5]",  names[7]="delta[4]";//Second detector
    names[8]="BETA[1]";                                                      //Beta before ([0]) or after
    beta_ = 0;
    plane_[0] = 3;
    plane_[1] = 5;
    delta_[0] = 2;
    delta_[1] = 4;
  }

  Char_t* LinCorr = "",* SquCorr = "",*cut = "";
  if(aoq != 0) cut = "ZET[0]>49.5 && ZET[0] < 50.5 && TMath::Abs(AOQ[0]-2.56)<0.01";
  for(short ii = 0; ii < 9; ii++){
    LinCorr = Form("%s+%f*%s"   ,LinCorr,corr[0][ii],names[ii]);
    SquCorr = Form("%s+%f*%s*%s",SquCorr,corr[1][ii],names[ii],names[ii]);
  }
  TH2F* h2_aoq;
  if(var == 8) h2_aoq = new TH2F("h2_aoq",Form("AOQ[%i] vs %s",aoq,names[var]),200, 0.5,0.6,200,2.54,2.58);
  else if(var == 3 || var == 7)h2_aoq = new TH2F("h2_aoq",Form("AOQ[%i] vs %s",aoq,names[var]),200,-2,2, 200,2.54,2.58);
  else  h2_aoq = new TH2F("h2_aoq",Form("AOQ[%i] vs %s",aoq, names[var]),200,-10,10,200,2.54,2.58);
  tree->Draw(Form("AOQ[%i]+%s+%s:%s>>h2_aoq",aoq,LinCorr,SquCorr,names[var]),cut,"colz");



  tree->Draw(Form("AOQ[2]+%s+%s:ZET[3]>>h50(100,45,55,200,2.5,2.7)",LinCorr,SquCorr),cut,"colz");

}
コード例 #26
0
void PDFSystCalculator_Powheg12Bin()
{
  typedef std::pair<double,double> pairOfDouble;
  set<pairOfDouble> uniqueEventsTrue;

  typedef std::pair<int,int> pairOfInt;
  set<pairOfInt> uniqueEventsReco;

  double mLow = 60.; // Z mass
  double mHigh = 120.; // Z mass
  double ptLow = 0.;
  double ptHigh = 4000.;

  //variable related PDF systematic uncertainty
  //double weightedSelectedEvents[18][53];
  //double weighted2SelectedEvents[18][53];
  double weightedSelectedEvents[12][53];
  double weighted2SelectedEvents[12][53];
  
  double events_central[nptBins] = {0.0};
  double events2_central[nptBins] = {0.0};
  double wa[nptBins] = {0.0};
  double wb[nptBins] = {0.0};
  double wplus[nptBins] = {0.0};
  double wminus[nptBins] = {0.0};

  char tmpName[30];


 // std::ofstream Fout;
 // TString FoutName = "Zpt_12BinWeightedSelectedEvents.txt";
 // Fout.open(FoutName);
 // Fout << fixed << setprecision(3);



  // read input root file
  TChain* tree = new TChain("tree");
  for(int i(1);i<95;i++)
  {
    //sprintf(tmpName,"DYJetsToLL_%d.root",i);
    //sprintf(tmpName,"/d1/scratch/sangilpark/Zpt/CMSSW_5_3_14_patch1/src/TerraNova/NtupleMaker/test/ZpT_Powheg_LowPU/DYJetsToLL_%d.root",i);
    sprintf(tmpName,"/d2/scratch/Storage_Area/ZpT8TeV_Powheg_LowPU/DYJetsToLL_%d.root",i);
    tree->AddFile(tmpName);  // Powheg Ntuple
  }

  TH1D* hPtMCTot = new TH1D("hPtMCTot", "", nptBins, xbins_pt); // no cut
  TH1D* hPtMCAcc = new TH1D("hPtMCAcc", "", nptBins, xbins_pt); // acc.cuts
  TH1D* hPtMCEff = new TH1D("hPtMCEff", "", nptBins, xbins_pt); // acc + all selection cuts


  //Hammid MC truth information pre FSR
  _TrackInfo true1PreFSR, true2PreFSR;
  tree->SetBranchAddress("true1PreFSR", &true1PreFSR);
  tree->SetBranchAddress("true2PreFSR", &true2PreFSR);

  float trueMassPreFSR, truePtPreFSR;
  tree->SetBranchAddress("trueMassPreFSR",	&trueMassPreFSR);
  tree->SetBranchAddress("truePtPreFSR",	&truePtPreFSR);

  vector<float> *weights_CT10;
  TBranch *b_weights_CT10;
  weights_CT10 = 0;
  tree->SetBranchAddress("weights_CT10", &weights_CT10, &b_weights_CT10);


  // Initialize variable
  for(int iBin(0); iBin<nptBins; iBin++)
  {
    {
      for(int j=0; j<53; j++)
      {
	weightedSelectedEvents[iBin][j] = 0;
	weighted2SelectedEvents[iBin][j] = 0;
//	cout << "initialized weightedSelectedEvents : " << weightedSelectedEvents[iBin][j] << endl;
      }
    }
  }

  // Print # of events
  cout << "Loop over the " << tree->GetEntries() << " entries ...\n";

  // Fill histogram
  for(int iEvt(0); iEvt<tree->GetEntries(); iEvt++)
  //for(int iEvt(0); iEvt<20; iEvt++)
  {
    if ( (iEvt % 100000)==0 ) cout << "event " << iEvt << endl;
    tree -> GetEntry(iEvt);

    //nocut start
    pairOfDouble trueMassPtPreFSR(trueMassPreFSR,truePtPreFSR);
    if( !uniqueEventsTrue.insert( trueMassPtPreFSR ).second ) continue;

    if (trueMassPreFSR <  mLow) continue;
    if (trueMassPreFSR > mHigh) continue;

    hPtMCTot -> Fill( truePtPreFSR );

    // acc cut start
    if (true1PreFSR.charge == -999) continue;
    if (true2PreFSR.charge == -999) continue;
    if (true1PreFSR.charge*true2PreFSR.charge>0) continue;

    if (trueMassPreFSR <  mLow) continue;
    if (trueMassPreFSR > mHigh) continue;
    if (true1PreFSR.pt < 20         || true2PreFSR.pt < 20        ) continue;
    if (fabs(true1PreFSR.eta) > 2.1 || fabs(true2PreFSR.eta) > 2.1) continue;
    hPtMCAcc -> Fill( truePtPreFSR );

    //cout << "trueMassPreFSR : " << trueMassPreFSR << endl;
    //cout << "true1PreFSR : " << true1PreFSR.pt << endl;
    //cout << "truePtPreFSR : " << truePtPreFSR << endl;
    //cout << "weights size : " << weights_CT10->size() << endl;


    // Check weight numbers are normal. 
    //cout << Form("iEvt : %d ============================= ",iEvt) << endl;
    //for(int i(0); i<weights_CT10->size(); i++)
    //{
    //  cout << "weights_CT10 : " << (*weights_CT10)[i] << endl;
    //}


    // Save weights each bin
    for(int iBin(0); iBin<nptBins; iBin++)
    {
      if(truePtPreFSR >= xbins_pt[iBin] && truePtPreFSR < xbins_pt[iBin+1])
      {
	for(int j=0; j<weights_CT10->size(); j++)
	{
	  weightedSelectedEvents[iBin][j] += (*weights_CT10)[j];
	  weighted2SelectedEvents[iBin][j] += (*weights_CT10)[j] * (*weights_CT10)[j];
	  //cout << Form("weightedSelectedEvents[%d][%d] : %f \t weighted2SelectedEvents[%d][%d] : %f \t weights_CT10[%d] : %f ",iBin,j,weightedSelectedEvents[iBin][j],iBin,j,weighted2SelectedEvents[iBin][j], j, (*weights_CT10)[j]) << endl;
	}
      }
    }
  }

  double weightedSelectedEventsCentTot=0;
  for(int iBin(0);iBin<nptBins;iBin++)
  {
     weightedSelectedEventsCentTot += weightedSelectedEvents[iBin][0];

      for (unsigned int j=0; j<weights_CT10->size(); ++j)
      {
	cout << fixed << setprecision(5);
	cout<<iBin<<"\t"<<j<<"\t"<<weightedSelectedEvents[iBin][j]<<endl;
      }
  }
    // Calculate PDF syst
  for(int iBin(0);iBin<nptBins;iBin++)
  {
    unsigned int nmembers = weights_CT10->size();
    unsigned int npairs = (nmembers-1)/2;
 
    events_central[iBin] = weightedSelectedEvents[iBin][0]/weightedSelectedEventsCentTot/(xbins_pt[iBin+1]-xbins_pt[iBin]);
    events2_central[iBin] = weighted2SelectedEvents[iBin][0];
    if(npairs>0){
      for (unsigned int j=0; j<npairs; ++j)
      {
	
	double weightedSelectedEventsXPlusTot=0;
	double weightedSelectedEventsXMinusTot=0;
	for(int iBin(0);iBin<nptBins;iBin++)
	{
	  weightedSelectedEventsXPlusTot += weightedSelectedEvents[iBin][2*j+1];
	  weightedSelectedEventsXMinusTot += weightedSelectedEvents[iBin][2*j+2];
	}

	cout << "events central : " << events_central[iBin] << endl;
	//wa[iBin] = weightedSelectedEvents[iBin][2*j+1]/events_central[iBin]-1.;
	//wb[iBin] = weightedSelectedEvents[iBin][2*j+2]/events_central[iBin]-1.;
	
	wa[iBin] = (weightedSelectedEvents[iBin][2*j+1]/weightedSelectedEventsXPlusTot/(xbins_pt[iBin+1]-xbins_pt[iBin]))/events_central[iBin]-1.;
	wb[iBin] = (weightedSelectedEvents[iBin][2*j+2]/weightedSelectedEventsXMinusTot/(xbins_pt[iBin+1]-xbins_pt[iBin]))/events_central[iBin]-1.;
	
	if (wa[iBin]>wb[iBin]){
	  if (wa[iBin]<0.) wa[iBin] = 0.;
	  if (wb[iBin]>0.) wb[iBin] = 0.;
	  wplus[iBin] += wa[iBin]*wa[iBin];
	  wminus[iBin] += wb[iBin]*wb[iBin];
	}else{
	  if (wb[iBin]<0.) wb[iBin] = 0.;
	  if (wa[iBin]>0.) wa[iBin] = 0.;
	  wplus[iBin] += wb[iBin]*wb[iBin];
	  wminus[iBin] += wa[iBin]*wa[iBin];
	}
      }
      if (wplus[iBin]>0) wplus[iBin] = sqrt(wplus[iBin]);
      if (wminus[iBin]>0) wminus[iBin] = sqrt(wminus[iBin]);
    }else{
      cout << "\tNO eigenvectors for uncertainty estimation" << endl;
    }
    //cout <<iBin+1<<" Bin: Relative uncertainty with respect to central member: +" << 100.*wplus[iBin] << " / -" <<  100.*wminus[iBin] << " [%]" << endl;
    cout <<iBin+1<<" + " << 100.*wplus[iBin] << " / -" <<  100.*wminus[iBin] << " [%]" << endl;
  }

  for(int i(0); i<nptBins; i++)
  {
    cout << i+1 << " bin Events number : " << hPtMCAcc->GetBinContent(i+1) << endl;
  }

  TFile* Hist_out = new TFile("ZptPreFSR_Powheg12Bin.root","recreate");

  hPtMCTot->Write();
  hPtMCAcc->Write();

  //Fout.close();
}
コード例 #27
0
ファイル: xSection.C プロジェクト: pawannetrakanti/UserCode
int xSection(string recotype="HI"){

  TH1::SetDefaultSumw2();

  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiForest2015#5_02_TeV_pp_MC

  double pthats[] = {15       , 30       , 50       , 80       , 120      , 170      , 220      , 280      , 370      , 460      , 540      , 9999};
  double xs502[]  = {5.269e-01, 3.455e-02, 4.068e-03, 4.959e-04, 7.096e-05, 1.223e-05, 3.031e-06, 7.746e-07, 1.410e-07, 3.216e-08, 1.001e-08, 0.0};

  //double xs276[]  = {2.034e-01, 1.075e-02, 1.025e-03, 9.865e-05, 1.129e-05, 1.465e-06, 2.837e-07, 5.323e-08, 5.934e-09, 8.125e-10, 1.467e-10, 0.0};


  //double pthats[] = {15       , 30       , 50       , 80       , 120      , 170      , 220      , 280      , 9999};
  //double xs502[]  = {5.269e-01, 3.455e-02, 4.068e-03, 4.959e-04, 7.096e-05, 1.223e-05, 3.031e-06, 7.746e-07, 0.0};

  //double pthats[] = {15       , 30       , 50       , 80       , 120      , 170      , 220      , 280      , 460      , 540      , 9999};
  //double xs502 [] = {5.269e-01, 3.455e-02, 4.068e-03, 4.959e-04, 7.096e-05, 1.223e-05, 3.031e-06, 7.746e-07, 3.216e-08, 1.001e-08, 0.0};


  const int Npt = sizeof(pthats)/sizeof(double) - 1;
  double n[Npt]={0};

  // double n  [Npt] = {279441,909299,939442,790651,482031,120627,422180,764369,1143728};
  // double wtf[Npt] = {1.07364e-07,3.66964e-09,4.04208e-10,6.48706e-11,2.06051e-11,
  double *xs = xs502;
  for(int i=0; i<Npt; i++){
    cout << pthats[i] << "\t" << xs[i] << " " << xs502[i] << endl;
  }
  cout << "Npt :  " << Npt << endl;
  //return 0;

  //! Read the files and get the effective # of events

  TChain* nt;
  //TChain* evt;
  // TFile* outf[Nfiles];
  
  nt  = new TChain("ak3PFJetAnalyzer/t");
  //nt  = new TChain("akPu3PFJetAnalyzer/t");

  std::string infile_Forest;
  infile_Forest="filelist_PP_Signal_758_HcalRespCorr_v4.txt";
  //infile_Forest="filelist_PbPb_hcalv4.txt";
  //infile_Forest="filelist_ppJEC2015_"+recotype+"Reco_757p1_HcalRespCorrs_v4_00_mc.txt";
  std::ifstream infile(infile_Forest.c_str(),std::ifstream::in);
  std::string filename_Forest;

  while(1){
    infile>>filename_Forest;
    if( !infile.good() )break;
    //cout << filename_Forest.c_str() << endl;
    nt->AddFile(filename_Forest.c_str());
  }

  for(int i = 0; i < Npt; i++){
    TCut pthatCut(Form("pthat >= %f && pthat < %f",pthats[i],pthats[i+1]));
    n[i] = 1.0*nt->GetEntries(pthatCut);
    //cout<<"no of events in pthat = "<<pthats[i]<<" = "<<n[i]<<endl;
    //xs[i] = xs502[i] - xs502[i+1];
    xs[i]-= xs[i+1];
    cout << "{" << pthats[i] << "," << std::setprecision (std::numeric_limits<double>::digits10 + 1) 
	 << n[i]  << "," << std::setprecision (std::numeric_limits<double>::digits10 + 1) 
	 << xs[i] << "," << std::setprecision (std::numeric_limits<double>::digits10 + 1)  
	 << xs[i]/n[i] << "}," 
	 << endl;
  }

  //TFile *fout = new TFile(Form("xsec_weight_PbPb_%sreco_757p1_HcalRespCorrs_v4_00_mc.root",recotype.c_str()),"RECREATE");
  //TFile *fout = new TFile("xsec_weight_PbPb.root","RECREATE");
  TFile *fout = new TFile(Form("xsec_weight_pp_%sreco_758_HcalRespCorrs_v4_mc.root",recotype.c_str()),"RECREATE");
  TH1D *hpthat_comb = new TH1D("hpthat","pt hat combined",500,0,1500);
  hpthat_comb->Sumw2();

  float pthat;
  nt->SetBranchAddress("pthat",&pthat);
  nt->SetBranchStatus("*",0,0);
  nt->SetBranchStatus("pthat",1);  

  for(int i=0; i<nt->GetEntries(); i++){
    nt->GetEntry(i);
    double pthatwt=-1.0;
    for(int j = 0; j < Npt; j++){
      if(n[j] > 0 && pthat >= pthats[j]){
	pthatwt = xs[j]/n[j];
      }
    }
    if( pthatwt > 0 )hpthat_comb->Fill(pthat,pthatwt);
  }

  fout->cd();
  fout->Write();
  fout->Close();

  return 0;
}
コード例 #28
0
ファイル: egammaResolution.cpp プロジェクト: J-C-Wright/PFCal
int main(int argc, char** argv){//main  

  //Input output and config options
  std::string cfg;
  bool concept;
  //size of signal region to perform Chi2 position fit.
  //in units of 2.5mm cells to accomodate different granularities
  unsigned nSR;
  //maximum value of residuals to use in error matrix: discard positions that are too far away 
  double residualMax;//mm
  unsigned pNevts;
  std::string filePath;
  std::string digifilePath;
  unsigned nRuns;
  std::string simFileName;
  std::string recoFileName;
  std::string outPath;
  unsigned nSiLayers;
  //0:do just the energies, 1:do fit+energies, 2: do zpos+fit+energies
  unsigned redoStep;
  unsigned debug;
  bool applyPuMixFix;

  po::options_description preconfig("Configuration"); 
  preconfig.add_options()("cfg,c",po::value<std::string>(&cfg)->required());
  po::variables_map vm;
  po::store(po::command_line_parser(argc, argv).options(preconfig).allow_unregistered().run(), vm);
  po::notify(vm);
  po::options_description config("Configuration");
  config.add_options()
    //Input output and config options //->required()
    ("concept",        po::value<bool>(&concept)->default_value(true))
    ("nSR",            po::value<unsigned>(&nSR)->default_value(3))
    ("residualMax",    po::value<double>(&residualMax)->default_value(25))
    ("pNevts,n",       po::value<unsigned>(&pNevts)->default_value(0))
    ("filePath,i",     po::value<std::string>(&filePath)->required())
    ("digifilePath", po::value<std::string>(&digifilePath)->default_value(""))
    ("nRuns",        po::value<unsigned>(&nRuns)->default_value(0))
    ("simFileName,s",  po::value<std::string>(&simFileName)->required())
    ("recoFileName,r", po::value<std::string>(&recoFileName)->required())
    ("outPath,o",      po::value<std::string>(&outPath)->required())
    ("nSiLayers",      po::value<unsigned>(&nSiLayers)->default_value(2))
    ("redoStep",       po::value<unsigned>(&redoStep)->default_value(0))
    ("debug,d",        po::value<unsigned>(&debug)->default_value(0))
    ("applyPuMixFix",  po::value<bool>(&applyPuMixFix)->default_value(false))
    ;

  // ("output_name,o",            po::value<std::string>(&outputname)->default_value("tmp.root"))

  po::store(po::command_line_parser(argc, argv).options(config).allow_unregistered().run(), vm);
  po::store(po::parse_config_file<char>(cfg.c_str(), config), vm);
  po::notify(vm);



  std::string inFilePath = filePath+simFileName;

  size_t end=outPath.find_last_of(".");
  std::string outFolder = outPath.substr(0,end);


  std::cout << " -- Input parameters: " << std::endl
	    << " -- Input file path: " << filePath << std::endl
	    << " -- Digi Input file path: " << digifilePath << std::endl
	    << " -- Output file path: " << outPath << std::endl
	    << " -- Output folder: " << outFolder << std::endl
	    << " -- Requiring " << nSiLayers << " si layers." << std::endl
	    << " -- Number cells in signal region for fit: " << nSR << " cells" << std::endl
	    << " -- Residual max considered for filling matrix and fitting: " << residualMax << " mm" << std::endl
	    << " -- Apply PUMix fix? " << applyPuMixFix << std::endl
	    << " -- Processing ";
  if (pNevts == 0) std::cout << "all events." << std::endl;
  else std::cout << pNevts << " events." << std::endl;

  TRandom3 lRndm(1);
  std::cout << " -- Random number seed: " << lRndm.GetSeed() << std::endl;

  /////////////////////////////////////////////////////////////
  //input
  /////////////////////////////////////////////////////////////

  std::ostringstream inputsim;
  inputsim << filePath << "/" << simFileName;
  std::ostringstream inputrec;
  if (digifilePath.size()==0)
    inputrec << filePath << "/" << recoFileName;
  else 
    inputrec << digifilePath << "/" << recoFileName;

  //std::cout << inputsim.str() << " " << inputrec.str() << std::endl;

  HGCSSInfo * info;

  TChain *lSimTree = new TChain("HGCSSTree");
  TChain *lRecTree = 0;
  
  TFile * simFile = 0;
  TFile * recFile = 0;

  if (recoFileName.find("Digi") != recoFileName.npos) 
    lRecTree = new TChain("RecoTree");
  else lRecTree = new TChain("PUTree");

  if (nRuns == 0){
    if (!testInputFile(inputsim.str(),simFile)) return 1;
    lSimTree->AddFile(inputsim.str().c_str());
    if (!testInputFile(inputrec.str(),recFile)) return 1;
    lRecTree->AddFile(inputrec.str().c_str());
  }
  else {
    for (unsigned i(0);i<nRuns;++i){
      std::ostringstream lstr;
      lstr << inputsim.str() << "_run" << i << ".root";
      if (testInputFile(lstr.str(),simFile)){  
	if (simFile) info =(HGCSSInfo*)simFile->Get("Info");
	else {
	  std::cout << " -- Error in getting information from simfile!" << std::endl;
	  return 1;
	}
      }
      else continue;
      lSimTree->AddFile(lstr.str().c_str());
      lstr.str("");
      lstr << inputrec.str() << "_run" << i << ".root";
      if (!testInputFile(lstr.str(),recFile)) continue;
      lRecTree->AddFile(lstr.str().c_str());
    }
  }

  if (!lSimTree){
    std::cout << " -- Error, tree HGCSSTree cannot be opened. Exiting..." << std::endl;
    return 1;
  }

  if (!lRecTree){
    std::cout << " -- Error, tree RecoTree cannot be opened. Exiting..." << std::endl;
    return 1;
  }


  /////////////////////////////////////////////////////////////
  //Info
  /////////////////////////////////////////////////////////////

  const double cellSize = info->cellSize();
  const unsigned versionNumber = info->version();
  const unsigned model = info->model();
  
  //models 0,1 or 3.
  //bool isTBsetup = (model != 2);
  bool isCaliceHcal = versionNumber==23;//inFilePath.find("version23")!=inFilePath.npos || inFilePath.find("version_23")!=inFilePath.npos;

  //extract input energy

  std::cout << " -- Version number is : " << versionNumber 
	    << ", model = " << model
	    << ", cellSize = " << cellSize
	    << std::endl;


  //initialise detector
  HGCSSDetector & myDetector = theDetector();
 
  myDetector.buildDetector(versionNumber,concept,isCaliceHcal);

  const unsigned nLayers = myDetector.nLayers();
  const unsigned nSections = myDetector.nSections();

  std::cout << " -- N layers = " << nLayers << std::endl
	    << " -- N sections = " << nSections << std::endl;


  HGCSSGeometryConversion geomConv(inFilePath,model,cellSize);
  //set granularity to get cellsize for PU subtraction
  std::vector<unsigned> granularity;
  granularity.resize(nLayers,4);
  geomConv.setGranularity(granularity);

  //////////////////////////////////////////////////
  //////////////////////////////////////////////////
  ///////// Output File // /////////////////////////
  //////////////////////////////////////////////////
  //////////////////////////////////////////////////

  TFile *outputFile = TFile::Open(outPath.c_str(),"RECREATE");
  
  if (!outputFile) {
    std::cout << " -- Error, output file " << outPath << " cannot be opened. Please create output directory. Exiting..." << std::endl;
    return 1;
  }
  else {
    std::cout << " -- output file " << outputFile->GetName() << " successfully opened." << std::endl;
  }
  outputFile->cd();


  ///initialise PU density object

  HGCSSPUenergy puDensity("data/EnergyDensity.dat");


    //////////////////////////////////////////////////
    //////////////////////////////////////////////////
    ///////// positionFit /////////////////////////////
    //////////////////////////////////////////////////
    //////////////////////////////////////////////////
  
  const unsigned nEvts = ((pNevts > lSimTree->GetEntries() || pNevts==0) ? static_cast<unsigned>(lSimTree->GetEntries()) : pNevts) ;
  

  PositionFit lChi2Fit(nSR,residualMax,nLayers,nSiLayers,applyPuMixFix,debug);
  lChi2Fit.initialise(outputFile,"PositionFit",outFolder,geomConv,puDensity);

  //try getting z position from input file, if doesn't exit,
  //perform first loop over simhits to find z positions of layers
  if ((redoStep<2 && !lChi2Fit.getZpositions(versionNumber)) || redoStep>1)
    lChi2Fit.getZpositions(versionNumber,lSimTree,nEvts);
  
  //perform second loop over events to find positions to fit and get energies
  SignalRegion SignalEnergy(outFolder, nLayers, nEvts, geomConv, puDensity,applyPuMixFix,versionNumber);
  SignalEnergy.initialise(outputFile,"Energies");

  //initialise
  bool dofit = redoStep>0 || !SignalEnergy.initialiseFitPositions();
  if (!dofit && redoStep==0) std::cout << " -- Info: fit positions taken from file on disk." << std::endl;
  else std::cout << " -- Info: redoing least square fit." << std::endl;

  if (redoStep>0 || (redoStep==0 && dofit)){
    lChi2Fit.getInitialPositions(lSimTree,lRecTree,nEvts);
    lChi2Fit.finaliseErrorMatrix();
    lChi2Fit.initialiseLeastSquareFit();
  }
  
  //loop on events
  HGCSSEvent * event = 0;
  std::vector<HGCSSSamplingSection> * ssvec = 0;
  std::vector<HGCSSSimHit> * simhitvec = 0;
  std::vector<HGCSSRecoHit> * rechitvec = 0;
  std::vector<HGCSSGenParticle> * genvec = 0;
  unsigned nPuVtx = 0;

  lSimTree->SetBranchAddress("HGCSSEvent",&event);
  lSimTree->SetBranchAddress("HGCSSSamplingSectionVec",&ssvec);
  lSimTree->SetBranchAddress("HGCSSSimHitVec",&simhitvec);
  lSimTree->SetBranchAddress("HGCSSGenParticleVec",&genvec);

  lRecTree->SetBranchAddress("HGCSSRecoHitVec",&rechitvec);
  if (lRecTree->GetBranch("nPuVtx")) lRecTree->SetBranchAddress("nPuVtx",&nPuVtx);
  const unsigned nRemove = 12;
  std::vector<unsigned> lToRemove;
  unsigned list[nRemove] = {25,27,15,1,10,3,18,5,12,7,23,20};

  for (unsigned ievt(0); ievt<nEvts; ++ievt){//loop on entries
    if (debug) std::cout << "... Processing entry: " << ievt << std::endl;
    else if (ievt%50 == 0) std::cout << "... Processing entry: " << ievt << std::endl;

    lSimTree->GetEntry(ievt);
    lRecTree->GetEntry(ievt);
    if (dofit) {
      bool found = lChi2Fit.setTruthInfo(genvec,1);
      if (!found) continue;
      //mask layers in turn
      lToRemove.clear();
      for (unsigned r(0); r<nRemove+1;++r){
	FitResult fit;
	if ( lChi2Fit.performLeastSquareFit(ievt,fit,lToRemove)==0 ){
	  //SignalEnergy.fillEnergies(ievt,(*ssvec),(*simhitvec),(*rechitvec),nPuVtx,fit);
	}
	else std::cout << " -- remove " << r << " Fit failed." << std::endl;
	if (r<nRemove) lToRemove.push_back(list[r]);
      }

    }
    else SignalEnergy.fillEnergies(ievt,(*ssvec),(*simhitvec),(*rechitvec),nPuVtx);

  }//loop on entries

  //finalise

  if (dofit) lChi2Fit.finaliseFit();
  SignalEnergy.finalise();

  outputFile->Write();
  //outputFile->Close();
  
  std::cout << " - End of egammaResolution program." << std::endl;

  return 0;
  

}//main
コード例 #29
0
ファイル: MinBias.cpp プロジェクト: J-C-Wright/PFCal
int main(int argc, char** argv){//main  

  if (argc < 6) {
    std::cout << " Usage: " 
	      << argv[0] << " <nEvts to process (0=all)>"
	      << " <path to input files>"
	      << " <name of input reco file>"
	      << " <full path to output file>"
	      << " <number of si layers to consider: 1,2 or 3>" 
	      << " <optional: debug (default=0)>"
	      << std::endl;
    return 1;
  }

  //////////////////////////////////////////////////////////
  //// Hardcoded config ////////////////////////////////////
  //////////////////////////////////////////////////////////
  //for HGCAL, true means only 12 FHCAL layers considered (24 are simulated)
  bool concept = true;

  bool selectEarlyDecays = false;

  double minX=-1700,maxX=1700;
  double minY=-1700,maxY=1700;
  double minZ=3170,maxZ=5070;

  unsigned nX=(maxX-minX)/10,nY=(maxY-minY)/10;
  unsigned nZ=maxZ-minZ;

  //// End Hardcoded config ////////////////////////////////////
  //////////////////////////////////////////////////////////

  const unsigned pNevts = atoi(argv[1]);
  std::string filePath = argv[2];
  std::string recoFileName = argv[3];

  std::string outPath = argv[4];
  unsigned nSiLayers = 2;
  nSiLayers = atoi(argv[5]);

  unsigned debug = 0;
  if (argc >7) debug = atoi(argv[7]);

  bool isEM = false;

  if (selectEarlyDecays && isEM) {
    selectEarlyDecays = false;
  }

  std::cout << " -- Input parameters: " << std::endl
	    << " -- Input file path: " << filePath << std::endl
	    << " -- Output file path: " << outPath << std::endl
	    << " -- Requiring " << nSiLayers << " si layers." << std::endl
	    << " -- Processing ";
  if (pNevts == 0) std::cout << "all events." << std::endl;
  else std::cout << pNevts << " events." << std::endl;

  TRandom3 lRndm(1);
  std::cout << " -- Random number seed: " << lRndm.GetSeed() << std::endl;

  /////////////////////////////////////////////////////////////
  //input
  /////////////////////////////////////////////////////////////

  TFile *recFile = new TFile(); 
  TChain *lRecTree = new TChain("RecoTree");
  if(recoFileName.find("*")!=recoFileName.npos){ 
     ofstream myscript;
     myscript.open("eosls.sh");
     myscript<<"#!/bin/bash" << std::endl;
     myscript<<"/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select ls " << filePath << std::endl; 
     myscript.close();
     FILE *script = popen("bash eosls.sh", "r");
     char eoslsName[100];
     int nF =0;
     while(fgets(eoslsName, 100, script)) {
        std::ostringstream input;
        std::string temp = std::string(eoslsName).substr(0,strlen(eoslsName)-1);
        if(temp.find("HG")!=temp.npos)continue;
        input << filePath << temp;
        lRecTree->AddFile(input.str().c_str());
        if(nF==0)recFile=TFile::Open(input.str().c_str());
        nF+=1;
     }
     pclose(script);  
     system("rm ./eosls.sh");
   }
   else {
     std::ostringstream input;
     input << filePath << recoFileName;
     lRecTree->AddFile(input.str().c_str());
     recFile=TFile::Open(input.str().c_str());
   }
   if (!recFile) {
     std::cout << " -- Error, input file cannot be opened. Exiting..." << std::endl;
     return 1;
   }

  /////////////////////////////////////////////////////////////
  //Info
  /////////////////////////////////////////////////////////////

  HGCSSInfo * info=(HGCSSInfo*)recFile->Get("Info");
  const double cellSize = info->cellSize();
  const unsigned versionNumber = info->version();
  const unsigned model = info->model();
  
  //models 0,1 or 3.
  bool isCaliceHcal = versionNumber==23;//inFilePath.find("version23")!=inFilePath.npos || inFilePath.find("version_23")!=inFilePath.npos;


  std::cout << " -- Version number is : " << versionNumber 
	    << ", model = " << model
	    << ", cellSize = " << cellSize
	    << std::endl;


  //initialise detector
  HGCSSDetector & myDetector = theDetector();

  myDetector.buildDetector(versionNumber,concept,isCaliceHcal);

  //initialise calibration class
  HGCSSDigitisation myDigitiser;
  myDigitiser.setRandomSeed(lRndm.GetSeed());

  const unsigned nLayers = myDetector.nLayers();
  const unsigned nSections = myDetector.nSections();

  std::cout << " -- N layers = " << nLayers << std::endl
	    << " -- N sections = " << nSections << std::endl;

  ofstream EnDensity;
  EnDensity.open("../test/EnergyDensity.dat");

  TFile *outputFile = TFile::Open(outPath.c_str(),"RECREATE");
  
  if (!outputFile) {
    std::cout << " -- Error, output file " << outPath << " cannot be opened. Please create output directory. Exiting..." << std::endl;
    return 1;
  }
  else {
    std::cout << " -- output file " << outputFile->GetName() << " successfully opened." << std::endl;
  }
  
  
  std::cout << " -- 2-D histograms: " << std::endl
	    << " -- X: " << nX << " " << minX << " " << maxX << std::endl
	    << " -- Y: " << nY << " " << minY << " " << maxY << std::endl
	    << " -- Z: " << nZ << " " << minZ << " " << maxZ << std::endl
    ;
  outputFile->cd();

  TH1F *p_nRecHits = new TH1F("p_nRecHits","n(RecHits)",
			      1000,0,500000);
  p_nRecHits->StatOverflows();

  TProfile *p_EvsLayer = new TProfile("p_EvsLayer","Average E vs Layer",30,1,30);

  TProfile *p_AveE[nLayers];
  std::ostringstream p_AveE_Name;
  for(unsigned iL(0); iL<nLayers; iL++){
     p_AveE_Name.str("");
     p_AveE_Name << "p_AveE_layer" <<iL+1;
     p_AveE[iL] = new TProfile(p_AveE_Name.str().c_str(),"Average Energy vs eta",40,1.5,3.5);
  }

  TH2F *p_Occupancy[nLayers];
  for(unsigned iL(0); iL<nLayers; iL++){
     p_AveE_Name.str("");
     p_AveE_Name << "p_Occupancy_Layer" <<iL+1;
     p_Occupancy[iL] = new TH2F(p_AveE_Name.str().c_str(),"RecoHits Occupancy",340,-170,170,340,-170,170);
 }

  std::vector<HGCSSRecoHit> * rechitvec = 0;
  
  lRecTree->SetBranchAddress("HGCSSRecoHitVec",&rechitvec);

  const unsigned nEvts = ((pNevts > lRecTree->GetEntries() || pNevts==0) ? static_cast<unsigned>(lRecTree->GetEntries()) : pNevts) ;
  
  std::cout << "- Processing = " << nEvts  << " events out of " << lRecTree->GetEntries() << std::endl;
  
  //Initialise histos
  //necessary to have overflows ?
  gStyle->SetOptStat(0);

  double Z_layer[nLayers];
  for(unsigned iL(0);iL<nLayers;iL++){
    Z_layer[iL]=0;
  }
  
  double CellNumber[nLayers][40];
  for(unsigned iL(0);iL<nLayers;iL++){
     for(unsigned iEta(0);iEta<40;iEta++){
        CellNumber[iL][iEta] =0;
      }
  }

  std::map<unsigned,bool> channelAlive;

  for (unsigned ievt(0); ievt<nEvts; ++ievt){//loop on entries
    if (debug) std::cout << "... Processing entry: " << ievt << std::endl;
    else if (ievt%50 == 0) std::cout << "... Processing entry: " << ievt << std::endl;
    
    lRecTree->GetEntry(ievt);

    double EvsLayer[nLayers][40];
    double EtotRec[nLayers];
    for(unsigned iL(0);iL<nLayers;iL++){
       EtotRec[iL]=0;
       for(unsigned iEta(0);iEta<40;iEta++){
           EvsLayer[iL][iEta] =0;
       }
    } 
  
    for (unsigned iH(0); iH<(*rechitvec).size(); ++iH){//loop on rechits
      HGCSSRecoHit lHit = (*rechitvec)[iH];
      
      double energy = lHit.energy();//in MIP already...
      unsigned layer = lHit.layer();
      int x = lHit.get_x()/10;
      int y = lHit.get_y()/10;
      double eta = lHit.eta();
      if (layer >= nLayers) {
	//std::cout << " WARNING! RecoHits with layer " << layer << " outside of detector's definition range ! Please fix the digitiser or the detector definition used here. Ignoring..." << std::endl;
	continue;
      }

      p_Occupancy[layer]->Fill(x,y);

      if(ievt==0){
         if(Z_layer[layer] ==0)Z_layer[layer]=lHit.get_z()/10.0;} 
  
      for(unsigned iEta(0);iEta<40;iEta++){
         if(eta>1.5+iEta*0.05 && eta<1.5+(iEta+1)*0.05)EvsLayer[layer][iEta]+=energy;
      }

      if(eta>1.5 && eta<3.5)EtotRec[layer] += energy;
      if (debug>1) std::cout << "-hit" << iH << "-" << layer << " " << energy << " " << EtotRec[layer];
    }//loop on rechits
    
    p_nRecHits->Fill((*rechitvec).size());
    for(unsigned iL(0); iL<nLayers; iL++){
       p_EvsLayer->Fill(iL+1, EtotRec[iL]);
    }

    if(ievt==0){
      for(unsigned iL(0);iL<nLayers;iL++){
         for(int iX(-170); iX < 170; iX++){
            for(int iY(-170);iY < 170; iY++){
              double radius = sqrt(iX*iX + iY*iY);
              if(radius > 170 || radius < 15)continue;
              double R = sqrt(radius*radius + Z_layer[iL]*Z_layer[iL]);
              double theta = acos(Z_layer[iL]/R);
              double eta = -log(tan(theta/2.));
              for(unsigned iEta(0); iEta < 40; iEta++){
                if(eta>1.5+iEta*0.05 && eta<1.5+(iEta+1)*0.05)CellNumber[iL][iEta]+=1;
              }
             }
          }
       }
     }

    for(unsigned iEta(0);iEta<40;iEta++){
       for(unsigned iL(0);iL<nLayers;iL++){
          p_AveE[iL]->Fill(1.5+iEta*0.05,EvsLayer[iL][iEta]/CellNumber[iL][iEta]);
       }
    }
    
  }//loop on entries

  outputFile->Write();
  //outputFile->Close();

  // Fit the Energy Density
  EnDensity << "f(x) = exp(p0+p1*x)" << std::endl;
  EnDensity << "layer  p0  p1" << std::endl;
  for(unsigned iL(0);iL<nLayers;iL++){
       TF1 *expofit = new TF1("density","expo",1.5,3.0); 
       p_AveE[iL]->Fit("density","R");
       double p0 = expofit->GetParameter(0);
       double p1 = expofit->GetParameter(1);
       EnDensity << iL << " " << p0 << " " << p1 << std::endl;  
  }
  EnDensity.close();
 
  return 0;


}//main
コード例 #30
0
ファイル: draw.C プロジェクト: jaylawhorn/PulseShapes
void draw() {

  TChain *chain = new TChain("Events");

  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_1.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_10.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_100.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_101.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_102.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_103.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_104.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_105.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_106.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_107.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_108.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_109.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_11.root");
  chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_110.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_111.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_112.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_113.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_114.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_115.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_116.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_117.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_118.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_119.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_12.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_120.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_121.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_122.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_123.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_124.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_125.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_126.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_127.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_128.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_129.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_13.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_130.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_131.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_132.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_133.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_134.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_135.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_136.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_137.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_138.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_139.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_14.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_140.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_141.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_142.root");
  //chain->AddFile("/afs/cern.ch/work/j/jlawhorn/HighPtJet80/HCALTree_143.root");
  
  cout << chain->GetEntries() << endl;

  Double_t pulse[10], ped[10];

  chain->SetBranchAddress("pulse", &pulse);
  chain->SetBranchAddress("ped", &ped);

  vector<Double_t> ucut;
  vector<Double_t> lcut;

  const int nbin=11;

  for (int i=0; i<nbin; i++) {
    lcut.push_back(25+i*25);
    ucut.push_back(50+i*25);
  }
  
  Double_t avgPulse[nbin][10], avgPulse2[nbin][10], adcUnc[nbin][10], totUnc[nbin][10]; 
  for (UInt_t i=0; i<nbin; i++) {
    for (UInt_t j=0; j<10; j++) {avgPulse[i][j]=0; avgPulse2[i][j]=0; adcUnc[i][j]=0; totUnc[i][j]=0;}
  }

  Int_t nPulses[nbin]={0};

  TFile *outf = new TFile("test_hist.root", "recreate");
  TH1D *hQ = new TH1D("hq", "hq",50, 0, 400);

  for (UInt_t i=0; i<chain->GetEntries(); i++) {
  //for (UInt_t i=0; i<1000; i++) {
    chain->GetEntry(i);

    Double_t sumQ=0;
    for (UInt_t j=0; j<10; j++) { sumQ+=pulse[j];}

    hQ->Fill(sumQ);

    if (sumQ<25 || sumQ>300) continue;
    Int_t ibin= floor( sumQ/25-1 );
    //cout << sumQ << ", " << ibin << endl;

    nPulses[ibin]++;

    for (UInt_t j=0; j<10; j++) { 
      avgPulse[ibin][j]+=pulse[j]/sumQ;
      avgPulse2[ibin][j]+=pulse[j]*pulse[j]/sumQ;
      adcUnc[ibin][j]+=(sigma(pulse[j])*sigma(pulse[j])+1)/(pulse[j]*pulse[j]);
    }

  }

  //hQ->Draw("hist");

  //TH1D *h = new TH1D("h1", "h1", 10, -0.5, 9.5);
  vector<TGraphErrors*> grs;
  for (UInt_t i=0; i<nbin; i++) {
    char gname[50];
    sprintf(gname,"graph_%i",i);
    grs.push_back(new TGraphErrors(0));
    grs[i]->SetName(gname);

    cout << lcut[i] << " < Q_10 < " << ucut[i] << ": " << nPulses[i] << endl;

    for (UInt_t j=0; j<10; j++) {
      avgPulse[i][j]/=nPulses[i];
      avgPulse2[i][j]/=nPulses[i];
      adcUnc[i][j]=sqrt(adcUnc[i][j])/nPulses[i];
      totUnc[i][j]=sqrt(adcUnc[i][j] + avgPulse2[i][j] - avgPulse[i][j]*avgPulse[i][j])/sqrt(nPulses[i]);

      //cout << "avgPulse[" << j << "] = " << avgPulse[j] << " +/- " << totUnc[j] << endl;

      grs[i]->SetPoint(j, j, avgPulse[i][j]);
      grs[i]->SetPointError(j, 0, totUnc[i][j]);
    }
    
    grs[i]->Write();
  }

  outf->Write();
  outf->Close();


}