iris-hep / func_adl_xAOD

Client interface to send a hierarchical SQL-like query to an xAOD backend
0 stars 5 forks source link

Implement all the variables for the CMS Run 1 AOD Demo #143

Closed gordonwatts closed 3 years ago

gordonwatts commented 3 years ago

The run 1 demo from CMS makes a final Higgs to 4 lepton plot. Looking through that there are a number of variables that are extracted to make the plot and selections that require some more complex type information than is currently supported by the cms run 1 aod extractor.

This issue is to complete the set of variables required for extraction.

sudo-panda commented 3 years ago

List of variables that need to be supported:

gordonwatts commented 3 years ago

Meeting minutes from a detailed discussion of this...

How to do SelectIndex

Experiment's Datamodel

class Event:
    @property
    def tracks(self) -> Array[Track]

class Track:
    @property
    def pt(self) -> float

    @property
    def hitPattern(self) -> HitPattern

class HitPattern:
    @property
    def nHits(self) -> int

    def getHitPattern(self, i: int) -> int

    def validHitFilter(self, hp: int) -> bool

func_adl Query

Want the track pt's of all tracks with more than 5 valid hits (in the hit pattern mask)

Define events as our source dataset upon which all func_adl queries run (e.g. ObjectStream)

Low level func_adl:

events
    .SelectMany(e: e.tracks())
    .Where(t: Range(0, t.hitPattern().nHits)
                 .Select(nth: t.hitPattern().getHitPattern(nth)))
                 .Where(hp: t.hitPattern.validHitFilter(hp))
                 .Count() > 5
           )
    .Select(t: t.pt())

Comments:

Using SelectIndex

events
    .SelectMany(e: e.tracks())
    .Where(t: SelectIndex(t.hitPattern().nHits, nth: t.hitPattern().getHitPattern(nth))
                 .Where(hp: t.hitPattern.validHitFilter(hp))
                 .Count() > 5
           )
    .Select(t: t.pt())

Comments

If we added SelectIndex:

LINQ Query:

events
    .SelectMany(e: e.tracks("Tracks"))
    .Where(t: Range(0, t.hitPattern().nHits)
                 .Select(nth: t.hitPattern().getHitPattern(nth)))
                 .Where(hp: t.hitPattern().validHitFilter(hp))
                 .Count() > 5
           )
    .Select(t: t.pt())

C++ Code


Tracks = iEvent.getByLabel("Tracks")

for(auto *t : Tracks) {
    int c =0 ;
    int length = t.hitPattern().nHits();
    int start_index = 0;
    for(int i=start_index; i<length; i++) {
        hp = t.hitPattern().getHitPattern(i);
        if(t.hitPattern().validHitFilter(hp)) {
          c++;
        }
    }

    if(c>5) {
        double p = t.pt();
        ttree->Fill(p);
    }
}
gordonwatts commented 3 years ago

This was done!