Example #1
0
void listEvents(){
	Recon recon;
	//TFile f(Form("%s/cal.root",RDKANAL));
	//CalibrationList *list=(CalibrationList*)f.Get("CalibrationList");
	TString path=Form("%s/calibration/TCfit_511keV_calibration_21Feb11.dat",RDKANAL);
	CalibrationList *list=new CalibrationList(path);
	TreeReader reader;
	reader.reset(kTRUE);
	//NData ndata=reader.openList(Form("%s/runlist.csv",RDKANAL));
	NData ndata=reader.openSeries(256,"S");
	//NData ndata=reader.openSeries(TreeReader::n1400,TreeReader::all1400,"S");
	logNdat(ndata);
	ofstream log(Form("%s/eventLists/list.csv",RDKANAL));
	log<<"Series,Run,EventNum,PeakHeight,Energy,DeltaTime"<<endl;
	Int_t series=0,run=0,evnt=0;
	for(Long64_t i=0;i<reader.tree->GetEntries();i++){
		if(i%10000==0){
			cout<<i<<endl;
		}
		reader.tree->GetEntry(i);
		//if(series==reader.entry.nseries && run==reader.entry.nrun){
		//	reader.entry.nevent=++evnt;
		//}else{
		//	series=reader.entry.nseries;
		//	run=reader.entry.nrun;
		//	evnt=0;
		//}
		recon=list->calibrate(reader.entry,reader.recon);
		Int_t delta_t=recon.t_gamma[CH]-recon.t_e-PEAK;
		if(recon.E_gamma[CH]>=MIN && recon.E_gamma[CH]<=MAX && recon.t_p-recon.t_e<650
			&& delta_t>-ONPEAK && delta_t<=ONPEAK && recon.E_e<30000 && recon.E_p>300 && recon.E_p<1000){
			log<<reader.entry.nseries<<","<<reader.entry.nrun<<","<<reader.entry.nevent<<",";
			log<<reader.recon.E_gamma[CH]<<","<<recon.E_gamma[CH]<<",";
			log<<(recon.t_gamma[CH]-recon.t_e)<<endl;
		}
	}
	log.close();
	delete list;
	//f.close();
	gSystem->ChangeDirectory(WORKDIR);
}
Example #2
0
TTree* cudaFitTest(){
	//find/record test signals
	TreeReader reader;
	reader.openFile(258,0);
	int index[512],channel[512];
	float energy[512],time[512];
	int i=0,j=0;
	while(i<512 && j<reader.tree->GetEntries()){
		reader.tree->GetEntry(j);
		for(int k=0;k<11;k++){
			int t=reader.recon.t_gamma[CH[k]];
			float E=reader.recon.E_gamma[CH[k]];
			if(t>0 && t<NPOINTS && E>3000 && E<6000 && i<512){
				index[i]=j;
				channel[i]=CH[k];
				time[i]=t;
				energy[i]=E;
				i++;
			}
		}
		j++;
	}
	reader.reset();
	//copy signals to data;
	RawFileReader rawReader(258,0);
	Entry entry;
	RawData rdata;
	data=new float[512];
	i=0;
	rawReader.initialize();
	for(i=0;i<512;i++){
		data[i]=new float[2048];
		j=index[i];
		int k=channel[i];
		rawReader.seek(j);
		rawReader.readNext(entry,rdata);
		for(int x=0;x<2048;x++){
			data[i][x]=rdata.ch[k][x];
		}
	}
	rawReader.close();
	//fit
	fitter=new cudaFit(512);
	fitter->setData(data);
	float *initParam=new float[8];
	initParam[0]=100;
	initParam[1]=0;
	initParam[2]=15000;
	initParam[3]=1.1e-3;
	initParam[4]=1.3e-3;
	initParam[5]=625;
	initParam[6]=0;
	initParam[7]=0;
	fitter->fit(initParam,0);
	float **param=new float[512];
	for(i=0;i<512;i++){
		param[i]=new float[8];
	}
	float fitE[512],fitT[512];
	fitter->getParameters(param);
	for(int evnt=0;evnt<512;evnt++){
		fitE[evnt]=peakHeight(param[evnt]);
		fitT[evnt]=param[evnt][5];
	}
	//compare
	deltaT=new TH1F("deltaT","deltaT",250,-250,0);
	deltaE=new TH1F("deltaE","deltaE",200,0,2);
	paramB=new TH1F("paramB","paramB",500,10000,30000);
	for(int evnt=0;evnt<512;evnt++){
		deltaT->Fill(time[evnt]-fitT[evnt]);
		deltaE->Fill(fitE[evnt]/energy[evnt]);
		paramB->Fill(param[evnt][2]);
	}
	delete[] param;
	delete[] initParam;
}