Пример #1
0
//_____________________________________________________________________________________________________//
KVIDGrid* KVIDTelescope::CalculateDeltaE_EGrid(TH2* haa_zz, Bool_t Zonly, Int_t npoints)
{
   //Genere une grille dE-E (perte d'energie - energie residuelle)
   //Le calcul est fait pour chaque couple comptant de charge (Z) et masse (A)
   //au moins un coup dans l'histogramme haa_zz definit :
   // Axe X -> Z
   // Axe Y -> A
   //
   //- Si Zonly=kTRUE (kFALSE par defaut), pour un Z donne, le A choisi est la valeur entiere la
   //plus proche de la valeur moyenne <A>
   //- Si Zonly=kFALSE et que pour un Z donne il n'y a qu'un seul A associe, les lignes correspondants
   //a A-1 et A+1 sont ajoutes
   //- Si a un Z donne, il n'y a aucun A, pas de ligne tracee
   //un noyau de A et Z donne n'est considere que s'il retourne KVNucleus::IsKnown() = kTRUE
   //
   // Warning : the grid is not added to the list of the telescope and MUST BE DELETED by the user !

   if (GetSize() <= 1) return 0;

   TClass* cl = new TClass(GetDefaultIDGridClass());
   KVIDGrid* idgrid = (KVIDGrid*)cl->New();
   delete cl;

   idgrid->AddIDTelescope(this);
   idgrid->SetOnlyZId(Zonly);

   KVDetector* det_de = GetDetector(1);
   if (!det_de)      return 0;
   KVDetector* det_eres = GetDetector(2);
   if (!det_eres)    return 0;

   KVNucleus part;
   Info("CalculateDeltaE_EGrid",
        "Calculating dE-E grid: dE detector = %s, E detector = %s",
        det_de->GetName(), det_eres->GetName());

   KVIDCutLine* B_line = (KVIDCutLine*)idgrid->Add("OK", "KVIDCutLine");
   Int_t npoi_bragg = 0;
   B_line->SetName("Bragg_line");
   B_line->SetAcceptedDirection("right");

   Double_t SeuilE = 0.1;

   for (Int_t nx = 1; nx <= haa_zz->GetNbinsX(); nx += 1) {

      Int_t zz = TMath::Nint(haa_zz->GetXaxis()->GetBinCenter(nx));
      KVNumberList nlA;
      Double_t sumA = 0, sum = 0;
      for (Int_t ny = 1; ny <= haa_zz->GetNbinsY(); ny += 1) {
         Double_t stat = haa_zz->GetBinContent(nx, ny);
         if (stat > 0) {
            Double_t val = haa_zz->GetYaxis()->GetBinCenter(ny);
            nlA.Add(TMath::Nint(val));
            sumA += val * stat;
            sum  += stat;
         }
      }
      sumA /= sum;
      Int_t nA = nlA.GetNValues();
      if (nA == 0) {
         Warning("CalculateDeltaE_EGrid", "no count for Z=%d", zz);
      } else {
         if (Zonly) {
            nlA.Clear();
            nlA.Add(TMath::Nint(sumA));
         } else {
            if (nA == 1) {
               Int_t aref = nlA.Last();
               nlA.Add(aref - 1);
               nlA.Add(aref + 1);
            }
         }
         part.SetZ(zz);
//            printf("zz=%d\n",zz);
         nlA.Begin();
         while (!nlA.End()) {
            Int_t aa = nlA.Next();
            part.SetA(aa);
//                printf("+ aa=%d known=%d\n",aa,part.IsKnown());
            if (part.IsKnown()) {

               //loop over energy
               //first find :
               //  ****E1 = energy at which particle passes 1st detector and starts to enter in the 2nd one****
               //      E2 = energy at which particle passes the 2nd detector
               //then perform npoints calculations between these two energies and use these
               //to construct a KVIDZALine

               Double_t E1, E2;
               //find E1
               //go from SeuilE MeV to det_de->GetEIncOfMaxDeltaE(part.GetZ(),part.GetA()))
               Double_t E1min = SeuilE, E1max = det_de->GetEIncOfMaxDeltaE(zz, aa);
               E1 = (E1min + E1max) / 2.;

               while ((E1max - E1min) > SeuilE) {

                  part.SetEnergy(E1);
                  det_de->Clear();
                  det_eres->Clear();

                  det_de->DetectParticle(&part);
                  det_eres->DetectParticle(&part);
                  if (det_eres->GetEnergy() > SeuilE) {
                     //particle got through - decrease energy
                     E1max = E1;
                     E1 = (E1max + E1min) / 2.;
                  } else {
                     //particle stopped - increase energy
                     E1min = E1;
                     E1 = (E1max + E1min) / 2.;
                  }
               }

               //add point to Bragg line
               Double_t dE_B = det_de->GetMaxDeltaE(zz, aa);
               Double_t E_B = det_de->GetEIncOfMaxDeltaE(zz, aa);
               Double_t Eres_B = det_de->GetERes(zz, aa, E_B);
               B_line->SetPoint(npoi_bragg++, Eres_B, dE_B);

               //find E2
               //go from E1 MeV to maximum value where the energy loss formula is valid
               Double_t E2min = E1, E2max = det_eres->GetEmaxValid(part.GetZ(), part.GetA());
               E2 = (E2min + E2max) / 2.;

               while ((E2max - E2min > SeuilE)) {

                  part.SetEnergy(E2);
                  det_de->Clear();
                  det_eres->Clear();

                  det_de->DetectParticle(&part);
                  det_eres->DetectParticle(&part);
                  if (part.GetEnergy() > SeuilE) {
                     //particle got through - decrease energy
                     E2max = E2;
                     E2 = (E2max + E2min) / 2.;
                  } else {
                     //particle stopped - increase energy
                     E2min = E2;
                     E2 = (E2max + E2min) / 2.;
                  }
               }

//                    printf("z=%d a=%d E1=%lf E2=%lf\n",zz,aa,E1,E2);
               KVIDZALine* line = (KVIDZALine*)idgrid->Add("ID", "KVIDZALine");
               if (TMath::Even(zz)) line->SetLineColor(4);
               line->SetAandZ(aa, zz);

               Double_t logE1 = TMath::Log(E1);
               Double_t logE2 = TMath::Log(E2);
               Double_t dLog = (logE2 - logE1) / (npoints - 1.);

               for (Int_t i = 0; i < npoints; i++) {
                  Double_t E = TMath::Exp(logE1 + i * dLog);
                  Double_t Eres = 0.;
                  Int_t niter = 0;
                  while (Eres < SeuilE && niter <= 20) {
                     det_de->Clear();
                     det_eres->Clear();

                     part.SetEnergy(E);

                     det_de->DetectParticle(&part);
                     det_eres->DetectParticle(&part);

                     Eres = det_eres->GetEnergy();
                     E += SeuilE;

                     niter += 1;
                  }
                  if (!(niter > 20)) {
                     Double_t dE = det_de->GetEnergy();
                     Double_t gEres, gdE;
                     line->GetPoint(i - 1, gEres, gdE);
                     line->SetPoint(i, Eres, dE);
                  }
               }

            }
         }

      }

   }

   return idgrid;

}
Пример #2
0
void KV_CCIN2P3_GE::Run()
{
   //Processes the job requests for the batch system.
   //In normal mode, this submits one job for the data analyser fAnalyser
   //In multijobs mode, this submits one job for each run in the runlist associated to fAnalyser

   if (!CheckJobParameters()) return;

   if (MultiJobsMode()) {
      if (fAnalyser->InheritsFrom("KVDataSetAnalyser")) {
         //submit jobs for every GetRunsPerJob() runs in runlist
         KVDataSetAnalyser* ana = dynamic_cast<KVDataSetAnalyser*>(fAnalyser);
         KVNumberList runs = ana->GetRunList();
         runs.Begin();
         Int_t remaining_runs = runs.GetNValues();
         fCurrJobRunList.Clear();
         while (remaining_runs && !runs.End()) {
            Int_t run = runs.Next();
            remaining_runs--;
            fCurrJobRunList.Add(run);
            if ((fCurrJobRunList.GetNValues() == GetRunsPerJob()) || runs.End()) {
               // submit job for GetRunsPerJob() runs (or less if we have reached end of runlist 'runs')
               ana->SetRuns(fCurrJobRunList, kFALSE);
               ana->SetFullRunList(runs);
               SubmitJob();
               fCurrJobRunList.Clear();
            }
         }
         ana->SetRuns(runs, kFALSE);
      }
      else if (fAnalyser->InheritsFrom("KVSimDirAnalyser")) {
         // here we understand "run" to mean "file"
         KVSimDirAnalyser* ana = dynamic_cast<KVSimDirAnalyser*>(fAnalyser);
         TList* file_list = ana->GetFileList();
         Int_t remaining_runs = ana->GetNumberOfFilesToAnalyse();
         fCurrJobRunList.Clear();
         TList cur_file_list;
         TObject* of;
         TIter it(file_list);
         Int_t file_no = 1;
         while ((of = it())) {
            cur_file_list.Add(of);
            fCurrJobRunList.Add(file_no);
            remaining_runs--;
            file_no++;
            if ((fCurrJobRunList.GetNValues() == GetRunsPerJob()) || (remaining_runs == 0)) {
               // submit job for GetRunsPerJob() files (or less if we have reached end of list)
               ana->SetFileList(&cur_file_list);
               SubmitJob();
               fCurrJobRunList.Clear();
               cur_file_list.Clear();
            }
         }
         ana->SetFileList(file_list);
      }
   }
   else {
      SubmitJob();
   }

}