void GuideInfoParser::parseEventInfo(int idx) { EventInfo info; info.setId(atoi(m_csvHelper.getData(idx, 1))); info.setEventName(m_csvHelper.getData(idx, 2)); info.setEventUserData(atoi(m_csvHelper.getData(idx, 3))); m_vecEvent.push_back(info); }
/// [11/19/2008 by Guanhua Yan. ] /// /// reads info from input file <Time> <EntityID> <ServiceAddr> /// <InfoType> <info data .....> without any time constraints. Open a /// file and then read all infos. ///≈ void InfoManager::readFullDataFile(const std::string& infoFiles ) { assert(false); /// these variables should be static because they will be reused may times static const Control::LpPtrMap& lpMap = Control::getLpPtrMap(); SMART_ASSERT( lpMap.begin() != lpMap.end() ); SMART_ASSERT( lpMap.begin()->second ); static const LP& lp = *(lpMap.begin()->second); // get address of ANY lp on this computer node Time now = lp.getNow(); #ifdef DEBUG Logger::debug3() << "InfoManager: in readFullDataFile at time " << now << ", infoFiles= " << infoFiles << endl; #endif stringstream sstr; sstr << infoFiles; string fileName; // for each file, setup a reader while( sstr >> fileName ) { InfoData::Reader reader(fileName); while ( reader.MoreData()) { InfoData data( reader.ReadData() ); // see if we will send the info: LPID lpId = theEntityManager().findEntityLpId( data.getEntityId() ); Control::LpPtrMap::const_iterator lpIter = lpMap.find(lpId); if( lpIter != lpMap.end() ) { // the destination resides on one of LPs in this Unix process // send the info: #ifdef DEBUG Logger::debug3() << "InfoManager: processing data: " << data << endl; #endif // get info object and fill it with data boost::shared_ptr<Input> input( fInputHandler.createInput( data.getClassType(), data.getProfileId(), data.getData() ) ); boost::shared_ptr<Info> info = boost::dynamic_pointer_cast<Info>(input); SMART_ASSERT( info ); /// the object MUST actually be a descendant of Info #ifdef DEBUG Logger::debug3() << "InfoManager: processing info: " << info << endl; #endif // set EventInfo parameters: EventInfo event; event.setTo( data.getEntityId(), data.getServiceAddress() ); event.setDelay( max (LOCAL_MINDELAY, data.getTime() - now )); event.setInfo( info ); // send it off directly to the right LP LP* lpPointer = lpIter->second; SMART_ASSERT( lpPointer ); lpPointer->sendEventInfo(event); } // else don't schedule it, other Unix process will } // while(MoreData) } }
void Entity::processOutgoingInfo(const boost::shared_ptr<const Info> info, const Time& delay, const EntityID& dest, const ServiceAddress& serv) const { if(Control::getSimPhase() != Control::kPhaseRun) { Logger::failure("Entity::processOutgoingInfo(): simulation not running!"); } EventInfo event; event.setTo(dest, serv); event.setDelay(delay); event.setInfo(info); // send it off fLP.sendEventInfo( event ); }
bool PicItem::mouseReleaseEvent( const EventInfo &info ) { QMouseEvent *e = info.mouseReleaseEvent( 0, 0 ); if ( !m_pressed ) { delete e; return CNItem::mouseReleaseEvent( info ); } const PinItemList::iterator end = m_pinItemList.end(); for ( PinItemList::iterator it = m_pinItemList.begin(); it != end; ++it ) if ( !e->isAccepted() ) { continue; } else if ( (*it)->boundingRect().contains(m_pos) && (*it)->boundingRect().contains( info.pos ) ) { if ( m_dragged ) { (*it)->dragged( m_dx ); } else { (*it)->switchState(); } m_pressed = false; m_dragged = false; m_pos = QPoint(); m_dx = 0; delete e; return true; } delete e; return CNItem::mouseReleaseEvent( info ); }
void TauAnalysisSelector::setupBranches(BranchManager& branchManager) { fEventInfo.setupBranches(branchManager); if(fIsEmbedded) { branchManager.book("weightGenerator", &fGeneratorWeight); fMuons.setupBranches(branchManager, isMC()); //fElectrons.setupBranches(branchManager, isMC()); fJets.setupBranches(branchManager); fGenTausEmbedded.setupBranches(branchManager); } fTaus.setupBranches(branchManager, isMC() && !fIsEmbedded); if(isMC()) fGenTaus.setupBranches(branchManager); if(!fPuWeightName.empty()) branchManager.book(fPuWeightName, &fPuWeight); branchManager.book("selectedPrimaryVertex_count", &fSelectedVertexCount); branchManager.book("goodPrimaryVertex_count", &fVertexCount); if(fIsEmbedded) { branchManager.book("trigger_Mu40_eta2p1", &fMuTriggerPassed); } //branchManager.book("ElectronVetoPassed", &fElectronVetoPassed); }
EventInfo* EventInfo::AutoDeserialise(QDomNode* Reader) { EventInfo* info = NULL; if( Reader->nodeName() == "And" ) { info = (EventInfo*)new EventAndBlock(); info->Deserialise( Reader ); } else if( Reader->nodeName() == "Or" ) { info = (EventInfo*)new EventOrBlock(); info->Deserialise( Reader ); } else if( Reader->nodeName() == "Event" ) { info = (EventInfo*)new EventPlugInInfo(); info->Deserialise( Reader ); } return info; }
static void addSharedInfo( const EventInfo& event, VcfWriterSV::InfoTag_t& infoTags) { if (event.isEvent()) { infoTags.push_back( str(boost::format("EVENT=%i") % event.label)); } }
void InfoManager::createPyInfoFromInfoData( PyInfoData& data ) { static const Control::LpPtrMap& lpMap = Control::getLpPtrMap(); static const LP& lp = *(lpMap.begin()->second); // get address of ANY lp on this computer node Time now = lp.getNow(); // see if we will send the info: LPID lpId = theEntityManager().findEntityLpId( data.getEntityId() ); Control::LpPtrMap::const_iterator lpIter = lpMap.find(lpId); if( lpIter != lpMap.end() ) { // the destination resides on one of LPs in this Unix process // send the info: #ifdef DEBUG Logger::debug3() << "InfoManager: processing data: " << data << endl; #endif // get info object and fill it with data boost::shared_ptr<Input> input( fInputHandler.createInput( data.getClassType(), data.getProfileId(), data.getProfile(), data.getData() ) ); boost::shared_ptr<Info> info = boost::dynamic_pointer_cast<Info>(input); SMART_ASSERT( info ); /// the object MUST actually be a descendant of Info #ifdef DEBUG Logger::debug3() << "InfoManager: processing info: " << info << endl; #endif // set EventInfo parameters: EventInfo event; event.setTo( data.getEntityId(), data.getServiceAddress() ); if( data.getTime() < now ) Logger::warn() << "InfoManager: Sending event at time " << now << " which should have been sent at " << data.getTime() << " : Check if input is time sorted " << endl; event.setDelay( max (LOCAL_MINDELAY, data.getTime() - now )); event.setInfo( info ); // send it off directly to the right LP LP* lpPointer = lpIter->second; SMART_ASSERT( lpPointer ); lpPointer->sendEventInfo(event); } // else don't schedule it, other Unix process will }
void VcfWriterSomaticSV:: modifyInfo( const EventInfo& event, std::vector<std::string>& infotags) const { infotags.push_back("SOMATIC"); infotags.push_back( str(boost::format("SOMATICSCORE=%i") % getSomaticInfo().somaticScore) ); if (event.isEvent()) { infotags.push_back( str(boost::format("JUNCTION_SOMATICSCORE=%i") % getSingleJunctionSomaticInfo().somaticScore) ); } }
bool PicItem::mouseMoveEvent( const EventInfo &info ) { QMouseEvent *e = info.mouseMoveEvent( 0, 0 ); const PinItemList::iterator end = m_pinItemList.end(); for ( PinItemList::iterator it = m_pinItemList.begin(); it != end; ++it ) if ( e->isAccepted() && (*it)->boundingRect().contains( info.pos ) ) { QPoint vec = info.pos - m_pos; if ( m_pressed && vec.manhattanLength() > 4 ) { m_dragged = true; m_dx = vec.x(); } delete e; return true; } delete e; return CNItem::mouseMoveEvent( info ); }
bool PicItem::mousePressEvent( const EventInfo &info ) { QMouseEvent *e = info.mousePressEvent( 0, 0 ); const PinItemList::iterator end = m_pinItemList.end(); for ( PinItemList::iterator it = m_pinItemList.begin(); it != end; ++it ) if ( e->isAccepted() && (*it)->boundingRect().contains( info.pos ) ) { //reset mouse-gesture state m_pressed = true; m_pos = info.pos; m_dragged = false; m_dx = 0; delete e; return true; } m_pressed = false; delete e; return CNItem::mousePressEvent( info ); }
void MidiParser_SMF::parseNextEvent(EventInfo &info) { info.start = _position._play_pos; info.delta = readVLQ(_position._play_pos); // Process the next info. If mpMalformedPitchBends // was set, we must skip over any pitch bend events // because they are from Simon games and are not // real pitch bend events, they're just two-byte // prefixes before the real info. do { if ((_position._play_pos[0] & 0xF0) >= 0x80) info.event = *(_position._play_pos++); else info.event = _position._running_status; } while (_malformedPitchBends && (info.event & 0xF0) == 0xE0 && _position._play_pos++); if (info.event < 0x80) return; _position._running_status = info.event; switch (info.command()) { case 0x9: // Note On info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); if (info.basic.param2 == 0) info.event = info.channel() | 0x80; info.length = 0; break; case 0xC: case 0xD: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; break; case 0x8: case 0xA: case 0xB: case 0xE: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); info.length = 0; break; case 0xF: // System Common, Meta or SysEx event switch (info.event & 0x0F) { case 0x2: // Song Position Pointer info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); break; case 0x3: // Song Select info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; break; case 0x6: case 0x8: case 0xA: case 0xB: case 0xC: case 0xE: info.basic.param1 = info.basic.param2 = 0; break; case 0x0: // SysEx info.length = readVLQ(_position._play_pos); info.ext.data = _position._play_pos; _position._play_pos += info.length; break; case 0xF: // META event info.ext.type = *(_position._play_pos++); info.length = readVLQ(_position._play_pos); info.ext.data = _position._play_pos; _position._play_pos += info.length; break; default: warning("MidiParser_SMF::parseNextEvent: Unsupported event code %x", info.event); } } }
bool TauAnalysisSelector::process(Long64_t entry) { double weight = 1.0; if(!fPuWeightName.empty()) { weight *= fPuWeight->value(); } fEventCounter.setWeight(weight); cAll.increment(); if(fIsEmbedded) { weight *= fGeneratorWeight->value(); fEventCounter.setWeight(weight); } cGeneratorWeight.increment(); /* std::cout << "FOO Event " << fEventInfo.event() << ":" << fEventInfo.lumi() << ":" << fEventInfo.run() << " electronVeto passed? " << fElectronVetoPassed->value() << std::endl; if( (fEventInfo.event() == 10069461 && fEventInfo.lumi() == 33572) || (fEventInfo.event() == 10086951 && fEventInfo.lumi() == 33630) || (fEventInfo.event() == 101065527 && fEventInfo.lumi() == 336953) || (fEventInfo.event() == 101450418 && fEventInfo.lumi() == 338236) || (fEventInfo.event() == 101460111 && fEventInfo.lumi() == 338268) ) { std::cout << "BAR Event " << fEventInfo.event() << ":" << fEventInfo.lumi() << ":" << fEventInfo.run() << " electronVeto passed? " << fElectronVetoPassed->value() << " Nelectrons " << fElectrons.size() << std::endl; for(size_t i=0; i<fElectrons.size(); ++i) { ElectronCollection::Electron electron = fElectrons.get(i); std::cout << " Electron " << i << " pt " << electron.p4().Pt() << " eta " << electron.p4().Eta() << " hasGsfTrack " << electron.hasGsfTrack() << " hasSuperCluster " << electron.hasSuperCluster() << " supercluster eta " << electron.superClusterEta() << " passIdVeto " << electron.cutBasedIdVeto() << std::endl; } } if(!fElectronVetoPassed->value()) return false; cElectronVeto.increment(); */ // Tau BR if(fIsEmbedded && fEmbeddingNormalizationMode == kIDTriggerEfficiencyTauBR) { weight *= (1-0.357); // from my thesis, which took the numbers from PDG fEventCounter.setWeight(weight); } cTauBRWeight.increment(); // MC status std::vector<GenParticleCollection::GenParticle> genTaus; GenParticleCollection::GenParticle theGenTau; if(isMC()) { bool canContinue = true; if(fIsEmbedded) { canContinue = findGenTaus(fGenTausEmbedded, 2212, &genTaus); canContinue = canContinue && genTaus.size() != 0; } else canContinue = findGenTaus(fGenTaus, 6, &genTaus); if(!canContinue) return false; } cGenTauFound.increment(); if(isMC() && fMCTauMultiplicity != kMCTauNone) { size_t ntaus = genTaus.size(); if(fIsEmbedded) { std::vector<GenParticleCollection::GenParticle> genTausOrig; findGenTaus(fGenTaus, 6, &genTausOrig); ntaus = genTausOrig.size(); } if(fIsEmbedded) { // For embedded the embedded tau is counted as one if(fMCTauMultiplicity == kMCTauZeroTaus) return true; if(fMCTauMultiplicity == kMCTauOneTau && ntaus != 0) return true; if(fMCTauMultiplicity == kMCTauTwoTaus && ntaus != 1) return true; if(fMCTauMultiplicity == kMCTauMoreThanTwoTaus && ntaus < 2) return true; } else { if(fMCTauMultiplicity == kMCTauZeroTaus && ntaus != 0) return true; if(fMCTauMultiplicity == kMCTauOneTau && ntaus != 1) return true; if(fMCTauMultiplicity == kMCTauTwoTaus && ntaus != 2) return true; if(fMCTauMultiplicity == kMCTauMoreThanTwoTaus && ntaus < 3) return true; } if(genTaus.size() > 0) theGenTau = genTaus[0]; } cTauMCSelection.increment(); bool originalMuonIsWMu = false; EmbeddingMuonCollection::Muon embeddingMuon; if(fIsEmbedded) { if(fMuons.size() != 1) throw std::runtime_error("Embedding muon collection size is not 1"); embeddingMuon = fMuons.get(0); if(embeddingMuon.p4().Pt() < 41) return true; //std::cout << "Muon pt " << muon.p4().Pt() << std::endl; originalMuonIsWMu = std::abs(embeddingMuon.pdgId()) == 13 && std::abs(embeddingMuon.motherPdgId()) == 24 && std::abs(embeddingMuon.grandMotherPdgId()) == 6; if(!originalMuonIsWMu) return true; } cOnlyWMu.increment(); // Per-event correction for W->tau->mu if(fIsEmbedded && fEmbeddingWTauMuWeights) { embeddingMuon.ensureValidity(); int bin = fEmbeddingWTauMuWeights->FindBin(embeddingMuon.p4().Pt()); //std::cout << embeddingMuon.p4().Pt() << " " << bin << std::endl; weight *= fEmbeddingWTauMuWeights->GetBinContent(bin); fEventCounter.setWeight(weight); } cWTauMuWeight.increment(); // Muon trigger efficiency weighting if(fIsEmbedded && (fEmbeddingNormalizationMode == kIDTriggerEfficiency || fEmbeddingNormalizationMode == kIDTriggerEfficiencyTauBR)) { weight *= 1/embeddingMuon.triggerEfficiency(); fEventCounter.setWeight(weight); } cTriggerEffWeight.increment(); // Muon ID efficiency weighting if(fIsEmbedded) { weight *= 1/embeddingMuon.idEfficiency(); fEventCounter.setWeight(weight); } cIdEffWeight.increment(); // Weighting by arbitrary histogram, given in constructor argument if(fIsEmbedded && fEmbeddingMuonWeights) { embeddingMuon.ensureValidity(); int bin = fEmbeddingMuonWeights->FindFixBin(embeddingMuon.p4().Pt()); weight *= fEmbeddingMuonWeights->GetBinContent(bin); fEventCounter.setWeight(weight); } cMuonWeight.increment(); // Jet selection /* size_t njets = fJets.size(); size_t nselectedjets = 0; for(size_t i=0; i<njets; ++i) { JetCollection::Jet jet = fJets.get(i); // Clean selected muon from jet collection bool matches = false; double DR = ROOT::Math::VectorUtil::DeltaR(fMuons.get(0).p4(), jet.p4()); if(DR < 0.1) { matches = true; } if(matches) continue; // Count jets ++nselectedjets; } if(nselectedjets < 3) return true; */ cJetSelection.increment(); if(fSelectedVertexCount->value() <= 0) return true; cPrimaryVertex.increment(); std::vector<TauCollection::Tau> selectedTaus; std::vector<TauCollection::Tau> tmp; if(fTaus.size() < 1) return true; cAllTauCandidates.increment(); // Pre pT cut (for some reason in the region pT < 10 there is significantly more normal than embedded) for(size_t i=0; i<fTaus.size(); ++i) { TauCollection::Tau tau = fTaus.get(i); if(tau.p4().Pt() < 10) continue; if(!TauID::isolation(tau)) continue; //if(isMC() && !fIsEmbedded && tau.genMatchP4().Pt() <= 41) continue; // temporary hack selectedTaus.push_back(tau); if(!fIsEmbedded) break; // select only the first gen tau } if(selectedTaus.empty()) return true; cPrePtCut.increment(); // Decay mode finding bool atLeastOneIsolated = false; for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::decayModeFinding(tau)) continue; if(TauID::isolation(tau)) { atLeastOneIsolated = true; hTau_AfterDecayModeFindingIsolation.fill(tau.p4(), weight); } tmp.push_back(tau); } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cDecayModeFinding.increment(); if(atLeastOneIsolated) { if(theGenTau.isValid()) hGenTau_AfterDecayModeFindingIsolation.fill(theGenTau.p4(), weight); hVertexCount_AfterDecayModeFindingIsolation->Fill(fVertexCount->value(), weight); } // Eta cut atLeastOneIsolated = false; for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::eta(tau)) continue; if(TauID::isolation(tau)) { atLeastOneIsolated = true; hTau_AfterEtaCutIsolation.fill(tau.p4(), weight); } tmp.push_back(tau); } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cEtaCut.increment(); if(atLeastOneIsolated) { hGenTau_AfterEtaCutIsolation.fill(theGenTau.p4(), weight); hVertexCount_AfterEtaCutIsolation->Fill(fVertexCount->value(), weight); } // Pt cut atLeastOneIsolated = false; for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::pt(tau)) continue; if(TauID::isolation(tau)) { atLeastOneIsolated = true; hTau_AfterPtCutIsolation.fill(tau.p4(), weight); hTauLeadingTrackPt_AfterPtCutIsolation->Fill(tau.leadPFChargedHadrCandP4().Pt(), weight); } tmp.push_back(tau); } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cPtCut.increment(); if(atLeastOneIsolated) { hGenTau_AfterPtCutIsolation.fill(theGenTau.p4(), weight); hVertexCount_AfterPtCutIsolation->Fill(fVertexCount->value(), weight); } // Leading track pt atLeastOneIsolated = false; for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::leadingChargedHadrCandPt(tau)) continue; tmp.push_back(tau); if(TauID::isolation(tau)) { atLeastOneIsolated = true; hTau_AfterLeadingTrackPtCutIsolation.fill(tau.p4(), weight); } } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cLeadingTrackPtCut.increment(); if(atLeastOneIsolated) { hGenTau_AfterLeadingTrackPtCutIsolation.fill(theGenTau.p4(), weight); } // ECAL fiducial cuts for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::ecalCracks(tau)) continue; tmp.push_back(tau); } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cEcalCracks.increment(); for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::ecalGap(tau)) continue; tmp.push_back(tau); } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cEcalGap.increment(); // Against electron atLeastOneIsolated = false; for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::againstElectron(tau)) continue; tmp.push_back(tau); if(TauID::isolation(tau)) { atLeastOneIsolated = true; hTau_AfterAgainstElectronIsolation.fill(tau.p4(), weight); } } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cAgainstElectron.increment(); if(atLeastOneIsolated) { hGenTau_AfterAgainstElectronIsolation.fill(theGenTau.p4(), weight); } // Against muon atLeastOneIsolated = false; for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::againstMuon(tau)) continue; tmp.push_back(tau); if(TauID::isolation(tau)) { atLeastOneIsolated = true; hTau_AfterAgainstMuonIsolation.fill(tau.p4(), weight); } } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cAgainstMuon.increment(); if(atLeastOneIsolated) { hGenTau_AfterAgainstMuonIsolation.fill(theGenTau.p4(), weight); } // Tau candidate selection finished // Isolation for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::isolation(tau)) continue; int decayMode = tau.decayMode(); int fill = -1; if (decayMode <= 2) fill = decayMode; // 0 = pi+, 1 = pi+pi0, 2 = pi+pi0pi0 else if(decayMode == 10) fill = 3; // pi+pi-pi+ else fill = 4; // Other hTau_AfterIsolation.fill(tau.p4(), weight); hTauDecayModeAll_AfterIsolation->Fill(decayMode, weight); hTauDecayMode_AfterIsolation->Fill(fill, weight); tmp.push_back(tau); } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cIsolation.increment(); hVertexCount_AfterIsolation->Fill(fVertexCount->value(), weight); if(theGenTau.isValid()) hGenTau_AfterIsolation.fill(theGenTau.p4(), weight); // One prong for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::oneProng(tau)) continue; tmp.push_back(tau); hTau_AfterOneProng.fill(tau.p4(), weight); hTauP_AfterOneProng->Fill(tau.p4().P(), weight); hTauLeadingTrackPt_AfterOneProng->Fill(tau.leadPFChargedHadrCandP4().Pt(), weight); hTauLeadingTrackP_AfterOneProng->Fill(tau.leadPFChargedHadrCandP4().P(), weight); hTauRtau_AfterOneProng->Fill(tau.rtau(), weight); } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cOneProng.increment(); hGenTau_AfterOneProng.fill(theGenTau.p4(), weight); hVertexCount_AfterOneProng->Fill(fVertexCount->value(), weight); // Rtau for(size_t i=0; i<selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; if(!TauID::rtau(tau)) continue; hTau_AfterRtau.fill(tau.p4(), weight); tmp.push_back(tau); } selectedTaus.swap(tmp); tmp.clear(); if(selectedTaus.empty()) return true; cRtau.increment(); hVertexCount_AfterRtau->Fill(fVertexCount->value(), weight); if(theGenTau.isValid()) hGenTau_AfterRtau.fill(theGenTau.p4(), weight); // Tau ID finished // Trigger /* if(fIsEmbedded) { if(!fMuTriggerPassed->value()) return true; } */ cMuTrigger.increment(); if(false) { std::cout << "Event " << fEventInfo.event() << ":" << fEventInfo.lumi() << ":" << fEventInfo.run() << std::endl; for(size_t i=0; i< selectedTaus.size(); ++i) { TauCollection::Tau& tau = selectedTaus[i]; std::cout << " selected tau pt " << tau.p4().Pt() << " eta " << tau.p4().Eta() << " phi " << tau.p4().Phi() << std::endl; if(fIsEmbedded) { embeddingMuon.ensureValidity(); double DR = ROOT::Math::VectorUtil::DeltaR(tau.p4(), embeddingMuon.p4()); if(DR < 0.5) { std::cout << " matched to embedding muon, DR " << DR << std::endl; } } for(size_t j=0; j<fGenTaus.size(); ++j) { GenParticleCollection::GenParticle gen = fGenTaus.get(j); double DR = ROOT::Math::VectorUtil::DeltaR(tau.p4(), gen.p4()); if(DR < 0.5) { std::cout << " matched to generator tau, DR " << DR << " mother " << gen.motherPdgId() << " grandmother " << gen.grandMotherPdgId() << std::endl; } } } } return true; }
void MidiParser_S1D::parseNextEvent(EventInfo &info) { info.start = _position._play_pos; info.delta = _no_delta ? 0 : readVLQ2(_position._play_pos); _no_delta = false; info.event = *(_position._play_pos++); if (info.command() < 0x8) { _no_delta = true; info.event += 0x80; } switch (info.command()) { case 0x8: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; info.length = 0; break; case 0x9: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); // I'm ASSUMING this byte is velocity! info.length = 0; break; case 0xA: case 0xB: // I'm not sure what these are meant to do, or what the // parameter is. Elvira 1 needs them, though, and who am I to // argue with her? info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; break; case 0xC: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; ++_position._play_pos; // I have NO IDEA what the second byte is for. break; case 0xD: // Triggered by MOD0/MOD1/MOD2/MOD3/MOD4/MOD6/MOD7/MOD8/MOD9 in Elvira 2 // Triggered by MOD0/MOD2/MOD3/MOD5/MOD6/MOD7/MOD8/MOD9/MOD10/MOD12/MOD14/MOD15/MOD20 in Waxworks break; case 0xE: // Triggered by MOD9 in Elvira 1 // Triggered by MOD3/MOD5 in Elvira 2 // Triggered by MOD3/MOD7/MOD8/MOD13 in Waxworks break; case 0xF: switch (info.event & 0x0F) { case 0x0: // Trigged by MOD2/MOD6/MOD15 in Waxworks // Pure guesswork info.ext.type = *(_position._play_pos++); info.length = readVLQ(_position._play_pos); info.ext.data = _position._play_pos; break; case 0x3: // Not sure, Song Select? // Trigged by MOD1/MOD7/MOD10 in Elvira 1 info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; break; case 0x4: // Trigged by MOD8 in Elvira 1 break; case 0x7: // Trigged by MOD6 in Elvira 2 // Trigged by MOD5 in Waxworks break; case 0x8: // Not sure, ? // Trigged by MOD19 in Waxworks info.basic.param1 = info.basic.param2 = 0; break; case 0xA: // Trigged by MOD5 in Elvira 2 break; case 0xC: // This means End of Track. // Rewrite in SMF (MIDI transmission) form. info.event = 0xFF; info.ext.type = 0x2F; info.length = 0; break; case 0xF: // Not sure, META event? // Trigged by MOD8/MOD9/MOD11/MOD12/MOD13 in Waxworks info.ext.type = *(_position._play_pos++); info.length = readVLQ(_position._play_pos); info.ext.data = _position._play_pos; _position._play_pos += info.length; break; default: error("MidiParser_S1D: Unexpected type 0x%02X found", (int) info.event); break; } break; default: error("MidiParser_S1D: Unexpected event 0x%02X found", (int) info.command()); break; } }
void MidiParser_RO::parseNextEvent (EventInfo &info) { _markerCount += _lastMarkerCount; _lastMarkerCount = 0; info.delta = 0; do { info.start = _position._play_pos; info.event = *(_position._play_pos++); if (info.command() == 0xA) { ++_lastMarkerCount; info.event = 0xF0; } else if (info.event == 0xF0 || info.event == 0xF1) { byte delay = *(_position._play_pos++); info.delta += delay; if (info.event == 0xF1) { // This event is, as far as we have been able // to determine, only used in one single song // in EGA Loom. It seems to be meant for adding // values greater than 255 to info.delta. See // bug #1498785. info.delta += 256; } continue; } break; } while (true); // Seems to indicate EOT if (info.event == 0) { info.event = 0xFF; info.ext.type = 0x2F; info.length = 0; info.ext.data = 0; return; } if (info.event < 0x80) return; _position._running_status = info.event; switch (info.command()) { case 0xC: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; break; case 0x8: case 0x9: case 0xB: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); if (info.command() == 0x9 && info.basic.param2 == 0) info.event = info.channel() | 0x80; info.length = 0; break; case 0xF: // Marker and EOT messages info.length = 0; info.ext.data = 0; if (info.event == 0xFF) { _autoLoop = true; info.ext.type = 0x2F; } else { info.ext.type = 0x7F; // Bogus META } info.event = 0xFF; break; } }
void MidiParser_S1D::parseNextEvent(EventInfo &info) { info.start = _position._playPos; info.length = 0; info.delta = _noDelta ? 0 : readVLQ2(_position._playPos); _noDelta = false; info.event = *_position._playPos++; if (!(info.event & 0x80)) { _noDelta = true; info.event |= 0x80; } if (info.event == 0xFC) { // This means End of Track. // Rewrite in SMF (MIDI transmission) form. info.event = 0xFF; info.ext.type = 0x2F; } else { switch (info.command()) { case 0x8: // note off info.basic.param1 = *_position._playPos++; info.basic.param2 = 0; break; case 0x9: // note on info.basic.param1 = *_position._playPos++; info.basic.param2 = *_position._playPos++; // Rewrite note on events with velocity 0 as note off events. // This is the actual meaning of this, but theoretically this // should not need to be rewritten, since all MIDI devices should // interpret it like that. On the other hand all our MidiParser // implementations do it and there seems to be code in MidiParser // which relies on this for tracking active notes. if (info.basic.param2 == 0) { info.event = info.channel() | 0x80; } break; case 0xA: { // loop control // In case the stop mode(?) is set to 0x80 this will stop the // track over here. const int16 loopIterations = int8(*_position._playPos++); if (!loopIterations) { _loops[info.channel()].start = _position._playPos; } else { if (!_loops[info.channel()].timer) { if (_loops[info.channel()].start) { _loops[info.channel()].timer = uint16(loopIterations); _loops[info.channel()].end = _position._playPos; // Go to the start of the loop _position._playPos = _loops[info.channel()].start; } } else { if (_loops[info.channel()].timer) _position._playPos = _loops[info.channel()].start; --_loops[info.channel()].timer; } } // We need to read the next midi event here. Since we can not // safely pass this event to the MIDI event processing. chainEvent(info); } break; case 0xB: // auto stop marker(?) // In case the stop mode(?) is set to 0x80 this will stop the // track. // We need to read the next midi event here. Since we can not // safely pass this event to the MIDI event processing. chainEvent(info); break; case 0xC: // program change info.basic.param1 = *_position._playPos++; info.basic.param2 = 0; break; case 0xD: // jump to loop end if (_loops[info.channel()].end) _position._playPos = _loops[info.channel()].end; // We need to read the next midi event here. Since we can not // safely pass this event to the MIDI event processing. chainEvent(info); break; default: // The original called some other function from here, which seems // not to be MIDI related. warning("MidiParser_S1D: default case %d", info.channel()); // We need to read the next midi event here. Since we can not // safely pass this event to the MIDI event processing. chainEvent(info); break; } } }
void MidiParser_SH::parseNextEvent(EventInfo &info) { Common::StackLock lock(_mutex); // warning("parseNextEvent"); // there is no delta right at the start of the music data // this order is essential, otherwise notes will get delayed or even go missing if (_position._playPos != _tracks[0]) { info.delta = *(_position._playPos++); } else { info.delta = 0; } info.start = _position._playPos; info.event = *_position._playPos++; //warning("Event %x", info.event); _position._runningStatus = info.event; switch (info.command()) { case 0xC: { // program change int idx = *_position._playPos++; info.basic.param1 = idx & 0x7f; info.basic.param2 = 0; } break; case 0xD: info.basic.param1 = *_position._playPos++; info.basic.param2 = 0; break; case 0xB: info.basic.param1 = *_position._playPos++; info.basic.param2 = *_position._playPos++; info.length = 0; break; case 0x8: case 0x9: case 0xA: case 0xE: info.basic.param1 = *(_position._playPos++); info.basic.param2 = *(_position._playPos++); if (info.command() == 0x9 && info.basic.param2 == 0) { // NoteOn with param2==0 is a NoteOff info.event = info.channel() | 0x80; } info.length = 0; break; case 0xF: if (info.event == 0xFF) { error("SysEx META event 0xFF"); byte type = *(_position._playPos++); switch(type) { case 0x2F: // End of Track allNotesOff(); stopPlaying(); unloadMusic(); return; case 0x51: warning("TODO: 0xFF / 0x51"); return; default: warning("TODO: 0xFF / %x Unknown", type); break; } } else if (info.event == 0xFC) { // Official End-Of-Track signal debugC(kDebugLevelMusic, "Music: System META event 0xFC"); byte type = *(_position._playPos++); switch (type) { case 0x80: // end of track, triggers looping debugC(kDebugLevelMusic, "Music: META event triggered looping"); jumpToTick(0, true, true, false); break; case 0x81: // end of track, stop playing debugC(kDebugLevelMusic, "Music: META event triggered music stop"); stopPlaying(); unloadMusic(); break; default: error("MidiParser_SH::parseNextEvent: Unknown META event 0xFC type %x", type); break; } } else { warning("TODO: %x / Unknown", info.event); break; } break; default: warning("MidiParser_SH::parseNextEvent: Unsupported event code %x", info.event); break; }// switch (info.command()) }
void MidiParser_XMIDI::parseNextEvent(EventInfo &info) { info.start = _position._play_pos; info.delta = readVLQ2(_position._play_pos) - _inserted_delta; // Process the next event. _inserted_delta = 0; info.event = *(_position._play_pos++); switch (info.event >> 4) { case 0x9: // Note On info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); info.length = readVLQ(_position._play_pos); if (info.basic.param2 == 0) { info.event = info.channel() | 0x80; info.length = 0; } break; case 0xC: case 0xD: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; break; case 0x8: case 0xA: case 0xE: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); break; case 0xB: info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); // This isn't a full XMIDI implementation, but it should // hopefully be "good enough" for most things. switch (info.basic.param1) { // Simplified XMIDI looping. case 0x74: { // XMIDI_CONTROLLER_FOR_LOOP byte *pos = _position._play_pos; if (_loopCount < ARRAYSIZE(_loop) - 1) _loopCount++; else warning("XMIDI: Exceeding maximum loop count %d", ARRAYSIZE(_loop)); _loop[_loopCount].pos = pos; _loop[_loopCount].repeat = info.basic.param2; break; } case 0x75: // XMIDI_CONTORLLER_NEXT_BREAK if (_loopCount >= 0) { if (info.basic.param2 < 64) { // End the current loop. _loopCount--; } else { // Repeat 0 means "loop forever". if (_loop[_loopCount].repeat) { if (--_loop[_loopCount].repeat == 0) _loopCount--; else _position._play_pos = _loop[_loopCount].pos; } else { _position._play_pos = _loop[_loopCount].pos; } } } break; case 0x77: // XMIDI_CONTROLLER_CALLBACK_TRIG if (_callbackProc) _callbackProc(info.basic.param2, _callbackData); break; case 0x6e: // XMIDI_CONTROLLER_CHAN_LOCK case 0x6f: // XMIDI_CONTROLLER_CHAN_LOCK_PROT case 0x70: // XMIDI_CONTROLLER_VOICE_PROT case 0x71: // XMIDI_CONTROLLER_TIMBRE_PROT case 0x72: // XMIDI_CONTROLLER_BANK_CHANGE case 0x73: // XMIDI_CONTROLLER_IND_CTRL_PREFIX case 0x76: // XMIDI_CONTROLLER_CLEAR_BB_COUNT case 0x78: // XMIDI_CONTROLLER_SEQ_BRANCH_INDEX default: if (info.basic.param1 >= 0x6e && info.basic.param1 <= 0x78) { warning("Unsupported XMIDI controller %d (0x%2x)", info.basic.param1, info.basic.param1); } } // Should we really keep passing the XMIDI controller events to // the MIDI driver, or should we turn them into some kind of // NOP events? (Dummy meta events, perhaps?) Ah well, it has // worked so far, so it shouldn't cause any damage... break; case 0xF: // Meta or SysEx event switch (info.event & 0x0F) { case 0x2: // Song Position Pointer info.basic.param1 = *(_position._play_pos++); info.basic.param2 = *(_position._play_pos++); break; case 0x3: // Song Select info.basic.param1 = *(_position._play_pos++); info.basic.param2 = 0; break; case 0x6: case 0x8: case 0xA: case 0xB: case 0xC: case 0xE: info.basic.param1 = info.basic.param2 = 0; break; case 0x0: // SysEx info.length = readVLQ(_position._play_pos); info.ext.data = _position._play_pos; _position._play_pos += info.length; break; case 0xF: // META event info.ext.type = *(_position._play_pos++); info.length = readVLQ(_position._play_pos); info.ext.data = _position._play_pos; _position._play_pos += info.length; if (info.ext.type == 0x51 && info.length == 3) { // Tempo event. We want to make these constant 500,000. info.ext.data[0] = 0x07; info.ext.data[1] = 0xA1; info.ext.data[2] = 0x20; } break; default: warning("MidiParser_XMIDI::parseNextEvent: Unsupported event code %x", info.event); } } }