コード例 #1
0
int main(int argc,  char * argv[]){
  if(argc < 3){cout<<" Usage: executable input_file.root outfile.txt"<<endl; return -4;}
  int sm_ = 18;
  TFile f(argv[1]);
  TProfile* pr = 0;
  pr = (TProfile*) f.Get("rel_timing_prof_conv_blu");
  if( !pr ){cout<<" timing profile not found in the root file"<<endl; return -1;}
  
  float time[1701]; for(int i=0;i<1701;i++){time[i]=-100;}
  float half_mean  = 0;

  for(int ch=1;ch<1701;ch++){ 
    if ( ch<101 || (ch-1)%20 > 9){half_mean=137.4/25.;}// half1
    else {half_mean=137.1/25.;}
    time[ch] = pr->GetBinContent(ch)+half_mean;
    if( fabs(pr->GetBinContent(ch))>0.2 || pr->GetBinEntries(ch)<500 ){
      cout<<"cry: "<<ch<<" entries: "<<pr->GetBinEntries(ch)<<" rel timing: "<<pr->GetBinContent(ch)<<endl;
    }
  }
  f.Close();
  
  ofstream txt_channels;
  txt_channels.open(argv[2],ios::out);
  for(int i=1;i<1701;i++){
    txt_channels <<sm_<<"   "<<setw(4)<<i<<" \t "<<setw(8)<<setprecision(7)<<time[i]<< endl;
  }
  txt_channels.close();
  
  return 0;
}
コード例 #2
0
ファイル: t.C プロジェクト: schuetzepaul/testbeam-analysis
//------------------------------------------------------------------------------
double meanY( char* hs ) // for profiles only
{
  TObject* obj = gDirectory->Get(hs);
  if( !obj->InheritsFrom( "TProfile" ) ) {
    cout << hs << " is not profile plot" << endl;
    return 0;
  }
  TProfile* p = (TProfile*)obj;
  double sumw = 0;
  double sumy = 0;
  for( int i = 1; i <= p->GetNbinsX(); ++i ) { // bin 0 is underflow
    double w = p->GetBinEntries(i);
    sumw += w;
    sumy += w * p->GetBinContent(i);
  }
  if( sumw > 0.1 )
    return sumy/sumw;
  else
    return 0;
}