示例#1
0
double BTagWeight::getBScaleFactor(const JetPointer jet, double uncertaintyFactor) const {
	const boost::array<double, 14> SFb_error = { { 0.0295675, 0.0295095, 0.0210867, 0.0219349, 0.0227033, 0.0204062,
			0.0185857, 0.0256242, 0.0383341, 0.0409675, 0.0420284, 0.0541299, 0.0578761, 0.0655432 } };

	const boost::array<double, 14> ptbins = { { 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500 } };

	double SFb(0);
	double sf_error(0);
	//these numbers are for CSVM only
	double pt = jet->pt();
	if (pt < 30) {
		SFb = 0.6981 * (1. + 0.414063 * 30) / (1. + 0.300155 * 30);
		sf_error = 0.12;
	} else if (pt > 670) {
		SFb = 0.6981 * (1. + 0.414063 * 670) / (1. + 0.300155 * 670);
		//use twice the uncertainty
		sf_error = 2 * SFb_error[SFb_error.size() - 1];
	} else {
		SFb = 0.6981 * (1. + 0.414063 * pt) / (1. + 0.300155 * pt);
		unsigned int ptbin(0);
		for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) {
			double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 670.;
			double lowerCut = ptbins.at(bin);

			if (pt > lowerCut && pt <= upperCut) {
				ptbin = bin;
				break;
			}
		}
		sf_error = SFb_error.at(ptbin);
	}
	SFb += sf_error * Globals::BJetSystematic * uncertaintyFactor;
	return SFb;
}
示例#2
0
double BTagWeight::getBScaleFactor(const Jet& jet, double uncertaintyFactor) const {
	const boost::array<double, 16> SFb_error = { {0.0554504,
			 0.0209663,
			 0.0207019,
			 0.0230073,
			 0.0208719,
			 0.0200453,
			 0.0264232,
			 0.0240102,
			 0.0229375,
			 0.0184615,
			 0.0216242,
			 0.0248119,
			 0.0465748,
			 0.0474666,
			 0.0718173,
			 0.0717567 } };

	const boost::array<double, 16> ptbins = { {20, 30, 40, 50, 60, 70, 80,100, 120, 160, 210, 260, 320, 400, 500, 600 } };

	double SFb(0);
	double sf_error(0);
	//these numbers are for CSVM only
	double pt = getSmearedJetPtScale(jet, 0)*jet.pt();
	if (pt < 20) {
		SFb = 0.726981*((1.+(0.253238*20))/(1.+(0.188389*20)));
		sf_error = 0.12;
	} else if (pt > 800) {
		SFb = 0.726981*((1.+(0.253238*800))/(1.+(0.188389*800)));
		//use twice the uncertainty
		sf_error = 2 * SFb_error[SFb_error.size() - 1];
	} else {
		SFb = 0.726981*((1.+(0.253238*pt))/(1.+(0.188389*pt)));
		unsigned int ptbin(0);
		for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) {
			double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 800.;
			double lowerCut = ptbins.at(bin);

			if (pt > lowerCut && pt <= upperCut) {
				ptbin = bin;
				break;
			}
		}
		sf_error = SFb_error.at(ptbin);
	}
	SFb += sf_error * BJetSystematic_ * uncertaintyFactor;
	return SFb;
}
示例#3
0
void receiver (int index) {
    try {
        
        const NodeId receiver_id = receiver_ids.at (index);        
        
        std::cout << "Receiver " << receiver_id << " starting..." << std::endl;
        
        LocalClientConnectionRef conn = net->open (receiver_id, channel);
        
        while (true) {            
            const ParcelRef parcel = conn->receive ();
            std::cout << 
                "I (" << receiver_id << 
                ") heard that sender " << 
                parcel->envelope ().sender ()
                << " slept for " << 
                parcel->message().get<int>()
                << " milliseconds" << std::endl;
        }
        
    } 
    catch (std::exception &e) {
        std::cout << "Exception [receiver]: " << e.what () << std::endl;
    }
    catch (...) {
        std::cout << "Unknown exception." << std::endl;
    }
}
示例#4
0
void sender (int index) {
  
  try {
      
    const NodeId sender_id = sender_ids.at (index);
  
    std::cout << "Sender " << sender_id << " starting..." << std::endl;
    
    LocalClientConnectionRef conn = net->open (sender_id, channel);
    
    boost::mt19937 gen (index);
    boost::uniform_int<> dist (350, 750);
    boost::variate_generator<boost::mt19937 &, boost::uniform_int<> > rnd (gen, dist);
    
    while (true) {
        const int pause = rnd();
        
        std::cout << "I (" << sender_id << ") shall sleep for " << pause << " ms." << std::endl;
        
        boost::this_thread::sleep
          (boost::posix_time::milliseconds
            (pause));
        
        conn->send (receiver_id, channel, Message::build<int>(pause));
    }
    
  } 
  catch (std::exception &e) {
    std::cout << "Exception [sender]: " << e.what () << std::endl;
  }
  catch (...) {
    std::cout << "Unknown exception." << std::endl;
  }
}
void HistogramManager::prepareForSeenDataTypes(
		const boost::array<bool, DataType::NUMBER_OF_DATA_TYPES>& seenDataTypes) {
	this->seenDataTypes = seenDataTypes;

	for (unsigned type = 0; type < DataType::NUMBER_OF_DATA_TYPES; ++type) {
		if (seenDataTypes.at(type)) {
			const std::string filename = assembleFilename((DataType::value) type);
			boost::shared_ptr<TFile> file(new TFile(filename.c_str(), "RECREATE"));
			file->SetCompressionLevel(7);

			histFiles.at(type) = file;
			collection1D[""].at(type) = TH1CollectionRef(new TH1Collection());
			collection2D[""].at(type) = TH2CollectionRef(new TH2Collection());
		}
	}
}
示例#6
0
void read_callback(const boost::system::error_code& e, std::size_t size)
{
	boost::mutex::scoped_lock lk(mtx);

	for(unsigned int i=0;i<size;i++){
		unsigned char c = rbuf.at(i);
		if(flag_receive_datas){
			switch(state_num){
			  case 0:
			  case 1:
				if(c == 0xaa) state_num++;
				else state_num = 0;
				break;
			  case 2:
				if(c == 0x02) state_num++;
				else state_num = 0;
				break;
			  case 3:
				result = c<<8;
				state_num++;
				break;
			  case 4:
				result |= c;
				state_num++;
				break;
			  default:
				state_num = 0;
			}
			
			if(state_num == 5){
				//printf("%d\r\n", result);
				val[val_pointer++] = result;
				if(val_pointer == 640) val_pointer = 0;
				sample_num++;
#ifdef FILE_SAVE
				ptime now = second_clock::local_time();
				ofs << to_iso_string(now) << "," << result << std::endl;
#endif /* FILE_SAVE */
			}
		}else{
			state_num = 0;
		}
	}

	port.async_read_some( buffer(rbuf), boost::bind(&read_callback, _1, _2 ));
}
示例#7
0
 value_type *const getcvals(const unsigned int b)
 { return cvals.at(b); }
示例#8
0
 void setcvals(const unsigned int b, value_type *const cval)
 { cvals.at(b) = cval; }
示例#9
0
 explicit Expansion(const point_type& _u)
   : u(_u), vals(new value_type [FAC*nnodes])
 {
   this->zero();
   for (unsigned int b=0; b<nboxes; ++b) cvals.at(b) = NULL;
 }
示例#10
0
double BTagWeight::getBScaleFactor(const Jet& jet, std::string MCSampleTag, double uncertaintyFactor) const {
	double SFb(0);
	double sf_error(0);
	//these numbers are for CSVM only
	double pt = getSmearedJetPtScale(jet, 0)*jet.pt();
	double eta = jet.eta();

	if (MCSampleTag == "Summer12") { // 2012 btag scale factors
		// From https://twiki.cern.ch/twiki/pub/CMS/BtagPOG/SFb-pt_WITHttbar_payload_EPS13.txt,
		// which is linked from https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagPOG#2012_Data_and_MC_EPS13_prescript
		const boost::array<double, 16> SFb_error = { { 0.0415707,
				0.0204209,
				0.0223227,
				0.0206655,
				0.0199325,
				0.0174121,
				0.0202332,
				0.0182446,
				0.0159777,
				0.0218531,
				0.0204688,
				0.0265191,
				0.0313175,
				0.0415417,
				0.0740446,
				0.0596716 } };

		//2012 pt bins low edges
		const boost::array<double, 16> ptbins = { { 20, 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500, 600 } };

		if (pt < 20) {
			SFb = (0.938887 + (0.00017124 * 20)) + (-2.76366e-07 * (20 * 20));
			//use twice the uncertainty
			sf_error = 2 * SFb_error[0];

		} else if (pt > 800) {
			SFb = (0.938887 + (0.00017124 * 800)) + (-2.76366e-07 * (800 * 800));
			//use twice the uncertainty
			sf_error = 2 * SFb_error[SFb_error.size() - 1];

		} else {
			SFb = (0.938887 + (0.00017124 * pt)) + (-2.76366e-07 * (pt * pt));
			unsigned int ptbin(0);
			for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) {
				double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 800.;
				double lowerCut = ptbins.at(bin);

				if (pt > lowerCut && pt <= upperCut) {
					ptbin = bin;
					break;
				}
			}
			sf_error = SFb_error.at(ptbin);

			//use twice the uncertainty if outside the 0 to 2.4 eta range
			if (2.4 < eta && eta <= 2.6) {
				sf_error = 2 * SFb_error.at(ptbin);
			}
		}
	} else if (MCSampleTag == "Summer11Leg") { // 2011 btag scale factors
		// https://twiki.cern.ch/twiki/pub/CMS/BtagPOG/SFb-mujet_payload.txt
		const boost::array<double, 14> SFb_error = { { 0.0295675,
				0.0295095,
				0.0210867,
				0.0219349,
				0.0227033,
				0.0204062,
				0.0185857,
				0.0256242,
				0.0383341,
				0.0409675,
				0.0420284,
				0.0541299,
				0.0578761,
				0.0655432 } };

		//2011 pt bins low edges
		const boost::array<double, 14> ptbins = { { 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500 } };

		if (pt < 30) {
			SFb = 0.6981 * ((1. + (0.414063 * pt)) / (1. + (0.300155 * 30)));
			//absolute uncertainty of +/-0.12
			sf_error = 0.12;

		} else if (pt > 670) {
			SFb = 0.6981 * ((1. + (0.414063 * 670)) / (1. + (0.300155 * 670)));
			//use twice the uncertainty
			sf_error = 2 * SFb_error[SFb_error.size() - 1];

		} else {
			SFb = 0.6981 * ((1. + (0.414063 * pt)) / (1. + (0.300155 * pt)));

			unsigned int ptbin(0);
			for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) {
				double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 670.;
				double lowerCut = ptbins.at(bin);

				if (pt > lowerCut && pt <= upperCut) {
					ptbin = bin;
					break;
				}
			}
			sf_error = SFb_error.at(ptbin);
		}
	}
	SFb += sf_error * BJetSystematic_ * uncertaintyFactor;
	return SFb;
}