예제 #1
0
// draw the next waveform that we find associated with an event
void DrawNext(void)
{
  static Int_t evno=0;

  if (tree == nullptr) {
    tree = (TTree*)gROOT->FindObject("FragmentTree");
  }
  tree->SetBranchAddress("TFragment", &frag);
  
  do {
    tree->GetEntry(evno++);
  } while (frag->wavebuffer.empty());
  
  cout<<"Event number "<<evno<<endl;
  frag->Print();

  //printf("wavebuffer.size() = %i\n",wavebuffer.size()); 
  TH1 *his = makeHisto(frag->wavebuffer);
  TChannel *chan = TChannel::GetChannel(frag->ChannelAddress);

  // if(chan && (strncmp(chan->GetChannelName(),"DSC",3)==0))
  //    TH1 *his = makeDescantHisto(frag->wavebuffer);
  if(chan)
  	 his->SetTitle(chan->GetChannelName());
  his->Draw();
}
예제 #2
0
파일: rcp.cpp 프로젝트: jdbrice/rcpMaker
void rcp( string en, int c, int p, string cpf = "/Users/danielbrandenburg/bnl/local/work/rcpMaker/products/presentation/11GeV/data.root" ){


	TCanvas * cc = new TCanvas( "c1", "c2", 250, 250 );

	gStyle->SetOptStat( 0 );
	
	vector<double> c6 = readSpectra( c, p, 0, 1, en );
	vector<double> c6e = readSpectraE1( c, p, 0, 1, en );

	TH1D * hc6 = makeHisto( "cen6", c6, c6e );

	vector<double> c0 = readSpectra( c, p, 8, 8, en );
	vector<double> c0e = readSpectraE1( c, p, 8, 8, en );
	TH1D * hc0 = makeHisto( "cen0", c0, c0e );

	hc0->Scale( 19.0 );
	hc6->Scale( 784.0 );

	hc0->Divide( hc6 );

	hc0->SetTitle( (plcName( p ) + " : " + hCharge( c )).c_str()  );
	hc0->GetYaxis()->SetRangeUser( 0.1, 5 );
	hc0->GetXaxis()->SetRangeUser( 0.0, 4 );
	hc0->SetMarkerStyle( 20 );
	hc0->SetMarkerColor( kBlue );
	hc0->Draw();
	gPad->SetLogy(1);	

	string name = "rcp_" + plcName( p ) + "_" + charge( c ) + "_0_Over_6";
	TFile * f = new TFile( cpf.c_str(), "READ" );

	TH1D * crcp = (TH1D*)f->Get( ("rcp/"+name).c_str() );
	crcp->SetMarkerStyle( 22 );
	crcp->SetMarkerColor( kRed );
	crcp->Scale( 1.08 );
	crcp->Draw( "same" );

	cc->SetGrid(1, 1);

	cc->Print( (name + ".pdf").c_str());



}
예제 #3
0
void singleSpectra( int c, int p, int cl, int ch, string en ) {


	vector<double> vals = readSpectra( c, p, cl, ch, en );
	vector<double> errors = readSpectraE1( c, p, cl, ch, en );

	TH1D * h = makeHisto( plcName( p ) + "_" + charge(c) + "_" + ts(cl) + "_" + ts(ch), vals, errors );

}
예제 #4
0
int main (int argc, char *argv[])
{
	FILE 	*inAFile, *inBFile, *inMaskFile;
	FILE	*outAFile, *outBFile;
	uint16_t   	bufA[BUFF_SIZE];
	uint16_t 	bufB[BUFF_SIZE];
	uint16_t	bufMask[BUFF_SIZE];
	int 	histoA[DSP_RANGE];
	int 	histoB[DSP_RANGE];
	int 	maskedHistoA[DSP_RANGE];
	int 	maskedHistoB[DSP_RANGE]; //negative of A mask
	int 	count = 0;
	int 	maxA = 0;
	int 	maxB = 0;
	int 	maskedMaxA = 0;
	int 	maskedMaxB = 0;
	int 	minA = 60000;
	int 	minB = 60000;
	int 	maskedMinA = 60000;
	int 	maskedMinB = 60000;
	int 	blackPointA = 0;
	int 	blackPointB = 0;
	int 	whitePointA = 0;
	int 	whitePointB = 0;
	int 	clippedBlackA = 0;
	int 	clippedWhiteA = 0;
	int 	clippedBlackB = 0;
	int 	clippedWhiteB = 0;
	float 	averageA = 0;
	float 	maskedAverageA = 0;
	float 	maskedAverageB = 0;
	float 	stdDevA = 0;
	float 	maskedStdDevA = 0;
	float 	maskedStdDevB = 0;
	float 	averageB = 0;
	float 	stdDevB = 0;
	int	offsetA = OFFSET_A;
	int	offsetB = OFFSET_B;
	int 	maskedOffsetA = MASKED_OFFSET_A;
	int 	maskedOffsetB = MASKED_OFFSET_B;
	float	sigmaA = SIGMA_A;
	float	sigmaB = SIGMA_B;
	float	maskedSigmaA = MASKED_SIGMA_A;
	float	maskedSigmaB = MASKED_SIGMA_B;


	if (argc != 4)	{
		printf("\nError: need infile and outfile");
		exit(1);
	}
	
	outAFile = fopen("outA.dat", "w");
	if (outAFile == 0) {
		printf("\nError: could not open shit");
		exit (1);
	}
	outBFile = fopen("outB.dat", "w");
	if (outBFile == 0) {
		printf("\nError: could not open shit");
		exit (1);
	}
	//inAFile = fopen("rawB.dat", "r");

	inAFile = fopen(argv[1], "r");
	if (inAFile == 0)	{
		printf("\nError: could not open inAfile");
		exit(1);
	}
printf("\n opening the file");	
	
	inBFile = fopen(argv[2], "r");
	if (inBFile == 0)	{
		printf("\nError: could not open inBfile");
		exit(1);
	}
	
//printf("\n opening the last file");	
	inMaskFile = fopen(argv[3], "r");
//printf("\n opened it ");	

	if (inMaskFile == 0)	{
		printf("\nError: could not open outfile");
		exit(1);
	}
	printf("\ngot the right arguments all files opened");
	

//	int k = 0;
	//while ((count = fillBuff(bufA, inAFile)) == fillBuff(bufB, inBFile) &&
	//		(count == fillBuff(bufMask, inMaskFile)) &&
	//	       count != 0)
///////////////////////////////////////////////////dddddddddddddddddddd

printf("\nstarting hard shit");
	clearHisto(histoA);
	clearHisto(histoB);
	clearHisto(maskedHistoA);
	clearHisto(maskedHistoB);
	while (((count = fillBuff(bufA, inAFile))  != 0 ) &&
			(fillBuff(bufMask, inMaskFile) != 0))
	//while ((count = fillBuff(bufA, inAFile)) == fillBuff(bufB, inBFile) &&
	//		(count == fillBuff(bufMask, inMaskFile)) &&
	//	       count != 0)
	{	
		makeHisto (bufA, histoA, &maxA, &minA);
		makeMaskedHisto(bufA, bufMask, 
				maskedHistoA, &maskedMaxA, &maskedMinA);

			
	}
	rewind(inMaskFile);
	while (((count = fillBuff(bufB, inBFile))  != 0 ) &&
			(fillBuff(bufMask, inMaskFile) != 0))
	//while ((count = fillBuff(bufA, inAFile)) == fillBuff(bufB, inBFile) &&
	//		(count == fillBuff(bufMask, inMaskFile)) &&
	//	       count != 0)
	{	
		makeHisto (bufB, histoB, &maxB, &minB);
		negateMask(bufMask); //mask fire
		makeMaskedHisto(bufB, bufMask, 
				maskedHistoB, &maskedMaxB, &maskedMinB);
		//makeHisto (bufB, histoB, &maxB, &minB);
		//printf("\nread = %d", bufA[2]);
		//printf("\n maxA = %d, minA = %d", maxA, minA);
		//makeHisto (bufB, histoB, &maxB, &minB);
		//makeMaskedHisto(bufA, bufMask, maskedHistoA, &maxA, &minA);
		//makeMaskedHisto(bufB, bufMask, maskedHistoB, &maxB, &minB);
	
	}
	count = 0;
	int i;
	for (i=0;i<DSP_RANGE;i++)
		count += histoA[i];
	printf("\nread %d pixels", count);
	averageA = averageHisto(histoA);
	maskedAverageA = averageHisto(maskedHistoA);
	maskedAverageB = averageHisto(maskedHistoB);
	averageB = averageHisto(histoB);
	stdDevA = stdDev(histoA, averageA);
	maskedStdDevA = stdDev(maskedHistoA, maskedAverageA);
	maskedStdDevB = stdDev(maskedHistoB, maskedAverageB);
	stdDevB = stdDev(histoB, averageB);
	printf("\nmaxA = %d minA = %d", maxA, minA);
	printf("\naverage A = %f", averageA);
	printf("\nstddev A = %f, sigmaA = %f, offsetA = %d",
		       	stdDevA, sigmaA, offsetA);
	printf("\nmaskedmaxA = %d maskedminA = %d", maskedMaxA, maskedMinA);
	printf("\nmasked average A = %f", maskedAverageA);
	printf("\nsmasked tddev A = %f, masked sigma = %f, masked offset = %d",
		       	maskedStdDevA,	maskedSigmaA, maskedOffsetA);
	printf("\nmaxB = %d minB = %d", maxB, minB);
	printf("\naverage B = %f", averageB);
	printf("\nstddev B = %f, sigmab = %f, offsetb = %d",
		       	stdDevB, sigmaB, offsetB);
	printf("\nmaskedmaxB = %d maskedminB = %d", maskedMaxB, maskedMinB);
	printf("\nmasked average B = %f", maskedAverageB);
	printf("\nsmasked tddev B = %f, masked sigma = %f, masked offset = %d",
		       	maskedStdDevB,	maskedSigmaB, maskedOffsetB);
//	buildLUT(histoA, averageA, stdDevA, offsetA, sigmaA);
	buildLUT(maskedHistoA, maskedAverageA, maskedStdDevA,
		       	maskedOffsetA, maskedSigmaA);
	//buildLUT(histoB, averageB, stdDevB, offsetB, sigmaB);
	buildLUT(maskedHistoB, maskedAverageB, maskedStdDevB,
		       	maskedOffsetB, maskedSigmaB);
	averageA = averageHisto(histoA);
	maskedAverageA = averageHisto(maskedHistoA);
	averageB = averageHisto(histoB);
	maskedAverageB = averageHisto(maskedHistoB);
	printf("\naverage A pixel value = %f", averageA);
	printf("\nmasked average A pixel value = %f", maskedAverageA);
	printf("\naverage B pixel value = %f", averageB);
//	printf("\nblackpoint A = %d, whitepoint A = %d", blackPointA,
		       					//whitePointA);	
	//stretch the data
	rewind(inAFile);
	rewind(inBFile);
//	rewind(inMaskFile);
	while (((count = fillBuff(bufA, inAFile)) != 0 ) &&
		(fillBuff(bufB, inBFile) !=0))
	{	
		//contrastStretch(bufA, histoA,&clippedBlackA,
		//	       &clippedWhiteA,	outAFile);
		contrastStretch(bufA, maskedHistoA,&clippedBlackA,
			       &clippedWhiteA,	outAFile);
		contrastStretch(bufB, maskedHistoB,&clippedBlackB,
			       &clippedWhiteB,	outBFile);
	}
		printf("\nContrast stretch complete");
	printf("\nclippedblackA %d, clippedwhiteA %d",
			clippedBlackA, clippedWhiteA);
	printf("\nclippedblackB %d, clippedwhiteB %d",
			clippedBlackB, clippedWhiteB);
/*
	fclose(inAFile);
	fclose(inBFile);
	fclose(outAFile);
	*/
	return 0;
}