예제 #1
0
Trigger* SimpleActionData::trigger()
{
    if( triggers() == 0 || triggers()->isEmpty() )
        return NULL;

    return triggers()->first();
}
예제 #2
0
/*!
    Returns a deep-copied clone of the QUmlProtocolTransition.
*/
QModelingElement *QUmlProtocolTransition::clone() const
{
    QUmlProtocolTransition *c = new QUmlProtocolTransition;
    c->asQModelingObject()->setObjectName(this->asQModelingObject()->objectName());
    c->asQModelingObject()->setProperty("role", this->asQModelingObject()->property("role"));
    foreach (QUmlComment *element, ownedComments())
        c->addOwnedComment(dynamic_cast<QUmlComment *>(element->clone()));
    c->setName(name());
    if (nameExpression())
        c->setNameExpression(dynamic_cast<QUmlStringExpression *>(nameExpression()->clone()));
    c->setVisibility(visibility());
    c->setLeaf(isLeaf());
    foreach (QUmlElementImport *element, elementImports())
        c->addElementImport(dynamic_cast<QUmlElementImport *>(element->clone()));
    foreach (QUmlConstraint *element, ownedRules())
        c->addOwnedRule(dynamic_cast<QUmlConstraint *>(element->clone()));
    foreach (QUmlPackageImport *element, packageImports())
        c->addPackageImport(dynamic_cast<QUmlPackageImport *>(element->clone()));
    if (effect())
        c->setEffect(dynamic_cast<QUmlBehavior *>(effect()->clone()));
    if (guard())
        c->setGuard(dynamic_cast<QUmlConstraint *>(guard()->clone()));
    c->setKind(kind());
    foreach (QUmlTrigger *element, triggers())
        c->addTrigger(dynamic_cast<QUmlTrigger *>(element->clone()));
    if (postCondition())
        c->setPostCondition(dynamic_cast<QUmlConstraint *>(postCondition()->clone()));
    if (preCondition())
        c->setPreCondition(dynamic_cast<QUmlConstraint *>(preCondition()->clone()));
    return c;
}
예제 #3
0
QCodeCompletionEngine * CCompletion::clone()
{
    CCompletion *e = new CCompletion();

    foreach ( QString t, triggers() )
        e->addTrigger(t);

    emit cloned(e);

    return e;
}
예제 #4
0
bool Game_Player::CheckActionEvent() {
	if (InAirship())
		return false;
	int triggers_here[] = { 0 };
	std::vector<int> triggers(triggers_here, triggers_here + sizeof triggers_here / sizeof(int));

	if ( CheckEventTriggerHere(triggers) ) {
		return true;
	}

	int triggers_there[] = { 0, 1, 2 };
	triggers.assign(triggers_there, triggers_there + sizeof triggers_there / sizeof(int));

	return CheckEventTriggerThere(triggers);

}
예제 #5
0
const Event& NTupleEventReader::getNextEvent() {
    currentEvent = Event();
    selectNextNtupleEvent();

    boost::shared_ptr<std::vector<int> > triggers(new std::vector<int>());

    for(unsigned int i = 0; i < hltReader->size(); i++){
        triggers->push_back(hltReader->getIntVariableAt(i));
    }

    currentEvent.setDataType(getDataType(getCurrentFile()));
    currentEvent.setHLTs(triggers);
    currentEvent.setVertices(vertexReader->getVertices());

    if(NTupleEventReader::loadTracks)
        currentEvent.setTracks(trackReader->getTracks());
    currentEvent.setElectrons(electronReader->getElectrons());
    // currentEvent.setLoosePFElectrons(loosePFelectronReader->getElectrons());

    if(!currentEvent.isRealData()) {
			// GenParticles not currently available
    	currentEvent.setGenParticles(genParticleReader->getGenParticles());
    	currentEvent.setGenJets(genJetReader->getGenJets());
        currentEvent.setGenNumberOfPileUpVertices(PileupInfoReader->getVariable());
    }

    currentEvent.setJets(jetReader->getJets());
    currentEvent.setMuons(muonReader->getMuons());
    currentEvent.setMET(metReader->getMET());
    currentEvent.setRunNumber(runNumberReader->getVariable());
    currentEvent.setEventNumber(eventNumberReader->getVariable());
    currentEvent.setLocalEventNumber(currentEventEntry);
    currentEvent.setLumiBlock(lumiBlockReader->getVariable());
    currentEvent.setBeamScrapingVeto(false);

    return currentEvent;
}
예제 #6
0
void ActionData::doEnable()
    {
    triggers()->enable();
    update_triggers();
    }
예제 #7
0
void ActionData::doDisable()
    {
    triggers()->disable();
    update_triggers();
    }
예제 #8
0
파일: app.cpp 프로젝트: Greentwip/Windy
void windy::app::on_assets_delete_pressed(nana::menu::item_proxy& ip) {
			
	if (this->_instance_creator->items().size() > 0) {

		switch (this->_instance_creator->category()) {
			case layer::kind::graphicable: {
				// references from graphicables and nuke 
				{
					for (auto item : this->_instance_creator->items()) {

						for (auto instance : item->instances()) {
							this->_environment->project()->remove(instance);
						}

						auto sprite =
							std::dynamic_pointer_cast<content::sprite>(item);

						this->_environment->project()->remove_sprite(sprite);
					}
				}

			}
			break;

			case layer::kind::groupable: {
				for (auto item : this->_instance_creator->items()) {

					// references from compositions and nuke if single-animation remains
					{
						auto compositions = 
						this->_environment->project()->assets()->collection()->
							get(layer::kind::compositable);

						std::vector <std::shared_ptr<content::composition> >
							compositions_nuked;

						for (auto composition_item : compositions) {
							auto composition = 
								std::dynamic_pointer_cast<content::composition>
								(composition_item);

							auto& instances = composition->instances();

							for (auto instance : instances) {
								auto compositable = 
									std::dynamic_pointer_cast
									<content::compositable>(instance);

								std::vector<std::shared_ptr<content::groupable> > 
									groupables_nuked;

								for (auto child : compositable->children()) {
									auto groupable = 
										std::dynamic_pointer_cast
										<content::groupable>(child);

									if (groupable->asset_uuid() == item->uuid()) {
										groupables_nuked.push_back(groupable);
										this->_environment->project()->assets()->
											collection()->remove(groupable);
									}

								}

								for (auto nuked : groupables_nuked) {
									auto& children = compositable->children();
									auto it = std::find(children.begin(), 
														children.end(),
														nuked);

									children.erase(it);
								}

							}

							composition->unmap(item);

							if (composition->maps().empty()) {
								compositions_nuked.push_back(composition);
							}
							
						}

						for (auto composition : compositions_nuked) {
							for (auto instance : composition->instances()) {
								this->_environment->project()->remove(instance);
							}

							this->_environment->project()->remove_composition(composition);
						}
					}
						
					// nuke timeline triggers 
					{

						for (auto instance : item->instances()) {
							auto groupable =
								std::dynamic_pointer_cast<content::groupable> (instance);

							for (auto trigger : groupable->triggers()) {
								this->_environment->timeline()->remove_trigger(trigger);
							}

						}

					}

					// references from groupables and nuke 

					{
						auto instances = item->instances(); // copy by reference to store the instances

						for (auto instance : instances) {
							this->_environment->project()->remove(instance);
						}

						auto group = std::dynamic_pointer_cast<content::group>(item);

						this->_environment->project()->remove_group(group);

					}
				}
			}
			break;

			case layer::kind::compositable: {
				// references from compositables and nuke 
				{
					for (auto item : this->_instance_creator->items()) {

						for (auto instance : item->instances()) {
							this->_environment->project()->remove(instance);
						}

						auto composition = 
							std::dynamic_pointer_cast<content::composition>(item);

						this->_environment->project()->remove_composition(composition);
					}
				}

			}
			break;

		}

		// refresh
		{
			this->_environment->project()->assets()->refresh();

//			this->_selection_targets.clear();

			this->_environment->edition()->refresh(this->_environment->project()->game()->container());

			this->_environment->properties()->clear();

			this->_environment->trigger_recalculation();
		}

	} else  {
		nana::msgbox error(this->handle(),
							L"Error");

		error << L"Please select one or more assets first.";

		error.show();
	}

}
예제 #9
0
const Event& NTupleEventReader::getNextEvent() {
    currentEvent = Event();
    selectNextNtupleEvent();
///    cout << "End of evtchain? " << evtchain->atEnd() << endl;

///    cout << "Opening BNevent\n";
    fwlite::Handle<BNeventCollection> h_event;
    h_event.getByLabel(*evtchain,"BNproducer");
    const BNevent *const evtstruc = &h_event->at(0);

    boost::shared_ptr<std::vector<int> > triggers(new std::vector<int>());
    boost::shared_ptr<std::vector<std::string> > trignames(new std::vector<std::string>());
    boost::shared_ptr<std::vector<int> > prescales(new std::vector<int>());

    fwlite::Handle<BNtriggerCollection> h_trig;
    h_trig.getByLabel(*evtchain,"BNproducer","HLT");

    for(unsigned int i = 0; i < h_trig->size(); i++){
       const BNtrigger *const trigstruc = &h_trig->at(i);
       triggers->push_back(trigstruc->pass);
       if( evtstruc->run != currentRunNumber ){ // menu can only change between runs 
           trignames->push_back(trigstruc->name);
           prescales->push_back(trigstruc->prescale);
       }
    }
    if( evtstruc->run != currentRunNumber ){ // menu can only change between runs 
       currentTrigger->resynch(trignames, prescales);
       currentRunNumber = evtstruc->run;
    }
    currentTrigger->setHLTs(triggers);
    currentEvent.setHLT(currentTrigger);

    currentEvent.setDataType(getDataType(getCurrentFile()));
    currentEvent.setVertices(vertexReader->getVertices(evtchain));

    if(NTupleEventReader::loadTracks)
        currentEvent.setTracks(trackReader->getTracks(evtchain));
    currentEvent.setElectrons(electronReader->getElectrons(evtchain));
    // currentEvent.setLoosePFElectrons(loosePFelectronReader->getElectrons());

    if(!currentEvent.isRealData()) {
    	currentEvent.setGenParticles(genParticleReader->getGenParticles(evtchain));
    	currentEvent.setGenJets(genJetReader->getGenJets(evtchain));
	currentEvent.setGenNumberOfPileUpVertices(evtstruc->numGenPV);
	currentEvent.setTrueNumberOfPileUpVertices(evtstruc->numTruePV);
			boost::shared_ptr<std::vector<double> > pdfWts(new std::vector<double>());
//			for(unsigned int i = 0; i < pdfWtReader->size(); i++)
//					pdfWts->push_back(pdfWtReader->getVariableAt(i));
/*
if( useLHAPDF ){
                        double w0 = 1.0;
                        for(int i=0; i <=44; ++i){
                            LHAPDF::usePDFMember(1,i);
                            double xpdf1 = LHAPDF::xfx(1, evtstruc->x1, evtstruc->qScale, evtstruc->id1);
                            double xpdf2 = LHAPDF::xfx(1, evtstruc->x2, evtstruc->qScale, evtstruc->id2);
                            double weight = 1.0;
                            if (i > 0) {
                                   weight = xpdf1 * xpdf2 / w0;
                                   pdfWts->push_back(weight);
                            } else w0 = xpdf1 * xpdf2;
//std::cout<<"x1="<<evtstruc->x1<<" x2="<<evtstruc->x2<<" qScale="<<evtstruc->qScale<<" id1="<<evtstruc->id1<<" id2="<<evtstruc->id2<<" PDF weight = "<<weight<<std::endl;
                        }

} else */ pdfWts->resize(44);
			currentEvent.setPDFWts(pdfWts);

    }
    currentEvent.setJets(jetReader->getJets(evtchain));
    currentEvent.setMuons(muonReader->getMuons(evtchain));
    currentEvent.setMET(metReader->getMET(evtchain));
    currentEvent.setRunNumber(evtstruc->run);
    currentEvent.setEventNumber(evtstruc->evt);
    currentEvent.setQ2Scales(evtstruc->Q2ScaleUpWgt,evtstruc->Q2ScaleDownWgt);
    currentEvent.setLocalEventNumber(currentEventEntry);
    currentEvent.setLumiBlock(evtstruc->lumi);
    currentEvent.setBeamScrapingVeto(false);

    return currentEvent;
}
예제 #10
0
void plotXsec(const TString xsecConfFile, const TString xSecKindString, 
	      const TString crossSectionSet="_fsrUnfGood"){

  // --------------------------------------------------------------
  //           Process input
  // --------------------------------------------------------------

  XSecInputFileMgr_t inpMgr;
  if (!inpMgr.Load(xsecConfFile)) {
    std::cout << "failed to load file <" << xsecConfFile << ">\n";
    return;
  }

  DYTools::TCrossSectionKind_t csKind=DYTools::_cs_None;
  if (xSecKindString.Contains("auto") ||
      xSecKindString.Contains("default")) {
    if (DYTools::study2D==1) csKind=DYTools::_cs_preFsrDetNorm;
    else csKind=DYTools::_cs_preFsrNorm;
  }
  else {
    csKind=DetermineCrossSectionKind(xSecKindString);  // auto-stop on failure
  }

  // --------------------------------------------------------------
  //           Prepare variables
  // --------------------------------------------------------------

  TGaxis::SetMaxDigits(3);
  CPlot::sOutDir = TString("plots_") + DYTools::analysisTag +
    TString("_") + inpMgr.evtEffScaleTag();

  TriggerSelection triggers(inpMgr.triggerSetName(),true,0);
  
  ComparisonPlot_t::TRatioType_t ratio=
      ComparisonPlot_t::_ratioPlain;  //   #1/#2
    //ComparisonPlot_t::_ratioRel;  //   (#1-#2)/#1
  TString ratioYLabel=(ratio==ComparisonPlot_t::_ratioPlain) ?
    "data/theory" : "(th-dt)/th";
  if (DYTools::study2D) {
    ratioYLabel=(ratio==ComparisonPlot_t::_ratioPlain) ?
      "theory/data" : "(dt-th)/dt";
  }

  ComparisonPlot_t compPlot(ratio, "check","",
    (DYTools::study2D) ? "rapidity |y|" : "m_{ee} [GeV]",
			    CrossSectionKindLongName(csKind),
			    ratioYLabel);

  //compPlot.SetRatioNdivisions(805);
  //compPlot.SetPrintValues(1);
  //compPlot.SetPrintRatios(1);
  compPlot.SetPrintRatioNames(1);

  int cWidth=600, cHeight=700;
  if (DYTools::study2D) {
    //double rdy=0.15; compPlot.SetRatioYRange(1-rdy,1+rdy);
    cWidth=400*(2+landscape); cHeight=400*(3-landscape);
  }
  else {
    compPlot.SetLogx(1);
    compPlot.SetLogy(1);
    //double rdy=0.15; compPlot.SetRatioYRange(1-rdy,1+rdy);
    cWidth=600; cHeight=700;
  }

  TString dataFName=TString("../root_files/") + 
    inpMgr.evtEffScaleTag() +
    crossSectionSet +
    TString("/xSec");
  if (!csPreFsr(csKind)) dataFName.Append("PostFsr");
  if (csInDET(csKind)) dataFName.Append("DET");
  dataFName.Append("_results_"); 
  dataFName.Append(DYTools::analysisTag);
  if (!csPreFsr(csKind)) dataFName.Append(triggers.triggerConditionsName());
  dataFName.Append(".root");
  

  // --------------------------------------------------------------
  //      Prepare plots
  // --------------------------------------------------------------

  TString canvasName=TString("cXsec_") + CrossSectionKindName(csKind) + 
    TString("_") + DYTools::analysisTag;
  TCanvas *canvas=MakeCanvas(canvasName,canvasName,cWidth,cHeight);


  std::vector<ComparisonPlot_t*> compPlotsV;
  //std::vector<TH1F*> dataHistos;
  std::vector<TH1F*> histos;

  if (DYTools::study2D) { // 2D

    compPlot.Prepare6Pads(canvas,landscape);

    vector<TLatex*> massLabels;
    prepareMassRanges(massLabels,0.55,0.17, kBlue+2);

    // 

    // data
    for (int i=0; i<6; ++i) {
      const int iM=i+1; // skip 1st mass bin
      ComparisonPlot_t *cp=new ComparisonPlot_t(compPlot,Form("compPlot_%d",i+1),"");
      compPlotsV.push_back(cp);
      std::vector<TH1F*> localHV;

      if ((csKind==DYTools::_cs_preFsrDet) || (csKind==DYTools::_cs_preFsrDetNorm)) {
	if (plot_theoryCT10) {
	  TH1F* hTh=readTh2D_CT10(csKind, iM);
	  hTh->SetMarkerStyle(27);
	  hTh->SetMarkerSize(0.8);
	  cp->AddHist1D(hTh,"CTEQ10W","L",kGreen+1,1,0,1);
	  histos.push_back(hTh);
	  localHV.push_back(hTh);
	}
	if (plot_theoryMSTW2008) {
	  TH1F* hTh=readTh2D_MSTW2008(csKind, iM);
	  hTh->SetMarkerStyle(24);
	  hTh->SetMarkerSize(0.8);
	  cp->AddHist1D(hTh,"MSTW2008","L",kBlue,1,0,1);
	  histos.push_back(hTh);
	  localHV.push_back(hTh);
	}
      }

      // data
      TH1F* hData=readData(triggers,csKind,iM,dataFName);
      histos.push_back(hData);
      localHV.push_back(hData);
      cp->AddHist1D(hData,"data","P",kBlack,1,0,1);
      cp->SetRefIdx(hData);

      for (unsigned int ii=0; ii<localHV.size(); ++ii) {
	localHV[ii]->GetYaxis()->SetTitleOffset(1.2);
      }

      // Plotting and beautifying
      int subpad=-1;
      cp->Draw6(canvas,landscape,i+1,false,"png",&subpad);
      canvas->cd(subpad);
      massLabels[iM]->Draw();
      if (i==2) {
	cp->AddTextCMSPreliminary();
	cp->AddTextLumi(0.55,0.27);
      }
    }

  }
  else { // 1D

    canvas->Divide(1,2);
    compPlot.PreparePads(canvas);

    // theory
    if ((csKind==DYTools::_cs_preFsr) || (csKind==DYTools::_cs_preFsrNorm)) {
      TH1F* hTh=readTh1D_MSTW2008(csKind);
      removeError(hTh);
      compPlot.AddHist1D(hTh,"NNLO, FEWZ+MSTW08","L",kBlue,1,0,0);
      compPlot.SkipInRatioPlots(hTh); // do not consider for ratios
      histos.push_back(hTh);
    }
    // theory: special set to calculate ratios
    if (csKind==DYTools::_cs_preFsrNorm) {
      int showLabel=-1;
      TString draw_opt=(showPoints) ? "P" : "P skip";
      TH1F* hTh=readTh1D_MSTW2008(csKind,"_NNLO","default",_th2011_nnlo);
      hTh->SetMarkerSize(0.8);
      compPlot.AddHist1D(hTh,"NNLO, FEWZ+MSTW08 (40bins)",draw_opt,kBlue,1,0,showLabel);
      compPlot.SetRefIdx(hTh); // use to calculate ratios
      histos.push_back(hTh);
    }

    // data 1D
    TH1F* hData=readData(triggers,csKind,-1, dataFName);
    histos.push_back(hData);
    compPlot.AddHist1D(hData,"data","P",kBlack,1,0,1);

  }


  for (unsigned int i=0; i<histos.size(); i++) {
    histos[i]->SetDirectory(0);
  }

  // --------------------------------------------------------------
  //      Plot
  // --------------------------------------------------------------

  if (DYTools::study2D) {
  }
  else { // 1D
    compPlot.Draw(canvas,false,"png");
    canvas->cd(1);
    compPlot.AddTextCMSPreliminary();
    compPlot.AddTextLumi(0.55,0.27);
  }

  canvas->Update();
  canvas->cd();
  SaveCanvas(canvas,canvas->GetName());
  
  return;
}
예제 #11
0
void Dbtc::initRecords() 
{
  void *p;
  // Records with dynamic sizes
  cacheRecord = (CacheRecord*)allocRecord("CacheRecord",
					  sizeof(CacheRecord), 
					  ccacheFilesize);

  apiConnectRecord = (ApiConnectRecord*)allocRecord("ApiConnectRecord",
						    sizeof(ApiConnectRecord),
						    capiConnectFilesize);

  for(unsigned i = 0; i<capiConnectFilesize; i++) {
    p = &apiConnectRecord[i];
    new (p) ApiConnectRecord(c_theFiredTriggerPool, 
			     c_theIndexOperationPool);
  }
  // Init all fired triggers
  DLFifoList<TcFiredTriggerData> triggers(c_theFiredTriggerPool);
  FiredTriggerPtr tptr;
  while (triggers.seizeLast(tptr) == true) {
    p= tptr.p;
    new (p) TcFiredTriggerData();
  }
  while (triggers.releaseFirst());

  /*
  // Init all index records
  ArrayList<TcIndexData> indexes(c_theIndexPool);
  TcIndexDataPtr iptr;
  while(indexes.seize(iptr) == true) {
    new (iptr.p) TcIndexData(c_theAttrInfoListPool);
  }
  indexes.release();
  */

  // Init all index operation records
  SLList<TcIndexOperation> indexOps(c_theIndexOperationPool);
  TcIndexOperationPtr ioptr;
  while (indexOps.seizeFirst(ioptr) == true) {
    p= ioptr.p;
    new (p) TcIndexOperation(); // TODO : Modify alloc size of c_theAttributeBufferPool
  }
  while (indexOps.releaseFirst());

  c_apiConTimer = (UintR*)allocRecord("ApiConTimer",
				      sizeof(UintR),
				      capiConnectFilesize);
  
  c_apiConTimer_line = (UintR*)allocRecord("ApiConTimer_line",
					   sizeof(UintR),
					   capiConnectFilesize);

  tcConnectRecord = (TcConnectRecord*)allocRecord("TcConnectRecord",
						  sizeof(TcConnectRecord),
						  ctcConnectFilesize);
  
  m_commitAckMarkerPool.setSize(2 * capiConnectFilesize);
  m_commitAckMarkerHash.setSize(1024);
  c_theCommitAckMarkerBufferPool.setSize(4 * capiConnectFilesize);

  hostRecord = (HostRecord*)allocRecord("HostRecord",
					sizeof(HostRecord),
					chostFilesize);

  tableRecord = (TableRecord*)allocRecord("TableRecord",
					  sizeof(TableRecord),
					  ctabrecFilesize);

  scanRecord = (ScanRecord*)allocRecord("ScanRecord",
					sizeof(ScanRecord),
					cscanrecFileSize);


  c_scan_frag_pool.setSize(cscanFragrecFileSize);
  {
    ScanFragRecPtr ptr;
    SLList<ScanFragRec> tmp(c_scan_frag_pool);
    while (tmp.seizeFirst(ptr)) {
      new (ptr.p) ScanFragRec();
    }
    while (tmp.releaseFirst());
  }

  while (indexOps.releaseFirst());
  
  gcpRecord = (GcpRecord*)allocRecord("GcpRecord",
				      sizeof(GcpRecord), 
				      cgcpFilesize);
  
}//Dbtc::initRecords()