Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 

Code Block
languagejava
public void process(EventHeader event) {        
    List<CalorimeterHit> hits = event.get(CalorimeterHit.class, "EcalHits");
    for (CalorimeterHit hit : hits) {
        System.out.println("calorimeter hit has energy " + hit.getCorrectedEnergy() + " GeV.");
    }
}

You may also get all collections of a given type by not providing a collection name which will return a "list of lists."

Code Block
languagejava
public void process(EventHeader event) {        
    List<List<CalorimeterHit>> collections = event.get(CalorimeterHit.class);
    for (List<CalorimeterHit> hits : collections) {    
        for (CalorimeterHit hit : hits) {
            System.out.println("calorimeter hit has energy " + hit.getCorrectedEnergy() + " GeV.");
        }
    }
}

Collection Metadata

Each collection in the event has an associated metadata object with information about it.

Code Block
languagejava
public void process(EventHeader event) {        
    List<List<CalorimeterHit>> collections = event.get(CalorimeterHit.class);
    for (List<CalorimeterHit> hits : collections) {    
        System.out.println("found Calorimeter collection: " + event.getMetaData(hits).getName());
    }
}

Writing Event Data

New collections can be added to the event using the put method of EventHeader.

Code Block
languagejava
public void process(EventHeader event) {        
    // Create new collection somehow!
    List<Track> myFancyTracks = createFancyTracks(event);
 
    // Put new collection into the event.
    int flag = 1 << LCIOConstants.TRBIT_HITS;
    event.put("MyFancyTracks", fancyTrackCollection, Track.class, flag);
}

Flags is an integer bit mask with values defined in the LCIOConstants class.

AIDA Histogramming