Ejemplo n.º 1
0
int AudacityProject::FindCommandByCombos(wxString cName)
{
   for(int i = 0; i < GetNumCommands(); i++)
   {
      wxStringTokenizer tName(mCommandMenuItem[i]->comboStrings, ":");
      while (tName.HasMoreTokens())
      {
          wxString token = tName.GetNextToken();

          if(!cName.CmpNoCase(token))
             return i;
      }
   }

   return -1;
}
Ejemplo n.º 2
0
bool side::enter()
{
	if (filesPath.size() < 2 && !(_stricmp(files[indexFile].name, "..")))
		return false;
	else if (!(_stricmp(files[indexFile].name, "..")))  //..
	{
		string tName(filesPath.back());
		filesPath.pop_back();
		makePath();
		if (!fillFiles())
			throw string("Can't read the directory: " + path);
		indexFile = getIndexByNameInCurrent(tName);
		if (indexFile >= side::countFiles)  // не вміщається в першу (значить хз :) десь посерединці поставимо :))
		{
			indexRow = 10;
			upIndexFile = indexFile - 10;
		}
		else // ваміщається в перший комлект
		{
			upIndexFile = 0;
			indexRow = indexFile;
		}
		show();
		writePath();
		return true;
	}
	else if ((_stricmp(files[indexFile].name, "..")) && !(files[indexFile].attrib & _A_SUBDIR))
		return false;
	else   // not .. but folder
	{
		filesPath.emplace_back(files[indexFile].name);
		makePath();
		if (!fillFiles())
			throw string("Can't read the directory: " + path);
		clearIndex();
		show();
		writePath();
		return true;
	}
	
}
Ejemplo n.º 3
0
void packTemplatesMass(const int iMass) {
  // This Root macro is for the purpose of providing input for expected limit computation
  // It packs predicted background and a set of signal samples into a root file per Higgs mass
  // 
  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();
  canvas = new TCanvas ("cg1","PadX",10,10,800,600);
  gStyle->SetPadColor(0);
  canvas->SetFillColor(0);

//   const int nbtag = 4;
  const int nbtag = 1;
  //const std::string sbtag[nbtag] = { "TCHPT", "TCHP6", "CSVT", "SSVHPT" };
  const std::string sbtag[nbtag] = { "CSVT" };

  const int nfc=3;
  const int ncateg=3;
  string sfc[nfc] = { "q", "c", "b" };

  // this is for the combination of triggers in real data
  int nTCombData = 4;
  std::string tCombData[] = {"Trig0", "Trig1", "Trig2", "Trig3"};

  std::string L1L2Mode("Weight");
  std::string signalMode("PU_WEIGHTED-NEW");
//   std::string L1L2Mode("Cut");
//   std::string signalMode("CUT_BASED");

  //std::string scenario("LowMass2011");
  //std::string scenario("MediumMass2011");

  std::string scenario;
  bool useTemplateError;
  bool useNP;
  if (  getHbbCfg(scenario,useTemplateError,useNP) != 0 ) return;

  string IgorVersion("V6");

#include "Analysis/Utilities/interface/HbbMass.h"

  if (iMass >= nSignal) {
    std::cout << "Bad iMass=" << iMass << std::endl;
    return;
  }
//   const int nSignal=7;
//   int signalMass[nSignal] = { 90, 100, 120, 140, 180, 250, 350 };
  // int signalMass[nSignal] = { 90, 100, 120, 130, 140, 160, 180, 200, 250, 350 }
  //  there are also : 450, 500, 600, 700, 800, 900, 1000
//   double efficiency[nSignal] = { 0.0022081, 0.00324694, 0.00600146, 0.00918135,
// 				0.0138382, 0.0189684, 0.0206572 };
  double efficiency[nSignal][nbtag];
  double intLumi = 0;
  string IgorScen("");
  string spacer("");
  string SashaPath("");
  string IgorPath("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/SignalTemplates-Production");

  if (IgorVersion == "V4") {
    IgorPath.assign("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-4");
  } else if (IgorVersion == "V6") {
    IgorPath.assign("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/SignalTemplates-Production2");
  }

  if (scenario == "LowMass2011") {
    //intLumi = 2.66794; // in fb-1
    intLumi = 2.692643;  // with new method
    IgorScen.assign("low");
    spacer.assign("");
    //SashaPath.assign("Data-Run2011AB");
    SashaPath.assign("Data-Run2011AB/TripleBtagAnalysis_CR3_SF7");
  } else if (scenario == "MediumMass2011") {
    //intLumi = 3.99983; // in fb-1
    intLumi = 4.040802;
    IgorScen.assign("medium");
    spacer.assign("/MEDIUM");
    //SashaPath.assign("Data-Run2011AB-Medium");
    SashaPath.assign("Data-Run2011AB/TripleBtagAnalysis_CR3_SF7_med");
  

  } else if (scenario == "MediumMass2012") {
    //intLumi = 3.99983; // in fb-1
    intLumi = 2.663;
    IgorScen.assign("medium");
    spacer.assign("/MEDIUM");
    //SashaPath.assign("Data-Run2011AB-Medium");
    SashaPath.assign("");
}
else {
    std::cout << "Bad scenario in packing" << std::endl;
    return;
  }
  string signalHistPattern("massEvBtag/mjjEvBTag_%s");
  if (L1L2Mode == "Weight") {
    signalHistPattern.assign("massEvBtagTW/mjjEvBTagTW_%s");
  }

  double fScal[nSignal][nbtag];
  
  // systematics
//   const int nSyst = 3;
//   std::string systName[nSyst] = { "JES", "SFbc", "SFudsg" };
//   bool realDataNuisance[nSyst] = { false, true, true }; // indicate if relevant for real data

  string bbPurity("DataDriven"); //  "MC", "DataDrivenR", "None"
  //string bbPurity("None"); //  "MC", "DataDrivenR", "None"

  bool onlineBtagCorr = true;

  int nSyst = 4;
  std::string systName[] = { "JES", "SFbc", "SFudsg", "JER" };
  bool realDataNuisance[] = { false, true, true, false }; // indicate if relevant for real data

  const int nUpDown = 2;
  std::string signalFile = "";

bool dosignal=true;


#if defined(MEDIUM2012)
dosignal=false;
nTCombData=1; ///only one trigger
//nSyst=0; /// no syst templates

#endif


  // signal templates
  if (IgorVersion != "V3") {
    std::cout << "Using signal files " << IgorVersion << std::endl;
    signalFile.assign( Form("%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",IgorPath.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  } else {
    std::cout << "Using V3 signal files" << std::endl;
    signalFile.assign( Form("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",signalMode.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  }
  std::string signalSystFiles[nSyst][nUpDown];
  //bool activeNuisance[nSyst] = { true, true, true };
  std::string upDownName[nUpDown] = { "Up", "Down" };
  TH2F* hSignalSyst[nSyst][nUpDown][nbtag];

  // output file
  TFile* hout = new TFile(Form("packedTemplates-M-%d.root",signalMass[iMass]),"recreate");
  hout->cd();
  TH2::AddDirectory(true);

  TFile* fSig = new TFile( signalFile.c_str() );
  if ( fSig == NULL ) {
    std::cout << "Could not open signal central file " << signalFile.c_str() << std::endl;
    return;
  } else {
    std::cout << "Open signal file " << signalFile.c_str() << std::endl;
  }

  TH2F* hSignalCentral[nbtag];

  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    hSignalCentral[ibtag] = mergeSignal(fSig,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
					Form("bbH_%s",sbtag[ibtag].c_str()));
    // read the efficiency
    TH1F* histEffMerged = (TH1F*) fSig->Get(Form("TrigEff/EffMerged%s",sbtag[ibtag].c_str()));
    if ( histEffMerged == NULL) {
      std::cout << "Efficiency histo not found" << std::endl;
      return;
    }
    double newEff = histEffMerged->GetBinContent(1);
    std::cout << "Mass= " << signalMass[iMass] 
	      << " btag= " << sbtag[ibtag]
	      << " Efficiency = " << newEff << std::endl;
    efficiency[iMass][ibtag] = newEff;

    double normShould = 1000 * intLumi * efficiency[iMass][ibtag];
    double normIs = hSignalCentral[ibtag]->GetSumOfWeights();
    std::cout << hSignalCentral[ibtag]->GetName() << " TotalContents=" << hSignalCentral[ibtag]->GetSumOfWeights()
	      << std::endl;
    fScal[iMass][ibtag] = normShould / normIs;
    std::cout << "normShould = " << normShould << " normIs " << normIs
	      << " rescale by " << fScal[iMass][ibtag] << std::endl;
    hSignalCentral[ibtag]->Scale( fScal[iMass][ibtag] );
    hout->cd();
    hSignalCentral[ibtag]->Write();
    histEffMerged->Write();

    // create empty file just as marker
    ofstream markerFile;
    markerFile.open(Form("pack-%s-%s.txt",sbtag[ibtag].c_str(),scenario.c_str()),ios::app);
    markerFile << "Template for mass " << signalMass[iMass] << std::endl;
    markerFile.close();
  }

  // read the nominal cross section
  TH1F* histXSect = (TH1F*) fSig->Get("xsection/xsect");
  if ( histXSect == NULL) {
    std::cout << "xsection/xsect" << " not found" << std::endl;
    return;
  }
  histXSect->Write();

  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
      if (IgorVersion != "V3") {
	signalSystFiles[iSyst][iUpDown] = Form( "%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
						IgorPath.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
						upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      } else {	
	signalSystFiles[iSyst][iUpDown] = Form( "/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
						signalMode.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
						upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      }
      std::cout << "Signal systematics file " << signalSystFiles[iSyst][iUpDown] << std::endl;
      TFile* fSigSys = new TFile( signalSystFiles[iSyst][iUpDown].c_str() );
      if ( fSigSys == NULL ) {
	std::cout << "Could not open signal syst file " << signalSystFiles[iSyst][iUpDown].c_str() << std::endl;
	return;
      }
      for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	hSignalSyst[iSyst][iUpDown][ibtag] 
	  = mergeSignal(fSigSys,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
			Form("bbH_%s_%s_%s",systName[iSyst].c_str(),
			     upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()));
	std::cout << "The merged hist has name " << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << std::endl;
	std::cout << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << " TotalContents=" << hSignalSyst[iSyst][iUpDown][ibtag]->GetSumOfWeights()
		  << std::endl;
	
	hSignalSyst[iSyst][iUpDown][ibtag]->Scale( fScal[iMass][ibtag] );
	hout->cd();
	hSignalSyst[iSyst][iUpDown][ibtag]->Write();
      }
      fSigSys->Close();
    }
  }

  // real data
  std::string backgroundFile( Form("/afs/naf.desy.de/user/r/rmankel/scratch/HbbPat/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_SF/TripleBtagAnalysis.root",SashaPath.c_str()) );

#if defined(MEDIUM2012)
//bool dosignal=true;
//backgroundFile = std::string("/data/user/marfin/CMSSW_5_3_3/src/Analysis/HbbMSSMAnalysis/test/Analysis2012/MVA-production-selection-trees/TripleBtagAnalysis.root");
backgroundFile = std::string("/data/user/marfin/CMSSW_5_3_3/src/Analysis/HbbMSSMAnalysis/test/Analysis2012/Blind-test-BG-only-Fit/MEDIUM/TripleBtagAnalysis_SF/TripleBtagAnalysis.root");
#endif


  std::cout << "Background central file : " << backgroundFile << std::endl;
  TFile* fBac = new TFile( backgroundFile.c_str() );
  if ( fBac == NULL ) {
    std::cout << "Could not open background central file " << signalFile.c_str() << std::endl;
    return;
  }

  // hist-to-be-fitted
  TH2F* mjjEbtdata[nbtag];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    mjjEbtdata[ibtag] = getTrigsAndMerge(fBac,Form("massEvBtag/mjjEvBTag_%s",sbtag[ibtag].c_str()),nTCombData,tCombData);

    if (mjjEbtdata[ibtag] == NULL) {
      std::cout << "Histogram not found: " << Form("massEvBtag/mjjEvBTag_%s",sbtag[ibtag].c_str()) << std::endl;
      return;
    }
    // rename
    mjjEbtdata[ibtag]->SetName( Form("Data_%s",sbtag[ibtag].c_str() ) );
    hout->cd();
    mjjEbtdata[ibtag]->Write();
  }

  TH2F* hBackgroundCentral[nbtag][ncateg][nfc];
  TH2F* hBackgroundCentralError[nbtag][ncateg][nfc];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    for (int icateg=0; icateg<ncateg; ++icateg) {
      int theTpat;
      if (onlineBtagCorr) {
	theTpat = 3;
      } else {
	theTpat = icateg;
      }

      for (int ifc=0; ifc<nfc; ++ifc) {
	string templateCore("massBTagTemplatesCld/MassBTagTemplateCld");
	if (bbPurity == "None") {
	   templateCore.assign("massBTagTemplatesCld/MassBTagTemplateUncld");
	}
	string hbSystName( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,theTpat) );
	hBackgroundCentral[ibtag][icateg][ifc] = getTrigsAndMerge(fBac,Form("%s_%s_%s_Cat%dTpat%d",
									   templateCore.c_str(),
									   sfc[ifc].c_str(),
									   sbtag[ibtag].c_str(),icateg,theTpat),nTCombData,tCombData);

	if ( hBackgroundCentral[ibtag][icateg][ifc] == NULL ) {
	  std::cout << "Hist not found: " << hbSystName << std::endl;
	  return;
	}
	// rename
	templateId tName(ifc,icateg);
	hBackgroundCentral[ibtag][icateg][ifc]->SetName( Form("%s_%s",tName.name().c_str(),sbtag[ibtag].c_str()) );
	// read the template errors
	templateCore.assign("errorMassBTagTemplates/ErrorMassBTagTemplate");
	string hbSystNameError( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,theTpat) );
	hBackgroundCentralError[ibtag][icateg][ifc] 
	  = getTrigsAndMerge(fBac,Form("%s_%s_%s_Cat%dTpat%d",
				       templateCore.c_str(),
				       sfc[ifc].c_str(),
				       sbtag[ibtag].c_str(),icateg,theTpat),nTCombData,tCombData);
	if ( hBackgroundCentralError[ibtag][icateg][ifc] == NULL ) {
	  std::cout << "Hist not found: " << hbSystNameError << std::endl;
	  return;
	}
	if (useTemplateError) {
	  // add the template error
	  std::cout << " ==== Adding Btag Errors ==== " << hBackgroundCentral[ibtag][icateg][ifc]->GetName() << std::endl;
	  for (int ibinx=1; ibinx<= (hBackgroundCentral[ibtag][icateg][ifc]->GetXaxis()->GetNbins()); ++ibinx) {
	    for (int ibiny=1; ibiny<= (hBackgroundCentral[ibtag][icateg][ifc]->GetYaxis()->GetNbins()); ++ibiny) {
	      float oldError = hBackgroundCentral[ibtag][icateg][ifc]->GetBinError(ibinx,ibiny);
	      float addError = hBackgroundCentralError[ibtag][icateg][ifc]->GetBinContent(ibinx,ibiny);
	      float newError = sqrt( oldError * oldError + addError * addError );
	      hBackgroundCentral[ibtag][icateg][ifc]->SetBinError(ibinx,ibiny,newError);
	    }
	  }
	}
	hout->cd();
	hBackgroundCentral[ibtag][icateg][ifc]->Write();
      }
    }
  }



  std::string backgroundSystFiles[nSyst][nUpDown];
  std::string systNameSasha[] = { "JES", "SFbc", "SFq" };
  std::string upDownNameSasha[nUpDown] = { "plus2", "minus2" };
  TH2F* hBackgroundSyst[nSyst][nUpDown][nbtag][ncateg][nfc];
  TH2F* hBackgroundSystError[nSyst][nUpDown][nbtag][ncateg][nfc];

//#if !defined(MEDIUM2012)

  // for nuisances like JEC, the up/down templates are just copies of the central templates
  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    if (! realDataNuisance[iSyst]) {
      std::cout << "Non-real data relevant nuisance: " << systName[iSyst].c_str() << std::endl;
      for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
	for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	  for (int icateg=0; icateg<ncateg; ++icateg) {
	    for (int ifc=0; ifc<nfc; ++ifc) {
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
		= new TH2F( *hBackgroundCentral[ibtag][icateg][ifc] );
	      // rename
	      templateId tName(ifc,icateg);
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
		->SetName( Form("%s_%s_%s_%s",
				tName.name().c_str(),systName[iSyst].c_str(),
				upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()) );
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->Write();
	    }
	  }
	}
      }
    }
  }
//#endif

  fBac->Close();


  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    if (realDataNuisance[iSyst]) {
      std::cout << "Real data relevant nuisance: " << systName[iSyst].c_str() << std::endl;
      for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
//	backgroundSystFiles[iSyst][iUpDown] = Form( "/afs/naf.desy.de/user/r/rmankel/scratch/HbbPat/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_%s%s/TripleBtagAnalysis.root",SashaPath.c_str(),systNameSasha[iSyst].c_str(),upDownNameSasha[iUpDown].c_str() );
	backgroundSystFiles[iSyst][iUpDown] = Form( "/data/user/marfin/CMSSW_5_3_3/src/Analysis/HbbMSSMAnalysis/test/Analysis2012/Blind-test-BG-only-Fit/MEDIUM/TripleBtagAnalysis_%s%s/TripleBtagAnalysis.root",systNameSasha[iSyst].c_str(),upDownNameSasha[iUpDown].c_str() );
	TFile* fBacSys = new TFile( backgroundSystFiles[iSyst][iUpDown].c_str() );
	std::cout << "Background systematics file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	if ( fBacSys == NULL ) {
	  std::cout << "Could not open background syst file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	  return;
	}
	for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	  for (int icateg=0; icateg<ncateg; ++icateg) {
	    int theTpat;
	    if (onlineBtagCorr) {
	      theTpat = 3;
	    } else {
	      theTpat = icateg;
	    }

	    for (int ifc=0; ifc<nfc; ++ifc) {
	      string templateCore("massBTagTemplatesCld/MassBTagTemplateCld");
	      if (bbPurity == "None") {
		templateCore.assign("massBTagTemplatesCld/MassBTagTemplateUncld");
	      }
	      string hbSystName( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				      sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,theTpat) );
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc] 
		= getTrigsAndMerge(fBacSys,Form("%s_%s_%s_Cat%dTpat%d",
						templateCore.c_str(),
						sfc[ifc].c_str(),
						sbtag[ibtag].c_str(),icateg,theTpat),nTCombData,tCombData);
	      if ( hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc] == NULL ) {
		std::cout << "Hist not found: " << hbSystName << std::endl;
		return;
	      }
	      // rename
	      templateId tName(ifc,icateg);
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
		->SetName( Form("%s_%s_%s_%s",
				tName.name().c_str(),systName[iSyst].c_str(),
				upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()) );
	      
	      // read template errors
	      templateCore.assign("errorMassBTagTemplates/ErrorMassBTagTemplate");
	      string hbSystNameError( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
					   sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,theTpat) );
	      hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc] 
		= getTrigsAndMerge(fBacSys,Form("%s_%s_%s_Cat%dTpat%d",
						templateCore.c_str(),
						sfc[ifc].c_str(),
						sbtag[ibtag].c_str(),icateg,theTpat),nTCombData,tCombData);
	      if ( hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc] == NULL ) {
		std::cout << "Hist not found: " << hbSystNameError << std::endl;
		return;
	      }
	      if (useTemplateError) {
		// add the template error
		std::cout << " ==== ErrorAdd ==== " << hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName() << std::endl;
		for (int ibinx=1; ibinx<= (hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetXaxis()->GetNbins()); ++ibinx) {
		  for (int ibiny=1; ibiny<= (hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetYaxis()->GetNbins()); ++ibiny) {
		    float oldError = hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetBinError(ibinx,ibiny);
		    float addError = hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc]->GetBinContent(ibinx,ibiny);
		    float newError = sqrt( oldError * oldError + addError * addError );
		    hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->SetBinError(ibinx,ibiny,newError);
		  }
		}
	      }
	      hout->cd();
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->Write();
	    }
	  }
	}
	fBacSys->Close();
      }
    }
  }

  std::cout << "Everything done " << std::endl;

#ifdef PROJECTIONS

TFile * projections_out=TFile::Open("projections.root","RECREATE");

  // loop over background templates
  //TH1D* bgProX[nbtag][ncateg][nfc];
  TH1D* bgSystProX[nSyst][nUpDown][nbtag][ncateg][nfc];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    for (int icateg=0; icateg<ncateg; ++icateg) {
      for (int ifc=0; ifc<nfc; ++ifc) {
	TH2F* theTemp = hBackgroundCentral[ibtag][icateg][ifc];
	TH1D* theTempProX = theTemp->ProjectionX(Form("%sProX",theTemp->GetName()),0,-1,"e");
	theTempProX->SetName( Form("%sProX",theTemp->GetName()) );
	TH1D* theTempProY = theTemp->ProjectionY(Form("%sProY",theTemp->GetName()),0,-1,"e");
	std::cout << "Made projection " << theTempProX->GetName() << std::endl;

	if ( (icateg == 0) && (ifc == 0) ) {
	  for (int ibinx=1; ibinx<= theTempProX->GetXaxis()->GetNbins(); ++ibinx) {
	    std::cout << ibinx << " content " << theTempProX->GetBinContent(ibinx)
		      << " error " << theTempProX->GetBinError(ibinx) << std::endl;
	  }
	}
	theTempProX->SetMarkerStyle(20);
	theTempProX->SetMarkerColor(1);
	theTempProX->SetLineColor(1);
	theTempProX->SetMarkerSize(1);
	std::cout << "Draw" << std::endl;
	theTempProX->Draw("EP");
	theTempProX->Write();






	//theTempProX->Draw("LP,SAME");
	// draw the SFbc systematics
	int colSyst[3] = {1, 2, 4};
	int lstyleUpDown[2] = {1, 1};
	for (int iSyst=1; iSyst<nSyst; ++iSyst) {
	  for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
	    bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc] =  hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->ProjectionX(Form("%sProXX",hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName()),0,-1,"e");
	    bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->SetName( Form("%sProXX",hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName()) );
	    std::cout << "Made projection " << bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->GetName() << std::endl;
	     bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->SetLineColor( colSyst[iSyst] );
	     bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->Draw("HIST,SAME");
		 bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->Write();


// 	    TH2F* theTemp = hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc];
// 	    TH1D* theTempProX = theTemp->ProjectionX(Form("%sProX",theTemp->GetName()),0,-1,"e");
// 	    theTempProX->SetLineColor( colSyst[iSyst] );
// 	    TH1D* theTempProY = theTemp->ProjectionY(Form("%sProY",theTemp->GetName()),0,-1,"e");
// 	    theTempProY->SetLineColor( colSyst[iSyst] );
// 	    //theTempProX->Draw("HIST");
	  }
	}

	canvas->Print(Form("Template_%s_%s_Cat%d_ProX.png",sbtag[ibtag].c_str(),sfc[ifc].c_str(),icateg));


	theTempProY->SetMarkerStyle(20);
	theTempProY->SetMarkerColor(1);
	theTempProY->SetLineColor(1);
	theTempProY->SetMarkerSize(1);
	std::cout << "Draw" << std::endl;
	theTempProY->Draw("EP");
	theTempProY->Write();


      }
    }
  }

projections_out->Write();
projections_out->Close();



#endif

  hout->Write();
  hout->Close();

  // close the signal central file
  fSig->Close();

  return;
}
Ejemplo n.º 4
0
void AudacityProject::BuildMenuBar()
{
   unsigned int i;
   for (i = 0; i < mCommandMenuItem.Count(); i++) {

      wxMenu *menu = 0;
      //This determines which menu the current MenuItem belongs to.
      switch (mCommandMenuItem[i]->category) {
         case fileMenu:
            menu = mFileMenu;
            break;
         case editMenu:
            menu = mEditMenu;
            break;
         case viewMenu:
            menu = mViewMenu;
            break;
         case projectMenu:
            menu = mProjectMenu;
            break;
         case helpMenu:
            menu = mHelpMenu;
            break;
         default:
    
            // ERROR -- should not happen
            break;
      }

      //BG: Tokenize menu shortcuts
      TokenizeCommandStrings(i);

      wxString menuString = mCommandMenuItem[i]->commandString;

      //BG: Pick first shortcut
      wxStringTokenizer tName(mCommandMenuItem[i]->comboStrings, ":");
      if(tName.HasMoreTokens())
      {
          wxString token = tName.GetNextToken();
          menuString += "\t" + token;
      }

      const wxString dummy = "";

      //This adds an element of the correct type:
      switch(mCommandMenuItem[i]->type) {
      case typeSeparator:

         menu->AppendSeparator();

         break;
      
      case typeNormal:

         menu->Append(i + MenuBaseID, menuString);
         break;
      case typeCheckItem:
         menu->Append(i + MenuBaseID,(const wxString &) menuString, dummy,true);
         //menu->AppendCheckItem() can be used with wxWindows 2.3
         //menu->AppendCheckItem(i + MenuBaseID,(const wxString &) mCommandMenuItem[i]->commandString, dummy);
         break;
      case typeRadioItem:
         //This can't be done until wxWindows 2.3
         //menu->AppendRadioItem(i + MenuBaseID,(const wxString &) mCommandMenuItem[i]->commandString, dummy);
         //Put in a normal item instead.
         menu->Append(i + MenuBaseID, menuString);
         break;
      default:
         //Error--this shouldn't happen
         break;
      }
   }


   int numEffects = Effect::GetNumEffects(false);
   int fi;
   for (fi = 0; fi < numEffects; fi++)
      mEffectMenu->Append(FirstEffectID + fi,
                          (Effect::GetEffect(fi, false))->GetEffectName());


 #if defined __WXGTK__


   //STM: only put MAX_NUMBER_OF_PLUGINS_IN_MENU in the menu.  If
   //there are more, split into multiple submenus.

   int numPlugins = Effect::GetNumEffects(true);

   if( numPlugins <= MAX_NUMBER_OF_PLUGINS_IN_MENU) {
      for (fi = 0; fi < numPlugins; fi++)
         mPluginMenu->Append(FirstPluginID + fi,
                             (Effect::GetEffect(fi, true))->GetEffectName());
   }
   else {
      //There are more than MAX_NUMBER_OF_PLUGINS_IN_MENU plugins: make submenus
      
 
      wxMenu * tmp;
      wxString label;
      tmp = new wxMenu;
      int lower,upper, submenu;
      
      lower = 1;
      upper = MAX_NUMBER_OF_PLUGINS_IN_MENU;
      submenu=0;
      for (fi = 0; fi < numPlugins; fi++){
  
         tmp->Append(FirstPluginID + fi,
                     (Effect::GetEffect(fi, true))->GetEffectName());
    
         //
         if( (fi+1) % MAX_NUMBER_OF_PLUGINS_IN_MENU == 0
             ||  fi == (numPlugins - 1)) {
            
            
            upper = fi +1;   //upper limit should be the current plugin number (+1)
            label =  wxString::Format(_("Plugins %d to %d"), lower, upper);  //make submenu label
            mPluginMenu->Append(FirstPluginSubMenuID + submenu, label, tmp , label);   //Add submenu
            submenu++;                                          //Increment submenu counter

            lower += MAX_NUMBER_OF_PLUGINS_IN_MENU;              //reset lower for next time.
            if(fi != (numPlugins -1))
               tmp= new wxMenu;                                 //reset temp. menu
         }

      }
   }


#else

  int numPlugins = Effect::GetNumEffects(true);
   for (fi = 0; fi < numPlugins; fi++)
      mPluginMenu->Append(FirstPluginID + fi,
                          (Effect::GetEffect(fi, true))->GetEffectName());
#endif
  

#ifdef __WXMAC__
   wxApp::s_macAboutMenuItemId = AboutID;
#endif

   mInsertSilenceAmount = 1.0;
}
Ejemplo n.º 5
0
AliEmcalParticleMaker* AddTaskEmcalParticleMaker(
  const char *tracksName          = "PicoTracks",
  const char *clustersName        = 0,
  const char *tracksOutName       = "EmcalTracks",
  const char *clustersOutName     = "EmcalClusters",
  const char *taskName            = "AliEmcalParticleMaker"
)
{  
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskEmcalParticleMaker", "No analysis manager to connect to.");
    return NULL;
  }  
  
  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  AliVEventHandler *evhand = mgr->GetInputEventHandler();
  if (!evhand) {
    ::Error("AddTaskEmcalParticleMaker", "This task requires an input event handler");
    return NULL;
  }

  TString clusName(clustersName);
  if (!clustersName) {
    if (evhand->InheritsFrom("AliESDInputHandler")) {
      ::Info("AddTaskEmcalParticleMaker", "ESD analysis, clustersName = \"CaloClusters\"");
      clusName = "CaloClusters";
    } else {
      ::Info("AddTaskEmcalParticleMaker", "AOD analysis, clustersName = \"caloClusters\"");
      clusName = "caloClusters";
    }
  }
  
  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------
  TString toName(tracksOutName);
  if (!toName.EndsWith(tracksName)) {
    toName += "_";
    toName +=tracksName;
  }
  TString coName(clustersOutName);
  if (!coName.EndsWith(clusName)) {
    coName += "_";
    coName += clusName;
  }
  TString tName(taskName);
  tName += "_";
  tName += toName;
  tName += "_";
  tName += coName;

  AliEmcalParticleMaker *eTask = new AliEmcalParticleMaker(tName);
  eTask->AddParticleContainer(tracksName);
  eTask->AddClusterContainer(clusName);
  eTask->SetTracksOutName(toName);
  eTask->SetClusOutName(coName);

  //-------------------------------------------------------
  // Final settings, pass to manager and set the containers
  //-------------------------------------------------------
  mgr->AddTask(eTask);
  
  // Create containers for input/output
  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
  mgr->ConnectInput(eTask, 0, cinput1);
  
  return eTask;
}
Ejemplo n.º 6
0
int main(){
	Label lTitle(20);
	lTitle.setValue("    Student Form");
	lTitle.setBorder(BorderType::Double);
	lTitle.setForeground(Color::Purple);
	Label lName(10);
	lName.setValue("Name:");
	lName.setBorder(BorderType::Single);
	Label lAddress(10);
	lAddress.setValue("Address:");
	lAddress.setBorder(BorderType::Single);
	Label lCountry(18);
	lCountry.setValue("Counrty:");
	lCountry.setBorder(BorderType::Single);
	Label lSex(10);
	lSex.setValue("Gender:");
	lSex.setBorder(BorderType::Single);
	Label lInterests(10);
	lInterests.setValue("Interests:");
	lInterests.setBorder(BorderType::Single);
	Label lAge(15);
	lAge.setValue("Age:");
	lAge.setBorder(BorderType::Single);
	TextBox tName(30);
	tName.setValue("Sherlock Holmes");
	tName.setBorder(BorderType::Double);
	TextBox tAddress(30);
	tAddress.setValue("221B Baker Street, London");
	tAddress.setBorder(BorderType::Double);
	Combox cCountry(18, { "Israel", "Great Britain", "United States" });
	cCountry.setSelectedIndex(1);
	cCountry.setBorder(BorderType::Double);
	RadioList rSex(2, 10, { "Male", "Female" });
	rSex.setBorder(BorderType::Double);
	CheckList clInterests(3, 10, { "Sports", "Books", "Movies" });
	clInterests.selectIndex(1);
	clInterests.selectIndex(2);
	auto v = clInterests.getSelectedIndices();
	cCountry.getSelectedIndex();
	clInterests.setBorder(BorderType::Double);
	NumericBox nAge(15, 18, 120);
	nAge.setValue(23);
	nAge.setBorder(BorderType::Double);
	Button bSubmit(13);
	bSubmit.setValue("   Submit");
	bSubmit.setBorder(BorderType::Double);
	Button bExit(13);
	bExit.setValue("    Exit");
	bExit.setBorder(BorderType::Double);
	Messagebox msg(10, 35);
	Panel main(26,75);
	main.setBackground(Color::Cyan);
	main.setForeground(Color::White);
	main.setBorder(BorderType::Double);
	main.addControl(lTitle, (main.getWidth() - lTitle.getWidth()) / 2, 2);
	main.addControl(lName, 13, 6);
	main.addControl(lAddress, 13, 10);
	main.addControl(lCountry, 3, 14);
	main.addControl(lSex, 26, 14);
	main.addControl(lInterests, 41, 14);
	main.addControl(lAge, 57, 14);
	main.addControl(tName, 27, 6);
	main.addControl(tAddress, 27, 10);
	main.addControl(cCountry, 3, 18);
	main.addControl(rSex, 26, 18);
	main.addControl(clInterests, 41, 18);
	main.addControl(nAge, 57, 18);
	main.addControl(bSubmit, (main.getWidth()*1/4) , 24);
	main.addControl(bExit, (main.getWidth() * 3 / 5), 24);
	main.addControl(msg, (main.getWidth()-msg.getWidth())/2, 10);
	bSubmit.addListener(e, &msg);
	Control::setFocus(tName);
	auto engine = EventEngine::getEngine();
	auto eStop = [&](Control* c) {engine.stop(); };
	bExit.addListener(eStop, nullptr);
	engine.run(main);
	return 0;
}