/** * Metropolis Algorithm. * <p> * The Metropolis algorithm is used to accept or reject a change in the state * of the sample. Randomly changing a spin direction, the energy of the system * is computed. If the energy is lower than the energy before the change, the * new state is accepted. If not, an exponential function is calculated and * compared with a random number between zero and one. If the exponential is * greater than the random number the change is accepted. If not the initial * state is preserved. * * @param tempMax Maximum loop temperature * @param atoms Atom type vector with the characteristics of each atom in the sample * @param al ReadAtomLinks type that contain information about the number of atoms in the sample * @param iterations number of changes of spin direction in each temperature * @param csr compressed sparse row that contains the information of the atoms' neighbors */ void metropolis( int tempMax, int tempStep, const std::vector<Atom>& atoms, const ReadAtomsLinks& al, long int iterations, const CSRMatrix& csr ) { int natoms{al.natoms()}; std::mt19937 sequence; std::uniform_int_distribution<> dis(0, natoms-1); std::uniform_real_distribution<> met(0, 1); RandomSpinGenerator randSpinGen(sequence); std::vector<Spin> state(al.natoms(), Spin::null()); std::generate(state.begin(), state.end(), randSpinGen); double energy = compute_energy(atoms, state, csr); /*std::ofstream myfile; myfile.open ("Experiments/energias.dat");*/ for (int Temp = tempMax; Temp >= 0; Temp -= tempStep) { //myfile << energy << "\n"; //std::cout << "Temperature = " << Temp << std::endl; for (int i = 0; i < iterations; ++i) { int site{dis(sequence)}; Spin aleatorio = Spin::randSpin(sequence); double energyDiff = delta_energy(atoms, state, csr, aleatorio, site); if (energyDiff < 0) { state[site] = aleatorio; energy += energyDiff; //myfile << energy << "\n"; } else { if (std::exp(- (energyDiff)/Temp) >= met(sequence)) { state[site] = aleatorio; energy += energyDiff; //myfile << energy << "\n"; } else { //myfile << energy << "\n"; } } } //myfile.close(); } }
void FileNameHandler::onReadFinished(std::tr1::shared_ptr<DenseData> fileContents, std::tr1::shared_ptr<MetadataRequest> request, NameCallback callback) { mStats.resolved++; std::tr1::shared_ptr<RemoteFileMetadata> bad; if (!fileContents) { SILOG(transfer, error, "FileNameHandler couldn't find file '" << request->getURI() << "'"); callback(bad); return; } FileHeaders emptyHeaders; Fingerprint fp = SparseData(fileContents).computeFingerprint(); //Just treat everything as a single chunk for now Range::length_type file_size = fileContents->length(); Range whole(0, file_size, LENGTH, true); Chunk chunk(fp, whole); ChunkList chunkList; chunkList.push_back(chunk); SharedChunkCache::getSingleton().getCache()->addToCache(fp, fileContents); std::tr1::shared_ptr<RemoteFileMetadata> met(new RemoteFileMetadata(fp, request->getURI(), file_size, chunkList, emptyHeaders)); callback(met); }
void run_crossover_task( const classifier_type & cls, genome_pointer p0_start, genome_pointer p0_end, genome_pointer p1_start, genome_pointer p1_end, row_pointer offspring, bool should_swap_strands ) { if( cls.event_count() == 0 ) { genome_pointer o_start = offspring->begin(); size_t N = offspring->size(); if( should_swap_strands ) { while( p1_start != p1_end ) { // offspring->push_back( *p1_start++ ); if( N > 0 ) { *o_start = *p1_start; o_start++; --N; } else { offspring->push_back( *p1_start ); } ++p1_start; } } else { while( p0_start != p0_end ) { // offspring->push_back( *p0_start++ ); if( N > 0 ) { *o_start = *p0_start; o_start++; --N; } else { offspring->push_back( *p0_start ); } p0_start++; } } while( N-- > 0 ) { offspring->pop_back(); } } else if( should_swap_strands ) { method_type met(cls); met( p1_start, p1_end, p0_start, p0_end, offspring); } else { method_type met(cls); met( p0_start, p0_end, p1_start, p1_end, offspring); } }
DupSetCallbackVector(std::istream & in) : B(in), Pmetrics(new map_type), metrics(*Pmetrics) { uint64_t const nummet = libmaus2::util::NumberSerialisation::deserialiseNumber(in); for ( uint64_t i = 0; i < nummet; ++i ) { uint64_t const j = libmaus2::util::NumberSerialisation::deserialiseNumber(in); ::libmaus2::bambam::DuplicationMetrics met(in); metrics[j] = met; } }
void Plots2D::allPlots(AllSamples samples){ folder = "MuonMET/patType1CorrectedPFMet/"; bins.push_back(25); bins.push_back(45); bins.push_back(70); bins.push_back(100); bins.push_back(150); // Variable::Variable(TString name_temp, TString xTitle_temp, double minX_temp, double maxX_temp, int rebinFact_temp) Variable met("GenMET_vs_RecoMET", "E_{T}^{miss} [GeV]", 0, 200, 2);; savePlot(samples, met); folder = "MuPlusJets/"; bins.clear(); bins.push_back(350); bins.push_back(400); bins.push_back(450); bins.push_back(500); bins.push_back(580); bins.push_back(700); Variable st("GenHT_lep_met_vs_RecoHT_lep_met", "S_{T} [GeV]", 200, 900, 1); savePlot(samples, st); bins.clear(); bins.push_back(40); bins.push_back(70); bins.push_back(100); bins.push_back(130); bins.push_back(170); Variable wpt("Gen_WPT_vs_Reco_WPT", "p_{T}^{W} [GeV]", 0, 250, 5); savePlot(samples, wpt); bins.clear(); bins.push_back(30); bins.push_back(50); bins.push_back(80); bins.push_back(100); Variable mt("Gen_MT_vs_Reco_MT", "M_{T}^{W} [GeV]", 0, 120, 5); savePlot(samples, mt); bins.clear(); bins.push_back(240); bins.push_back(280); bins.push_back(330); bins.push_back(380); bins.push_back(450); bins.push_back(600); Variable ht("GenHT_vs_RecoHT", "H_{T} [GeV]", 150, 800, 1); savePlot(samples, ht); }
int main (int argc, char** argv) { // load framework libraries gSystem->Load( "libFWCoreFWLite" ); //gSystem->Load("libNtupleMakerBEANmaker.so"); AutoLibraryLoader::enable(); int debug = 0; // levels of debug, 10 is large JobParameters myConfig = parseJobOptions(argc, argv); TFile * outputFile = new TFile (myConfig.outputFileName.c_str(), "RECREATE"); outputFile->cd(); TTree * summaryTree = new TTree("summaryTree", "Summary Event Values"); fwlite::ChainEvent ev(myConfig.inputFileNames); HelperLeptonCore lepHelper; BEANhelper * beanHelper = lepHelper.setupAnalysisParameters("2012_53x", myConfig.sampleName); sysType::sysType jetSyst = sysType::NA; if (myConfig.jetSyst == "NA") jetSyst = sysType::NA; else if (myConfig.jetSyst == "JESUp") jetSyst = sysType::JESup; else if (myConfig.jetSyst == "JESDown") jetSyst = sysType::JESdown; else std::cout << "No valid JES corrections specified - using nominal" << std::endl; muonID::muonID muonTightID = muonID::muonSideTightMVA; muonID::muonID muonLooseID = muonID::muonSideLooseMVA; muonID::muonID muonPreselectedID = muonID::muonSide; electronID::electronID electronTightID = electronID::electronSideTightMVA; electronID::electronID electronLooseID = electronID::electronSideLooseMVA; electronID::electronID electronPreselectedID = electronID::electronSide; tauID::tauID tauTightID = tauID::tauMedium; tauID::tauID tauLooseID = tauID::tauLoose; tauID::tauID tauPreselectedID = tauID::tauNonIso; // collections GenericCollection<BNelectronCollection> tightElectrons(beanHelper); GenericCollection<BNelectronCollection> looseElectrons(beanHelper); GenericCollection<BNelectronCollection> preselectedElectrons(beanHelper); GenericCollection<BNelectronCollection> tightLooseElectrons(beanHelper); GenericCollection<BNelectronCollection> loosePreselectedElectrons(beanHelper); GenericCollection<BNelectronCollection> tightLoosePreselectedElectrons(beanHelper); GenericCollection<BNmuonCollection> tightMuons(beanHelper); GenericCollection<BNmuonCollection> looseMuons(beanHelper); GenericCollection<BNmuonCollection> preselectedMuons(beanHelper); GenericCollection<BNmuonCollection> tightLooseMuons(beanHelper); GenericCollection<BNmuonCollection> tightLoosePreselectedMuons(beanHelper); GenericCollection<BNleptonCollection> tightLeptons(beanHelper); GenericCollection<BNleptonCollection> looseLeptons(beanHelper); GenericCollection<BNleptonCollection> preselectedLeptons(beanHelper); GenericCollection<BNleptonCollection> tightLooseLeptons(beanHelper); GenericCollection<BNleptonCollection> tightLoosePreselectedLeptons(beanHelper); GenericCollection<BNtauCollection> tightTaus(beanHelper); GenericCollection<BNtauCollection> tightLooseTaus(beanHelper); GenericCollection<BNtauCollection> tightLoosePreselectedTaus(beanHelper); GenericCollection<BNjetCollection> jets(beanHelper); GenericCollection<BNjetCollection> jetsByCSV(beanHelper); GenericCollection<BNjetCollection> looseCSVJets(beanHelper); GenericCollection<BNjetCollection> mediumCSVJets(beanHelper); GenericCollection<BNjetCollection> notLooseCSVJets(beanHelper); GenericCollection<BNjetCollection> jetsForLepMVA(beanHelper); GenericCollection<BNjetCollection> jetsClosestToLep1(beanHelper); GenericCollection<BNmetCollection> met(beanHelper); GenericCollection<BNprimaryvertexCollection> primaryVertexes(beanHelper); GenericCollection<BNtriggerCollection> hltCollection(beanHelper); GenericCollection<BNeventCollection> events(beanHelper); GenericCollection<BNmcparticleCollection> mcParticles(beanHelper); GenericCollection<BNmcparticleCollection> genHiggsParticles(beanHelper); GenericCollection<BNmcparticleCollection> genTopParticles(beanHelper); GenericCollection<BNmcparticleCollection> genAntiTopParticles(beanHelper); GenericCollection<BNmcparticleCollection> genTTbarParticles(beanHelper); // declare the kinematic variables that you want to be written out into the tree vector<ArbitraryVariable*> kinVars; vector<ArbitraryVariable*> cutVars; ////////////////////////// corrections, weights, etc CSVWeights myCSV(beanHelper, &(jets.ptrToItems), jetSyst); kinVars.push_back(&myCSV); //Btag POG version vector<pair<string, double>> WPs = {make_pair("CSVT", 0.898), make_pair("CSVM", 0.679), make_pair("CSVL", 0.244)}; BTagWeights myBTagWeights(WPs, &(jets.ptrToItems)); kinVars.push_back(&myBTagWeights); PUWeights myPU(&lepHelper, &(events.ptrToItems)); kinVars.push_back(&myPU); TopPtWeights myTopPt(&lepHelper, &(mcParticles.ptrToItems)); kinVars.push_back(&myTopPt); //Currently, gets ND loose lepton SF; could switch to tight and loose - AWB Feb 12, 2014 //LeptonIDAndIsoScaleFactors myLepIDAndIsoSF(&lepHelper, muonID::muonTight, muonID::muonLoose, electronID::electronTight, electronID::electronLoose); LeptonIDAndIsoScaleFactors myLepIDAndIsoSF(&lepHelper, muonTightID, muonLooseID, electronTightID, electronLooseID, &(tightMuons.ptrToItems), &(looseMuons.ptrToItems), &(tightElectrons.ptrToItems), &(looseElectrons.ptrToItems)); kinVars.push_back(&myLepIDAndIsoSF); //CERN version RecoIDIsoSIPSFs myRecoIDIsoSIPSFs(2, &(tightLoosePreselectedLeptons.ptrToItems)); kinVars.push_back(&myRecoIDIsoSIPSFs); LeptonTriggerScaleFactors myLepTrig(&lepHelper, &(tightMuons.ptrToItems), &(looseMuons.ptrToItems), &(preselectedMuons.ptrToItems), &(tightElectrons.ptrToItems), &(looseElectrons.ptrToItems), &(preselectedElectrons.ptrToItems)); kinVars.push_back(&myLepTrig); TightChargeAndLepMVAScaleFactors myTightChargeAndLepMVASFs(2, &(tightLoosePreselectedLeptons.ptrToItems)); kinVars.push_back(&myTightChargeAndLepMVASFs); CleanEventVars myClean(&lepHelper, &(events.ptrToItems), &(primaryVertexes.ptrToItems)); kinVars.push_back(&myClean); CheckTwoLepTrigger checkTrig(&lepHelper, &(hltCollection.ptrToItems)); kinVars.push_back(&checkTrig); DataDrivenFR<BNleptonCollection> myDataDrivenFRAllLeptons(&lepHelper, &(tightLoosePreselectedLeptons.ptrToItems), &(mediumCSVJets.ptrToItems), 2, 0.7, "FR_merged_data", "QF_data_el"); kinVars.push_back(&myDataDrivenFRAllLeptons); DataDrivenFR<BNleptonCollection> myDataDrivenFRAllLeptonsLoose(&lepHelper, &(tightLoosePreselectedLeptons.ptrToItems), &(mediumCSVJets.ptrToItems), 2, -0.3, "FR_merged_data", "QF_data_el", "_Loose"); kinVars.push_back(&myDataDrivenFRAllLeptonsLoose); HiggsDecayType myHiggsDecayType(&lepHelper, &(mcParticles.ptrToItems)); kinVars.push_back(&myHiggsDecayType); TightCharges myTightCharges(&(tightLoosePreselectedLeptons.ptrToItems), "CERN_tight_charge", "all_leptons_by_pt", 2); kinVars.push_back(&myTightCharges); //myTightCharges.setCut("pass"); ////////////////////////// collection sizes GenericCollectionSizeVariable<BNjetCollection> numJets(&(jets.ptrToItems), "numJets"); kinVars.push_back(&numJets); numJets.setCutMin(2); //cutVars.push_back(&numJets); GenericCollectionSizeVariable<BNjetCollection> numLooseBJets(&(looseCSVJets.ptrToItems), "numLooseBJets"); kinVars.push_back(&numLooseBJets); GenericCollectionSizeVariable<BNjetCollection> numMediumBJets(&(mediumCSVJets.ptrToItems), "numMediumBJets"); kinVars.push_back(&numMediumBJets); GenericCollectionSizeVariable<BNjetCollection> numJetsClosestToLep1(&(jetsClosestToLep1.ptrToItems), "numJetsClosestToLep1"); kinVars.push_back(&numJetsClosestToLep1); GenericCollectionSizeVariable<BNmuonCollection> numAllMuons(&(tightLoosePreselectedMuons.ptrToItems), "numAllMuons"); kinVars.push_back(&numAllMuons); GenericCollectionSizeVariable<BNelectronCollection> numAllElectrons(&(tightLoosePreselectedElectrons.ptrToItems), "numAllElectrons"); kinVars.push_back(&numAllElectrons); GenericCollectionSizeVariable<BNleptonCollection> numAllLeptons(&(tightLoosePreselectedLeptons.ptrToItems), "numAllLeptons"); kinVars.push_back(&numAllLeptons); GenericCollectionSizeVariable<BNleptonCollection> numTightLooseLeptons(&(tightLooseLeptons.ptrToItems), "numTightLooseLeptons"); kinVars.push_back(&numTightLooseLeptons); GenericCollectionSizeVariable<BNmuonCollection> numTightMuons(&(tightMuons.ptrToItems), "numTightMuons"); kinVars.push_back(&numTightMuons); GenericCollectionSizeVariable<BNelectronCollection> numTightElectrons(&(tightElectrons.ptrToItems), "numTightElectrons"); kinVars.push_back(&numTightElectrons); GenericCollectionSizeVariable<BNleptonCollection> numTightLeptons(&(tightLeptons.ptrToItems), "numTightLeptons"); kinVars.push_back(&numTightLeptons); if (myConfig.sampleName.find("NP_sideband") == std::string::npos) { //All samples except NP_sideband std::cout << "Sample is not a sideband" << std::endl; numTightLeptons.setCutMin(2); } else if (myConfig.sampleName.find("NP_sideband") != std::string::npos) { //NP_sideband samples std::cout << "Sample is a sideband" << std::endl; //Cut to require opposite-sign leptons numTightLeptons.setCutMin(0); } cutVars.push_back(&numTightLeptons); GenericCollectionSizeVariable<BNtauCollection> numAllTaus(&(tightLoosePreselectedTaus.ptrToItems), "numAllTaus"); kinVars.push_back(&numAllTaus); GenericCollectionSizeVariable<BNtauCollection> numTightLooseTaus(&(tightLooseTaus.ptrToItems), "numTightLooseTaus"); kinVars.push_back(&numTightLooseTaus); GenericCollectionSizeVariable<BNtauCollection> numTightTaus(&(tightTaus.ptrToItems), "numTightTaus"); kinVars.push_back(&numTightTaus); ////////////////////////// lep MVAs LepMVAs<BNleptonCollection> myLepMVAsTightLeptons(&lepHelper, &(tightLeptons.ptrToItems), "tight_leptons_by_pt", 2); kinVars.push_back(&myLepMVAsTightLeptons); LepMVAs<BNleptonCollection> myLepMVAsLooseLeptons(&lepHelper, &(looseLeptons.ptrToItems), "loose_leptons_by_pt", 2); kinVars.push_back(&myLepMVAsLooseLeptons); LepMVAs<BNleptonCollection> myLepMVAsPreselectedLeptons(&lepHelper, &(preselectedLeptons.ptrToItems), "preselected_leptons_by_pt", 2); kinVars.push_back(&myLepMVAsPreselectedLeptons); LepMVAs<BNleptonCollection> myLepMVAsAllLeptons(&lepHelper, &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 3); kinVars.push_back(&myLepMVAsAllLeptons); LepMVAs<BNmuonCollection> myLepMVAsAllMuons(&lepHelper, &(tightLoosePreselectedMuons.ptrToItems), "all_muons_by_pt", 3); kinVars.push_back(&myLepMVAsAllMuons); ////////////////////////// composite objects TwoObjectKinematic<BNleptonCollection, BNmetCollection> mySumLep1Lep2MetPt("pt", "sum", "sum_lep1pt_lep2pt_met", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 2, &(met.ptrToItems), "met", 1, 1); kinVars.push_back(&mySumLep1Lep2MetPt); TwoObjectKinematic<BNleptonCollection, BNleptonCollection> myMinMassLepLep("mass", "min", "min_mass_leplep", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99, &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99); kinVars.push_back(&myMinMassLepLep); TwoObjectKinematic<BNleptonCollection,BNleptonCollection> myMinMassLepLepSFOS("mass", "min", "min_mass_leplep_SFOS", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99, &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99, -99, "same_flavour", "opposite_sign"); kinVars.push_back(&myMinMassLepLepSFOS); TwoObjectKinematic<BNleptonCollection,BNleptonCollection> myZLikeMassLepLepSFOS("mass", "closest_to", "ZLike_mass_leplep_SFOS", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99, &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99, 91.2, "same_flavour", "opposite_sign"); kinVars.push_back(&myZLikeMassLepLepSFOS); TwoObjectKinematic<BNleptonCollection, BNleptonCollection> myMinDeltaRLepLep("deltaR", "min", "min_dR_leplep", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99, &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99); kinVars.push_back(&myMinDeltaRLepLep); TwoObjectKinematic<BNjetCollection, BNjetCollection> myHiggsLikeDijetMass110("mass", "closest_to", "higgsLike_dijet_mass", &(mediumCSVJets.ptrToItems), "medium_btags_by_pt", 1, 99, &(mediumCSVJets.ptrToItems), "medium_btags_by_pt", 1, 99, 110); kinVars.push_back(&myHiggsLikeDijetMass110); TwoObjectKinematic<BNtauCollection, BNjetCollection> myMinDeltaRTau1Jet("deltaR", "min", "min_deltaR_tau1_jet", &(tightLoosePreselectedTaus.ptrToItems), "all_taus_by_pt", 1, 1, &(jets.ptrToItems), "jets_by_pt", 1, 99); kinVars.push_back(&myMinDeltaRTau1Jet); TwoObjectKinematic<BNtauCollection, BNleptonCollection> myMassTau1Leptons("mass", "all_pairs", "", &(tightLoosePreselectedTaus.ptrToItems), "all_taus_by_pt", 1, 1, &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 2); kinVars.push_back(&myMassTau1Leptons); //Variables for CERN same-sign dilepton BDT TwoObjectKinematic<BNleptonCollection, BNjetCollection> myMHT("pt", "vector_sum", "mht", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99, &(jets.ptrToItems), "jets_by_pt", 1, 99); kinVars.push_back(&myMHT); TwoObjectKinematic<BNleptonCollection, BNjetCollection> myMinDeltaRLep1Jet("deltaR", "min", "min_deltaR_lep1_jet", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 1, &(jets.ptrToItems), "jets_by_pt", 1, 99); kinVars.push_back(&myMinDeltaRLep1Jet); TwoObjectKinematic<BNleptonCollection, BNjetCollection> myMinDeltaRLep2Jet("deltaR", "min", "min_deltaR_lep2_jet", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 2, 2, &(jets.ptrToItems), "jets_by_pt", 1, 99); kinVars.push_back(&myMinDeltaRLep2Jet); TwoObjectKinematic<BNleptonCollection, BNjetCollection> myMinDeltaRLep3Jet("deltaR", "min", "mindr_lep3_jet", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 3, 3, &(jets.ptrToItems), "jets_by_pt", 1, 99); kinVars.push_back(&myMinDeltaRLep3Jet); TwoObjectKinematic<BNmetCollection, BNleptonCollection> myMtMetLep("MT", "all_pairs", "", &(met.ptrToItems), "met", 1, 1, &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 2); kinVars.push_back(&myMtMetLep); TwoObjectKinematic<BNleptonCollection,BNjetCollection> mySumPt("pt", "sum", "sum_pt", &(tightLoosePreselectedLeptons.ptrToItems), "all_leptons_by_pt", 1, 99, &(jets.ptrToItems), "jets_by_pt", 1, 99); kinVars.push_back(&mySumPt); int TwoMuon = 0; int TwoElectron = 0; int MuonElectron = 0; Char_t *dataset = (Char_t *)lepHelper.dataset.c_str(); int sampleNumber = (int)lepHelper.sampleNumber; double weight_Xsec = (double)lepHelper.weight_Xsec; int nGen = (int)lepHelper.nGen; double Xsec = (double)lepHelper.Xsec; summaryTree->Branch("sampleNumber", &sampleNumber); summaryTree->Branch("weight_Xsec", &weight_Xsec); summaryTree->Branch("nGen", &nGen); summaryTree->Branch("Xsec", &Xsec); summaryTree->Branch("TwoMuon", &TwoMuon); summaryTree->Branch("TwoElectron", &TwoElectron); summaryTree->Branch("MuonElectron", &MuonElectron); summaryTree->Branch("dataset", (void*)dataset, "dataset/C"); ////////// all leptons ////////// GenericCollectionMember<int, BNleptonCollection> allLeptonNumberOfValidTrackerHitsInnerTrack(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "numberOfValidTrackerHitsInnerTrack", "all_leptons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allLeptonNumberOfValidTrackerHitsInnerTrack); GenericCollectionMember<double, BNleptonCollection> allLeptonInnerTkPt(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "innerTrackPt", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonInnerTkPt); GenericCollectionMember<double, BNleptonCollection> allLeptonInnerTkPtError(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "innerTrackPtError", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonInnerTkPtError); GenericCollectionMember<double, BNleptonCollection> allLeptonJetDeltaR(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "jetDeltaR", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonJetDeltaR); GenericCollectionMember<double, BNleptonCollection> allLeptonJetPtRatio(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "jetPtRatio", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonJetPtRatio); GenericCollectionMember<double, BNleptonCollection> allLeptonJetBTagCSV(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "jetBTagCSV", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonJetBTagCSV); GenericCollectionMember<double, BNleptonCollection> allLeptonMvaNonTrigV0(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "mvaNonTrigV0", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonMvaNonTrigV0); GenericCollectionMember<int, BNleptonCollection> allLeptonNumberOfExpectedInnerHits(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "numberOfExpectedInnerHits", "all_leptons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allLeptonNumberOfExpectedInnerHits); GenericCollectionMember<int, BNleptonCollection> allLeptonIsGsfCtfScPixChargeConsistent(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "isGsfCtfScPixChargeConsistent", "all_leptons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allLeptonIsGsfCtfScPixChargeConsistent); GenericCollectionMember<double, BNleptonCollection> allLeptonPt(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "pt", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonPt); GenericCollectionMember<double, BNleptonCollection> allLeptonTkPT(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "tkPT", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonTkPT); GenericCollectionMember<double, BNleptonCollection> allLeptonEta(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "eta", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonEta); GenericCollectionMember<int, BNleptonCollection> allLeptonIsMuon(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "isMuon", "all_leptons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allLeptonIsMuon); GenericCollectionMember<int, BNleptonCollection> allLeptonIsElectron(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "isElectron", "all_leptons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allLeptonIsElectron); GenericCollectionMember<int, BNleptonCollection> allLeptonTkCharge(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "tkCharge", "all_leptons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allLeptonTkCharge); if (myConfig.sampleName.find("QF_sideband") == std::string::npos) { //All samples except QF_sideband //Cut to require same-sign leptons auto tkChargeCut = [] (vector<BranchInfo<int>> vars) { return ((vars[0].branchVal * vars[1].branchVal) > 0 || abs(vars[2].branchVal) == 1 ); }; allLeptonTkCharge.setCut(tkChargeCut); } else if (myConfig.sampleName.find("QF_sideband") != std::string::npos) { //QF_sideband samples //Cut to require opposite-sign leptons auto tkChargeCut = [] (vector<BranchInfo<int>> vars) { return ((vars[0].branchVal * vars[1].branchVal) < 0); }; allLeptonTkCharge.setCut(tkChargeCut); } cutVars.push_back(&allLeptonTkCharge); GenericCollectionMember<double, BNleptonCollection> allLeptonSIP(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "SIP", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonSIP); GenericCollectionMember<double, BNleptonCollection> allLeptonD0(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "correctedD0Vertex", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonD0); GenericCollectionMember<double, BNleptonCollection> allLeptonDZ(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "correctedDZ", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonDZ); GenericCollectionMember<double, BNleptonCollection> allLeptonIP(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "IP", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonIP); GenericCollectionMember<double, BNleptonCollection> allLeptonIPError(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "IPError", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonIPError); GenericCollectionMember<double, BNleptonCollection> allLeptonPhi(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "phi", "all_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&allLeptonPhi); GenericCollectionMember<int, BNleptonCollection> allLeptonGlobalMuon(Reflex::Type::ByName("BNlepton"), &(tightLoosePreselectedLeptons.ptrToItems), "isGlobalMuon", "all_leptons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allLeptonGlobalMuon); ////////// all muons ////////// GenericCollectionMember<int, BNmuonCollection> allMuonPFmuon(Reflex::Type::ByName("BNmuon"), &(tightLoosePreselectedMuons.ptrToItems), "isPFMuon", "all_muons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allMuonPFmuon); GenericCollectionMember<int, BNmuonCollection> allMuonGlobalMuon(Reflex::Type::ByName("BNmuon"), &(tightLoosePreselectedMuons.ptrToItems), "isGlobalMuon", "all_muons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allMuonGlobalMuon); GenericCollectionMember<int, BNmuonCollection> allMuonTrackerMuon(Reflex::Type::ByName("BNmuon"), &(tightLoosePreselectedMuons.ptrToItems), "isTrackerMuon", "all_muons_by_pt", KinematicVariableConstants::INT_INIT, 4); kinVars.push_back(&allMuonTrackerMuon); GenericCollectionMember<double, BNmuonCollection> allMuonPt(Reflex::Type::ByName("BNmuon"), &(tightLoosePreselectedMuons.ptrToItems), "pt", "all_muons_by_pt", KinematicVariableConstants::FLOAT_INIT, 2); kinVars.push_back(&allMuonPt); GenericCollectionMember<double, BNmuonCollection> allMuonEta(Reflex::Type::ByName("BNmuon"), &(tightLoosePreselectedMuons.ptrToItems), "eta", "all_muons_by_pt", KinematicVariableConstants::FLOAT_INIT, 2); kinVars.push_back(&allMuonEta); ////////// all electrons ////////// GenericCollectionMember<int, BNelectronCollection> allElectronNumExpInnerHits(Reflex::Type::ByName("BNelectron"), &(tightLoosePreselectedElectrons.ptrToItems), "numberOfExpectedInnerHits", "all_electrons_by_pt", KinematicVariableConstants::INT_INIT, 2); kinVars.push_back(&allElectronNumExpInnerHits); GenericCollectionMember<int, BNelectronCollection> allElectronPassConvVeto(Reflex::Type::ByName("BNelectron"), &(tightLoosePreselectedElectrons.ptrToItems), "passConvVeto", "all_electrons_by_pt", KinematicVariableConstants::INT_INIT, 2); kinVars.push_back(&allElectronPassConvVeto); GenericCollectionMember<double, BNelectronCollection> allElectronEta(Reflex::Type::ByName("BNelectron"), &(tightLoosePreselectedElectrons.ptrToItems), "eta", "all_electrons_by_pt", KinematicVariableConstants::FLOAT_INIT, 2); kinVars.push_back(&allElectronEta); GenericCollectionMember<double, BNelectronCollection> allElectronPt(Reflex::Type::ByName("BNelectron"), &(tightLoosePreselectedElectrons.ptrToItems), "pt", "all_electrons_by_pt", KinematicVariableConstants::FLOAT_INIT, 2); kinVars.push_back(&allElectronPt); ////////// tight leptons ///////// GenericCollectionMember<double, BNleptonCollection> tightLeptonInnerTkPt(Reflex::Type::ByName("BNlepton"), &(tightLeptons.ptrToItems), "innerTrackPt", "tight_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&tightLeptonInnerTkPt); GenericCollectionMember<double, BNleptonCollection> tightLeptonInnerTkPtError(Reflex::Type::ByName("BNlepton"), &(tightLeptons.ptrToItems), "innerTrackPtError", "tight_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&tightLeptonInnerTkPtError); GenericCollectionMember<double, BNleptonCollection> tightLeptonPt(Reflex::Type::ByName("BNlepton"), &(tightLeptons.ptrToItems), "pt", "tight_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&tightLeptonPt); GenericCollectionMember<double, BNleptonCollection> tightLeptonEta(Reflex::Type::ByName("BNlepton"), &(tightLeptons.ptrToItems), "eta", "tight_leptons_by_pt", KinematicVariableConstants::FLOAT_INIT, 4); kinVars.push_back(&tightLeptonEta); ////////// all taus ////////// GenericCollectionMember<double, BNtauCollection> allTauPt(Reflex::Type::ByName("BNtau"), &(tightLoosePreselectedTaus.ptrToItems), "pt", "all_taus_by_pt", KinematicVariableConstants::FLOAT_INIT, 2); kinVars.push_back(&allTauPt); GenericCollectionMember<double, BNtauCollection> allTauEta(Reflex::Type::ByName("BNtau"), &(tightLoosePreselectedTaus.ptrToItems), "eta", "all_taus_by_pt", KinematicVariableConstants::FLOAT_INIT, 2); kinVars.push_back(&allTauEta); ////////// all jets ////////// GenericCollectionMember<double, BNjetCollection> allJetPt(Reflex::Type::ByName("BNjet"), &(jets.ptrToItems), "pt", "jets_by_pt", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&allJetPt); GenericCollectionMember<double, BNjetCollection> allJetEta(Reflex::Type::ByName("BNjet"), &(jets.ptrToItems), "eta", "jets_by_pt", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&allJetEta); GenericCollectionMember<double, BNjetCollection> allJetPhi(Reflex::Type::ByName("BNjet"), &(jets.ptrToItems), "phi", "jets_by_pt", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&allJetPhi); GenericCollectionMember<double, BNjetCollection> allJetCSV(Reflex::Type::ByName("BNjet"), &(jets.ptrToItems), "btagCombinedSecVertex", "jets_by_pt", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&allJetCSV); ////////// all jets, ordered by CSV ////////// GenericCollectionMember<double, BNjetCollection> allJetByCSVPt(Reflex::Type::ByName("BNjet"), &(jetsByCSV.ptrToItems), "pt", "jets_by_CSV", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&allJetByCSVPt); GenericCollectionMember<double, BNjetCollection> allJetByCSVEta(Reflex::Type::ByName("BNjet"), &(jetsByCSV.ptrToItems), "eta", "jets_by_CSV", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&allJetByCSVEta); GenericCollectionMember<double, BNjetCollection> allJetByCSVPhi(Reflex::Type::ByName("BNjet"), &(jetsByCSV.ptrToItems), "phi", "jets_by_CSV", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&allJetByCSVPhi); GenericCollectionMember<double, BNjetCollection> allJetByCSVCSV(Reflex::Type::ByName("BNjet"), &(jetsByCSV.ptrToItems), "btagCombinedSecVertex", "jets_by_CSV", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&allJetByCSVCSV); ////////// lepMVA jets ////////// GenericCollectionMember<double, BNjetCollection> lepMVAJetPt(Reflex::Type::ByName("BNjet"), &(jetsForLepMVA.ptrToItems), "pt", "lepMVAjets_by_CSV", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&lepMVAJetPt); GenericCollectionMember<double, BNjetCollection> lepMVAJetEta(Reflex::Type::ByName("BNjet"), &(jetsForLepMVA.ptrToItems), "eta", "lepMVAjets_by_CSV", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&lepMVAJetEta); GenericCollectionMember<double, BNjetCollection> lepMVAJetPhi(Reflex::Type::ByName("BNjet"), &(jetsForLepMVA.ptrToItems), "phi", "lepMVAjets_by_CSV", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&lepMVAJetPhi); GenericCollectionMember<double, BNjetCollection> lepMVAJetCSV(Reflex::Type::ByName("BNjet"), &(jetsForLepMVA.ptrToItems), "btagCombinedSecVertex", "lepMVAjets_by_CSV", KinematicVariableConstants::FLOAT_INIT, 6); kinVars.push_back(&lepMVAJetCSV); ////////// met ////////// GenericCollectionMember<double, BNmetCollection> metPt(Reflex::Type::ByName("BNmet"), &(met.ptrToItems), "pt", "met", KinematicVariableConstants::FLOAT_INIT, 1); kinVars.push_back(&metPt); // GenericCollectionMember<double, BNmetCollection> // met1d(Reflex::Type::ByName("BNmet"), &(selectedCollections.metpfType1CorrectedMetBNCollection), "pt", "metpfType1CorrectedMetBN", KinematicVariableConstants::FLOAT_INIT, 1); // kinVars.push_back(&met1d); int numExtraPartons = -99; summaryTree->Branch("numExtraPartons", &numExtraPartons); ////////// event info ////////// GenericCollectionMember<unsigned, BNeventCollection> runNumber(Reflex::Type::ByName("BNevent"), &(events.ptrToItems), "run", "eventInfo", KinematicVariableConstants::UINT_INIT, 1); kinVars.push_back(&runNumber); GenericCollectionMember<unsigned, BNeventCollection> lumiBlock(Reflex::Type::ByName("BNevent"), &(events.ptrToItems), "lumi", "eventInfo", KinematicVariableConstants::UINT_INIT, 1); kinVars.push_back(&lumiBlock); // this is a long inside BNevent: just using keyword long won't work-- needs to be Long64_t GenericCollectionMember<Long64_t, BNeventCollection> eventNumber(Reflex::Type::ByName("BNevent"), &(events.ptrToItems), "evt", "eventInfo", KinematicVariableConstants::INT_INIT, 1); kinVars.push_back(&eventNumber); MetLD myMetLD(&myMHT, &metPt); kinVars.push_back(&myMetLD); FinalBDT myFinalBDT(&allLeptonEta, &allLeptonPt, &myMHT, &myMinDeltaRLep2Jet, &myMtMetLep, &mySumPt); kinVars.push_back(&myFinalBDT); if (debug > 9) { cout << "Hooking variables to tree" << endl;} for (vector<ArbitraryVariable*>::iterator iVar = kinVars.begin(); iVar != kinVars.end(); iVar++) { (*iVar)->attachToTree (summaryTree); } int numEvents = 0; int numEventsFailCuts = 0; int numEventsPassCuts = 0; int printEvery = 1000; for (ev.toBegin(); !ev.atEnd(); ++ev){ numEvents++; if ((numEvents > myConfig.maxEvents) && myConfig.maxEvents != -1) break; if (numEvents == 1 || numEvents % printEvery == 0 ) cout << "Processing event.... " << numEvents << endl; if (debug > 9) cout << "---------->>>>>> Event " << numEvents << endl; ///////////////////////////////////////////////////////////// // // Initialize collections and apply object ids // ////////////////////////////////////////////////////////////// jetsForLepMVA.initializeRawItemsSortedByCSV(ev, "BNproducer", "patJetsAK5PF"); tightLoosePreselectedMuons.initializeRawItemsSortedByPt(ev, "BNproducer","selectedPatMuonsLoosePFlow"); tightLoosePreselectedElectrons.initializeRawItemsSortedByPt(ev, "BNproducer","selectedPatElectronsGSF"); lepHelper.applyRochesterCorrections(tightLoosePreselectedMuons.rawItems); bool applySmearing = !(lepHelper.isData); if (applySmearing) { lepHelper.fillMCMatchAny(tightLoosePreselectedMuons.rawItems, mcParticles.rawItems, 0.3); lepHelper.fillMCMatchAny(tightLoosePreselectedElectrons.rawItems, mcParticles.rawItems, 0.3); lepHelper.fillMCMatchID(tightLoosePreselectedMuons.rawItems, mcParticles.rawItems, 1.2); lepHelper.fillMCMatchID(tightLoosePreselectedElectrons.rawItems, mcParticles.rawItems, 1.2); lepHelper.scaleMCCollectionDZ(tightLoosePreselectedElectrons.rawItems); lepHelper.scaleMCCollectionDZ(tightLoosePreselectedMuons.rawItems); lepHelper.scaleMCCollectionDXY(tightLoosePreselectedElectrons.rawItems); lepHelper.scaleMCCollectionDXY(tightLoosePreselectedMuons.rawItems); } lepHelper.fillSIP(tightLoosePreselectedMuons.rawItems, applySmearing); lepHelper.fillSIP(tightLoosePreselectedElectrons.rawItems, applySmearing); lepHelper.fillLepJetPtRatio(tightLoosePreselectedMuons.rawItems, jetsForLepMVA.rawItems, applySmearing); lepHelper.fillLepJetPtRatio(tightLoosePreselectedElectrons.rawItems, jetsForLepMVA.rawItems, applySmearing); lepHelper.fillLepJetDeltaR(tightLoosePreselectedMuons.rawItems, jetsForLepMVA.rawItems, applySmearing); lepHelper.fillLepJetDeltaR(tightLoosePreselectedElectrons.rawItems, jetsForLepMVA.rawItems, applySmearing); lepHelper.fillLepJetBTagCSV(tightLoosePreselectedMuons.rawItems, jetsForLepMVA.rawItems); lepHelper.fillLepJetBTagCSV(tightLoosePreselectedElectrons.rawItems, jetsForLepMVA.rawItems); tightLoosePreselectedElectrons.keepSelectedParticles(electronPreselectedID); tightElectrons.initializeRawItems(tightLoosePreselectedElectrons.rawItems); tightElectrons.keepSelectedParticles(electronTightID); tightLooseElectrons.initializeRawItems(tightLoosePreselectedElectrons.rawItems); tightLooseElectrons.keepSelectedParticles(electronLooseID); looseElectrons.initializeRawItems(tightLoosePreselectedElectrons.rawItems); looseElectrons.keepSelectedDifference(electronLooseID, electronTightID); preselectedElectrons.initializeRawItems(tightLoosePreselectedElectrons.rawItems); preselectedElectrons.keepSelectedDifference(electronPreselectedID, electronLooseID); loosePreselectedElectrons.initializeRawItems(tightLoosePreselectedElectrons.rawItems); loosePreselectedElectrons.addUnion({looseElectrons.items, preselectedElectrons.items}); tightLoosePreselectedMuons.keepSelectedParticles(muonPreselectedID); tightMuons.initializeRawItems(tightLoosePreselectedMuons.rawItems); tightMuons.keepSelectedParticles(muonTightID); looseMuons.initializeRawItems(tightLoosePreselectedMuons.rawItems); looseMuons.keepSelectedDifference(muonLooseID, muonTightID); preselectedMuons.initializeRawItems(tightLoosePreselectedMuons.rawItems); preselectedMuons.keepSelectedDifference(muonPreselectedID, muonLooseID); tightLooseMuons.initializeRawItems(tightLoosePreselectedMuons.rawItems); tightLooseMuons.keepSelectedParticles(muonLooseID); // Require reset before first pushback to avoid keeping leptons from previous event tightLeptons.resetAndPushBack(tightElectrons.items); tightLeptons.pushBackAndSort(tightMuons.items); looseLeptons.resetAndPushBack(looseElectrons.items); looseLeptons.pushBackAndSort(looseMuons.items); preselectedLeptons.resetAndPushBack(preselectedElectrons.items); preselectedLeptons.pushBackAndSort(preselectedMuons.items); tightLooseLeptons.resetAndPushBack(tightLooseElectrons.items); tightLooseLeptons.pushBackAndSort(tightLooseMuons.items); tightLoosePreselectedLeptons.resetAndPushBack(tightLoosePreselectedElectrons.items); tightLoosePreselectedLeptons.pushBackAndSort(tightLoosePreselectedMuons.items); tightTaus.initializeRawItemsSortedByPt(ev, "BNproducer","selectedPatTausPFlow"); tightTaus.keepSelectedParticles(tauTightID); tightLooseTaus.initializeRawItems(tightTaus.rawItems); tightLooseTaus.keepSelectedParticles(tauTightID); tightLoosePreselectedTaus.initializeRawItems(tightTaus.rawItems); tightLoosePreselectedTaus.keepSelectedParticles(tauPreselectedID); jets.initializeRawItemsSortedByPt(ev, "BNproducer","selectedPatJetsPFlow"); jets.cleanJets(tightLoosePreselectedLeptons.items); jets.correctRawJets(jetSyst); jets.keepSelectedJets(25.0, 2.4, jetID::jetLoose, '-'); jetsByCSV.initializeRawItemsSortedByCSV(jets.items); looseCSVJets.initializeRawItems(jets.rawItems); looseCSVJets.keepSelectedJets(25.0, 2.4, jetID::jetLoose, 'L'); mediumCSVJets.initializeRawItems(jets.rawItems); mediumCSVJets.keepSelectedJets(25.0, 2.4, jetID::jetLoose, 'M'); notLooseCSVJets.initializeRawItems(beanHelper->GetDifference(jets.items, looseCSVJets.items)); met.initializeRawItems(ev, "BNproducer","patMETsPFlow"); met.getCorrectedMet(jets); events.initializeRawItems(ev, "BNproducer", ""); mcParticles.initializeRawItems(ev, "BNproducer", "MCstatus3"); primaryVertexes.initializeRawItems(ev, "BNproducer","offlinePrimaryVertices"); hltCollection.initializeRawItems(ev, "BNproducer", "HLT"); genHiggsParticles.initializeRawItems(mcParticles.rawItems); auto higgsPDGID = [] (BNmcparticle p) { return (p.id == 25); }; genHiggsParticles.keepSelectedParticles(higgsPDGID); genTopParticles.initializeRawItems(mcParticles.rawItems); auto topPDGID = [] (BNmcparticle p) { return (p.id == 6); }; genTopParticles.keepSelectedParticles(topPDGID); genAntiTopParticles.initializeRawItems(mcParticles.rawItems); auto antitopPDGID = [] (BNmcparticle p) { return (p.id == -6); }; float lep1_eta = KinematicVariableConstants::FLOAT_INIT; float lep1_phi = KinematicVariableConstants::FLOAT_INIT; if (tightLoosePreselectedLeptons.items.size() >= 1) { lep1_eta = tightLoosePreselectedLeptons.items.at(0)->eta; lep1_phi = tightLoosePreselectedLeptons.items.at(0)->phi; } float lep1_jet_deltaR = 0.7; jetsClosestToLep1.initializeRawItems(jets.items); auto jetsClosestToLep1Auto = [] (BNjet j, float x, float y, float z) { return (sqrt( pow(j.eta - x, 2)+pow(j.phi - y,2) ) < z); }; jetsClosestToLep1.keepSelectedParticles(jetsClosestToLep1Auto, lep1_eta, lep1_phi, lep1_jet_deltaR); // reset all the vars if (debug > 9) cout << "Resetting " << endl; for (vector<ArbitraryVariable*>::iterator iVar = kinVars.begin(); iVar != kinVars.end(); iVar++) { (*iVar)->reset(); } bool passAllCuts = true; if (debug > 9) cout << "Checking cuts " << endl; for (vector<ArbitraryVariable*>::iterator iCut = cutVars.begin(); iCut != cutVars.end(); iCut++ ) { (*iCut)->evaluate(); passAllCuts = passAllCuts && (*iCut)->passCut(); } // do the lepton cut passAllCuts = passAllCuts && LeptonCutThisAnalysis(tightLoosePreselectedLeptons.items); if (!passAllCuts) { numEventsFailCuts++; continue; //!!!! Skip The event /////////////// } else { numEventsPassCuts++; } // Now evaluate the vars if (debug > 9) cout << "Evaluating vars " << endl; for (vector<ArbitraryVariable*>::iterator iVar = kinVars.begin(); iVar != kinVars.end(); iVar++) { (*iVar)->evaluate(); } if (debug > 9) { for (vector<ArbitraryVariable*>::iterator iVar = kinVars.begin(); iVar != kinVars.end(); iVar++) { (*iVar)->print(); cout << endl; } } LeptonVarsThisAnalysis(tightMuons.items, tightElectrons.items, LeptonCutThisAnalysis(tightLoosePreselectedLeptons.items), TwoMuon, TwoElectron, MuonElectron); getNumExtraPartons(beanHelper, mcParticles.items, numExtraPartons); if (myConfig.sampleName.find("_0p") != std::string::npos) { //0 parton samples //Cut to require 0 partons if (numExtraPartons != 0) { numEventsFailCuts++; numEventsPassCuts--; continue; } } if (debug > 9) cout << "Filling tree " << endl; summaryTree->Fill(); if (debug > 9) cout << "Done with event " << numEvents << endl; }// end for each event cout << "Num Events processed " << numEvents << endl << "Passed cuts " << numEventsPassCuts << endl << "Failed cuts " << numEventsFailCuts << endl ; outputFile->Write(); outputFile->Close(); }
void updatebombs(){ int i,j; for(i=0;i<20;i++){ if(bomb[i].alive){ int dieatlast=0; bomb[i].x=bomb[i].x+bomb[i].velx; bomb[i].y-=bomb[i].jumpfactor/10; bomb[i].jumpfactor--; if(bomb[i].x<(mapxoff-WIDTH) || bomb[i].x>mapxoff+WIDTH || bomb[i].y<mapyoff || bomb[i].y>mapyoff+HEIGHT){ bomb[i].alive=0; } else if(bomb[i].y>mapblockheight*mapheight-30) bomb[i].alive=0; if( bomb[i].x-mapxoff>0 && (bomb[i].x-mapxoff)<(WIDTH-bomb[i].width)) bomb[i].draw(); if(bomb[i].jumpfactor<0){ if(collided(bomb[i].x+bomb[i].width/2,bomb[i].y+bomb[i].height)) { bomb[i].jump=false; while(collided(bomb[i].x+bomb[i].width/2,bomb[i].y+bomb[i].height)) bomb[i].y-=2; if(i<10){ for(int k=0;k<20;k++){ if(bulldogs[k].alive && bulldogs[k].hitpoints>0){ if(met(bulldogs[k].x,bulldogs[k].y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,bulldogs[k].width,BOMBRADIUS*2,bulldogs[k].height,BOMBRADIUS*2)){ scores+=500; bulldogs[k].hitpoints-=bomb[i].damagept; if((bulldogs[k].hitpoints)<=0){ bulldogs[k].type2=REBELDYING; bulldogs[k].totalframes=REBELMAX[REBELDYING]; bulldogs[k].curframe=0; bulldogs[k].velx=0; bulldogs[k].jump=false; } } } if(k>=MAXBOMBERS) continue; if(bombman[k].alive && bombman[k].hitpoints>0){ if(met(bombman[k].x,bombman[k].y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,bombman[k].width,BOMBRADIUS*2,bombman[k].height,BOMBRADIUS*2)){ scores+=1000; bombman[k].hitpoints-=bomb[i].damagept; if((bombman[k].hitpoints)<=0){ bombman[k].type2=REBELDYING; bombman[k].totalframes=REBELMAX[REBELDYING]; bombman[k].curframe=0; bombman[k].velx=0; bombman[k].jump=false; } } } } //bomb[i].alive=0; } if(i>=10 && inputflag){ if(met(tarma.x,tarma.y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,tarma.width,BOMBRADIUS*2,tarma.height,BOMBRADIUS*2)){ tarma.hitpoints-=bomb[i].damagept; if(tarma.hitpoints<=0) resetplayer(); bomb[i].alive=0; } } bomb[i].alive=0; } } if(!bomb[i].alive) continue; for(j=0;j<20;j++){ if(bulldogs[j].alive &&i<10 && bulldogs[j].hitpoints>0){ if(met(bulldogs[j].x,bulldogs[j].y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,bulldogs[j].width,BOMBRADIUS*2,bulldogs[j].height,BOMBRADIUS*2)){ dieatlast=1; scores+=500; bulldogs[j].hitpoints-=bomb[i].damagept; if((bulldogs[j].hitpoints)<=0){ bulldogs[j].type2=REBELDYING; bulldogs[j].totalframes=REBELMAX[REBELDYING]; bulldogs[j].curframe=0; bulldogs[j].velx=0; bulldogs[j].jump=false; } } } if(j>=MAXBOMBERS) continue; if(bombman[j].alive &&i<10 && bombman[j].hitpoints>0){ if(met(bombman[j].x,bombman[j].y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,bombman[j].width,BOMBRADIUS*2,bombman[j].height,BOMBRADIUS*2)){ dieatlast=1; scores+=1000; bombman[j].hitpoints-=bomb[i].damagept; if((bombman[j].hitpoints)<=0){ bombman[j].type2=REBELDYING; bombman[j].totalframes=REBELMAX[REBELDYING]; bombman[j].curframe=0; bombman[j].velx=0; bombman[j].jump=false; } } } } if(dieatlast) bomb[i].alive=0; if(!bomb[i].alive) continue; if(i>=10 && inputflag){ if(met(tarma.x,tarma.y,bomb[i].x-BOMBRADIUS,bomb[i].y-BOMBRADIUS,tarma.width,BOMBRADIUS*2,tarma.height,BOMBRADIUS*2)){ tarma.hitpoints-=bomb[i].damagept; if(tarma.hitpoints<=0) resetplayer(); bomb[i].alive=0; } } } } }
void updatebombers(int& spawn){ int difficulty=2+tarma.x*10/(mapblockwidth*mapwidth); if(spawn==1){ int n,i; n=rand()%difficulty; for(i=0;i<MAXBOMBERS && n>0;i++){ if(!(bombman[i].alive)){ bombman[i].alive=1; bombman[i].totalframes=14; bombman[i].x=mapxoff+WIDTH+rand()%1200; bombman[i].y=SCREEN_H/2; bombman[i].curframe=0; bombman[i].hitpoints=2; bombman[i].jump=false; if((bombman[i].x+bombman[i].width/2)<(tarma.x+tarma.width/2)){ bombman[i].velx=rand()%3; bombman[i].facing=RIGHT; bombman[i].type2=ENEMY; bombman[i].curframe=0; } else { bombman[i].velx=-(rand()%3); bombman[i].facing=LEFT; bombman[i].type2=ENEMY; bombman[i].curframe=0; } n--; } } spawn=0; } for(int i=0;i<MAXBOMBERS;i++){ if(bombman[i].alive && bombman[i].hitpoints>0){ if(bombman[i].jump==false){ if(!collided(bombman[i].x+bombman[i].width/2,bombman[i].y+bombman[i].height+5)){ bombman[i].jump=true; bombman[i].jumpfactor = -1; } } if(bombman[i].jump==false){ for(int j=0;j<25;j++){ if(pistols[j].alive){ int dist=pistols[j].x-bombman[i].x; if(((dist>50 && dist<80) || (dist<-50 && dist>-80)) && pistols[j].y>bombman[i].y && pistols[j].y<bombman[i].y+ bombman[i].width){ bombman[i].jump=(rand()%(40/difficulty))?false:true; bombman[i].jumpfactor=24; } } } } if(bombman[i].jump) { bombman[i].y -= bombman[i].jumpfactor/3; bombman[i].jumpfactor--; } if(bombman[i].jumpfactor<0){ if(collided(bombman[i].x+bombman[i].width/2,bombman[i].y+bombman[i].height)) { bombman[i].jump=false; while(collided(bombman[i].x+bombman[i].width/2,bombman[i].y+bombman[i].height)) bombman[i].y -= 2; } } bombman[i].lastx=bombman[i].x; bombman[i].animate(); if(bombman[i].jump) bombman[i].x=bombman[i].lastx; if((counter-bombman[i].lastcount)>bombman[i].firedelay+1){ if((bombman[i].x-mapxoff) >0 && (bombman[i].x-mapxoff)<(640-bombman[i].width)){ firebombathero(i); bombman[i].lastcount=counter; } } if(bombman[i].facing==LEFT){ if(collided(bombman[i].x,bombman[i].y+bombman[i].height/2)){ bombman[i].x=bombman[i].lastx; } } if(bombman[i].facing==RIGHT){ if(collided(bombman[i].x+bombman[i].width,bombman[i].y+bombman[i].height/2)){ bombman[i].x=bombman[i].lastx; } } if(!collided(bombman[i].x+bombman[i].width/2,bombman[i].y+bombman[i].height) ){ bombman[i].x=bombman[i].lastx; } if(met(tarma.x,tarma.y,bombman[i].x,bombman[i].y,tarma.width,bombman[i].width,tarma.height,bombman[i].height)){ bombman[i].x=bombman[i].lastx; } //bombman[i].velx=0; if((bombman[i].x+bombman[i].width/2)<(tarma.x+tarma.width/2)){ bombman[i].velx=rand()%3; bombman[i].facing=RIGHT; bombman[i].type2=REBELRIGHT; } else { bombman[i].velx=-(rand()%3); bombman[i].facing=LEFT; bombman[i].type2=REBELLEFT; } //bombman[i].type2=REBELLEFT; //bombman[i].facing=LEFT; if(bombman[i].x+bombman[i].width<mapxoff) bombman[i].alive=0; if(bombman[i].y>mapheight*mapblockheight-bombman[i].height-50 || bombman[i].y<10) bombman[i].alive=0; if(bombman[i].alive && (bombman[i].x+bombman[i].width-mapxoff)>0 && (bombman[i].x-mapxoff<WIDTH)) bombman[i].draw(); } } }
void updatebullets(){ int i,j; for(i=0;i<50;i++){ if(pistols[i].alive){ pistols[i].x=pistols[i].x+pistols[i].velx; pistols[i].y=pistols[i].y+pistols[i].vely; if(pistols[i].x<(mapxoff-WIDTH) || pistols[i].x>mapxoff+WIDTH || pistols[i].y<mapyoff || pistols[i].y>mapyoff+HEIGHT){ pistols[i].alive=0; continue; } else if( pistols[i].x-mapxoff>0 && pistols[i].x-mapxoff<WIDTH) pistols[i].draw(); for(j=0;j<20;j++){ if(bulldogs[j].alive &&i<25 && bulldogs[j].hitpoints>0){ if(met(pistols[i].x,pistols[i].y,bulldogs[j].x,bulldogs[j].y,pistols[i].width,bulldogs[j].width,pistols[i].height,bulldogs[j].height)){ pistols[i].alive=0; scores+=100; bulldogs[j].hitpoints--; if((bulldogs[j].hitpoints)<=0){ bulldogs[j].type2=REBELDYING; bulldogs[j].totalframes=REBELMAX[REBELDYING]; bulldogs[j].curframe=0; bulldogs[j].velx=0; bulldogs[j].jump=false; } break; } } if(j>=MAXBOMBERS) continue; if(bombman[j].alive &&i<25 && bombman[j].hitpoints>0){ if(met(pistols[i].x,pistols[i].y,bombman[j].x,bombman[j].y,bombman[i].width,bombman[j].width,bombman[i].height,bombman[j].height)){ pistols[i].alive=0; scores+=500; bombman[j].hitpoints--; if((bombman[j].hitpoints)<=0){ bombman[j].type2=REBELDYING; bombman[j].totalframes=REBELMAX[REBELDYING]; bombman[j].curframe=0; bombman[j].velx=0; bombman[j].jump=false; } break; } } } if(!pistols[i].alive) continue; if(i>25 && inputflag){ if(met(pistols[i].x,pistols[i].y,tarma.x,tarma.y,pistols[i].width,tarma.width,pistols[i].height,tarma.height)){ scores-=100; tarma.hitpoints--; if(!tarma.hitpoints) resetplayer(); pistols[i].alive=0; } } } } }
void updatehero(){ tarma.animate(); if(tarma.crouch) tarma.height=35; else tarma.height=70; if(tarma.jump==false){ if(!collided(tarma.x+tarma.width/2,tarma.y+tarma.height+5)){ tarma.jump=true; tarma.jumpfactor=-1; } } if(tarma.jump) { tarma.lasty=tarma.y; tarma.y -= tarma.jumpfactor/5; if(tarma.y<20){ tarma.y=20; } tarma.jumpfactor--; } if(tarma.jumpfactor<0){ if(collided(tarma.x+tarma.width/2,tarma.y+tarma.height)) { tarma.jump=false; lastjump=mils; while(collided(tarma.x+tarma.width/2,tarma.y+tarma.height)) tarma.y-=2; } } if(tarma.facing==LEFT){ if(collided(tarma.x,tarma.y+tarma.height)){ tarma.x=tarma.lastx; } } if(tarma.facing==RIGHT){ if(collided(tarma.x+tarma.width,tarma.y+tarma.height)){ tarma.x=tarma.lastx; } } for(int i=0;i<20;i++){ if(bulldogs[i].alive){ if(met(tarma.x,tarma.y,bulldogs[i].x,bulldogs[i].y,tarma.width,bulldogs[i].width,tarma.height,bulldogs[i].height)){ tarma.x=tarma.lastx; } } if(i>=MAXBOMBERS) continue; if(bombman[i].alive){ if(met(tarma.x,tarma.y,bombman[i].x,bombman[i].y,tarma.width,bombman[i].width,tarma.height,bombman[i].height)){ tarma.x=tarma.lastx; } } } if(tarma.y>(mapheight*mapblockheight-tarma.height-50) ){ resetplayer(); if(gameover) return; } if(tarma.x<5) tarma.x=5; mapxoff=tarma.x+tarma.width/2-WIDTH/2+10; mapyoff=tarma.y+tarma.height/2-HEIGHT/2+10; if(mapxoff<0) mapxoff=0; if(mapxoff>mapwidth*mapblockwidth-WIDTH) mapxoff=mapwidth*mapblockwidth-WIDTH; if(mapyoff<0) mapyoff=0; if(mapyoff>mapheight*mapblockheight-HEIGHT) mapyoff=mapheight*mapblockheight-HEIGHT; MapDrawBG(buffer,mapxoff,mapyoff,0,0,WIDTH-1,HEIGHT-1); MapDrawFG(buffer,mapxoff,mapyoff,0,0,WIDTH-1,HEIGHT-1,0); tarma.draw(); }
static QString translationAttempt( const QString& oldTranslation, const char* oldSource, const char* newSource ) { int p = zeroKey( oldSource ).contains( '0' ); int oldSourceLen = qstrlen( oldSource ); QString attempt; QStringList oldNumbers; QStringList newNumbers; QMemArray<bool> met( p ); QMemArray<int> matchedYet( p ); int i, j; int k = 0, ell, best; int m, n; int pass; /* This algorithm is hard to follow, so we'll consider an example all along: oldTranslation is "XeT 3.0", oldSource is "TeX 3.0" and newSource is "XeT 3.1". First, we set up two tables: oldNumbers and newNumbers. In our example, oldNumber[0] is "3.0" and newNumber[0] is "3.1". */ for ( i = 0, j = 0; i < oldSourceLen; i++, j++ ) { m = numberLength( oldSource + i ); n = numberLength( newSource + j ); if ( m > 0 ) { oldNumbers.append( QCString( oldSource + i, m + 1 ) ); newNumbers.append( QCString( newSource + j, n + 1 ) ); i += m; j += n; met[k] = FALSE; matchedYet[k] = 0; k++; } } /* We now go over the old translation, "XeT 3.0", one letter at a time, looking for numbers found in oldNumbers. Whenever such a number is met, it is replaced with its newNumber equivalent. In our example, the "3.0" of "XeT 3.0" becomes "3.1". */ for ( i = 0; i < ( int ) oldTranslation.length(); i++ ) { attempt += oldTranslation[i]; for ( k = 0; k < p; k++ ) { if ( oldTranslation[i] == oldNumbers[k][matchedYet[k]] ) matchedYet[k]++; else matchedYet[k] = 0; } /* Let's find out if the last character ended a match. We make two passes over the data. In the first pass, we try to match only numbers that weren't matched yet; if that fails, the second pass does the trick. This is useful in some suspicious cases, flagged below. */ for ( pass = 0; pass < 2; pass++ ) { best = p; // an impossible value for ( k = 0; k < p; k++ ) { if ( ( !met[k] || pass > 0 ) && matchedYet[k] == ( int ) oldNumbers[k].length() && numberLength( oldTranslation.latin1() + ( i + 1 ) - matchedYet[k] ) == matchedYet[k] ) { // the longer the better if ( best == p || matchedYet[k] > matchedYet[best] ) best = k; } } if ( best != p ) { attempt.truncate( attempt.length() - matchedYet[best] ); attempt += newNumbers[best]; met[best] = TRUE; for ( k = 0; k < p; k++ ) matchedYet[k] = 0; break; } } } /* We flag two kinds of suspicious cases. They are identified as such with comments such as "{2000?}" at the end. Example of the first kind: old source text "TeX 3.0" translated as "XeT 2.0" is flagged "TeX 2.0 {3.0?}", no matter what the new text is. */ for ( k = 0; k < p; k++ ) { if ( !met[k] ) attempt += QString( " {" ) + newNumbers[k] + QString( "?}" ); } /* Example of the second kind: "1 of 1" translated as "1 af 1", with new source text "1 of 2", generates "1 af 2 {1 or 2?}" because it's not clear which of "1 af 2" and "2 af 1" is right. */ for ( k = 0; k < p; k++ ) { for ( ell = 0; ell < p; ell++ ) { if ( k != ell && oldNumbers[k] == oldNumbers[ell] && newNumbers[k] < newNumbers[ell] ) attempt += QString( " {" ) + newNumbers[k] + QString( " or " ) + newNumbers[ell] + QString( "?}" ); } } return attempt; }
QSize SoftKey::sizeHint() const { QFontMetricsF met(font()); return QSize(met.height() * 2.0 * d->stretch, met.height() * 1.75); }
void createWorkspace(){ gSystem->Load("libHiggsAnalysisCombinedLimit.so"); TFile *outfile = new TFile("workspace.root","RECREATE"); RooWorkspace wspace("w","w"); RooRealVar met("met","E_{T}^{miss}",200,1000); RooArgList vars(met); // Templates TFile* templatesfile = new TFile("templates.root"); // ---------------------------- SIGNAL REGION -------------------------------------------------------------------// // Data addTemplate("data_obs_SR", vars, wspace, (TH1F*)templatesfile->Get("datahist")); // Signal shape addTemplate("DM_SR", vars, wspace, (TH1F*)templatesfile->Get("sig1hist")); // Znunu background TH1F* znn_SR_hist = (TH1F*)templatesfile->Get("zinvhist"); RooArgList znn_SR_bins; makeBinList("Znunu_SR", met, wspace, znn_SR_hist, znn_SR_bins); // WJets background TH1F* wln_SR_hist = (TH1F*)templatesfile->Get("wjethist"); RooArgList wln_SR_bins; vector<pair<RooRealVar*, TH1*> > wln_SR_syst; RooRealVar* wln_SR_re1 = new RooRealVar("WJets_SR_RenScale1" , "", 0., -5., 5.); RooRealVar* wln_SR_fa1 = new RooRealVar("WJets_SR_FactScale1", "", 0., -5., 5.); RooRealVar* wln_SR_re2 = new RooRealVar("WJets_SR_RenScale2" , "", 0., -5., 5.); RooRealVar* wln_SR_fa2 = new RooRealVar("WJets_SR_FactScale2", "", 0., -5., 5.); RooRealVar* wln_SR_pdf = new RooRealVar("WJets_SR_PDF" , "", 0., -5., 5.); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(NULL , (TH1F*)templatesfile->Get("ZW_EWK"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_re1, (TH1F*)templatesfile->Get("ZW_RenScale1"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_fa1, (TH1F*)templatesfile->Get("ZW_FactScale1"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_re2, (TH1F*)templatesfile->Get("ZW_RenScale2"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_fa2, (TH1F*)templatesfile->Get("ZW_FactScale2"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_pdf, (TH1F*)templatesfile->Get("ZW_PDF"))); if (!connectWZ) makeBinList("WJets_SR", met, wspace, wln_SR_hist, wln_SR_bins); else makeConnectedBinList("WJets_SR", met, wspace, (TH1F*)templatesfile->Get("zwjcorewkhist"), wln_SR_syst, znn_SR_bins, &wln_SR_bins); TH1F* qcdhist = (TH1F*)templatesfile->Get("qbkghist"); qcdhist->Scale(2.0); // Other MC backgrounds addTemplate("ZJets_SR" , vars, wspace, (TH1F*)templatesfile->Get("zjethist")); addTemplate("Top_SR" , vars, wspace, (TH1F*)templatesfile->Get("tbkghist")); //addTemplate("QCD_SR" , vars, wspace, (TH1F*)templatesfile->Get("qbkghist")); addTemplate("QCD_SR" , vars, wspace, qcdhist); addTemplate("Dibosons_SR" , vars, wspace, (TH1F*)templatesfile->Get("dbkghist")); // ---------------------------- CONTROL REGION (Dimuon) -----------------------------------------------------------------// addTemplate("data_obs_ZM", vars, wspace, (TH1F*)templatesfile->Get("datahistzmm")); vector<pair<RooRealVar*, TH1*> > znn_ZM_syst; makeConnectedBinList("Znunu_ZM", met, wspace, (TH1F*)templatesfile->Get("zmmcorhist"), znn_ZM_syst, znn_SR_bins); // Other MC backgrounds in dimuon control region addTemplate("WJets_ZM" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistzmm")); addTemplate("Top_ZM" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistzmm")); addTemplate("QCD_ZM" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistzmm")); addTemplate("Dibosons_ZM" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistzmm")); // ---------------------------- CONTROL REGION (Dielectron) -----------------------------------------------------------------// addTemplate("data_obs_ZE" , vars, wspace, (TH1F*)templatesfile->Get("datahistzee")); vector<pair<RooRealVar*, TH1*> > znn_ZE_syst; makeConnectedBinList("Znunu_ZE", met, wspace, (TH1F*)templatesfile->Get("zeecorhist"), znn_ZE_syst, znn_SR_bins); // Other MC backgrounds in dielectron control region addTemplate("WJets_ZE" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistzee")); addTemplate("Top_ZE" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistzee")); addTemplate("QCD_ZE" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistzee")); addTemplate("Dibosons_ZE" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistzee")); // ---------------------------- CONTROL REGION (Photon+Jets) -----------------------------------------------------------------// addTemplate("data_obs_GJ" , vars, wspace, (TH1F*)templatesfile->Get("datahistgam")); vector<pair<RooRealVar*, TH1*> > znn_GJ_syst; RooRealVar* znn_GJ_re1 = new RooRealVar("Znunu_GJ_RenScale1" , "", 0., -5., 5.); RooRealVar* znn_GJ_fa1 = new RooRealVar("Znunu_GJ_FactScale1", "", 0., -5., 5.); RooRealVar* znn_GJ_re2 = new RooRealVar("Znunu_GJ_RenScale2" , "", 0., -5., 5.); RooRealVar* znn_GJ_fa2 = new RooRealVar("Znunu_GJ_FactScale2", "", 0., -5., 5.); RooRealVar* znn_GJ_pdf = new RooRealVar("Znunu_GJ_PDF" , "", 0., -5., 5.); RooRealVar* znn_GJ_fpc = new RooRealVar("Znunu_GJ_Footprint" , "", 0., -5., 5.); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(NULL , (TH1F*)templatesfile->Get("ZG_EWK"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_re1, (TH1F*)templatesfile->Get("ZG_RenScale1"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fa1, (TH1F*)templatesfile->Get("ZG_FactScale1"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_re2, (TH1F*)templatesfile->Get("ZG_RenScale2"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fa2, (TH1F*)templatesfile->Get("ZG_FactScale2"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_pdf, (TH1F*)templatesfile->Get("ZG_PDF"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fpc, (TH1F*)templatesfile->Get("ZG_Footprint"))); makeConnectedBinList("Znunu_GJ", met, wspace, (TH1F*)templatesfile->Get("gamcorewkhist"), znn_GJ_syst, znn_SR_bins); // Other MC backgrounds photon+jets control region addTemplate("QCD_GJ" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistgam")); // ---------------------------- CONTROL REGION (Single muon) -----------------------------------------------------------------// addTemplate("data_obs_WM" , vars, wspace, (TH1F*)templatesfile->Get("datahistwmn")); vector<pair<RooRealVar*, TH1*> > wln_WM_syst; makeConnectedBinList("WJets_WM", met, wspace, (TH1F*)templatesfile->Get("wmncorhist"), wln_WM_syst, wln_SR_bins); // Other MC backgrounds in single muon control region addTemplate("ZJets_WM" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistwmn")); addTemplate("Top_WM" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistwmn")); addTemplate("QCD_WM" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistwmn")); addTemplate("Dibosons_WM" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistwmn")); // ---------------------------- CONTROL REGION (Single electron) -----------------------------------------------------------------// addTemplate("data_obs_WE" , vars, wspace, (TH1F*)templatesfile->Get("datahistwen")); vector<pair<RooRealVar*, TH1*> > wln_WE_syst; makeConnectedBinList("WJets_WE", met, wspace, (TH1F*)templatesfile->Get("wencorhist"), wln_WE_syst, wln_SR_bins); // Other MC backgrounds in single electron control region addTemplate("ZJets_WE" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistwen")); addTemplate("Top_WE" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistwen")); addTemplate("QCD_WE" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistwen")); addTemplate("Dibosons_WE" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistwen")); // ---------------------------- Write out the workspace -----------------------------------------------------------------// outfile->cd(); wspace.Write(); outfile->Close(); }
void MeerkatNameHandler::request_finished(std::tr1::shared_ptr<HttpManager::HttpResponse> response, HttpManager::ERR_TYPE error, const boost::system::error_code& boost_error, std::tr1::shared_ptr<MetadataRequest> request, NameCallback callback) { std::tr1::shared_ptr<RemoteFileMetadata> bad; if (error == Transfer::HttpManager::REQUEST_PARSING_FAILED) { SILOG(transfer, error, "Request parsing failed during an HTTP name lookup (" << request->getURI() << ")"); callback(bad); return; } else if (error == Transfer::HttpManager::RESPONSE_PARSING_FAILED) { SILOG(transfer, error, "Response parsing failed during an HTTP name lookup (" << request->getURI() << ")"); callback(bad); return; } else if (error == Transfer::HttpManager::BOOST_ERROR) { SILOG(transfer, error, "A boost error happened during an HTTP name lookup (" << request->getURI() << "). Boost error = " << boost_error.message()); callback(bad); return; } else if (error != HttpManager::SUCCESS) { SILOG(transfer, error, "An unknown error happened during an HTTP name lookup. (" << request->getURI() << ")"); callback(bad); return; } if (response->getHeaders().size() == 0) { SILOG(transfer, error, "There were no headers returned during an HTTP name lookup (" << request->getURI() << ")"); callback(bad); return; } HttpManager::Headers::const_iterator it; it = response->getHeaders().find("Content-Length"); if (it != response->getHeaders().end()) { SILOG(transfer, error, "Content-Length header was present when it shouldn't be during an HTTP name lookup (" << request->getURI() << ")"); callback(bad); return; } if (response->getStatusCode() != 200) { SILOG(transfer, error, "HTTP status code = " << response->getStatusCode() << " instead of 200 during an HTTP name lookup (" << request->getURI() << ")"); callback(bad); return; } it = response->getHeaders().find("File-Size"); if (it == response->getHeaders().end()) { SILOG(transfer, error, "Expected File-Size header not present during an HTTP name lookup (" << request->getURI() << ")"); callback(bad); return; } std::string file_size_str = it->second; it = response->getHeaders().find("Hash"); if (it == response->getHeaders().end()) { SILOG(transfer, error, "Expected Hash header not present during an HTTP name lookup (" << request->getURI() << ")"); callback(bad); return; } std::string hash = it->second; if (response->getData()) { SILOG(transfer, error, "Body present during an HTTP name lookup (" << request->getURI() << ")"); callback(bad); return; } Fingerprint fp; try { fp = Fingerprint::convertFromHex(hash); } catch(std::invalid_argument e) { SILOG(transfer, error, "Hash header didn't contain a valid Fingerprint string (" << request->getURI() << ")"); callback(bad); return; } std::istringstream istream(file_size_str); uint64 file_size; istream >> file_size; std::ostringstream ostream; ostream << file_size; if(ostream.str() != file_size_str) { SILOG(transfer, error, "Error converting File-Size header string to integer (" << request->getURI() << ")"); callback(bad); return; } //Just treat everything as a single chunk for now Range whole(0, file_size, LENGTH, true); Chunk chunk(fp, whole); ChunkList chunkList; chunkList.push_back(chunk); std::tr1::shared_ptr<RemoteFileMetadata> met(new RemoteFileMetadata(fp, request->getURI(), file_size, chunkList, response->getRawHeaders())); callback(met); SILOG(transfer, detailed, "done http name handler request_finished"); }
bool InvertedIndex::ReadMetaDataFile(bool force, bool nodata, bool wrlocked, string filename, size_t maxn) { bool debug = false; string msg = "Index::ReadMetaDataFile() : "; if (force || /*nodata ||*/ wrlocked) { cerr << "Index::ReadMetaDataFile(" << force << ", " << nodata << ", " << wrlocked << ")" << endl; return ShowError(msg+"strange arguments"); } // obs! feature_target should be solved here! if (filename=="") filename = metfile_str; ifstream met(filename.c_str()); if (!met) return ShowError(msg+"could not read <"+filename+">"); FloatVectorSet cols(DataSetSize()); string comment = "Automatically generated meta data\n" "Field names (components):\n"; Tic("ReadMetaDataFile"); size_t linecount=0; for (;;) { string line; getline(met, line); if (!met) break; if (line.find_first_not_of(" \t")==string::npos) continue; if (line[0]=='#') { if (line.find("indices")!=string::npos) binary_classindices = true; continue; } int i = line.size()-1; while (i>=0 && isspace(line[i])) line.erase(i--); Tic("GroundTruthExpression"); bool expand = false; // was true (and much slower) until 5.4.2006 ground_truth ivec = db->GroundTruthExpression(line, feature_target, -1, expand); Tac("GroundTruthExpression"); if (debug) db->GroundTruthSummaryTable(ivec); if (ivec.empty()) { meta_data_fields.clear(); return ShowError(msg+"<"+filename+"> field \"", line, "\" not known"); } if (!nodata) { Tic("loop-1"); FloatVector fvec(ivec.size()); for (int j=0; j<fvec.Length(); j++) fvec[j] = ivec[j]; cols.AppendCopy(fvec); linecount++; Tac("loop-1"); } int ncols = 1; pair<string,int> mdf(line, ncols); meta_data_fields.push_back(mdf); stringstream ss; ss << " " << line << " (" << ncols << ")";;; comment += ss.str(); // cout << "!!! [" << line << "] OK !!!" << endl; if (maxn != 0 && linecount >= maxn) break; } if (!nodata) { bool check_type = true, check_restr = true; // added 3.5.2006 Tic("loop-2"); data.Delete(); data.VectorLength(cols.Nitems()); for (int i=0; i<cols.VectorLength(); i++) { if (check_type && !db->ObjectsTargetTypeContains(i, feature_target)) continue; if (check_restr && !db->OkWithRestriction(i)) continue; FloatVector v(cols.Nitems(), NULL, db->LabelP(i)); v.Number(i); for (int j=0; j<v.Length(); j++) v[j] = cols[j][i]; data.AppendCopy(v); } data.SetDescription(comment.c_str()); Tac("loop-2"); } Tac("ReadMetaDataFile"); string log = "Read meta data file <"+ShortFileName(filename)+">"; if (!nodata) log += " and processed to "+ToStr(data.Nitems())+" vectors of length "+ ToStr(data.VectorLength()); else log += " without processing"; WriteLog(log); return true; }
void minivalidator::analyze(size_t childid /* this info can be used for printouts */){ d_ana::dBranchHandler<Electron> elecs(tree(),"Electron"); d_ana::dBranchHandler<HepMCEvent> event(tree(),"Event"); d_ana::dBranchHandler<GenParticle> genpart(tree(),"Particle"); d_ana::dBranchHandler<Jet> genjet(tree(),"GenJet"); d_ana::dBranchHandler<Jet> jet(tree(),"JetPUPPI"); d_ana::dBranchHandler<Jet> taujet(tree(),"Jet"); d_ana::dBranchHandler<Muon> muontight(tree(),"MuonTight"); d_ana::dBranchHandler<Photon> photon(tree(),"Photon"); d_ana::dBranchHandler<MissingET> met(tree(),"MissingET"); d_ana::dBranchHandler<MissingET> puppimet(tree(),"PuppiMissingET"); d_ana::dBranchHandler<MissingET> genpumet(tree(),"GenPileUpMissingET"); d_ana::dBranchHandler<MissingET> genmet(tree(),"GenMissingET"); size_t nevents=tree()->entries(); if(isTestMode()) nevents/=100; //create output TString chilidstr=""; chilidstr+=childid; TFile * outfile= new TFile(getOutDir()+"/p2val_"+(TString)getLegendName()+"_"+chilidstr+".root","RECREATE"); TDirectory *counterdir = outfile->mkdir("weightCounter"); counterdir->cd(); TH1F * h_event_weight = new TH1F("Event_weight","Event_weight",1,0,1); outfile->cd(); TDirectory *muondir = outfile->mkdir("muonTight"); muondir->cd(); TH1F * h_muontight_all_pt = new TH1F("h_muontight_all_pt","Muon PT",200,0,200); TH1F * h_muontight_all_eta = new TH1F("h_muontight_all_eta","Muon eta",200,-5,5); TH1F * h_muontight_all_phi = new TH1F("h_muontight_all_phi","Muon phi",200,-3.5,3.5); TH1F * h_muontight_all_tof = new TH1F("h_muontight_all_tof","Muon tof",200,0,10); TH1F * h_muontight_all_charge = new TH1F("h_muontight_all_charge","Muon charge",2,-1,1); TH1F * h_muontight_all_IsolationVar = new TH1F("h_muontight_all_IsolationVar","Muon IsolationVar",100,0,20); TH1F * h_muontight_all_IsolationVarRhoCorr = new TH1F("h_muontight_all_IsolationVarRhoCorr","Muon IsolationVarRhoCorr",100,0,20); TH1F * h_muontight_all_SumPtCharged = new TH1F("h_muontight_all_SumPtCharged","Muon SumPtCharged",100,0,20); TH1F * h_muontight_all_SumPtNeutral = new TH1F("h_muontight_all_SumPtNeutral","Muon SumPtNeutral",100,0,20); TH1F * h_muontight_all_SumPtChargedPU = new TH1F("h_muontight_all_SumPtChargedPU","Muon SumPtChargedPU",100,0,20); TH1F * h_muontight_all_SumPt = new TH1F("h_muontight_all_SumPt","Muon SumPt",100,0,20); TH1F * h_muontight_iso_pt = new TH1F("h_muontight_iso_pt","Muon PT",200,0,200); TH1F * h_muontight_iso_eta = new TH1F("h_muontight_iso_eta","Muon eta",200,-5,5); TH1F * h_muontight_iso_phi = new TH1F("h_muontight_iso_phi","Muon phi",200,-3.5,3.5); TH2F * h_muontight_all_IsolationVarRhoCorr_pt = new TH2F ("h_muontight_all_IsolationVarRhoCorr_pt","",200,0,20,200,0,20); outfile->cd(); TDirectory *zmmdir = outfile->mkdir("zmm"); zmmdir->cd(); TH1F * h_zmm_m1_pt = new TH1F("h_zmm_m1_pt","Muon PT 1",200,0,200); TH1F * h_zmm_m2_pt = new TH1F("h_zmm_m2_pt","Muon PT 2",200,0,200); TH1F * h_zmm_mass = new TH1F("h_zmm_mass","ZMM mass",200,60,120); TH1F * h_zmm_met_pt = new TH1F("h_zmm_met_pt","MET ZMM sel",200,0,200); TH1F * h_zmm_puppimet_pt = new TH1F("h_zmm_puppimet_pt","MET no sel",200,0,200); TH1F * h_zmm_genpumet_pt = new TH1F("h_zmm_genpumet_pt","MET no sel",200,0,200); TH1F * h_zmm_genmet_pt = new TH1F("h_zmm_genmet_pt","MET no sel",200,0,200); TDirectory *metdir = outfile->mkdir("met"); metdir->cd(); TH1F * h_met_pt = new TH1F("h_met_pt","MET no sel",200,0,200); TH1F * h_puppimet_pt = new TH1F("h_puppimet_pt","MET no sel",200,0,200); TH1F * h_genpumet_pt = new TH1F("h_genpumet_pt","MET no sel",200,0,200); TH1F * h_genmet_pt = new TH1F("h_genmet_pt","MET no sel",200,0,200); //load effective corrections for delphes samples vs fullSim scaleFactors tightelecsf,medelecsf,looseelecsf, tightmuonsf,loosemuonsf, jetsf, tightphotonsf,loosephotonsf, metsf; TString basepath=getenv("CMSSW_BASE"); basepath+="/src/PhaseTwoAnalysis/delphesInterface/ntupler/data/"; tightelecsf.loadTH2D (basepath+"ElectronTight_PTEta.root","FullSimOverDelphes"); medelecsf.loadTH2D (basepath+"ElectronMedium_PTEta.root","FullSimOverDelphes"); //looseelecsf.loadTH2D (cmsswbase+"bla.root","histo"); // tightmuonsf.loadTH2D (basepath+"MuonTight_PTEta.root","FullSimOverDelphes"); //loosemuonsf.loadTH2D (cmsswbase+"bla.root","histo"); // //jetsf.loadTH2D (cmsswbase+"bla.root","histo"); // tightphotonsf.loadTH2D(basepath+"PhotonTight_PTEta.root","FullSimOverDelphes"); //loosephotonsf.loadTH2D(cmsswbase+"bla.root","histo"); // //metsf.loadTH2D (cmsswbase+"bla.root","histo"); for(size_t eventno=0;eventno<nevents;eventno++){ /* * The following two lines report the status and set the event link * Do not remove! */ reportStatus(eventno,nevents); tree()->setEntry(eventno); if(event.size()<1)continue; h_event_weight->Fill(0.,(double)event.at(0)->Weight); // No selection h_met_pt->Fill(met.at(0)->MET); h_puppimet_pt->Fill(puppimet.at(0)->MET); h_genpumet_pt->Fill(genpumet.at(0)->MET); h_genmet_pt->Fill(genmet.at(0)->MET); // Playing at genlevel // Lets look for muons Double_t maxpt1=0, maxpt2=0; size_t index1=0, index2=0; size_t ngoodmuons=0; for(size_t i=0;i<muontight.size();i++){ h_muontight_all_pt->Fill(muontight.at(i)->PT); h_muontight_all_eta->Fill(muontight.at(i)->Eta); h_muontight_all_phi->Fill(muontight.at(i)->Phi); h_muontight_all_charge->Fill(muontight.at(i)->Charge); h_muontight_all_tof->Fill(muontight.at(i)->T); h_muontight_all_IsolationVar->Fill(muontight.at(i)->IsolationVar); h_muontight_all_IsolationVarRhoCorr->Fill(muontight.at(i)->IsolationVarRhoCorr); h_muontight_all_SumPtCharged->Fill(muontight.at(i)->SumPtCharged); h_muontight_all_SumPtNeutral->Fill(muontight.at(i)->SumPtNeutral); h_muontight_all_SumPtChargedPU->Fill(muontight.at(i)->SumPtChargedPU); h_muontight_all_SumPt->Fill(muontight.at(i)->SumPt); h_muontight_all_IsolationVarRhoCorr_pt ->Fill(muontight.at(i)->IsolationVar,muontight.at(i)->PT); if(muontight.at(i)->IsolationVarRhoCorr<0.1) { // this is just a guess h_muontight_iso_pt->Fill(muontight.at(i)->PT); h_muontight_iso_eta->Fill(muontight.at(i)->Eta); h_muontight_iso_phi->Fill(muontight.at(i)->Phi); if(muontight.at(i)->PT>maxpt1) { maxpt2=maxpt1; index2=index1; maxpt1=muontight.at(i)->PT; index1=i;} else if (muontight.at(i)->PT>maxpt2) {maxpt2=muontight.at(i)->PT; index2=i;} ngoodmuons++; } } if(ngoodmuons>=2) { if( muontight.at(index1)->PT>20 && muontight.at(index2)->PT > 20 && (muontight.at(index1)->Charge!=muontight.at(index2)->Charge) ) { h_zmm_m1_pt->Fill(muontight.at(index1)->PT); h_zmm_m2_pt->Fill(muontight.at(index2)->PT); TLorentzVector m1, m2; m1.SetPtEtaPhiM(muontight.at(index1)->PT,muontight.at(index1)->Eta,muontight.at(index1)->Phi,0.105); m2.SetPtEtaPhiM(muontight.at(index2)->PT,muontight.at(index2)->Eta,muontight.at(index2)->Phi,0.105); h_zmm_mass->Fill( (m1+m2).M() ); h_zmm_met_pt->Fill(met.at(0)->MET); h_zmm_puppimet_pt->Fill(puppimet.at(0)->MET); h_zmm_genpumet_pt->Fill(genpumet.at(0)->MET); h_zmm_genmet_pt->Fill(genmet.at(0)->MET); // Double_t mass2=2*muontight.at(index1)->PT*muontight.at(index2)->PT*( cosh(muontight.at(index1)->Eta-muontight.at(index2)->Eta) - cos(muontight.at(index1)->Phi-muontight.at(index2)->Phi) ); // std::cout<<muontight.at(index1)->PT<<" "<<m1.Pt()<<std::endl; // std::cout<<sqrt(mass2)<<" "<<(m1+m2).M()<<std::endl; } } } counterdir->cd(); h_event_weight->Write(); muondir->cd(); h_muontight_all_pt->Write(); h_muontight_all_eta ->Write(); h_muontight_all_phi ->Write(); h_muontight_all_charge ->Write(); h_muontight_all_tof ->Write(); h_muontight_all_IsolationVar ->Write(); h_muontight_all_IsolationVarRhoCorr ->Write(); h_muontight_all_SumPtCharged ->Write(); h_muontight_all_SumPtNeutral ->Write(); h_muontight_all_SumPtChargedPU ->Write(); h_muontight_all_SumPt ->Write(); h_muontight_all_IsolationVarRhoCorr_pt->Write(); h_muontight_iso_pt->Write(); h_muontight_iso_eta ->Write(); h_muontight_iso_phi ->Write(); zmmdir->cd(); h_zmm_m1_pt->Write(); h_zmm_m2_pt->Write(); h_zmm_mass->Write(); h_zmm_met_pt->Write(); h_zmm_puppimet_pt->Write(); h_zmm_genpumet_pt->Write(); h_zmm_genmet_pt->Write(); metdir->cd(); h_met_pt->Write(); h_puppimet_pt->Write(); h_genpumet_pt->Write(); h_genmet_pt->Write(); outfile->Close(); /* * Must be called in the end, takes care of thread-safe writeout and * call-back to the parent process */ processEndFunction(); }