Пример #1
0
int as::sea(int c,int e){
    if(c==e) return 0;
    int re=sea(c+1,e);
    if(!to[val[c]]){
        re++;
        memset(ce,0,sizeof(as));
        to[val[c]]=ce++;
    }
    re+=to[val[c]]->sea(c+1,e);
    return re;
}
Пример #2
0
int main(){
    freopen("jian.in","r",stdin);
    freopen("jian.out","w",stdout);
    scanf("%d%d",&n,&m);
    if(n<=5&&m<=10)
        sea(0,0);
    printf("%d\n",ans);
    fclose(stdin);
    fclose(stdout);
    return 0;
}
void main()
{
    clrscr();
    int op, a[20], n;
    cout<<"No of elements: ";
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        cout<<"Element "<<i+1<<": ";
        cin>>a[i];
    }
    char ans;
    do
    {
        clrscr();
        cout<<"1.	Traversing\n";
        cout<<"2.	Adding\n";
        cout<<"3.	Deleting\n";
        cout<<"4.	Sorting\n";
        cout<<"5.	Searching\n";
        cout<<"6.	Exit\n";
        cout<<"Give your option: ";
        cin>>op;
        switch(op)
        {
        case 1:
            trav(a,n);
            break;
        case 2:
            add(a,n);
            break;
        case 3:
            del(a,n);
            break;
        case 4:
            sort(a,n);
            break;
        case 5:
            sea(a,n);
            break;
        case 6:
            exit(0);
        }
        cout<<"\n\nContinue?(y/n) ";
        cin>>ans;
    } while(ans == 'y');
}
Пример #4
0
void sea(int c,int d){
    if(c==n-1){
        ji[c]=m-d;
        if(lock[d])
            return;
        for(int i=1;i<n;i++)
            if(!xy(i))
                return;
        ans++;
        return;
    }
    for(int i=0;i<=m-d;i++){
        int cl=(i+c+1)%n;
        if(lock[cl])
            continue;
        lock[cl]=1;
        ji[c]=i;
        sea(c+1,d+i);
        lock[cl]=0;
    }
}
Пример #5
0
void CrapPhoAnalysis(TString outputName="analysis"){

  // REMOVE THE LINE BELOW IF NOT RUNNING IN CMSSW ENVIRONMENT
  //gSystem->Load("libCondFormatsJetMETObjects.so");

  //gSystem->Load("../../SUSYPhotonAnalysis/SusyNtuplizer/macro/libSusyEvent.so");

  //gSystem->AddIncludePath("-I" + TString(gSystem->Getenv("CMSSW_RELEASE_BASE")) + "/src");

  // Analysis macro
  //gROOT->LoadMacro("SusyEventAnalyzer.cc+");

  //gSystem->AddIncludePath("-I /Users/dmason/play/photons/SUSYPhotonAnalysis/SusyNtuplizer/src");
  //gSystem->AddIncludePath("-I /Users/dmason/play/photons/Crap");

  //gSystem->Load("/Users/dmason/play/photons/SUSYPhotonAnalysis/SusyNtuplizer/src/SusyEvent.h+");
  gROOT->ProcessLine(".L ../SusyEvent.h+");
  gROOT->ProcessLine(".L ../Crap.h+");
  
  gROOT->ProcessLine(".L CrapPhoAnalysis.h+");


  gSystem->Load("../lib/libCrapPhoAnalysis.so");
  
  //gROOT->LoadMacro("CrapPhoAnalysis.cc++");

  // chain of inputs
  TChain chain("susyTree");
  //chain.Add("susyEvents.root");
  chain.Add("root://cmseos.fnal.gov//eos/uscms/store/user/lpcpjm/SusyNtuples/cms538v1/Run2012D-22Jan2013-v1/DoublePhoton/susyEvents_361_1_fC3.root");

  // Disabling unused branches will speed up the processing significantly, but risks inconsistencies if wrong trees are turned off.
  // Make sure you know what you are doing.
  // Especially be careful when producing a skim - disabled branches will not be copied.
  // You can either enable all branches, or have two Event objects (one for event selection with reduced branch configuration, and the
  // other for event copying with branches fully enabled).
  //chain.SetBranchStatus("*", 0);
  //chain.SetBranchStatus("runNumber", 1);
  //chain.SetBranchStatus("luminosityBlockNumber", 1);
  //chain.SetBranchStatus("eventNumber", 1);
  //chain.SetBranchStatus("isRealData", 1);
  //chain.SetBranchStatus("metFilterBit", 1);
  //chain.SetBranchStatus("rho", 1);
  //chain.SetBranchStatus("rho25", 1);
  //chain.SetBranchStatus("hlt*", 1);
  //chain.SetBranchStatus("vertices*", 1);
  //chain.SetBranchStatus("photons_photons*", 1);
  //chain.SetBranchStatus("muons_muons*", 1);
  //chain.SetBranchStatus("electrons_gsfElectrons*", 1);
  //chain.SetBranchStatus("pfJets_ak5*", 1);
  //chain.SetBranchStatus("met_pfType01CorrectedMet*", 1);
  //chain.SetBranchStatus("pfParticles*", 1);

  if(chain.LoadTree(0) != 0){
    cerr << "Error with input chain. Do the files exist?" << endl;
    return;
  }

  CrapPhoAnalysis sea(chain);

  sea.SetOutput(outputName);
  sea.SetLogFile("cout"); // set to a full path to a file to output log to a file
  sea.SetPrintInterval(1000);
  sea.SetPrintLevel(0);
  sea.AddHltName("HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50");
  sea.CopyEvents(true);
  sea.SetProcessNEvents(-1);

  TStopwatch ts;

  ts.Start();

  sea.Run();

  ts.Stop();

  std::cout << "RealTime : " << ts.RealTime()/60.0 << " minutes" << std::endl;
  std::cout << "CPUTime  : " << ts.CpuTime()/60.0 << " minutes" << std::endl;

}
Пример #6
0
void ana_1(TString outputName="analysis_SUSYSignal_1"){
   TChain chain("susyTree");//susyTree

  // REMOVE THE LINE BELOW IF NOT RUNNING IN CMSSW ENVIRONMENT
  gSystem->Load("libCondFormatsJetMETObjects.so");

  gSystem->Load("libSusyEvent.so");

  gSystem->AddIncludePath("-I" + TString(gSystem->Getenv("CMSSW_RELEASE_BASE")) + "/src");

  // Analysis macro
  gROOT->LoadMacro("SusyEventAnalyzer.cc+");
  //gSystem->Load("SusyEventAnalyzer_cc.so");

  // chain of inputs
  chain.Add("/eos/uscms/store/user/lpcpjm/SusyNtuples/cms538v1/SMS-T5gg_2J_mGl-800to950_mLSP-25to925_TuneZ2star_8TeV-madgraph-tauola_Summer12-START53_V19_FSIM_PU_S12/susyEvents_T5gg_800_125_119.root");
  


  // Disabling unused branches will speed up the processing significantly, but risks inconsistencies if wrong trees are turned off.
  // Make sure you know what you are doing.
  // Especially be careful when producing a skim - disabled branches will not be copied.
  // You can either enable all branches, or have two Event objects (one for event selection with reduced branch configuration, and the
  // other for event copying with branches fully enabled).
  chain.SetBranchStatus("*", 0);
  chain.SetBranchStatus("runNumber", 1);
  chain.SetBranchStatus("luminosityBlockNumber", 1);
  chain.SetBranchStatus("eventNumber", 1);
  chain.SetBranchStatus("isRealData", 1);
  chain.SetBranchStatus("metFilterBit", 1);
  chain.SetBranchStatus("rho", 1);
  chain.SetBranchStatus("rho25", 1);
  chain.SetBranchStatus("hlt*", 1);
  chain.SetBranchStatus("vertices*", 1);
  chain.SetBranchStatus("tracks*", 1);
  chain.SetBranchStatus("photons_photons*", 1);
  chain.SetBranchStatus("muons_muons*", 1);
  chain.SetBranchStatus("electrons_gsfElectrons*", 1);
  chain.SetBranchStatus("pfJets_ak5*", 1);
  //chain.SetBranchStatus("met_pfType01SysShiftCorrectedMet*", 1);
  //chain.SetBranchStatus("met_pfMet*", 1);// yutaro's idea on April 18, 2014
  chain.SetBranchStatus("met_pfType01CorrectedMet*", 1);// corrected from Yutaro's new code, commented out to check yutaro's idea on march 3, 2014, comment3d in on June 25, 2014 to get the fake rate
  //chain.SetBranchStatus("met_pfType1CorrectedMet*", 1);
  chain.SetBranchStatus("gridParams*", 1);

  if(chain.LoadTree(0) != 0){
    cerr << "Error with input chain. Do the files exist?" << endl;
    return;
  }

  SusyEventAnalyzer sea(chain);

  sea.SetOutput(outputName);
  sea.SetLogFile("cout"); // set to a full path to a file to output log to a file
  sea.SetPrintInterval(10000);
  sea.SetPrintLevel(0);
  //sea.AddHltName("HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50"); // uncomment if working with data
  //sea.AddHltName("HLT_Photon36_R9Id85_Photon22_R9Id85"); // adding new trigger to see if we are getting consistent result
  //sea.IncludeAJson(""); // put your favourite JSON
  sea.CopyEvents(false);
  sea.SetProcessNEvents(-1);

  TStopwatch ts;

  ts.Start();

  sea.Run();

  ts.Stop();

  std::cout << "RealTime : " << ts.RealTime()/60.0 << " minutes" << std::endl;
  std::cout << "CPUTime  : " << ts.CpuTime()/60.0 << " minutes" << std::endl;

}
Пример #7
0
	void SDL_Window::_handleSDLKeyEvent(Window::KeyEventType type, SDL_Keycode keysym, unsigned int unicode)
	{
		april::Key akeysym = AK_UNKNOWN;
	
		#define _s2a(sdlk, ak) case sdlk: akeysym = ak; break; 
		#define _s2a_u0(sdlk, ak) case sdlk: akeysym = ak; unicode = 0; break;
		#define s2a(sdlk, ak) _s2a(SDLK_ ## sdlk, AK_ ## ak)
		#define s2a_u0(sdlk, ak) _s2a_u0(SDLK_ ## sdlk, AK_ ## ak)
		#define sea(key) s2a(key, key)
		#define sea_u0(key) s2a_u0(key, key)
		
		switch (keysym)
		{
			// control character keys
			s2a(BACKSPACE, BACK);
#ifdef __APPLE__
			s2a_u0(DELETE, DELETE);
#else
		case SDLK_DELETE:
			akeysym = AK_DELETE; //sea(DELETE);
#endif
			sea(TAB)
			sea(RETURN);
			s2a(KP_ENTER, RETURN);
			
			// control keys above cursor keys
			s2a(PAGEUP, PRIOR);
			s2a(PAGEDOWN, NEXT);
			sea(HOME);
			sea(END);
			sea(INSERT);
			// delete already defined under control chars
			// this is because on mac sdl, delete == backspace
			// for some reason
			
			// cursor keys
			sea_u0(LEFT);
			sea_u0(RIGHT);
			sea_u0(UP);
			sea_u0(DOWN);
			
			// space
			sea(SPACE);
			
			// function keys
			sea_u0(F1);
			sea_u0(F2);
			sea_u0(F3);
			sea_u0(F4);
			sea_u0(F5);
			sea_u0(F6);
			sea_u0(F7);
			sea_u0(F8);
			sea_u0(F9);
			sea_u0(F10);
			sea_u0(F11);
			sea_u0(F12);
			s2a(ESCAPE, ESCAPE);

			// keypad keys
			s2a(KP_0, NUMPAD0);
			s2a(KP_1, NUMPAD1);
			s2a(KP_2, NUMPAD2);
			s2a(KP_3, NUMPAD3);
			s2a(KP_4, NUMPAD4);
			s2a(KP_5, NUMPAD5);
			s2a(KP_6, NUMPAD6);
			s2a(KP_7, NUMPAD7);
			s2a(KP_8, NUMPAD8);
			s2a(KP_9, NUMPAD9);
			
			s2a(LCTRL, LCONTROL);
			s2a(RCTRL, RCONTROL);
			s2a(LALT, LMENU);
			s2a(RALT, RMENU);
			s2a(LGUI, LCOMMAND); // TODO - check if this is ok in SDL 2
			s2a(RGUI, RCOMMAND); // TODO - check if this is ok in SDL 2
			s2a(LSHIFT, LSHIFT);
			s2a(RSHIFT, RSHIFT);

		default:
			break;
		}
		// number keys
		if (keysym >= '0' && keysym <= '9')
		{
			akeysym = (Key)keysym;
		}
		// letters
		if (keysym >= 'a' && keysym <= 'z') // sdl letter keys are small ASCII letters
		{
			akeysym = (Key)(keysym - 32); // april letter keys are capital ASCII letters
		}
		if (akeysym == AK_LCONTROL || akeysym == AK_RCONTROL)
		{
			if (type == KEY_DOWN)
			{
				this->scrollHorizontal = true;
			}
			else if (type == KEY_UP)
			{
				this->scrollHorizontal = false;
			}
		}
		Window::handleKeyEvent(type, akeysym, 0);
	}