Пример #1
0
const EventPtr NTupleEventReader::getNextEvent() {
	currentEvent = EventPtr(new Event());
	selectNextNtupleEvent();

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

	// //    assert(hltReader->size() == HLTriggers::NUMBER_OF_TRIGGERS);
	// for (unsigned int i = 0; i < hltReader->size(); i++) {
	// 	triggers->push_back(hltReader->getIntVariableAt(i));
	// 	triggerPrescales->push_back(hltPrescaleReader->getIntVariableAt(i));
	// }

	// while (triggers->size() < HLTriggers::NUMBER_OF_TRIGGERS) {
	// 	triggers->push_back(0);
	// 	triggerPrescales->push_back(0);
	// }

	currentEvent->setDataType(DataType::getDataType(getCurrentFile()));
	currentEvent->setFile(getCurrentFile());
	// currentEvent->setHLTs(triggers);
	// currentEvent->setHLTPrescales(triggerPrescales);
	currentEvent->setVertices(vertexReader->getVertices());

	if (NTupleEventReader::loadTracks)
		currentEvent->setTracks(trackReader->getTracks());
	//fill leptons BEFORE jets for jet cleaning
	currentEvent->setElectrons(electronReader->getElectrons());
	currentEvent->setMuons(muonReader->getMuons());

	currentEvent->setJets(jetReader->getJets(currentEvent->isRealData()));

	if (currentEvent->isRealData()) {
		currentEvent->setPassesElectronChannelTrigger( passesElectronChannelTriggerReader->getVariable() );
		currentEvent->setPassesMuonChannelTrigger( passesMuonChannelTriggerReader->getVariable() );
		currentEvent->setPassesTkMuonChannelTrigger( passesTkMuonChannelTriggerReader->getVariable() );
		currentEvent->setPassesElectronChannelQCDTrigger( passesElectronChannelTriggerReader->getVariable() );
		currentEvent->setPassesMuonChannelQCDTrigger( passesMuonChannelTriggerReader->getVariable() );
	}
	else if ( currentEvent->isReHLTMC() ) {
		// currentEvent->setPassesElectronChannelTrigger( passesElectronChannelMCTriggerReader->getVariable() );
		// currentEvent->setPassesMuonChannelTrigger( passesMuonChannelMCTriggerReader->getVariable() );
		// currentEvent->setPassesTkMuonChannelTrigger( passesTkMuonChannelMCTriggerReader->getVariable() );		
		currentEvent->setPassesElectronChannelTrigger( true );
		currentEvent->setPassesMuonChannelTrigger( true );
		currentEvent->setPassesTkMuonChannelTrigger( true );
		currentEvent->setPassesElectronChannelQCDTrigger( true );
		currentEvent->setPassesMuonChannelQCDTrigger( passesMuonChannelMCTriggerReader->getVariable() );
	}
	else {
		currentEvent->setPassesElectronChannelTrigger( true );
		currentEvent->setPassesMuonChannelTrigger( true );
		currentEvent->setPassesTkMuonChannelTrigger( true );		
		currentEvent->setPassesElectronChannelQCDTrigger( true );
		currentEvent->setPassesMuonChannelQCDTrigger( true );
	}

	// Set info that depends on selection criteria e.g. cleaned jets
	// Must do this before setPassOfflineSelectionInfo, as this selects on the cleaned jets
	currentEvent->setElectronSelectionOutputInfo( selectionOutputReader_electron->getSelectionOutputInfo() );
	currentEvent->setMuonSelectionOutputInfo( selectionOutputReader_muon->getSelectionOutputInfo() );
	currentEvent->setElectronQCDNonisolatedSelectionOutputInfo( selectionOutputReader_electronQCDNonisolated->getSelectionOutputInfo() );
	currentEvent->setElectronConversionSelectionOutputInfo( selectionOutputReader_electronQCDConversion->getSelectionOutputInfo() );
	currentEvent->setMuonQCDNonisolatedSelection1p5to3OutputInfo( selectionOutputReader_muonQCDNonisolated1p5to3->getSelectionOutputInfo() );
	currentEvent->setMuonQCDNonisolatedSelection3toInfOutputInfo( selectionOutputReader_muonQCDNonisolated3toInf->getSelectionOutputInfo() );

	currentEvent->setPassOfflineSelectionInfo( *passesOfflineSelectionReader->getVariable() );
	currentEvent->setPassGenSelectionInfo( *passesGenSelectionReader->getVariable() );

	if (!currentEvent->isRealData()) {
		currentEvent->setTTGenInfo( ttGenInfoReader->getTTGenInfo());
		// Have to do this after setting jets and TTGenInfo
		currentEvent->setJetTTBarPartons();

		// 	std::cout << "Gen Particles etc." << std::endl;
		// 	currentEvent->setGenParticles(genParticleReader->getGenParticles());
		currentEvent->setGenJets(genJetReader->getGenJets());
		currentEvent->setPseudoTopParticles( pseudoTopReader->getPseudoTopParticles() );
		// 	currentEvent->setGenNumberOfPileUpVertices(*PileupInfoReader->getVariable());
		// 	currentEvent->setPDFWeights(*PDFWeightsReader->getVariable());
		currentEvent->setTrueNumberOfPileUpVertices(*TruePileupInfoReader->getVariable());
		// 	if (Globals::NTupleVersion >= 6) {
		// 		currentEvent->setPUWeightInTimeOnly(PUWeightInTimeOnly_->getVariable());
		// 		currentEvent->setPUWeight3BX(PUWeight3BX_->getVariable());
		// 		currentEvent->setPUWeightShiftUp(PUWeightShiftUp_->getVariable());
		// 		currentEvent->setPUWeightShiftDown(PUWeightShiftDown_->getVariable());
		// 	}

			currentEvent->setGeneratorWeight( generatorWeightReader_->getVariable() );

			currentEvent->setGeneratorSystematicWeights( *systematicWeightsReader_->getVariable() );

			currentEvent->setCentralLHEWeight( centralLHEWeightReader_->getVariable() );
	}

	// Get and set the cleaned jets for this event
	// After knowing which selection criteria are satisfied
	if( currentEvent->PassesElectronSelectionNoB() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::ElectronPlusJetsReference ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::ElectronPlusJetsReference ) );
	}
	else if ( currentEvent->PassesMuonSelectionNoB() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::MuonPlusJetsReference ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::MuonPlusJetsReference ) );
	}
	else if ( currentEvent->PassesElectronQCDSelectionNoB() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::ElectronPlusJetsQCDNonIsolated ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::ElectronPlusJetsQCDNonIsolated ) );
	}
	else if ( currentEvent->PassesElectronConversionSelectionNoB() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::ElectronPlusJetsQCDConversion ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::ElectronPlusJetsQCDConversion ) );		
	}
	else if ( currentEvent->PassesMuonQCDSelection1p5to3NoB() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::MuonPlusJetsQCDNonIsolated1p5to3 ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::MuonPlusJetsQCDNonIsolated1p5to3 ) );
	}
	else if ( currentEvent->PassesMuonQCDSelection3toInfNoB() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::MuonPlusJetsQCDNonIsolated3toInf ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::MuonPlusJetsQCDNonIsolated3toInf ) );
	}
	// Set bjet weight
	if ( !currentEvent->isRealData() ) {
		boost::scoped_ptr<BTagWeight> btagWeight(new BTagWeight());
		// Normal 2 medium BTags selection
		// Which combination of b tags do you want? 
		// L = Loose, Not implemented yet
		// M = Medium, 
		// T = Tight, 
		// Currently only same WP jets are supported
		double bweight = btagWeight->weight( currentEvent->CleanedJets(), 0, {"M", "M"} );
		currentEvent->setBJetWeight( bweight );
		bweight = btagWeight->weight( currentEvent->CleanedJets(), 1, {"M", "M"}  );
		currentEvent->setLightJetUpWeight( bweight );
		bweight = btagWeight->weight( currentEvent->CleanedJets(), -1, {"M", "M"}  );
		currentEvent->setLightJetDownWeight( bweight );		
		bweight = btagWeight->weight( currentEvent->CleanedJets(), 2, {"M", "M"}  );
		currentEvent->setBJetUpWeight( bweight );			
		bweight = btagWeight->weight( currentEvent->CleanedJets(), -2, {"M", "M"}  );
		currentEvent->setBJetDownWeight( bweight );	
		// 2 tight BTags selection
		bweight = btagWeight->weight( currentEvent->CleanedJets(), 0, {"T", "T"} );
		currentEvent->setTightBJetWeight( bweight );
		// bweight = btagWeight->weight( currentEvent->CleanedJets(), 1, {"T", "T"}  );
		// currentEvent->setTightLightJetUpWeight( bweight );
		// bweight = btagWeight->weight( currentEvent->CleanedJets(), -1, {"T", "T"}  );
		// currentEvent->setTightLightJetDownWeight( bweight );		
		// bweight = btagWeight->weight( currentEvent->CleanedJets(), 2, {"T", "T"}  );
		// currentEvent->setTightBJetUpWeight( bweight );			
		// bweight = btagWeight->weight( currentEvent->CleanedJets(), -2, {"T", "T"}  );
		// currentEvent->setTightBJetDownWeight( bweight );	
	}


	double sysShiftMetCorrectionX = 0;
	double sysShiftMetCorrectionY = 0;
	double type0MetCorrectionX = 0;
	double type0MetCorrectionY = 0;
	double type1MetCorrectionX = 0;
	double type1MetCorrectionY = 0;

	double totalMetCorrectionX = sysShiftMetCorrectionX + type0MetCorrectionX + type1MetCorrectionX;
	double totalMetCorrectionY = sysShiftMetCorrectionY + type0MetCorrectionY + type1MetCorrectionY;

	METCollection mets;
	mets.resize(METAlgorithm::NUMBER_OF_METALGORITHMS);
	for (unsigned int index = 0; index < METAlgorithm::NUMBER_OF_METALGORITHMS; ++index) {
		if (!MET::isAvailableInNTupleVersion(Globals::NTupleVersion, index))
			continue;
		bool isMCOnlyMET = MET::isMCOnlyMETType(index);
		// if (isMCOnlyMET && currentEvent->isRealData())
		if (isMCOnlyMET)
			continue;
		const METPointer met(metReaders.at(index)->getMET(totalMetCorrectionX, totalMetCorrectionY));
		if (Globals::NTupleVersion >= 7){
			met->setSumET(sumETReader_->getVariable());
			currentEvent->setHCALLaserFilter(HCALLaserFilter->getVariable());
			currentEvent->setECALDeadCellFilter(ECALDeadCellFilter->getVariable());
			currentEvent->setTrackingFailureFilter(TrackingFailureFilter->getVariable());
			currentEvent->setCSCTightBeamHaloFilter(!CSCTightHaloId->getVariable());
			currentEvent->setHBHENoiseFilter(true);//we filter on this for the skim
		}
		if (Globals::NTupleVersion >= 9){
			currentEvent->setECALDeadCellTPFilter(ECALDeadCellTPFilter->getVariable());
		}
		if (Globals::NTupleVersion >= 10){
			currentEvent->setEEBadSCFilter(EEBadSCFilter->getVariable());
			currentEvent->setECALLaserCorrFilter(ECALLaserCorrFilter->getVariable());
			currentEvent->setTrackingPOGFilters(TrackingPOGFilters->getVariable());
		}
		mets.at(index) = met;
	}

	currentEvent->setMETs(mets);
	currentEvent->setRunNumber(runNumberReader->getVariable());
	currentEvent->setEventNumber(eventNumberReader->getVariable());
	currentEvent->setLocalEventNumber(currentEventEntry);
	currentEvent->setLumiBlock(lumiBlockReader->getVariable());
	currentEvent->setBeamScrapingVeto(false);
	if (currentEvent->isRealData()) {
		currentEvent->setPassesMETFilters(passesMetFilterReader_->getVariable());
	}

	return currentEvent;
}
Пример #2
0
const EventPtr NTupleEventReader::getNextEvent() {
	currentEvent = EventPtr(new Event());
	selectNextNtupleEvent();

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

	// //    assert(hltReader->size() == HLTriggers::NUMBER_OF_TRIGGERS);
	// for (unsigned int i = 0; i < hltReader->size(); i++) {
	// 	triggers->push_back(hltReader->getIntVariableAt(i));
	// 	triggerPrescales->push_back(hltPrescaleReader->getIntVariableAt(i));
	// }

	// while (triggers->size() < HLTriggers::NUMBER_OF_TRIGGERS) {
	// 	triggers->push_back(0);
	// 	triggerPrescales->push_back(0);
	// }

	currentEvent->setDataType(DataType::getDataType(getCurrentFile()));
	currentEvent->setFile(getCurrentFile());
	// currentEvent->setHLTs(triggers);
	// currentEvent->setHLTPrescales(triggerPrescales);
	currentEvent->setVertices(vertexReader->getVertices());

	if (NTupleEventReader::loadTracks)
		currentEvent->setTracks(trackReader->getTracks());
	//fill leptons BEFORE jets for jet cleaning
	currentEvent->setElectrons(electronReader->getElectrons());
	currentEvent->setMuons(muonReader->getMuons());

	currentEvent->setJets(jetReader->getJets(currentEvent->isRealData()));

	currentEvent->setPassesElectronChannelTrigger( passesElectronChannelTriggerReader->getVariable() );
	currentEvent->setPassesMuonChannelTrigger( passesMuonChannelTriggerReader->getVariable() );

	// Set info that depends on selection criteria e.g. cleaned jets
	// Must do this before setPassOfflineSelectionInfo, as this selects on the cleaned jets
	currentEvent->setElectronSelectionOutputInfo( selectionOutputReader_electron->getSelectionOutputInfo() );
	currentEvent->setMuonSelectionOutputInfo( selectionOutputReader_muon->getSelectionOutputInfo() );
	currentEvent->setElectronQCDNonisolatedSelectionOutputInfo( selectionOutputReader_electronQCDNonisolated->getSelectionOutputInfo() );
	currentEvent->setElectronConversionSelectionOutputInfo( selectionOutputReader_electronQCDConversion->getSelectionOutputInfo() );
	currentEvent->setMuonQCDNonisolatedSelectionOutputInfo( selectionOutputReader_muonQCDNonisolated->getSelectionOutputInfo() );

	currentEvent->setPassOfflineSelectionInfo( *passesOfflineSelectionReader->getVariable() );

	currentEvent->setPassGenSelectionInfo( *passesGenSelectionReader->getVariable() );

	currentEvent->setTTGenInfo( ttGenInfoReader->getTTGenInfo());

	// Have to do this after setting jets and TTGenInfo
	currentEvent->setJetTTBarPartons();

	if (!currentEvent->isRealData()) {
	// 	std::cout << "Gen Particles etc." << std::endl;
	// 	currentEvent->setGenParticles(genParticleReader->getGenParticles());
		currentEvent->setGenJets(genJetReader->getGenJets());
		currentEvent->setPseudoTopParticles( pseudoTopReader->getPseudoTopParticles() );
	// 	currentEvent->setGenNumberOfPileUpVertices(*PileupInfoReader->getVariable());
	// 	currentEvent->setPDFWeights(*PDFWeightsReader->getVariable());

	// 	if (Globals::NTupleVersion >= 6) {
	// 		currentEvent->setTrueNumberOfPileUpVertices(*TruePileupInfoReader->getVariable());
	// 		currentEvent->setPUWeightInTimeOnly(PUWeightInTimeOnly_->getVariable());
	// 		currentEvent->setPUWeight3BX(PUWeight3BX_->getVariable());
	// 		currentEvent->setPUWeightShiftUp(PUWeightShiftUp_->getVariable());
	// 		currentEvent->setPUWeightShiftDown(PUWeightShiftDown_->getVariable());
	// 	}

	}

	// Get and set the cleaned jets for this event
	// After knowing which selection criteria are satisfied
	if( currentEvent->PassesElectronSelection() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::ElectronPlusJetsReference ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::ElectronPlusJetsReference ) );
	}
	else if ( currentEvent->PassesMuonSelection() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::MuonPlusJetsReference ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::MuonPlusJetsReference ) );
	}
	else if ( currentEvent->PassesElectronQCDSelection() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::ElectronPlusJetsQCDNonIsolated ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::ElectronPlusJetsQCDNonIsolated ) );
	}
	else if ( currentEvent->PassesElectronConversionSelection() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::ElectronPlusJetsQCDConversion ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::ElectronPlusJetsQCDConversion ) );		
	}
	else if ( currentEvent->PassesMuonQCDSelection() ) {
		currentEvent->setCleanedJets( currentEvent->getCleanedJets( SelectionCriteria::MuonPlusJetsQCDNonIsolated ) );
		currentEvent->setCleanedBJets( currentEvent->getCleanedBJets( SelectionCriteria::MuonPlusJetsQCDNonIsolated ) );
	}

	double sysShiftMetCorrectionX = 0;
	double sysShiftMetCorrectionY = 0;
	double type0MetCorrectionX = 0;
	double type0MetCorrectionY = 0;
	double type1MetCorrectionX = 0;
	double type1MetCorrectionY = 0;

	// if (Globals::NTupleVersion > 8) {
	// 	if (Globals::applySysShiftMetCorrection) {
	// 		metCorrReaders.at(METCorrections::pfMetSysShiftCorrections)->readMETCorrections();
	// 		sysShiftMetCorrectionX = metCorrReaders.at(METCorrections::pfMetSysShiftCorrections)->getXcorrection();
	// 		sysShiftMetCorrectionY = metCorrReaders.at(METCorrections::pfMetSysShiftCorrections)->getYcorrection();
	// 	}
	// 	if (Globals::applyType0MetCorrection) {
	// 		metCorrReaders.at(METCorrections::pfMetType0Corrections)->readMETCorrections();
	// 		type0MetCorrectionX = metCorrReaders.at(METCorrections::pfMetType0Corrections)->getXcorrection();
	// 		type0MetCorrectionY = metCorrReaders.at(METCorrections::pfMetType0Corrections)->getYcorrection();
	// 	}
	// 	if (Globals::applyType1MetCorrection) {
	// 		metCorrReaders.at(METCorrections::pfMetType1Corrections)->readMETCorrections();
	// 		type1MetCorrectionX = metCorrReaders.at(METCorrections::pfMetType1Corrections)->getXcorrection();
	// 		type1MetCorrectionY = metCorrReaders.at(METCorrections::pfMetType1Corrections)->getYcorrection();
	// 	}
	// }

	double totalMetCorrectionX = sysShiftMetCorrectionX + type0MetCorrectionX + type1MetCorrectionX;
	double totalMetCorrectionY = sysShiftMetCorrectionY + type0MetCorrectionY + type1MetCorrectionY;

	METCollection mets;
	mets.resize(METAlgorithm::NUMBER_OF_METALGORITHMS);
	for (unsigned int index = 0; index < METAlgorithm::NUMBER_OF_METALGORITHMS; ++index) {
		if (!MET::isAvailableInNTupleVersion(Globals::NTupleVersion, index))
			continue;
		bool isMCOnlyMET = MET::isMCOnlyMETType(index);
		// if (isMCOnlyMET && currentEvent->isRealData())
		if (isMCOnlyMET)
			continue;
		const METPointer met(metReaders.at(index)->getMET(totalMetCorrectionX, totalMetCorrectionY));
		if (Globals::NTupleVersion >= 7){
			met->setSumET(sumETReader_->getVariable());
			currentEvent->setHCALLaserFilter(HCALLaserFilter->getVariable());
			currentEvent->setECALDeadCellFilter(ECALDeadCellFilter->getVariable());
			currentEvent->setTrackingFailureFilter(TrackingFailureFilter->getVariable());
			currentEvent->setCSCTightBeamHaloFilter(!CSCTightHaloId->getVariable());
			currentEvent->setHBHENoiseFilter(true);//we filter on this for the skim
		}
		if (Globals::NTupleVersion >= 9){
			currentEvent->setECALDeadCellTPFilter(ECALDeadCellTPFilter->getVariable());
		}
		if (Globals::NTupleVersion >= 10){
			currentEvent->setEEBadSCFilter(EEBadSCFilter->getVariable());
			currentEvent->setECALLaserCorrFilter(ECALLaserCorrFilter->getVariable());
			currentEvent->setTrackingPOGFilters(TrackingPOGFilters->getVariable());
		}
		mets.at(index) = met;
	}

	currentEvent->setMETs(mets);
	currentEvent->setRunNumber(runNumberReader->getVariable());
	currentEvent->setEventNumber(eventNumberReader->getVariable());
	currentEvent->setLocalEventNumber(currentEventEntry);
	currentEvent->setLumiBlock(lumiBlockReader->getVariable());
	currentEvent->setBeamScrapingVeto(false);

	return currentEvent;
}