Esempio n. 1
0
void AnalysisTaskXi(TString pre = "", int nevts=0, double mom=2.7){
	TDatabasePDG::Instance()-> AddParticle("pbarpSystem","pbarpSystem", 1.9, kFALSE, 0.1, 0,"", 88888);

	//Output File
	if (pre==""){
		TString Path = "/private/puetz/mysimulations/analysis/pbarp_Xiplus_Ximinus/idealtracking/10000_events/";
		TString outPath = Path;
		TString OutputFile = outPath + "analysis_output_test.root";

		//Input simulation Files
		TString inPIDFile = Path + "pid_complete.root";
		TString inParFile = Path + "simparams.root";
	}
	else{
		TString Path = pre;
		TString outPath = Path + "_test_";
		TString OutputFile = Path + "_analysis_output.root";

		//Input simulation Files
		TString inPIDFile = Path + "_pid_complete.root";
		TString inParFile = Path + "_simparams.root";
	}

	TString PIDParFile = TString( gSystem->Getenv("VMCWORKDIR")) + "/macro/params/all.par";

	//Initialization
	FairLogger::GetLogger()->SetLogToFile(kFALSE);
	FairRunAna* RunAna = new FairRunAna();
	FairRuntimeDb* rtdb = RunAna->GetRuntimeDb();
	RunAna->SetInputFile(inPIDFile);

	//setup parameter database
	FairParRootFileIo* parIo = new FairParRootFileIo();
	parIo->open(inParFile);
	FairParAsciiFileIo* parIoPID = new FairParAsciiFileIo();
	parIoPID->open(PIDParFile.Data(),"in");

	rtdb->setFirstInput(parIo);
	rtdb->setSecondInput(parIoPID);
	rtdb->setOutput(parIo);


	RunAna->SetOutputFile(OutputFile);

	// *** HERE OUR TASK GOES!
	AnalysisTask *anaTask = new AnalysisTask();
	anaTask->SetOutPutDir(outPath);
	anaTask->SetNEvents(nevts);
	anaTask->SetMom(mom);
	RunAna->AddTask(anaTask);

	RunAna->Init();
	RunAna->Run(0.,1.);

	exit(0);
Esempio n. 2
0
void ana(int iplab = 0, int itype = 0, int brem = 1, int fid=0, int nevts = 10000) {

  gSystem->Load("libanatda");
  gSystem->ListLibraries();

  //double plab[3] = {5.513, 8., 12.};
  //const char *tt[2] = {"pip_pim","jpsi"};
  //const char *cbrem[2] = {"raw","brem"};
  //TString inPidFile = Form("output/pid/pbar_p_%s_pi0_plab%3.1f_%d.root", tt[itype], plab[iplab], fid);
  //TString inParFile = Form("output/par/pbar_p_%s_pi0_plab%3.1f_%d.root", tt[itype], plab[iplab], fid);
  //TString outFile = Form("test/ana_%s_%s_plab%3.1f_%d.root", tt[itype], cbrem[brem], plab[iplab], fid);
  //cout << "inPidFile= " << inPidFile << endl;
  //cout << "inParFile= " << inParFile << endl;
  //cout << " tt= " << tt[itype] <<  " Outfile= " << outFile << endl;

  const char *tt[2] = {"pi0pipm_dpm","pi0jpsi"};
  const char *cbrem[2] = {"raw","brem"};
  const char *dir = Form("/vol0/panda/work/jpsi_pi0/grid.out/tda/%s/runall.%d.%d", tt[itype], iplab, fid);
  TString inPidFile = Form("%s/pid_complete.root",dir);
  TString inParFile = Form("%s/simparams.root",dir);
  TString outFile = Form("%s/ana_%s.root",dir,cbrem[brem]);
  cout << "inPidFile= " << inPidFile << endl;
  cout << "inParFile= " << inParFile << endl;
  cout << "outFile= " << outFile << endl;

  // *** initialization
  FairLogger::GetLogger()->SetLogToFile(kFALSE);
  FairRunAna* fRun = new FairRunAna();
  fRun->SetInputFile(inPidFile);

  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo* parIO = new FairParRootFileIo();
  parIO->open(inParFile);
  FairParAsciiFileIo* parIOPid = new FairParAsciiFileIo();
  parIOPid->open((TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all.par").Data(),"in");
  rtdb->setFirstInput(parIO);
  rtdb->setSecondInput(parIOPid);
  rtdb->setOutput(parIO);

  AnaTda *atda = new AnaTda(iplab, itype, brem);
  atda->set_verbosity(0);
  fRun->AddTask(atda);

  fRun->SetOutputFile(outFile);

  fRun->Init();

  fRun->Run(0,nevts);

  cout << "Done with: " << outFile << endl;

}
Esempio n. 3
0
void analysis_pbarp_Xi_test(int nevts=0){
  
  TDatabasePDG::Instance()-> AddParticle("pbarpSystem","pbarpSystem", 1.9, kFALSE, 0.1, 0,"", 88888);
  
  TStopwatch timer; 



  //Output File
  TString Path = "/private/puetz/mysimulations/analysis/pbarp_Xiplus_Ximinus/idealtracking/10000_events/";
  TString outPath = Path;
  TString OutputFile = outPath + "analysis_output_test.root";
  
  //Input simulation Files
  TString inPIDFile = Path + "pid_complete.root";
  TString inParFile = Path + "simparams.root";
  TString PIDParFile = TString( gSystem->Getenv("VMCWORKDIR")) + "/macro/params/all.par";
  
  //Initialization
  FairLogger::GetLogger()->SetLogToFile(kFALSE);
  FairRunAna* RunAna = new FairRunAna();
  FairRuntimeDb* rtdb = RunAna->GetRuntimeDb();
  RunAna->SetInputFile(inPIDFile);
  
  //setup parameter database
  FairParRootFileIo* parIo = new FairParRootFileIo();
  parIo->open(inParFile);
  FairParAsciiFileIo* parIoPID = new FairParAsciiFileIo();
  parIoPID->open(PIDParFile.Data(),"in");
  
  rtdb->setFirstInput(parIo);
  rtdb->setSecondInput(parIoPID);
  rtdb->setOutput(parIo);

  RunAna->SetOutputFile(OutputFile);
  RunAna->Init();

  //*** create tuples
  RhoTuple * ntpMC = new RhoTuple("ntpMC", "MCTruth info");
  RhoTuple * ntpPiMinus = new RhoTuple("ntpPiMinus", "PiMinus info");
  RhoTuple * ntpPiPlus = new RhoTuple("ntpPiPlus", "PiPlus info");
  RhoTuple * ntpProton = new RhoTuple("ntpProton", "Proton info");
  RhoTuple * ntpAntiProton = new RhoTuple("ntpAntiProton", "Antiproton info");
  RhoTuple * ntpLambda0 = new RhoTuple("ntpLambda0", "Lambda0 info");
  RhoTuple * ntpAntiLambda0 = new RhoTuple("ntpAntiLambda0", "AntiLambda0 info");
  RhoTuple * ntpXiMinus = new RhoTuple("ntpXiMinus", "XiMinus info");
  RhoTuple * ntpXiPlus = new RhoTuple("ntpXiPlus", "XiPlus info");
  RhoTuple * ntpXiSys = new RhoTuple("ntpXiSys", "XiMinus XiPlus system info");

  //Create output file 
  TFile *out = TFile::Open(outPath+"output_ana_test.root","RECREATE");

  // data reader Object
  PndAnalysis* theAnalysis = new PndAnalysis();
  if (nevts==0) nevts = theAnalysis->GetEntries();
  
  //RhoCandLists for analysis
  RhoCandList piplus, piminus, lambda0, antiLambda0, proton, antiProton, xiplus, ximinus, xiSys;
  RhoCandList NotCombinedPiMinus, CombinedPiMinus, CombinedPiPlus, NotCombinedPiPlus;
  RhoCandList SelectedProton, SelectedAntiProton, SelectedPiMinus, SelectedPiPlus;
  RhoCandList Lambda0Fit, AntiLambda0Fit, XiMinusFit, XiPlusFit;
  RhoCandList mclist, all;

  //Dummy RhoCandidate
  RhoCandidate * dummyCand = new RhoCandidate();


  //***Mass selector
  double m0_lambda0= TDatabasePDG::Instance()->GetParticle("Lambda0")->Mass();
  cout<<"Mass of Lambda0: "<<m0_lambda0<<endl;
  RhoMassParticleSelector * lambdaMassSelector = new RhoMassParticleSelector("lambda0", m0_lambda0, 0.3);
 
  double m0_Xi = TDatabasePDG::Instance()->GetParticle("Xi-")->Mass();
  cout<<"Mass of Xi-: "<<m0_Xi<<endl;
  RhoMassParticleSelector * xiMassSelector = new RhoMassParticleSelector("Xi-", m0_Xi, 0.3);

  double m0_pbarpsystem = TDatabasePDG::Instance()->GetParticle("pbarpSystem")->Mass();

  
  double pbarmom = 2.7;
  double p_m0 = TDatabasePDG::Instance()->GetParticle("proton")->Mass();
  TLorentzVector ini (0,0, pbarmom, sqrt(p_m0*p_m0+ pbarmom*pbarmom)+p_m0);
  TVector3 beamBoost = ini.BoostVector();
  
  PndRhoTupleQA qa(theAnalysis, pbarmom);
 
  int evt=-1;
  int index=0;

  while (theAnalysis->GetEvent() && ++evt<nevts){

    if ((evt%100)==0) cout << "evt "<< evt <<endl;
    cout << "Running event " << evt << endl;
		
    //***get MC list and store info
    theAnalysis->FillList(mclist, "McTruth");
    qa.qaMcList("", mclist, ntpMC);
    ntpMC->DumpData();
   	
		
	//if you want to print the hole MCTree uncomment the following
    /*
    for (int j=0;j<mclist.GetLength();++j)
    {
      RhoCandidate *mcmother = mclist[j]->TheMother();        // mother of mc particle         
      int muid = (mcmother==0x0) ? -1 : mcmother->GetTrackNumber(); // track ID of mother, if existing 
        
      cout << "Track "<< mclist[j]->GetTrackNumber()<<" (PDG:"<<mclist[j]->PdgCode() <<") has mother "<<muid;
      if (mclist[j]->NDaughters()>0) cout <<" and daughter(s) ";
	 for (k=0;k<mclist[j]->NDaughters();++k) cout <<mclist[j]->Daughter(k)->GetTrackNumber()<<"  ";
	cout<<endl;        
    }*/


    //***Setup event shape object
		
    TString PidSelection = "PidAlgoIdealCharged";//"PidAlgoMvd;PidAlgoStt;PidAlgoDrc";

    theAnalysis->FillList(all, "All", PidSelection);
    PndEventShape evsh(all, ini, 0.05, 0.1);
    
    //***Selection with no PID info
    theAnalysis->FillList(piminus, "PionAllMinus", PidSelection);
//    theAnalysis->FillList(NotCombinedPiMinus, "PionAllMinus", PidSelection);
//    theAnalysis->FillList(NotCombinedPiPlus, "PionAllPlus", PidSelection);
    theAnalysis->FillList(piplus, "PionAllPlus", PidSelection);
    theAnalysis->FillList(proton, "ProtonAllPlus", PidSelection);
    theAnalysis->FillList(antiProton, "ProtonAllMinus", PidSelection);



    for (int pip=0; pip<piplus.GetLength(); ++pip){
        ntpPiPlus->Column("ev",     (Float_t) evt);
        ntpPiPlus->Column("cand",    (Float_t) pip);
        ntpPiPlus->Column("ncand",   (Float_t) piplus.GetLength());
        ntpPiPlus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(piplus[pip]));


        qa.qaP4("PiPlus_", piplus[pip]->P4(), ntpPiPlus);
        qa.qaCand("PiPlus_", piplus[pip], ntpPiPlus);

        jenny::numberOfHitsInSubdetector("PiPlus_", piplus[pip], ntpPiPlus);
        jenny::tagNHits("PiPlus_", piplus[pip], ntpPiPlus);
        int tag = jenny::tagHits(piplus[pip]);


        RhoCandidate * mother_pip = piplus[pip]->GetMcTruth()->TheMother();
        int moth_pip = (0x0==mother_pip)? 88888 : mother_pip->PdgCode();

        ntpPiPlus->Column("Mother", (Float_t) moth_pip);
        ntpPiPlus->Column("PiPlus_CosTheta", (Float_t) piplus[pip]->GetMomentum().CosTheta());

        qa.qaP4("PiPlus_MC_", piplus[pip]->GetMcTruth()->P4(), ntpPiPlus);
        qa.qaCand("PiPlus_MC_", piplus[pip]->GetMcTruth(), ntpPiPlus);
        ntpPiPlus->Column("PiPlus_MC_CosTheta", (Float_t) piplus[pip]->GetMcTruth()->GetMomentum().CosTheta());

        if(tag==1){
        	SelectedPiPlus.Append(piplus[pip]);
        	NotCombinedPiPlus.Append(piplus[pip]);
        }

        ntpPiPlus->DumpData();
    }

    for (int pim=0; pim<piminus.GetLength(); ++pim){
        ntpPiMinus->Column("ev",     (Float_t) evt);
        ntpPiMinus->Column("cand",    (Float_t) pim);
        ntpPiMinus->Column("ncand",   (Float_t) piminus.GetLength());
        ntpPiMinus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(piminus[pim]));

        qa.qaP4("piminus_", piminus[pim]->P4(), ntpPiMinus);
        qa.qaCand("piminus_", piminus[pim], ntpPiMinus);

        jenny::numberOfHitsInSubdetector("piminus_", piminus[pim], ntpPiMinus);
        jenny::tagNHits("piminus_", piminus[pim], ntpPiMinus);
        int tag = jenny::tagHits(piminus[pim]);

        RhoCandidate * mother_pim = piminus[pim]->GetMcTruth()->TheMother();
        int moth_pim = (0x0==mother_pim)? 88888 : mother_pim->PdgCode();

        ntpPiMinus->Column("Mother", (Float_t) moth_pim);
        ntpPiMinus->Column("PiMinus_CosTheta", (Float_t) piminus[pim]->GetMomentum().CosTheta());

        qa.qaP4("piminus_MC_", piminus[pim]->GetMcTruth()->P4(), ntpPiMinus);
        qa.qaCand("piminus_MC_", piminus[pim]->GetMcTruth(), ntpPiMinus);
        ntpPiMinus->Column("piminus_MC_CosTheta", (Float_t) piminus[pim]->GetMcTruth()->GetMomentum().CosTheta());

        ntpPiMinus->DumpData();

        if(tag==1){
        	SelectedPiMinus.Append(piminus[pim]);
        	NotCombinedPiMinus.Append(piminus[pim]);
        }
    }

    for (int prot=0; prot<proton.GetLength(); ++prot){
        ntpProton->Column("ev",     (Float_t) evt);
        ntpProton->Column("cand",    (Float_t) prot);
        ntpProton->Column("ncand",   (Float_t) proton.GetLength());
        ntpProton->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(proton[prot]));

        qa.qaP4("proton_", proton[prot]->P4(), ntpProton);
        qa.qaCand("proton_", proton[prot], ntpProton);

        jenny::numberOfHitsInSubdetector("proton_", proton[prot], ntpProton);
//        jenny::tagNHits("proton_", proton[prot], ntpProton);

        int tag = jenny::tagHits(proton[prot]);

        RhoCandidate * mother_prot = proton[prot]->GetMcTruth()->TheMother();
        int moth_prot = (0x0==mother_prot)? 88888 : mother_prot->PdgCode();

        ntpProton->Column("Mother", (Float_t) moth_prot);
        ntpProton->Column("proton_CosTheta", (Float_t) proton[prot]->GetMomentum().CosTheta());

        qa.qaP4("proton_MC_", proton[prot]->GetMcTruth()->P4(), ntpProton);
        qa.qaCand("proton_", proton[prot]->GetMcTruth(), ntpProton);
        ntpProton->Column("proton_MC_CosTheta", (Float_t) proton[prot]->GetMcTruth()->GetMomentum().CosTheta());

        ntpProton->DumpData();

        if(tag==1) SelectedProton.Append(proton[prot]);

    }

    for (int aProt=0; aProt<antiProton.GetLength(); ++aProt){
        ntpAntiProton->Column("ev",     (Float_t) evt);
        ntpAntiProton->Column("cand",    (Float_t) aProt);
        ntpAntiProton->Column("ncand",   (Float_t) antiProton.GetLength());
        ntpAntiProton->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(antiProton[aProt]));

        qa.qaP4("antiProton_", antiProton[aProt]->P4(), ntpAntiProton);
        qa.qaCand("antiProton_", antiProton[aProt], ntpAntiProton);

        jenny::numberOfHitsInSubdetector("antiProton_", antiProton[aProt], ntpAntiProton);
//        jenny::tagNHits("antiProton_", antiProton[aProt], ntpAntiProton);
        int tag = jenny::tagHits(antiProton[aProt]);

        RhoCandidate * mother_aProt = antiProton[aProt]->GetMcTruth()->TheMother();
        int moth_aProt = (0x0==mother_aProt)? 88888 : mother_aProt->PdgCode();

        ntpAntiProton->Column("Mother", (Float_t) moth_aProt);
        ntpAntiProton->Column("antiProton_CosTheta", (Float_t) antiProton[aProt]->GetMomentum().CosTheta());


        qa.qaP4("antiProton_MC_", antiProton[aProt]->GetMcTruth()->P4(), ntpAntiProton);
        qa.qaCand("antiProton_", antiProton[aProt]->GetMcTruth(), ntpAntiProton);
        ntpAntiProton->Column("antiProton_MC_CosTheta", (Float_t) antiProton[aProt]->GetMcTruth()->GetMomentum().CosTheta());

        ntpAntiProton->DumpData();

        if(tag==1) SelectedAntiProton.Append(antiProton[aProt]);
    }





    //***Lambda0 -> PiMinus + Proton

    lambda0.Combine(SelectedPiMinus,SelectedProton);
	lambda0.Select(lambdaMassSelector);
    lambda0.SetType(kl0);

    std::map<int,int> bestVtxFitLambda0, bestMassFitLambda0;

    bestVtxFitLambda0 = jenny::VertexQaIndex(&lambda0);
    bestMassFitLambda0 = jenny::MassFitQaIndex(&lambda0, m0_lambda0);


    for (int j=0; j<lambda0.GetLength(); ++j){


      //general info about event
      ntpLambda0->Column("ev",     (Float_t) evt);
      ntpLambda0->Column("cand",    (Float_t) j);
      ntpLambda0->Column("ncand",   (Float_t) lambda0.GetLength());
      ntpLambda0->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(lambda0[j]));
      ntpLambda0->Column("Lambda0_Pdg", (Float_t) lambda0[j]->PdgCode());

	  RhoCandidate * mother = lambda0[j]->TheMother();
  	  int moth = (mother==0x0) ? 88888 : mother->PdgCode();

	  ntpLambda0->Column("Mother", (Float_t) moth);

      qa.qaP4("Lambda0_", lambda0[j]->P4(), ntpLambda0);
      qa.qaComp("Lambda0_", lambda0[j], ntpLambda0);


      // do vertex fit
      PndKinVtxFitter vertexfitterLambda0 (lambda0[j]);
	  vertexfitterLambda0.Fit();
      RhoCandidate * lambda0Fit = lambda0[j]->GetFit();


      // store info of vertex fit
      qa.qaFitter("VtxFit_", &vertexfitterLambda0, ntpLambda0);
      ntpLambda0->Column("VtxFit_HowGood", (Int_t) bestVtxFitLambda0[j]);
      qa.qaVtx("VtxFit_", lambda0Fit, ntpLambda0);

      // differenz to MCTruth
       qa.qaMcDiff("fvtxMcDiff_", lambda0Fit, ntpLambda0);


      // do mass fit
      PndKinFitter massFitterLambda0(lambda0Fit);
      massFitterLambda0.AddMassConstraint(m0_lambda0);
      massFitterLambda0.Fit();

      RhoCandidate * lambda0Fit_mass = lambda0Fit->GetFit();
      qa.qaFitter("MassFit_", &massFitterLambda0, ntpLambda0);

      ntpLambda0->Column("MassFit_HowGood", (Int_t) bestMassFitLambda0[j]);


      RhoCandidate * truth = lambda0[j]->GetMcTruth();
      RhoCandidate * truthDaughter = lambda0[j]->Daughter(0)->GetMcTruth();
      TLorentzVector l;
      TVector3 dl;

	    if(0x0 != truth){
	    	l = truth->P4();
	    	qa.qaVtx("McTruth_", truth, ntpLambda0);
	    	dl = truth->Daughter(0)->Pos();
	    }
	    else{
	    	qa.qaVtx("McTruth_", dummyCand, ntpLambda0);
	    }

      jenny::qaP3("McTruth_", dl, ntpLambda0);
      qa.qaP4("McTruth_", l, ntpLambda0);


      //*** use for Xi only bestChi2Cand

      if (bestVtxFitLambda0[j]==1 && bestMassFitLambda0[j]>0){
		  Lambda0Fit.Append(lambda0Fit);
		  jenny::CombinedList(lambda0Fit, &CombinedPiMinus, -211);
      }


      //***information of boosted particle
      lambda0Fit->Boost(-beamBoost);
      qa.qaComp("boost_", lambda0Fit, ntpLambda0);

      ntpLambda0->DumpData();


   }

    jenny::GetNotCombinedList(CombinedPiMinus, &NotCombinedPiMinus);


//     Lambda0Fit.Cleanup();
     CombinedPiMinus.Cleanup();
     SelectedPiMinus.Cleanup();
     SelectedProton.Cleanup();
//     NotCombinedPiMinus.Cleanup();
     bestVtxFitLambda0.clear();
     bestMassFitLambda0.clear();


    //***AntiLambda0 -> PiPlus + AntiProton
    antiLambda0.Combine(SelectedPiPlus,SelectedAntiProton);
	antiLambda0.Select(lambdaMassSelector);
    antiLambda0.SetType(kal0);

    std::map<int,int> bestVtxFitAntiLambda0, bestMassFitAntiLambda0;

    bestVtxFitAntiLambda0 = jenny::VertexQaIndex(&antiLambda0);
    bestMassFitAntiLambda0 = jenny::MassFitQaIndex(&antiLambda0, m0_lambda0);


    for (int j=0; j<antiLambda0.GetLength(); ++j){

      //general info about event
      ntpAntiLambda0->Column("ev",     (Float_t) evt);
      ntpAntiLambda0->Column("cand",    (Float_t) j);
      ntpAntiLambda0->Column("ncand",   (Float_t) antiLambda0.GetLength());
      ntpAntiLambda0->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(antiLambda0[j]));
      ntpAntiLambda0->Column("AntiLambda0_Pdg", (Float_t) antiLambda0[j]->PdgCode());

	  RhoCandidate * mother = antiLambda0[j]->TheMother();
	  int moth = (mother==0x0) ? 88888 : mother->PdgCode();
	  ntpAntiLambda0->Column("Mother", (Float_t) moth);

      qa.qaP4("AntiLambda0_", antiLambda0[j]->P4(), ntpAntiLambda0);
      qa.qaComp("AntiLambda0_", antiLambda0[j], ntpAntiLambda0);


      // do vertex fit
      PndKinVtxFitter vertexfitterAntiLambda0 (antiLambda0[j]);
      vertexfitterAntiLambda0.Fit();
      RhoCandidate * antiLambda0Fit = antiLambda0[j]->GetFit();



      // store info of vertex fit
      qa.qaFitter("VtxFit_", &vertexfitterAntiLambda0, ntpAntiLambda0);
      qa.qaVtx("VtxFit_", antiLambda0Fit, ntpAntiLambda0);

      ntpAntiLambda0->Column("VtxFit_HowGood", (Int_t) bestVtxFitAntiLambda0[j]);


      // do mass fit
      PndKinFitter massFitterAntiLambda0(antiLambda0Fit);
      massFitterAntiLambda0.AddMassConstraint(m0_lambda0);
      massFitterAntiLambda0.Fit();

      RhoCandidate * antiLambda0Fit_mass = antiLambda0Fit->GetFit();
      qa.qaFitter("MassFit_", &massFitterAntiLambda0, ntpAntiLambda0);
      ntpAntiLambda0->Column("MassFit_HowGood", (Int_t) bestMassFitAntiLambda0[j]);


      RhoCandidate * truth = antiLambda0[j]->GetMcTruth();

      TLorentzVector l;
      if(0x0 != truth){
				l = truth->P4();
				qa.qaVtx("MCTruth_", truth, ntpAntiLambda0);
      }
      else{
    	  qa.qaVtx("McTruth_", dummyCand, ntpAntiLambda0);
      }

      qa.qaP4("MCTruth_", l, ntpAntiLambda0);


      //***information of boosted particle
      antiLambda0Fit->Boost(-beamBoost);
      qa.qaComp("boost_", antiLambda0Fit, ntpAntiLambda0);



      if(bestVtxFitAntiLambda0[j]==1 && bestMassFitAntiLambda0[j]>0){
		  AntiLambda0Fit.Append(antiLambda0Fit);
		  jenny::CombinedList(antiLambda0Fit, &CombinedPiPlus, 211);
      }

      ntpAntiLambda0->DumpData();
    }

    jenny::GetNotCombinedList(CombinedPiPlus, &NotCombinedPiPlus);

	CombinedPiPlus.Cleanup();
	SelectedPiPlus.Cleanup();
	SelectedAntiProton.Cleanup();

    bestVtxFitAntiLambda0.clear();
    bestMassFitAntiLambda0.clear();



    //*** Xi- -> Lambda0 + Pi-
	ximinus.Combine(Lambda0Fit, NotCombinedPiMinus);
	ximinus.Select(xiMassSelector);
	ximinus.SetType(kXim);

	std::map<int,int> BestVtxFitXiMinus, BestMassFitXiMinus;

	BestVtxFitXiMinus = jenny::VertexQaIndex(&ximinus);
	BestMassFitXiMinus = jenny::MassFitQaIndex(&ximinus, m0_Xi);


    for (int j=0; j<ximinus.GetLength(); ++j){

      //general info about event
      ntpXiMinus->Column("ev",     (Float_t) evt);
      ntpXiMinus->Column("cand",    (Float_t) j);
      ntpXiMinus->Column("ncand",   (Float_t) ximinus.GetLength());
      ntpXiMinus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(ximinus[j]));
      ntpXiMinus->Column("XiMinus_Pdg", (Float_t) ximinus[j]->PdgCode());


	  RhoCandidate * mother = ximinus[j]->TheMother();
	  int moth = (mother==0x0) ? 88888 : mother->PdgCode();
	  ntpXiMinus->Column("Mother", (Float_t) moth);

      qa.qaP4("XiMinus_", ximinus[j]->P4(), ntpXiMinus);
      qa.qaComp("XiMinus_", ximinus[j], ntpXiMinus);
      qa.qaPoca("XiMinus_", ximinus[j], ntpXiMinus);



      // do vertex-fit

      PndKinVtxFitter vertexfitterXiMinus (ximinus[j]);
      vertexfitterXiMinus.Fit();
      RhoCandidate * ximinusFit = ximinus[j]->GetFit();


      // store info of vertex-fit

      qa.qaFitter("VtxFit_", &vertexfitterXiMinus, ntpXiMinus);
      ntpXiMinus->Column("VtxFit_HowGood", (Int_t) BestVtxFitXiMinus[j]);

      qa.qaVtx("VtxFit_", ximinusFit, ntpXiMinus);
//      qa.Cand("VtxFit_", ximinusFit, ntpXiMinus);


	  // difference to MCTruth
      qa.qaMcDiff("VtxFit_", ximinusFit, ntpXiMinus);




      // do mass fit
      PndKinFitter massFitterXiMinus(ximinusFit);
      massFitterXiMinus.AddMassConstraint(m0_lambda0);
      massFitterXiMinus.Fit();

      RhoCandidate * ximinusFit_mass = ximinusFit->GetFit();
      qa.qaFitter("MassFit_", &massFitterXiMinus, ntpXiMinus);
      ntpXiMinus->Column("MassFit_HowGood", (Int_t) BestMassFitXiMinus[j]);

      qa.qaMcDiff("MassFit_", ximinusFit_mass, ntpXiMinus);


      RhoCandidate * truth = ximinus[j]->GetMcTruth();
      TLorentzVector l;

      if(0x0 != truth){
				l = truth->P4();
				qa.qaVtx("MCTruth_", truth, ntpXiMinus);
      }
      else{
    	  qa.qaVtx("MCTruth_", dummyCand, ntpXiMinus);
      }

      qa.qaP4("MCTruth_", l, ntpXiMinus);

      if (BestVtxFitXiMinus[j]==1 && BestMassFitXiMinus[j]>0){
    	  XiMinusFit.Append(ximinusFit);
      }


      //***information of boosted particle
      ximinusFit->Boost(-beamBoost);
      qa.qaComp("boost_", ximinusFit, ntpXiMinus);

      ntpXiMinus->DumpData();


	}
    Lambda0Fit.Cleanup();
    NotCombinedPiMinus.Cleanup();

	BestVtxFitXiMinus.clear();
	BestMassFitXiMinus.clear();



	//*** Xi+ -> AntiLambda0 + Pi+
	xiplus.Combine(AntiLambda0Fit,piplus);
	xiplus.Select(xiMassSelector);
	xiplus.SetType(kaXip);

	std::map<int,int> BestVtxFitXiPlus, BestMassFitXiPlus;

	BestVtxFitXiPlus = jenny::VertexQaIndex(&xiplus);
	BestMassFitXiPlus = jenny::MassFitQaIndex(&xiplus, m0_Xi);

    for (int j=0; j<xiplus.GetLength(); ++j){

      //general info about event
      ntpXiPlus->Column("ev",     (Float_t) evt);
      ntpXiPlus->Column("cand",    (Float_t) j);
      ntpXiPlus->Column("ncand",   (Float_t) xiplus.GetLength());
      ntpXiPlus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(xiplus[j]));

      RhoCandidate * mother = xiplus[j]->TheMother();
      int moth = (mother==0x0) ? 88888 : mother->PdgCode();
      ntpXiPlus->Column("Mother", (Float_t) moth);

      qa.qaP4("Xiplus_", xiplus[j]->P4(), ntpXiPlus);
      qa.qaComp("Xiplus_", xiplus[j], ntpXiPlus);


//      int tag = 0;
//      int dtag[2] = {0,0};
//
//      for (int dau=0; dau<xiplus[j]->NDaughters(); dau++){
//
//    	  RhoCandidate * daughter = xiplus[j]->Daughter(dau);
//    	  if(daughter->IsComposite()){
//    		  int dtag1 = jenny::tagHits(daughter->Daughter(0));
//    		  int dtag2 = jenny::tagHits(daughter->Daughter(1));
//       		  if(dtag1==1 && dtag2==1) dtag[dau]=1;
//    	  }
//    	  else{
//    		  dtag[dau] = jenny::tagHits(daughter);
//    	  }
//	 }
//
//      if(dtag[0]==1 && dtag[1]==1) tag=1;
//
//      ntpXiPlus->Column("XiPlus_HitTag", (Int_t) tag);



      //******** do vertex-fit
      PndKinVtxFitter vertexfitterxiplus (xiplus[j]);
      vertexfitterxiplus.Fit();
      RhoCandidate * xiplusFit = xiplus[j]->GetFit();


      // store info of vertex-fit
      qa.qaFitter("VtxFit_", &vertexfitterxiplus, ntpXiPlus);
      ntpXiPlus->Column("VtxFit_HowGood", (Int_t) BestVtxFitXiPlus[j]);
      qa.qaVtx("VtxFit_", xiplusFit, ntpXiPlus);

	  // difference to MCTruth
      qa.qaMcDiff("VtxFit_", xiplusFit, ntpXiPlus);


      //****** do mass fit
      PndKinFitter massFitterxiplus(xiplusFit);
      massFitterxiplus.AddMassConstraint(m0_lambda0);
      massFitterxiplus.Fit();

      RhoCandidate * xiplusFit_mass = xiplusFit->GetFit();
      qa.qaFitter("MassFit_", &massFitterxiplus, ntpXiPlus);
      ntpXiPlus->Column("MassFit_HowGood", (float) BestMassFitXiPlus[j]);
      qa.qaVtx("MassFit_", xiplusFit_mass, ntpXiPlus);

      qa.qaMcDiff("MassFit_", xiplusFit_mass, ntpXiPlus);

      RhoCandidate * truth = xiplus[j]->GetMcTruth();
      TLorentzVector l;
      if(0x0 != truth){
				l = truth->P4();
				qa.qaVtx("MCTruth_", truth, ntpXiPlus);
      }
      else{
    	  qa.qaVtx("MCTruth_", dummyCand, ntpXiPlus);
      }

      qa.qaP4("MCTruth_", l, ntpXiPlus);


      if(BestVtxFitXiPlus[j]==1 && BestMassFitXiPlus[j]>0){
    	  XiPlusFit.Append(xiplusFit);
      }

      //***information of boosted particle
      xiplusFit->Boost(-beamBoost);
      qa.qaComp("boost_", xiplusFit, ntpXiPlus);

      ntpXiPlus->DumpData();
	 }

    AntiLambda0Fit.Cleanup();
//    BestCandAntiLambda0.Cleanup();
	BestVtxFitXiPlus.clear();
	BestMassFitXiPlus.clear();



    //******* Xi+ Xi- System*****************************

    xiSys.Combine(XiPlusFit, XiMinusFit);
    xiSys.SetType(88888);

    for (int syscand=0; syscand<xiSys.GetLength(); ++syscand){

		ntpXiSys->Column("ev",     (Float_t) evt);
		ntpXiSys->Column("cand",    (Float_t) j);
		ntpXiSys->Column("ncand",   (Float_t) ximinus.GetLength());
		ntpXiSys->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(xiSys[syscand]));

		RhoCandidate * mother = xiSys[syscand]->TheMother();
		int moth = (mother==0x0) ? 88888 : mother->PdgCode();
		ntpXiSys->Column("Mother", (Float_t) moth);

		qa.qaP4("XiSys_", xiSys[syscand]->P4(), ntpXiSys);
		qa.qaComp("XiSys_", xiSys[syscand], ntpXiSys);
		qa.qaPoca("XiSys_", xiSys[syscand], ntpXiSys);


		RhoCandidate *  truth = xiSys[syscand]->GetMcTruth();
		TLorentzVector l;

		if (truth != 0x0){
//			qa.qaComp("McTruth_", truth, ntpXiSys);
			qa.qaVtx("McTruth_", truth, ntpXiSys);
			l = truth->P4();
		}
		else{
//			qa.qaComp("McTruth_", dummyCand, ntpXiSys);
			qa.qaVtx("McTruth_", dummyCand, ntpXiSys);
		}
		qa.qaP4("McTruth_", l, ntpXiSys);


		//4C-Fitter

		PndKinFitter fitter4c (xiSys[syscand]);
		fitter4c.Add4MomConstraint(ini);
		fitter4c.Fit();

		RhoCandidate * xiSysFit4c = xiSys[syscand]->GetFit();

		qa.qaFitter("4CFit_", &fitter4c, ntpXiSys);
		qa.qaComp("4cFit_", xiSysFit4c, ntpXiSys);
		qa.qaVtx("4CFit_", xiSysFit4c, ntpXiSys);


		ntpXiSys->DumpData();


    }
    XiMinusFit.Cleanup();
    XiPlusFit.Cleanup();
  }



   

  //Write output
  out->cd();

  ntpMC -> GetInternalTree()->Write();
  ntpPiMinus ->GetInternalTree()->Write();
  ntpPiPlus->GetInternalTree()->Write();
  ntpProton->GetInternalTree()->Write();
  ntpAntiProton->GetInternalTree()->Write();
  ntpLambda0->GetInternalTree()->Write();
  ntpAntiLambda0->GetInternalTree()->Write();
  ntpXiMinus->GetInternalTree()->Write();
  ntpXiPlus->GetInternalTree()->Write();
  ntpXiSys->GetInternalTree()->Write();

  out->Save();
  

  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout<<endl<<endl;
  cout<<"Macro finisched successfully."<<endl;
  cout<<"Realtime: "<<rtime<<" s, CPU time: "<<ctime<<" s"<<endl;
  cout<<endl;

 
  exit(0);
 
}
Esempio n. 4
0
void run_litqa(Int_t nEvents = 1000)
{
   TTree::SetMaxTreeSize(90000000000);

	TString script = TString(gSystem->Getenv("SCRIPT"));
	TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters");

	//gRandom->SetSeed(10);

    TString dir = "/hera/cbm/users/slebedev/mc/dielectron/sep13/25gev/trd/1.0field/nomvd/rho0/";
	TString mcFile = dir + "mc.auau.25gev.centr.00001.root";
	TString parFile = dir + "/params.auau.25gev.centr.00001.root";
	TString recoFile = dir + "/test.reco.test.auau.25gev.centr.00001.root";
	TString qaFile = dir + "/test.litqa.test.auau.25gev.centr.00001.root";

	TString delta = "no"; // if "yes" Delta electrons will be embedded
	TString deltaFile = "";

   TList *parFileList = new TList();
   TObjString stsDigiFile = parDir + "/sts/sts_v13c_std.digi.par"; // STS digi file
   TObjString trdDigiFile = parDir + "/trd/trd_v13p_3e.digi.par"; // TRD digi file
   TObjString tofDigiFile = parDir + "/tof/tof_v13b.digi.par"; // TRD digi file

   TString stsMatBudgetFileName = parDir + "/sts/sts_matbudget_v13c.root"; // Material budget file for L1 STS tracking

   TString resultDir = "results_litqa/";
   Double_t trdAnnCut = 0.85;
   Int_t minNofPointsTrd = 6;

	if (script == "yes") {
		mcFile = TString(gSystem->Getenv("MC_FILE"));
		parFile = TString(gSystem->Getenv("PAR_FILE"));
		recoFile = TString(gSystem->Getenv("RECO_FILE"));
		qaFile = TString(gSystem->Getenv("LITQA_FILE"));

		delta = TString(gSystem->Getenv("DELTA"));
		deltaFile = TString(gSystem->Getenv("DELTA_FILE"));

		stsDigiFile = TString(gSystem->Getenv("STS_DIGI"));
		trdDigiFile = TString(gSystem->Getenv("TRD_DIGI"));
		tofDigiFile = TString(gSystem->Getenv("TOF_DIGI"));

		resultDir = TString(gSystem->Getenv("RESULT_DIR"));

		stsMatBudgetFileName = TString(gSystem->Getenv("STS_MATERIAL_BUDGET_FILE"));
		trdAnnCut = TString(gSystem->Getenv("TRD_ANN_CUT")).Atof();
		minNofPointsTrd = TString(gSystem->Getenv("MIN_NOF_POINTS_TRD")).Atof();
	}

   parFileList->Add(&stsDigiFile);
   parFileList->Add(&trdDigiFile);
   parFileList->Add(&tofDigiFile);

   TStopwatch timer;
   timer.Start();

	// ----  Load libraries   -------------------------------------------------
   gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C");
	loadlibs();
	gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/determine_setup.C");

	// -----   Reconstruction run   -------------------------------------------
	FairRunAna *run= new FairRunAna();
	if (mcFile != "") run->SetInputFile(mcFile);
	if (recoFile != "") run->AddFriend(recoFile);
	if (qaFile != "") run->SetOutputFile(qaFile);

	CbmKF* kalman = new CbmKF();
	run->AddTask(kalman);
	CbmL1* l1 = new CbmL1();
	l1->SetMaterialBudgetFileName(stsMatBudgetFileName);
	run->AddTask(l1);

   // Reconstruction Qa
   CbmLitTrackingQa* trackingQa = new CbmLitTrackingQa();
   trackingQa->SetMinNofPointsSts(4);
   trackingQa->SetUseConsecutivePointsInSts(true);
   trackingQa->SetMinNofPointsTrd(minNofPointsTrd);
   trackingQa->SetMinNofPointsMuch(10);
   trackingQa->SetMinNofPointsTof(1);
   trackingQa->SetQuota(0.7);
   trackingQa->SetMinNofHitsTrd(minNofPointsTrd);
   trackingQa->SetMinNofHitsMuch(10);
   trackingQa->SetVerbose(0);
   trackingQa->SetMinNofHitsRich(7);
   trackingQa->SetQuotaRich(0.6);
   trackingQa->SetPRange(30, 0., 6.);
   trackingQa->SetOutputDir(std::string(resultDir));
   std::vector<std::string> trackCat, richCat;
   trackCat.push_back("All");
   trackCat.push_back("Electron");
   richCat.push_back("All");
   richCat.push_back("Electron");
   richCat.push_back("ElectronReference");
   trackingQa->SetTrackCategories(trackCat);
   trackingQa->SetRingCategories(richCat);
   trackingQa->SetTrdAnnCut(trdAnnCut);
   run->AddTask(trackingQa);

   CbmLitFitQa* fitQa = new CbmLitFitQa();
   fitQa->SetMvdMinNofHits(0);
   fitQa->SetStsMinNofHits(4);
   fitQa->SetMuchMinNofHits(10);
   fitQa->SetTrdMinNofHits(minNofPointsTrd);
   fitQa->SetPRange(30, 0., 3.);
   fitQa->SetOutputDir(std::string(resultDir));
   run->AddTask(fitQa);

  /* CbmLitClusteringQa* clusteringQa = new CbmLitClusteringQa();
   clusteringQa->SetMuchDigiFileName(muchDigiFile.Data());
   clusteringQa->SetOutputDir(std::string(resultDir));
   run->AddTask(clusteringQa);*/

   CbmLitTofQa* tofQa = new CbmLitTofQa();
   tofQa->SetOutputDir(std::string(resultDir));
   run->AddTask(tofQa);


    // -----  Parameter database   --------------------------------------------
   FairRuntimeDb* rtdb = run->GetRuntimeDb();
   FairParRootFileIo* parIo1 = new FairParRootFileIo();
   FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
   parIo1->open(parFile.Data());
   parIo2->open(parFileList, "in");
   rtdb->setFirstInput(parIo1);
   rtdb->setSecondInput(parIo2);
   rtdb->setOutput(parIo1);
   rtdb->saveOutput();

    run->Init();
    run->Run(0, nEvents);

    // -----   Finish   -------------------------------------------------------
    timer.Stop();
    std::cout << "Macro finished successfully." << std::endl;
    std::cout << "Output file is "    << recoFile << std::endl;
    std::cout << "Parameter file is " << parFile << std::endl;
    std::cout << "Real time " << timer.RealTime() << " s, CPU time " << timer.CpuTime() << " s" << std::endl;
    std::cout << " Test passed" << std::endl;
    std::cout << " All ok " << std::endl;
}
void number_of_particles_leaving_GEM_hits_boxgen(TString pre="", int nevts=0, double mom=4.1){
	  TDatabasePDG::Instance()-> AddParticle("pbarpSystem","pbarpSystem", 1.9, kFALSE, 0.1, 0,"", 88888);

	  TStopwatch timer;

	  if (pre==""){
		  //Output File
		  TString OutputFile = "test_analysis_output.root";
		  TString outPath = "";
		  //Input simulation Files
		 TString inPIDFile = "pid_complete.root";
		 TString inParFile = "simparams.root";
	  }
	  else {
		  //Output File
		  TString outPath = pre + "_";
		  TString OutputFile = pre + "_test_analysis_output.root";

		  //Input simulation Files
		  TString inPIDFile = pre + "_pid_complete.root";
		  TString inParFile = pre + "_simparams.root";
	  }

	  TString PIDParFile = TString( gSystem->Getenv("VMCWORKDIR")) + "/macro/params/all.par";

	  //Initialization
	  FairLogger::GetLogger()->SetLogToFile(kFALSE);
	  FairRunAna* RunAna = new FairRunAna();
	  FairRuntimeDb* rtdb = RunAna->GetRuntimeDb();
	  RunAna->SetInputFile(inPIDFile);

	  //setup parameter database
	  FairParRootFileIo* parIo = new FairParRootFileIo();
	  parIo->open(inParFile);
	  FairParAsciiFileIo* parIoPID = new FairParAsciiFileIo();
	  parIoPID->open(PIDParFile.Data(),"in");

	  rtdb->setFirstInput(parIo);
	  rtdb->setSecondInput(parIoPID);
	  rtdb->setOutput(parIo);

	  RunAna->SetOutputFile(OutputFile);
	  RunAna->Init();


	  /*************************************************************************
	   *  Create new ntuple and fill them with information
	   ************************************************************************/

	  //*** create tuples
	  RhoTuple * ntpPiMinus = new RhoTuple("ntpPiMinus", "PiMinus info");
	  RhoTuple * ntpPiPlus = new RhoTuple("ntpPiPlus", "PiPlus info");
	  RhoTuple * ntpKaonMinus = new RhoTuple("ntpKaonMinus", "KaonMinus info");
	  RhoTuple * ntpKaonPlus = new RhoTuple("ntpKaonPlus", "KaonPlus info");
	  RhoTuple * ntpProton = new RhoTuple("ntpProton", "Proton info");
	  RhoTuple * ntpAntiProton = new RhoTuple("ntpAntiProton", "Antiproton info");


	  //Create output file
	  TFile *out = TFile::Open(outPath+"test_output_ana.root","RECREATE");

	  // data reader Object
	  PndAnalysis* theAnalysis = new PndAnalysis();
	  if (nevts==0) nevts = theAnalysis->GetEntries();


	  //RhoCandLists for analysis
	  RhoCandList piplus, piminus, proton, antiproton, kaonminus, kaonplus;

	  RhoCandidate * dummyCand = new RhoCandidate(); //dummy candidate for empty candidate usage


	  double p_m0 = TDatabasePDG::Instance()->GetParticle("proton")->Mass();


	  TLorentzVector ini (0,0, mom, sqrt(p_m0*p_m0+ mom*mom)+p_m0);
	  TVector3 beamBoost = ini.BoostVector();

	  PndRhoTupleQA qa(theAnalysis, mom);

	  int evt=-1;
	  while (theAnalysis->GetEvent() && ++evt<nevts){

	    if ((evt%100)==0) cout << "evt "<< evt <<endl;


	    TString PidSelection = "PidAlgoIdealCharged";//"PidAlgoMvd;PidAlgoStt;PidAlgoDrc"; to change from ideal PID to realistic PID uncomment this!


	    //***Selection with no PID info
	    theAnalysis->FillList(piminus, "PionBestMinus", PidSelection);
	    theAnalysis->FillList(piplus, "PionBestPlus", PidSelection);
	    theAnalysis->FillList(kaonminus, "KaonBestMinus", PidSelection);
	    theAnalysis->FillList(kaonplus, "KaonBestPlus", PidSelection);
	    theAnalysis->FillList(proton, "ProtonBestPlus", PidSelection);
	    theAnalysis->FillList(antiproton, "ProtonBestMinus", PidSelection);


	    //Get piminus information
	    ntpPiMinus->Column("ev",     (Float_t) evt);

	    for (int j=0; j<piminus.GetLength(); ++j){


			//information about the mother and MCTruth Candidate

			TLorentzVector l;
			float costheta = -999.;

			RhoCandidate * truth = piminus[j]->GetMcTruth();
			RhoCandidate * mother;
			if (truth)  mother = truth->TheMother();

			int moth = (mother==0x0) ? 88888 : mother->PdgCode();
			ntpPiMinus->Column("Mother", (Int_t) moth);

			bool truthmatch = theAnalysis->McTruthMatch(piminus[j]);
			ntpPiMinus->Column("MCTruthMatch", (bool) truthmatch);

			int gemhit = GemHits(piminus[j]);

			int count = 0;
			if (moth==88888 && gemhit==1 && truthmatch==1) count=1;

			ntpPiMinus->Column("GemHit", (int) count, 0);


	    }
	    ntpPiMinus->DumpData();

		//Get PiPlus information

	    ntpPiPlus->Column("ev", (int) evt);

	    for (int j=0; j<piplus.GetLength(); ++j){


			//information about the mother and MCTruth Candidate

			TLorentzVector l;
			float costheta = -999.;

			RhoCandidate * truth = piplus[j]->GetMcTruth();
			RhoCandidate * mother;
			if (truth)  mother = truth->TheMother();

			int moth = (mother==0x0) ? 88888 : mother->PdgCode();
			ntpPiPlus->Column("Mother", (Int_t) moth);

			bool truthmatch = theAnalysis->McTruthMatch(piplus[j]);
			ntpPiPlus->Column("MCTruthMatch", (bool) truthmatch);

			int gemhit = GemHits(piplus[j]);

			int count = 0;
			if (moth==88888 && gemhit==1 && truthmatch==1) count=1;

			ntpPiPlus->Column("GemHit", (int) count, 0);


	    }

	    ntpPiPlus->DumpData();

	    ntpKaonMinus->Column("ev", (int) evt);

	    for (int j=0; j<kaonminus.GetLength(); ++j){


			//information about the mother and MCTruth Candidate

			TLorentzVector l;
			float costheta = -999.;

			RhoCandidate * truth = kaonminus[j]->GetMcTruth();
			RhoCandidate * mother;
			if (truth)  mother = truth->TheMother();

			int moth = (mother==0x0) ? 88888 : mother->PdgCode();
			ntpKaonMinus->Column("Mother", (Int_t) moth);

			bool truthmatch = theAnalysis->McTruthMatch(kaonminus[j]);
			ntpKaonMinus->Column("MCTruthMatch", (bool) truthmatch);

			int gemhit = GemHits(kaonminus[j]);

			int count = 0;
			if (moth==88888 && gemhit==1 && truthmatch==1) count=1;

			ntpKaonMinus->Column("GemHit", (int) count, 0);


	    }

	    ntpKaonMinus->DumpData();


	    ntpKaonPlus->Column("ev", (int) evt);

	    for (int j=0; j<kaonplus.GetLength(); ++j){


			//information about the mother and MCTruth Candidate

			TLorentzVector l;
			float costheta = -999.;

			RhoCandidate * truth = kaonplus[j]->GetMcTruth();
			RhoCandidate * mother;
			if (truth)  mother = truth->TheMother();

			int moth = (mother==0x0) ? 88888 : mother->PdgCode();
			ntpKaonPlus->Column("Mother", (Int_t) moth);

			bool truthmatch = theAnalysis->McTruthMatch(kaonplus[j]);
			ntpKaonPlus->Column("MCTruthMatch", (bool) truthmatch);

			int gemhit = GemHits(kaonplus[j]);

			int count = 0;
			if (moth==88888 && gemhit==1 && truthmatch==1) count=1;

			ntpKaonPlus->Column("GemHit", (int) count, 0);


	    }

	    ntpKaonPlus->DumpData();

//		Get Proton information
	    ntpProton->Column("ev", (int) evt);

	    for (int j=0; j<proton.GetLength(); ++j){


			//information about the mother and MCTruth Candidate

			TLorentzVector l;
			float costheta = -999.;

			RhoCandidate * truth = proton[j]->GetMcTruth();
			RhoCandidate * mother;
			if (truth)  mother = truth->TheMother();

			int moth = (mother==0x0) ? 88888 : mother->PdgCode();
			ntpProton->Column("Mother", (Int_t) moth);

			bool truthmatch = theAnalysis->McTruthMatch(proton[j]);
			ntpProton->Column("MCTruthMatch", (bool) truthmatch);

			int gemhit = GemHits(proton[j]);

			int count = 0;
			if (moth==88888 && gemhit==1 && truthmatch==1) count=1;

			ntpProton->Column("GemHit", (int) count, 0);


	    }

	    ntpProton->DumpData();

//			Get Antiproton
	    ntpAntiProton->Column("ev", (int) evt);

	    for (int j=0; j<antiproton.GetLength(); ++j){


			//information about the mother and MCTruth Candidate

			TLorentzVector l;
			float costheta = -999.;

			RhoCandidate * truth = antiproton[j]->GetMcTruth();
			RhoCandidate * mother;
			if (truth)  mother = truth->TheMother();

			int moth = (mother==0x0) ? 88888 : mother->PdgCode();
			ntpAntiProton->Column("Mother", (Int_t) moth);

			bool truthmatch = theAnalysis->McTruthMatch(antiproton[j]);
			ntpAntiProton->Column("MCTruthMatch", (bool) truthmatch);

			int gemhit = GemHits(antiproton[j]);

			int count = 0;
			if (moth==88888 && gemhit==1 && truthmatch==1) count=1;

			ntpAntiProton->Column("GemHit", (int) count, 0);


	    }

	    ntpAntiProton->DumpData();

	  }


	  //Write output
	  out->cd();

	  ntpPiMinus ->GetInternalTree()->Write();
	  ntpPiPlus->GetInternalTree()->Write();
	  ntpKaonMinus ->GetInternalTree()->Write();
	  ntpKaonPlus->GetInternalTree()->Write();
	  ntpProton->GetInternalTree()->Write();
	  ntpAntiProton->GetInternalTree()->Write();


	  out->Save();

	  timer.Stop();
	  Double_t rtime = timer.RealTime();
	  Double_t ctime = timer.CpuTime();

	  cout<<"Macro finisched successfully."<<endl;
	  cout<<"Realtime: "<<rtime<<" s, CPU time: "<<ctime<<" s"<<endl;
	  cout<<endl;


	  exit(0);

	}
Esempio n. 6
0
/********************************************************************************
 *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
 *                                                                              *
 *              This software is distributed under the terms of the             *
 *              GNU Lesser General Public Licence (LGPL) version 3,             *
 *                  copied verbatim in the file "LICENSE"                       *
 ********************************************************************************/
void run_reco( TString mcEngine="TGeant3", Bool_t AlignDone=true )
{
   // ----  Load libraries   -------------------------------------------------
  FairLogger *logger = FairLogger::GetLogger();
//  logger->SetLogFileName("MyLog.log");
  logger->SetLogToScreen(kTRUE);
//  logger->SetLogToFile(kTRUE);
//  logger->SetLogVerbosityLevel("HIGH");
//  logger->SetLogFileLevel("DEBUG4");
  logger->SetLogScreenLevel("INFO");

  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
  Int_t iVerbose = 0; // just forget about it, for the moment

  TString Align= "";
  if (AlignDone) {
    Align= "align_";
  }
  TString InDir = "./data/";
  // Input file (MC Events)
  TString  inFile     ="testrun_";
  inFile = InDir +inFile + Align + mcEngine + ".root";

  // Output file name
  TString  outFile     ="testreco_";
  outFile = InDir + outFile + Align + mcEngine + ".root";

  // Parameter file
  TString  parFile     ="testparams_";
  parFile = InDir + parFile + Align + mcEngine + ".root";

  // Millepede file name
  TString  milleFile     ="testmille_";
  milleFile = InDir + milleFile + Align + mcEngine;

  TList *parFileList = new TList();

  TString workDir = gSystem->Getenv("VMCWORKDIR");
  TString paramDir = workDir + "/simulation/Tutorial4/parameters/";
  TString paramFile = paramDir + "example.par";

  TObjString tutDetDigiFile;
  tutDetDigiFile.SetString(paramFile);
  parFileList->Add(&tutDetDigiFile);

  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;

  // -----   Reconstruction run   -------------------------------------------
  FairRunAna *fRun= new FairRunAna();
  FairFileSource *fFileSource = new FairFileSource(inFile);
  fRun->SetSource(fFileSource);
  fRun->SetSink(new FairRootFileSink(outFile));

  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo* parInput1 = new FairParRootFileIo();
  FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
  parIo2->open(parFileList, "in");
  parInput1->open(parFile.Data());
  parIo2->open(parFileList, "in");
  rtdb->setFirstInput(parInput1);
  rtdb->setSecondInput(parIo2);
  rtdb->setOutput(parInput1);
  rtdb->saveOutput();

  // -----   TorinoDetector hit  producers   ---------------------------------
  FairTutorialDet4HitProducerIdealMisalign* hitProducer = new FairTutorialDet4HitProducerIdealMisalign();
  hitProducer->DoMisalignment(kFALSE);
  fRun->AddTask(hitProducer);

  FairTutorialDet4StraightLineFitter* fitter = new FairTutorialDet4StraightLineFitter();
  fitter->SetVersion(2);
  fRun->AddTask(fitter);

  FairTutorialDet4MilleWriter* writer = new FairTutorialDet4MilleWriter();
//  writer->SetWriteAscii(kTRUE);
  writer->SetVersion(2);
  writer->SetFileName(milleFile);
  fRun->AddTask(writer);


  fRun->Init();

  timer.Start();
  fRun->Run();

  // -----   Finish   -------------------------------------------------------

  cout << endl << endl;

  // Extract the maximal used memory an add is as Dart measurement
  // This line is filtered by CTest and the value send to CDash
  FairSystemInfo sysInfo;
  Float_t maxMemory=sysInfo.GetMaxMemory();
  cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
  cout << maxMemory;
  cout << "</DartMeasurement>" << endl;

  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();

  Float_t cpuUsage=ctime/rtime;
  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
  cout << cpuUsage;
  cout << "</DartMeasurement>" << endl;

  cout << endl << endl;
  cout << "Output file is "    << outFile << endl;
  cout << "Parameter file is " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime
       << "s" << endl << endl;
  cout << "Macro finished successfully." << endl;
  // ------------------------------------------------------------------------
}
/********************************************************************************
 *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
 *                                                                              *
 *              This software is distributed under the terms of the             * 
 *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
 *                  copied verbatim in the file "LICENSE"                       *
 ********************************************************************************/
Int_t  sql_params_write_bin()
{
  // ----  Load libraries   -------------------------------------------------
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
  basiclibs();
  gSystem->Load("libGenVector");
  gSystem->Load("libGeoBase");
  gSystem->Load("libFairDB");
  gSystem->Load("libParBase");
  gSystem->Load("libBase");
  gSystem->Load("libMCStack");
  gSystem->Load("libTutorial5");

  // Generate a unique RunID
  FairRunIdGenerator runID;
  UInt_t runId =  runID.generateId();

  FairRuntimeDb* db = FairRuntimeDb::instance();
  cout << "-I- FairRuntimeDb created ----> " << db << endl;

  // Create in memory the relevant container
  FairDbTutParBin* p1 = (FairDbTutParBin*)(db->getContainer("TUTParBin"));

  // Set the Ascii IO as first input
  FairParAsciiFileIo* inp1 = new FairParAsciiFileIo();

  //TString work = getenv("VMCWORKDIR");
  TString filename = "ascii-example_bin.par";
  inp1->open(filename.Data(),"in");
  db->setFirstInput(inp1);

  // Set the SQL based IO as second input
  FairParTSQLIo* inp2 = new FairParTSQLIo();
  inp2->open();
  db->setSecondInput(inp2);


  // <INIT> containers from Ascii input
  // with assigned  RunId
  db->initContainers(runId);

  // Additionnally  prime some dummy values to the data members that are not
  // initialized using the ascii input file .
 
  p1->FillDummy();

  cout << endl;
  cout << "\n  -I- FAIRDB: RuntimeDB::init from Ascii File done using RunID# " <<  runId << endl;
  cout << endl;

  // <WRITE> back containers to the user-defined
  // Database using the Sql based IO of the
  // second input.

  db->setOutput(inp2);
  db->writeContainers();

  cout << endl;
  cout << "-I-  FAIRDB: RuntimeDB Parameters successfully written to DB with RunID# " << runId << endl;
  cout << endl;

  if (db) delete db;
  return 0;
}
Esempio n. 8
0
void sts_reco(  Int_t nEvents = 1,  Int_t iVerbose = 0){
  TString inFile  = "data/mc_sector.root";
  TString outFile = "data/sts_sector.root";
  TString parFile = "data/params.root";
  TString stsFile = "sts_v11a.digi.par";
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
  basiclibs();
  gROOT->LoadMacro("$VMCWORKDIR/macro/much/muchlibs.C");
  muchlibs();

  FairRunAna *fRun= new FairRunAna();
  fRun->SetInputFile(inFile);
  fRun->SetOutputFile(outFile);

  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo*  parInput1 = new FairParRootFileIo();
  FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
  parInput1->open(parFile.Data());
  parInput2->open(Form("%s/parameters/sts/%s",gSystem->Getenv("VMCWORKDIR"),stsFile.Data()),"in");
  rtdb->setFirstInput(parInput1);
  rtdb->setSecondInput(parInput2);

  Double_t threshold  =  4;
  Double_t noiseWidth =  0.01;
  Int_t    nofBits    = 20;
  Double_t minStep    =  0.01;
  Double_t StripDeadTime = 0.1;
  CbmStsDigitize* stsDigitize = new CbmStsDigitize("STS Digitiser", iVerbose);
  stsDigitize->SetRealisticResponse();
  stsDigitize->SetFrontThreshold (threshold);
  stsDigitize->SetBackThreshold  (threshold);
  stsDigitize->SetFrontNoiseWidth(noiseWidth);
  stsDigitize->SetBackNoiseWidth (noiseWidth);
  stsDigitize->SetFrontNofBits   (nofBits);
  stsDigitize->SetBackNofBits    (nofBits);
  stsDigitize->SetFrontMinStep   (minStep);
  stsDigitize->SetBackMinStep    (minStep);
  stsDigitize->SetStripDeadTime  (StripDeadTime);
  fRun->AddTask(stsDigitize);

  FairTask* stsClusterFinder = new CbmStsClusterFinder("STS Cluster Finder",iVerbose);
  fRun->AddTask(stsClusterFinder);

  FairTask* stsFindHits = new CbmStsFindHits("STS Hit Finder", iVerbose);
  fRun->AddTask(stsFindHits);

  FairTask* stsMatchHits = new CbmStsMatchHits("STS Hit Matcher", iVerbose);
  fRun->AddTask(stsMatchHits);

  // ---  STS track finding   ------------------------------------------------
  CbmKF* kalman = new CbmKF();
  fRun->AddTask(kalman);
  CbmL1* l1 = new CbmL1();
  fRun->AddTask(l1);
  CbmStsTrackFinder* stsTrackFinder    = new CbmL1StsTrackFinder();
  FairTask* stsFindTracks = new CbmStsFindTracks(iVerbose, stsTrackFinder);  
  fRun->AddTask(stsFindTracks);

  CbmStsMatchTracks* stsMatchTracks = new CbmStsMatchTracks(iVerbose);
  fRun->AddTask(stsMatchTracks);

  CbmStsTrackFitter* stsTrackFitter = new CbmStsKFTrackFitter();
  FairTask* stsFitTracks = new CbmStsFitTracks(stsTrackFitter, iVerbose);
  fRun->AddTask(stsFitTracks);

  CbmPrimaryVertexFinder* pvFinder     = new CbmPVFinderKF();
  CbmFindPrimaryVertex* pvFindTask = new CbmFindPrimaryVertex(pvFinder);
  fRun->AddTask(pvFindTask);

  fRun->Init();
  fRun->Run(0,nEvents);
}
Esempio n. 9
0
void digi_complete_jenny(TString pre = "")
{
  // Macro created 20/09/2006 by S.Spataro
  // It loads a simulation file and digitize hits 

  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
  Int_t iVerbose = 0; // just forget about it, for the moment
  
  if (pre!=""){

	TString inFile = pre+"_sim_complete.root";
	TString parFile = pre+"_simparams.root"; // at the moment you do not need it
	TString digiFile = "all.par";
	TString outFile = pre+"_digi_complete.root";
  }
  else{
	TString inFile = "sim_complete.root";
	TString parFile = "simparams.root"; // at the moment you do not need it
	TString digiFile = "all.par";
	TString outFile = "digi_complete.root";
  }

  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;
  
  // -----   Reconstruction run   -------------------------------------------
  FairRunAna *fRun= new FairRunAna();
  fRun->SetInputFile(inFile);
  fRun->SetOutputFile(outFile);
  fRun->SetWriteRunInfoFile(kFALSE);  
  fRun->SetUseFairLinks(kTRUE); 
  // -----  Parameter database   --------------------------------------------
  TString allDigiFile = gSystem->Getenv("VMCWORKDIR");
  allDigiFile += "/macro/params/";
  allDigiFile += digiFile;
  
  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo* parInput1 = new FairParRootFileIo();
  parInput1->open(parFile.Data());
  
  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
  parIo1->open(allDigiFile.Data(),"in");
        
  rtdb->setFirstInput(parInput1);
  rtdb->setSecondInput(parIo1);
  
  // -----   STT digi producers   ---------------------------------
  PndSttHitProducerRealFast* sttHitProducer = new PndSttHitProducerRealFast();
  fRun->AddTask(sttHitProducer);
  
  // -----   MDV digi producers   ---------------------------------
  PndMvdDigiTask* mvddigi = new PndMvdDigiTask();
  mvddigi->SetVerbose(iVerbose);
  fRun->AddTask(mvddigi);

  PndMvdClusterTask* mvdmccls = new PndMvdClusterTask();
  mvdmccls->SetVerbose(iVerbose);
  fRun->AddTask(mvdmccls);

  // -----   EMC hit producers   ---------------------------------
  PndEmcHitsToWaveform* emcHitsToWaveform= new PndEmcHitsToWaveform(iVerbose);
  PndEmcWaveformToDigi* emcWaveformToDigi=new PndEmcWaveformToDigi(iVerbose);
  emcHitsToWaveform->SetStorageOfData(kFALSE);
  //emcWaveformToDigi->SetStorageOfData(kFALSE);
  fRun->AddTask(emcHitsToWaveform);  // full digitization
  fRun->AddTask(emcWaveformToDigi);  // full digitization

  PndEmcMakeCluster* emcMakeCluster= new PndEmcMakeCluster(iVerbose);
  fRun->AddTask(emcMakeCluster);

  PndEmcMakeBump* emcMakeBump= new PndEmcMakeBump();
  fRun->AddTask(emcMakeBump);

  //PndEmcHdrFiller* emcHdrFiller = new PndEmcHdrFiller();
  //fRun->AddTask(emcHdrFiller); // ECM header

  // -----   SciT hit producers   ---------------------------
  PndSciTHitProducerIdeal* tofhit = new PndSciTHitProducerIdeal();
  tofhit->SetVerbose(iVerbose);
  fRun->AddTask(tofhit);

  // -----   MDT hit producers   ---------------------------------
  PndMdtHitProducerIdeal* mdtHitProd = new PndMdtHitProducerIdeal();
  mdtHitProd->SetPositionSmearing(.3); // position smearing [cm]
  fRun->AddTask(mdtHitProd);

  PndMdtTrkProducer* mdtTrkProd = new PndMdtTrkProducer();
  fRun->AddTask(mdtTrkProd);

  // -----   DRC hit producers   ---------------------------------
  PndDrcHitProducerReal* drchit = new PndDrcHitProducerReal();
  drchit->SetVerbose(iVerbose);
  fRun->AddTask(drchit);

  // -----   GEM hit producers   ---------------------------------
  Int_t verboseLevel = 0;
  PndGemDigitize* gemDigitize = new PndGemDigitize("GEM Digitizer", verboseLevel);
  fRun->AddTask(gemDigitize);

  PndGemFindHits* gemFindHits = new PndGemFindHits("GEM Hit Finder", verboseLevel);
  fRun->AddTask(gemFindHits);

  // -----   FTS hit producers   ---------------------------------
  PndFtsHitProducerRealFast* ftsHitProducer = new PndFtsHitProducerRealFast();
  fRun->AddTask(ftsHitProducer);

  // -----   Ftof hit producers   ---------------------------
  PndFtofHitProducerIdeal* ftofhit = new PndFtofHitProducerIdeal();
  ftofhit->SetVerbose(iVerbose);
  fRun->AddTask(ftofhit);

  // -----   Intialise and run   --------------------------------------------
  fRun->Init();

  timer.Start();
  fRun->Run();

  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished successfully." << endl;
  cout << "Output file is "    << outFile << endl;
  cout << "Parameter file is " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
  cout << endl;
  // ------------------------------------------------------------------------
  cout << " Test passed" << endl;
  cout << " All ok " << endl;

  exit(0);
}
Esempio n. 10
0
void prod_rec(TString outpre="")
{
  // Macro created 20/09/2006 by S.Spataro
  // It loads a digi file and performs tracking

  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
  Int_t iVerbose = 0; // just forget about it, for the moment
  
	// Number of events to process
  Int_t nEvents = 0;  // if 0 all the vents will be processed
  
  // Parameter file
  TString parFile = outpre+"_par.root"; // at the moment you do not need it
  
  // Digitisation file (ascii)
  TString digiFile = "all.par";
  
  // Output file
  TString outFile = outpre+"_rec.root";
  
  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;
    // ------------------------------------------------------------------------
  
  // -----   Reconstruction run   -------------------------------------------
  FairRunAna *fRun= new FairRunAna();
  fRun->SetInputFile(outpre+"_sim.root");
  fRun->AddFriend(outpre+"_dig.root");
  fRun->SetOutputFile(outFile);
  fRun->SetGenerateRunInfo(kFALSE);
  fRun->SetUseFairLinks(kTRUE);
  FairGeane *Geane = new FairGeane();
  fRun->AddTask(Geane);

  // -----  Parameter database   --------------------------------------------
  TString emcDigiFile = gSystem->Getenv("VMCWORKDIR");
  emcDigiFile += "/macro/params/";
  emcDigiFile += digiFile;
  
  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo* parInput1 = new FairParRootFileIo();
  parInput1->open(parFile.Data());
  
  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
  parIo1->open(emcDigiFile.Data(),"in");
        
  rtdb->setFirstInput(parInput1);
  rtdb->setSecondInput(parIo1);

  // ------------------------------------------------------------------------
  //  use the constructor with input :
  //      printout flag (int) , plotting flag (bool), MC comparison flag (bool), SciTil.
  PndTrkTracking2* tracking = new PndTrkTracking2(0,false,false,true);
  tracking->SetInputBranchName("STTHit","MVDHitsPixel","MVDHitsStrip");
  // tracking->SetInputBranchName("STTHitMix","MVDHitsPixelMix","MVDHitsStripMix");
  //  don't do the Pattern Recognition second part, starting from the Mvd;
  tracking->NoMvdAloneTracking();
  // do Cleanup only when there is Mixing;
  // tracking->Cleanup();
  tracking->SetPersistence(kFALSE);
  fRun->AddTask(tracking);

  PndSttMvdGemTracking * SttMvdGemTracking = new PndSttMvdGemTracking(0);
  //SttMvdGemTracking->SetPdgFromMC();
  SttMvdGemTracking->SetPersistence(kFALSE);
  fRun->AddTask(SttMvdGemTracking);
  
  PndMCTrackAssociator* trackMC = new PndMCTrackAssociator();
  trackMC->SetTrackInBranchName("SttMvdGemTrack");
  trackMC->SetTrackOutBranchName("SttMvdGemTrackID");
  trackMC->SetPersistence(kFALSE);
  fRun->AddTask(trackMC);

  PndRecoKalmanTask* recoKalman = new PndRecoKalmanTask();
  recoKalman->SetTrackInBranchName("SttMvdGemTrack");
//  recoKalman->SetTrackInIDBranchName("SttMvdGemTrackID");
  recoKalman->SetTrackOutBranchName("SttMvdGemGenTrack");
  recoKalman->SetBusyCut(50); // CHECK to be tuned
  //recoKalman->SetIdealHyp(kTRUE);
  //recoKalman->SetNumIterations(3);
  recoKalman->SetTrackRep(0); // 0 Geane (default), 1 RK
  //recoKalman->SetPropagateToIP(kFALSE);
  fRun->AddTask(recoKalman);

  PndMCTrackAssociator* trackMC2 = new PndMCTrackAssociator();
  trackMC2->SetTrackInBranchName("SttMvdGemGenTrack"); 
  trackMC2->SetTrackOutBranchName("SttMvdGemGenTrackID");
  fRun->AddTask(trackMC2);
 
  PndFtsTrackerIdeal* trackFts = new PndFtsTrackerIdeal();
  trackFts->SetRelativeMomentumSmearing(0.05);
  trackFts->SetVertexSmearing(0.05, 0.05, 0.05);
  trackFts->SetTrackingEfficiency(1.);
  trackFts->SetTrackOutput("FtsIdealTrack");
  trackFts->SetPersistence(kFALSE);
  fRun->AddTask(trackFts);

  PndMCTrackAssociator* trackMCfwd = new PndMCTrackAssociator();
  trackMCfwd->SetTrackInBranchName("FtsIdealTrack");
  trackMCfwd->SetTrackOutBranchName("FtsIdealTrackID");
  fRun->AddTask(trackMCfwd);

  PndRecoKalmanTask* recoKalmanFwd = new PndRecoKalmanTask();
  recoKalmanFwd->SetTrackInBranchName("FtsIdealTrack");
  //recoKalmanFwd->SetTrackInIDBranchName("FtsIdealTrackID");
  recoKalmanFwd->SetTrackOutBranchName("FtsIdealGenTrack");
  recoKalmanFwd->SetBusyCut(50); // CHECK to be tuned
  //recoKalmanFwd->SetIdealHyp(kTRUE);
  //recoKalmanFwd->SetNumIterations(3);
  recoKalmanFwd->SetTrackRep(0); // 0 Geane (default), 1 RK
  //recoKalmanFwd->SetPropagateToIP(kFALSE);
  fRun->AddTask(recoKalmanFwd);

  PndMCTrackAssociator* trackMC3 = new PndMCTrackAssociator();
  trackMC3->SetTrackInBranchName("FtsIdealGenTrack");
  trackMC3->SetTrackOutBranchName("FtsIdealGenTrackID");
  fRun->AddTask(trackMC3);

  // -----   Intialise and run   --------------------------------------------
  PndEmcMapper::Init(1);
  cout << "fRun->Init()" << endl;
  fRun->Init();

  timer.Start();
  fRun->Run(0,nEvents);
  // ------------------------------------------------------------------------


  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished successfully." << endl;
  cout << "Output file is "    << outFile << endl;
  cout << "Parameter file is " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
  cout << endl;
  // ------------------------------------------------------------------------
  cout << " Test passed" << endl;
  cout << " All ok " << endl;
  //exit(0);
}
Esempio n. 11
0
void comparison_cov_firstpar(int nevts=0, TString Path=""){

  TDatabasePDG::Instance()-> AddParticle("pbarpSystem","pbarpSystem", 1.9, kFALSE, 0.1, 0,"", 88888);

  TStopwatch timer;

  //Output File
  TString outPath = Path;
  TString OutputFile = "cov_output.root";

  //Input simulation Files
  TString DigiFile  = Path + "digi_complete.root";
  TString RecoFile  = Path + "reco_complete.root";
  TString inPIDFile = Path + "pid_complete.root";
  TString inParFile = Path + "simparams.root";
  TString PIDParFile = TString( gSystem->Getenv("VMCWORKDIR")) + "/macro/params/all.par";


  //Initialization
  FairLogger::GetLogger()->SetLogToFile(kFALSE);
  FairRunAna* RunAna = new FairRunAna();
  FairRuntimeDb* rtdb = RunAna->GetRuntimeDb();
  RunAna->SetInputFile(inPIDFile);

  //setup parameter database
  FairParRootFileIo* parIo = new FairParRootFileIo();
  parIo->open(inParFile);
  FairParAsciiFileIo* parIoPID = new FairParAsciiFileIo();
  parIoPID->open(PIDParFile.Data(),"in");

  rtdb->setFirstInput(parIo);
  rtdb->setSecondInput(parIoPID);
  rtdb->setOutput(parIo);

  RunAna->AddFriend(DigiFile);
  RunAna->AddFriend(RecoFile);
  RunAna->SetOutputFile(OutputFile);
  RunAna->Init();


  // data reader Object
  PndAnalysis* theAnalysis = new PndAnalysis();
  if (nevts==0) nevts = theAnalysis->GetEntries();

  RhoCandList piminus, proton;


  TMatrixD CovPion(5,5);
  TMatrixD CovProton(5,5);

	int evt=-1;
	while (theAnalysis->GetEvent() && ++evt<nevts){
		cout << "evt: " << evt << endl;

		TString PidSelection = "PidAlgoIdealCharged";//"PidAlgoMvd;PidAlgoStt;PidAlgoDrc";


		//***Selection with no PID info
		theAnalysis->FillList(piminus, "PionAllMinus", PidSelection);
		theAnalysis->FillList(proton, "ProtonAllPlus", PidSelection);


		//Get piminus

		for (int j=0; j<piminus.GetLength(); ++j){

			bool truth = theAnalysis->McTruthMatch(piminus[j]);

			if(truth){

				TMatrixD piCov(7,7);
				piCov = piminus[j]->Cov7();


				FairTrackParP paramFirst = theAnalysis->GetFirstPar(piminus[j]);

				double cov[15];
				paramFirst.GetCov(cov);

				for (int i=0; i<15; i++){
					if(TMath::Abs(cov[i]<1e-6)) cov[i]=0;
				}

				CovPion[0][0] = cov[0];
				CovPion[0][1] = cov[1];
				CovPion[0][2] = cov[2];
				CovPion[0][3] = cov[3];
				CovPion[0][4] = cov[4];

				CovPion[1][1] = cov[5];
				CovPion[1][2] = cov[6];
				CovPion[1][3] = cov[7];
				CovPion[1][4] = cov[8];

				CovPion[2][2] = cov[9];
				CovPion[2][3] = cov[10];
				CovPion[2][4] = cov[11];

				CovPion[3][3] = cov[12];
				CovPion[3][4] = cov[13];

				CovPion[4][4] = cov[14];

				for (int i=0; i<5; i++){
					for(int j=0; j<5; j++){
						CovPion[j][i]=CovPion[i][j];
					}
				}

				cout << "Covariance matrix for pion: " << endl;

				for(int i=0; i<7; i++){
					for(int j=0; j<7; j++){
						if(TMath::Abs(piCov[i][j])<1e-6) piCov[i][j]=0;
					}
				}
				piCov.Print();

				cout << "First Par Covariance matrix for pion: " << endl;
				CovPion.Print();

			}

			//Get proton

			for (int j=0; j<proton.GetLength(); ++j){

				bool truth = theAnalysis->McTruthMatch(proton[j]);

				if(truth){
					TMatrixD protCov = proton[j]->Cov7();

					FairTrackParP paramFirst = theAnalysis->GetFirstPar(proton[j]);

					double cov[15];
					paramFirst.GetCov(cov);

					for (int i=0; i<15; i++){
						if(TMath::Abs(cov[i]<1e-6)) cov[i]=0;
					}

					CovProton[0][0] = cov[0];
					CovProton[0][1] = cov[1];
					CovProton[0][2] = cov[2];
					CovProton[0][3] = cov[3];
					CovProton[0][4] = cov[4];

					CovProton[1][1] = cov[5];
					CovProton[1][2] = cov[6];
					CovProton[1][3] = cov[7];
					CovProton[1][4] = cov[8];

					CovProton[2][2] = cov[9];
					CovProton[2][3] = cov[10];
					CovProton[2][4] = cov[11];

					CovProton[3][3] = cov[12];
					CovProton[3][4] = cov[13];

					CovProton[4][4] = cov[14];

					for (int i=0; i<5; i++){
						for(int j=0; j<5; j++){
							CovProton[j][i]=CovProton[i][j];
						}
					}

					cout << "Covariance matrix for proton: " << endl;

					for(int i=0; i<7; i++){
						for(int j=0; j<7; j++){
							if(TMath::Abs(protCov[i][j])<1e-6) protCov[i][j]=0;
						}
					}
					protCov.Print();

					cout << "First Par Covariance matrix for proton: " << endl;
					CovProton.Print();
				}
			}

		}
	}
}
Esempio n. 12
0
void pid_complete_sec(TString pre="")
{
  // Macro created 02/10/2012 by S.Spataro
  // It loads a reconstruction file and compute PID informations

  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
  Int_t iVerbose = 0; // just forget about it, for the moment
  
	// Number of events to process
  Int_t nEvents = 0;  // if 0 all the vents will be processed
  
  
  if (pre == ""){
	  TString inputFile = "sim_complete.root";
	  TString digFile = "digi_complete.root";
	  TString recoFile = "reco_complete_sec.root";



	  // Parameter file
	  TString parFile = "simparams.root"; // at the moment you do not need it

	  // Digitisation file (ascii)
	  TString digiFile = "all.par";

	  // Output file
	  TString outFile = "pid_complete_sec.root";
  }
  
  else{
	  TString inputFile = pre + "_sim_complete.root";
	  TString digFile = pre + "_digi_complete.root";
	  TString recoFile = pre + "_reco_complete_sec.root";



	  // Parameter file
	  TString parFile = pre + "_simparams.root"; // at the moment you do not need it

	  // Digitisation file (ascii)
	  TString digiFile = "all.par";

	  // Output file
	  TString outFile = pre + "_pid_complete_sec.root";
  }

  
  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;
    // ------------------------------------------------------------------------
  
  // -----   Reconstruction run   -------------------------------------------
  FairRunAna *fRun= new FairRunAna();
  fRun->SetInputFile(inputFile);
  fRun->AddFriend(digFile);
  fRun->AddFriend(recoFile);
  fRun->SetOutputFile(outFile);
  fRun->SetGenerateRunInfo(kFALSE);
  fRun->SetUseFairLinks(kTRUE);
  FairGeane *Geane = new FairGeane();
  fRun->AddTask(Geane);

  // -----  Parameter database   --------------------------------------------
  TString emcDigiFile = gSystem->Getenv("VMCWORKDIR");
  emcDigiFile += "/macro/params/";
  emcDigiFile += digiFile;
  
  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo* parInput1 = new FairParRootFileIo();
  parInput1->open(parFile.Data());
  
  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
  parIo1->open(emcDigiFile.Data(),"in");
        
  rtdb->setFirstInput(parInput1);
  rtdb->setSecondInput(parIo1);

  // ------------------------------------------------------------------------

  PndPidCorrelator* corr = new PndPidCorrelator();
  //corr->SetVerbose();
  corr->SetInputBranch("SttMvdGemGenTrack");
  corr->SetInputIDBranch("SttMvdGemGenTrackID");
  corr->SetInputBranch2("FtsIdealGenTrack");
  corr->SetInputIDBranch2("FtsIdealGenTrackID");
  //corr->SetDebugMode(kTRUE);
  //corr->SetFast(kTRUE);
  corr->SetBackPropagate(kFALSE);
  fRun->AddTask(corr);

  PndPidBremCorrector *bremCorr = new PndPidBremCorrector();
  fRun->AddTask(bremCorr);

  PndMcCloner *clone = new PndMcCloner();
  fRun->AddTask(clone);
 
  PndPidIdealAssociatorTask *assMC= new PndPidIdealAssociatorTask();
  fRun->AddTask(assMC);

  PndPidMvdAssociatorTask *assMvd= new PndPidMvdAssociatorTask();
  fRun->AddTask(assMvd);

  PndPidMdtHCAssociatorTask *assMdt= new PndPidMdtHCAssociatorTask();
  fRun->AddTask(assMdt);

  PndPidDrcAssociatorTask *assDrc= new PndPidDrcAssociatorTask();
  fRun->AddTask(assDrc);

  PndPidDiscAssociatorTask *assDisc= new PndPidDiscAssociatorTask();
  fRun->AddTask(assDisc);

  PndPidSttAssociatorTask *assStt= new PndPidSttAssociatorTask();
  fRun->AddTask(assStt);

  PndPidEmcBayesAssociatorTask *assEMC= new PndPidEmcBayesAssociatorTask();
  fRun->AddTask(assEMC);

  // -----   Intialise and run   --------------------------------------------
  PndEmcMapper::Init(1);
  cout << "fRun->Init()" << endl;
  fRun->Init();

  timer.Start();
  fRun->Run(0,nEvents);
  // ------------------------------------------------------------------------


  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished successfully." << endl;
  cout << "Output file is "    << outFile << endl;
  cout << "Parameter file is " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
  cout << endl;
  // ------------------------------------------------------------------------
  cout << " Test passed" << endl;
  cout << " All ok " << endl;
  exit(0);
}
Esempio n. 13
0
void rec(Int_t file_nr=0, Int_t nEvents=1, Int_t s=0){
  Char_t filenr[4];
  sprintf(filenr,"%04d",file_nr);
  printf("Filenr: %s\n", filenr);

  TString signal;
  if (s!=3312 && s!=3334) signal = "la";
  else if (s==3312) signal = "xi";
  else if (s==3334) signal = "om";

  // ----- Paths and file names  --------------------------------------------
  TString inDir = TString(filenr);
  inDir+="/";
  TString mcFile   = inDir+signal+".mc.root";
  TString parFile  = inDir+signal+".par.root";
  TString rcFile   = inDir+signal+".rc.root";
  TString digiFile = "sts_Standard_s3055AAFK5.SecD.digi.par";

  Int_t iVerbose = 1;
  TStopwatch timer;
  timer.Start();

  // ----  Load libraries   -------------------------------------------------
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
  basiclibs();
  gROOT->LoadMacro("$VMCWORKDIR/analysis/hyperon/analysislibs.C");
  analysislibs();
  // ------------------------------------------------------------------------

  // -----   Reconstruction run   -------------------------------------------
  FairRunAna* run= new FairRunAna();
  run->SetInputFile(mcFile);
  run->SetOutputFile(rcFile);
  // ------------------------------------------------------------------------

  // -----   STS digitiser   ------------------------------------------------
  FairTask* stsDigitize = new CbmStsDigitize("STSDigitize", iVerbose);
  run->AddTask(stsDigitize);
  // ------------------------------------------------------------------------

  // ---  STS hit finding   -------------------------------------------------
  FairTask* findHits = new CbmStsFindHits("STSFindHits", iVerbose);
  run->AddTask(findHits);
  // ------------------------------------------------------------------------

  // ---  STS hit matching   ------------------------------------------------
  FairTask* matchHits = new CbmStsMatchHits("STSMatchHits",
          iVerbose);
  run->AddTask(matchHits);
  // ------------------------------------------------------------------------


  // -----   STS track finding   --------------------------------------------
  FairTask* kalman= new CbmKF();
  run->AddTask(kalman);
  FairTask* l1 = new CbmL1();
  run->AddTask(l1);
  CbmStsTrackFinder* trackFinder    = new CbmL1StsTrackFinder();
  FairTask* findTracks = new CbmStsFindTracks(iVerbose, trackFinder);
  run->AddTask(findTracks);
  // ------------------------------------------------------------------------


  // -----   STS track matching   -------------------------------------------
  FairTask* matchTracks = new CbmStsMatchTracks("Match tracks", iVerbose);
  run->AddTask(matchTracks);
  // ------------------------------------------------------------------------

  // -----   STS track fitting   --------------------------------------------
  CbmStsTrackFitter* trackFitter = new CbmStsKFTrackFitter();
  FairTask* fitTracks = new CbmStsFitTracks("STS Track Fitter", trackFitter, iVerbose);
  run->AddTask(fitTracks);
  // ------------------------------------------------------------------------

  // -----   Primary vertex finder   ----------------------------------------
  CbmPVFinderKF *vfinder = new CbmPVFinderKF();
  FairTask *vTask = new CbmFindPrimaryVertex("PV finder", "FairTask", vfinder);
  run->AddTask(vTask);
  // ------------------------------------------------------------------------


  // -----  Parameter database   --------------------------------------------
  TString stsDigiFile = gSystem->Getenv("VMCWORKDIR");
  stsDigiFile += "/parameters/sts/";
  stsDigiFile += digiFile;
  FairRuntimeDb* rtdb = run->GetRuntimeDb();
  FairParRootFileIo*  parIo1 = new FairParRootFileIo();
  FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
  parIo1->open(parFile.Data());
  parIo2->open(stsDigiFile.Data(),"in");
  rtdb->setFirstInput(parIo1);
  rtdb->setSecondInput(parIo2);
  rtdb->setOutput(parIo1);
  rtdb->saveOutput();
  // ------------------------------------------------------------------------

  // -----   Initialise and run   -------------------------------------------
  run->LoadGeometry();
  run->Init();
  run->Run(0, nEvents);
  // ------------------------------------------------------------------------

  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished succesfully." << endl;
  cout << "Output file is "         << rcFile << endl;
  cout << "Parameter file is "      << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
  cout << endl;
  // ------------------------------------------------------------------------
}
Esempio n. 14
0
void global_reco104(Int_t nEvents = 100, // number of events
	Int_t seed = 555)
{
	gRandom->SetSeed(seed);

	TString script = TString(gSystem->Getenv("LIT_SCRIPT"));
	TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters");

   // Input and output data
   //TString dir = "/Users/andrey/Development/cbm/d/events/sts_tof/"; // Output directory
   TString dir = "data/"; // Output directory
   TString mcFile = dir + "auaumbias4.mc.root"; // MC transport file
   TString parFile = dir + "auaumbias4.params.root"; // Parameters file
   TString globalRecoFile = dir + "auaumbias4.global.reco.root"; // Output file with reconstructed tracks and hits

   // Digi files
   TList *parFileList = new TList();
   TObjString stsDigiFile = parDir + "/sts/sts_v12b_std.digi.par"; // STS digi file
   TString stsMatBudgetFileName = parDir + "/sts/sts_matbudget_v12b.root";

   TString TofGeoPar = "/parameters/tof/par_tof_V12a.txt";  // 10 m version 

   // Directory for output results
   TString resultDir = "./data/auaumbias104/";

   // Reconstruction parameters
   TString globalTrackingType = "branch"; // Global tracking type
   TString stsHitProducerType = "real"; // STS hit producer type: real, ideal

   // Normalization for efficiency
   Int_t normStsPoints = 4;
   Int_t normTrdPoints = 0;
   Int_t normMuchPoints = 0;
   Int_t normTofPoints = 1;
   Int_t normTrdHits = 0;
   Int_t normMuchHits = 0;
   Int_t normTofHits = 1;

	if (script == "yes") {
		mcFile = TString(gSystem->Getenv("LIT_MC_FILE"));
		parFile = TString(gSystem->Getenv("LIT_PAR_FILE"));
		globalRecoFile = TString(gSystem->Getenv("LIT_GLOBAL_RECO_FILE"));
		resultDir = TString(gSystem->Getenv("LIT_RESULT_DIR"));
	}

	parFileList->Add(&stsDigiFile);

	Int_t iVerbose = 1;
	TStopwatch timer;
	timer.Start();

	gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C");
	loadlibs();
	gSystem->Load("libHadron");

	FairRunAna *run = new FairRunAna();
	run->SetInputFile(mcFile);
	run->SetOutputFile(globalRecoFile);

	// ----- STS REAL reconstruction -----------------------------------------------
	// -----   STS digitizer   -------------------------------------------------
	Double_t threshold  =  4;
	Double_t noiseWidth =  0.01;
	Int_t    nofBits    = 12;
	Double_t ElectronsPerAdc    =  10.;
	Double_t StripDeadTime = 0.1;
	CbmStsDigitize* stsDigitize = new CbmStsDigitize("STS Digitiser", iVerbose);
	stsDigitize->SetRealisticResponse();
	stsDigitize->SetFrontThreshold (threshold);
	stsDigitize->SetBackThreshold  (threshold);
	stsDigitize->SetFrontNoiseWidth(noiseWidth);
	stsDigitize->SetBackNoiseWidth (noiseWidth);
	stsDigitize->SetFrontNofBits   (nofBits);
	stsDigitize->SetBackNofBits    (nofBits);
	stsDigitize->SetFrontNofElPerAdc  (ElectronsPerAdc);
	stsDigitize->SetBackNofElPerAdc   (ElectronsPerAdc);
	stsDigitize->SetStripDeadTime  (StripDeadTime);
	run->AddTask(stsDigitize);
	// -------------------------------------------------------------------------

	 FairTask* stsClusterFinder = new CbmStsClusterFinder("STS Cluster Finder",iVerbose);
	 run->AddTask(stsClusterFinder);

	 FairTask* stsFindHits = new CbmStsFindHits("STS Hit Finder", iVerbose);
	 run->AddTask(stsFindHits);

	 FairTask* stsMatchHits = new CbmStsMatchHits("STS Hit Matcher", iVerbose);
	 run->AddTask(stsMatchHits);


	FairTask* kalman = new CbmKF();
	run->AddTask(kalman);
	CbmL1* l1 = new CbmL1();
        l1->SetMaterialBudgetFileName(stsMatBudgetFileName);
	run->AddTask(l1);
	CbmStsTrackFinder* trackFinder = new CbmL1StsTrackFinder();
	FairTask* findTracks = new CbmStsFindTracks(iVerbose, trackFinder);
	run->AddTask(findTracks);

	FairTask* stsMatchTracks = new CbmStsMatchTracks("STSMatchTracks", iVerbose);
	run->AddTask(stsMatchTracks);

	// ------------------------------------------------------------------------


	// ------ TOF hits --------------------------------------------------------
	CbmTofHitProducer* tofHitProd = new CbmTofHitProducer("TOF HitProducer", 1);
        tofHitProd->SetParFileName(std::string(TofGeoPar));

	run->AddTask(tofHitProd);
	// ------------------------------------------------------------------------

	// ------ Global track reconstruction -------------------------------------
	CbmLitFindGlobalTracks* finder = new CbmLitFindGlobalTracks();
	// Tracking method to be used
	// "branch" - branching tracking
	// "nn" - nearest neighbor tracking
	// "nn_parallel" - nearest neighbor parallel tracking
	finder->SetTrackingType(std::string(globalTrackingType));

	// Hit-to-track merger method to be used
	// "nearest_hit" - assigns nearest hit to the track
	finder->SetMergerType("nearest_hit");

	run->AddTask(finder);
	// ------------------------------------------------------------------------

	// ------------------------------------------------------------------------
        CbmRichHitProducer* richHitProd  = new CbmRichHitProducer();
	//run->AddTask(richHitProd);

        CbmRichReconstruction* richReco = new CbmRichReconstruction();
	//run->AddTask(richReco);

        CbmRichMatchRings* matchRings = new CbmRichMatchRings();
	//run->AddTask(matchRings);
        // ------------------------------------------------------------------------


	// -----   Primary vertex finding   ---------------------------------------
	CbmPrimaryVertexFinder* pvFinder = new CbmPVFinderKF();
	CbmFindPrimaryVertex* findVertex = new CbmFindPrimaryVertex(pvFinder);
	run->AddTask(findVertex);
	// ------------------------------------------------------------------------


	// -----   Track finding QA check   ------------------------------------
	CbmLitTrackingQa* trackingQa = new CbmLitTrackingQa();
	trackingQa->SetMinNofPointsSts(normStsPoints);
	trackingQa->SetMinNofPointsTrd(normTrdPoints);
	trackingQa->SetMinNofPointsMuch(normMuchPoints);
	trackingQa->SetMinNofPointsTof(normTofPoints);
	trackingQa->SetQuota(0.7);
	trackingQa->SetMinNofHitsTrd(normTrdHits);
	trackingQa->SetMinNofHitsMuch(normMuchHits);
	trackingQa->SetMinNofHitsRich(7);
	trackingQa->SetQuotaRich(0.6);
	trackingQa->SetVerbose(normTofHits);
	trackingQa->SetOutputDir(std::string(resultDir));
	run->AddTask(trackingQa);
	// ------------------------------------------------------------------------

	CbmLitFitQa* fitQa = new CbmLitFitQa();
	fitQa->SetMvdMinNofHits(0);
	fitQa->SetStsMinNofHits(normStsPoints);
	fitQa->SetMuchMinNofHits(normMuchPoints);
	fitQa->SetTrdMinNofHits(normTrdPoints);
	fitQa->SetOutputDir(std::string(resultDir));
	run->AddTask(fitQa);

	CbmLitClusteringQa* clusteringQa = new CbmLitClusteringQa();
	clusteringQa->SetOutputDir(std::string(resultDir));
	run->AddTask(clusteringQa);

	CbmProduceDst *produceDst = new CbmProduceDst(); // in hadron
	run->AddTask(produceDst);

	CbmHadronAnalysis *HadronAna = new CbmHadronAnalysis(); // in hadron
	run->AddTask(HadronAna);

	// -----  Parameter database   --------------------------------------------
	FairRuntimeDb* rtdb = run->GetRuntimeDb();
	FairParRootFileIo* parIo1 = new FairParRootFileIo();
	FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
	parIo1->open(parFile.Data());
	parIo2->open(parFileList, "in");
	rtdb->setFirstInput(parIo1);
	rtdb->setSecondInput(parIo2);
	rtdb->setOutput(parIo1);
	rtdb->saveOutput();
	// ------------------------------------------------------------------------

	// -----   Initialize and run   --------------------------------------------
	run->Init();
	run->Run(0, nEvents);
	// ------------------------------------------------------------------------

	// -----   Finish   -------------------------------------------------------
	timer.Stop();
	cout << endl << endl;
 	cout << "Macro finished successfully." << endl;
   cout << "Test passed"<< endl;
   cout << " All ok " << endl;
	cout << "Output file is " << globalRecoFile << endl;
	cout << "Parameter file is " << parFile << endl;
	cout << "Real time " << timer.RealTime() << " s, CPU time "	<< timer.CpuTime() << " s" << endl;
	cout << endl;
	// ------------------------------------------------------------------------
}
Esempio n. 15
0
void tut_ana_mclist(int nevts=0)
{
	// *** some variables
	int i=0,j=0, k=0, l=0;

	TString OutFile="output.root";

	// *** the files coming from the simulation
	TString inPidFile = "pid_complete.root";    // this file contains the PndPidCandidates and McTruth
	TString inParFile = "simparams.root";

	gStyle->SetOptFit(1011);

	// *** PID table with selection thresholds; can be modified by the user
	TString pidParFile = TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all.par";

	// *** initialization
	FairLogger::GetLogger()->SetLogToFile(kFALSE);
	FairRunAna* fRun = new FairRunAna();
	FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
	fRun->SetInputFile(inPidFile);

	// *** setup parameter database
	FairParRootFileIo* parIO = new FairParRootFileIo();
	parIO->open(inParFile);
	FairParAsciiFileIo* parIOPid = new FairParAsciiFileIo();
	parIOPid->open(pidParFile.Data(),"in");

	rtdb->setFirstInput(parIO);
	rtdb->setSecondInput(parIOPid);
	rtdb->setOutput(parIO);

	fRun->SetOutputFile(OutFile);
	fRun->Init();

	//
	// Now the analysis stuff comes...
	//


	// *** the data reader object
	PndAnalysis* theAnalysis = new PndAnalysis();
	if (nevts==0) nevts= theAnalysis->GetEntries();

	// *** RhoCandLists for the analysis
	RhoCandList mctruth;

	// ***
	// the event loop
	// ***
	while (theAnalysis->GetEvent() && i++<nevts)
	{
		cout<<"****** Evt " << i << endl;

		// *** the MC Truth objects
		theAnalysis->FillList(mctruth,"McTruth");

		//
		// Print MC Truth list with mother-daughter relations
		//
		for (j=0;j<mctruth.GetLength();++j)
		{
			RhoCandidate *mcmother = mctruth[j]->TheMother();

		  	int muid = -1;
		  	if (mcmother) muid = mcmother->GetTrackNumber();

		  	cout << "Track "<< mctruth[j]->GetTrackNumber()<<" (PDG:"<<mctruth[j]->PdgCode() <<") has mother "<<muid;

		  	if (mctruth[j]->NDaughters()>0) cout <<" and daughter(s) ";
		  	for (k=0;k<mctruth[j]->NDaughters();++k) cout <<mctruth[j]->Daughter(k)->GetTrackNumber()<<"  ";

		  	cout<<endl;
		}
		cout <<endl;
	}

}
Esempio n. 16
0
void global_reco(Int_t nEvents = 100, Int_t seed = 555)
{
	gRandom->SetSeed(seed);

   TTree::SetMaxTreeSize(90000000000);
   TString script = TString(gSystem->Getenv("LIT_SCRIPT"));
   TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters");

   // Input and output data
   TString dir = "events/much_anna_omega_8gev_10k/"; // Output directory
   TString mcFile = dir + "mc.0000.root"; // MC transport file
   TString parFile = dir + "param.0000.root"; // Parameters file
   TString globalRecoFile = dir + "global.reco.0000.root"; // Output file with reconstructed tracks and hits

   // Digi files
   TList* parFileList = new TList();
   TObjString stsDigiFile = parDir + "/sts/sts_v12b_std.digi.par"; // STS digi file
   TObjString trdDigiFile = parDir + "/trd/trd_v13g.digi.par"; // TRD digi file
   TString muchDigiFile = parDir + "/much/much_v12c.digi.root"; // MUCH digi file
   TString stsMatBudgetFile = parDir + "/sts/sts_matbudget_v12b.root";
   TObjString tofDigiFile = parDir + "/tof/tof_v13b.digi.par";// TOF digi file

   // Reconstruction parameters
   TString globalTrackingType = "nn"; // Global tracking type
   TString trdHitProducerType = "smearing"; // TRD hit producer type: smearing, digi, clustering
   TString muchHitProducerType = "advanced"; // MUCH hit producer type: simple, advanced

   if (script == "yes") {
      mcFile = TString(gSystem->Getenv("LIT_MC_FILE"));
      parFile = TString(gSystem->Getenv("LIT_PAR_FILE"));
      globalRecoFile = TString(gSystem->Getenv("LIT_GLOBAL_RECO_FILE"));

      stsDigiFile = TString(gSystem->Getenv("LIT_STS_DIGI"));
      trdDigiFile = TString(gSystem->Getenv("LIT_TRD_DIGI"));
      muchDigiFile = TString(gSystem->Getenv("LIT_MUCH_DIGI"));
      tofDigiFile = TString(gSystem->Getenv("LIT_TOF_DIGI"));
      stsMatBudgetFile = TString(gSystem->Getenv("LIT_STS_MAT_BUDGET_FILE"));
   }

   parFileList->Add(&stsDigiFile);
   parFileList->Add(&trdDigiFile);
   parFileList->Add(&tofDigiFile);

	Int_t iVerbose = 1;
	TStopwatch timer;
	timer.Start();

	gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C");
	loadlibs();

	FairRunAna *run = new FairRunAna();
   run->SetInputFile(mcFile);
	run->SetOutputFile(globalRecoFile);


   // -----   STS  -------------------------------------------------
   Double_t threshold = 4;
   Double_t noiseWidth = 0.01;
   Int_t nofBits = 12;
   Double_t ElectronsPerAdc =  10.;
   Double_t StripDeadTime = 0.1;
   CbmStsDigitize* stsDigitize = new CbmStsDigitize("STS Digitiser", iVerbose);
   stsDigitize->SetRealisticResponse();
   stsDigitize->SetFrontThreshold(threshold);
   stsDigitize->SetBackThreshold(threshold);
   stsDigitize->SetFrontNoiseWidth(noiseWidth);
   stsDigitize->SetBackNoiseWidth(noiseWidth);
   stsDigitize->SetFrontNofBits(nofBits);
   stsDigitize->SetBackNofBits(nofBits);
   stsDigitize->SetFrontNofElPerAdc(ElectronsPerAdc);
   stsDigitize->SetBackNofElPerAdc(ElectronsPerAdc);
   stsDigitize->SetStripDeadTime(StripDeadTime);
   run->AddTask(stsDigitize);

   FairTask* stsClusterFinder = new CbmStsClusterFinder("STS Cluster Finder",iVerbose);
   run->AddTask(stsClusterFinder);

   FairTask* stsFindHits = new CbmStsFindHits("STS Hit Finder", iVerbose);
   run->AddTask(stsFindHits);

   FairTask* stsMatchHits = new CbmStsMatchHits("STS Hit Matcher", iVerbose);
   run->AddTask(stsMatchHits);

   FairTask* kalman = new CbmKF();
   run->AddTask(kalman);
   CbmL1* l1 = new CbmL1();
   //l1->SetExtrapolateToTheEndOfSTS(true);
   l1->SetMaterialBudgetFileName(stsMatBudgetFile);
   run->AddTask(l1);
   CbmStsTrackFinder* trackFinder = new CbmL1StsTrackFinder();
   FairTask* findTracks = new CbmStsFindTracks(iVerbose, trackFinder);
   run->AddTask(findTracks);

   FairTask* stsMatchTracks = new CbmStsMatchTracks("STSMatchTracks", iVerbose);
   run->AddTask(stsMatchTracks);
	// ------------------------------------------------------------------------

   if (IsMuch(parFile)) {
      // -------- MUCH digitization ------------
      CbmMuchDigitizeGem* digitize = new CbmMuchDigitizeGem(muchDigiFile.Data());
      if (muchHitProducerType == "simple") {
         digitize->SetAlgorithm(0);
      } else if (muchHitProducerType == "advanced") {
         digitize->SetAlgorithm(1);
      }
      run->AddTask(digitize);
      CbmMuchFindHitsGem* findHits = new CbmMuchFindHitsGem(muchDigiFile.Data());
      run->AddTask(findHits);

      CbmMuchDigitizeStraws* strawDigitize = new CbmMuchDigitizeStraws("MuchDigitizeStraws", muchDigiFile.Data(), iVerbose);
      run->AddTask(strawDigitize);
      CbmMuchFindHitsStraws* strawFindHits = new CbmMuchFindHitsStraws("MuchFindHitsStraws", muchDigiFile.Data(), iVerbose);
      strawFindHits->SetMerge(1);
      run->AddTask(strawFindHits);
      // -----------------------------------------------------------------
   }

   if (IsTrd(parFile)) {
      // ----- TRD reconstruction-----------------------------------------
      // Update of the values for the radiator F.U. 17.08.07
      Int_t trdNFoils = 130; // number of polyetylene foils
      Float_t trdDFoils = 0.0013; // thickness of 1 foil [cm]
      Float_t trdDGap = 0.02; // thickness of gap between foils [cm]
      Bool_t simpleTR = kTRUE; // use fast and simple version for TR production

      CbmTrdRadiator *radiator = new CbmTrdRadiator(simpleTR, trdNFoils, trdDFoils, trdDGap);

      if (trdHitProducerType == "smearing") {
         CbmTrdHitProducerSmearing* trdHitProd = new CbmTrdHitProducerSmearing(radiator);
         trdHitProd->SetUseDigiPar(false);
         run->AddTask(trdHitProd);
      } else if (trdHitProducerType == "digi") {
         CbmTrdDigitizer* trdDigitizer = new CbmTrdDigitizer(radiator);
         run->AddTask(trdDigitizer);

         CbmTrdHitProducerDigi* trdHitProd = new CbmTrdHitProducerDigi();
         run->AddTask(trdHitProd);
      } else if (trdHitProducerType == "clustering") {
         // ----- TRD clustering -----
         CbmTrdDigitizerPRF* trdClustering = new CbmTrdDigitizerPRF("TRD Clusterizer", "TRD task", radiator, false, true);
         run->AddTask(trdClustering);

         CbmTrdClusterFinderFast* trdClusterfindingfast = new CbmTrdClusterFinderFast(true, true, false, 5.0e-7);
         run->AddTask(trdClusterfindingfast);

         CbmTrdHitProducerCluster* trdClusterHitProducer = new CbmTrdHitProducerCluster();
         run->AddTask(trdClusterHitProducer);
         // ----- End TRD Clustering -----
      }
      // ------------------------------------------------------------------------
   }

   if (IsTof(parFile)) {
      // ------ TOF hits --------------------------------------------------------
      CbmTofHitProducerNew* tofHitProd = new CbmTofHitProducerNew("TOF HitProducerNew",iVerbose);
      tofHitProd->SetInitFromAscii(kFALSE);
      run->AddTask(tofHitProd);
      // ------------------------------------------------------------------------
   }

   // ------ Global track reconstruction -------------------------------------
   CbmLitFindGlobalTracks* finder = new CbmLitFindGlobalTracks();
   //CbmLitFindGlobalTracksParallel* finder = new CbmLitFindGlobalTracksParallel();
   // Tracking method to be used
   // "branch" - branching tracking
   // "nn" - nearest neighbor tracking
   // "nn_parallel" - nearest neighbor parallel tracking
   finder->SetTrackingType(std::string(globalTrackingType));

   // Hit-to-track merger method to be used
   // "nearest_hit" - assigns nearest hit to the track
   finder->SetMergerType("nearest_hit");

   run->AddTask(finder);

   if (IsTrd(parFile)) {
      CbmTrdMatchTracks* trdMatchTracks = new CbmTrdMatchTracks();
      run->AddTask(trdMatchTracks);
   }

   if (IsMuch(parFile)) {
      CbmMuchMatchTracks* muchMatchTracks = new CbmMuchMatchTracks();
      run->AddTask(muchMatchTracks);
   }

   // -----   Primary vertex finding   --------------------------------------
   CbmPrimaryVertexFinder* pvFinder = new CbmPVFinderKF();
   CbmFindPrimaryVertex* findVertex = new CbmFindPrimaryVertex(pvFinder);
   run->AddTask(findVertex);
   // -----------------------------------------------------------------------

	// -----  Parameter database   --------------------------------------------
	FairRuntimeDb* rtdb = run->GetRuntimeDb();
	FairParRootFileIo* parIo1 = new FairParRootFileIo();
	FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
	parIo1->open(parFile.Data());
	parIo2->open(parFileList, "in");
	rtdb->setFirstInput(parIo1);
	rtdb->setSecondInput(parIo2);
	rtdb->setOutput(parIo1);
	rtdb->saveOutput();
	// ------------------------------------------------------------------------

	// -----   Initialize and run   --------------------------------------------
	run->Init();
	run->Run(0, nEvents);
	// ------------------------------------------------------------------------

	// -----   Finish   -------------------------------------------------------
	timer.Stop();
 	cout << "Macro finished successfully." << endl;
   cout << "Test passed"<< endl;
   cout << " All ok " << endl;
	cout << "Output file is " << globalRecoFile << endl;
	cout << "Parameter file is " << parFile << endl;
	cout << "Real time " << timer.RealTime() << " s, CPU time "	<< timer.CpuTime() << " s" << endl;
	// ------------------------------------------------------------------------
}
Esempio n. 17
0
void ana_complete(int nevts=0)
{
        TDatabasePDG::Instance()->AddParticle("pbarpSystem","pbarpSystem",1.9,kFALSE,0.1,0,"",88888);
        TStopwatch fTimer;
	// *** some variables
	int i=0,j=0, k=0, l=0;
	gStyle->SetOptFit(1011);
	
	// *** the output file for FairRunAna
	TString OutFile="output.root";  
					
	// *** the files coming from the simulation
	TString inPidFile  = "psi2s_jpsi2pi_jpsi_mumu_pid.root";    // this file contains the PndPidCandidates and McTruth
	TString inParFile  = "psi2s_jpsi2pi_jpsi_mumu_par.root";
	
	// *** PID table with selection thresholds; can be modified by the user
	TString pidParFile = TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all_day1.par";	
	
	// *** initialization
	FairLogger::GetLogger()->SetLogToFile(kFALSE);
	FairRunAna* fRun = new FairRunAna();
	FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
	fRun->SetInputFile(inPidFile);
	
	// *** setup parameter database 	
	FairParRootFileIo* parIO = new FairParRootFileIo();
	parIO->open(inParFile);
	FairParAsciiFileIo* parIOPid = new FairParAsciiFileIo();
	parIOPid->open(pidParFile.Data(),"in");
	
	rtdb->setFirstInput(parIO);
	rtdb->setSecondInput(parIOPid);
	rtdb->setOutput(parIO);  
	
	fRun->SetOutputFile(OutFile);
	fRun->Init(); 
	
        // *** create an output file for all histograms
	TFile *out = TFile::Open("output_ana.root","RECREATE");
	
	// *** create some histograms
	TH1F *hmomtrk    = new TH1F("hmomtrk","track momentum (all)",200,0,5);
	TH1F *hthttrk    = new TH1F("hthttrk","track theta (all)",200,0,3.1415);
	
	TH1F *hjpsim_all = new TH1F("hjpsim_all","J/#psi mass (all)",200,0,4.5);
	TH1F *hpsim_all  = new TH1F("hpsim_all","#psi(2S) mass (all)",200,0,5);
	
	TH1F *hjpsim_lpid = new TH1F("hjpsim_lpid","J/#psi mass (loose pid)",200,0,4.5);
	TH1F *hpsim_lpid  = new TH1F("hpsim_lpid","#psi(2S) mass (loose pid)",200,0,5);
	
	TH1F *hjpsim_tpid = new TH1F("hjpsim_tpid","J/#psi mass (tight pid)",200,0,4.5);
	TH1F *hpsim_tpid  = new TH1F("hpsim_tpid","#psi(2S) mass (tight pid)",200,0,5);
	
	TH1F *hjpsim_trpid = new TH1F("hjpsim_trpid","J/#psi mass (true pid)",200,0,4.5);
	TH1F *hpsim_trpid  = new TH1F("hpsim_trpid","#psi(2S) mass (true pid)",200,0,5);
	
	
	TH1F *hjpsim_ftm = new TH1F("hjpsim_ftm","J/#psi mass (full truth match)",200,0,4.5);
	TH1F *hpsim_ftm  = new TH1F("hpsim_ftm","#psi(2S) mass (full truth match)",200,0,5);
	
	TH1F *hjpsim_nm = new TH1F("hjpsim_nm","J/#psi mass (no truth match)",200,0,4.5);
	TH1F *hpsim_nm  = new TH1F("hpsim_nm","#psi(2S) mass (no truth match)",200,0,5);
	
	TH1F *hjpsim_diff = new TH1F("hjpsim_diff","J/#psi mass diff to truth",100,-2,2);
	TH1F *hpsim_diff  = new TH1F("hpsim_diff","#psi(2S) mass diff to truth",100,-2,2);
	
	
	TH1F *hjpsim_vf   = new TH1F("hjpsim_vf","J/#psi mass (vertex fit)",200,0,4.5);
	TH1F *hjpsim_4cf  = new TH1F("hjpsim_4cf","J/#psi mass (4C fit)",200,0,4.5);
	TH1F *hjpsim_mcf  = new TH1F("hjpsim_mcf","J/#psi mass (mass constraint fit)",200,0,4.5);
	
	TH1F *hjpsi_chi2_vf  = new TH1F("hjpsi_chi2_vf", "J/#psi: #chi^{2} vertex fit",100,0,10);
	TH1F *hpsi_chi2_4c   = new TH1F("hpsi_chi2_4c",  "#psi(2S): #chi^{2} 4C fit",100,0,250);
	TH1F *hjpsi_chi2_mf  = new TH1F("hjpsi_chi2_mf", "J/#psi: #chi^{2} mass fit",100,0,10);
	
	TH1F *hjpsi_prob_vf  = new TH1F("hjpsi_prob_vf", "J/#psi: Prob vertex fit",100,0,1);
	TH1F *hpsi_prob_4c   = new TH1F("hpsi_prob_4c",  "#psi(2S): Prob 4C fit",100,0,1);
	TH1F *hjpsi_prob_mf  = new TH1F("hjpsi_prob_mf", "J/#psi: Prob mass fit",100,0,1);
	
	TH2F *hvpos = new TH2F("hvpos","(x,y) projection of fitted decay vertex",100,-2,2,100,-2,2);
	
	//
	// Now the analysis stuff comes...
	//
	
	
	// *** the data reader object
	PndAnalysis* theAnalysis = new PndAnalysis();
	if (nevts==0) nevts= theAnalysis->GetEntries();
	
	// *** RhoCandLists for the analysis
	RhoCandList chrg, muplus, muminus, piplus, piminus, jpsi, psi2s;
	
	// *** Mass selector for the jpsi cands
	double m0_jpsi = TDatabasePDG::Instance()->GetParticle("J/psi")->Mass();   // Get nominal PDG mass of the J/psi
	RhoMassParticleSelector *jpsiMassSel=new RhoMassParticleSelector("jpsi",m0_jpsi,1.0);
	
	// *** the lorentz vector of the initial psi(2S)
	TLorentzVector ini(0, 0, 6.231552, 7.240065);
	
	// ***
	// the event loop
	// ***
	
	int cntdbltrk=0, cntdblmc=0, cntdblboth=0, cnttrk=0, cnt_dbl_jpsi=0, cnt_dbl_psip=0;
	
	while (theAnalysis->GetEvent() && i++<nevts)
	{
		if ((i%100)==0) cout<<"evt " << i << endl;
				
		// *** Select with no PID info ('All'); type and mass are set 		
		theAnalysis->FillList(chrg,    "Charged");
		theAnalysis->FillList(muplus,  "MuonAllPlus");
		theAnalysis->FillList(muminus, "MuonAllMinus");
		theAnalysis->FillList(piplus,  "PionAllPlus");
		theAnalysis->FillList(piminus, "PionAllMinus");

		// *** momentum and theta histograms
		for (j=0;j<muplus.GetLength();++j) 
		{
			hmomtrk->Fill(muplus[j]->P());
			hthttrk->Fill(muplus[j]->P4().Theta());
		}
		for (j=0;j<muminus.GetLength();++j) 
		{
			hmomtrk->Fill(muminus[j]->P());
			hthttrk->Fill(muminus[j]->P4().Theta());
		}
		
		cnttrk += chrg.GetLength();
		
		int n1, n2, n3;
		
		countDoubles(chrg,n1,n2,n3);
		cntdbltrk  += n1;
		cntdblmc   += n2;
		cntdblboth += n3;		
		
		// *** combinatorics for J/psi -> mu+ mu-
		jpsi.Combine(muplus, muminus);
		
		
		// ***
		// *** do the TRUTH MATCH for jpsi
		// ***
		jpsi.SetType(443);
				
		int nm = 0;
		for (j=0;j<jpsi.GetLength();++j) 
		{
			hjpsim_all->Fill( jpsi[j]->M() );
			
			if (theAnalysis->McTruthMatch(jpsi[j]))
			{ 
				nm++;
				hjpsim_ftm->Fill( jpsi[j]->M() );
			 	hjpsim_diff->Fill( jpsi[j]->GetMcTruth()->M() - jpsi[j]->M() );
			}
			else 
				hjpsim_nm->Fill( jpsi[j]->M() );
		}
		
		if (nm>1) cnt_dbl_jpsi++;
		// ***
		// *** do VERTEX FIT (J/psi)
		// ***
		for (j=0;j<jpsi.GetLength();++j) 
		{
			PndKinVtxFitter vtxfitter(jpsi[j]);	// instantiate a vertex fitter
			vtxfitter.Fit();
			
			double chi2_vtx = vtxfitter.GetChi2();	// access chi2 of fit
			double prob_vtx = vtxfitter.GetProb();	// access probability of fit
			hjpsi_chi2_vf->Fill(chi2_vtx);
			hjpsi_prob_vf->Fill(prob_vtx);			
			
			if ( prob_vtx > 0.01 )				// when good enough, fill some histos
			{
				RhoCandidate *jfit = jpsi[j]->GetFit();	// access the fitted cand
				TVector3 jVtx=jfit->Pos();		// and the decay vertex position
				
				hjpsim_vf->Fill(jfit->M());            
				hvpos->Fill(jVtx.X(),jVtx.Y());
			}
		}
		
		// *** some rough mass selection
		jpsi.Select(jpsiMassSel);
		
		// *** combinatorics for psi(2S) -> J/psi pi+ pi-
		psi2s.Combine(jpsi, piplus, piminus);
		
		
		// ***
		// *** do the TRUTH MATCH for psi(2S)
		// ***
		psi2s.SetType(88888);

		nm = 0;
		for (j=0;j<psi2s.GetLength();++j) 
		{
			hpsim_all->Fill( psi2s[j]->M() );
			
			if (theAnalysis->McTruthMatch(psi2s[j])) 
			{
				nm++;
			 	hpsim_ftm->Fill( psi2s[j]->M() );
			 	hpsim_diff->Fill( psi2s[j]->GetMcTruth()->M() - psi2s[j]->M() );
			}
			else 
				hpsim_nm->Fill( psi2s[j]->M() );
		}			
		if (nm>1) cnt_dbl_psip++;

		
		// ***
		// *** do 4C FIT (initial psi(2S) system)
		// ***
		for (j=0;j<psi2s.GetLength();++j) 
		{
			PndKinFitter fitter(psi2s[j]);	// instantiate the kin fitter in psi(2S)
			fitter.Add4MomConstraint(ini);	// set 4 constraint
			fitter.Fit();		            // do fit
			
			double chi2_4c = fitter.GetChi2();	// get chi2 of fit
			double prob_4c = fitter.GetProb();	// access probability of fit
			hpsi_chi2_4c->Fill(chi2_4c);
			hpsi_prob_4c->Fill(prob_4c);			
			
			if ( prob_4c > 0.01 )			// when good enough, fill some histo
			{
				RhoCandidate *jfit = psi2s[j]->Daughter(0)->GetFit();	// get fitted J/psi
				
				hjpsim_4cf->Fill(jfit->M());
			}
		}		
		
		
		// ***
		// *** do MASS CONSTRAINT FIT (J/psi)
		// ***
		for (j=0;j<jpsi.GetLength();++j) 
		{
			PndKinFitter mfitter(jpsi[j]);		// instantiate the PndKinFitter in psi(2S)
			mfitter.AddMassConstraint(m0_jpsi);	// add the mass constraint
			mfitter.Fit();						// do fit
			
			double chi2_m = mfitter.GetChi2();	// get chi2 of fit
			double prob_m = mfitter.GetProb();	// access probability of fit
			hjpsi_chi2_mf->Fill(chi2_m);
			hjpsi_prob_mf->Fill(prob_m);			
			
			if ( prob_m > 0.01 )				// when good enough, fill some histo
			{
				RhoCandidate *jfit = jpsi[j]->GetFit();	// access the fitted cand
				hjpsim_mcf->Fill(jfit->M());
			}
		}		
		
		
		// ***
		// *** TRUE PID combinatorics
		// ***
		
		// *** do MC truth match for PID type
		SelectTruePid(theAnalysis, muplus);
		SelectTruePid(theAnalysis, muminus);
		SelectTruePid(theAnalysis, piplus);
		SelectTruePid(theAnalysis, piminus);
				
		// *** all combinatorics again with true PID
		jpsi.Combine(muplus, muminus);
		for (j=0;j<jpsi.GetLength();++j) hjpsim_trpid->Fill( jpsi[j]->M() );
		jpsi.Select(jpsiMassSel);
		
		psi2s.Combine(jpsi, piplus, piminus);
		for (j=0;j<psi2s.GetLength();++j) hpsim_trpid->Fill( psi2s[j]->M() );
		
		
		// ***
		// *** LOOSE PID combinatorics
		// ***
		
		// *** and again with PidAlgoMvd;PidAlgoStt;PidAlgoDrc and loose selection
		theAnalysis->FillList(muplus,  "MuonLoosePlus",  "PidAlgoMvd;PidAlgoStt;PidAlgoDrc;PidAlgoMdtHardCuts");
		theAnalysis->FillList(muminus, "MuonLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc;PidAlgoMdtHardCuts");
		theAnalysis->FillList(piplus,  "PionLoosePlus",  "PidAlgoMvd;PidAlgoStt;PidAlgoDrc");
		theAnalysis->FillList(piminus, "PionLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc");
		
		jpsi.Combine(muplus, muminus);
		for (j=0;j<jpsi.GetLength();++j) hjpsim_lpid->Fill( jpsi[j]->M() );
		jpsi.Select(jpsiMassSel);
		
		psi2s.Combine(jpsi, piplus, piminus);
		for (j=0;j<psi2s.GetLength();++j) hpsim_lpid->Fill( psi2s[j]->M() );
		
		
		// ***
		// *** TIGHT PID combinatorics
		// ***
		
		// *** and again with PidAlgoMvd;PidAlgoStt and tight selection
		theAnalysis->FillList(muplus,  "MuonTightPlus",  "PidAlgoMdtHardCuts");
		theAnalysis->FillList(muminus, "MuonTightMinus", "PidAlgoMdtHardCuts");
		theAnalysis->FillList(piplus,  "PionLoosePlus",  "PidAlgoMvd;PidAlgoStt;PidAlgoDrc");
		theAnalysis->FillList(piminus, "PionLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc");
		
		jpsi.Combine(muplus, muminus);
		for (j=0;j<jpsi.GetLength();++j) hjpsim_tpid->Fill( jpsi[j]->M() );
		jpsi.Select(jpsiMassSel);
		
		psi2s.Combine(jpsi, piplus, piminus);
		for (j=0;j<psi2s.GetLength();++j) hpsim_tpid->Fill( psi2s[j]->M() );
		
	}
		
	// *** write out all the histos
	out->cd();
	
	hmomtrk->Write();
	hthttrk->Write();
	
	hjpsim_all->Write();
	hpsim_all->Write();
	hjpsim_lpid->Write();
	hpsim_lpid->Write();
	hjpsim_tpid->Write();
	hpsim_tpid->Write();
	hjpsim_trpid->Write();
	hpsim_trpid->Write();
	
	hjpsim_ftm->Write();
	hpsim_ftm->Write();
	hjpsim_nm->Write();
	hpsim_nm->Write();
	
	hpsim_diff->Write();
	hjpsim_diff->Write();
	
	hjpsim_vf->Write();
	hjpsim_4cf->Write();
	hjpsim_mcf->Write();
	
	hjpsi_chi2_vf->Write();
	hpsi_chi2_4c->Write();
	hjpsi_chi2_mf->Write();
			
	hjpsi_prob_vf->Write();
	hpsi_prob_4c->Write();
	hjpsi_prob_mf->Write();
			
	hvpos->Write();
		
	out->Save();
        
	// Extract the maximal used memory an add is as Dart measurement
	// This line is filtered by CTest and the value send to CDash
	FairSystemInfo sysInfo;
	Float_t maxMemory=sysInfo.GetMaxMemory();
	cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
	cout << maxMemory;
	cout << "</DartMeasurement>" << endl;
  
	fTimer.Stop();
	Double_t rtime = fTimer.RealTime();
	Double_t ctime = fTimer.CpuTime();
  
	Float_t cpuUsage=ctime/rtime;
	cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
	cout << cpuUsage;
	cout << "</DartMeasurement>" << endl;
  
	cout << endl;
	cout << "Real time " << rtime << " s, CPU time " << ctime
		  << "s" << endl;
	cout << "CPU usage " << cpuUsage*100. << "%" << endl;
	cout << "Max Memory " << maxMemory << " MB" << endl;
   
	cout << "Macro finished successfully." << endl;

        exit(0);
	
}
Esempio n. 18
0
/********************************************************************************
 *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
 *                                                                              *
 *              This software is distributed under the terms of the             *
 *              GNU Lesser General Public Licence (LGPL) version 3,             *
 *                  copied verbatim in the file "LICENSE"                       *
 ********************************************************************************/
void run_hits( TString mcEngine="TGeant3" )
{
  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
  Int_t iVerbose = 0; // just forget about it, for the moment

  // Input file (MC events)
  TString inFile = "pixel_";
  inFile = inFile + mcEngine + ".digi.root";

  // Parameter file
  TString parFile = "pixel_";
  parFile = parFile + mcEngine + ".params.root";

  // Digitization parameter file
  TString dir = getenv("VMCWORKDIR");
  TString tutdir = dir + "/MQ/pixelDetector";
  TString digParFile = tutdir + "/param/pixel_digi.par";

  // Output file
  TString outFile = "pixel_";
  outFile = outFile + mcEngine + ".hits.root";

  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;

  // -----   Reconstruction run   -------------------------------------------
  FairRunAna *fRun= new FairRunAna();
  FairFileSource *fFileSource = new FairFileSource(inFile);
  fRun->SetSource(fFileSource);
  fRun->SetSink(new FairRootFileSink(outFile));

  // fRun->AddFile(inFile);
  // fRun->AddFile(inFile);
  // fRun->AddFile(inFile);
  // fRun->AddFile(inFile);
  // fRun->AddFile(inFile);
  // fRun->AddFile(inFile);
  // fRun->AddFile(inFile);
  // fRun->AddFile(inFile);
  // fRun->AddFile(inFile);

  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo* parInput1 = new FairParRootFileIo();
  parInput1->open(parFile.Data());

  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
  parIo1->open(digParFile.Data(),"in");

  rtdb->setFirstInput(parInput1);
  rtdb->setSecondInput(parIo1);

  // -----   TorinoDetector hit  producers   ---------------------------------
  PixelFindHits* hitFinderTask = new PixelFindHits();
  fRun->AddTask(hitFinderTask);


  fRun->Init();

  timer.Start();
  fRun->Run();

  // -----   Finish   -------------------------------------------------------

  cout << endl << endl;

  // Extract the maximal used memory an add is as Dart measurement
  // This line is filtered by CTest and the value send to CDash
  FairSystemInfo sysInfo;
  Float_t maxMemory=sysInfo.GetMaxMemory();
  cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
  cout << maxMemory;
  cout << "</DartMeasurement>" << endl;

  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();

  Float_t cpuUsage=ctime/rtime;
  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
  cout << cpuUsage;
  cout << "</DartMeasurement>" << endl;

  cout << endl << endl;
  cout << "Output file is "    << outFile << endl;
  cout << "Parameter file is " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime
       << "s" << endl << endl;
  cout << "Macro finished successfully." << endl;

  // ------------------------------------------------------------------------
}
Esempio n. 19
0
void prod_ana(TString outpre="M9999", int nevts=0, double mom=2.7)
{
	TDatabasePDG::Instance()-> AddParticle("pbarpSystem","pbarpSystem", 1.9, kFALSE, 0.1, 0,"", 88888);


 	TString OutFile1   = TString::Format("%s_ana.root",outpre.Data()); 
 	TString OutFile2   = TString::Format("%s_",outpre.Data()); 
	TString inParFile = TString::Format("%s_par.root",outpre.Data());
	
  	FairRunAna *fRun= new FairRunAna();
  
   	//bool firstfile=true;

  	// *** Add pid files
  	//for (int i=id;i<=to;++i)
  	//{
	
	TString fname = TString::Format("%s_pid.root",outpre.Data());

	//	if ( checkfile(fname) )
	//	{
	//		if (firstfile) 
				fRun->SetInputFile(fname);
	//		else 
	//			fRun->AddFile(fname);
	//		
	//		firstfile=false;
	//	}
  	//}
  	
	// *** PID table with selection thresholds; can be modified by the user
	TString pidParFile = TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all.par";
	
	// *** initialization
	FairLogger::GetLogger()->SetLogToFile(kFALSE);
	FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
	
	// *** setup parameter database 	
	
	FairParRootFileIo* parIO = new FairParRootFileIo();
	parIO->open(inParFile);
	FairParAsciiFileIo* parIOPid = new FairParAsciiFileIo();
	parIOPid->open(pidParFile.Data(),"in");
	
	rtdb->setFirstInput(parIO);
	rtdb->setSecondInput(parIOPid);
	rtdb->setOutput(parIO);  
	
	
	fRun->SetOutputFile(OutFile1);
	
	//---------------------Create and Set the Field(s)---------- 
//  	PndMultiField *fField= new PndMultiField("FULL");
//  	fRun->SetField(fField);
	
	//RhoCalculationTools::ForceConstantBz(20.0);

	// ***
	// *** HERE YOUR ANALYSIS CODE GOES!
	// ***
	AnalysisTask *anaTask = new AnalysisTask();
	anaTask->SetOutPutDir(OutFile2);
	anaTask->SetNEvents(nevts);
	anaTask->SetMom(mom);
	fRun->AddTask(anaTask);

	fRun->Init();
	fRun->Run(0.,1.);

	
}