国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

ROOT36: 波形分析代碼2

2023-08-29 12:39 作者:guanming-yf  | 我要投稿

#include "iostream"

using namespace std;

void ana2(){

? // 1. read the WFM.root file, and get data

? TFile *ifile = new TFile( "../root35/WFM.root", "read" );

? TTree *itree = (TTree*)ifile->Get( "WFM" );

? double timestamp =0.0;

? vector<double> *time = 0;

? vector<double> *channel1 = 0;

? vector<double> *channel2 = 0;

? itree->SetBranchAddress( "TimeStamp", &timestamp );

? itree->SetBranchAddress( "Time", &time );

? itree->SetBranchAddress( "Channel1", &channel1 );

? itree->SetBranchAddress( "Channel2", &channel2 );

??

? // 2. analyze the waveform and get some charateristic values, ex. timestamp, peakenergy, and flag

? // energy = peakheight *511 / 0.31 [keV]

? // time = 5*timeindex [ns]

? double TimeStamp;

? double PeakHeight1;

? double PeakEnergy1;

? double PeakHeight2;

? double PeakEnergy2;

? double PeakTime1;

? double PeakTime2;

? bool Flag_Coin;

? const int N = itree->GetEntries();

? TFile *ofile = new TFile( "WFM_Analysis.root", "recreate" );

? TTree *otree = new TTree( "WFM", "analyzed WFM" );

? otree->Branch( "TimeStamp", &TimeStamp, "TimeStamp/D" );

? otree->Branch( "PeakEnergy1", &PeakEnergy1, "PeakEnergy1/D" ?);

? otree->Branch( "PeakEnergy2", &PeakEnergy2, "PeakEnergy2/D" ?);

? otree->Branch( "PeakTime1", &PeakTime1, "PeakTime1/D" ?);

? otree->Branch( "PeakTime2", &PeakTime2, "PeakTime2/D" ?);

? otree->Branch( "Flag_Coin", &Flag_Coin, "Flag_Coin/O" );

? //3 . save the analyzed data into a new file WFM_analysis.root

? for( int j=0; j<N; j++ ){

? ? // j is the number-th of event

? ? cout << "Analyzing " << j << "-th event" <<"\r" << flush;

? ??

? ? itree->GetEntry(j);

? ? TimeStamp = timestamp;

? ? auto pk1 = std::min_element( channel1->begin(), channel1->end() );

? ? PeakHeight1 = *pk1;

? ? PeakEnergy1 = -PeakHeight1*(511/0.31);

? ? auto PeakIndex1 = std::distance( channel1->begin(), pk1 );

? ? PeakTime1 = 5*PeakIndex1;

? ? auto pk2 = std::min_element( channel2->begin(), channel2->end() );

? ? PeakHeight2 = *pk2;

? ? PeakEnergy2 = -PeakHeight2*(511/0.31);

? ? auto PeakIndex2 = std::distance( channel2->begin(), pk2 );

? ? PeakTime2 = 5*PeakIndex2;

? ? if( (450<PeakEnergy2&&PeakEnergy2<560)&&(400<PeakTime2&&PeakTime2<700) ){

? ? ? Flag_Coin = 1;

? ? }else{

? ? ? Flag_Coin = 0;

? ? }

? ??

? ? otree->Fill();

? }

? cout << endl;

? otree->Write();

? ofile->Close();

}


ROOT36: 波形分析代碼2的評論 (共 條)

分享到微博請遵守國家法律
乐都县| 大埔县| 崇阳县| 夏邑县| 乌审旗| 汪清县| 合阳县| 曲水县| 宝应县| 嘉祥县| 尚义县| 鹤岗市| 沁阳市| 永年县| 遵化市| 吉安市| 无极县| 嘉荫县| 东明县| 普安县| 栾城县| 陵川县| 蒲城县| 施秉县| 台山市| 五原县| 桃源县| 台江县| 措美县| 治多县| 洛阳市| 屏山县| 广德县| 正镶白旗| 合作市| 吴堡县| 巴里| 涡阳县| 仲巴县| 孟连| 仪征市|