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


C++ KVDetector::GetELostByParticle方法代码示例

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


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

示例1: MakeIDLine

TGraph* KVIDTelescope::MakeIDLine(KVNucleus* nuc, Double_t Emin,
                                  Double_t Emax, Double_t Estep)
{
   //For a given nucleus, generate a TGraph representing the line in the deltaE-E
   //plane of the telescope which can be associated with nuclei of this (A,Z) with total
   //incident energies between the two limits.
   //NOTE: if there are other absorbers/detectors placed before this telescope,
   //the energy losses of the particle in these will be taken into account.
   //If the step in energy is not given, it is taken equal to 100 equal steps between min and max.
   //The TGraph should be deleted by the user after use.


   if (!Estep)
      Estep = (Emax - Emin) / 100.;

   Int_t nsteps = 1 + (Int_t)((Emax - Emin) / Estep);

   if (nsteps < 1)
      return 0;

   Double_t* y = new Double_t[nsteps];
   Double_t* x = new Double_t[nsteps];
   Int_t step = 0;

   //get list of all detectors through which particle must pass in order to reach
   //2nd member of ID Telescope
   TList* detectors =
      GetDetector(2)->GetAlignedDetectors(KVGroup::kForwards);
   //detectors->ls();
   TIter next_det(detectors);
   //cout << "nsteps =" << nsteps << endl;

   for (Double_t E = Emin; E <= Emax; E += Estep) {
      //Set energy of nucleus
      nuc->SetEnergy(E);
      //cout << "Einc=" << E << endl;

      //Calculate energy loss in each member and stock in arrays x & y
      //first member
      KVDetector* det = 0;
      x[step] = y[step] = -1;
      while ((det = (KVDetector*) next_det())) {
         //det->Print();
         Double_t eloss = det->GetELostByParticle(nuc);
         if (det == GetDetector(1))
            y[step] = eloss;
         else if (det == GetDetector(2))
            x[step] = eloss;
         Double_t E1 = nuc->GetEnergy() - eloss;
         nuc->SetEnergy(E1);
         //cout << "Eloss=" << eloss << endl;
         //cout << "Enuc=" << nuc->GetEnergy() << endl;
         if (E1 < 1.e-3) break;
      }

      //cout << "step = " << step << " x = " << x[step] << " y = " << y[step] << endl;

      //make sure that some energy is lost in each member
      //otherwise miss a step and reduce number of points in graph
      if (x[step] > 0 && y[step] > 0) {
         step++;
      } else {
         nsteps--;
      }

      //cout << "nsteps =" << nsteps << endl;
      //reset iterator ready for next loop on detectors
      next_det.Reset();
   }
   TGraph* tmp = 0;
   if (nsteps > 1)
      tmp = new TGraph(nsteps, x, y);
   delete[]x;
   delete[]y;
   return tmp;
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:76,代码来源:KVIDTelescope.cpp


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