当前位置: 首页>>代码示例>>C++>>正文


C++ TimeStamp::Add方法代码示例

本文整理汇总了C++中TimeStamp::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeStamp::Add方法的具体用法?C++ TimeStamp::Add怎么用?C++ TimeStamp::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeStamp的用法示例。


在下文中一共展示了TimeStamp::Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
  string inputfilelist;
  string filenameext = ".TWin.root";
  string outputfilebase;
  string outputfile;

  TChain *SubEvt = new TChain("SubEvt");

  if( argc != 3 ) {
    cout<<"Usage:"<<endl;
    cout<<"    TWin inputfiles.list output/path/namebase"<<endl;
    cout<<endl;
    return 1;
  } else {
    inputfilelist = argv[1];
    outputfilebase = argv[2];

    /// The input file parsing
    ifstream inlist( inputfilelist.c_str() );
    string line;
    while( getline( inlist, line ) )  {
      SubEvt->Add( line.c_str() );
    }

    /// The output file
    outputfile = outputfilebase + filenameext;
  }

  /// Do the work 
  /// ###########
  // Load the SubEvt Tree
  // This should a TChain
  // Get the SubEvt Tree reader
  SEReader = new SubEvtReader;
  SEReader->Init(SubEvt);
  // Prepare the output tree
  aEventTree = new EventTree("Event",outputfile.c_str(),0);

  /// Prepare to Start
  BeginJob();

  /// The main loop
  /// #############
  unsigned int entries = SubEvt->GetEntries();
  for( unsigned int entry=0; entry<entries; entry++ )  {
    int ret = SEReader->GetEntry( entry );
    if( ret==0 ) {
      cout<<"Warning: Read error"<<endl;
    }

    if( SEReader->Run != CurrRun )  {
      if( CurrRun != 0 ) {
	EndRun();
      }
      BeginRun();
    }
    
    /* A few key variables */
    CurrSubEvtTime = TimeStamp(SEReader->SubEvtSec, SEReader->SubEvtNano);
    bool GoodSingleAdSubEvt = false;
    TimeStamp T2PrevMuon;
    if( PrevMuonTime == TimeStamp::GetBOT() )  {
      T2PrevMuon == TimeStamp(0,0);
    } else {
      T2PrevMuon = CurrSubEvtTime - PrevMuonTime;
    }

    CurrSingleDet = 0;
    if( SEReader->NDet == 1 ) {
      for( unsigned int i=0; i<7; i++ )  {
	if( SEReader->Valid[i] ) {
	  CurrSingleDet = SEReader->Det[i];
	}
      }
    }

    if( SEReader->MuonProb < 0.5 &&
	/// SEReader->RetrigProb < 0.5 &&   /// This turns out to be not very useful
	SEReader->NDet == 1 &&
	CurrSingleDet <= 4 &&
	T2PrevMuon.GetSeconds() > cuts.SpallDt/second )  {
      GoodSingleAdSubEvt = true;
    }

    /* For non-muon-event, if it is a single AD sub event */
    /* Need to filter out non-physical events. They should not go into the searching queue. */
    if( SEReader->MuonProb < 0.5 ) {
      if( GoodSingleAdSubEvt ) {
	
	/* Skip flashers */
	double Quadrant = SEReader->Quadrant[ CurrSingleDet - 1 ];
	double QMax2Sum = SEReader->QMax2Sum[ CurrSingleDet - 1 ];
	double ellipse = sqrt(
			      (Quadrant)*(Quadrant) +
			      (QMax2Sum)/0.45*(QMax2Sum)/0.45
			      );
	if( ellipse>1 ) goto EndEachSubEvent;
      
	/* Remove low and high energy events */
//.........这里部分代码省略.........
开发者ID:zhangzc11,项目名称:CPTV,代码行数:101,代码来源:Main.C

示例2: DailyPlot

void DailyPlot()
{
  cout<<" [ Measured and predicted rate ] "<<endl;
  /* Predicted daily rate */
  IGetFluxXsec* GetFluxXsec;
  if( Basic::DailyFlux == true ) {
    /// Daily flux blinded.
  } else {
    GetFluxXsec = gGetFluxXsec;
  }


  /* Daily rate */
  TimeStamp BeginTime(2011,12,24,0,0,0);
  TimeStamp EndTime  (2012,02,11,0,0,0);
  TimeStamp Week(7*24*60*60);
  TimeStamp Day(24*60*60);
  map< TimeStamp, double > Rate[ Basic::NoAd ];

  for( TimeStamp Time = BeginTime; Time <= EndTime; Time.Add( Week ) )  {
    for( unsigned int m_AdNo = 1; m_AdNo<=Basic::NoAd; m_AdNo++ )  {
      
      double Sum=0;

      for( unsigned int BinIdx = 1; BinIdx <= Binning::NHistoBin; BinIdx++ )  {
	for( unsigned int RctIdx = 1; RctIdx <= Basic::NoRct; RctIdx++ )  {

	  Sum +=
	    GetFluxXsec->Get( Time, RctIdx, BinIdx )
	    * (Binning::EndEnergy-Binning::BeginEnergy)/Binning::NHistoBin
	    * pow( Baseline(RctIdx, m_AdNo), -2 ) / 4 /3.1415926
	    * gProtonNumber->Get( Time, m_AdNo ).NPGdLs
	    * Day.GetSeconds()*CLHEP::second;

	}
      }
      
      Rate[m_AdNo-1][Time] = Sum;
    }
  }

  /// Sum over all live time
  double Sum8[Basic::NoAd];
  const std::vector< RunBrief* > Runs = gAnalyzeData->GetRuns();

  /* ============================================== */
  for( unsigned int m_AdNo=1; m_AdNo<=Basic::NoAd; m_AdNo++ ) {
    Sum8[m_AdNo-1] = 0;

    int Site = ToSite(m_AdNo);
    int LocalAdNo = ToLocalAdNo(m_AdNo);

    for( std::vector< RunBrief* >::const_iterator iRun = Runs.begin();
	 iRun!=Runs.end(); iRun++ ) {

      const RunBrief* const Brief = (*iRun);

      if( Dataset::GdCap != Brief->Dataset ) continue;

      /* Must be from the same site */
      if( Site != Brief->Site ) continue;

      /* Cache run info */
      double fulltime     = Brief->Fulltime;
      double livefraction = Brief->Livetime[ LocalAdNo-1 ] / fulltime;

      /* split it into days */
      for( TimeStamp Time = Brief->StartTime; Time < Brief->StopTime; /* Complex increment */) {

	/* Through this, runs span over a day are split into days at exactly 00:00:00 */
	unsigned int StartDate,StartYY,StartMM,StartDD;
	unsigned int StopDate, StopYY, StopMM, StopDD;

	StartDate =            Time.GetDate( true, 0, &StartYY, &StartMM, &StartDD );
	StopDate  = Brief->StopTime.GetDate( true, 0, &StopYY,  &StopMM,  &StopDD  );

	TimeStamp Step(0,0); /* Alway init a TimeStamp, otherwise it will be inited to sys time and too slow. */
	if( StartDate == StopDate ) {
	  /* The same day */
	  Step = Brief->StopTime - Time;
	} else {
	  /* The closest day's end */
	  TimeStamp DaysEnd( StartYY,StartMM,StartDD+1, 0, 0, 0, 0);
	  Step = DaysEnd - Time;
	}

	for( unsigned int BinIdx = 1; BinIdx <= Binning::NHistoBin; BinIdx++ ) {
	  for( unsigned int RctIdx = 1; RctIdx <= Basic::NoRct; RctIdx++ ) {

	    Sum8[m_AdNo-1] +=
	      GetFluxXsec->Get( Time, RctIdx, BinIdx )
	      * (Binning::EndEnergy-Binning::BeginEnergy)/Binning::NHistoBin
	      * pow( Baseline(RctIdx, m_AdNo), -2 ) / 4 /3.1415926
	      * gProtonNumber->Get( Time, m_AdNo ).NPGdLs
	      * Step.GetSeconds()*CLHEP::second;
	  }
	}
	/* After all calculation, calculate the addtion for Time */
	Time.Add( Step );
      }
//.........这里部分代码省略.........
开发者ID:zhangzc11,项目名称:CPTV,代码行数:101,代码来源:DailyPlot.C

示例3: SetupTruth


//.........这里部分代码省略.........
    /* Cache run info */
    double fulltime     = Brief->Fulltime;
    double livefraction = Brief->Livetime[ LocalAdNo-1 ] / fulltime;
    double OstwEff      = Brief->OstwEff[ LocalAdNo-1 ];

    /* split it into days */
    for( TimeStamp Time = Brief->StartTime; Time < Brief->StopTime; /* Complex increment */)  {
            
      /* Through this, runs span over a day are split into days at exactly 00:00:00 */
      unsigned int StartDate,StartYY,StartMM,StartDD;
      unsigned int StopDate, StopYY, StopMM, StopDD;
      
      StartDate =            Time.GetDate( true, 0, &StartYY, &StartMM, &StartDD );
      StopDate  = Brief->StopTime.GetDate( true, 0, &StopYY,  &StopMM,  &StopDD  );

      TimeStamp Step(0,0); /* Alway init a TimeStamp, otherwise it will be inited to sys time and too slow. */
      if( StartDate == StopDate )  {
	/* The same day */
	Step = Brief->StopTime - Time;
      } else {
	/* The closest day's end */
	TimeStamp DaysEnd( StartYY,StartMM,StartDD+1, 0, 0, 0, 0);
	Step = DaysEnd - Time;
      }

      /* live time in this step */
      double thislivetime = Step.GetSeconds()*CLHEP::second * livefraction;

      for( unsigned int BinIdx = 1; BinIdx <= Binning::NHistoBin; BinIdx++ )  {
	for( unsigned int RctIdx = 1; RctIdx <= Basic::NoRct; RctIdx++ )  {
	  
	  double NTruth = GetBinContent( BinIdx );
	  double Increment = 0;
	  double Incre8 = 0, Incre22 = 0;
	  
	  double Evis = Binning::BeginEnergy + (BinIdx-1) * (Binning::EndEnergy-Binning::BeginEnergy)/Binning::NHistoBin;
	  double Enu  = Evis + Phys::EnuToEprompt;

	  if( m_dataset == Dataset::GdCap ) {
	    
	    Incre8 += 
	      GetFluxXsec->Get( Time, RctIdx, BinIdx ) 
	      * (Binning::EndEnergy-Binning::BeginEnergy)/Binning::NHistoBin
	      * pow( Baseline(RctIdx, m_AdNo), -2 ) / 4 /3.1415926
	      * gProtonNumber->Get( Time, m_AdNo ).NPGdLs 
	      * thislivetime 
	      * OstwEff
	      * SurvProb( s_2_2_13, Baseline(RctIdx, m_AdNo), Enu)
	      * Phys::Gd_Cap_Pmpt_eff
	      * Phys::Gd_Cap_Dlyd_eff
	      * Phys::GdLS_Gd_Cap_Frac
	      * Phys::GdLS_Distance_8_eff  /* 100% */
	      * Eff::Flasher_8_eff
	      * Eff::Time_8_eff
	      * Eff::Spill_in_8_eff;
	  }

	  if( m_dataset == Dataset::HCap ) {
	    /// GdLS part
	    Incre22 +=
	      GetFluxXsec->Get( Time, RctIdx, BinIdx )
	      * (Binning::EndEnergy-Binning::BeginEnergy)/Binning::NHistoBin
	      * pow( Baseline(RctIdx, m_AdNo), -2 ) / 4 /3.1415926
	      * gProtonNumber->Get( Time, m_AdNo ).NPGdLs
              * thislivetime
	      * OstwEff
	      * Phys::GdLS_H_Cap_Frac
	      * SurvProb( s_2_2_13, Baseline(RctIdx, m_AdNo), Enu)
	      * Phys::GdLS_Distance_22_eff;  /* Not finalized. */

	    //cout<<s_2_2_13<<" "<<Baseline(RctIdx, m_AdNo)/CLHEP::m<<" "<<Enu/CLHEP::MeV<<" "<<SurvProb( s_2_2_13, Baseline(RctIdx, m_AdNo), Enu)<<endl;
	    
	    /// LS part
	    Incre22 +=
	      GetFluxXsec->Get( Time, RctIdx, BinIdx )
	      * (Binning::EndEnergy-Binning::BeginEnergy)/Binning::NHistoBin
	      * pow( Baseline(RctIdx, m_AdNo), -2 ) / 4 /3.1415926
	      * gProtonNumber->Get( Time, m_AdNo ).NPLs
              * thislivetime
	      * OstwEff
	      * Phys::En3sigma_eff
	      * SurvProb( s_2_2_13, Baseline(RctIdx, m_AdNo), Enu)
	      * Phys::LS_Distance_22_eff;  /* Not finalized. */
	  }
	  
	  Increment = Incre8 + Incre22;
	  
	  SetBinContent( BinIdx, NTruth + Increment );

	}
      }
      
      /* After all calculation, calculate the addtion for Time */
      Time.Add( Step );
    }

  }

  return 1;
}
开发者ID:zhangzc11,项目名称:CPTV,代码行数:101,代码来源:Truth.C


注:本文中的TimeStamp::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。