Esempio n. 1
0
void asap::STPolLinear::rotateLinPolPhase( casa::Float phase )
{
//
// Rotate P = Q + iU but do it directly on the  linear
// correlations.
//
// We are using I=(XX+YY)/2 convention
// C1 = XX; C2 = YY, C3 = Real(XY)
//
  if (nspec() != 4) {
    throw(AipsError("You must have 4 linear polarizations to run this function"));
  }
  Vector<Float> I,Q,U;
  I = getStokes(0);
  Q = getStokes(1);
  U = getStokes(2);
  // Rotate Q & U (factor of 2 for polarization)
  Float cosVal = cos(C::pi/180.0*2.0*phase);
  Float sinVal = sin(C::pi/180.0*2.0*phase);
  Vector<Float> Q2 = Q*cosVal - U*sinVal;
  U =  Q*sinVal + U*cosVal;
  Q = Q2;
  Matrix<Float>& specs = getSpectra();
  specs.column(0) = (I+Q)/Float(2.0);
  specs.column(1) = (I-Q)/Float(2.0);
  specs.column(2) = U/Float(2.0);

}
Esempio n. 2
0
void asap::STPolLinear::invertPhase( Float phase )
{
  // phase isnt used, just ro keep interface the same for all pol operations
  (void) phase;
  if (nspec() != 4) {
    throw(AipsError("You must have 4 linear polarizations to run this function"));
  }
  Matrix<Float>& specs = getSpectra();
  Vector<Float> I = specs.column(3);
  I *= Float(-1.0);
}
TEST(DetectorSpectrumMapDataTest, read_detector_spectrum_map_spectra) {
  extern std::string testDataPath;
  auto detSpecMap =
      DetectorSpectrumMapData(testDataPath + "spectrum_gastubes_01.dat");
  EXPECT_EQ(245768, detSpecMap.getNumberOfEntries());

  auto spectra = detSpecMap.getSpectra();
  EXPECT_EQ(1, spectra[0]);
  EXPECT_EQ(9, spectra[8]);
  EXPECT_EQ(245768, spectra[245767]);
}
Esempio n. 4
0
void asap::STPolLinear::rotatePhase( Float phase )
{
  if (nspec() != 4) {
    throw(AipsError("You must have 4 linear polarizations to run this function"));
  }
  Float cosVal = cos(C::pi/180.0*phase);
  Float sinVal = sin(C::pi/180.0*phase);
  Matrix<Float>& specs = getSpectra();
  Vector<Float> R2 = specs.column(2)*cosVal - specs.column(3)*sinVal;
  specs.column(3) =  specs.column(2)*sinVal + specs.column(3)*cosVal;
  specs.column(2) = R2;
}
Esempio n. 5
0
/**
 * Reserve pulse list space for the expected number of pulses.
 *
 * Description:\n
 * 	Computes the expected number of pulses for the activity based
 * 	on # of frames, # of resolutions requested and pulse threshold,
 * 	then reserves space for that many pulses in the vector.\n\n
 * Notes:\n
 * 	This function will be a NOP except for the first time the
 * 	activity is used and when a longer activity length is specified.\n
 * 	It is important that the detector not have to reallocate vector
 * 	space during data collection where time is critical.
 */
void
Channel::allocPulseList(const DxActivityParameters& params)
{
	double totalBins = 0;
	for (int32_t i = 0; i < MAX_RESOLUTIONS; ++i) {
		if (params.requestPulseResolution[i] == SSE_TRUE)
			totalBins += getUsableBinsPerSpectrum((Resolution) i)
					* getSpectra((Resolution) i);
	}
	double threshold = params.pd[RES_1HZ].pulseThreshold;
	double pulses = totalBins * exp(-threshold);
	// two polarizations and a safety factor
	pulses *= 2 * PULSE_SAFETY_FACTOR;
	pulseList.reserve((int32_t) pulses);
}
TEST(DetectorSpectrumMapDataTest, create_message_buffer) {
  extern std::string testDataPath;
  auto detSpecMap =
      DetectorSpectrumMapData(testDataPath + "spectrum_gastubes_01.dat");

  std::string rawbuf;
  EXPECT_NO_THROW(detSpecMap.getBufferPointer(rawbuf));

  auto receivedMapData = DetectorSpectrumMapData();
  EXPECT_NO_THROW(receivedMapData.decodeMessage(
      reinterpret_cast<const uint8_t *>(rawbuf.c_str())));
  EXPECT_EQ(245768, receivedMapData.getNumberOfEntries());

  auto detectors = receivedMapData.getDetectors();
  EXPECT_EQ(1, detectors[0]);
  EXPECT_EQ(1100000, detectors[8]);
  EXPECT_EQ(4523511, detectors[245767]);

  auto spectra = receivedMapData.getSpectra();
  EXPECT_EQ(1, spectra[0]);
  EXPECT_EQ(9, spectra[8]);
  EXPECT_EQ(245768, spectra[245767]);
}
Esempio n. 7
0
TH1D* getFF_pp(double jetPt_low, double jetPt_high, const char* histTitle, int mode)
{
  TH1D * FF = new TH1D(histTitle,";p_{T trk};#frac{1}{N_{jet}} #frac{dN_{trk}}{dp_{t trk}}",trkBins ,yAxis);

  getSpectra(mode);

  //looping over bins in Trk pt
    for(int t = 1; t < trkBins+1; t++)
    {
      double sum   = 0;
      double error = 0;
      double norm  = 0;        

      //looping over jet pt
      for(int j = jet->FindBin(jetPt_low); j < jet->FindBin(jetPt_high); j++)
      {
        //reweighting factor to 5 TeV pPb
        //for (mode 2) 5TeV pPb jet_pPb = jet so this is by definition one
        double w = jet_pPb->GetBinContent(j)/jet->GetBinContent(j);

        //adding up contributions to the FF from each track and jet bin
        sum   += w*(trk->GetBinContent(j,t) - trkUE->GetBinContent(j,t));
        error += w*w*(TMath::Power(trk->GetBinError(j,t),2) + TMath::Power(trkUE->GetBinError(j,t),2));
        norm  += jet_pPb->GetBinContent(j);
      }

      if(norm!=0)
      {   
        sum   = sum/(norm*FF->GetBinWidth(t));
        error = TMath::Power(error,0.5)/(norm*FF->GetBinWidth(t));
        FF->SetBinContent(t,sum);
        FF->SetBinError(t,error);
      }
    }
  return FF;
}