void ilceve_create_vsd(Int_t nEvents=1, Int_t minTracks=0)
{
  // Invoke from a running ilceve.
  // nEvents will be domped starting from current one.
  // If minTracks is set at least that many ESD tracks must exist.

  TEveVSD::DisableTObjectStreamersForVSDStruct();

  IlcEveVSDCreator vc;
  vc.SetDebugLevel(2);

  Int_t nDone = 0;
  while (nDone < nEvents)
  {
    if (minTracks)
    {
      IlcESDEvent* esd = IlcEveEventManager::AssertESD();
      while (esd->GetNumberOfTracks() < minTracks)
      {
	IlcEveEventManager::GetMaster()->NextEvent();
	esd = IlcEveEventManager::AssertESD();
      }
    }
    vc.CreateVSD("IlcVSD.root");
    ++nDone;

    IlcEveEventManager::GetMaster()->NextEvent();
  }
}
示例#2
0
void on_new_event()
{
  Double_t x[3] = { 0, 0, 0 };
  
  if (IlcEveEventManager::HasESD())
  {
    IlcESDEvent* esd = IlcEveEventManager::AssertESD();
    esd->GetPrimaryVertex()->GetXYZ(x);
    
    TTimeStamp ts(esd->GetTimeStamp());
    TString win_title("Eve Main Window -- Timestamp: ");
    win_title += ts.AsString("s");
    win_title += "; Event # in ESD file: ";
    win_title += esd->GetEventNumberInFile();
    gEve->GetBrowser()->SetWindowName(win_title);
  }
  
  TEveElement* top = gEve->GetCurrentEvent();
  
  IlcEveMultiView *mv = IlcEveMultiView::Instance();
  
  mv->DestroyEventRPhi();
  if (gCenterProjectionsAtPrimaryVertex)
    mv->SetCenterRPhi(x[0], x[1], x[2]);
  mv->ImportEventRPhi(top);
  
  mv->DestroyEventRhoZ();
  if (gCenterProjectionsAtPrimaryVertex)
    mv->SetCenterRhoZ(x[0], x[1], x[2]);
  mv->ImportEventRhoZ(top);
}
示例#3
0
TEveStraightLineSet*
primary_vertex_box_tpc(Bool_t use_sigma=kTRUE, Float_t fx=30, Float_t fy=30, Float_t fz=10)
{
  IlcESDEvent  *esd  = IlcEveEventManager::AssertESD();
  const IlcESDVertex *tpcv = esd->GetPrimaryVertexTPC();
  if ( ! tpcv->GetStatus()) {
    Info("primary_vertex_box_tpc", "Primary vertex TPC not available.");
    return 0;
  }

  TEveStraightLineSet* ls = make_vertex_box(tpcv, use_sigma, fx, fy, fz);
  ls->ApplyVizTag("REC PVTX Box TPC");
  assert_vertex_parent("Primary Vertex TPC", 5)->AddElement(ls);
  gEve->Redraw3D();
  return ls;
}
示例#4
0
TEveStraightLineSet*
primary_vertex_ellipse_spd(Bool_t use_sigma=kTRUE, Float_t fx=30, Float_t fy=30, Float_t fz=10)
{
  IlcESDEvent  *esd  = IlcEveEventManager::AssertESD();
  const IlcESDVertex *spdv = esd->GetPrimaryVertexSPD();
  if ( ! spdv->GetStatus()) {
    Info("primary_vertex_ellipse_spd", "Primary vertex SPD not available.");
    return 0;
  }

  TEveStraightLineSet* ls = make_vertex_ellipse(spdv, use_sigma, fx, fy, fz);
  ls->ApplyVizTag("REC PVTX Ellipse SPD");
  assert_vertex_parent("Primary Vertex SPD", 6)->AddElement(ls);
  gEve->Redraw3D();
  return ls;
}
示例#5
0
TEveStraightLineSet*
primary_vertex(Bool_t use_sigma=kTRUE, Float_t fx=1, Float_t fy=1, Float_t fz=1)
{
  IlcESDEvent  *esd = IlcEveEventManager::AssertESD();
  const IlcESDVertex *pv  = esd->GetPrimaryVertex();
  if ( ! pv->GetStatus()) {
    Info("primary_vertex", "Primary vertex not available.");
    return 0;
  }

  TEveStraightLineSet* ls = make_vertex_cross(pv, use_sigma, fx, fy, fz);
  ls->ApplyVizTag("REC PVTX");
  assert_vertex_parent("Primary Vertex", 7)->AddElement(ls);
  gEve->Redraw3D();
  return ls;
}
示例#6
0
void esd_kink_fill_pointset(TEvePointSet* ps)
{
  IlcESDEvent* esd = IlcEveEventManager::AssertESD();

  for (Int_t n=0; n<esd->GetNumberOfTracks(); ++n)
  { 
      IlcESDtrack* track = esd->GetTrack(n);
      if(track->GetKinkIndex(0)<0){
    
          IlcESDkink *kink = esd->GetKink(TMath::Abs(track->GetKinkIndex(0))-1);
	  const TVector3 Position(kink->GetPosition());
	  ps->SetNextPoint(Position.X(), Position.Y(), Position.Z());
          ps->SetPointId(kink);
      }
  }

}
示例#7
0
void test(const char * sdir ="signal",
	  const char * bdir ="backgr") {

  TStopwatch timer;
  timer.Start();

  TString name;

  // Signal file, tree, and branch
  name = sdir;
  name += "/IlcESDs.root";
  TFile * fSig = TFile::Open(name.Data());
  TTree * tSig = (TTree*)fSig->Get("esdTree");

  IlcESDEvent * esdSig = new IlcESDEvent();// The signal ESD object is put here
  esdSig->ReadFromTree(tSig);

  // Run loader (signal events)
  name = sdir;
  name += "/gilc.root";
  IlcRunLoader* rlSig = IlcRunLoader::Open(name.Data());

  // Run loader (underlying events)
  name = bdir;
  name += "/gilc.root";
  IlcRunLoader* rlUnd = IlcRunLoader::Open(name.Data(),"Underlying");

  // gIlc
  rlSig->LoadgIlc();
  rlUnd->LoadgIlc();
  gIlc = rlSig->GetIlcRun();

  // Now load kinematics and event header
  rlSig->LoadKinematics();
  rlSig->LoadHeader();
  rlUnd->LoadKinematics();
  rlUnd->LoadHeader();

  // Loop on events: check that MC and data contain the same number of events
  Long64_t nevSig = rlSig->GetNumberOfEvents();
  Long64_t nevUnd = rlUnd->GetNumberOfEvents();
  Long64_t nSigPerUnd = nevSig/nevUnd;

  cout << nevSig << " signal events" << endl;
  cout << nevUnd << " underlying events" << endl;
  cout << nSigPerUnd << " signal events per one underlying" << endl;

  for (Int_t iev=0; iev<nevSig; iev++) {
    cout << "Signal event " << iev << endl;
    Int_t ievUnd = iev/nSigPerUnd;
    cout << "Underlying event " << ievUnd << endl;

    // Get signal ESD
    tSig->GetEntry(iev);
    // Get signal kinematics
    rlSig->GetEvent(iev);
    // Get underlying kinematics
    rlUnd->GetEvent(ievUnd);

    // Particle stack
    IlcStack * stackSig = rlSig->Stack();
    Int_t nPartSig = stackSig->GetNtrack();
    IlcStack * stackUnd = rlUnd->Stack();
    Int_t nPartUnd = stackUnd->GetNtrack();

    Int_t nrec = esdSig->GetNumberOfTracks();
    cout << nrec << " reconstructed tracks" << endl;
    for(Int_t irec=0; irec<nrec; irec++) {
      IlcESDtrack * track = esdSig->GetTrack(irec);
      UInt_t label = TMath::Abs(track->GetTPCLabel());
      if (label>=10000000) {
	// Underlying event. 10000000 is the
	// value of fkMASKSTEP in IlcRunDigitizer
// 	cout << " Track from the underlying event" << endl;
	label %=10000000;
	if (label>=nPartUnd) continue;
	TParticle * part = stackUnd->Particle(label);
 	if(part) part->Print();
      }
      else {
	cout << " Track " << label << " from the signal event" << endl;
	if (label>=nPartSig) {
	  cout <<"Strange, label outside the range "<< endl;
	  continue;
	}
	TParticle * part = stackSig->Particle(label);
	if(part) part->Print();
      }

    }

  }

  fSig->Close();

  timer.Stop();
  timer.Print();
}
示例#8
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;
}
示例#9
0
void clusters()
{
  IlcEveEventManager::AssertGeometry();

  IlcRunLoader *rl        = IlcEveEventManager::AssertRunLoader();
  IlcESDEvent  *esd       = IlcEveEventManager::AssertESD();
  IlcEveEventManager::AssertESDfriend();
  IlcEveEventManager::AssertMagField();

  const char* detNames[] = { "ITS", "TPC", /*"TRD",*/ "TOF", "HMPID" };
  const Int_t detIds[]   = {   0,     1,   /*  2,  */   3,     5   };
  const Int_t detN       = sizeof(detNames)/sizeof(char*);

  // Hack - IlcReconstruction does wonders with gGeoManager.
  TGeoManager* xxx = gGeoManager; gGeoManager = 0;
  IlcReconstruction* reco = new IlcReconstruction;
  gGeoManager = xxx;

  // Hack for ITS - it requires RecoParams outside event-loop!
  reco->SetRecoParam("ITS", IlcITSRecoParam::GetLowFluxParam());

  reco->ImportRunLoader(rl);
  {
    TString alldets;
    for (Int_t i = 0; i < detN; ++i) {
      alldets += detNames[i];
      alldets += " ";
    }
    reco->CreateTrackers(alldets);
  }

  TObjArray* clarr = new TObjArray();

  // Load clusters, fill them into clarr.

  for (Int_t i = 0; i < detN; ++i)
  {
    Int_t det = detIds[i];
    rl->LoadRecPoints(detNames[i]);

    TTree *cTree = rl->GetTreeR(detNames[i], false);
    if (cTree == 0)
      continue;

    IlcTracker* tracker = reco->GetTracker(det);
    if (tracker == 0) continue;
    tracker->LoadClusters(cTree);
    tracker->FillClusterArray(clarr);
  }

  // Loop over tracks and friends, tag used clusters.

  for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
  {
    IlcESDtrack* at = esd->GetTrack(n);

    Int_t idx[200];
    for (Int_t i = 0; i < detN; ++i)
    {
      Int_t det = detIds[i];
      IlcTracker* tracker = reco->GetTracker(det);
      if (tracker == 0) continue;
      Int_t nclusters = at->GetClusters(det, idx);
      Int_t p=0;
      for (Int_t c = 0; c < nclusters; )
      {
        Int_t index = idx[p++];
        if (index < 0) continue;
        c++;
        IlcCluster* cluster = tracker->GetCluster(index);
        if (cluster) cluster->IncreaseClusterUsage();
        //else printf("Zero cluster pointer for detector: %s\n",detNames[i]);
      }
    }
  }

  for (Int_t i = 0; i < detN; ++i)
    rl->UnloadRecPoints(detNames[i]);

  // Fill visualization structs

  TEveElementList* list = new TEveElementList("Clusters");
  gEve->AddElement(list);

  TEvePointSet* shared = new TEvePointSet("Shared Clusters");
  shared->SetMainColor(2);
  shared->SetMarkerSize(0.4);
  shared->SetMarkerStyle(2);
  list->AddElement(shared);

  TEvePointSet* used = new TEvePointSet("Single-used Clusters");
  used->SetMainColor(3);
  used->SetMarkerSize(0.4);
  used->SetMarkerStyle(2);
  list->AddElement(used);

  TEvePointSet* nonused = new TEvePointSet("Not-used Clusters");
  nonused->SetMainColor(4);
  nonused->SetMarkerSize(0.4);
  nonused->SetMarkerStyle(2);
  list->AddElement(nonused);

  // Loop over all clusters, fill appropriate container based
  // on shared/used information.

  Int_t ncl = clarr->GetEntriesFast();
  for (Int_t i = 0; i < ncl; ++i)
  {
    IlcCluster   *cluster = (IlcCluster*) clarr->UncheckedAt(i);
    TEvePointSet *dest    = 0;
    if (cluster->IsClusterShared())
      dest = shared;
    else if (cluster->IsClusterUsed())
      dest = used;
    else
      dest = nonused;

    Float_t g[3]; //global coordinates
    cluster->GetGlobalXYZ(g);
    dest->SetNextPoint(g[0], g[1], g[2]);
    dest->SetPointId(cluster);
  }

  delete clarr;

  // ??? What to do with trackers ???
  // I'd propose: have global reconstruction that owns them.
  // IlcEveEventManager::AssertIlcReconstruction();
  // do we have bit-field for detectors, like
  // enum IlcDetectors_e {
  //    kITS = BIT(0),
  //    kTPC = BIT(1),
  //    ...
  //    kCentralTracking = kITS | kTPC | kTRD | kTOF,
  //    ...
  //  };

  gEve->Redraw3D();
}
示例#10
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;
}