本文整理汇总了C++中TSpectrum::SearchHighRes方法的典型用法代码示例。如果您正苦于以下问题:C++ TSpectrum::SearchHighRes方法的具体用法?C++ TSpectrum::SearchHighRes怎么用?C++ TSpectrum::SearchHighRes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSpectrum
的用法示例。
在下文中一共展示了TSpectrum::SearchHighRes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: laserCalibration
void laserCalibration(
char* filename = "frascatirun", //input file
int filenum = 1081, //file number
int channel = 3, //trace channel
int flagChannel = 5, //laser flag channel
Double_t entriesN = 10, //number of entries for prcessing
int sleep = 10, //sleep time between 2 processed entries, helpful for viewing traces
bool gui = true //enable or disable trace visualization
)
{
caen_5742 caen;
Int_t nbins = 1024;
Double_t entries = entriesN;
Int_t bin;
TCanvas *c1 = new TCanvas("c1","frascatirun",900,700);
c1->Divide(1,2);
c1->cd(1);
TGraph* g = new TGraph();
TH1F* lmPeaks = new TH1F("lm","Peaks Ratio", 1000, 0, 5000);
TH1F* d = new TH1F("d","",nbins,0,nbins);
TH1F* back = new TH1F("Back","",nbins,0,nbins);
// input file
char fname[100]=0;
sprintf(fname,"%s_0%i.root",filename,filenum);
TFile* infile = new TFile(fname);
TTree *t = (TTree*) infile->Get("t");
t->SetBranchAddress("caen_5742", &caen.system_clock);
t->Print();
if(entriesN<=0)
entries = t->GetEntries();
//out file
char foutname[100]=0;
int lm=0;
if (channel ==3)lm=1;
if (channel ==4)lm=2;
sprintf(foutname,"./calibration/LM%i_out_0%i.root",lm,filenum);
outfile = new TFile(foutname,"RECREATE");
outTree = new TTree("LM","frascatirun output");
calibTree = new TTree("LM_cal","frascatirun output");
outTree->Branch("LM_PX1",&fPositionX1,"PX1/D");
outTree->Branch("LM_PX2",&fPositionX2,"PX2/D");
outTree->Branch("LM_PY1",&fPositionY1,"PY1/D");
outTree->Branch("LM_PY2",&fPositionY2,"PY2/D");
//outTree->Branch("baseline",baseline,"baseline[1024]/F");
outTree->Branch("time",&timeline,"time/D");
outTree->Branch("LM_P2_Integral",&integralP2,"IP2/D");
calibTree->Branch("LM_P2_Integral_mean",&integralP2_mean,"IP2_mean/D");
calibTree->Branch("LM_P2_Integral_mean_error",&integralP2_mean_error,"IP2_mean_error/D");
calibTree->Branch("LM_P2_Integral_sigma",&integralP2_sigma,"IP2_sigma/D");
calibTree->Branch("LM_P2_Integral_sigma_error",&integralP2_sigma_error,"IP2_sigma_error/D");
/**************************************
* read entries
**************************************
*/
for (int j = 0; j < entries; ++j){
gSystem->Sleep (sleep);
t->GetEntry(j);
//TRIGGER SELECTION
if(caen.trace[flagChannel][400]>1000 && caen.trace[flagChannel][800]<3000){
timeline = caen.system_clock;
/**************************************
* Peaks estimation
**************************************
*/
for (int i = 0; i < nbins; ++i){
g->SetPoint(i, i, caen.trace[channel][i]);
}
Double_t y_max = TMath::MaxElement(g->GetN(),g->GetY());
Float_t * source = new Float_t[nbins];
Float_t * dest = new Float_t[nbins];
for (int i = 0; i < nbins; ++i){
source[i]=y_max-caen.trace[channel][i];
g->SetPoint(i, i, source[i]);
}
//Use TSpectrum to find the peak candidates
TSpectrum *s = new TSpectrum();
Int_t nfound = s->SearchHighRes(source, dest, nbins, 3, 2, kTRUE, 2, kFALSE, 5);
/**************************************
* Background estimation
**************************************
*/
Int_t ssize = nbins;
Int_t numberIterations = 20;
Int_t direction = s->kBackIncreasingWindow;
Int_t filterOrder = s->kBackOrder2;
bool smoothing = kFALSE;
//.........这里部分代码省略.........