void CamaraLucida::init( string config_path, Depthmap* depthmap ) { this->depthmap = depthmap; this->config_path = config_path; xml.loadFile(config_path); xml.pushTag("camaralucida"); int dxoff = xml.getValue("depth_xoff", -8); init_keys(); init_events(); config = new Config( &xml ); Calibration calib( config ); proj = new OpticalDevice( calib.proj_config() ); depth = new cml::Kinect( calib.depth_config(), dxoff ); rgb = new OpticalDevice( calib.rgb_config() ); mesh = new Mesh( config->mesh_step, depth->width(), depth->height(), config->tex_width, config->tex_height ); renderer = new Renderer(config, proj, depth, rgb); depthmap->init( depth, mesh ); _debug = false; _render_help = false; };
void* get_result( void *ptr ) { char buf[1024]; int fd=*((int*)ptr); char* pos; int n; int pipe; char type; pos=&buf[0]; while(1){ if((n=read(fd, pos, 1))==1 ){ if(*pos=='\n'){ *pos=0; if(pos!=buf){ //接收到一个反馈 printf("feedback::%s\n",buf); fflush(stdout); calib(buf,pipe,type); check_stability(pipe,type); } pos=&buf[0]; continue; } pos++; } } }
static void keyEvent( unsigned char key, int x, int y) { CvPoint2D32f *p1, *p2; int i; if( key == 0x1b || key == 'q' || key == 'Q' ) { cleanup(); } if( cornerFlag && key==' ' ) { cvFindCornerSubPix( calibImage, corners, chessboardCornerNumX*chessboardCornerNumY, cvSize(5,5), cvSize(-1,-1), cvTermCriteria (CV_TERMCRIT_ITER, 100, 0.1) ); p1 = &corners[0]; p2 = &cornerSet[capturedImageNum*chessboardCornerNumX*chessboardCornerNumY]; for( i = 0; i < chessboardCornerNumX*chessboardCornerNumY; i++ ) { *(p2++) = *(p1++); } capturedImageNum++; ARLOG("---------- %2d/%2d -----------\n", capturedImageNum, calibImageNum); for( i = 0; i < chessboardCornerNumX*chessboardCornerNumY; i++ ) { ARLOG(" %f, %f\n", corners[i].x, corners[i].y); } ARLOG("---------- %2d/%2d -----------\n", capturedImageNum, calibImageNum); if( capturedImageNum == calibImageNum ) { calib(); cleanup(); } } }
static void keyEvent( unsigned char key, int x, int y) { int i; if( key == 0x1b || key == 'q' || key == 'Q' ) { cleanup(); } if( cornerFlag && key==' ' ) { cvFindCornerSubPix( calibImageL, cornersL, chessboardCornerNumX*chessboardCornerNumY, cvSize(5,5), cvSize(-1,-1), cvTermCriteria(CV_TERMCRIT_ITER, 100, 0.1) ); for( i = 0; i < chessboardCornerNumX*chessboardCornerNumY; i++ ) { arParamObserv2Ideal(paramL.dist_factor, (double)cornersL[i].x, (double)cornersL[i].y, &calibData[capturedImageNum].screenCoordL[i].x, &calibData[capturedImageNum].screenCoordL[i].y, paramL.dist_function_version); } cvFindCornerSubPix( calibImageR, cornersR, chessboardCornerNumX*chessboardCornerNumY, cvSize(5,5), cvSize(-1,-1), cvTermCriteria(CV_TERMCRIT_ITER, 100, 0.1) ); for( i = 0; i < chessboardCornerNumX*chessboardCornerNumY; i++ ) { arParamObserv2Ideal(paramR.dist_factor, (double)cornersR[i].x, (double)cornersR[i].y, &calibData[capturedImageNum].screenCoordR[i].x, &calibData[capturedImageNum].screenCoordR[i].y, paramR.dist_function_version); } ARLOG("---------- %2d/%2d -----------\n", capturedImageNum+1, calibImageNum); for( i = 0; i < chessboardCornerNumX*chessboardCornerNumY; i++ ) { ARLOG(" %f, %f ---- %f, %f\n", calibData[capturedImageNum].screenCoordL[i].x, calibData[capturedImageNum].screenCoordL[i].y, calibData[capturedImageNum].screenCoordR[i].x, calibData[capturedImageNum].screenCoordR[i].y); } ARLOG("---------- %2d/%2d -----------\n", capturedImageNum+1, calibImageNum); capturedImageNum++; if( capturedImageNum == calibImageNum ) { calib(); cleanup(); } } }
void CalibProcNode::ImageCb(const sensor_msgs::ImageConstPtr &image_msg) { cv::Mat image = cv_bridge::toCvCopy(image_msg, image_msg->encoding)->image; cv::Mat inverted; cv::bitwise_not(image, inverted); /* // Threshold cv::Mat thresh; cv::adaptiveThreshold(image, thresh, 255, config_.thresh_type, cv::THRESH_BINARY, config_.thresh_window, 0); cv::imshow("thresh", thresh); // Gaussian blur cv::Mat gauss; cv::GaussianBlur(thresh, gauss, cv::Size(), config_.sigma, config_.sigma, cv::BORDER_DEFAULT); cv::imshow("gauss", gauss); // Erosion cv::Mat eroded; int erosion_size = config_.erosion_size; cv::Mat element = cv::getStructuringElement( cv::MORPH_RECT, cv::Size(2 * erosion_size + 1, 2 * erosion_size + 1), cv::Point(erosion_size, erosion_size)); cv::erode(thresh, eroded, element); cv::imshow("erosion", eroded); // Contour std::vector<std::vector<cv::Point>> contours; cv::findContours(eroded, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); cv::Mat ctr_image; cv::cvtColor(image, ctr_image, CV_GRAY2BGR); for (size_t i = 0; i < contours.size(); ++i) { double area = cv::contourArea(contours[i]); if (area > config_.min_area && area < config_.max_area) { cv::drawContours(ctr_image, contours, i, cv::Scalar(255, 0, 0), 2, 8); } } cv::imshow("contour", ctr_image); */ // cv::Mat display; // DetectAndDrawCriclesGrid( // inverted, cv::Size(config_.circles_per_row, config_.circles_per_col), // display); // Display // cv::imshow("display", display); // cv::waitKey(1); cv::Mat calib(inverted); // Publish processed image cv_bridge::CvImage cvimg_calib(image_msg->header, image_msg->encoding, calib); pub_calib_.publish(cvimg_calib.toImageMsg()); }
void ImageCallback( const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::CameraInfoConstPtr& info ) { cv_bridge::CvImageConstPtr frame; try { frame = cv_bridge::toCvShare( msg, msg->encoding ); } catch( cv_bridge::Exception& e ) { ROS_ERROR( "cv_bridge exception: %s", e.what() ); return; } camplex::CameraCalibration calib( "", *info ); if( _useMaps && !_mapsInited ) { _distMap1 = cv::Mat( frame->image.size(), CV_16SC2 ); _distMap2 = cv::Mat( frame->image.size(), CV_16UC1 ); cv::initUndistortRectifyMap( calib.GetIntrinsicMatrix(), calib.GetDistortionCoeffs(), cv::noArray(), calib.GetIntrinsicMatrix(), frame->image.size(), CV_16SC2, _distMap1, _distMap2 ); _mapsInited = true; } cv::Mat undistorted( frame->image.size(), frame->image.type() ); if( !_useMaps ) { cv::undistort( frame->image, undistorted, calib.GetIntrinsicMatrix(), calib.GetDistortionCoeffs() ); } else { cv::remap( frame->image, undistorted, _distMap1, _distMap2, cv::INTER_LINEAR ); } sensor_msgs::ImagePtr outImage = cv_bridge::CvImage( msg->header, msg->encoding, undistorted ).toImageMsg(); sensor_msgs::CameraInfoPtr outInfo = boost::make_shared<sensor_msgs::CameraInfo>( *info ); outInfo->D = std::vector<double>( 5, 0.0 ); _imagePub.publish( outImage, outInfo ); }
std::vector<sample_t> CalibrationInverter::getXyzSamples(std::size_t i) { std::vector<sample_t> calib_samples{}; auto const& calib = m_data_volumes_xyz[i]; calib_samples.reserve(calib.numVoxels()); glm::uvec3 const& dims{calib.res()}; for(unsigned x = 0; x < dims.x; ++x) { for(unsigned y = 0; y < dims.y; ++y) { for(unsigned z = 0; z < dims.z; ++z) { calib_samples.emplace_back(calib(x,y,z), glm::uvec3{x, y, z}); } } } return calib_samples; }
void MainWindow::createConnections() { connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newproject())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openproject())); connect(ui->actionOpenCamera, SIGNAL(triggered()), this, SLOT(opencamera())); connect(ui->actionFocusAssistant, SIGNAL(triggered()), this, SLOT(startfocusassistant())); connect(ui->leftExSlider,SIGNAL(valueChanged(int)),this,SLOT(setexposure())); connect(ui->rightExSlider,SIGNAL(valueChanged(int)),this,SLOT(setexposure())); connect(ui->actionBasler, SIGNAL(triggered()), this, SLOT(usebasler()));//暂时用来调试的功能 connect(ui->actionProjector,SIGNAL(triggered()),this,SLOT(projectorcontrol())); connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(selectPath(int))); connect(ui->actionCalib, SIGNAL(triggered()), this, SLOT(calib())); connect(ui->captureButton, SIGNAL(clicked()), this, SLOT(capturecalib())); connect(ui->redoButton, SIGNAL(clicked()), this, SLOT(redocapture())); connect(ui->calibButton,SIGNAL(clicked()),this,SLOT(calibration())); connect(ui->actionScan,SIGNAL(triggered()),this,SLOT(scan())); connect(ui->findPointButton,SIGNAL(clicked()),this,SLOT(pointmatch())); connect(ui->reFindButton,SIGNAL(clicked()),this,SLOT(refindmatch())); connect(ui->startScanButton, SIGNAL(clicked()), this, SLOT(startscan())); connect(ui->multiFreqTest, SIGNAL(clicked()), this, SLOT(testmulitfreq())); //connect(ui->testR, SIGNAL(clicked()), this, SLOT(test()));//用于测试功能的暂时按键 connect(ui->actionReconstruct,SIGNAL(triggered()),this,SLOT(reconstruct())); connect(ui->reconstructionButton,SIGNAL(clicked()),this,SLOT(startreconstruct())); connect(ui->actionSet, SIGNAL(triggered()), this, SLOT(set())); connect(ui->actionChinese, SIGNAL(triggered()), this, SLOT(switchlanguage())); connect(ui->actionEnglish, SIGNAL(triggered()), this, SLOT(switchlanguage())); connect(ui->pSizeValue, SIGNAL(valueChanged(int)), this, SLOT(changePointSize(int))); connect(ui->loadTest, SIGNAL(clicked()), this, SLOT(loadTestModel())); connect(ui->actionExit, SIGNAL(triggered()), pj, SLOT(close()));//解决投影窗口不能关掉的问题 connect(ui->actionExit, SIGNAL(triggered()), fa, SLOT(close())); connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close())); }
int main (void){ cpu_wakeup_init(); clock_init(); gpio_init(); gpio_write(GPIO_PD7, 0); gpio_set_output_en(GPIO_PD7, 1); i2c_init(); wd_stop(); sleep_us(50*1000); mouse_sensor_no_fifo_init(); sleep_us(1000*1000); // for L3G, must delay enough time s16 avg_data[6]; calib(64, avg_data); flash_erase_sector(AIRMOUSE_CALIBRATION_ADDR); flash_write_page(AIRMOUSE_CALIBRATION_ADDR, 12, avg_data); while (1); return 0; }
void HH4bBtagEffBase_80_v2(int wMs,int wM, string st,string st2,string option=""){ //1=signal ,0=QCD ,2=data----------------------------------------------------------- int nameRoot=1; if((st2.find("QCD")!= std::string::npos)|| (st2.find("bGen")!= std::string::npos)|| (st2.find("bEnriched")!= std::string::npos))nameRoot=0; if(st2.find("data")!= std::string::npos)nameRoot=2; //Thea correction--------------------- TFile *f3; f3=TFile::Open("puppiCorr.root"); TF1* tf1[3]; tf1[0]=(TF1 *) f3->FindObjectAny("puppiJECcorr_gen"); tf1[1]=(TF1 *) f3->FindObjectAny("puppiJECcorr_reco_0eta1v3"); tf1[2]=(TF1 *) f3->FindObjectAny("puppiJECcorr_reco_1v3eta2v5"); //option----------------------------------------------------------- int JESOption=0; if(option.find("JESUp")!= std::string::npos)JESOption=1; if(option.find("JESDown")!= std::string::npos)JESOption=2; if(option.find("BtagUp")!= std::string::npos)JESOption=3; if(option.find("BtagDown")!= std::string::npos)JESOption=4; if(option.find("tau21Up")!= std::string::npos)JESOption=5; if(option.find("tau21Down")!= std::string::npos)JESOption=6; cout<<"JESOption = "<<JESOption<<endl; bool printHighPtSubjet=0; bool isFast=1; //tuple tree and cutflow variables------------------------------------------------------------------------------------ TFile *f; TTree *tree; double nPass[30]={0},total=0; double fixScaleNum[2]={0}; //using for Btag Eff ----------------------------------------------------------------------------- string btagsystematicsType="central"; if(JESOption==3)btagsystematicsType="up"; else if(JESOption==4)btagsystematicsType="down"; BTagCalibration calib("CSVv2L", "subjet_CSVv2_ichep.csv"); BTagCalibrationReader LF(BTagEntry::OP_LOOSE,"central", {"up", "down"}); BTagCalibrationReader HFC(BTagEntry::OP_LOOSE, "central", {"up", "down"}); // other sys types BTagCalibrationReader HF(BTagEntry::OP_LOOSE,"central",{"up", "down"}); // other sys types LF.load(calib, BTagEntry::FLAV_UDSG, // btag flavour "incl"); // measurement type HFC.load(calib, BTagEntry::FLAV_C, // btag flavour "lt"); // measurement type HF.load(calib, BTagEntry::FLAV_B, // btag flavour "lt"); // measurement type TFile *f1; if(nameRoot==2)f1=TFile::Open("btagEffSource/data.root"); else if (nameRoot!=2 && (JESOption==0||JESOption==3||JESOption==4||JESOption==5||JESOption==6))f1=TFile::Open(Form("btagEffSource/%s.root",st2.data())); else if (nameRoot!=2 && JESOption==1)f1=TFile::Open(Form("btagEffSource/%s_JESUp.root",st2.data())); else if (nameRoot!=2 && JESOption==2)f1=TFile::Open(Form("btagEffSource/%s_JESDown.root",st2.data())); TH1D* th1[6]; string btaggingEff[6]={"effD_b","effN_b","effD_c","effN_c","effD_l","effN_l"}; for(int i=0;i<6;i++){ th1[i]=(TH1D*)f1->FindObjectAny(Form("%s_1d",btaggingEff[i].data())); if(i==1||i==3||i==5)th1[i]->Divide(th1[i-1]); } //saving variables---------------------------------------------------------------------------------------- TH1D * th5[300],* th_flavor[4][300]; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ for(int k=0;k<5;k++){ th5[(i*2+j)*5+k]=new TH1D(Form("Pt_j%d_sj%d_%db",i,j,k),Form("Pt_j%d_sj%d_%db",i,j,k),200,0,2000); th5[(i*2+j)*5+k+20]=new TH1D(Form("Eta_j%d_sj%d_%db",i,j,k),Form("Eta_j%d_sj%d_%db",i,j,k),60,-3,3); th5[(i*2+j)*5+k+85]=new TH1D(Form("subCSV_j%d_sj%d_%db",i,j,k),Form("subCSV_j%d_sj%d_%db",i,j,k),20,0,1); th5[(i*2+j)*5+k+194]=new TH1D(Form("subCSVCut_j%d_sj%d_%db",i,j,k),Form("subCSVCut_j%d_sj%d_%db",i,j,k),20,0,1); } } for(int k=0;k<5;k++){ th5[i*5+k+40]=new TH1D(Form("deltaR_j%d_%db",i,k),Form("deltaR_j%d_%db",i,k),20,0,1); th5[i*5+k+50]=new TH1D(Form("Pt_j%d_%db",i,k),Form("Pt_j%d_%db",i,k),200,0,2000); th5[i*5+k+60]=new TH1D(Form("Eta_j%d_%db",i,k),Form("Eta_j%d_%db",i,k),60,-3,3); th5[i*5+k+70]=new TH1D(Form("prMassL2L3_j%d_%db",i,k),Form("prMassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+105]=new TH1D(Form("tau21_j%d_%db",i,k),Form("tau21_j%d_%db",i,k),25,0,1); th5[i*5+k+120]=new TH1D(Form("PuppiSDMassL2L3_j%d_%db",i,k),Form("PuppiSDMassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+130]=new TH1D(Form("puppiTau21_j%d_%db",i,k),Form("puppiTau21_j%d_%db",i,k),25,0,1); th5[i*5+k+140]=new TH1D(Form("prMass_j%d_%db",i,k),Form("prMass_j%d_%db",i,k),15,90,150); th5[i*5+k+150]=new TH1D(Form("PuppiSDMass_j%d_%db",i,k),Form("PuppiSDMass_j%d_%db",i,k),15,90,150); th5[i*5+k+170]=new TH1D(Form("doubleSV_j%d_%db",i,k),Form("doubleSV_j%d_%db",i,k),40,-1,1); th5[i*5+k+184]=new TH1D(Form("FatSV_j%d_%db",i,k),Form("FatSV_j%d_%db",i,k),20,0,1); th5[i*5+k+250]=new TH1D(Form("PuppiSDMassThea_j%d_%db",i,k),Form("PuppiSDMassThea_j%d_%db",i,k),15,90,150); } } for(int k=0;k<5;k++){ th5[k+80]=new TH1D(Form("totalMass_%db",k),Form("totalMass_%db",k),200,1000,5000); th5[k+115]=new TH1D(Form("deltaEta_%db",k),Form("deltaEta_%db",k),40,0,2); th5[k+160]=new TH1D(Form("logPt_%db",k),Form("logPt_%db",k),70,0,7); th5[k+165]=new TH1D(Form("totalMassRed_%db",k),Form("totalMassRed_%db",k),200,1000,5000); } th5[180]= new TH1D("h_nvtx","h_nvtx",60,0,60); th5[181]= new TH1D("h_ntrue","h_ntrue",60,0,60); th5[182]= new TH1D("h_nvtx_cut","h_nvtx_cut",60,0,60); th5[183]= new TH1D("h_ntrue_cut","h_ntrue_cut",60,0,60); string prMass_no[4]={"prMass","prMassL2L3","PuppiSDMass","PuppiSDMassL2L3"}; string tau21_no[2]={"tau21","puppiTau21"}; for (int i=0;i<4;i++){ th5[214+i*2]=new TH1D(Form("%s_j0_noPr_noTau21",prMass_no[i].data()),Form("%s_j0_noPr_noTau21",prMass_no[i].data()),200,0,200); th5[215+i*2]=new TH1D(Form("%s_j1_noPr_noTau21",prMass_no[i].data()),Form("%s_j1_noPr_noTau21",prMass_no[i].data()),200,0,200); th5[222+i*2]=new TH1D(Form("%s_j0_noPr",prMass_no[i].data()),Form("%s_j0_noPr",prMass_no[i].data()),200,0,200); th5[223+i*2]=new TH1D(Form("%s_j1_noPr",prMass_no[i].data()),Form("%s_j1_noPr",prMass_no[i].data()),200,0,200); th5[230+i*2]=new TH1D(Form("%s_j0_noTau21",prMass_no[i].data()),Form("%s_j0_noTau21",prMass_no[i].data()),15,90,150); th5[231+i*2]=new TH1D(Form("%s_j1_noTau21",prMass_no[i].data()),Form("%s_j1_noTau21",prMass_no[i].data()),15,90,150); } for (int i=0;i<2;i++){ th5[238+i*2]=new TH1D(Form("%s_j0_noPr_noTau21",tau21_no[i].data()),Form("%s_j0_noPr_noTau21",tau21_no[i].data()),25,0,1); th5[239+i*2]=new TH1D(Form("%s_j1_noPr_noTau21",tau21_no[i].data()),Form("%s_j1_noPr_noTau21",tau21_no[i].data()),25,0,1); th5[242+i*2]=new TH1D(Form("%s_j0_noPr",tau21_no[i].data()),Form("%s_j0_noPr",tau21_no[i].data()),25,0,1); th5[243+i*2]=new TH1D(Form("%s_j1_noPr",tau21_no[i].data()),Form("%s_j1_noPr",tau21_no[i].data()),25,0,1); th5[246+i*2]=new TH1D(Form("%s_j0_noTau21",tau21_no[i].data()),Form("%s_j0_noTau21",tau21_no[i].data()),25,0,1); th5[247+i*2]=new TH1D(Form("%s_j1_noTau21",tau21_no[i].data()),Form("%s_j1_noTau21",tau21_no[i].data()),25,0,1); } for(int i=0;i<260;i++){ th5[i]->Sumw2(); th_flavor[0][i]=(TH1D* )th5[i]->Clone(Form("%s_bb",th5[i]->GetTitle())); th_flavor[1][i]=(TH1D* )th5[i]->Clone(Form("%s_b",th5[i]->GetTitle())); th_flavor[2][i]=(TH1D* )th5[i]->Clone(Form("%s_cc",th5[i]->GetTitle())); th_flavor[3][i]=(TH1D* )th5[i]->Clone(Form("%s_udcsg",th5[i]->GetTitle())); //th_flavor[0][i]->Sumw2(); //th_flavor[1][i]->Sumw2(); //th_flavor[2][i]->Sumw2(); //th_flavor[3][i]->Sumw2(); } //pileup uncertainty---------------------------------------------------------------------------------------- TH1D* th7[14]; th7[0]=new TH1D("totalMass","totalMass",200,1000,5000); th7[1]=new TH1D("totalMass_pileup_up","totalMass_pileup_up",200,1000,5000); th7[2]=new TH1D("totalMass_pileup_down","totalMass_pileup_down",200,1000,5000); th7[3]=new TH1D("pileupEff","pileupEff",15,0.5,15.5); double totalPileup[3]={0},passPileup[3]={0}; standalone_LumiReWeighting LumiWeights_central(0),LumiWeights_up(1),LumiWeights_down(-1); //PDF uncertainty th7[4]=new TH1D("PDFEff","PDFEff",101,0.5,101.5); double passPDF[101]={0},totalPDF[101]={0}; //QCD uncertainty for(int i=5;i<14;i++)th7[i]=new TH1D(Form("uns_QCD_%d",i-5),Form("uns_QCD_%d",i-5),200,1000,5000); //NCUtuple loop---------------------------------------------------------------------------------------- for (int w=wMs;w<wM;w++){ if(w%20==0)cout<<w<<endl; //Get ntuple---------------------------------------------------------------------------------------- if (nameRoot!=1)f = TFile::Open(Form("%s%d.root",st.data(),w)); else f = TFile::Open(st.data()); if (!f || !f->IsOpen())continue; TDirectory * dir; if (nameRoot!=1)dir = (TDirectory*)f->Get(Form("%s%d.root:/tree",st.data(),w)); else dir = (TDirectory*)f->Get(Form("%s:/tree",st.data())); dir->GetObject("treeMaker",tree); TreeReader data(tree); total+=data.GetEntriesFast(); //TFile* fileFast=TFile::Open(Form("fast/%s/%d.root",st2.data(),w)); //TTree* treeFast=(TTree* )fileFast->Get("hh4bFast"); //TreeReader dataFast(treeFast); //if(isFast)dataFast=TreeReader(treeFast); for(Long64_t jEntry=0; jEntry<data.GetEntriesFast() ;jEntry++){//event loop---------------------------------------------------------------------------------------- data.GetEntry(jEntry); //if(isFast)dataFast.GetEntry(jEntry); Int_t nVtx = data.GetInt("nVtx"); Float_t ntrue= data.GetFloat("pu_nTrueInt"); //Float_t* pdfscaleSysWeights= data.GetPtrFloat("pdfscaleSysWeights"); double PU_weight[3]={1,1,1}; if(nameRoot!=2){ if(ntrue<51){ PU_weight[0] = LumiWeights_central.weight(ntrue); PU_weight[1]= LumiWeights_up.weight(ntrue); PU_weight[2] = LumiWeights_down.weight(ntrue); } else { PU_weight[0] = LumiWeights_central.weight(50); PU_weight[1] = LumiWeights_up.weight(50); PU_weight[2]= LumiWeights_down.weight(50); } } fixScaleNum[0]+=PU_weight[0]; for(int i=0;i<3;i++)totalPileup[i]+=PU_weight[i]; for(int i=0;i<101;i++)totalPDF[i]+=PU_weight[0]; //Int_t nPassFast; //if(isFast)nPassFast= dataFast.GetInt("nPassB"); //cout<<nPassFast<<endl; //if(isFast &&nPassFast<8)continue; //0. has a good vertex if(nVtx<1)continue;nPass[0]+=PU_weight[0]; //1.trigger std::string* trigName = data.GetPtrString("hlt_trigName"); vector<bool> &trigResult = *((vector<bool>*) data.GetPtr("hlt_trigResult")); bool passTrigger=false; for(int it=0; it< data.GetPtrStringSize(); it++){ std::string thisTrig= trigName[it]; bool results = trigResult[it]; if( ((thisTrig.find("HLT_PFHT800")!= std::string::npos|| //thisTrig.find("HLT_PFHT650")!= std::string::npos|| thisTrig.find("HLT_PFHT650_WideJetMJJ900DEtaJJ1p5_v")!= std::string::npos|| thisTrig.find("HLT_PFHT650_WideJetMJJ950DEtaJJ1p5_v")!= std::string::npos|| thisTrig.find("HLT_AK8PFJet360_TrimMass30_v")!= std::string::npos|| thisTrig.find("HLT_AK8PFHT700_TrimR0p1PT0p03Mass50_v")!= std::string::npos ) && results==1)){ passTrigger=true; break; } } if(!passTrigger && nameRoot==2)continue;nPass[1]+=PU_weight[0]; int nFATJet = data.GetInt("FATnJet"); TClonesArray* fatjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); float* FATjetCorrUncUp = data.GetPtrFloat("FATjetCorrUncUp"); float* FATjetCorrUncDown = data.GetPtrFloat("FATjetCorrUncDown"); vector<bool> &FATjetPassIDTight = *((vector<bool>*) data.GetPtr("FATjetPassIDTight")); //2.nJets if(nFATJet<2)continue;nPass[2]+=PU_weight[0]; TLorentzVector* thisJet ,* thatJet; if (JESOption==1){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1+FATjetCorrUncUp[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1+FATjetCorrUncUp[1] ); thisJet= &test0; thatJet= &test1; } else if (JESOption==2){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1-FATjetCorrUncDown[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1-FATjetCorrUncDown[1] ); thisJet= &test0; thatJet= &test1; } else{ thisJet= (TLorentzVector*)fatjetP4->At(0); thatJet = (TLorentzVector*)fatjetP4->At(1); } //3. Pt if(thisJet->Pt()<200||thatJet->Pt()<200)continue; nPass[3]+=PU_weight[0]; //4tightId----------------------------------------- if(FATjetPassIDTight[0]==0||FATjetPassIDTight[1]==0)continue; Float_t* FATjetCEmEF = data.GetPtrFloat("FATjetCEmEF"); Float_t* FATjetMuEF = data.GetPtrFloat("FATjetMuEF"); if(FATjetMuEF[0]>0.8||FATjetMuEF[1]>0.8)continue; if(FATjetCEmEF[0]>0.9||FATjetCEmEF[1]>0.9)continue; nPass[4]+=PU_weight[0]; //5. Eta----------------------------------------- if(fabs(thisJet->Eta())>2.4||fabs(thatJet->Eta())>2.4)continue; nPass[5]+=PU_weight[0]; int event_flavor=-1; Int_t* FATjetHadronFlavor = data.GetPtrInt("FATjetHadronFlavor"); vector<Int_t> *FATsubjetSDHadronFlavor = data.GetPtrVectorInt("FATsubjetSDHadronFlavor"); if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)event_flavor=0; else if(FATjetHadronFlavor[1]==5 && FATsubjetSDHadronFlavor[1][0]==5 && FATsubjetSDHadronFlavor[1][1]==5)event_flavor=0; else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))event_flavor=1; else if(FATjetHadronFlavor[1]==5 && (FATsubjetSDHadronFlavor[1][0]==5 || FATsubjetSDHadronFlavor[1][1]==5))event_flavor=1; else if(FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)event_flavor=2; else if(FATjetHadronFlavor[1]==4 && FATsubjetSDHadronFlavor[1][0]==4 && FATsubjetSDHadronFlavor[1][1]==4)event_flavor=2; else event_flavor=3; th5[180]->Fill(nVtx,PU_weight[0]); th5[181]->Fill(ntrue,PU_weight[0]); th_flavor[event_flavor][180]->Fill(nVtx,PU_weight[0]); th_flavor[event_flavor][181]->Fill(ntrue,PU_weight[0]); //6. DEta----------------------------------------- float dEta = fabs(thisJet->Eta()-thatJet->Eta()); if(dEta>1.3)continue; nPass[6]+=PU_weight[0]; //7. Mjj----------------------------------------- float mjj = (*thisJet+*thatJet).M(); float mjjRed = (*thisJet+*thatJet).M()+250-thisJet->M()-thatJet->M(); if(mjjRed<1000)continue; nPass[7]+=PU_weight[0]; //8. fatjetPRmassL2L3Corr----------------------------------------- Float_t* fatjetPRmassL2L3Corr = data.GetPtrFloat("FATjetPRmassL2L3Corr"); Float_t* FATjetPuppiSDmassL2L3Corr = data.GetPtrFloat("FATjetPuppiSDmassL2L3Corr"); Float_t* FATjetPRmass = data.GetPtrFloat("FATjetPRmass"); Float_t* FATjetPuppiSDmass = data.GetPtrFloat("FATjetPuppiSDmass"); vector<float> *subjetSDCSV = data.GetPtrVectorFloat("FATsubjetSDCSV"); vector<float> *subjetSDPx = data.GetPtrVectorFloat("FATsubjetSDPx", nFATJet); vector<float> *subjetSDPy = data.GetPtrVectorFloat("FATsubjetSDPy", nFATJet); vector<float> *subjetSDPz = data.GetPtrVectorFloat("FATsubjetSDPz", nFATJet); vector<float> *subjetSDE = data.GetPtrVectorFloat("FATsubjetSDE", nFATJet); int nbtag=0,nbtag2=0; float MaxBJetPt = 670., MaxLJetPt = 1000.; double sf[2][2],eta[2],pt[2],dr[2],subjetPt[2][2],subjetEta[2][2],eff[2][2],btaggingscaleFactor=1; pt[0]=thisJet->Pt(); pt[1]=thatJet->Pt(); TLorentzVector* subjetP4[2][2]; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ sf[i][j]=1; subjetP4[i][j]=new TLorentzVector(0,0,0,0); subjetP4[i][j]->SetPxPyPzE(subjetSDPx[i][j],subjetSDPy[i][j],subjetSDPz[i][j],subjetSDE[i][j]); subjetPt[i][j]=subjetP4[i][j]->Pt(); subjetEta[i][j]=subjetP4[i][j]->Eta(); } dr[i]=subjetP4[i][0]->DeltaR(*subjetP4[i][1]); } for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ //get btagging eff------------------------------------------------------------ int getPtBin=1; if(subjetPt[i][j]<140)getPtBin=1; else if (140<=subjetPt[i][j] && subjetPt[i][j]<180)getPtBin=2; else if (180<=subjetPt[i][j] && subjetPt[i][j]<240)getPtBin=3; else getPtBin=4; //if(FATsubjetSDHadronFlavor[i][j]==5)eff[i][j]=th1[1]->GetBinContent(getPtBin,ceil(subjetEta[i][j]/0.2)+15); //else if(FATsubjetSDHadronFlavor[i][j]==4)eff[i][j]=th1[3]->GetBinContent(getPtBin,ceil(subjetEta[i][j]/0.2)+15); //else eff[i][j]=th1[5]->GetBinContent(getPtBin,ceil(subjetEta[i][j]/0.2)+15); if(FATsubjetSDHadronFlavor[i][j]==5)eff[i][j]=th1[1]->GetBinContent(getPtBin); else if(FATsubjetSDHadronFlavor[i][j]==4)eff[i][j]=th1[3]->GetBinContent(getPtBin); else { int temp=0; if(subjetPt[i][j]>=900)temp=10; else temp=ceil(subjetPt[i][j]/100); bool checkBinContentIfZero=0; while(checkBinContentIfZero==0){ if(th1[4]->GetBinContent(temp)==0){ temp--; } else checkBinContentIfZero=1; } eff[i][j]=th1[5]->GetBinContent(temp); } //Get SF from csv------------------------------------------------------------ if(FATsubjetSDHadronFlavor[i][j]==5){ sf[i][j]=HF.eval_auto_bounds("central",BTagEntry::FLAV_B, subjetEta[i][j],subjetPt[i][j]); //sf[i][j]=HF.eval(BTagEntry::FLAV_B,subjetEta[i][j],subjetPt[i][j]); } else if(FATsubjetSDHadronFlavor[i][j]==4){ sf[i][j]=HFC.eval_auto_bounds("central",BTagEntry::FLAV_C, subjetEta[i][j],subjetPt[i][j]); //sf[i][j]=HF.eval(BTagEntry::FLAV_C,subjetEta[i][j],subjetPt[i][j]); } else { sf[i][j]=LF.eval_auto_bounds("central",BTagEntry::FLAV_UDSG, subjetEta[i][j],subjetPt[i][j]); //sf[i][j]=LF.eval(BTagEntry::FLAV_UDSG,subjetEta[i][j],subjetPt[i][j]); } //conut nbtag--------------------------------------------------------- if(subjetSDCSV[i][j]>0.46)nbtag++; //get tot. btagging SF if(subjetSDCSV[i][j]>=0.46)btaggingscaleFactor*=sf[i][j]; else btaggingscaleFactor*=((1-eff[i][j]*sf[i][j])/(1-eff[i][j])); } } if(nameRoot==2)btaggingscaleFactor=1; double scaleFactor=PU_weight[0]*btaggingscaleFactor; Float_t* fatjetTau1 = data.GetPtrFloat("FATjetTau1"); Float_t* fatjetTau2 = data.GetPtrFloat("FATjetTau2"); Float_t* FATjetPuppiTau1 = data.GetPtrFloat("FATjetPuppiTau1"); Float_t* FATjetPuppiTau2 = data.GetPtrFloat("FATjetPuppiTau2"); double tau21[2]; tau21[0]=(fatjetTau2[0]/fatjetTau1[0]),tau21[1]=(fatjetTau2[1]/fatjetTau1[1]); double puppiTau21[2]; puppiTau21[0]=(FATjetPuppiTau2[0]/FATjetPuppiTau1[0]),puppiTau21[1]=(FATjetPuppiTau2[1]/FATjetPuppiTau1[1]); for (int i=0;i<2;i++){ th5[214+i]->Fill(FATjetPRmass[i],scaleFactor); th5[216+i]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th5[218+i]->Fill(FATjetPuppiSDmass[i],scaleFactor); th5[220+i]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th5[238+i]->Fill(tau21[i],scaleFactor); th5[240+i]->Fill(puppiTau21[i],scaleFactor); th_flavor[event_flavor][214+i]->Fill(FATjetPRmass[i],scaleFactor); th_flavor[event_flavor][216+i]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th_flavor[event_flavor][218+i]->Fill(FATjetPuppiSDmass[i],scaleFactor); th_flavor[event_flavor][220+i]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th_flavor[event_flavor][238+i]->Fill(tau21[i],scaleFactor); th_flavor[event_flavor][240+i]->Fill(puppiTau21[i],scaleFactor); } if(!(tau21[0]>0.6 || tau21[1]>0.6)){ for (int i=0;i<2;i++){ th5[222+i]->Fill(FATjetPRmass[i],scaleFactor); th5[224+i]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th5[226+i]->Fill(FATjetPuppiSDmass[i],scaleFactor); th5[228+i]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th5[242+i]->Fill(tau21[i],scaleFactor); th5[244+i]->Fill(puppiTau21[i],scaleFactor); th_flavor[event_flavor][222+i]->Fill(FATjetPRmass[i],scaleFactor); th_flavor[event_flavor][224+i]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th_flavor[event_flavor][226+i]->Fill(FATjetPuppiSDmass[i],scaleFactor); th_flavor[event_flavor][228+i]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th_flavor[event_flavor][242+i]->Fill(tau21[i],scaleFactor); th_flavor[event_flavor][244+i]->Fill(puppiTau21[i],scaleFactor); } } if(fatjetPRmassL2L3Corr[0]<105||fatjetPRmassL2L3Corr[0]>135)continue; if(fatjetPRmassL2L3Corr[1]<105||fatjetPRmassL2L3Corr[1]>135)continue; nPass[8]+=PU_weight[0]; for (int i=0;i<2;i++){ th5[230+i]->Fill(FATjetPRmass[i],scaleFactor); th5[232+i]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th5[234+i]->Fill(FATjetPuppiSDmass[i],scaleFactor); th5[236+i]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th5[246+i]->Fill(tau21[i],scaleFactor); th5[248+i]->Fill(puppiTau21[i],scaleFactor); th_flavor[event_flavor][230+i]->Fill(FATjetPRmass[i],scaleFactor); th_flavor[event_flavor][232+i]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th_flavor[event_flavor][234+i]->Fill(FATjetPuppiSDmass[i],scaleFactor); th_flavor[event_flavor][236+i]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th_flavor[event_flavor][246+i]->Fill(tau21[i],scaleFactor); th_flavor[event_flavor][248+i]->Fill(puppiTau21[i],scaleFactor); } //9.----------------------------------------- if(tau21[0]>0.6 || tau21[1]>0.6) continue; nPass[9]+=PU_weight[0]; double tau21_SF=1.031*0.881; if(JESOption==5)tau21_SF=(1.031+0.126)*(0.881+0.49); if(JESOption==6)tau21_SF=(1.031-0.126)*(0.881-0.49); if(tau21[0]<0.6 && tau21[1]<0.6 ){ tau21_SF=1.031*1.031; if(JESOption==5)tau21_SF=(1.031+0.126)*(1.031+0.126); if(JESOption==6)tau21_SF=(1.031-0.126)*(1.031-0.126); } //10.btag //uncertainty ------------------------------------- //double scaleFactor=btaggingscaleFactor*PU_weight[0]*tau21_SF; for(int i=0;i<3;i++){ passPileup[i]+=btaggingscaleFactor*PU_weight[i]*tau21_SF; th7[i]->Fill(mjj,btaggingscaleFactor*PU_weight[i]*tau21_SF); } for(int i=0;i<101;i++)passPDF[i]+=btaggingscaleFactor*PU_weight[0]*tau21_SF; for(int i=5;i<14;i++)th7[i]->Fill(mjj,btaggingscaleFactor*PU_weight[0]*tau21_SF); fixScaleNum[1]+=PU_weight[0]; //-------------------------------------- Float_t FATjetPuppiSDmassThea[2] ={0}; FATjetPuppiSDmassThea[0]=FATjetPuppiSDmass[0]*getPUPPIweight(thisJet->Pt(),thisJet->Eta(),tf1); FATjetPuppiSDmassThea[1]=FATjetPuppiSDmass[1]*getPUPPIweight(thatJet->Pt(),thatJet->Eta(),tf1); eta[0]=thisJet->Eta(); eta[1]=thatJet->Eta(); Float_t* ADDjet_DoubleSV = data.GetPtrFloat("ADDjet_DoubleSV"); Float_t FATjet_DoubleSV[2]={0}; Int_t ADDnJet = data.GetInt("ADDnJet"); bool matchThis=0,matchThat=0; TClonesArray* ADDjetP4 = (TClonesArray*) data.GetPtrTObject("ADDjetP4"); for(int i=0;i<ADDnJet;i++){ TLorentzVector* thisAddJet ; thisAddJet= (TLorentzVector*)ADDjetP4->At(i); if(!matchThis && thisAddJet->DeltaR(*thisJet)<0.8){ matchThis=1; FATjet_DoubleSV[0]=ADDjet_DoubleSV[i]; continue; } if(!matchThat && thisAddJet->DeltaR(*thatJet)<0.8){ matchThat=1; FATjet_DoubleSV[1]=ADDjet_DoubleSV[i]; } if(matchThis&& matchThat)break; } Float_t* FATjetCISVV2 = data.GetPtrFloat("FATjetCISVV2"); for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ th5[(i*2+j)*5+nbtag]->Fill(subjetPt[i][j],scaleFactor); th5[(i*2+j)*5+nbtag+20]->Fill(subjetEta[i][j],scaleFactor); th5[(i*2+j)*5+nbtag+85]->Fill(subjetSDCSV[i][j],scaleFactor); if(subjetPt[i][j]>30 && fabs(subjetEta[i][j])<2.4)th5[(i*2+j)*5+nbtag+194]->Fill(subjetSDCSV[i][j],scaleFactor); th_flavor[event_flavor][(i*2+j)*5+nbtag]->Fill(subjetPt[i][j],scaleFactor); th_flavor[event_flavor][(i*2+j)*5+nbtag+20]->Fill(subjetEta[i][j],scaleFactor); th_flavor[event_flavor][(i*2+j)*5+nbtag+85]->Fill(subjetSDCSV[i][j],scaleFactor); if(subjetPt[i][j]>30 && fabs(subjetEta[i][j])<2.4)th_flavor[event_flavor][(i*2+j)*5+nbtag+194]->Fill(subjetSDCSV[i][j],scaleFactor); } th5[i*5+nbtag+40]->Fill(dr[i],scaleFactor); th5[i*5+nbtag+50]->Fill(pt[i],scaleFactor); th5[i*5+nbtag+60]->Fill(eta[i],scaleFactor); th5[i*5+nbtag+70]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th5[i*5+nbtag+105]->Fill(tau21[i],scaleFactor); th5[i*5+nbtag+120]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th5[i*5+nbtag+130]->Fill(puppiTau21[i],scaleFactor); th5[i*5+nbtag+140]->Fill(FATjetPRmass[i],scaleFactor); th5[i*5+nbtag+150]->Fill(FATjetPuppiSDmass[i],scaleFactor); th5[i*5+nbtag+170]->Fill(FATjet_DoubleSV[i],PU_weight[0]); th5[i*5+nbtag+184]->Fill(FATjetCISVV2[i],scaleFactor); th5[i*5+nbtag+250]->Fill(FATjetPuppiSDmassThea[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+40]->Fill(dr[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+50]->Fill(pt[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+60]->Fill(eta[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+70]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+105]->Fill(tau21[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+120]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+130]->Fill(puppiTau21[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+140]->Fill(FATjetPRmass[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+150]->Fill(FATjetPuppiSDmass[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+170]->Fill(FATjet_DoubleSV[i],PU_weight[0]); th_flavor[event_flavor][i*5+nbtag+184]->Fill(FATjetCISVV2[i],scaleFactor); th_flavor[event_flavor][i*5+nbtag+250]->Fill(FATjetPuppiSDmassThea[i],scaleFactor); } th5[nbtag+80]->Fill(mjj,scaleFactor); th5[nbtag+115]->Fill(dEta,scaleFactor); th5[nbtag+165]->Fill(mjjRed,scaleFactor); th_flavor[event_flavor][nbtag+80]->Fill(mjj,scaleFactor); th_flavor[event_flavor][nbtag+115]->Fill(dEta,scaleFactor); th_flavor[event_flavor][nbtag+165]->Fill(mjjRed,scaleFactor); nPass[nbtag+10]+=PU_weight[0]*btaggingscaleFactor; int nDoubleSV=0; if(FATjet_DoubleSV[0]>0.6)nDoubleSV++; if(FATjet_DoubleSV[1]>0.6)nDoubleSV++; if(nDoubleSV==0)nPass[15]+=PU_weight[0]; else if(nDoubleSV==2)nPass[17]+=PU_weight[0]; else { nPass[16]+=PU_weight[0]; if((FATjet_DoubleSV[0]>0.6 && subjetSDCSV[1][0]<0.46 && subjetSDCSV[1][1]<0.46) || (FATjet_DoubleSV[1]>0.6 && subjetSDCSV[0][0]<0.46 && subjetSDCSV[0][1]<0.46))nPass[18]+=PU_weight[0]; else if((FATjet_DoubleSV[0]>0.6 && subjetSDCSV[1][0]>0.46 && subjetSDCSV[1][1]>0.46) || (FATjet_DoubleSV[1]>0.6 && subjetSDCSV[0][0]>0.46 && subjetSDCSV[0][1]>0.46))nPass[20]+=PU_weight[0]; else nPass[19]+=PU_weight[0]; } th5[182]->Fill(nVtx,scaleFactor); th5[183]->Fill(ntrue,scaleFactor); th_flavor[event_flavor][182]->Fill(nVtx,scaleFactor); th_flavor[event_flavor][183]->Fill(ntrue,scaleFactor); }//end event loop---------------------------------------------------------------------------------------- } //end ntuple loop---------------------------------------------------------------------------------------- cout<<"entries="<<total<<endl; for(int i=0;i<22;i++)cout<<"nPass["<<i<<"]="<<nPass[i]<<endl; for(int i=0;i<3;i++)th7[3]->SetBinContent(i+1,passPileup[i]/totalPileup[i]); for(int i=0;i<101;i++)th7[4]->SetBinContent(i+1,passPDF[i]/totalPDF[i]); TH1D * th2o=new TH1D("Nbtagjet","Nbtagjet",5,-0.5,4.5); for (int i=0;i<5;i++){ if(nameRoot==2 && i>2)continue; th2o->SetBinContent(i+1,nPass[i+10]); } TH1D * fixScale=new TH1D("fixScale","fixScale",2,-0.5,1.5); fixScale->SetBinContent(1,fixScaleNum[0]); fixScale->SetBinContent(2,fixScaleNum[1]); TH1D * cutflow=new TH1D("cutflow","cutflow",21,0.5,21.5); cutflow->SetBinContent(1,fixScaleNum[0]); if(nameRoot!=2)for(int ii=1;ii<22;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); else for(int ii=1;ii<16;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); TFile* outFile ; if(JESOption==0)outFile= new TFile(Form("sf2/%s.root",st2.data()),"recreate"); else if(JESOption==1)outFile= new TFile(Form("sf2/%s_JESUp.root",st2.data()),"recreate"); else if(JESOption==2)outFile= new TFile(Form("sf2/%s_JESDown.root",st2.data()),"recreate"); else if(JESOption==3)outFile= new TFile(Form("sf2/%s_BtagUp.root",st2.data()),"recreate"); else if(JESOption==4)outFile= new TFile(Form("sf2/%s_BtagDown.root",st2.data()),"recreate"); else if(JESOption==5)outFile= new TFile(Form("sf2/%s_tau21Up.root",st2.data()),"recreate"); else if(JESOption==6)outFile= new TFile(Form("sf2/%s_tau21Down.root",st2.data()),"recreate"); th2o->Write(); fixScale->Write(); cutflow->Write(); for(int i=0;i<260;i++){ th5[i]->Write(); th_flavor[0][i]->Write(); th_flavor[1][i]->Write(); th_flavor[2][i]->Write(); th_flavor[3][i]->Write(); } for(int i=0;i<14;i++)th7[i]->Write(); outFile->Close(); }
int main(const int iArgc, const char** iArgv) { std::string rootDir; ConciseArgs opt(iArgc, (char**)iArgv); opt.add(rootDir, "r", "root_dir", "input root directory"); opt.parse(); // set up vo std::shared_ptr<drc::BotWrapper> botWrapper(new drc::BotWrapper()); std::shared_ptr<drc::LcmWrapper> lcmWrapper(new drc::LcmWrapper(botWrapper->getLcm())); auto boostLcm = lcmWrapper->getBoost(); auto config = new voconfig::KmclConfiguration(botWrapper->getBotParam(), "CAMERA"); boost::shared_ptr<fovis::StereoCalibration> calib(config->load_stereo_calibration()); FoVision vo(boostLcm, calib); // find file timestamps std::ifstream ifs(rootDir + "/cam_poses.txt"); std::vector<int64_t> times; std::string line; while (std::getline(ifs,line)) { std::istringstream iss(line); int64_t utime; iss >> utime; times.push_back(utime); } // iterate std::string poseFileName = rootDir + "/fovis_poses.txt"; std::ofstream ofs(poseFileName); ofs << std::setprecision(15); for (auto utime : times) { std::string fileName; std::ostringstream oss; // read image oss << rootDir << "/color_" << utime << ".png"; cv::Mat img = cv::imread(oss.str()); cv::cvtColor(img,img,CV_RGB2GRAY); // read disparity oss.str(""); oss.clear(); oss << rootDir << "/disp_" << utime << ".float"; std::ifstream ifs(oss.str(), std::ios::binary); int width, height; ifs.read((char*)&width, sizeof(width)); ifs.read((char*)&height, sizeof(height)); std::vector<float> vals(width*height); ifs.read((char*)vals.data(), width*height*sizeof(float)); ifs.close(); cv::Mat disp(height,width,CV_32FC1,vals.data()); // do fovis vo.doOdometry(img.data, (float*)disp.data, utime); Eigen::Isometry3d delta; auto worldToCamera = Eigen::Isometry3d::Identity(); Eigen::MatrixXd cov; fovis::MotionEstimateStatusCode status; vo.getMotion(delta, cov, status); worldToCamera = worldToCamera*delta; vo.fovis_stats(); // write pose auto cameraPose = worldToCamera.inverse(); auto& m = cameraPose; ofs << utime << " " << m(0,0) << " " << m(0,1) << " " << m(0,2) << " " << m(0,3) << " " << m(1,0) << " " << m(1,1) << " " << m(1,2) << " " << m(1,3) << " " << m(2,0) << " " << m(2,1) << " " << m(2,2) << " " << m(2,3) << std::endl; } ofs.close(); return 1; }
/* * Калибровка по алюминию */ int dcalibAl(uint8_t ev) { return calib(ev, 1); }
/* * Калибровка по железу */ int dcalibFe(uint8_t ev) { return calib(ev, 0); }
int main(int argc, char const *argv[]) { Calibration calib(10.0f, 20.0f); calib.print(); return 0; }
void HHbbbbBtagEffBase_76(int wMs,int wM, string st,string st2,string option=""){ //0=signal ,1=QCD ,2=data----------------------------------------------------------- int nameRoot=1; if(st2.find("QCD")!= std::string::npos)nameRoot=0; if(st2.find("data")!= std::string::npos)nameRoot=2; //option----------------------------------------------------------- int JESOption=0; if(option.find("JESUp")!= std::string::npos)JESOption=1; if(option.find("JESDown")!= std::string::npos)JESOption=2; if(option.find("BtagUp")!= std::string::npos)JESOption=3; if(option.find("BtagDown")!= std::string::npos)JESOption=4; if(option.find("tau21Up")!= std::string::npos)JESOption=5; if(option.find("tau21Down")!= std::string::npos)JESOption=6; cout<<"JESOption = "<<JESOption<<endl; //tuple tree and cutflow variables------------------------------------------------------------------------------------ TFile *f; TTree *tree; int nPass[20]={0},total=0,dataPassingcsc=0; double nPassB[6]={0}; //using for Btag Eff ----------------------------------------------------------------------------- string btagsystematicsType="central"; if(JESOption==3)btagsystematicsType="up"; else if(JESOption==4)btagsystematicsType="down"; BTagCalibration calib("CSVv2L", "../CSVv2_76.csv"); BTagCalibrationReader LF(&calib, // calibration instance BTagEntry::OP_LOOSE, // operating point "incl", // measurement type btagsystematicsType); // systematics type BTagCalibrationReader HF(&calib, BTagEntry::OP_LOOSE, "mujets",btagsystematicsType); TFile *f1; if(nameRoot==2)f1=TFile::Open("../btagEffSource/data.root"); else if (nameRoot!=2 && (JESOption==0||JESOption==3||JESOption==4||JESOption==5||JESOption==6))f1=TFile::Open(Form("../btagEffSource/%s.root",st2.data())); else if (nameRoot!=2 && JESOption==1)f1=TFile::Open(Form("../btagEffSource/%s_JESUp.root",st2.data())); else if (nameRoot!=2 && JESOption==2)f1=TFile::Open(Form("../btagEffSource/%s_JESDown.root",st2.data())); TH2D* th1[6]; string btaggingEff[6]={"effD_b","effN_b","effD_c","effN_c","effD_l","effN_l"}; for(int i=0;i<6;i++){ th1[i]=(TH2D*)f1->FindObjectAny(Form("%s",btaggingEff[i].data())); if(i==1||i==3||i==5)th1[i]->Divide(th1[i-1]); } //check for zero btagging SF---------------------------------------------------------------------------------------- TH2D* th3[6]; th3[0]=new TH2D("zeroSF_b","zeroSF_b",200,0,2000,60,-3,3); th3[1]=new TH2D("zeroSF_c","zeroSF_c",200,0,2000,60,-3,3); th3[2]=new TH2D("zeroSF_l","zeroSF_l",200,0,2000,60,-3,3); th3[3]=new TH2D("SF_vs_Pt_b","SF_vs_Pt_b",120,0,1200,40,0.8,1.2); th3[4]=new TH2D("SF_vs_Pt_c","SF_vs_Pt_c",120,0,1200,40,0.8,1.2); th3[5]=new TH2D("SF_vs_Pt_l","SF_vs_Pt_l",120,0,1200,40,0.8,1.2); for(int i=0;i<6;i++)th3[i]->Sumw2(); //check for high btagging SF---------------------------------------------------------------------------------------- TH1D* th4[14]; string SF_jet_sub[8]={"SF_jet0_sub0_pass","SF_jet0_sub1_pass","SF_jet1_sub0_pass","SF_jet1_sub1_pass","SF_jet0_sub0_fail","SF_jet0_sub1_fail","SF_jet1_sub0_fail","SF_jet1_sub1_fail"}; for(int i=0;i<8;i++)th4[i]=new TH1D(Form("%s",SF_jet_sub[i].data()),Form("%s",SF_jet_sub[i].data()),40,0.8,1.2); string weightName[6]={"weight","weight_0b","weight_1b","weight_2b","weight_2b_ll","weight_2b_onel"}; for(int i=0;i<6;i++)th4[i+8]=new TH1D(Form("%s",weightName[i].data()),Form("%s",weightName[i].data()),40,0,2); for(int i=0;i<14;i++)th4[i]->Sumw2(); //saving variables---------------------------------------------------------------------------------------- TH1D * th5[200],* th6[200]; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ for(int k=0;k<5;k++){ th5[(i*2+j)*5+k]=new TH1D(Form("Pt_j%d_sj%d_%db",i,j,k),Form("Pt_j%d_sj%d_%db",i,j,k),200,0,2000); th5[(i*2+j)*5+k+20]=new TH1D(Form("Eta_j%d_sj%d_%db",i,j,k),Form("Eta_j%d_sj%d_%db",i,j,k),60,-3,3); th5[(i*2+j)*5+k+85]=new TH1D(Form("subCSV_j%d_sj%d_%db",i,j,k),Form("subCSV_j%d_sj%d_%db",i,j,k),20,0,1); } } for(int k=0;k<5;k++){ th5[i*5+k+40]=new TH1D(Form("deltaR_j%d_%db",i,k),Form("deltaR_j%d_%db",i,k),20,0,1); th5[i*5+k+50]=new TH1D(Form("Pt_j%d_%db",i,k),Form("Pt_j%d_%db",i,k),200,0,2000); th5[i*5+k+60]=new TH1D(Form("Eta_j%d_%db",i,k),Form("Eta_j%d_%db",i,k),60,-3,3); th5[i*5+k+70]=new TH1D(Form("prMassL2L3_j%d_%db",i,k),Form("prMassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+105]=new TH1D(Form("tau21_j%d_%db",i,k),Form("tau21_j%d_%db",i,k),25,0,1); th5[i*5+k+120]=new TH1D(Form("PuppiSDmassL2L3_j%d_%db",i,k),Form("PuppiSDmassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+130]=new TH1D(Form("puppiTau21_j%d_%db",i,k),Form("puppiTau21_j%d_%db",i,k),25,0,1); th5[i*5+k+140]=new TH1D(Form("prMass_j%d_%db",i,k),Form("prMass_j%d_%db",i,k),15,90,150); th5[i*5+k+150]=new TH1D(Form("PuppiSDmass_j%d_%db",i,k),Form("PuppiSDmass_j%d_%db",i,k),15,90,150); } } for(int k=0;k<5;k++){ th5[k+80]=new TH1D(Form("totalMass_%db",k),Form("totalMass_%db",k),200,1000,5000); th5[k+115]=new TH1D(Form("deltaEta_%db",k),Form("deltaEta_%db",k),40,0,2); th5[k+160]=new TH1D(Form("logPt_%db",k),Form("logPt_%db",k),70,0,7); } for(int i=0;i<165;i++){ th6[i]=(TH1D* )th5[i]->Clone(Form("%ss",th5[i]->GetTitle())); th5[i]->Sumw2(); th6[i]->Sumw2(); } //pileup uncertainty---------------------------------------------------------------------------------------- TH1D* th7[14]; th7[0]=new TH1D("totalMass","totalMass",200,1000,5000); th7[1]=new TH1D("totalMass_pileup_up","totalMass_pileup_up",200,1000,5000); th7[2]=new TH1D("totalMass_pileup_down","totalMass_pileup_down",200,1000,5000); th7[3]=new TH1D("pileupEff","pileupEff",15,0.5,15.5); double totalPileup[3]={0},passPileup[3]={0}; standalone_LumiReWeighting LumiWeights_central(0),LumiWeights_up(1),LumiWeights_down(-1); //PDF uncertainty th7[4]=new TH1D("PDFEff","PDFEff",101,0.5,101.5); double passPDF[101]={0},totalPDF[101]={0}; //QCD uncertainty for(int i=5;i<14;i++)th7[i]=new TH1D(Form("uns_QCD_%d",i-5),Form("uns_QCD_%d",i-5),200,1000,5000); //NCUtuple loop---------------------------------------------------------------------------------------- for (int w=wMs;w<wM;w++){ if(w%20==0)cout<<w<<endl; //Get ntuple---------------------------------------------------------------------------------------- if (nameRoot!=1)f = TFile::Open(Form("%s%d.root",st.data(),w)); else f = TFile::Open(st.data()); if (!f || !f->IsOpen())continue; TDirectory * dir; if (nameRoot!=1)dir = (TDirectory*)f->Get(Form("%s%d.root:/tree",st.data(),w)); else dir = (TDirectory*)f->Get(Form("%s:/tree",st.data())); dir->GetObject("treeMaker",tree); TreeReader data(tree); total+=data.GetEntriesFast(); for(Long64_t jEntry=0; jEntry<data.GetEntriesFast() ;jEntry++){//event loop---------------------------------------------------------------------------------------- data.GetEntry(jEntry); Int_t nVtx = data.GetInt("nVtx"); Float_t ntrue= data.GetFloat("pu_nTrueInt"); //Float_t* pdfscaleSysWeights= data.GetPtrFloat("pdfscaleSysWeights"); double PU_weight[3]={1,1,1}; if(nameRoot!=2){ if(ntrue<51){ PU_weight[0] = LumiWeights_central.weight(ntrue); PU_weight[1]= LumiWeights_up.weight(ntrue); PU_weight[2] = LumiWeights_down.weight(ntrue); } else { PU_weight[0] = LumiWeights_central.weight(50); PU_weight[1] = LumiWeights_up.weight(50); PU_weight[2]= LumiWeights_down.weight(50); } } for(int i=0;i<3;i++)totalPileup[i]+=PU_weight[i]; for(int i=0;i<101;i++)totalPDF[i]+=PU_weight[0]; //0. has a good vertex if(nVtx<1)continue;nPass[0]++; //1.trigger std::string* trigName = data.GetPtrString("hlt_trigName"); vector<bool> &trigResult = *((vector<bool>*) data.GetPtr("hlt_trigResult")); bool passTrigger=false; for(int it=0; it< data.GetPtrStringSize(); it++){ std::string thisTrig= trigName[it]; bool results = trigResult[it]; if( ((thisTrig.find("HLT_PFHT800")!= std::string::npos|| thisTrig.find("HLT_PFHT650")!= std::string::npos|| thisTrig.find("HLT_PFHT650_WideJetMJJ900DEtaJJ1p5_v")!= std::string::npos|| thisTrig.find("HLT_PFHT650_WideJetMJJ950DEtaJJ1p5_v")!= std::string::npos|| thisTrig.find("HLT_AK8PFJet360_TrimMass30_v")!= std::string::npos|| thisTrig.find("HLT_AK8PFHT700_TrimR0p1PT0p03Mass50_v")!= std::string::npos ) && results==1)){ passTrigger=true; break; } } if(!passTrigger && nameRoot==2)continue;nPass[1]++; int nFATJet = data.GetInt("FATnJet"); TClonesArray* fatjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); float* FATjetCorrUncUp = data.GetPtrFloat("FATjetCorrUncUp"); float* FATjetCorrUncDown = data.GetPtrFloat("FATjetCorrUncDown"); vector<bool> &FATjetPassIDTight = *((vector<bool>*) data.GetPtr("FATjetPassIDTight")); //2.nJets if(nFATJet<2)continue;nPass[2]++; TLorentzVector* thisJet ,* thatJet; if (JESOption==1){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1+FATjetCorrUncUp[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1+FATjetCorrUncUp[1] ); thisJet= &test0; thatJet= &test1; } else if (JESOption==2){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1-FATjetCorrUncDown[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1-FATjetCorrUncDown[1] ); thisJet= &test0; thatJet= &test1; } else{ thisJet= (TLorentzVector*)fatjetP4->At(0); thatJet = (TLorentzVector*)fatjetP4->At(1); } //3. Pt if(thisJet->Pt()<300||thatJet->Pt()<300)continue; nPass[3]++; //4tightId----------------------------------------- if(FATjetPassIDTight[0]==0||FATjetPassIDTight[1]==0)continue; Float_t* FATjetCEmEF = data.GetPtrFloat("FATjetCEmEF"); Float_t* FATjetMuEF = data.GetPtrFloat("FATjetMuEF"); if(FATjetMuEF[0]>0.8||FATjetMuEF[1]>0.8)continue; if(FATjetCEmEF[0]>0.9||FATjetCEmEF[1]>0.9)continue; nPass[4]++; //5. Eta----------------------------------------- if(fabs(thisJet->Eta())>2.4||fabs(thatJet->Eta())>2.4)continue; nPass[5]++; //6. DEta----------------------------------------- float dEta = fabs(thisJet->Eta()-thatJet->Eta()); if(dEta>1.3)continue; nPass[6]++; //7. Mjj----------------------------------------- float mjj = (*thisJet+*thatJet).M(); if(mjj<1000)continue; nPass[7]++; //8. fatjetPRmassL2L3Corr----------------------------------------- Float_t* fatjetPRmassL2L3Corr = data.GetPtrFloat("FATjetPRmassL2L3Corr"); Float_t* FATjetPuppiSDmassL2L3Corr = data.GetPtrFloat("FATjetPuppiSDmassL2L3Corr"); Float_t* FATjetPRmass = data.GetPtrFloat("FATjetPRmass"); Float_t* FATjetPuppiSDmass = data.GetPtrFloat("FATjetPuppiSDmass"); if(fatjetPRmassL2L3Corr[0]<105||fatjetPRmassL2L3Corr[0]>135)continue; if(fatjetPRmassL2L3Corr[1]<105||fatjetPRmassL2L3Corr[1]>135)continue; nPass[8]++; //9.----------------------------------------- Float_t* fatjetTau1 = data.GetPtrFloat("FATjetTau1"); Float_t* fatjetTau2 = data.GetPtrFloat("FATjetTau2"); Float_t* FATjetPuppiTau1 = data.GetPtrFloat("FATjetPuppiTau1"); Float_t* FATjetPuppiTau2 = data.GetPtrFloat("FATjetPuppiTau2"); double tau21[2]; tau21[0]=(fatjetTau2[0]/fatjetTau1[0]),tau21[1]=(fatjetTau2[1]/fatjetTau1[1]); double puppiTau21[2]; puppiTau21[0]=(FATjetPuppiTau2[0]/FATjetPuppiTau1[0]),puppiTau21[1]=(FATjetPuppiTau2[1]/FATjetPuppiTau1[1]); if(tau21[0]>0.75||tau21[1]>0.75)continue; if(tau21[0]>0.6 &&tau21[1]>0.6) continue; nPass[9]++; bool isHPHP=0; double tau21_SF=1.031*0.881; if(JESOption==5)tau21_SF=(1.031+0.126)*(0.881+0.49); if(JESOption==6)tau21_SF=(1.031-0.126)*(0.881-0.49); if(tau21[0]<0.6 && tau21[1]<0.6 ){ isHPHP=1; tau21_SF=1.031*1.031; if(JESOption==5)tau21_SF=(1.031+0.126)*(1.031+0.126); if(JESOption==6)tau21_SF=(1.031-0.126)*(1.031-0.126); } //8.btag vector<float> *subjetSDCSV = data.GetPtrVectorFloat("FATsubjetSDCSV"); vector<float> *subjetSDPx = data.GetPtrVectorFloat("FATsubjetSDPx", nFATJet); vector<float> *subjetSDPy = data.GetPtrVectorFloat("FATsubjetSDPy", nFATJet); vector<float> *subjetSDPz = data.GetPtrVectorFloat("FATsubjetSDPz", nFATJet); vector<float> *subjetSDE = data.GetPtrVectorFloat("FATsubjetSDE", nFATJet); vector<Int_t> *FATsubjetSDHadronFlavor = data.GetPtrVectorInt("FATsubjetSDHadronFlavor"); int nbtag=0,nbtag2=0; float MaxBJetPt = 670., MaxLJetPt = 1000.; double sf[2][2],eta[2],pt[2],dr[2],subjetPt[2][2],subjetEta[2][2],eff[2][2],btaggingscaleFactor=1; TLorentzVector* subjetP4[2][2]; for(int i=0;i<2;i++)for(int j=0;j<2;j++)sf[i][j]=1; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ subjetP4[i][j]=new TLorentzVector(0,0,0,0); subjetP4[i][j]->SetPxPyPzE(subjetSDPx[i][j],subjetSDPy[i][j],subjetSDPz[i][j],subjetSDE[i][j]); subjetPt[i][j]=subjetP4[i][j]->Pt(); subjetEta[i][j]=subjetP4[i][j]->Eta(); //get btagging eff------------------------------------------------------------ if(FATsubjetSDHadronFlavor[i][j]==5)eff[i][j]=th1[1]->GetBinContent(ceil(subjetPt[i][j]/10),ceil(subjetEta[i][j]/0.1)+30); else if(FATsubjetSDHadronFlavor[i][j]==4)eff[i][j]=th1[3]->GetBinContent(ceil(subjetPt[i][j]/10),ceil(subjetEta[i][j]/0.1)+30); else eff[i][j]=th1[5]->GetBinContent(ceil(subjetPt[i][j]/10),ceil(subjetEta[i][j]/0.1)+30); //check maxPt------------------------------------------------------------- if(FATsubjetSDHadronFlavor[i][j]!=0 && subjetPt[i][j]>MaxBJetPt )subjetPt[i][j]=MaxBJetPt-0.1; if(FATsubjetSDHadronFlavor[i][j]==0 && subjetPt[i][j]>MaxLJetPt )subjetPt[i][j]=MaxLJetPt-0.1; //Get SF from csv------------------------------------------------------------ if(FATsubjetSDHadronFlavor[i][j]==5){ sf[i][j]=HF.eval(BTagEntry::FLAV_B,subjetEta[i][j],subjetPt[i][j]); th3[3]->Fill(subjetPt[i][j],sf[i][j]); } else if(FATsubjetSDHadronFlavor[i][j]==4){ sf[i][j]=HF.eval(BTagEntry::FLAV_C,subjetEta[i][j],subjetPt[i][j]); th3[4]->Fill(subjetPt[i][j],sf[i][j]); } else { sf[i][j]=LF.eval(BTagEntry::FLAV_UDSG,subjetEta[i][j],subjetPt[i][j]); th3[5]->Fill(subjetPt[i][j],sf[i][j]); } //check zero ------------------------------------------------------------ if(sf[i][j]==0 && FATsubjetSDHadronFlavor[i][j]==5 ) th3[0]->Fill(subjetPt[i][j],subjetEta[i][j]); if(sf[i][j]==0 && FATsubjetSDHadronFlavor[i][j]==4 ) th3[1]->Fill(subjetPt[i][j],subjetEta[i][j]); if(sf[i][j]==0 && FATsubjetSDHadronFlavor[i][j]!=5 && FATsubjetSDHadronFlavor[i][j]!=4 ) th3[2]->Fill(subjetPt[i][j],subjetEta[i][j]); //conut nbtag--------------------------------------------------------- if(subjetSDCSV[i][j]>0.46)nbtag++; //get tot. btagging SF if(subjetSDCSV[i][j]>=0.46)btaggingscaleFactor*=sf[i][j]; else btaggingscaleFactor*=((1-eff[i][j]*sf[i][j])/(1-eff[i][j])); //##############check light jet SF########## if(subjetSDCSV[i][j]>0.46 &&FATsubjetSDHadronFlavor[i][j]==0)nbtag2++; if(subjetSDCSV[i][j]>0.46)th4[i*2+j]->Fill(sf[i][j]); else th4[i*2+j+4]->Fill(sf[i][j]); subjetPt[i][j]=subjetP4[i][j]->Pt(); } dr[i]=subjetP4[i][0]->DeltaR(*subjetP4[i][1]); } th4[8]->Fill(btaggingscaleFactor); if(nbtag2==2 && nbtag==2)th4[12]->Fill(btaggingscaleFactor); if(nbtag2==1 && nbtag==2)th4[13]->Fill(btaggingscaleFactor); //uncertainty ------------------------------------- double scaleFactor=btaggingscaleFactor*PU_weight[0]*tau21_SF; for(int i=0;i<3;i++){ passPileup[i]+=btaggingscaleFactor*PU_weight[i]*tau21_SF; th7[i]->Fill(mjj,btaggingscaleFactor*PU_weight[i]*tau21_SF); } for(int i=0;i<101;i++)passPDF[i]+=btaggingscaleFactor*PU_weight[0]*tau21_SF; for(int i=5;i<14;i++)th7[i]->Fill(mjj,btaggingscaleFactor*PU_weight[0]*tau21_SF); //-------------------------------------- pt[0]=thisJet->Pt(); pt[1]=thatJet->Pt(); eta[0]=thisJet->Eta(); eta[1]=thatJet->Eta(); for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ for(int k=0;k<5;k++){ if(nbtag!=k)continue; th5[(i*2+j)*5+k]->Fill(subjetPt[i][j]); th5[(i*2+j)*5+k+20]->Fill(subjetEta[i][j]); th5[(i*2+j)*5+k+85]->Fill(subjetSDCSV[i][j]); th6[(i*2+j)*5+k]->Fill(subjetPt[i][j],scaleFactor); th6[(i*2+j)*5+k+20]->Fill(subjetEta[i][j],scaleFactor); th6[(i*2+j)*5+k]->Fill(subjetSDCSV[i][j],scaleFactor); } } for(int k=0;k<5;k++){ if(nbtag!=k)continue; th5[i*5+k+40]->Fill(dr[i]); th5[i*5+k+50]->Fill(pt[i]); th5[i*5+k+60]->Fill(eta[i]); th5[i*5+k+70]->Fill(fatjetPRmassL2L3Corr[i]); th5[i*5+k+105]->Fill(tau21[i]); th6[i*5+k+40]->Fill(dr[i],scaleFactor); th6[i*5+k+50]->Fill(pt[i],scaleFactor); th6[i*5+k+60]->Fill(eta[i],scaleFactor); th6[i*5+k+70]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th6[i*5+k+105]->Fill(tau21[i],scaleFactor); th5[i*5+k+120]->Fill(FATjetPuppiSDmassL2L3Corr[i]); th6[i*5+k+120]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th5[i*5+k+130]->Fill(puppiTau21[i]); th6[i*5+k+130]->Fill(puppiTau21[i],scaleFactor); th5[i*5+k+140]->Fill(FATjetPRmass[i]); th6[i*5+k+140]->Fill(FATjetPRmass[i],scaleFactor); th5[i*5+k+150]->Fill(FATjetPuppiSDmass[i]); th6[i*5+k+150]->Fill(FATjetPuppiSDmass[i],scaleFactor); } } for(int k=0;k<5;k++){ if(nbtag!=k)continue; th5[k+80]->Fill(mjj); th6[k+80]->Fill(mjj,scaleFactor); th5[k+115]->Fill(dEta); th6[k+115]->Fill(dEta,scaleFactor); th5[k+160]->Fill(log10(pt[0])); th6[k+160]->Fill(log10(pt[0]),scaleFactor); th5[k+160]->Fill(log10(pt[1])); th6[k+160]->Fill(log10(pt[1]),scaleFactor); nPassB[k]+=scaleFactor; nPass[k+10]++; if(k<3)th4[9+k]->Fill(btaggingscaleFactor); } if(nbtag==3){ if(isHPHP)nPassB[5]+=scaleFactor; if(isHPHP)nPass[15]++; } }//end event loop---------------------------------------------------------------------------------------- } //end ntuple loop---------------------------------------------------------------------------------------- cout<<"entries="<<total<<endl; for(int i=0;i<6;i++)cout<<"nPassB["<<i<<"]="<<nPassB[i]<<endl; for(int i=0;i<16;i++)cout<<"nPass["<<i<<"]="<<nPass[i]<<endl; for(int i=0;i<3;i++)th7[3]->SetBinContent(i+1,passPileup[i]/totalPileup[i]); for(int i=0;i<101;i++)th7[4]->SetBinContent(i+1,passPDF[i]/totalPDF[i]); TH1D * th2o=new TH1D("Nbtagjet","Nbtagjet",6,-0.5,5.5); for (int i=0;i<6;i++){ if(nameRoot==2 && i>2)continue; th2o->SetBinContent(i+1,nPass[i+10]); } TH1D * th2ob=new TH1D("NbtagjetB","NbtagjetB",6,-0.5,5.5); for (int i=0;i<6;i++){ if(nameRoot==2 && i>2)continue; th2ob->SetBinContent(i+1,nPassB[i]); } TH1D * cutflow=new TH1D("cutflow","cutflow",17,0.5,17.5); cutflow->SetBinContent(1,total); if(nameRoot==2)for(int ii=1;ii<14;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); else for(int ii=1;ii<17;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); TFile* outFile ; if(JESOption==0)outFile= new TFile(Form("../sf/%s.root",st2.data()),"recreate"); else if(JESOption==1)outFile= new TFile(Form("sf/%s_JESUp.root",st2.data()),"recreate"); else if(JESOption==2)outFile= new TFile(Form("sf/%s_JESDown.root",st2.data()),"recreate"); else if(JESOption==3)outFile= new TFile(Form("sf/%s_BtagUp.root",st2.data()),"recreate"); else if(JESOption==4)outFile= new TFile(Form("sf/%s_BtagDown.root",st2.data()),"recreate"); else if(JESOption==5)outFile= new TFile(Form("sf/%s_tau21Up.root",st2.data()),"recreate"); else if(JESOption==6)outFile= new TFile(Form("sf/%s_tau21Down.root",st2.data()),"recreate"); th2o->Write(); th2ob->Write(); cutflow->Write(); for(int i=0;i<6;i++)th3[i]->Write(); for(int i=0;i<14;i++)th4[i]->Write(); for(int i=0;i<165;i++){ th5[i]->Write(); th6[i]->Write(); } for(int i=0;i<14;i++)th7[i]->Write(); outFile->Close(); }
void bTagUncTree(string inputFile, string outputFile, string region, string channel){ // setup calibration and reader BTagCalibration calib("csvv1", "/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/CSVV1.csv"); BTagCalibrationReader reader_l(BTagEntry::OP_LOOSE, region.data()); BTagCalibrationReader reader_c(BTagEntry::OP_LOOSE, region.data()); BTagCalibrationReader reader_b(BTagEntry::OP_LOOSE, region.data()); reader_l.load(calib, BTagEntry::FLAV_UDSG, "comb"); reader_c.load(calib, BTagEntry::FLAV_C, "mujets"); reader_b.load(calib, BTagEntry::FLAV_B, "mujets"); // to read b-tag effinciency TFile* f_l = TFile::Open(Form("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/bTagEffroot/%s_udsgflavor_zjetsBtagEff.root", channel.data())); TFile* f_c = TFile::Open(Form("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/bTagEffroot/%s_cflavor_zjetsBtagEff.root", channel.data())); TFile* f_b = TFile::Open(Form("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/bTagEffroot/%s_bflavor_zjetsBtagEff.root", channel.data())); TH1F* h_l = (TH1F*)(f_l->Get(Form("%s_udsgflavor", channel.data()))); TH1F* h_c = (TH1F*)(f_c->Get(Form("%s_cflavor", channel.data()))); TH1F* h_b = (TH1F*)(f_b->Get(Form("%s_bflavor", channel.data()))); // read the ntuples (in pcncu) TreeReader data(inputFile.data()); TFile f(inputFile.data()); // Create a tree to store variables TFile* outFile = new TFile(Form("%s_%s_%sMiniTree.root", outputFile.data(), region.data(), channel.data()), "recreate"); TTree* tree = new TTree("tree", "TreeForRooFit"); Int_t cat; Float_t mllbb, prmass, evweight; tree->Branch("cat", &cat, "cat/I"); tree->Branch("mllbb", &mllbb, "mllbb/F"); tree->Branch("prmass", &prmass, "prmass/F"); tree->Branch("evweight", &evweight, "evweight/F"); // Calculate the scale correspond to inputFile float scale = 2512.*readHist::crossSection(outputFile.data())/((TH1F*)f.Get("h_totalEv"))->Integral(); // begin of event loop fprintf(stdout, "Total events %lli\n", data.GetEntriesFast()); for( Long64_t ev = data.GetEntriesFast()-1; ev >= 0; --ev ){ if( (unsigned)ev % 100000 == 0 ) fprintf(stdout, "Still left events %lli\n", ev); data.GetEntry(ev); Float_t eventWeight = data.GetFloat("ev_weight"); Float_t* FATjetPRmassCorr = data.GetPtrFloat("FATjetPRmassL2L3Corr"); TClonesArray* muP4 = (TClonesArray*) data.GetPtrTObject("muP4"); TClonesArray* eleP4 = (TClonesArray*) data.GetPtrTObject("eleP4"); TClonesArray* FATjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); // select good reco level events // select good leptons vector<int> goodLepID; if( channel == "ele" && !isPassZee(data,goodLepID) ) continue; if( channel == "mu" && !isPassZmumu(data,goodLepID) ) continue; TLorentzVector* thisLep = (channel=="ele") ? (TLorentzVector*)eleP4->At(goodLepID[0]) : (TLorentzVector*)muP4->At(goodLepID[0]); TLorentzVector* thatLep = (channel=="ele") ? (TLorentzVector*)eleP4->At(goodLepID[1]) : (TLorentzVector*)muP4->At(goodLepID[1]); // select good FATjet int goodFATJetID = -1; if( !isPassJet(data, &goodFATJetID, thisLep, thatLep, false) ) continue; TLorentzVector* thisJet = (TLorentzVector*)FATjetP4->At(goodFATJetID); if( !noiseCleaning(thisLep, thatLep, thisJet, &mllbb) ) continue; // b-tag cut int nsubBjet = 0; float btagWeight = bTagWeight(data, goodFATJetID, &nsubBjet, h_l, h_c, h_b, reader_l, reader_c, reader_b, region.data()); if ( nsubBjet == 1 ) cat = 1; else if( nsubBjet == 2 ) cat = 2; else continue; prmass = FATjetPRmassCorr[goodFATJetID]; evweight = eventWeight * scale * btagWeight; tree->Fill(); } // end of event loop fprintf(stdout, "Processed all events\n"); tree->Write(); outFile->Write(); delete outFile; }
void HH4bCategoryBase_80(int wMs,int wM, string st,string st2,string option=""){ //1=signal ,0=QCD ,2=data int nameRoot=1; if(st2.find("QCD")!= std::string::npos)nameRoot=0; if(st2.find("data")!= std::string::npos)nameRoot=2; cout<<"nameRoot = "<<nameRoot<<endl; //option----------------------------------------------------------- int JESOption=0; if(option.find("JESUp")!= std::string::npos)JESOption=1; if(option.find("JESDown")!= std::string::npos)JESOption=2; cout<<"JESOption = "<<JESOption<<endl; //using for Btag Eff ----------------------------------------------------------------------------- string btagsystematicsType="central"; if(JESOption==3)btagsystematicsType="up"; else if(JESOption==4)btagsystematicsType="down"; BTagCalibration calib("CSVv2L", "subjet_CSVv2_ichep.csv"); BTagCalibrationReader LF(BTagEntry::OP_LOOSE,"central", {"up", "down"}); BTagCalibrationReader HFC(BTagEntry::OP_LOOSE, "central", {"up", "down"}); // other sys types BTagCalibrationReader HF(BTagEntry::OP_LOOSE,"central",{"up", "down"}); // other sys types LF.load(calib, BTagEntry::FLAV_UDSG, // btag flavour "incl"); // measurement type HFC.load(calib, BTagEntry::FLAV_C, // btag flavour "lt"); // measurement type HF.load(calib, BTagEntry::FLAV_B, // btag flavour "lt"); // measurement type TFile *f1; if(nameRoot==2)f1=TFile::Open("btagEffSource/data.root"); else if (nameRoot!=2 && (JESOption==0||JESOption==3||JESOption==4||JESOption==5||JESOption==6))f1=TFile::Open(Form("btagEffSource/%s.root",st2.data())); else if (nameRoot!=2 && JESOption==1)f1=TFile::Open(Form("btagEffSource/%s_JESUp.root",st2.data())); else if (nameRoot!=2 && JESOption==2)f1=TFile::Open(Form("btagEffSource/%s_JESDown.root",st2.data())); TH1D* th1[6]; string btaggingEff[6]={"effD_b","effN_b","effD_c","effN_c","effD_l","effN_l"}; for(int i=0;i<6;i++){ th1[i]=(TH1D*)f1->FindObjectAny(Form("%s_1d",btaggingEff[i].data())); if(i==1||i==3||i==5)th1[i]->Divide(th1[i-1]); } standalone_LumiReWeighting LumiWeights_central(0),LumiWeights_up(1),LumiWeights_down(-1); TFile *f; TTree *tree; int nPass[20]={0}; int total=0; double fixScaleNum[2]={0}; double xBinsForHeavyFlavor[5]={30,140,180,240,3000}; double xBinsForLightFlavor[11]={20,100,200,300,400,500,600,700,800,900,3000}; TH1D* th5[3]; th5[0]=new TH1D("cat0","cat0",4000,1000,5000); th5[1]=new TH1D("cat1","cat1",4000,1000,5000); th5[2]=new TH1D("cat2","cat2",4000,1000,5000); for(int i=0;i<3;i++){ th5[i]->Sumw2(); } //--------------------------------- for (int w=wMs;w<wM;w++){ if(w%20==0)cout<<w<<endl; if (nameRoot!=1)f = TFile::Open(Form("%s%d.root",st.data(),w)); else f = TFile::Open(st.data()); if (!f || !f->IsOpen())continue; TDirectory * dir; if (nameRoot!=1)dir = (TDirectory*)f->Get(Form("%s%d.root:/tree",st.data(),w)); else dir = (TDirectory*)f->Get(Form("%s:/tree",st.data())); dir->GetObject("treeMaker",tree); TreeReader data(tree); total+=data.GetEntriesFast(); for(Long64_t jEntry=0; jEntry<data.GetEntriesFast() ;jEntry++){ data.GetEntry(jEntry); double PU_weight[3]={1,1,1}; Float_t ntrue= data.GetFloat("pu_nTrueInt"); if(nameRoot!=2){ if(ntrue<51){ PU_weight[0] = LumiWeights_central.weight(ntrue); PU_weight[1]= LumiWeights_up.weight(ntrue); PU_weight[2] = LumiWeights_down.weight(ntrue); } else { PU_weight[0] = LumiWeights_central.weight(50); PU_weight[1] = LumiWeights_up.weight(50); PU_weight[2]= LumiWeights_down.weight(50); } } fixScaleNum[0]+=PU_weight[0]; Int_t nVtx = data.GetInt("nVtx"); //0. has a good vertex if(nVtx<1)continue; nPass[0]++; //1.trigger std::string* trigName = data.GetPtrString("hlt_trigName"); vector<bool> &trigResult = *((vector<bool>*) data.GetPtr("hlt_trigResult")); bool passTrigger=false; for(int it=0; it< data.GetPtrStringSize();it++){ std::string thisTrig= trigName[it]; bool results = trigResult[it]; if( ((thisTrig.find("HLT_PFHT800")!= std::string::npos|| thisTrig.find("HLT_PFHT650_WideJetMJJ900DEtaJJ1p5_v")!= std::string::npos|| thisTrig.find("HLT_PFHT650_WideJetMJJ950DEtaJJ1p5_v")!= std::string::npos|| thisTrig.find("HLT_AK8PFJet360_TrimMass30_v")!= std::string::npos|| thisTrig.find("HLT_AK8PFHT700_TrimR0p1PT0p03Mass50_v")!= std::string::npos ) && results==1)){ passTrigger=true; break; } } if(!passTrigger && nameRoot==2)continue; nPass[1]++; const int nFATJet=data.GetInt("FATnJet"); //2.nJets if(nFATJet<2)continue;nPass[2]++; TClonesArray* fatjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); float* FATjetCorrUncUp = data.GetPtrFloat("FATjetCorrUncUp"); float* FATjetCorrUncDown = data.GetPtrFloat("FATjetCorrUncDown"); TLorentzVector* thisJet ,* thatJet; if(JESOption==0){ thisJet=(TLorentzVector*)fatjetP4->At(0); thatJet=(TLorentzVector*)fatjetP4->At(1); } else if (JESOption==1){ TLorentzVector thisJetScaleUp= (*((TLorentzVector*)fatjetP4->At(0)))*(1+FATjetCorrUncUp[0]); TLorentzVector thatJetScaleUp= (*((TLorentzVector*)fatjetP4->At(1)))*(1+FATjetCorrUncUp[1]); thisJet= &thisJetScaleUp; thatJet= &thatJetScaleUp; } else if (JESOption==2){ TLorentzVector thisJetScaleDown= (*((TLorentzVector*)fatjetP4->At(0)))*(1-FATjetCorrUncDown[0]); TLorentzVector thatJetScaleDown= (*((TLorentzVector*)fatjetP4->At(1)))*(1-FATjetCorrUncDown[1]); thisJet= &thisJetScaleDown; thatJet= &thatJetScaleDown; } //3. Pt if(thisJet->Pt()<200)continue; if(thatJet->Pt()<200)continue; nPass[3]++; //4tightId----------------------------------------- vector<bool> &FATjetPassIDTight = *((vector<bool>*) data.GetPtr("FATjetPassIDTight")); if(FATjetPassIDTight[0]==0)continue; if(FATjetPassIDTight[1]==0)continue; Float_t* FATjetCEmEF = data.GetPtrFloat("FATjetCEmEF"); Float_t* FATjetMuEF = data.GetPtrFloat("FATjetMuEF"); if(FATjetMuEF[0]>0.8)continue; if(FATjetCEmEF[0]>0.9)continue; if(FATjetMuEF[1]>0.8)continue; if(FATjetCEmEF[1]>0.9)continue; nPass[4]++; //5. Eta----------------------------------------- if(fabs(thisJet->Eta())>2.4)continue; if(fabs(thatJet->Eta())>2.4)continue; nPass[5]++; //6. DEta----------------------------------------- float dEta = fabs(thisJet->Eta()-thatJet->Eta()); if(dEta>1.3)continue; nPass[6]++; //7. Mjj----------------------------------------- float mjjRed = (*thisJet+*thatJet).M()+250-thisJet->M()-thatJet->M(); if(mjjRed<1000)continue; nPass[7]++; //8. fatjetPRmassL2L3Corr----------------------------------------- Float_t* fatjetPRmassL2L3Corr = data.GetPtrFloat("FATjetPRmassL2L3Corr"); if(fatjetPRmassL2L3Corr[0]<105||fatjetPRmassL2L3Corr[0]>135)continue; if(fatjetPRmassL2L3Corr[1]<105||fatjetPRmassL2L3Corr[1]>135)continue; nPass[8]++; //9.----------------------------------------- Float_t* fatjetTau1 = data.GetPtrFloat("FATjetTau1"); Float_t* fatjetTau2 = data.GetPtrFloat("FATjetTau2"); double tau21_1=(fatjetTau2[0]/fatjetTau1[0]),tau21_2=(fatjetTau2[1]/fatjetTau1[1]); //10.btag vector<float> *subjetSDCSV = data.GetPtrVectorFloat("FATsubjetSDCSV"); int nbtag=0; if(subjetSDCSV[0][0]>0.46)nbtag++; if(subjetSDCSV[0][1]>0.46)nbtag++; if(subjetSDCSV[1][0]>0.46)nbtag++; if(subjetSDCSV[1][1]>0.46)nbtag++; vector<float> *subjetSDPx = data.GetPtrVectorFloat("FATsubjetSDPx"); vector<float> *subjetSDPy = data.GetPtrVectorFloat("FATsubjetSDPy"); vector<float> *subjetSDPz = data.GetPtrVectorFloat("FATsubjetSDPz"); vector<float> *subjetSDE = data.GetPtrVectorFloat("FATsubjetSDE"); vector<Int_t> *FATsubjetSDHadronFlavor = data.GetPtrVectorInt("FATsubjetSDHadronFlavor"); double sf[2][2],subjetPt[2][2],subjetEta[2][2],eff[2][2],btaggingscaleFactor=1; TLorentzVector* subjetP4[2][2]; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ sf[i][j]=1; subjetP4[i][j]=new TLorentzVector(0,0,0,0); subjetP4[i][j]->SetPxPyPzE(subjetSDPx[i][j],subjetSDPy[i][j],subjetSDPz[i][j],subjetSDE[i][j]); subjetPt[i][j]=subjetP4[i][j]->Pt(); subjetEta[i][j]=subjetP4[i][j]->Eta(); } } for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ //get btagging eff------------------------------------------------------------ int getPtBin=1; if(subjetPt[i][j]<140)getPtBin=1; else if (140<=subjetPt[i][j] && subjetPt[i][j]<180)getPtBin=2; else if (180<=subjetPt[i][j] && subjetPt[i][j]<240)getPtBin=3; else getPtBin=4; if(FATsubjetSDHadronFlavor[i][j]==5)eff[i][j]=th1[1]->GetBinContent(getPtBin); else if(FATsubjetSDHadronFlavor[i][j]==4)eff[i][j]=th1[3]->GetBinContent(getPtBin); else { int temp=0; if(subjetPt[i][j]>=900)temp=10; else temp=ceil(subjetPt[i][j]/100); bool checkBinContentIfZero=0; while(checkBinContentIfZero==0){ if(th1[4]->GetBinContent(temp)==0){ temp--; } else checkBinContentIfZero=1; } eff[i][j]=th1[5]->GetBinContent(temp); } //Get SF from csv------------------------------------------------------------ if(FATsubjetSDHadronFlavor[i][j]==5){ sf[i][j]=HF.eval_auto_bounds("central",BTagEntry::FLAV_B, subjetEta[i][j],subjetPt[i][j]); } else if(FATsubjetSDHadronFlavor[i][j]==4){ sf[i][j]=HFC.eval_auto_bounds("central",BTagEntry::FLAV_C, subjetEta[i][j],subjetPt[i][j]); } else { sf[i][j]=LF.eval_auto_bounds("central",BTagEntry::FLAV_UDSG, subjetEta[i][j],subjetPt[i][j]); } //get tot. btagging SF if(subjetSDCSV[i][j]>=0.46)btaggingscaleFactor*=sf[i][j]; else btaggingscaleFactor*=((1-eff[i][j]*sf[i][j])/(1-eff[i][j])); } } //if(tau21_1>0.75 || tau21_2>0.75) continue; //if(nbtag==3 && ((tau21_1>0.6 && tau21_2<0.6)||(tau21_1<0.6 && tau21_2>0.6)))th1[2]->Fill(mjjRed); if(tau21_1>0.6 || tau21_2>0.6) continue; if(nbtag==4)th5[0]->Fill(mjjRed,btaggingscaleFactor*PU_weight[0]); if(nbtag==3)th5[1]->Fill(mjjRed,btaggingscaleFactor*PU_weight[0]); if(nbtag==2)th5[2]->Fill(mjjRed,btaggingscaleFactor*PU_weight[0]); nPass[9]++; fixScaleNum[1]+=PU_weight[0]; } } cout<<"entries="<<total<<endl; for(int i=0;i<9;i++)cout<<"nPass["<<i<<"]="<<nPass[i]<<endl; TH1D * fixScale=new TH1D("fixScale","fixScale",2,-0.5,1.5); fixScale->SetBinContent(1,fixScaleNum[0]); fixScale->SetBinContent(2,fixScaleNum[1]); TFile* outFile ; if(JESOption==0)outFile= new TFile(Form("category/%s.root",st2.data()),"recreate"); else if(JESOption==1)outFile= new TFile(Form("category/%s_JESUp.root",st2.data()),"recreate"); else if(JESOption==2)outFile= new TFile(Form("category/%s_JESDown.root",st2.data()),"recreate"); fixScale->Write(); for(int i=0;i<3;i++){ th5[i]->Write(); } outFile->Close(); }
TEST(TestCalibration, Calibration) { tdv::ImageReader readerL("../../res/OpenCVBook_StereoDataL/", tdv::ImageReader::Directory); tdv::ImageReader readerR("../../res/OpenCVBook_StereoDataR/", tdv::ImageReader::Directory); tdv::Calibration calib(13); calib.input(readerL.output(), readerR.output()); calib.chessPattern(tdv::ChessboardPattern(tdv::Dim(9, 6))); for (size_t i=0; i<13; i++) { readerL.update(); readerR.update(); calib.update(); } // p M1 // $1 = {{534.73022340234274, 0, 335.14036440321371}, {0, 534.73022340234274, 240.20358200823657}, {0, // 0, 1}} // (gdb) p D1 // $2 = {-0.27548644140618689, -0.0074741447321146201, 0, 0, 0.19877104747410226} // (gdb) p M2 // $3 = {{534.73022340234274, 0, 334.01685399468971}, {0, 534.73022340234274, 241.57913691145697}, {0, // 0, 1}} // (gdb) p D2 // $4 = {-0.28088283603968645, 0.093133149965471215, 0, 0, -0.014268852873648923} // (gdb) p T // $5 = {-3.338521775036563, 0.04875726580427088, -0.10610701997669005} // (gdb) p E // $6 = {{0.00052298343399445103, 0.10522183916666465, 0.05063656492846199}, {-0.034564465155821761, // -0.059921868662649605, 3.3394911303200199}, {-0.032337732207657177, -3.3382054064188389, // -0.058684316420089928}} // (gdb) p F // $7 = {{-2.5604703173677883e-08, -5.1515474183824866e-06, -7.9654502412560401e-05}, { // 1.6922388227714652e-06, 2.9337098672527604e-06, -0.088699079381738072}, {0.00044633859910145731, // 0.088405574779886281, 1}} tdv::CamerasDesc cdesc(calib.camerasDesc()); EXPECT_EQ(-0.27548644140618689, cdesc.leftCamera().distortion()[0]); tdv::RectificationCV rect; rect.camerasDesc(cdesc); rect.leftImgInput(readerL.output()); rect.rightImgInput(readerR.output()); readerL.reset(); readerR.reset(); readerL.update(); readerR.update(); rect.update(); tdv::FloatImage limg, rimg; ASSERT_TRUE(rect.leftImgOutput()->read(&limg)); ASSERT_TRUE(rect.rightImgOutput()->read(&rimg)); cvShowImage("L", limg.cpuMem()); cvShowImage("R", rimg.cpuMem()); cvWaitKey(0); tdv::ThunderSpec spec; spec.camerasDesc("default") = cdesc; tdv::ThunderLangWriter wrt; wrt.write("calib.tl", spec); }
EllipsoidFitter::Calibration EllipsoidFitter::calculateFit(void) const { /********************************************************************* First step: Fit a quadric to the point set by least-squares minimization based on algebraic distance. *********************************************************************/ /* Create the least-squares system: */ Math::Matrix a(10,10,0.0); /* Process all points: */ for(Misc::ChunkedArray<Point>::const_iterator pIt=points.begin();pIt!=points.end();++pIt) { /* Create the point's associated linear equation: */ double eq[10]; eq[0]=(*pIt)[0]*(*pIt)[0]; eq[1]=2.0*(*pIt)[0]*(*pIt)[1]; eq[2]=2.0*(*pIt)[0]*(*pIt)[2]; eq[3]=2.0*(*pIt)[0]; eq[4]=(*pIt)[1]*(*pIt)[1]; eq[5]=2.0*(*pIt)[1]*(*pIt)[2]; eq[6]=2.0*(*pIt)[1]; eq[7]=(*pIt)[2]*(*pIt)[2]; eq[8]=2.0*(*pIt)[2]; eq[9]=1.0; /* Insert the equation into the least-squares system: */ for(unsigned int i=0;i<10;++i) for(unsigned int j=0;j<10;++j) a(i,j)+=eq[i]*eq[j]; } /* Find the least-squares system's smallest eigenvalue: */ std::pair<Math::Matrix,Math::Matrix> qe=a.jacobiIteration(); unsigned int minEIndex=0; double minE=Math::abs(qe.second(0,0)); for(unsigned int i=1;i<10;++i) { if(minE>Math::abs(qe.second(i,0))) { minEIndex=i; minE=Math::abs(qe.second(i,0)); } } /* Create the quadric's defining matrices: */ Math::Matrix qa(3,3); qa(0,0)=qe.first(0,minEIndex); qa(0,1)=qe.first(1,minEIndex); qa(0,2)=qe.first(2,minEIndex); qa(1,0)=qe.first(1,minEIndex); qa(1,1)=qe.first(4,minEIndex); qa(1,2)=qe.first(5,minEIndex); qa(2,0)=qe.first(2,minEIndex); qa(2,1)=qe.first(5,minEIndex); qa(2,2)=qe.first(7,minEIndex); Math::Matrix qb(3,1); qb(0)=qe.first(3,minEIndex); qb(1)=qe.first(6,minEIndex); qb(2)=qe.first(8,minEIndex); double qc=qe.first(9,minEIndex); /* Calculate the quadric's principal axes: */ qe=qa.jacobiIteration(); std::cout<<std::fixed<<std::setprecision(6); std::cout<<std::setw(9)<<qe.first<<std::endl; std::cout<<std::setw(9)<<qe.second<<std::endl<<std::endl; std::cout.unsetf(std::ios_base::floatfield); /* "Complete the square" to calculate the quadric's centroid and radii: */ Math::Matrix qbp=qb.divideFullPivot(qe.first); Math::Matrix cp(3,1); for(int i=0;i<3;++i) cp(i)=-qbp(i)/qe.second(i); Math::Matrix c=qe.first*cp; std::cout<<"Centroid: "<<c(0)<<", "<<c(1)<<", "<<c(2)<<std::endl; double rhs=-qc; for(int i=0;i<3;++i) rhs+=Math::sqr(qbp(i))/qe.second(i); double radii[3]; for(int i=0;i<3;++i) radii[i]=Math::sqrt(rhs/qe.second(i)); std::cout<<"Radii: "<<radii[0]<<", "<<radii[1]<<", "<<radii[2]<<std::endl; Scalar averageRadius=Math::pow(radii[0]*radii[1]*radii[2],1.0/3.0); std::cout<<"Average radius: "<<averageRadius<<std::endl; /* Calculate the calibration matrix: */ Math::Matrix ellP(4,4,1.0); for(int i=0;i<3;++i) for(int j=0;j<3;++j) ellP(i,j)=qe.first(i,j); Math::Matrix ellScale(4,4,1.0); for(int i=0;i<3;++i) ellScale(i,i)=averageRadius/radii[i]; Math::Matrix ell=ellP; ell.makePrivate(); for(int i=0;i<3;++i) ell(i,3)=c(i); Math::Matrix ellInv=ell.inverseFullPivot(); Math::Matrix calib=ellP*ellScale*ellInv; std::cout<<std::fixed<<std::setprecision(6); std::cout<<std::setw(9)<<calib<<std::endl; std::cout.unsetf(std::ios_base::floatfield); /* Calculate the calibration residual: */ double rms=0.0; for(Misc::ChunkedArray<Point>::const_iterator pIt=points.begin();pIt!=points.end();++pIt) { /* Calibrate the point: */ Math::Matrix p(4,1); for(int i=0;i<3;++i) p(i)=(*pIt)[i]; p(3)=1.0; Math::Matrix cp=calib*p; rms+=Math::sqr(Math::sqrt(Math::sqr(cp(0))+Math::sqr(cp(1))+Math::sqr(cp(2)))-averageRadius); } std::cout<<"Calibration residual: "<<Math::sqrt(rms/double(points.size()))<<std::endl; /* Create and return the calibration result: */ Matrix result; for(int i=0;i<3;++i) for(int j=0;j<4;++j) result(i,j)=calib(i,j); return Calibration(result,averageRadius); }
void HHbbbbMikeBase(int wMs,int wM, string st,string st2,string option=""){ //1=signal ,0=QCD ,2=data----------------------------------------------------------- int nameRoot=1; if(st2.find("QCD")!= std::string::npos)nameRoot=0; if(st2.find("data")!= std::string::npos)nameRoot=2; //---------------------Thea correction TFile *f3; f3=TFile::Open("puppiCorr.root"); TF1 * puppisd_corrGEN,* puppisd_corrRECO_cen,* puppisd_corrRECO_for; puppisd_corrGEN=(TF1 *) f3->FindObjectAny("puppiJECcorr_gen"); puppisd_corrRECO_cen=(TF1 *) f3->FindObjectAny("puppiJECcorr_reco_0eta1v3"); puppisd_corrRECO_for=(TF1 *) f3->FindObjectAny("puppiJECcorr_reco_1v3eta2v5"); TF1* tf1[3]; tf1[0]=puppisd_corrGEN; tf1[1]=puppisd_corrRECO_cen; tf1[2]=puppisd_corrRECO_for; //option----------------------------------------------------------- int JESOption=0; if(option.find("JESUp")!= std::string::npos)JESOption=1; if(option.find("JESDown")!= std::string::npos)JESOption=2; if(option.find("BtagUp")!= std::string::npos)JESOption=3; if(option.find("BtagDown")!= std::string::npos)JESOption=4; if(option.find("tau21Up")!= std::string::npos)JESOption=5; if(option.find("tau21Down")!= std::string::npos)JESOption=6; cout<<"JESOption = "<<JESOption<<endl; bool printHighPtSubjet=0; bool isFast=1; //tuple tree and cutflow variables------------------------------------------------------------------------------------ TFile *f; TTree *tree; int nPass[20]={0},total=0,dataPassingcsc=0; double nPassB[6]={0}; double fixScaleNum[2]={0}; //using for Btag Eff ----------------------------------------------------------------------------- string btagsystematicsType="central"; if(JESOption==3)btagsystematicsType="up"; else if(JESOption==4)btagsystematicsType="down"; BTagCalibration calib("CSVv2L", "subjet_CSVv2_ichep.csv"); BTagCalibrationReader LF(BTagEntry::OP_LOOSE,"central", {"up", "down"}); BTagCalibrationReader HFC(BTagEntry::OP_LOOSE, "central", {"up", "down"}); // other sys types BTagCalibrationReader HF(BTagEntry::OP_LOOSE,"central",{"up", "down"}); // other sys types LF.load(calib, BTagEntry::FLAV_UDSG, // btag flavour "incl"); // measurement type HFC.load(calib, BTagEntry::FLAV_C, // btag flavour "lt"); // measurement type HF.load(calib, BTagEntry::FLAV_B, // btag flavour "lt"); // measurement type TFile *f1; if(nameRoot==2)f1=TFile::Open("btagEffSource/data.root"); else if (nameRoot!=2 && (JESOption==0||JESOption==3||JESOption==4||JESOption==5||JESOption==6))f1=TFile::Open(Form("btagEffSource/%s.root",st2.data())); else if (nameRoot!=2 && JESOption==1)f1=TFile::Open(Form("btagEffSource/%s_JESUp.root",st2.data())); else if (nameRoot!=2 && JESOption==2)f1=TFile::Open(Form("btagEffSource/%s_JESDown.root",st2.data())); TH1D* th1[6]; string btaggingEff[6]={"effD_b","effN_b","effD_c","effN_c","effD_l","effN_l"}; for(int i=0;i<6;i++){ th1[i]=(TH1D*)f1->FindObjectAny(Form("%s_1d",btaggingEff[i].data())); if(i==1||i==3||i==5)th1[i]->Divide(th1[i-1]); } //check for zero btagging SF---------------------------------------------------------------------------------------- TH2D* th3[6]; th3[0]=new TH2D("zeroSF_b","zeroSF_b",200,0,2000,60,-3,3); th3[1]=new TH2D("zeroSF_c","zeroSF_c",200,0,2000,60,-3,3); th3[2]=new TH2D("zeroSF_l","zeroSF_l",200,0,2000,60,-3,3); th3[3]=new TH2D("SF_vs_Pt_b","SF_vs_Pt_b",120,0,1200,40,0.8,1.2); th3[4]=new TH2D("SF_vs_Pt_c","SF_vs_Pt_c",120,0,1200,40,0.8,1.2); th3[5]=new TH2D("SF_vs_Pt_l","SF_vs_Pt_l",120,0,1200,40,0.8,1.2); for(int i=0;i<6;i++)th3[i]->Sumw2(); //check for high btagging SF---------------------------------------------------------------------------------------- TH1D* th4[14]; string SF_jet_sub[8]={"SF_jet0_sub0_pass","SF_jet0_sub1_pass","SF_jet1_sub0_pass","SF_jet1_sub1_pass","SF_jet0_sub0_fail","SF_jet0_sub1_fail","SF_jet1_sub0_fail","SF_jet1_sub1_fail"}; for(int i=0;i<8;i++)th4[i]=new TH1D(Form("%s",SF_jet_sub[i].data()),Form("%s",SF_jet_sub[i].data()),40,0.8,1.2); string weightName[6]={"weight","weight_0b","weight_1b","weight_2b","weight_2b_ll","weight_2b_onel"}; for(int i=0;i<6;i++)th4[i+8]=new TH1D(Form("%s",weightName[i].data()),Form("%s",weightName[i].data()),40,0,2); for(int i=0;i<14;i++)th4[i]->Sumw2(); //saving variables---------------------------------------------------------------------------------------- TH1D * th5[300],* th6[300]; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ for(int k=0;k<5;k++){ th5[(i*2+j)*5+k]=new TH1D(Form("Pt_j%d_sj%d_%db",i,j,k),Form("Pt_j%d_sj%d_%db",i,j,k),200,0,2000); th5[(i*2+j)*5+k+20]=new TH1D(Form("Eta_j%d_sj%d_%db",i,j,k),Form("Eta_j%d_sj%d_%db",i,j,k),60,-3,3); th5[(i*2+j)*5+k+85]=new TH1D(Form("subCSV_j%d_sj%d_%db",i,j,k),Form("subCSV_j%d_sj%d_%db",i,j,k),20,0,1); th5[(i*2+j)*5+k+194]=new TH1D(Form("subCSVCut_j%d_sj%d_%db",i,j,k),Form("subCSVCut_j%d_sj%d_%db",i,j,k),20,0,1); } } for(int k=0;k<5;k++){ th5[i*5+k+40]=new TH1D(Form("deltaR_j%d_%db",i,k),Form("deltaR_j%d_%db",i,k),20,0,1); th5[i*5+k+50]=new TH1D(Form("Pt_j%d_%db",i,k),Form("Pt_j%d_%db",i,k),200,0,2000); th5[i*5+k+60]=new TH1D(Form("Eta_j%d_%db",i,k),Form("Eta_j%d_%db",i,k),60,-3,3); th5[i*5+k+70]=new TH1D(Form("prMassL2L3_j%d_%db",i,k),Form("prMassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+105]=new TH1D(Form("tau21_j%d_%db",i,k),Form("tau21_j%d_%db",i,k),25,0,1); th5[i*5+k+120]=new TH1D(Form("PuppiSDMassL2L3_j%d_%db",i,k),Form("PuppiSDMassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+130]=new TH1D(Form("puppiTau21_j%d_%db",i,k),Form("puppiTau21_j%d_%db",i,k),25,0,1); th5[i*5+k+140]=new TH1D(Form("prMass_j%d_%db",i,k),Form("prMass_j%d_%db",i,k),15,90,150); th5[i*5+k+150]=new TH1D(Form("PuppiSDMass_j%d_%db",i,k),Form("PuppiSDMass_j%d_%db",i,k),15,90,150); th5[i*5+k+170]=new TH1D(Form("doubleSV_j%d_%db",i,k),Form("doubleSV_j%d_%db",i,k),40,-1,1); th5[i*5+k+184]=new TH1D(Form("FatSV_j%d_%db",i,k),Form("FatSV_j%d_%db",i,k),20,0,1); th5[i*5+k+250]=new TH1D(Form("PuppiSDMassThea_j%d_%db",i,k),Form("PuppiSDMassThea_j%d_%db",i,k),15,90,150); } } for(int k=0;k<5;k++){ th5[k+80]=new TH1D(Form("totalMass_%db",k),Form("totalMass_%db",k),200,1000,5000); th5[k+115]=new TH1D(Form("deltaEta_%db",k),Form("deltaEta_%db",k),40,0,2); th5[k+160]=new TH1D(Form("logPt_%db",k),Form("logPt_%db",k),70,0,7); th5[k+165]=new TH1D(Form("totalMassRed_%db",k),Form("totalMassRed_%db",k),200,1000,5000); } th5[180]= new TH1D("h_nvtx","h_nvtx",60,0,60); th5[181]= new TH1D("h_ntrue","h_ntrue",60,0,60); th5[182]= new TH1D("h_nvtx_cut","h_nvtx_cut",60,0,60); th5[183]= new TH1D("h_ntrue_cut","h_ntrue_cut",60,0,60); string prMass_no[4]={"prMass","prMassL2L3","PuppiSDMass","PuppiSDMassL2L3"}; string tau21_no[2]={"tau21","puppiTau21"}; for (int i=0;i<4;i++){ th5[214+i*2]=new TH1D(Form("%s_j0_noPr_noTau21",prMass_no[i].data()),Form("%s_j0_noPr_noTau21",prMass_no[i].data()),200,0,200); th5[215+i*2]=new TH1D(Form("%s_j1_noPr_noTau21",prMass_no[i].data()),Form("%s_j1_noPr_noTau21",prMass_no[i].data()),200,0,200); th5[222+i*2]=new TH1D(Form("%s_j0_noPr",prMass_no[i].data()),Form("%s_j0_noPr",prMass_no[i].data()),200,0,200); th5[223+i*2]=new TH1D(Form("%s_j1_noPr",prMass_no[i].data()),Form("%s_j1_noPr",prMass_no[i].data()),200,0,200); th5[230+i*2]=new TH1D(Form("%s_j0_noTau21",prMass_no[i].data()),Form("%s_j0_noTau21",prMass_no[i].data()),15,90,150); th5[231+i*2]=new TH1D(Form("%s_j1_noTau21",prMass_no[i].data()),Form("%s_j1_noTau21",prMass_no[i].data()),15,90,150); } for (int i=0;i<2;i++){ th5[238+i*2]=new TH1D(Form("%s_j0_noPr_noTau21",tau21_no[i].data()),Form("%s_j0_noPr_noTau21",tau21_no[i].data()),25,0,1); th5[239+i*2]=new TH1D(Form("%s_j1_noPr_noTau21",tau21_no[i].data()),Form("%s_j1_noPr_noTau21",tau21_no[i].data()),25,0,1); th5[242+i*2]=new TH1D(Form("%s_j0_noPr",tau21_no[i].data()),Form("%s_j0_noPr",tau21_no[i].data()),25,0,1); th5[243+i*2]=new TH1D(Form("%s_j1_noPr",tau21_no[i].data()),Form("%s_j1_noPr",tau21_no[i].data()),25,0,1); th5[246+i*2]=new TH1D(Form("%s_j0_noTau21",tau21_no[i].data()),Form("%s_j0_noTau21",tau21_no[i].data()),25,0,1); th5[247+i*2]=new TH1D(Form("%s_j1_noTau21",tau21_no[i].data()),Form("%s_j1_noTau21",tau21_no[i].data()),25,0,1); } string flavor[4]={"bb","b","cc","udscg"}; for (int i=0;i<4;i++){ th5[260+i]=new TH1D(Form("Pt_j0_0b_%s",flavor[i].data()),Form("Pt_j0_0b_%s",flavor[i].data()),200,0,2000); th5[264+i]=new TH1D(Form("Pt_j0_1b_%s",flavor[i].data()),Form("Pt_j0_1b_%s",flavor[i].data()),200,0,2000); th5[268+i]=new TH1D(Form("Pt_j0_2b_%s",flavor[i].data()),Form("Pt_j0_2b_%s",flavor[i].data()),200,0,2000); th5[272+i]=new TH1D(Form("Pt_j0_DSV_%s",flavor[i].data()),Form("Pt_j0_DSV_%s",flavor[i].data()),200,0,2000); } for(int i=0;i<276;i++){ th6[i]=(TH1D* )th5[i]->Clone(Form("%ss",th5[i]->GetTitle())); th5[i]->Sumw2(); th6[i]->Sumw2(); } //pileup uncertainty---------------------------------------------------------------------------------------- TH1D* th7[14]; th7[0]=new TH1D("totalMass","totalMass",200,1000,5000); th7[1]=new TH1D("totalMass_pileup_up","totalMass_pileup_up",200,1000,5000); th7[2]=new TH1D("totalMass_pileup_down","totalMass_pileup_down",200,1000,5000); th7[3]=new TH1D("pileupEff","pileupEff",15,0.5,15.5); double totalPileup[3]={0},passPileup[3]={0}; standalone_LumiReWeighting LumiWeights_central(0),LumiWeights_up(1),LumiWeights_down(-1); //PDF uncertainty th7[4]=new TH1D("PDFEff","PDFEff",101,0.5,101.5); double passPDF[101]={0},totalPDF[101]={0}; //QCD uncertainty for(int i=5;i<14;i++)th7[i]=new TH1D(Form("uns_QCD_%d",i-5),Form("uns_QCD_%d",i-5),200,1000,5000); //NCUtuple loop---------------------------------------------------------------------------------------- for (int w=wMs;w<wM;w++){ if(w%20==0)cout<<w<<endl; //Get ntuple---------------------------------------------------------------------------------------- if (nameRoot!=1)f = TFile::Open(Form("%s%d.root",st.data(),w)); else f = TFile::Open(st.data()); if (!f || !f->IsOpen())continue; TDirectory * dir; if (nameRoot!=1)dir = (TDirectory*)f->Get(Form("%s%d.root:/tree",st.data(),w)); else dir = (TDirectory*)f->Get(Form("%s:/tree",st.data())); dir->GetObject("treeMaker",tree); TreeReader data(tree); total+=data.GetEntriesFast(); for(Long64_t jEntry=0; jEntry<data.GetEntriesFast() ;jEntry++){//event loop---------------------------------------------------------------------------------------- data.GetEntry(jEntry); Int_t nVtx = data.GetInt("nVtx"); Float_t ntrue= data.GetFloat("pu_nTrueInt"); //Float_t* pdfscaleSysWeights= data.GetPtrFloat("pdfscaleSysWeights"); th5[180]->Fill(nVtx); th5[181]->Fill(ntrue); double PU_weight[3]={1,1,1}; if(nameRoot!=2){ if(ntrue<51){ PU_weight[0] = LumiWeights_central.weight(ntrue); PU_weight[1]= LumiWeights_up.weight(ntrue); PU_weight[2] = LumiWeights_down.weight(ntrue); } else { PU_weight[0] = LumiWeights_central.weight(50); PU_weight[1] = LumiWeights_up.weight(50); PU_weight[2]= LumiWeights_down.weight(50); } } th6[180]->Fill(nVtx,PU_weight[0]); th6[181]->Fill(ntrue,PU_weight[0]); fixScaleNum[0]+=PU_weight[0]; for(int i=0;i<3;i++)totalPileup[i]+=PU_weight[i]; for(int i=0;i<101;i++)totalPDF[i]+=PU_weight[0]; //1.trigger std::string* trigName = data.GetPtrString("hlt_trigName"); vector<bool> &trigResult = *((vector<bool>*) data.GetPtr("hlt_trigResult")); bool passTrigger=false; for(int it=0; it< data.GetPtrStringSize(); it++){ std::string thisTrig= trigName[it]; bool results = trigResult[it]; if( ((thisTrig.find("HLT_PFHT800")!= std::string::npos ) && results==1)){ passTrigger=true; break; } } if(!passTrigger && nameRoot==2)continue;nPass[1]++; Float_t HT= data.GetFloat("HT"); if(nameRoot!=2 && HT<800)continue; int nFATJet = data.GetInt("FATnJet"); TClonesArray* fatjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); float* FATjetCorrUncUp = data.GetPtrFloat("FATjetCorrUncUp"); float* FATjetCorrUncDown = data.GetPtrFloat("FATjetCorrUncDown"); vector<bool> &FATjetPassIDTight = *((vector<bool>*) data.GetPtr("FATjetPassIDTight")); //2.nJets if(nFATJet<2)continue;nPass[2]++; TLorentzVector* thisJet ,* thatJet; if (JESOption==1){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1+FATjetCorrUncUp[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1+FATjetCorrUncUp[1] ); thisJet= &test0; thatJet= &test1; } else if (JESOption==2){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1-FATjetCorrUncDown[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1-FATjetCorrUncDown[1] ); thisJet= &test0; thatJet= &test1; } else{ thisJet= (TLorentzVector*)fatjetP4->At(0); thatJet = (TLorentzVector*)fatjetP4->At(1); } //3. Pt if(thisJet->Pt()<200||thatJet->Pt()<200)continue; nPass[3]++; //4tightId----------------------------------------- if(FATjetPassIDTight[0]==0||FATjetPassIDTight[1]==0)continue; nPass[4]++; //5. Eta----------------------------------------- if(fabs(thisJet->Eta())>2.4||fabs(thatJet->Eta())>2.4)continue; nPass[5]++; //6. DEta----------------------------------------- float dEta = fabs(thisJet->Eta()-thatJet->Eta()); if(dEta>1.3)continue; nPass[6]++; //7. Mjj----------------------------------------- float mjj = (*thisJet+*thatJet).M(); float mjjRed = (*thisJet+*thatJet).M()+250-thisJet->M()-thatJet->M(); //if(mjjRed<1000)continue; nPass[7]++; //8. fatjetPRmassL2L3Corr----------------------------------------- Float_t* fatjetPRmassL2L3Corr = data.GetPtrFloat("FATjetPRmassL2L3Corr"); vector<float> *subjetSDCSV = data.GetPtrVectorFloat("FATsubjetSDCSV"); vector<Int_t> *FATsubjetSDHadronFlavor = data.GetPtrVectorInt("FATsubjetSDHadronFlavor"); int nbtag=0,nbtag2=0; float MaxBJetPt = 670., MaxLJetPt = 1000.; double sf[2][2],eta[2],pt[2],dr[2],subjetPt[2][2],subjetEta[2][2],eff[2][2],btaggingscaleFactor=1; pt[0]=thisJet->Pt(); pt[1]=thatJet->Pt(); double scaleFactor=PU_weight[0]*btaggingscaleFactor; Float_t* fatjetTau1 = data.GetPtrFloat("FATjetTau1"); Float_t* fatjetTau2 = data.GetPtrFloat("FATjetTau2"); Float_t* FATjetPuppiTau1 = data.GetPtrFloat("FATjetPuppiTau1"); Float_t* FATjetPuppiTau2 = data.GetPtrFloat("FATjetPuppiTau2"); double tau21[2]; tau21[0]=(fatjetTau2[0]/fatjetTau1[0]),tau21[1]=(fatjetTau2[1]/fatjetTau1[1]); double puppiTau21[2]; puppiTau21[0]=(FATjetPuppiTau2[0]/FATjetPuppiTau1[0]),puppiTau21[1]=(FATjetPuppiTau2[1]/FATjetPuppiTau1[1]); if(fatjetPRmassL2L3Corr[0]<50||fatjetPRmassL2L3Corr[0]>300)continue; if(fatjetPRmassL2L3Corr[1]<50||fatjetPRmassL2L3Corr[1]>300)continue; nPass[8]++; //9.----------------------------------------- if(tau21[0]>0.6 || tau21[1]>0.6) continue; nPass[9]++; Int_t* FATjetHadronFlavor = data.GetPtrInt("FATjetHadronFlavor"); if(subjetSDCSV[0][0]<0.605 && subjetSDCSV[0][1]<0.605){ if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)th5[260]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))th5[261]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)th5[262]->Fill(thisJet->Pt()); else th5[263]->Fill(thisJet->Pt()); } else if (subjetSDCSV[0][0]>0.605 && subjetSDCSV[0][1]>0.605){ if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)th5[268]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))th5[269]->Fill(thisJet->Pt()); else if (FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)th5[270]->Fill(thisJet->Pt()); else th5[271]->Fill(thisJet->Pt()); } else { if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)th5[264]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))th5[265]->Fill(thisJet->Pt()); else if (FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)th5[266]->Fill(thisJet->Pt()); else th5[267]->Fill(thisJet->Pt()); } fixScaleNum[1]+=PU_weight[0]; Float_t* ADDjet_DoubleSV = data.GetPtrFloat("ADDjet_DoubleSV"); Float_t FATjet_DoubleSV[2]={0}; Int_t ADDnJet = data.GetInt("ADDnJet"); bool matchThis=0,matchThat=0; TClonesArray* ADDjetP4 = (TClonesArray*) data.GetPtrTObject("ADDjetP4"); for(int i=0;i<ADDnJet;i++){ TLorentzVector* thisAddJet ; thisAddJet= (TLorentzVector*)ADDjetP4->At(i); if(!matchThis && thisAddJet->DeltaR(*thisJet)<0.8){ matchThis=1; FATjet_DoubleSV[0]=ADDjet_DoubleSV[i]; continue; } if(!matchThat && thisAddJet->DeltaR(*thatJet)<0.8){ matchThat=1; FATjet_DoubleSV[1]=ADDjet_DoubleSV[i]; } if(matchThis&& matchThat){ //cout<<"match"<<FATjet_DoubleSV[0]<<","<<FATjet_DoubleSV[0]<<endl; break; } } if(FATjet_DoubleSV[0]>-0.8){ if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)th5[272]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))th5[273]->Fill(thisJet->Pt()); else if (FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)th5[274]->Fill(thisJet->Pt()); else th5[275]->Fill(thisJet->Pt()); } }//end event loop---------------------------------------------------------------------------------------- } //end ntuple loop---------------------------------------------------------------------------------------- cout<<"entries="<<total<<endl; for(int i=0;i<6;i++)cout<<"nPassB["<<i<<"]="<<nPassB[i]<<endl; for(int i=0;i<16;i++)cout<<"nPass["<<i<<"]="<<nPass[i]<<endl; for(int i=0;i<3;i++)th7[3]->SetBinContent(i+1,passPileup[i]/totalPileup[i]); for(int i=0;i<101;i++)th7[4]->SetBinContent(i+1,passPDF[i]/totalPDF[i]); TH1D * th2o=new TH1D("Nbtagjet","Nbtagjet",5,-0.5,4.5); for (int i=0;i<5;i++){ if(nameRoot==2 && i>2)continue; th2o->SetBinContent(i+1,nPass[i+10]); } TH1D * th2ob=new TH1D("NbtagjetB","NbtagjetB",5,-0.5,4.5); for (int i=0;i<5;i++){ if(nameRoot==2 && i>2)continue; th2ob->SetBinContent(i+1,nPassB[i]); } TH1D * fixScale=new TH1D("fixScale","fixScale",2,-0.5,1.5); fixScale->SetBinContent(1,fixScaleNum[0]); fixScale->SetBinContent(2,fixScaleNum[1]); TH1D * cutflow=new TH1D("cutflow","cutflow",16,0.5,16.5); cutflow->SetBinContent(1,total); if(nameRoot==2)for(int ii=1;ii<14;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); else for(int ii=1;ii<16;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); TFile* outFile = new TFile(Form("root_file_mike/%s.root",st2.data()),"recreate"); th2o->Write(); th2ob->Write(); fixScale->Write(); cutflow->Write(); for(int i=0;i<6;i++)th3[i]->Write(); for(int i=0;i<14;i++)th4[i]->Write(); for(int i=0;i<276;i++){ th5[i]->Write(); th6[i]->Write(); } for(int i=0;i<14;i++)th7[i]->Write(); outFile->Close(); }
void mZHLimit(string inputFile, string outputFile, string channel, int cat, int mzh=0){ // setup calibration and reader BTagCalibration calib("csvv1", "/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/CSVV1.csv"); BTagCalibrationReader reader_l(BTagEntry::OP_LOOSE, "central"); BTagCalibrationReader reader_c(BTagEntry::OP_LOOSE, "central"); BTagCalibrationReader reader_b(BTagEntry::OP_LOOSE, "central"); reader_l.load(calib, BTagEntry::FLAV_UDSG, "comb"); reader_c.load(calib, BTagEntry::FLAV_C, "mujets"); reader_b.load(calib, BTagEntry::FLAV_B, "mujets"); // to read b-tag effinciency TFile* f_l = TFile::Open(Form("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/bTagEffroot/%s_udsgflavor_zjetsBtagEff.root", channel.data())); TFile* f_c = TFile::Open(Form("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/bTagEffroot/%s_cflavor_zjetsBtagEff.root", channel.data())); TFile* f_b = mzh==0 ? TFile::Open(Form("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/bTagEffroot/%s_bflavor_zjetsBtagEff.root", channel.data())) : TFile::Open(Form("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/bTagEffroot/%s_bflavor_signalBtagEff.root", channel.data())); TH1F* h_l = (TH1F*)(f_l->Get(Form("%s_udsgflavor", channel.data()))); TH1F* h_c = (TH1F*)(f_c->Get(Form("%s_cflavor", channel.data()))); TH1F* h_b = mzh==0 ? (TH1F*)(f_b->Get(Form("%s_bflavor", channel.data()))) : (TH1F*)(f_b->Get(Form("%s_bflavor_m%i", channel.data(), mzh))); // to read lepton scale factor / trigger TFile* f_ele = TFile::Open("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/leptonSFroot/CutBasedID_LooseWP_fromTemplates_withSyst_Final.txt_SF2D.root"); TFile* f_muScal = TFile::Open("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/leptonSFroot/MuonHighPt_Z_RunCD_Reco74X_Dec17.root"); TFile* f_muTrig = TFile::Open("/afs/cern.ch/work/h/htong/ZpZHllbb_13TeV/leptonSFroot/SingleMuonTrigger_Z_RunCD_Reco74X_Dec1.root"); TH2F* h2_ele = (TH2F*)(f_ele->Get("EGamma_SF2D")); TH2F* h2_muPt20 = (TH2F*)(f_muScal->Get("HighPtID_PtEtaBins_Pt20/abseta_pTtuneP_ratio")); TH2F* h2_muPt53 = (TH2F*)(f_muScal->Get("HighPtID_PtEtaBins_Pt53/abseta_pTtuneP_ratio")); TH2F* h2_muRunD = (TH2F*)(f_muTrig->Get("runD_Mu45_eta2p1_PtEtaBins/abseta_pt_ratio")); // read the ntuples (in pcncu) TreeReader data(inputFile.data()); TFile f(inputFile.data()); // Declare the histogram TH1D* h_totalEv = (TH1D*)f.Get("h_totalEv"); TH1D* h_mZH = new TH1D("h_mZH", "", 71, 750, 4300); h_mZH->Sumw2(); // begin of event loop fprintf(stdout, "Total events %lli\n", data.GetEntriesFast()); for( Long64_t ev = data.GetEntriesFast()-1; ev >= 0; --ev ){ if( (unsigned)ev % 100000 == 0 ) fprintf(stdout, "Still left events %lli\n", ev); data.GetEntry(ev); Bool_t isData = data.GetBool("isData"); Float_t eventWeight = data.GetFloat("ev_weight"); TClonesArray* muP4 = (TClonesArray*) data.GetPtrTObject("muP4"); TClonesArray* eleP4 = (TClonesArray*) data.GetPtrTObject("eleP4"); TClonesArray* FATjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); vector<bool>& isHighPtMuon = *((vector<bool>*) data.GetPtr("isHighPtMuon")); // select good reco level events // select good leptons vector<int> goodLepID; if( channel == "ele" && !isPassZee(data,goodLepID) ) continue; if( channel == "mu" && !isPassZmumu(data,goodLepID) ) continue; TLorentzVector* thisLep = (channel=="ele") ? (TLorentzVector*)eleP4->At(goodLepID[0]) : (TLorentzVector*)muP4->At(goodLepID[0]); TLorentzVector* thatLep = (channel=="ele") ? (TLorentzVector*)eleP4->At(goodLepID[1]) : (TLorentzVector*)muP4->At(goodLepID[1]); // calculate lepton weight float thisLepWeight = 1; float thatLepWeight = 1; if( mzh != 0){ if( channel == "ele" ){ thisLepWeight = leptonWeight(h2_ele, thisLep, false); thatLepWeight = leptonWeight(h2_ele, thatLep, false); } else if( channel == "mu" ){ if( isHighPtMuon[goodLepID[0]] ) thisLepWeight = (thisLep->Pt() < 53) ? leptonWeight(h2_muPt20, thisLep) : leptonWeight(h2_muPt53, thisLep); else thisLepWeight = 1; if( isHighPtMuon[goodLepID[1]] ) thatLepWeight = (thatLep->Pt() < 53) ? leptonWeight(h2_muPt20, thatLep) : leptonWeight(h2_muPt53, thatLep); else thatLepWeight = 1; } } // only signal samples // calculate trigger weight for muon float muTrigWeight = 1; if( mzh != 0 ){ if( channel=="mu" ){ if( thisLep->Pt() > thatLep->Pt() ) muTrigWeight = (fabs(thisLep->Eta()) < 2.1) ? leptonWeight(h2_muRunD, thisLep) : 1; else muTrigWeight = (fabs(thatLep->Eta()) < 2.1) ? leptonWeight(h2_muRunD, thatLep) : 1; } else muTrigWeight = 1; } // only signal samples // select good FATjet int goodFATJetID = -1; if( !isPassJet(data, &goodFATJetID, thisLep, thatLep) ) continue; TLorentzVector* thisJet = (TLorentzVector*)FATjetP4->At(goodFATJetID); float mllbb; if( !noiseCleaning(thisLep, thatLep, thisJet, &mllbb) ) continue; // b-tag cut int nsubBjet = 0; float btagWeight = bTagWeight(data, goodFATJetID, &nsubBjet, h_l, h_c, h_b, reader_l, reader_c, reader_b); if( cat == 1 && nsubBjet != 1 ) continue; if( cat == 2 && nsubBjet != 2 ) continue; float finalWeight = isData ? 1 : eventWeight * btagWeight * thisLepWeight * thatLepWeight * muTrigWeight; h_mZH->Fill(mllbb, finalWeight); } // end of event loop fprintf(stderr, "Processed all events\n"); TFile* outFile = new TFile(Form("%s_mZHLimit.root", outputFile.data()), "recreate"); h_mZH ->Write("mZH"); h_totalEv->Write("totalEvents"); outFile->Write(); delete outFile; }
int main_ecalib(int argc, char* argv[]) { long calsize[3] = { 24, 24, 24 }; int maps = 2; bool one = false; bool calcen = false; bool print_svals = false; struct ecalib_conf conf = ecalib_defaults; const struct opt_s opts[] = { OPT_FLOAT('t', &conf.threshold, "threshold", "This determined the size of the null-space."), OPT_FLOAT('c', &conf.crop, "crop_value", "Crop the sensitivities if the eigenvalue is smaller than {crop_value}."), OPT_VEC3('k', &conf.kdims, "ksize", "kernel size"), OPT_VEC3('K', &conf.kdims, "", "()"), OPT_VEC3('r', &calsize, "cal_size", "Limits the size of the calibration region."), OPT_VEC3('R', &calsize, "", "()"), OPT_INT('m', &maps, "maps", "Number of maps to compute."), OPT_SET('S', &conf.softcrop, "create maps with smooth transitions (Soft-SENSE)."), OPT_SET('W', &conf.weighting, "soft-weighting of the singular vectors."), OPT_SET('I', &conf.intensity, "intensity correction"), OPT_SET('1', &one, "perform only first part of the calibration"), OPT_CLEAR('P', &conf.rotphase, "Do not rotate the phase with respect to the first principal component"), OPT_CLEAR('O', &conf.orthiter, "()"), OPT_FLOAT('b', &conf.perturb, "", "()"), OPT_SET('V', &print_svals, "()"), OPT_SET('C', &calcen, "()"), OPT_SET('g', &conf.usegpu, "()"), OPT_FLOAT('p', &conf.percentsv, "", "()"), OPT_INT('n', &conf.numsv, "", "()"), OPT_FLOAT('v', &conf.var, "variance", "Variance of noise in data."), OPT_SET('a', &conf.automate, "Automatically pick thresholds."), OPT_INT('d', &debug_level, "level", "Debug level"), }; cmdline(&argc, argv, 2, 3, usage_str, help_str, ARRAY_SIZE(opts), opts); if (-1. != conf.percentsv) conf.threshold = -1.; if (-1 != conf.numsv) conf.threshold = -1.; if (conf.automate) { conf.crop = -1.; conf.weighting = true; } if (conf.weighting) { conf.numsv = -1.; conf.threshold = 0; conf.percentsv = -1.; conf.orthiter = false; } int N = DIMS; long ksp_dims[N]; complex float* in_data = load_cfl(argv[1], N, ksp_dims); // assert((kdims[0] < calsize_ro) && (kdims[1] < calsize_ro) && (kdims[2] < calsize_ro)); // assert((ksp_dims[0] == 1) || (calsize_ro < ksp_dims[0])); if (1 != ksp_dims[MAPS_DIM]) error("MAPS dimension is not of size one.\n"); long cal_dims[N]; complex float* cal_data = NULL; if (!calcen) { #ifdef USE_CC_EXTRACT_CALIB cal_data = cc_extract_calib(cal_dims, calsize, ksp_dims, in_data); #else cal_data = extract_calib(cal_dims, calsize, ksp_dims, in_data, false); #endif } else { for (int i = 0; i < 3; i++) cal_dims[i] = (calsize[i] < ksp_dims[i]) ? calsize[i] : ksp_dims[i]; for (int i = 3; i < N; i++) cal_dims[i] = ksp_dims[i]; cal_data = md_alloc(5, cal_dims, CFL_SIZE); md_resize_center(5, cal_dims, cal_data, ksp_dims, in_data, CFL_SIZE); } for (int i = 0; i < 3; i++) if (1 == ksp_dims[i]) conf.kdims[i] = 1; long channels = cal_dims[3]; unsigned int K = conf.kdims[0] * conf.kdims[1] * conf.kdims[2] * channels; float svals[K]; for (unsigned int i = 0; i < 3; i++) if ((1 == cal_dims[i]) && (1 != ksp_dims[i])) error("Calibration region not found!\n"); // To reproduce old results turn off rotation of phase. // conf.rotphase = false; // FIXME: we should scale the data (conf.usegpu ? num_init_gpu : num_init)(); if ((conf.var < 0) && (conf.weighting || (conf.crop < 0))) conf.var = estvar_calreg(conf.kdims, cal_dims, cal_data); if (one) { #if 0 long maps = out_dims[4]; assert(caldims[3] == out_dims[3]); assert(maps <= channels); #endif long cov_dims[4]; calone_dims(&conf, cov_dims, channels); complex float* imgcov = md_alloc(4, cov_dims, CFL_SIZE); calone(&conf, cov_dims, imgcov, K, svals, cal_dims, cal_data); complex float* out = create_cfl(argv[2], 4, cov_dims); md_copy(4, cov_dims, out, imgcov, CFL_SIZE); unmap_cfl(4, cov_dims, out); // caltwo(crthr, out_dims, out_data, emaps, cov_dims, imgcov, NULL, NULL); md_free(imgcov); } else { long out_dims[N]; long map_dims[N]; for (int i = 0; i < N; i++) { out_dims[i] = 1; map_dims[i] = 1; if ((i < 3) && (1 < conf.kdims[i])) { out_dims[i] = ksp_dims[i]; map_dims[i] = ksp_dims[i]; } } assert(maps <= ksp_dims[COIL_DIM]); out_dims[COIL_DIM] = ksp_dims[COIL_DIM]; out_dims[MAPS_DIM] = maps; map_dims[COIL_DIM] = 1; map_dims[MAPS_DIM] = maps; const char* emaps_file = NULL; if (4 == argc) emaps_file = argv[3]; complex float* out_data = create_cfl(argv[2], N, out_dims); complex float* emaps = (emaps_file ? create_cfl : anon_cfl)(emaps_file, N, map_dims); calib(&conf, out_dims, out_data, emaps, K, svals, cal_dims, cal_data); unmap_cfl(N, out_dims, out_data); unmap_cfl(N, map_dims, emaps); } if (print_svals) { for (unsigned int i = 0; i < K; i++) printf("SVALS %d %f\n", i, svals[i]); } printf("Done.\n"); unmap_cfl(N, ksp_dims, in_data); md_free(cal_data); return 0; }
BTagSFUtil::BTagSFUtil(string MeasurementType, string BTagAlgorithm, TString OperatingPoint, int SystematicIndex, TString FastSimDataset, int Seed) { rand_ = new TRandom3(Seed); string CSVFileName = "../BTagSFUtil/BTagScaleFactors/" + CampaignName + "/" + BTagAlgorithm + CSVFileFlag + ".csv"; BTagCalibrationSA calib(BTagAlgorithm, CSVFileName); SystematicFlagB = "central"; SystematicFlagC = "central"; SystematicFlagL = "central"; if (abs(SystematicIndex)<10) { if (SystematicIndex==-1) SystematicFlagB = "down"; if (SystematicIndex==+1) SystematicFlagB = "up"; if (SystematicIndex==-2) cout << "BTagSFUtil: SFc not available yet"; if (SystematicIndex==+2) cout << "BTagSFUtil: SFc not available yet"; SystematicFlagC = SystematicFlagB; if (SystematicIndex==-3) SystematicFlagL = "down"; if (SystematicIndex==+3) SystematicFlagL = "up"; } TaggerCut = -999.; TaggerName = BTagAlgorithm; TaggerOP = BTagAlgorithm; int iTagger = -1; for (int itg = 0; itg<nSupportedTaggers; itg++) if (SupportedTaggerName[itg]==TaggerName) iTagger = itg; if (iTagger<0) cout << " " << TaggerName << " not supported for " << CampaignName << endl; if (OperatingPoint=="Loose") { TaggerOP += "L"; TaggerCut = TaggerWP[iTagger][0]; reader = new BTagCalibrationReaderSA(BTagEntrySA::OP_LOOSE, "central", {"up", "down"}); } else if (OperatingPoint=="Medium") { TaggerOP += "M"; TaggerCut = TaggerWP[iTagger][1]; reader = new BTagCalibrationReaderSA(BTagEntrySA::OP_MEDIUM, "central", {"up", "down"}); } else if (OperatingPoint=="Tight") { TaggerOP += "T"; TaggerCut = TaggerWP[iTagger][2]; reader = new BTagCalibrationReaderSA(BTagEntrySA::OP_TIGHT, "central", {"up", "down"}); } reader->load(calib, BTagEntrySA::FLAV_B, MeasurementType); reader->load(calib, BTagEntrySA::FLAV_C, MeasurementType); reader->load(calib, BTagEntrySA::FLAV_UDSG, LightMeasurementType); if (TaggerCut==-999.) cout << " " << TaggerName << " not supported for " << OperatingPoint << " WP" << endl; //FastSimSystematic = 0; //if (abs(SystematicIndex)>10) FastSimSystematic = SystematicIndex%10; //GetFastSimPayload(BTagAlgorithm, FastSimDataset); // Run1 style IsFastSimDataset = false; if (FastSimDataset!="") { IsFastSimDataset = true; string FastSimName = ""; for (int idt = 0; idt<nFastSimDatasets; idt++) if (FastSimDataset==FastSimDatasetName[idt]) FastSimName = FastSimDatasetName[idt]; string FastSimCSVFileName = "../BTagSFUtil/FastSimCorrectionFactors/" + CampaignName + "/" + BTagAlgorithm + FastSimName + FastSimCSVFileFlag + ".csv"; BTagCalibrationSA fastsimcalib(BTagAlgorithm, FastSimCSVFileName); FastSimSystematicFlagB = "central"; FastSimSystematicFlagC = "central"; FastSimSystematicFlagL = "central"; if (abs(SystematicIndex)>=11) { if (SystematicIndex==-11) FastSimSystematicFlagB = "down"; if (SystematicIndex==+11) FastSimSystematicFlagB = "up"; if (SystematicIndex==-12) FastSimSystematicFlagC = "down"; if (SystematicIndex==+12) FastSimSystematicFlagC = "up"; if (SystematicIndex==-13) FastSimSystematicFlagL = "down"; if (SystematicIndex==+13) FastSimSystematicFlagL = "up"; } if (OperatingPoint=="Loose") { fastsimreader = new BTagCalibrationReaderSA(BTagEntrySA::OP_LOOSE, "central", {"up", "down"}); } else if (OperatingPoint=="Medium") { fastsimreader = new BTagCalibrationReaderSA(BTagEntrySA::OP_MEDIUM, "central", {"up", "down"}); } else if (OperatingPoint=="Tight") { fastsimreader = new BTagCalibrationReaderSA(BTagEntrySA::OP_TIGHT, "central", {"up", "down"}); } fastsimreader->load(fastsimcalib, BTagEntrySA::FLAV_B, "fastsim"); fastsimreader->load(fastsimcalib, BTagEntrySA::FLAV_C, "fastsim"); fastsimreader->load(fastsimcalib, BTagEntrySA::FLAV_UDSG, "fastsim"); } }