static int CheckJobs(void) { CronFile *file; CronLine *line; int nStillRunning = 0; for (file = FileBase; file; file = file->cf_Next) { if (file->cf_Running) { file->cf_Running = 0; for (line = file->cf_LineBase; line; line = line->cl_Next) { if (line->cl_Pid > 0) { int status; int r = wait4(line->cl_Pid, &status, WNOHANG, NULL); if (r < 0 || r == line->cl_Pid) { EndJob(file->cf_User, line); if (line->cl_Pid) { file->cf_Running = 1; } } else if (r == 0) { file->cf_Running = 1; } } } } nStillRunning += file->cf_Running; } return (nStillRunning); }
int CheckJobs(void) { CronFile *file; CronLine *line; int nStillRunning = 0; for (file = FileBase; file; file = file->cf_Next) { if (file->cf_Running) { file->cf_Running = 0; for (line = file->cf_LineBase; line; line = line->cl_Next) { if (line->cl_Pid > 0) { int status; int r = waitpid(line->cl_Pid, &status, WNOHANG); /* waitpid returns -1 for error, 0 if cl_Pid still running, cl_Pid if it's dead */ if (r < 0 || r == line->cl_Pid) { if (r > 0 && WIFEXITED(status)) status = WEXITSTATUS(status); else status = 1; EndJob(file, line, status); } else if (r == 0) { file->cf_Running = 1; } } } } nStillRunning += file->cf_Running; } return(nStillRunning); }
Job::Pointer JobManager::StartJob() { Job::Pointer job(nullptr); while (true) { job = NextJob(); if (!job) return Job::Pointer(nullptr); //must perform this outside sync block because it is third party code bool shouldRun = job->ShouldRun(); //check for listener veto if (shouldRun) m_JobListeners.AboutToRun(job); //listeners may have canceled or put the job to sleep bool endJob = false; { Poco::ScopedLock<Poco::Mutex> lock(m_mutex); InternalJob::Pointer internal = job; if (internal->InternalGetState() == InternalJob::ABOUT_TO_RUN) { if (shouldRun && !internal->IsAboutToRunCanceled()) { internal->SetProgressMonitor(CreateMonitor(job)); //change from ABOUT_TO_RUN to RUNNING internal->InternalSetState(Job::RUNNING); break; } internal->SetAboutToRunCanceled(false); endJob = true; //fall through and end the job below } } if (endJob) { //job has been vetoed or canceled, so mark it as done EndJob(job,Status::CANCEL_STATUS(BERRY_STATUS_LOC), true); continue; } } m_JobListeners.Running(job); return job; }
//------------------------------------------------------------------------------ // Loop //------------------------------------------------------------------------------ void AnalysisMonoH::Loop(TString analysis, TString filename, float luminosity) { if (fChain == 0) return; Setup(analysis, filename, luminosity); // Define histograms //---------------------------------------------------------------------------- for (int j=0; j<ncut; j++) { for (int k=0; k<=njetbin; k++) { TString sbin = (k < njetbin) ? Form("/%djet", k) : ""; TString directory = scut[j] + sbin; root_output->cd(); if (k < njetbin) gDirectory->mkdir(directory); root_output->cd(directory); for (int i=ee; i<=ll; i++) { TString suffix = "_" + schannel[i]; DefineHistograms(i, j, k, suffix); h_fullpmet [i][j][k] = new TH1D("h_fullpmet" + suffix, "", 1000, 0., 1000); h_trkpmet [i][j][k] = new TH1D("h_trkpmet" + suffix, "", 1000, 0., 1000); h_deltarl1met [i][j][k] = new TH1D("h_deltarl1met" + suffix, "", 100, 0., 5); h_deltarl2met [i][j][k] = new TH1D("h_deltarl2met" + suffix, "", 100, 0., 5); h_deltarllmet [i][j][k] = new TH1D("h_deltarllmet" + suffix, "", 100, 0., 5); h_deltarjet1met [i][j][k] = new TH1D("h_deltarjet1met" + suffix, "", 100, 0., 5); h_deltarjet2met [i][j][k] = new TH1D("h_deltarjet2met" + suffix, "", 100, 0., 5); h_deltarjj [i][j][k] = new TH1D("h_deltarjj" + suffix, "", 100, 0., 5); h_deltarjjmet [i][j][k] = new TH1D("h_deltarjjmet" + suffix, "", 100, 0., 5); h_deltarlep1jet1 [i][j][k] = new TH1D("h_deltarlep1jet1" + suffix, "", 100, 0., 5); h_deltarlep1jet2 [i][j][k] = new TH1D("h_deltarlep1jet2" + suffix, "", 100, 0., 5); h_deltarlep2jet1 [i][j][k] = new TH1D("h_deltarlep2jet1" + suffix, "", 100, 0., 5); h_deltarlep2jet2 [i][j][k] = new TH1D("h_deltarlep2jet2" + suffix, "", 100, 0., 5); h_mllstar [i][j][k] = new TH1D("h_mllstar" + suffix, "", 3000, 0., 3000); //h_mnunu [i][j][k] = new TH1D("h_mnunu" + suffix, "", 10, 0., 10); h_mr [i][j][k] = new TH1D("h_mr" + suffix, "", 2000, 0., 2000); //h_met_m2l [i][j][k] = new TH2D("h_met_m2l" + suffix, "", 200, 0, 2000, 100, 0, 200); //h_met_deltaphill [i][j][k] = new TH2D("h_met_deltaphill" + suffix, "", 200, 0, 2000, 100, 0, 5); } } } root_output->cd(); // Loop over events //---------------------------------------------------------------------------- for (Long64_t jentry=0; jentry<_nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); PrintProgress(jentry, _nentries); EventSetup(); // Analysis //-------------------------------------------------------------------------- //if (Lepton1.flavour * Lepton2.flavour > 0) continue; //if (Lepton1.v.Pt() < 20.) continue; //if (Lepton2.v.Pt() < 20.) continue; // Let's trust our ntuples //-------------------------------------------------------------------------- if (std_vector_lepton_flavour->at(0)*std_vector_lepton_flavour->at(1) > 0) continue; if (std_vector_lepton_pt->at(0) < 20.) continue; if (std_vector_lepton_pt->at(1) < 20.) continue; if (std_vector_lepton_pt->at(2) > 10.) continue; _nelectron = 0; if (abs(Lepton1.flavour) == ELECTRON_FLAVOUR) _nelectron++; if (abs(Lepton2.flavour) == ELECTRON_FLAVOUR) _nelectron++; if (_nelectron == 2) _channel = ee; else if (_nelectron == 1) _channel = em; else if (_nelectron == 0) _channel = mm; _m2l = mll; _pt2l = ptll; // Fill histograms //-------------------------------------------------------------------------- bool pass = true; // WW cuts FillLevelHistograms(MonoH_00_Has2Leptons, pass); pass &= (mll > 12.); FillLevelHistograms(MonoH_01_Mll, pass); pass &= (MET.Et() > 20.); FillLevelHistograms(MonoH_02_PfMet, pass); bool pass_zveto = (_nelectron == 1 || fabs(mll - Z_MASS) > 15.); FillLevelHistograms(MonoH_03_ZVeto, pass && pass_zveto); pass &= (mpmet > 45. || (_nelectron == 1 && mpmet > 45.)); FillLevelHistograms(MonoH_04_MpMet, pass && pass_zveto); pass &= (_passdphiveto); FillLevelHistograms(MonoH_05_DPhiVeto, pass && pass_zveto); pass &= (_nelectron == 1 && ptll > 30. || _nelectron != 1 && ptll > 45.); FillLevelHistograms(MonoH_06_Ptll, pass && pass_zveto); bool passTopCR = pass && _nbjet20cmvav2l == 1; pass &= (_nbjet20cmvav2l == 0); FillLevelHistograms(MonoH_07_BVeto, pass && pass_zveto); if (_saveminitree && pass && pass_zveto) minitree->Fill(); //ZH->4l Control Region if (AnalysisLeptons[2].v.Pt() > 0 || AnalysisLeptons[3].v.Pt() > 0 ){ //cout<<"I passed! :)"<<endl; bool passZHCR = ( (fabs(_mll13 - Z_MASS) < 15. || fabs(_mll23 - Z_MASS) < 15. || fabs(_mll14 - Z_MASS) < 15. || fabs(_mll24 - Z_MASS) < 15. || fabs(_mll34 - Z_MASS) < 15.) && AnalysisLeptons[2].v.Pt() > 20. && AnalysisLeptons[3].v.Pt() > 20.); FillLevelHistograms(MonoH_08_ZHCR, passZHCR); // cout<<"Lepton 3 pT = "<<std_vector_lepton_pt->at(2)<<endl; // cout<<"Lepton 4 pT = "<<std_vector_lepton_pt->at(3)<<endl; // cout<<"-------------------------------------------"<<endl; } FillLevelHistograms(MonoH_09_TopCR, passTopCR && pass_zveto); // pass &= (!_foundsoftmuon); // FillLevelHistograms(MonoH_08_SoftMu, pass && pass_zveto); // monoH cuts // bool pass_monoh = (pass && pass_zveto); // bool pass_drll = (Lepton1.v.DeltaR(Lepton2.v) < 1.5); // FillLevelHistograms(MonoH_103_CR, pass_monoh && !pass_drll); // pass_monoh &= (_mc < 100.); // FillLevelHistograms(MonoH_100_Mc, pass_monoh); // pass_monoh &= pass_drll; // FillLevelHistograms(MonoH_101_DRll, pass_monoh); // pass_monoh &= (mpmet > 60.); // FillLevelHistograms(MonoH_102_MpMet, pass_monoh); // pass_monoh &= (mpmet > 100.); // FillLevelHistograms(MonoH_09_mpmet100, pass_monoh); // pass_monoh &= (mth > 200.); // FillLevelHistograms(MonoH_10_mth200, pass_monoh); // pass_monoh &= (Lepton1.v.DeltaPhi(MET) > 2.6); // FillLevelHistograms(MonoH_11_dphil1met, pass_monoh); // pass_monoh &= (Lepton2.v.DeltaPhi(MET) > 2.6); // FillLevelHistograms(MonoH_12_dphil2met, pass_monoh); // pass_monoh &= (drll < 0.8); // FillLevelHistograms(MonoH_13_deltarll, pass_monoh); // pass_monoh &= (mtw1 > 160.); // FillLevelHistograms(MonoH_14_mtw1, pass_monoh); // pass_monoh &= (mtw2 > 100.); // FillLevelHistograms(MonoH_15_mtw2, pass_monoh); // pass_monoh &= (metTtrk > 100.); // FillLevelHistograms(MonoH_16_trkmet, pass_monoh); } EndJob(); }
status_t PrinterDriver::PrintJob(BFile *spoolFile, BMessage *jobMsg) { if (!spoolFile || !fPrinterNode) return B_ERROR; fJobFile = spoolFile; print_file_header pfh; // read print file header fJobFile->Seek(0, SEEK_SET); fJobFile->Read(&pfh, sizeof(pfh)); // read job message BMessage msg; msg.Unflatten(fJobFile); BeginJob(); fPrinting = true; printf("PrinterDriver::PrintJob, print massage read from spool file\n"); jobMsg->PrintToStream(); printf("\nPrinterDriver::PrintJob, print massage passed to print job\n"); msg.PrintToStream(); printf("\n"); for (int32 page = 1; page <= pfh.page_count; ++page) { printf("PrinterDriver::PrintPage(): Faking print of page %" B_PRId32 "/ %" B_PRId32 "\n", page, pfh.page_count); } fJobFile->Seek(0, SEEK_SET); PrintJobReader reader(fJobFile); status_t status = reader.InitCheck(); printf("\nPrintJobReader::InitCheck(): %s\n", status == B_OK ? "B_OK" : "B_ERROR"); printf("PrintJobReader::NumberOfPages(): %" B_PRId32 "\n", reader.NumberOfPages()); printf("PrintJobReader::FirstPage(): %" B_PRId32 "\n", reader.FirstPage()); printf("PrintJobReader::LastPage(): %" B_PRId32 "\n", reader.LastPage()); BRect rect = reader.PaperRect(); printf("PrintJobReader::PaperRect(): BRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f)\n", rect.left, rect.top, rect.right, rect.bottom); rect = reader.PrintableRect(); printf("PrintJobReader::PrintableRect(): BRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f)\n", rect.left, rect.top, rect.right, rect.bottom); int32 xdpi, ydpi; reader.GetResolution(&xdpi, &ydpi); printf("PrintJobReader::GetResolution(): xdpi:%" B_PRId32 ", ydpi:%" B_PRId32 "\n", xdpi, ydpi); printf("PrintJobReader::GetScale(): %.1f\n", reader.GetScale()); fPrinting = false; EndJob(); return status; }
//------------------------------------------------------------------------------ // Loop //------------------------------------------------------------------------------ void AnalysisControl::Loop(TString analysis, TString filename, float luminosity) { if (fChain == 0) return; Setup(analysis, filename, luminosity); // Define histograms //---------------------------------------------------------------------------- root_output->cd(); for (int j=0; j<ncut; j++) { for (int k=0; k<=njetbin; k++) { TString sbin = (k < njetbin) ? Form("/%djet", k) : ""; TString directory = scut[j] + sbin; root_output->cd(); if (k < njetbin) gDirectory->mkdir(directory); root_output->cd(directory); for (int i=ee; i<=ll; i++) { TString suffix = "_" + schannel[i]; DefineHistograms(i, j, k, suffix); } } } root_output->cd(); // Loop over events //---------------------------------------------------------------------------- for (Long64_t jentry=0; jentry<_nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); PrintProgress(jentry, _nentries); EventSetup(); // Analysis //-------------------------------------------------------------------------- _nelectron = 0; if (abs(Lepton1.flavour) == ELECTRON_FLAVOUR) _nelectron++; if (abs(Lepton2.flavour) == ELECTRON_FLAVOUR) _nelectron++; if (_nelectron == 2) _channel = ee; else if (_nelectron == 1) _channel = em; else if (_nelectron == 0) _channel = mm; _m2l = mll; // Needs l2Sel _pt2l = ptll; // Needs l2Sel bool pass_2l = (Lepton1.flavour * Lepton2.flavour < 0); pass_2l &= (Lepton1.v.Pt() > 25.); pass_2l &= (Lepton2.v.Pt() > 20.); pass_2l &= (std_vector_lepton_pt->at(2) < 10.); pass_2l &= (_m2l > 20.); bool pass; // No cuts //-------------------------------------------------------------------------- pass = true; FillLevelHistograms(Control_00_NoCuts, pass); // Has 2 tight leptons //-------------------------------------------------------------------------- pass = pass_2l; FillLevelHistograms(Control_01_TwoLeptons, pass); if (_saveminitree && pass) minitree->Fill(); // R out/in //-------------------------------------------------------------------------- pass = pass_2l; pass &= (_nbjet30csvv2m > 0); FillLevelHistograms(Control_02_Routin, pass); // WW // https://github.com/latinos/PlotsConfigurations/blob/master/Configurations/ControlRegions/WW/Full2016/cuts.py //-------------------------------------------------------------------------- pass = mll > 80 && std_vector_lepton_pt->at(0) > 25 && std_vector_lepton_pt->at(1) > 13 && std_vector_lepton_pt->at(2) < 10 && metPfType1 > 20 && ptll > 30 && mth >= 60 && (std_vector_jet_pt->at(0) < 20 || std_vector_jet_cmvav2->at(0) < -0.5884) && (std_vector_jet_pt->at(1) < 20 || std_vector_jet_cmvav2->at(1) < -0.5884) && (std_vector_jet_pt->at(2) < 20 || std_vector_jet_cmvav2->at(2) < -0.5884) && (std_vector_jet_pt->at(3) < 20 || std_vector_jet_cmvav2->at(3) < -0.5884) && (std_vector_jet_pt->at(4) < 20 || std_vector_jet_cmvav2->at(4) < -0.5884) && (std_vector_jet_pt->at(5) < 20 || std_vector_jet_cmvav2->at(5) < -0.5884) && (std_vector_jet_pt->at(6) < 20 || std_vector_jet_cmvav2->at(6) < -0.5884) && (std_vector_jet_pt->at(7) < 20 || std_vector_jet_cmvav2->at(7) < -0.5884) && (std_vector_jet_pt->at(8) < 20 || std_vector_jet_cmvav2->at(8) < -0.5884) && (std_vector_jet_pt->at(9) < 20 || std_vector_jet_cmvav2->at(9) < -0.5884); FillLevelHistograms(Control_03_WW, pass); if (pass) EventDump(); // Top //-------------------------------------------------------------------------- pass = pass_2l; pass &= (_njet > 1); pass &= (_nbjet30csvv2m > 0); pass &= (_channel == em || fabs(_m2l - Z_MASS) > 15.); pass &= (MET.Et() > 45.); FillLevelHistograms(Control_04_Top, pass); } EndJob(); }
//------------------------------------------------------------------------------ // Loop //------------------------------------------------------------------------------ void AnalysisPR::Loop(TString analysis, TString filename, float luminosity) { if (fChain == 0) return; Setup(analysis, filename, luminosity); root_output->cd(); // Define prompt rate histograms //---------------------------------------------------------------------------- h_Muon_loose_pt_eta_PR = new TH2D("h_Muon_loose_pt_eta_PR", "", nptbin, ptbins, netabin, etabins); h_Muon_tight_pt_eta_PR = new TH2D("h_Muon_tight_pt_eta_PR", "", nptbin, ptbins, netabin, etabins); h_Ele_loose_pt_eta_PR = new TH2D("h_Ele_loose_pt_eta_PR", "", nptbin, ptbins, netabin, etabins); h_Ele_tight_pt_eta_PR = new TH2D("h_Ele_tight_pt_eta_PR", "", nptbin, ptbins, netabin, etabins); h_Muon_loose_pt_PR = new TH1D("h_Muon_loose_pt_PR", "", nptbin, ptbins); h_Muon_tight_pt_PR = new TH1D("h_Muon_tight_pt_PR", "", nptbin, ptbins); h_Ele_loose_pt_PR = new TH1D("h_Ele_loose_pt_PR", "", nptbin, ptbins); h_Ele_tight_pt_PR = new TH1D("h_Ele_tight_pt_PR", "", nptbin, ptbins); h_Muon_loose_eta_PR = new TH1D("h_Muon_loose_eta_PR", "", netabin, etabins); h_Muon_tight_eta_PR = new TH1D("h_Muon_tight_eta_PR", "", netabin, etabins); h_Ele_loose_eta_PR = new TH1D("h_Ele_loose_eta_PR", "", netabin, etabins); h_Ele_tight_eta_PR = new TH1D("h_Ele_tight_eta_PR", "", netabin, etabins); // Loop over events //---------------------------------------------------------------------------- for (Long64_t jentry=0; jentry<_nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); PrintProgress(jentry, _nentries); EventSetup(); _channel = (abs(Lepton1.flavour) == ELECTRON_FLAVOUR) ? e : m; _leptonPtMin = (_channel == e) ? 13 : 10; _leptonEtaMax = (_channel == e) ? 2.5 : 2.4; if (Lepton1.v.Pt() < _leptonPtMin) continue; if (fabs(Lepton1.v.Eta()) > _leptonEtaMax) continue; // Make Z candidate //-------------------------------------------------------------------------- _Zlepton1type = Loose; _Zlepton2type = Loose; _m2l = -999; if (AnalysisLeptons.size() >= 2) { for (int iLep1=0; iLep1<AnalysisLeptons.size(); iLep1++) { if (AnalysisLeptons[iLep1].v.Pt() < 10.) continue; for (int iLep2=iLep1+1; iLep2<AnalysisLeptons.size(); iLep2++) { if (AnalysisLeptons[iLep2].v.Pt() < 10.) continue; if ((AnalysisLeptons[iLep1].flavour + AnalysisLeptons[iLep2].flavour) != 0.) continue; float inv_mass = (AnalysisLeptons[iLep1].v + AnalysisLeptons[iLep2].v).M(); if (_m2l < 0 || fabs(inv_mass - Z_MASS) < fabs(_m2l - Z_MASS)) { _m2l = inv_mass; // Is the first Z lepton tight? if (AnalysisLeptons[iLep1].type > 0.5 && AnalysisLeptons[iLep1].flavour == ELECTRON_FLAVOUR) { _Zlepton1type = Tight; _Zdecayflavour = ELECTRON_FLAVOUR; } else if (AnalysisLeptons[iLep1].type > 0.5 && AnalysisLeptons[iLep1].flavour == MUON_FLAVOUR) { _Zlepton1type = Tight; _Zdecayflavour = MUON_FLAVOUR; } // Is the second Z lepton tight? if (AnalysisLeptons[iLep2].type > 0.5 && AnalysisLeptons[iLep2].flavour == ELECTRON_FLAVOUR) { _Zlepton2type = Tight; } else if (AnalysisLeptons[iLep2].type > 0.5 && AnalysisLeptons[iLep2].flavour == MUON_FLAVOUR) { _Zlepton2type = Tight; } } } } } // Get the event weight //-------------------------------------------------------------------------- bool passTrigger; if (_ismc) { passTrigger = true; _event_weight = (baseW / 1e3) * puW; if (GEN_weight_SM) _event_weight *= GEN_weight_SM / abs(GEN_weight_SM); // Muons //------------------------------------------------------------------------ if (_channel == m) { (Lepton1.v.Pt() <= 20.) ? _event_weight *= 7.339 : _event_weight *= 217.553; // For 36/fb } // Electrons //------------------------------------------------------------------------ if (_channel == e) { (Lepton1.v.Pt() <= 25.) ? _event_weight *= 14.888 : _event_weight *= 63.046; } } else { _event_weight = 1.0; passTrigger = false; // Muons //------------------------------------------------------------------------ if (_sample.Contains("DoubleMuon") && _channel == m) { if (Lepton1.v.Pt() <= 20. && std_vector_trigger->at(22)) { // HLT_Mu8_TrkIsoVVL_v* passTrigger = true; } else if (Lepton1.v.Pt() > 20. && std_vector_trigger->at(23)) { // HLT_Mu17_TrkIsoVVL_v* passTrigger = true; } } // Electrons //------------------------------------------------------------------------ if (_sample.Contains("DoubleEG") && _channel == e) { if (Lepton1.v.Pt() <= 25. && std_vector_trigger->at(31)) { // HLT_Ele12_CaloIdL_TrackIdL_IsoVL_PFJet30_v* passTrigger = true; } else if (Lepton1.v.Pt() > 25. && std_vector_trigger->at(33)) { // HLT_Ele23_CaloIdL_TrackIdL_IsoVL_PFJet30_v* passTrigger = true; } } } // Prompt rate from MC //-------------------------------------------------------------------------- bool pass = true; pass &= (76. < _m2l && 106. > _m2l); pass &= (_mtw < 20.); if (pass && _sample.Contains("DYJetsToLL") && _Zlepton1type == Tight) { float Zlep2pt = std_vector_lepton_pt->at(1); float Zlep2eta = fabs(std_vector_lepton_eta->at(1)); if (fabs(_Zdecayflavour) == ELECTRON_FLAVOUR) { h_Ele_loose_pt_eta_PR->Fill(Zlep2pt, Zlep2eta, _event_weight); h_Ele_loose_pt_PR ->Fill(Zlep2pt, _event_weight); h_Ele_loose_eta_PR ->Fill(Zlep2eta, _event_weight); if (_Zlepton2type == Tight) { h_Ele_tight_pt_eta_PR->Fill(Zlep2pt, Zlep2eta, _event_weight); h_Ele_tight_pt_PR ->Fill(Zlep2pt, _event_weight); h_Ele_tight_eta_PR ->Fill(Zlep2eta, _event_weight); } } else if (fabs(_Zdecayflavour) == MUON_FLAVOUR) { h_Muon_loose_pt_eta_PR->Fill(Zlep2pt, Zlep2eta, _event_weight); h_Muon_loose_pt_PR ->Fill(Zlep2pt, _event_weight); h_Muon_loose_eta_PR ->Fill(Zlep2eta, _event_weight); if (_Zlepton2type == Tight) { h_Muon_tight_pt_eta_PR->Fill(Zlep2pt, Zlep2eta, _event_weight); h_Muon_tight_pt_PR ->Fill(Zlep2pt, _event_weight); h_Muon_tight_eta_PR ->Fill(Zlep2eta, _event_weight); } } } } EndJob(); }
status_t PrinterDriver::PrintJob ( BFile *jobFile, // spool file BNode *printerNode, // printer node, used by OpenTransport() to find & load transport add-on BMessage *jobMsg // job message ) { print_file_header pfh; status_t status; BMessage *msg; int32 page; uint32 copy; uint32 copies; const int32 passes = 2; fJobFile = jobFile; fPrinterNode = printerNode; fJobMsg = jobMsg; if (!fJobFile || !fPrinterNode) return B_ERROR; if (fPrintTransport.Open(fPrinterNode) != B_OK) { return B_ERROR; } if (fPrintTransport.IsPrintToFileCanceled()) { return B_OK; } // read print file header fJobFile->Seek(0, SEEK_SET); fJobFile->Read(&pfh, sizeof(pfh)); // read job message fJobMsg = msg = new BMessage(); msg->Unflatten(fJobFile); // We have to load the settings here for Dano/Zeta because they don't store // all fields from the message returned by config_job in the job file! PrinterSettings::Read(printerNode, msg, PrinterSettings::kJobSettings); if (msg->HasInt32("copies")) { copies = msg->FindInt32("copies"); } else { copies = 1; } // force creation of Report object Report::Instance(); // show status window StatusWindow* statusWindow = new StatusWindow(passes, pfh.page_count, this); status = BeginJob(); fPrinting = true; for (fPass = 0; fPass < passes && status == B_OK && fPrinting; fPass++) { for (copy = 0; copy < copies && status == B_OK && fPrinting; copy++) { for (page = 1; page <= pfh.page_count && status == B_OK && fPrinting; page++) { statusWindow->NextPage(); status = PrintPage(page, pfh.page_count); } // re-read job message for next page fJobFile->Seek(sizeof(pfh), SEEK_SET); msg->Unflatten(fJobFile); } } status_t s = EndJob(); if (status == B_OK) status = s; delete fJobMsg; // close status window if (Report::Instance()->CountItems() != 0) { statusWindow->WaitForClose(); } if (statusWindow->Lock()) { statusWindow->Quit(); } // delete Report object Report::Instance()->Free(); return status; }
//------------------------------------------------------------------------------ // Loop //------------------------------------------------------------------------------ void AnalysisFR::Loop(TString analysis, TString filename, float luminosity) { if (fChain == 0) return; Setup(analysis, filename, luminosity); // Define fake rate histograms //---------------------------------------------------------------------------- for (int i=0; i<ncut; i++) { TString directory = scut[i]; root_output->cd(); gDirectory->mkdir(directory); root_output->cd(directory); for (int j=0; j<njetet; j++) { TString muonsuffix = Form("_%.0fGeV", muonjetet[j]); TString elesuffix = Form("_%.0fGeV", elejetet[j]); h_Muon_loose_pt_eta_bin[i][j] = new TH2D("h_Muon_loose_pt_eta_bin" + muonsuffix, "", nptbin, ptbins, netabin, etabins); h_Muon_tight_pt_eta_bin[i][j] = new TH2D("h_Muon_tight_pt_eta_bin" + muonsuffix, "", nptbin, ptbins, netabin, etabins); h_Ele_loose_pt_eta_bin [i][j] = new TH2D("h_Ele_loose_pt_eta_bin" + elesuffix, "", nptbin, ptbins, netabin, etabins); h_Ele_tight_pt_eta_bin [i][j] = new TH2D("h_Ele_tight_pt_eta_bin" + elesuffix, "", nptbin, ptbins, netabin, etabins); h_Muon_loose_pt_bin[i][j] = new TH1D("h_Muon_loose_pt_bin" + muonsuffix, "", nptbin, ptbins); h_Muon_tight_pt_bin[i][j] = new TH1D("h_Muon_tight_pt_bin" + muonsuffix, "", nptbin, ptbins); h_Ele_loose_pt_bin [i][j] = new TH1D("h_Ele_loose_pt_bin" + elesuffix, "", nptbin, ptbins); h_Ele_tight_pt_bin [i][j] = new TH1D("h_Ele_tight_pt_bin" + elesuffix, "", nptbin, ptbins); h_Muon_loose_eta_bin[i][j] = new TH1D("h_Muon_loose_eta_bin" + muonsuffix, "", netabin, etabins); h_Muon_tight_eta_bin[i][j] = new TH1D("h_Muon_tight_eta_bin" + muonsuffix, "", netabin, etabins); h_Ele_loose_eta_bin [i][j] = new TH1D("h_Ele_loose_eta_bin" + elesuffix, "", netabin, etabins); h_Ele_tight_eta_bin [i][j] = new TH1D("h_Ele_tight_eta_bin" + elesuffix, "", netabin, etabins); h_Muon_loose_pt[i][j] = new TH1D("h_Muon_loose_pt" + muonsuffix, "", 1000, 0, 200); h_Muon_tight_pt[i][j] = new TH1D("h_Muon_tight_pt" + muonsuffix, "", 1000, 0, 200); h_Ele_loose_pt [i][j] = new TH1D("h_Ele_loose_pt" + elesuffix, "", 1000, 0, 200); h_Ele_tight_pt [i][j] = new TH1D("h_Ele_tight_pt" + elesuffix, "", 1000, 0, 200); h_Muon_loose_mtw[i][j] = new TH1D("h_Muon_loose_mtw" + muonsuffix, "", 1000, 0, 200); h_Muon_tight_mtw[i][j] = new TH1D("h_Muon_tight_mtw" + muonsuffix, "", 1000, 0, 200); h_Ele_loose_mtw [i][j] = new TH1D("h_Ele_loose_mtw" + elesuffix, "", 1000, 0, 200); h_Ele_tight_mtw [i][j] = new TH1D("h_Ele_tight_mtw" + elesuffix, "", 1000, 0, 200); h_Muon_loose_m2l[i][j] = new TH1D("h_Muon_loose_m2l" + muonsuffix, "", 1000, 0, 200); h_Muon_tight_m2l[i][j] = new TH1D("h_Muon_tight_m2l" + muonsuffix, "", 1000, 0, 200); h_Ele_loose_m2l [i][j] = new TH1D("h_Ele_loose_m2l" + elesuffix, "", 1000, 0, 200); h_Ele_tight_m2l [i][j] = new TH1D("h_Ele_tight_m2l" + elesuffix, "", 1000, 0, 200); // Define effective luminosity estimation histograms //------------------------------------------------------------------------ h_Muon_loose_pt_m2l[i][j] = new TH2D("h_Muon_loose_pt_m2l" + muonsuffix, "", 200, 0, 200, nptbin, ptbins); h_Muon_tight_pt_m2l[i][j] = new TH2D("h_Muon_tight_pt_m2l" + muonsuffix, "", 200, 0, 200, nptbin, ptbins); h_Ele_loose_pt_m2l [i][j] = new TH2D("h_Ele_loose_pt_m2l" + elesuffix, "", 200, 0, 200, nptbin, ptbins); h_Ele_tight_pt_m2l [i][j] = new TH2D("h_Ele_tight_pt_m2l" + elesuffix, "", 200, 0, 200, nptbin, ptbins); } } root_output->cd(); // Loop over events //---------------------------------------------------------------------------- for (Long64_t jentry=0; jentry<_nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); PrintProgress(jentry, _nentries); EventSetup(); _channel = (abs(Lepton1.flavour) == ELECTRON_FLAVOUR) ? e : m; _leptonPtMin = (_channel == e) ? 13 : 10; _leptonEtaMax = (_channel == e) ? 2.5 : 2.4; if (Lepton1.v.Pt() < _leptonPtMin) continue; if (fabs(Lepton1.v.Eta()) > _leptonEtaMax) continue; // Get the event weight //-------------------------------------------------------------------------- bool passTrigger; if (_ismc) { passTrigger = true; Float_t corrected_baseW = baseW; if (_sample.Contains("DYJetsToLL_M-10to50")) corrected_baseW = 0.829752445221; if (_sample.Contains("DYJetsToLL_M-50")) corrected_baseW = 0.318902641535; _base_weight = (corrected_baseW / 1e3) * puW6p3 * GEN_weight_SM / abs(GEN_weight_SM); _event_weight = _base_weight; // Muons //------------------------------------------------------------------------ if (_channel == m) { (Lepton1.v.Pt() <= 20.) ? _event_weight *= 5.86 : _event_weight *= 163.84; } // Electrons //------------------------------------------------------------------------ if (_channel == e) { (Lepton1.v.Pt() <= 25.) ? _event_weight *= 8.51 : _event_weight *= 42.34; } } else { _event_weight = 1.0; passTrigger = false; // Muons //------------------------------------------------------------------------ if (_sample.Contains("DoubleMuon") && _channel == m) { if (Lepton1.v.Pt() <= 20. && std_vector_trigger->at(22)) { // HLT_Mu8_TrkIsoVVL_v* passTrigger = true; } else if (Lepton1.v.Pt() > 20. && std_vector_trigger->at(23)) { // HLT_Mu17_TrkIsoVVL_v* passTrigger = true; } } // Electrons //------------------------------------------------------------------------ if (_sample.Contains("DoubleEG") && _channel == e) { if (Lepton1.v.Pt() <= 25. && std_vector_trigger->at(31)) { // HLT_Ele12_CaloIdL_TrackIdL_IsoVL_PFJet30_v* passTrigger = true; } else if (Lepton1.v.Pt() > 25. && std_vector_trigger->at(33)) { // HLT_Ele23_CaloIdL_TrackIdL_IsoVL_PFJet30_v* passTrigger = true; } } } // Get the jets and the W transverse mass //-------------------------------------------------------------------------- GetAwayJets(); GetMt(Lepton1, _mtw); // Preselection //-------------------------------------------------------------------------- if (!passTrigger) continue; if (AnalysisJets.size() < 1) continue; // Get histograms for different jet pt thresholds //-------------------------------------------------------------------------- for (int i=0; i<njetet; i++) { _inputJetEt = (_channel == e) ? elejetet[i] : muonjetet[i]; if (AnalysisJets[0].v.Pt() < _inputJetEt) continue; // QCD region //------------------------------------------------------------------------ bool pass; pass = (_nlepton == 1); FillLevelHistograms(FR_00_QCD, i, pass); } } EndJob(); }
/* Main function */ int main(int argc, char** argv) { if( BeginJob( argc, argv ) == 0 ) { cout<<"BeginJob failed"<<endl; return 0; } /* Layer 1. The main loop over every stream entries */ /* ------------------------------------------------ */ CurrRun.Run = -1; cout<<"StreamChain add "<<StreamChain<<endl; unsigned int entries = StreamChain->GetEntries(); for( unsigned int entry=0; entry<entries; entry++ ) { unsigned int localentry = StreamChain->LoadTree(entry); int ret = Reader->GetEntry( localentry ); if( ret==0 ) { cout<<"Error: Read error"<<endl; return 1; } /* Process run information and possible long time jump */ if( Reader->Run != CurrRun.Run ) { if( CurrRun.Run != -1 ) { /* End Run */ if( EndRun( Reader ) == 0 ) { cout<<"EndRun failed"<<endl; return 0; } } /* Begin Run */ if( BeginRun( Reader ) == 0 ) { cout<<"BeginRun failed"<<endl; return 0; } } /*** Test each entry here ***/ SubEvt* pSubEvt = new SubEvt( Reader ); TimeStamp NewTime( pSubEvt->TrigSec, pSubEvt->TrigNano ); if( (NewTime - CurrRun.CurrTime).GetSeconds() > 120 /* Two minutes */ ) { CurrRun.Breaks.push_back( CurrRun.CurrTime ); CurrRun.Breaks.push_back( NewTime ); CurrRun.SkipTime.Add( (NewTime - CurrRun.CurrTime).GetSeconds() ); } CurrRun.CurrTime = NewTime; /* Cache all temporal related event. Give a chance to clean up the queue and do muon Id */ SubEvtQueue PassedQueue = CachedQueueInsert( NewTime, pSubEvt ); /* Layer 2. The main loop over every non-muon SubEvt */ /* ------------------------------------------------- */ SubEvtQueueIterator it, it_end = PassedQueue.end(); for( it = PassedQueue.begin(); it != it_end; it++ ) { /* Build delay coincident event */ SubEvt* pSubEvt = it->second; int ret = BuildEvent( pSubEvt ); if( ret == 0 ) { cout<<"Error in BuildEvent"<<endl; } delete pSubEvt; } /*** End of SubEvt loop ***/ } /*** End of stream entry loop ***/ if( EndRun( Reader ) == 0 ) { cout<<"EndRun failed"<<endl; return 0; } /* End Job */ /* ------- */ if( EndJob() == 0 ) { cout<<"BeginJob failed"<<endl; return 0; } return 1; }