示例#1
0
Int_t IlcESDv0Analysis(const Char_t *dir=".") { 
   TH1F *hm=(TH1F*)gROOT->FindObject("hm");
   if (!hm) {
      hm=new TH1F("hm","Lambda+LambdaBar Effective Mass",60,1.065,1.165);
      hm->SetXTitle("Mass (GeV/c**2)");
   }
   Char_t fname[100];
   sprintf(fname,"%s/IlcESDs.root",dir);
   TFile *ef=TFile::Open(fname);
   if (!ef||!ef->IsOpen()) {cerr<<"Can't IlcESDs.root !\n"; return 1;}
   cerr<<"\n****** "<<fname<<" ******\n";

   IlcESDEvent* event = new IlcESDEvent();


   TTree* tree = (TTree*) ef->Get("esdTree");
   if (!tree) {cerr<<"no ESD tree found\n"; return 1;};
   event->ReadFromTree(tree);

   Int_t rc=0,n=0;

   //****** Tentative particle type "concentrations"
   Double_t c[5]={0.0, 0.0, 1, 0, 1};
   IlcPID pid;
   pid.SetPriors(c);

   //******* The loop over events
    while (tree->GetEvent(n)) {

     cerr<<"Processing event number : "<<n++<<endl;

     Int_t nv0=event->GetNumberOfV0s();
     cerr<<"Number of ESD v0s : "<<nv0<<endl; 

     while (nv0--) {
       IlcESDv0 *v0=event->GetV0(nv0);
       if (v0->GetOnFlyStatus()) continue;

       Int_t protonIdx=v0->GetPindex();
       Int_t pionIdx  =v0->GetNindex();
      
       v0->ChangeMassHypothesis(3122);
       Double_t mass=v0->GetEffMass();
       if (mass>1.17) {  //check also the LambdaBar hypothesis
          v0->ChangeMassHypothesis(-3122);
          mass=v0->GetEffMass();
          if (mass>1.17) continue;
          Int_t tmp=protonIdx; protonIdx=pionIdx; pionIdx=tmp;
       } 

       IlcESDtrack *protonTrk=event->GetTrack(protonIdx);
       IlcESDtrack *pionTrk  =event->GetTrack(pionIdx);

       if (protonTrk->GetP()<0.5) continue;

       // Check if the "proton track" is a proton
       if ((protonTrk->GetStatus()&IlcESDtrack::kESDpid)!=0) {
	 Double_t r[10]; protonTrk->GetESDpid(r);
         pid.SetProbabilities(r);
         Double_t pp=pid.GetProbability(IlcPID::kProton);
         if (pp < pid.GetProbability(IlcPID::kElectron)) continue;
         if (pp < pid.GetProbability(IlcPID::kMuon)) continue;
         if (pp < pid.GetProbability(IlcPID::kPion)) continue;
         if (pp < pid.GetProbability(IlcPID::kKaon)) continue;
       }
 
       //Check if the "pion track" is a pion
       if ((pionTrk->GetStatus()&IlcESDtrack::kESDpid)!=0) {
	 Double_t r[10]; pionTrk->GetESDpid(r);
         pid.SetProbabilities(r);
         Double_t ppi=pid.GetProbability(IlcPID::kPion);
         if (ppi < pid.GetProbability(IlcPID::kElectron)) continue;
         if (ppi < pid.GetProbability(IlcPID::kMuon)) continue;
         if (ppi < pid.GetProbability(IlcPID::kKaon)) continue;
         if (ppi < pid.GetProbability(IlcPID::kProton)) continue;
        }

       hm->Fill(mass);
     } 

   }

   delete event;
   delete tree;
   ef->Close();

   TCanvas *c1=(TCanvas*)gROOT->FindObject("c1");
   if (!c1) {
      c1=new TCanvas();
   }

   if (hm->GetEntries()>100) hm->Fit("gaus","","",1.11,1.12);
   else hm->Draw();

   c1->Update();

   return rc;
}
示例#2
0
Int_t IlcESDanalysis() {
    TStopwatch timer;

    gStyle->SetOptStat(111110);
    gStyle->SetOptFit(1);

    Double_t V0mass=0.497672, V0width=0.020, V0window=0.05;
    Double_t mmin=V0mass-V0window, mmax=V0mass+V0window;
    TH1F *hm =new TH1F("hm","K0s",40, mmin, mmax);
    hm->SetXTitle("Mass (GeV/c**2)");
    hm->SetLineColor(2);
    TH1F *hp =new TH1F("hp","Momentum of the positive daughter",40, 0, 2);
    hp->SetXTitle("P (GeV/c)");
    hp->SetLineColor(4);

//****** File with the ESD
    TFile *ef=TFile::Open("IlcESDs.root");
    if (!ef || !ef->IsOpen()) {
        cerr<<"Can't IlcESDs.root !\n";
        return 1;
    }
    IlcESDEvent* event = new IlcESDEvent();
    TTree* tree = (TTree*) ef->Get("esdTree");
    if (!tree) {
        cerr<<"no ESD tree found\n";
        return 1;
    };
    event->ReadFromTree(tree);

    Int_t n=0;

//******* The loop over events
    while (tree->GetEvent(n)) {
        cout<<endl<<"Processing event number : "<<n++<<endl;

        Int_t ntrk=event->GetNumberOfTracks();
        cout<<"Number of ESD tracks : "<<ntrk<<endl;
        Int_t nv0=event->GetNumberOfV0s();
        cout<<"Number of ESD V0s : "<<nv0<<endl;
        Int_t ncas=event->GetNumberOfCascades();
        cout<<"Number of ESD cascades : "<<ncas<<endl;

        //****** The loop over tracks
        Int_t nk=0;
        while (ntrk--) {
            IlcESDtrack *track=event->GetTrack(ntrk);
            UInt_t status=track->GetStatus();

            //select only tracks with the "combined PID"
            if ((status&IlcESDtrack::kESDpid)==0) continue;

            Double_t w[10];
            track->GetESDpid(w);
            //count only "Kaon-like" tracks
            if (w[3]>w[4] && w[3]>w[2] && w[3]>w[1] && w[3]>w[0]) nk++;
        }
        cout<<"Number of \"Kaon-like\" tracks : "<<nk<<endl;

        //****** The loop over V0s
        while (nv0--) {
            IlcESDv0 *v0=event->GetV0(nv0);
            v0->ChangeMassHypothesis(310); // K0s
            Double_t mass=v0->GetEffMass();
            hm->Fill(mass);

            Int_t pidx=v0->GetPindex();               // now let's get an access
            IlcESDtrack *track=event->GetTrack(pidx); // to the positive daughter
            Double_t p=track->GetP();
            hp->Fill(p);
        }

        //****** The loop over cascades
        while (ncas--) {
            IlcESDcascade *cas=event->GetCascade(ncas);
            Double_t q; //"quality" of the associated Lambda
            cas->ChangeMassHypothesis(q,3312); // Xi-
            // Here you do something with your Xis
            //  ...
            // You can get the access to the daughters
        }

    }

    delete event;
    ef->Close();

    timer.Stop();
    timer.Print();

    TCanvas *c1=new TCanvas("c1","",0,0,600,1200);
    c1->Divide(1,2);

    c1->cd(1);
    hm->Fit("gaus","","",V0mass-V0width,V0mass+V0width);

    c1->cd(2);
    hp->Fit("expo","","",0.3,2);

    return 0;
}