# Getting the Primary Vertex for Event Cuts

ROOT Version: 6.14/02
Platform: Ubuntu
Compiler: Default

Hey, all. I’m trying to make some event cuts and having a heck of a time doing so. I want to cut for Vz < 40.0 cm and Vr < 2.0 cm. This is the code I’m trying to use to call Vx, Vy, and Vz:

``````if (TMath::Abs(event->primaryVertex().z()) > 40.0 )
{
continue;
}

if (TMath::Abs( sqrt(pow(event->primaryVertex().x(),2) + pow(event->primaryVertex().y(),2))) > 2.0 )
{
continue;
}
``````

The code runs fine, but The cuts seem to do nothing. I created some histograms to check the output, and they’re all at 0 for Vz and Vr both before and after the cuts. I looked at the picos I’m using and Vz, Vx, and Vy are all in there. What am I doing wrong?

Thanks!

Hi,

could you do a printout right before these two cuts, for example

`printf("Vz = %.0f cm, Vr = %.0f\n", TMath::Abs(event->primaryVertex().z()), TMath::Abs(TMath::Sqrt(TMath::Sq(event->primaryVertex().x()) + TMath::Sq(event->primaryVertex().y()))));`

to make sure these numbers you are trying to cut on are indeed valid and are in cm - a lot of things may be wrong with them!

I think this suggests they are stored in meters, not cm.

I thought that might be the case, but when I would change the histogram axis scale nothing would happen. I had done some cout statements and they all came up 0. Here’s the cout code, in the event loop prior to the cuts:

``````cout << "Vz: " << TMath::Abs(event->primaryVertex().z()) << endl;
cout << "Vr: " << TMath::Abs( sqrt(pow(event->primaryVertex().x(),2) +
pow(event->primaryVertex().y(),2))) << endl;
cout << "VzVPD: " << event->vzVpd() << endl;
cout << "Full Vertex: " << event->primaryVertex() << endl;
``````

And here’s what I get when I run it, as an example; obviously there are thousands of these, but they all have 0 for every primaryVertex() entry:
Vz: 0
Vr: 0
VzVPD: 5.60292
Full Vertex: 0 0 0

When I do the cuts in Python, everything is fine. Python calls (via uproot) “Event.mPrimaryVertexX”. My code for reading those is as follows:

``````data = up.open('st_physics_19999_raw_1234.picoDst.root')

PicoDst = data["PicoDst"]

# These jagged arrays are to get the data out of the .root file.
mEpdId = PicoDst.arrays([b"EpdHit.mId"])
mEpdnMIP = PicoDst.arrays([b"EpdHit.mnMIP"])
mRefMult = PicoDst.arrays([b"Event.mGRefMult"])
mxVert = PicoDst.arrays([b"Event.mPrimaryVertexX"])
myVert = PicoDst.arrays([b"Event.mPrimaryVertexY"])
mzVert = PicoDst.arrays([b"Event.mPrimaryVertexZ"])
mVzVpd = PicoDst.arrays([b"Event.mVzVpd"])
mNBTOFMatch = PicoDst.arrays([b"Event.mNBTOFMatch"])
``````

Is there a way I can just call these in ROOT? I thought that would be event->primaryVertex().X(), but that clearly isn’t working.

No idea. I guess I could come up with a solution if I had access to your `st_physics_19999_raw_1234.picoDst.root`.

Here’s a link to a similar pico:
Ok, it looks like this file has to be processed in a dedicated framework, which I don’t have obviously. But you should definitely access branches named `Event.mPrimaryVertexX`, `Event.mPrimaryVertexY`, and `Event.mPrimaryVertexZ` rather than `event->primaryVertex().x()` and so on.