Esempio n. 1
0
double 
Gaussian::Cdf(size_t dim_, double val_) const{
    double nDevs = (val_ - GetMean(dim_))/GetStDev(dim_);
    if (nDevs > fCdfCutOff)
        return 1;
    if(nDevs < -1 * fCdfCutOff)
        return 0;

    return gsl_cdf_gaussian_P(val_ - GetMean(dim_), GetStDev(dim_));
}
Esempio n. 2
0
//circle equation |(x,y)-(a,b)|^2 = c^2
//f(a,b,c) = x^2+y^2-2ax-2yb+a^2+b^2-c^2 = 0
//let u=-2a, v=-2b, w = a^2+b^2-c^2
//f(u,v,w) = x^2+y^2+ux+vy+w
//min g(u,v,w) = 1/2 sum_(x,y) f(u,v,w)^2
//dg/du = sum_(x,y) df/du(u,v,w) f(u,v,w)
//      = sum_(x,y) x f(u,v,w)
//dg/dv = sum_(x,y) y f(u,v,w)
//dg/dw = sum_(x,y) f(u,v,w)
//dg/dparams = [sum x^2, sum xy,  sum x] *params + [sum x(x^2+y^2)] = 0
//             [sum xy,  sum y^2, sum y]           [sum y(x^2+y^2)]
//             [sum x,   sum y,   sum 1]           [sum (x^2+y^2) ]
//least squares fit
//A = matrix of (x,y,1)
//b = matrix of (x^2+y^2)
bool FitCircle(const std::vector<Vector2>& pts,Circle2D& c)
{
  Vector2 mean=GetMean(pts);
  Matrix3 A(Zero);
  Vector3 b(Zero);
  for(size_t i=0;i<pts.size();i++) {
    Vector3 v(pts[i].x-mean.x,pts[i].y-mean.x,1.0);
    Rank1Update(A,v,v);
    Real n = pts[i].distanceSquared(mean);
    b.x += (pts[i].x-mean.x)*n;
    b.y += (pts[i].y-mean.x)*n;
    b.z += n;
  }
  Matrix3 Ainv;
  if(!Ainv.setInverse(A)) return false;
  Vector3 params = Ainv*b;
  //recover circle from params
  c.center.x = -params.x*0.5;
  c.center.y = -params.y*0.5;
  c.radius = c.center.normSquared()-params.z;
  if(c.radius < 0) return false;
  c.radius = Sqrt(c.radius);
  c.center += mean;
  return true;
}
Esempio n. 3
0
void DataSignal :: WriteSmartPeakInfoToXML (RGTextOutput& text, const RGString& indent, const RGString& bracketTag, const RGString& locationTag) {

	int peak;
	Endl endLine;
	RGString suffix;
	
//	if (HasCrossChannelSignalLink ()) {

		if (HasAlleleName () && (!mDoNotCall)) {

			peak = (int) floor (Peak () + 0.5);

			if (mOffGrid)
				suffix = " OL";

			text << indent << "<" << bracketTag << ">" << endLine;
			text << indent << "\t<mean>" << GetMean () << "</mean>" << endLine;
			text << indent << "\t<height>" << peak << "</height>" << endLine;
			text << indent << "\t<BPS>" << GetBioID () << "</BPS>" << endLine;
//			text << indent << "\t<" << locationTag << ">" << (int) floor (GetApproximateBioID () + 0.5) << "</" << locationTag << ">" << endLine;
			text << indent << "\t<" << locationTag << ">" << GetApproximateBioID () << "</" << locationTag << ">" << endLine;
			text << indent << "\t<PeakArea>" << TheoreticalArea () << "</PeakArea>" << endLine;
			text << indent << "\t<allele>" << GetAlleleName () << suffix << "</allele>" << endLine;
			text << indent << "\t<width>" << 4.0 * GetStandardDeviation () << "</width>" << endLine;
			text << indent << "\t<fit>" << GetCurveFit () << "</fit>" << endLine;
			text << indent << "</" + bracketTag << ">" << endLine;
		}
//	}
}
Esempio n. 4
0
bool DataSignal :: ReportSmartNoticeObjects (RGTextOutput& text, const RGString& indent, const RGString& delim) {

	if (NumberOfSmartNoticeObjects () > 0) {

		int msgLevel = GetHighestMessageLevelWithRestrictionSM ();
		RGDListIterator it (*mSmartMessageReporters);
		SmartMessageReporter* nextNotice;
		text.SetOutputLevel (msgLevel);

		if (!text.TestCurrentLevel ()) {

			text.ResetOutputLevel ();
			return false;
		}

		Endl endLine;
		text << endLine;
		text << indent << "Notices for curve with (Mean, Sigma, Peak, 2Content, Fit) = " << delim << delim << delim << delim << delim << delim;
		text << GetMean () << delim << GetStandardDeviation () << delim << Peak () << delim << GetScale (2) << delim << Fit << endLine;

		while (nextNotice = (SmartMessageReporter*) it ())
			text << indent << nextNotice->GetMessage () << nextNotice->GetMessageData () << endLine;

		text.ResetOutputLevel ();
		text.Write (1, "\n");
	}

	else
		return false;

	return true;
}
Esempio n. 5
0
void GetCovariance(const vector<Vector3>& pts,Matrix3& C)
{
  C.setZero();
  Vector3 mean=GetMean(pts);
  for(size_t i=0;i<pts.size();i++) {
    Vector3 p = pts[i]-mean;
    Rank1Update(C,p,p);
  }
}
Esempio n. 6
0
//******************************************************************************
// Main
//******************************************************************************
int main(int argc, char **argv) {
    args::ArgumentParser parser("Checks if images are different within a tolerance.\n"
                                "Intended for use with library tests.\n"
                                "http://github.com/spinicist/QUIT");
    args::HelpFlag       help(parser, "HELP", "Show this help message", {'h', "help"});
    args::Flag           verbose(parser, "VERBOSE", "Print more information", {'v', "verbose"});
    args::ValueFlag<std::string> input_path(parser, "INPUT", "Input file for difference",
                                            {"input"});
    args::ValueFlag<std::string> baseline_path(parser, "BASELINE", "Baseline file for difference",
                                               {"baseline"});
    args::ValueFlag<double> tolerance(parser, "TOLERANCE", "Tolerance (mean percent difference)",
                                      {"tolerance"}, 0);
    args::ValueFlag<double> noise(parser, "NOISE",
                                  "Added noise level, tolerance is relative to this", {"noise"}, 0);
    args::Flag              absolute(parser, "ABSOLUTE",
                        "Use absolute difference, not relative (avoids 0/0 problems)",
                        {'a', "abs"});
    QI::ParseArgs(parser, argc, argv, verbose);
    auto input    = QI::ReadImage(QI::CheckValue(input_path), verbose);
    auto baseline = QI::ReadImage(QI::CheckValue(baseline_path), verbose);

    auto diff = itk::SubtractImageFilter<QI::VolumeF>::New();
    diff->SetInput1(input);
    diff->SetInput2(baseline);

    auto sqr_norm = itk::SquareImageFilter<QI::VolumeF, QI::VolumeF>::New();
    if (absolute) {
        sqr_norm->SetInput(diff->GetOutput());
    } else {
        auto diff_norm = itk::DivideImageFilter<QI::VolumeF, QI::VolumeF, QI::VolumeF>::New();
        diff_norm->SetInput1(diff->GetOutput());
        diff_norm->SetInput2(baseline);
        diff_norm->Update();
        sqr_norm->SetInput(diff_norm->GetOutput());
    }
    auto stats = itk::StatisticsImageFilter<QI::VolumeF>::New();
    stats->SetInput(sqr_norm->GetOutput());
    stats->Update();

    const double mean_sqr_diff      = stats->GetMean();
    const double root_mean_sqr_diff = sqrt(mean_sqr_diff);
    const double rel_diff =
        (noise.Get() > 0) ? root_mean_sqr_diff / noise.Get() : root_mean_sqr_diff;
    const bool passed = rel_diff <= tolerance.Get();
    QI::Log(verbose, "Mean Square Diff: {}\nRelative noise: {}\nSquare-root mean square diff: {}\nRelative Diff: {}\nTolerance: {}\nResult: ", mean_sqr_diff
    ,noise.Get()
                                         , root_mean_sqr_diff
                                         , rel_diff
                                         , tolerance.Get()
                                         , (passed ? "Passed" : "Failed"));
    if (passed) {
        return EXIT_SUCCESS;
    } else {
        return EXIT_FAILURE;
    }
}
float VarianceAccumulator<T>::GetNStdDev(T value)
{
    T variance = GetVariance();
    T mean = GetMean();
    if (variance > 0) {
        return std::fabs(value - mean) / (std::sqrt(variance));
    } else {
        return 0;
    }
}
Esempio n. 8
0
void CSamplePeak::FixAmel(int nStart, int nEnd)
{
  int nMean = GetMean();
  if( (nMean >= nStart) &&
      (nMean <= nEnd) )
  {
    wxString s(m_sAllele);
    s.Trim(true);
    s.Trim(false);
    if(s.Len() == 1)
    {
      m_sAllele.Replace("1","X");
      m_sAllele.Replace("2","Y");
    }
  }
}
Esempio n. 9
0
bool FitGaussian(const vector<Vector3>& pts,Vector3& mean,Matrix3& R,Vector3& axes)
{
  mean = GetMean(pts);
  Matrix A(pts.size(),3);
  for(size_t i=0;i<pts.size();i++) 
    (pts[i]-mean).get(A(i,0),A(i,1),A(i,2));
  SVDecomposition<Real> svd;
  if(!svd.set(A)) {
    return false;
  }

  svd.sortSVs();
  axes.set(svd.W(0),svd.W(1),svd.W(2));
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      R(i,j) = svd.V(i,j);
  return true;
}
Esempio n. 10
0
bool FitLine(const vector<Vector3>& pts,Line3D& l)
{
  Vector3 mean = GetMean(pts);
  Matrix A(pts.size(),3);
  for(size_t i=0;i<pts.size();i++) 
    (pts[i]-mean).get(A(i,0),A(i,1),A(i,2));
  SVDecomposition<Real> svd;
  if(!svd.set(A)) {
    return false;
  }

  svd.sortSVs();
  //take the first singular value
  Vector sv;
  svd.V.getColRef(0,sv);
  l.direction.set(sv(0),sv(1),sv(2));
  l.direction.inplaceNormalize();
  l.source = mean;
  return true;
}
Esempio n. 11
0
bool FitPlane(const vector<Vector3>& pts,Plane3D& p)
{
  Vector3 mean = GetMean(pts);
  Matrix A(pts.size(),3);
  for(size_t i=0;i<pts.size();i++) 
    (pts[i]-mean).get(A(i,0),A(i,1),A(i,2));
  SVDecomposition<Real> svd;
  if(!svd.set(A)) {
    return false;
  }

  svd.sortSVs();
  //take the last singular value
  Vector sv;
  svd.V.getColRef(2,sv);
  p.normal.set(sv(0),sv(1),sv(2));
  p.normal.inplaceNormalize();
  p.offset = dot(p.normal,mean);
  return true;
}
Esempio n. 12
0
/* smooth and normalize the input pitch vector */
void SProcessQuery(float* fPitchArray,int& Len){
	int i;
	float MeanVal;
	
    for (i=1;i<Len-1;i++){
		if (fPitchArray[i-1]<2 && fPitchArray[i]>2 && fPitchArray[i+1]<2)
			fPitchArray[i]=0;
	}
	
	int nCountFrm=0;
	for (i=0;i<Len-5;i++){
		if (i%5==0){
			fPitchArray[i/5]=GetMean(fPitchArray+i,5);	
			nCountFrm++;
		}
	}
	
	Len=nCountFrm;    

	float LastVal=0.0;
	for (i=1;i<Len-1;i++){
		if (fPitchArray[i-1]<2 && fabs(fPitchArray[i]-LastVal)>0.3*LastVal && fPitchArray[i+1]<2)
			fPitchArray[i]=0;

		if (fPitchArray[i]>2)
			LastVal=fPitchArray[i];		
	}

	/* remove the silence frame*/
	float temppitch=0;
 	int vadCount=0;
	int nStartTag=0;
	int nStart=0;
	for (i=0;i<Len;i++){ 
		if(nStartTag==0){
			if(fPitchArray[i]<2)
				nStart=i;
			else
				nStartTag=1;	
		}

		if (fPitchArray[i]>2){
			fPitchArray[i]=(float)(log10(fPitchArray[i])/log10(2.0f));
			if(i>3)
				temppitch=GetMean(fPitchArray+i-3,3);
			else
	            temppitch=fPitchArray[i]; 
             vadCount=0;
		}else{
 			vadCount++;
			if (temppitch>0)
				fPitchArray[i]=temppitch;
		}
	}
		
	for(i=0;i<Len-nStart-1;i++){
		fPitchArray[i]=fPitchArray[i+nStart+1];
	}
	Len-=(nStart+1);

	MeanVal=0;
	int VadSize=0;
	for (i=0;i<Len;i++){
         if (fPitchArray[i]>6.3){
			 MeanVal+=fPitchArray[i];
			 VadSize++;
		 }
	}
	
	float me=0.0f;
	if(VadSize<1){
		Len=0;
		return ;
	}
	else
		me=MeanVal/VadSize;

	for (i=0; i<Len; i++){
		fPitchArray[i]=fPitchArray[i]-me+PITCH_NORMALIZE_VALUE;
		if (fPitchArray[i]>8)
			fPitchArray[i]=fPitchArray[i]-1;  
		if (fPitchArray[i]<6.35)
			fPitchArray[i]=fPitchArray[i]+1;
	}
}
Esempio n. 13
0
void findtruthPbPb(int binMin, int binMax)
{
  TFile *fmc = new TFile(config.getFileName_djt("mcPbbfa"));

  buildNamesuffix = TString::Format("_bin_%d_%d",binMin, binMax);
  //  buildTitlesuffix = TString::Format("%d-%d %%",binMin/2, binMax/2);

  seth(10,0,1);
  auto hmcPbPbxJTrue = geth("hmcPbPbxJTrue","PbPb true;x_{J};Event fractions");
  auto hmcPbPbxJTrueTag = geth("hmcPbPbxJTrueTag","PbPb true tagged;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorr = geth("hmcPbPbxJTrueTagCorr","PbPb true tagged corrected;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrPt = geth("hmcPbPbxJTrueTagCorrPt","PbPb true tagged corrected pt;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrEta = geth("hmcPbPbxJTrueTagCorrEta","PbPb true tagged corrected eta;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrBin = geth("hmcPbPbxJTrueTagCorrBin","PbPb true tagged corrected bin;x_{J};Event fractions");

  seth(12,20,140);//10,40,100);
  auto hpt2true = geth("hpt2true","true;p_{T,2} GeV");
  auto hpt2truetag = geth("hpt2truetag","true tagged;p_{T,2} GeV");
  auto hpt2truetagovertrue = geth("hpt2truetagovertrue","true tagged/true;p_{T,2} GeV");
  auto hpt2truetagcorr = geth("hpt2truetagcorr","true tagged corrected;p_{T,2} GeV");
  auto hpt2truetagcorrovertrue = geth("hpt2truetagcorrovertrue","true tagged corrected/true;p_{T,2} GeV");

  seth(10,100,200);
  auto hpt1true = geth("hpt1true","true;p_{T,1} GeV");
  auto hpt1truetag = geth("hpt1truetag","true tagged;p_{T,1} GeV");
  auto hpt1truetagovertrue = geth("hpt1truetagovertrue","true tagged/true;p_{T,1} GeV");
  auto hpt1truetagcorr = geth("hpt1truetagcorr","true tagged corrected;p_{T,1} GeV");
  auto hpt1truetagcorrovertrue = geth("hpt1truetagcorrovertrue","true tagged corrected/true;p_{T,1} GeV");

  seth(10,0,200);
  auto hbintrue = geth("hbintrue","true;bin");
  auto hbintruetag = geth("hbintruetag","true tagged;bin");
  auto hbintruetagovertrue = geth("hbintruetagovertrue","true tagged/true;bin");
  auto hbintruetagcorr = geth("hbintruetagcorr","true tagged corrected;bin");
  auto hbintruetagcorrovertrue = geth("hbintruetagcorrovertrue","true tagged corrected/true;bin");

  seth(20,-2,2);
  auto heta2true = geth("heta2true","true;#eta_{2}");
  auto heta2truetag = geth("heta2truetag","true tagged;#eta_{2}");
  auto heta2truetagovertrue = geth("heta2truetagovertrue","true tagged/true;#eta_{2}");
  auto heta2truetagcorr = geth("heta2truetagcorr","true tagged corrected;#eta_{2}");
  auto heta2truetagcorrovertrue = geth("heta2truetagcorrovertrue","true tagged corrected/true;#eta_{2}");

  auto heta1true = geth("heta1true","true;#eta_{1}");
  auto heta1truetag = geth("heta1truetag","true tagged;#eta_{1}");
  auto heta1truetagovertrue = geth("heta1truetagovertrue","true tagged/true;#eta_{1}");
  auto heta1truetagcorr = geth("heta1truetagcorr","true tagged corrected;#eta_{1}");
  auto heta1truetagcorrovertrue = geth("heta1truetagcorrovertrue","true tagged corrected/true;#eta_{1}");

  unordered_set<int> eventstodiscard = {1805770,1116573,1084397};//,
                                        // 5755734,1599758,395810,
                                      // 1363321,211625,3195128};
//

  Fill(fmc,[&] (dict &m) {
    if (m["bin"]<binMin || m["bin"]>=binMax) return;
    if (m["pthat"]<pthatcut) return;
    if (m[pairCodeSB1]!=0) return;

    // if (m["bProdCode"]>1) return;

    if (eventstodiscard.find(m["event"])!=eventstodiscard.end()) return; //kill large-weight GSP event

    float w = m["weight"]*processweight((int)m["bProdCode"]); //because we have only b-dijets


    float corr = tageffcorrectionPbPb(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB],m["bin"]);
    // float corrpt  = getPbPbcorrectionPt(m["jtpt1"],m[jtptSB]);
    // float correta = getPbPbcorrectionEta(m["jteta1"],m[jtetaSB]);
    // float corrbin = getPbPbcorrectionBin(m["bin"]);


    float wb = w*corr;



   if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[refptSB]>20 && m[dphiSB1]>PI23) {
      hmcPbPbxJTrue->Fill(m[jtptSB]/m["jtpt1"],w);
      hpt2true->Fill(m[jtptSB],w);
      hpt1true->Fill(m["jtpt1"],w);
      heta2true->Fill(m[jtetaSB],w);
      heta1true->Fill(m["jteta1"],w);
      hbintrue->Fill(m["bin"],w);
   }

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[refptSB]>20 && m[dphiSB1]>PI23
        && m["discr_csvV1_1"]>0.9 &&  m[discr_csvV1_SB]>0.9) { //

     //corrpt *= m[jtptSB] < 60 ? 1./0.7 : 1;
     //wb *= m[jtptSB] < 60 ? 1./0.7 : 1;

      hmcPbPbxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w);
      hmcPbPbxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb);
      // hmcPbPbxJTrueTagCorrPt->Fill(m[jtptSB]/m["jtpt1"],w*corrpt);
      // hmcPbPbxJTrueTagCorrEta->Fill(m[jtptSB]/m["jtpt1"],w*corrpt*correta);
      // hmcPbPbxJTrueTagCorrBin->Fill(m[jtptSB]/m["jtpt1"],w*corrpt*correta*corrbin);


      hpt2truetag->Fill(m[jtptSB],w);
      hpt1truetag->Fill(m["jtpt1"],w);
      heta2truetag->Fill(m[jtetaSB],w);
      heta1truetag->Fill(m["jteta1"],w);
      hbintruetag->Fill(m["bin"],w);

      hpt2truetagcorr->Fill(m[jtptSB],wb);
      hpt1truetagcorr->Fill(m["jtpt1"],wb);
      heta2truetagcorr->Fill(m[jtetaSB],wb);
      heta1truetagcorr->Fill(m["jteta1"],wb);
      hbintruetagcorr->Fill(m["bin"],wb);

    }






  });

  NormalizeAllHists();
//plotymax = 9999;
  aktstring = TString::Format("PbPb %d-%d %%",binMin/2, binMax/2);//TString::Format("PbPb#Delta#phi>2/3#pi %d-%d %%",binMin/2, binMax/2);

  SetMC({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});
  SetData({hmcPbPbxJTrue});
  hmcPbPbxJTrue->SetMinimum(0);
  hmcPbPbxJTrue->SetMaximum(0.3);
  hmcPbPbxJTrue->SetLineWidth(2);
  hmcPbPbxJTrue->SetMarkerStyle(kNone);
  hmcPbPbxJTrue->SetFillStyle(0);

  hmcPbPbxJTrueTag->SetMarkerStyle(kOpenCircle);
  hmcPbPbxJTrueTagCorr->SetMarkerStyle(kOpenSquare);


  plotymax = 0.3;
  Draw({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});

  SetB({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});

  float xjtrue = hmcPbPbxJTrue->GetMean();
  float xjtruetag = hmcPbPbxJTrueTag->GetMean();
  float xjtruetagcorr = hmcPbPbxJTrueTagCorr->GetMean();

  float exjtrue = hmcPbPbxJTrue->GetMeanError();
  float exjtruetag = hmcPbPbxJTrueTag->GetMeanError();
  float exjtruetagcorr = hmcPbPbxJTrueTagCorr->GetMeanError();

  auto c = getc();
  hmcPbPbxJTrue->Draw("hist");
  hmcPbPbxJTrueTag->Draw("E1,same");
  hmcPbPbxJTrueTagCorr->Draw("E1,same");

  plotlegendpos = TopLeft;
  auto l = getLegend();
  l->AddEntry(hmcPbPbxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L");
  l->AddEntry(hmcPbPbxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P");
  l->AddEntry(hmcPbPbxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P");
  l->Draw();
  TLatex *Tl = new TLatex();
  Tl->DrawLatexNDC(0.2, 0.8, aktstring);
  SavePlot(c,Form("closure%d%d",binMin,binMax));


    // //if (binMin==0 && binMax==200) {

    // Draw({hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorrPt,hmcPbPbxJTrueTagCorrEta,hmcPbPbxJTrueTagCorrBin});
 

    // SetMC({hpt2truetag,hpt1truetag,heta2truetag,heta1truetag,hbintruetag});

    // plotputmean = false;

    // plotymax = 0.2;

    // Draw({hpt2true,hpt2truetag,hpt2truetagcorr});

    // plotymax = 0.3;

    // Draw({hpt1true,hpt1truetag,hpt1truetagcorr});

    // plotymax = 0.2;
    // Draw({heta2true,heta2truetag,heta2truetagcorr});
    // Draw({heta1true,heta1truetag,heta1truetagcorr});

    // plotymax = 1;
    // Draw({hbintrue,hbintruetag,hbintruetagcorr});


plotymin = 0;
plotymax = 0.2;

Draw({hpt2truetag,hpt2true});
Draw({hpt2truetagcorr,hpt2true});
hpt2truetagovertrue->Divide(hpt2truetag,hpt2true,1,1); //"B"
hpt1truetagovertrue->Divide(hpt1truetag,hpt1true,1,1); //"B"
heta2truetagovertrue->Divide(heta2truetag,heta2true,1,1); //"B"
heta1truetagovertrue->Divide(heta1truetag,heta1true,1,1); //"B"
hbintruetagovertrue->Divide(hbintruetag,hbintrue,1,1); //"B"


hpt2truetagcorrovertrue->Divide(hpt2truetagcorr,hpt2true,1,1); //"B"
hpt1truetagcorrovertrue->Divide(hpt1truetagcorr,hpt1true,1,1); //"B"
heta2truetagcorrovertrue->Divide(heta2truetagcorr,heta2true,1,1); //"B"
heta1truetagcorrovertrue->Divide(heta1truetagcorr,heta1true,1,1); //"B"
hbintruetagcorrovertrue->Divide(hbintruetagcorr,hbintrue,1,1); //"B"

 NormalizeAllHists();

Draw({hpt2truetagovertrue,hpt2truetagcorrovertrue});
Draw({hpt1truetagovertrue,hpt1truetagcorrovertrue});
Draw({heta2truetagovertrue,heta2truetagcorrovertrue});
Draw({heta1truetagovertrue,heta1truetagcorrovertrue});
Draw({hbintruetagovertrue,hbintruetagcorrovertrue});



 // }

}
Esempio n. 14
0
mitk::Quaternion mitk::NavigationDataEvaluationFilter::GetQuaternionMean(int input)
{
return GetMean(m_LoggedQuaternions[input]);
}
T VarianceAccumulator<T>::
GetVariance() {
    return (1.0*sumSqVal)/nSamples -  GetMean()*GetMean();
}
Esempio n. 16
0
void findtruthpp()
{
  seth(10,0,1);
  auto hmcppxJTrue = geth("hmcppxJTrue","true;x_{J};Event fractions");
  auto hmcppxJTrueTag = geth("hmcppxJTrueTag","true tagged;x_{J};Event fractions");
  auto hmcppxJTrueTagCorr = geth("hmcppxJTrueTagCorr","true tagged corrected;x_{J};Event fractions");

  TFile *fmcpp = new TFile(config.getFileName_djt("mcppbfa"));
  Fill(fmcpp,[&] (dict &m) {
    if (m["pthat"]<pthatcut) return;
    if (m[pairCodeSB1]!=0) return;
    // if (m["pthat"]<80) return;
    
    // if (m["bProdCode"]!=1) return;
    float w = m["weight"]*processweight((int)m["bProdCode"]);

    // float w = m["weight"];
    // if (m["bProdCode"]==2) return;

    float corr = tageffcorrectionpp(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB]);
    float wb = w*corr;

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23)
      hmcppxJTrue->Fill(m[jtptSB]/m["jtpt1"],w);

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23
        && m["discr_csvV1_1"]>0.9 && m[discr_csvV1_SB]>0.9) {
      hmcppxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w);
      hmcppxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb);
    }


  });

  NormalizeAllHists();
  plotputmean = true;
  plotytitle = "Event fractions";
  plotdivide = false;
  // aktstring += "R=0.4 |#eta|<2.0";
  // plotsecondline = Form("p_{T,1}>%d GeV, p_{T,2}>%d GeV", (int)pt1cut, (int)pt2cut);
  // plotthirdline = "#Delta#phi>2/3#pi";
  plottextposy = 0.8;
  plottextposx = 0.2;

  plotmeanposy = 0.43;
  plotymax = 0.2;
  plotymin = 0;
  plotlegendpos = BottomRight;//TopLeft;
  
  aktstring = "pp";
  SetMC({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});
  SetData({hmcppxJTrue});
  Draw({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});


  hmcppxJTrue->SetMinimum(0);
  hmcppxJTrue->SetMaximum(0.3);
  hmcppxJTrue->SetLineWidth(2);
  hmcppxJTrue->SetMarkerStyle(kNone);
  hmcppxJTrue->SetFillStyle(0);

  hmcppxJTrueTag->SetMarkerStyle(kOpenCircle);
  hmcppxJTrueTagCorr->SetMarkerStyle(kOpenSquare);


  plotymax = 0.3;

  SetB({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});


  float xjtrue = hmcppxJTrue->GetMean();
  float xjtruetag = hmcppxJTrueTag->GetMean();
  float xjtruetagcorr = hmcppxJTrueTagCorr->GetMean();

  float exjtrue = hmcppxJTrue->GetMeanError();
  float exjtruetag = hmcppxJTrueTag->GetMeanError();
  float exjtruetagcorr = hmcppxJTrueTagCorr->GetMeanError();

  auto c = getc();
  hmcppxJTrue->Draw("hist");
  hmcppxJTrueTag->Draw("E1,same");
  hmcppxJTrueTagCorr->Draw("E1,same");

  plotlegendpos = TopLeft;
  auto l = getLegend();
  l->AddEntry(hmcppxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L");
  l->AddEntry(hmcppxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P");
  l->AddEntry(hmcppxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P");
  l->Draw();
  TLatex *Tl = new TLatex();
  Tl->DrawLatexNDC(0.2, 0.8, aktstring);
  SavePlot(c,"closurepp");
}
Esempio n. 17
0
File: svmrbf.cpp Progetto: infnty/ys
    // Transforms each nominal feature into one of more real features,
    // imputes missing values, scales data.
    static vector< vector<double> > PreprocessFeatures(const IDataSet *data) {
        vector<int> offsets(1, 0);
        for (int j = 0; j < data->GetFeatureCount(); j++) {
            FeatureInfo info = data->GetMetaData().GetFeatureInfo(j);
            assert(info.Type == Numeric || info.Type == Nominal);
            int expansion = (info.Type == Nominal && info.NominalValues.size() >= 3) ? info.NominalValues.size() : 1;
            offsets.push_back(offsets.back() + expansion);
        }

        vector< vector<double> > nonmissing_values(data->GetFeatureCount());
        for (int i = 0; i < data->GetObjectCount(); i++) {
            for (int j = 0; j < data->GetFeatureCount(); j++) {
                if (data->HasFeature(i, j)) {
                    double feature = data->GetFeature(i, j);
                    nonmissing_values[j].push_back(feature);
                }
            }
        }

        vector<double> imputed_value(data->GetFeatureCount(), 0.0);
        for (int j = 0; j < data->GetFeatureCount(); j++) {
            FeatureInfo info = data->GetMetaData().GetFeatureInfo(j);

            if (nonmissing_values[j].size() == 0) {
                imputed_value[j] = 0;
                continue;
            }

            sort(nonmissing_values[j].begin(), nonmissing_values[j].end());

            if (info.Type == Nominal && info.NominalValues.size() >= 3) {
                imputed_value[j] = GetMode(nonmissing_values[j]);
            } else if (info.Type == Nominal) {
                imputed_value[j] = 0;
            } else {
                imputed_value[j] = GetMean(nonmissing_values[j]);
            }
        }

        vector< vector<double> > result(data->GetObjectCount(), vector<double>(offsets.back(), 0.0));
        for (int i = 0; i < data->GetObjectCount(); ++i) {
            for (int j = 0; j < data->GetFeatureCount(); ++j) {
                FeatureInfo info = data->GetMetaData().GetFeatureInfo(j);
                double feature = data->HasFeature(i, j) ? data->GetFeature(i, j) : imputed_value[j];

                if (info.Type == Nominal && info.NominalValues.size() >= 3) {
                    int val = (int)feature;
                    assert(0 <= val && val < info.NominalValues.size());
                    result[i][offsets[j] + val] = 1;
                } else if (info.Type == Nominal) {
                    // binary
                    if (!data->HasFeature(i, j))
                        result[i][offsets[j]] = 0;
                    else if (fabs(feature) < 0.5)
                        result[i][offsets[j]] = -1.0;
                    else
                        result[i][offsets[j]] = 1.0;
                } else {
                    // real
                    if (nonmissing_values[j].size() != 0) {
                        // scale to [-1, 1]
                        double fmin = nonmissing_values[j][0];
                        double fmax = nonmissing_values[j].back();
                        if (fmax > fmin)
                            feature = (feature - fmin) / (fmax - fmin);
                        else
                            feature = 0;
                    }
                    result[i][offsets[j]] = feature;
                }
            }
        }

        return result;
    }
Esempio n. 18
0
void derivefromNS(bool data = false)
{
  // float shift = mode == 2 ? -2 : mode*2; //mode = 0,1,2 shift = 0,2,-2
  // cout<<"shift = "<<shift<<endl;

  auto file = config.getfile_djt(data ? "dtPbjcl" : "mcPbqcd");
  auto nt = (TTree *)file->Get("nt");

  for (unsigned i=1;i<binbounds.size();i++) {
    int b1 = binbounds[i-1];
    int b2 = binbounds[i];
    seth(71,38,180); //71,38
    auto h = geth(Form("h%d%d",b1,b2)); //allowing one more bin for overflow
    seth(b2-b1,b1,b2);
    auto hb = geth(Form("hb%d%d",b1,b2));

   
    TString mcappendix = data ? "" : "&& pthat>50";//"&& subid2!=0 && pthat>50"; //"&& pthat>50";//"&& !(subid2==0 && refpt2>20) && pthat>50"; //"&& pthat>80";//
   
    //Form("jtpt2+%f",shift)
    nt->Project(h->GetName(),"jtpt2", Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphi21<1.05 %s)",b1,b2,mcappendix.Data()));
    nt->Project(hb->GetName(),"bin", Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphi21<1.05 %s)",b1,b2,mcappendix.Data()));

    ScaleVisibleBins(h,NSfrac[i-1]);

    h->SetBinContent(1,h->GetBinContent(0)+h->GetBinContent(1));

    // auto p = new TProfile(Form("p%d%d",b1,b2),Form("prof"),71,38,180);
    // nt->Project(p->GetName(),"(subid2 == 0 && refpt2 > 20):jtptSignal2",Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphiSignal21<1.05 && !(subid2==0 && refpt2>20) && pthat>80)",b1,b2));


    auto g = getCDFgraph(h);
    g->GetXaxis()->SetTitle("p_{T,2} threshold [GeV]");
    g->GetYaxis()->SetTitle("found fraction");

    auto gtemp = getCDFgraph(h);
    meanb.push_back(hb->GetMean());
    prob.push_back(gtemp->Eval(pt));

    float c0=g->Eval(50);
    cout<<"prob at 50: "<<c0<<endl;

    auto gf = new TFile("graph.root","recreate");
    gtemp->Write();
    gf->Close();

    // auto f = new TF1(Form("f%d%d",b1,b2),"1-[0]*exp(-[1]*(x-40))",40,180);
    // f->SetParameters(0.1,0.1);
    // // f->FixParameter(1,0.08);

    // auto f = new TF1(Form("f%d%d",b1,b2),"TMath::Erf((x-[0])/[1])",40,180);
    // f->SetParameters(40,10);
    // f->FixParameter(1,25);

    auto f = new TF1(Form("f%d%d",b1,b2),"exp(-[0]*exp(-[1]*x))",40,180);
    f->SetParameters(100,0.1);
    // f->FixParameter(1,0.11); //!!!!!!!!!!

    f->SetLineColor(kRed);
    f->SetLineWidth(2);
    g->Fit(f,"RM");
    fs.push_back(f);
    binmean.push_back(hb->GetMean());

    float median = -1/f->GetParameter(1)*log(-1/f->GetParameter(0)*log(0.5));

    Draw({h});

    // h->Rebin(2);
    auto gcoarse = getCDFgraph(h);

    auto c = getc();
          TLatex *Tl = new TLatex();
    gcoarse->SetMinimum(0);g->SetMaximum(1);
    gcoarse->Draw("AP");
    f->Draw("same");
    Tl->DrawLatexNDC(0.6,0.55,"y=e^{-a e^{-b x} }");
    Tl->DrawLatexNDC(0.6,0.50,Form("a = %.1f",f->GetParameter(0)));
    Tl->DrawLatexNDC(0.6,0.45,Form("b = %.2f",f->GetParameter(1)));
    Tl->DrawLatexNDC(0.6,0.4,Form("PbPb bin %d-%d",b1,b2));
    Tl->DrawLatexNDC(0.6,0.35,Form("median = %.2f",median));

    TLine *l1 = new TLine(median,0,median, f->Eval(median));
    l1->Draw();
    TLine *l2 = new TLine(0,0.5,median, f->Eval(median));
    l2->Draw();

    // p->SetMarkerColor(kRed);
    // p->SetMarkerSize(1);
    // p->Draw("same");
    SavePlot(c,Form("fit%d%d",b1,b2));//return;
  }

}
void drawMakeCorrelationSummariesTimePlots(){

  gStyle->SetOptStat("mre");

  // TFile* f = TFile::Open("makeCorrelationSummariesTimePlots_352_2016-02-26_18-02-20.root");
  auto corTree = new TChain("corTree");
  corTree->Add("makeCorrelationSummariesTimePlots/*.root");
  // TTree* corTree = (TTree*) f->Get("corTree");
  cout << corTree << endl;

  auto cc = new CrossCorrelator();
  auto h = new TH1D("h", "", 128, -2, 2);

  // Book histogram and set x, y axis labels to antenna names
  TString name = "h2";
  TString polLetter = "H";
  // TString polLetter = pol == AnitaPol::kHorizontal ? "H" : "V";  
  // name += polLetter;
  // name += TString::Format("%u", eventNumber[pol]);

  TString title = TString::Format("Mean #deltat_{measured} - #deltat_{expected} for all used antenna pairs; Antenna 1; Antenna 2; Mean #Delta#deltat (ns)");
  
  int binShift = 0;
  // title += pol==AnitaPol::kHorizontal ? "HPOL" : "VPOL";
  // title += "; ; ; Correlation coefficient";
  TH2D* h2 = new TH2D(name, title, NUM_SEAVEYS, 0, NUM_SEAVEYS, NUM_SEAVEYS, 0, NUM_SEAVEYS);
  for(int ant=0; ant<NUM_SEAVEYS; ant++){
    TString lab = TString::Format("%d", 1 + (ant/NUM_RING));
    if(ant%NUM_RING==0){
      lab += "T"+polLetter;
    }
    else if((ant%NUM_RING)==1){
      lab += "M"+polLetter;
    }
    else{
      lab += "B"+polLetter;
    }
    int binInd = ant + binShift;
    // binInd = binInd < 0 ? binInd + NUM_SEAVEYS : binInd;
    binInd = binInd >= NUM_SEAVEYS ? binInd - NUM_SEAVEYS : binInd;    
    h2->GetXaxis()->SetBinLabel(binInd+1, lab.Data());
    h2->GetYaxis()->SetBinLabel(binInd+1, lab.Data());
  }

  std::vector<TH1D*> hs;
  for(int combo=0; combo < NUM_COMBOS; combo++){

    int ant1 = cc->comboToAnt1s.at(combo);
    int ant2 = cc->comboToAnt2s.at(combo);

    auto command = TString::Format("deltaTMeasured[%d]-deltaTExpected[%d]>>h", combo, combo);
    auto cuts = TString::Format("deltaTMeasured[%d]>-999 && TMath::Abs(deltaTMeasured[%d]-deltaTExpected[%d]) < 0.7", combo, combo, combo);
    // cout << command << "\t" << cuts << endl;

    corTree->Draw(command, cuts, "goff");
    
    std::cout << ant1 << "\t" << ant2<< "\t" << h->GetMean() << std::endl;

    // auto h3 = ((TH1D*)h->Clone());
    // h3->SetTitle(TString::Format("antennas %d and %d; #Delta#deltat (ns); Events / bin", ant1, ant2));

    // hs.push_back(h3);

    Int_t phi1 = ant1%NUM_PHI;
    Int_t phi2 = ant2%NUM_PHI;

    Int_t ring1 = ant1/NUM_PHI;
    Int_t ring2 = ant2/NUM_PHI;

    Int_t theBinX = phi1*NUM_RING + ring1 + 1;
    Int_t theBinY = phi2*NUM_RING + ring2 + 1;

    theBinX += binShift;
    theBinY += binShift;

    theBinX = theBinX >= NUM_SEAVEYS ? theBinX - NUM_SEAVEYS : theBinX;
    theBinY = theBinY >= NUM_SEAVEYS ? theBinY - NUM_SEAVEYS : theBinY;
      
    h2->SetBinContent(theBinX, theBinY, h->GetMean());
    h2->SetBinContent(theBinY, theBinX, h->GetMean());          
    
    // if(combo >= 5){
    //   break;
    // }
  }
  
  // TCanvas* c1 = RootTools::drawArrayOfHistosPrettily(&hs[0], (Int_t) hs.size());
  // TCanvas* c2 = RootTools::drawHistsWithStatsBoxes((Int_t) hs.size(), &hs[0],
  // 						   "", "mre");
  // TLegend* l = c2->BuildLegend();
  // hs[0]->SetTitle("#deltat_{measured} - #deltat_{expected} for a selection of antenna pairs; #Delta#deltat (ns); Events / bin");
  
  auto c3 = new TCanvas();
  h2->Draw("colz");
}
Esempio n. 20
0
void DataSignal :: WriteSmartArtifactInfoToXML (RGTextOutput& text, const RGString& indent, const RGString& bracketTag, const RGString& locationTag) {

	int peak;
	Endl endLine;
	RGString suffix;
	RGString label;
	SmartMessageReporter* notice;
	int i;
	RGString virtualAllele;
	int reportedMessageLevel;

	reportedMessageLevel = GetHighestMessageLevelWithRestrictionSM ();
	bool thisIsFirstNotice = true;

	if ((!DontLook ()) && (NumberOfSmartNoticeObjects () != 0)) {
	
		peak = (int) floor (Peak () + 0.5);

		if (mOffGrid)
			suffix = " OL";

		virtualAllele = GetVirtualAlleleName ();

		RGDListIterator it (*mSmartMessageReporters);
		i = 0;

		while (notice = (SmartMessageReporter*) it ()) {

			if (!notice->GetDisplayOsirisInfo ())
				continue;

			if (thisIsFirstNotice) {

				text << indent << "<" << bracketTag << ">" << endLine;
				text << indent << "\t<level>" << reportedMessageLevel << "</level>" << endLine;
				text << indent << "\t<mean>" << GetMean () << "</mean>" << endLine;
				text << indent << "\t<height>" << peak << "</height>" << endLine;
//				text << indent << "\t<" << locationTag << ">" << (int) floor (GetApproximateBioID () + 0.5) << "</" << locationTag << ">" << endLine;
				text << indent << "\t<" << locationTag << ">" << GetApproximateBioID () << "</" << locationTag << ">" << endLine;
				text << indent << "\t<PeakArea>" << TheoreticalArea () << "</PeakArea>" << endLine;

				if (virtualAllele.Length () > 0)
					text << indent << "\t<equivAllele>" << virtualAllele << suffix << "</equivAllele>" << endLine;

				text << indent << "\t<width>" << 4.0 * GetStandardDeviation () << "</width>" << endLine;
				text << indent << "\t<fit>" << GetCurveFit () << "</fit>" << endLine;
				label = indent + "\t<label>";
				thisIsFirstNotice = false;
			}

			if (i > 0)
				label << "&#10;";

			label += notice->GetMessage ();
			label += notice->GetMessageData ();
			i++;
		}

		RGString temp = GetVirtualAlleleName () + suffix;

		if (temp.Length () > 0) {

			if (i > 0)
				label << "&#10;";

			label += "Allele " + temp;
		}

		if (i > 0) {

			label << "</label>";
			text << label << endLine;
			text << indent << "</" + bracketTag << ">" << endLine;
		}

		/*if ((signalLink != NULL) && (!signalLink->xmlArtifactInfoWritten)) {

			signalLink->xmlArtifactInfoWritten = true;
			peak = signalLink->height;

			text << indent << "<" << bracketTag << ">" << endLine;
			text << indent << "\t<mean>" << signalLink->mean << "</mean>" << endLine;
			text << indent << "\t<height>" << peak << "</height>" << endLine;
			text << indent << "\t<" << locationTag << ">" << signalLink->bioID << "</" << locationTag << ">" << endLine;
			text << indent << "\t<fit>" << GetCurveFit () << "</fit>" << endLine;
			label = indent + "\t<label>";
			mNoticeObjectIterator.Reset ();
			i = 0;

			while (notice = (Notice*) mNoticeObjectIterator ()) {

				if (i > 0)
					label << "&#10;";

				label += notice->GetLabel ();
				i++;
			}

			if (temp.Length () > 0) {

				if (i > 0)
					label << "&#10;";

				label += "Allele " + temp;
			}

			label << "</label>";
			text << label << endLine;
			text << indent << "</" + bracketTag << ">" << endLine;
		}*/
	}
}
Esempio n. 21
0
void DataSignal :: WriteSmartTableArtifactInfoToXML (RGTextOutput& text, RGTextOutput& tempText, const RGString& indent, const RGString& bracketTag, const RGString& locationTag) {

	int peak;
	Endl endLine;
	RGString suffix;
	RGString label;
	SmartMessageReporter* notice;
	int i;
	RGString virtualAllele;
	SmartMessageReporter* nextNotice;
	text.SetOutputLevel (1);
	int msgNum;

	smAcceptedOLLeft acceptedOLLeft;
	smAcceptedOLRight acceptedOLRight;

	int reportedMessageLevel = GetHighestMessageLevelWithRestrictionSM ();
	//bool hasThreeLoci;
	//bool needLocus0;

	if ((!DontLook ()) && (NumberOfSmartNoticeObjects () != 0)) {
	
		bool firstNotice = true;
		peak = (int) floor (Peak () + 0.5);
		virtualAllele = GetVirtualAlleleName ();

		text << indent << "<" << bracketTag << ">" << endLine;  // Should be <Artifact>
		text << indent << "\t<Id>" << GetSignalID () << "</Id>" << endLine;
		text << indent << "\t<Level>" << reportedMessageLevel << "</Level>" << endLine;
		text << indent << "\t<RFU>" << peak << "</RFU>" << endLine;
		text << indent << "\t<" << locationTag << ">" << GetApproximateBioID () << "</" << locationTag << ">" << endLine;
		text << indent << "\t<PeakArea>" << TheoreticalArea () << "</PeakArea>" << endLine;
		text << indent << "\t<Time>" << GetMean () << "</Time>" << endLine;
		text << indent << "\t<Fit>" << GetCurveFit () << "</Fit>" << endLine;

		if (!mAllowPeakEdit)
			text << indent << "\t<AllowPeakEdit>false</AllowPeakEdit>" << endLine;
		
		RGDListIterator it (*mSmartMessageReporters);
		i = 0;

		while (notice = (SmartMessageReporter*) it ()) {

			if (!notice->GetDisplayOsirisInfo ())
				continue;

			if (firstNotice) {

				label = indent + "\t<Label>";
				firstNotice = false;
			}

			if (i > 0)
				label << "&#10;";

			label += notice->GetMessage ();
			label += notice->GetMessageData ();
			i++;
		}

		if (i > 0) {

			label << "</Label>";
			text << label << endLine;
		}

		// Now add list of notices...

		it.Reset ();

		while (nextNotice = (SmartMessageReporter*) it ()) {

			msgNum = Notice::GetNextMessageNumber ();
			nextNotice->SetMessageCount (msgNum);
			text << indent << "\t<MessageNumber>" << msgNum << "</MessageNumber>" << endLine;
			tempText << "\t\t<Message>\n";
			tempText << "\t\t\t<MessageNumber>" << msgNum << "</MessageNumber>\n";
			tempText << "\t\t\t<Text>" << nextNotice->GetMessage () << nextNotice->GetMessageData () << "</Text>\n";

			if (nextNotice->HasViableExportInfo ()) {

				if (nextNotice->IsEnabled ())
					tempText << "\t\t\t<Hidden>false</Hidden>\n";

				else
					tempText << "\t\t\t<Hidden>true</Hidden>\n";

				if (!nextNotice->IsCritical ())
					tempText << "\t\t\t<Critical>false</Critical>\n";

				if (nextNotice->IsEnabled ())
					tempText << "\t\t\t<Enabled>true</Enabled>\n";

				else
					tempText << "\t\t\t<Enabled>false</Enabled>\n";

				if (!nextNotice->IsEditable ())
					tempText << "\t\t\t<Editable>false</Editable>\n";

				if (nextNotice->GetDisplayExportInfo ())
					tempText << "\t\t\t<DisplayExportInfo>true</DisplayExportInfo>\n";

				else
					tempText << "\t\t\t<DisplayExportInfo>false</DisplayExportInfo>\n";

				if (!nextNotice->GetDisplayOsirisInfo ())
					tempText << "\t\t\t<DisplayOsirisInfo>false</DisplayOsirisInfo>\n";

				tempText << "\t\t\t<MsgName>" << nextNotice->GetMessageName () << "</MsgName>\n";

				//tempText << "\t\t\t<ExportProtocolList>";
				//tempText << "\t\t\t" << nextNotice->GetExportProtocolInformation ();
				//tempText << "\t\t\t</ExportProtocolList>\n";
			}

			tempText << "\t\t</Message>\n";
		}

		// Now add list of alleles

		//hasThreeLoci = (mLocus != NULL) && (mLeftLocus != NULL) && (mRightLocus != NULL);

		//if (mLocus != NULL) {

		//	if ((mLeftLocus == NULL) && (mRightLocus == NULL))
		//		needLocus0 = true;

		//	else
		//		needLocus0 = false;
		//}

		//else
		//	needLocus0 = false;

		//needLocus0 = (!hasThreeLoci) && ((mLocus != mLeftLocus) || (mLocus != mRightLocus));

		if (mLocus != NULL) {

			//testing
			RGString locusName = mLocus->GetLocusName ();
			suffix = GetAlleleName (0);

			if ((suffix.Length () > 0) || (virtualAllele.Length () > 0)) {

				text << indent << "\t<Allele>" << endLine;

				if (suffix.Length () > 0)
					text << indent << "\t\t<Name>" << suffix << "</Name>" << endLine;

				else
					text << indent << "\t\t<Name>" << virtualAllele << "</Name>" << endLine;

				if (mOffGrid)
					suffix = "true";

				else if (mAcceptedOffGrid)
					suffix = "accepted";

				else
					suffix = "false";

				text << indent << "\t\t<OffLadder>" << suffix << "</OffLadder>" << endLine;
				text << indent << "\t\t<BPS>" << GetBioID (0) << "</BPS>" << endLine;
				text << indent << "\t\t<Locus>" << mLocus->GetLocusName () << "</Locus>" << endLine;
				text << indent << "\t\t<Location>0</Location>" << endLine;
				text << indent << "\t</Allele>" << endLine;
			}
		}

		if ((mLeftLocus != NULL) && (mLeftLocus != mLocus)) {

			if (mAlleleNameLeft.Length () > 0) {

				text << indent << "\t<Allele>" << endLine;
				text << indent << "\t\t<Name>" << mAlleleNameLeft << "</Name>" << endLine;

				if (mIsOffGridLeft)
					suffix = "true";

				else if (GetMessageValue (acceptedOLLeft))
					suffix = "accepted";

				else
					suffix = "false";

				text << indent << "\t\t<OffLadder>" << suffix << "</OffLadder>" << endLine;
				text << indent << "\t\t<BPS>" << GetBioID (-1) << "</BPS>" << endLine;
				text << indent << "\t\t<Locus>" << mLeftLocus->GetLocusName () << "</Locus>" << endLine;
				text << indent << "\t\t<Location>-1</Location>" << endLine;
				text << indent << "\t</Allele>" << endLine;
			}
		}

		if ((mRightLocus != NULL) && (mRightLocus != mLocus)) {

			if (mAlleleNameRight.Length () > 0) {

				text << indent << "\t<Allele>" << endLine;
				text << indent << "\t\t<Name>" << mAlleleNameRight << "</Name>" << endLine;

				if (mIsOffGridRight)
					suffix = "true";

				else if (GetMessageValue (acceptedOLRight))
					suffix = "accepted";

				else
					suffix = "false";

				text << indent << "\t\t<OffLadder>" << suffix << "</OffLadder>" << endLine;
				text << indent << "\t\t<BPS>" << GetBioID (1) << "</BPS>" << endLine;
				text << indent << "\t\t<Locus>" << mRightLocus->GetLocusName () << "</Locus>" << endLine;
				text << indent << "\t\t<Location>1</Location>" << endLine;
				text << indent << "\t</Allele>" << endLine;
			}
		}

		text << indent << "</" + bracketTag << ">" << endLine;
	}

	text.ResetOutputLevel ();
}
Esempio n. 22
0
void zScan(){

   double sf = 1.; 
   double ppm = 1E-6; 
   double ppb = 1E-9; 

   int units = 0;    // 0 = ppm, 1 = ppb 
   TString Units = "ND"; 

   if(units==0){
      sf = ppm;
      Units = Form("ppm"); 
   }else if(units==1){
      sf = ppb;
      Units = Form("ppb"); 
   }

   TString prefix = Form("./probe/");
   TString inpath = prefix + Form("probe-1.dat");

   // double r = 5; 
   // TString inpath = Form("./probe/probe-1_r-%.0f-cm.dat",r);

   vector<double> x,y,z,th,B,dB;
   vector<double> z1,z2,z3,z4; 
   vector<double> b1,b2,b3,b4; 
   vector<double> db1,db2,db3,db4; 
   vector<double> BR,dBR; 

   ImportScanData(inpath,z,B,dB); 
   // ImportScanDataAlt(inpath,x,y,z,th,B,dB); 

   double mean_b = GetMean(B); 
   double arg=0,err=0;

   cout << "B AVG = " << Form("%.15lf",mean_b) << endl;

   int TH=0; 

   FieldData myData; 
   TTree *myTree = new TTree("T","Field Data");
   myTree->Branch("field",&myData.x,"x/D:y/D:z/D:phi/D:B/D:dB/D:B_rel/D:dB_rel/D");

   const int N = z.size();
   for(int i=0;i<N;i++){
      // TH = (int)th[i]; 
      arg = (B[i]-mean_b)/mean_b/sf;
      err = dB[i]/mean_b/sf;
      // if(TH==0){
      //    z1.push_back(z[i]); 
      //    b1.push_back(arg);
      //    db1.push_back(err);
      // }else if(TH==90){
      //    z2.push_back(z[i]); 
      //    b2.push_back(arg);
      //    db2.push_back(err);
      // }else if(TH==180){ 
      //    z3.push_back(z[i]); 
      //    b3.push_back(arg);
      //    db3.push_back(err);
      // }else if(TH==270){
      //    z4.push_back(z[i]); 
      //    b4.push_back(arg);
      //    db4.push_back(err);
      // } 
      cout // << Form("%10.3f",x[i])  << "\t" 
           // << Form("%10.3f",y[i])  << "\t" 
           << Form("%10.3f",z[i])  << "\t" 
           // << Form("%10.3f",th[i]) << "\t" 
           << Form("%10.3f",arg )  << "\t" 
           << Form("%10.3f",err )  << endl;
      // myData.x      = x[i];  
      // myData.y      = y[i];  
      // myData.z      = z[i];  
      // myData.B_rel  = arg;  
      // myData.dB_rel = err; 
      // myTree->Fill();  
      BR.push_back(arg); 
      dBR.push_back(err); 
   } 

   TGraphErrors *g = GetTGraphErrors(z,BR,dBR);
   SetGraphParameters(g,20,kBlack);

   double MarkerSize = 1.5; 

   // TGraphErrors *g1 = GetTGraphErrors(z1,b1,db1);
   // SetGraphParameters(g1,20,kBlack);
   // g1->SetMarkerSize(MarkerSize); 

   // TGraphErrors *g2 = GetTGraphErrors(z2,b2,db2);
   // SetGraphParameters(g2,21,kBlue);
   // g2->SetMarkerSize(MarkerSize); 

   // TGraphErrors *g3 = GetTGraphErrors(z3,b3,db3);
   // SetGraphParameters(g3,22,kRed);
   // g3->SetMarkerSize(MarkerSize); 

   // TGraphErrors *g4 = GetTGraphErrors(z4,b4,db4);
   // SetGraphParameters(g4,23,kMagenta);
   // g4->SetMarkerSize(MarkerSize); 

   // TLegend *L = new TLegend(0.6,0.6,0.8,0.8); 
   // L->SetFillStyle(0); 
   // L->AddEntry(g1,"#theta = 0#circ"  ,"p"); 
   // L->AddEntry(g2,"#theta = 90#circ" ,"p"); 
   // L->AddEntry(g3,"#theta = 180#circ","p"); 
   // L->AddEntry(g4,"#theta = 270#circ","p"); 

   // TMultiGraph *mg = new TMultiGraph(); 
   // mg->Add(g1,"p"); 
   // mg->Add(g2,"p"); 
   // mg->Add(g3,"p"); 
   // mg->Add(g4,"p"); 

   double xMin = -350; 
   double xMax =  350; 
   // double yMin = -2;  
   // double yMax =  2;  

   TLine *xAxisLine  = new TLine(xMin,0,xMax,0); 
   TLine *xAxisLine2 = new TLine(-150,0, 150,0); 

   TString Title      = Form("Magnetic Field Map Along z Axis (x = 0, y = 0) ");
   // TString Title2     = Form("Magnetic Field Map (r = %.0f cm)",r);
   TString xAxisTitle = Form("z (mm)");
   TString yAxisTitle = Form("B (%s)",Units.Data());

   TCanvas *c1 = new TCanvas("c1","z Scan (1)",1200,800);
   c1->SetFillColor(kWhite); 
   c1->cd();

   gStyle->SetOptFit(111); 
   g->Draw("ap");
   g->SetTitle(Title); 
   g->GetXaxis()->SetTitle(xAxisTitle);
   g->GetXaxis()->CenterTitle();
   g->GetYaxis()->SetTitle(yAxisTitle);
   g->GetYaxis()->CenterTitle(); 
   g->GetXaxis()->SetLimits(xMin,xMax);  
   g->Draw("ap");
   xAxisLine->Draw("same"); 
   c1->Update(); 

   // TCanvas *c2 = new TCanvas("c2","z Scan (2)",1200,800);
   // c2->SetFillColor(kWhite); 
   // c2->cd();

   // gStyle->SetOptFit(111); 
   // mg->Draw("a");
   // mg->SetTitle(Title2); 
   // mg->GetXaxis()->SetTitle("z (mm)");
   // mg->GetXaxis()->CenterTitle();
   // mg->GetYaxis()->SetTitle(yAxisTitle);
   // mg->GetYaxis()->CenterTitle(); 
   // mg->GetXaxis()->SetLimits(-150,150);  
   // mg->GetYaxis()->SetRangeUser(yMin,yMax);
   // mg->Draw("a");
   // xAxisLine2->Draw("same");
   // L->Draw("same");  
   // c2->Update(); 

   // myTree->SetMarkerStyle(20);
   // myTree->SetMarkerSize(1.6);

   // TCanvas *c3 = new TCanvas("c3","3D Field Map",1200,800);
   // c3->SetFillColor(kWhite);

   // c3->cd();
   // myTree->Draw("y:x:z:B_rel","","colz");
   // c3->Update();

}