Differences between revisions 3 and 4
Revision 3 as of 2022-06-20 16:14:47
Size: 3602
Editor: BohdanDudar
Comment:
Revision 4 as of 2022-06-20 16:31:04
Size: 3482
Editor: BohdanDudar
Comment: Some typos and style
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
== Very important note == '''Contents'''
<<TableOfContents(2)>>
Line 5: Line 6:
LCIO ( Linear Collider I/O ) is a framework and event data model for linear collider detector studies.
It is '''strongly discouraged''' to modify any LCIO objects in any way for your analysis!!! LCIO is supposed to be a '''single and common''' tool/event data model for different experiments and analyses!
The last thing we need is 20 personalized LCIO versions!!! If something is missing which you think would be nice to have, communicate and ask, so it is implemented in the common software for general use.
== Important note ==

It is '''strongly discouraged''' to modify any LCIO objects in any way for your personal analysis!!!

LCIO is supposed to be a '''single and common''' framework for multiple different experiments and analyses!

/* '''The last thing we need is 20 personalized LCIO versions!!!''' */

If something is missing which you think would be nice to have, communicate and ask, so it is implemented in the common software for general use.
Line 12: Line 20:
Currently, workaround exists to attach additional parameters to the Reconstructed``Particle objects inside PID section. However, workaround exists to attach additional parameters to the Reconstructed``Particle objects.
Line 15: Line 23:
== Workaround on how to write custom parameter to ReconstructedParticle object == == How to write custom parameters ==
Line 17: Line 25:
As a workaround, we can use PID``Handler to attach a parameter/number to existing Reconstructed``Particle object like this: You can use PID``Handler to attach a parameter to existing Reconstructed``Particle object like this:
Line 42: Line 50:
You should be able to see corresponding lines saved in the dumpevent: You should be able to see corresponding lines saved in the dumpevent.
Line 44: Line 52:
This does '''NOT''' write information to the actual slcio file stored on the disk which is being processed.
Line 45: Line 54:
'''Note:'''
T
his information will be accesible only within current Marlin run for further executed processors.
This does '''NOT''' overwrite information inside analysed file. To save this information on a disk you will need to create an output file using e.g. LCIOOutputProcessor.
So this information will be accessible only within current Marlin run for further executed processors.
Line 49: Line 56:
To save this information on a disk you will need to create an output file using e.g. LCIOOutputProcessor.
Line 50: Line 58:
== Workaround on how to read custom parameters from ReconstructedParticle object == == How to read custom parameters ==
Line 52: Line 60:
Here is code example how to access attached parameters to the PFO: Here is code example how to access attached parameters to the Reconstructed``Particle:

How to attach custom parameter to LCIO object

Contents

Important note

It is strongly discouraged to modify any LCIO objects in any way for your personal analysis!!!

LCIO is supposed to be a single and common framework for multiple different experiments and analyses!

If something is missing which you think would be nice to have, communicate and ask, so it is implemented in the common software for general use.

For this you can open an issue for discussion in the github repository https://github.com/iLCSoft/LCIO/issues

With this in mind, LCIO objects are designed, so you cannot simply write your custom members to the class on will.

However, workaround exists to attach additional parameters to the ReconstructedParticle objects.

How to write custom parameters

You can use PIDHandler to attach a parameter to existing ReconstructedParticle object like this:

void MyWriteMarlinProcessor::processEvent(EVENT::LCEvent * evt){

    LCCollection* pfos = evt->getCollection("PandoraPFOs");
    PIDHandler pidHandler( pfos );

    int algoID = pidHandler.addAlgorithm( "MyCustomParameters", {"Awesomeness", "Cutiness"} );

    
    for (int i=0; i<pfos->getNumberOfElements(); ++i){
        ReconstructedParticle* pfo = static_cast <ReconstructedParticle*> ( pfos->getElementAt(i) );
        float awesomeness = std::sqrt( pfo->getEnergy()*42.);
        float cutiness = i*42/365.;

        std::vector<float> parameters = {awesomeness, cutiness};

        // This line attached our parameters to the specific pfo object inside our algorihm PID information.
        pidHandler.setParticleID(pfo , 0, 0, 0., algoID, parameters);
    }

}

You should be able to see corresponding lines saved in the dumpevent.

This does NOT write information to the actual slcio file stored on the disk which is being processed.

So this information will be accessible only within current Marlin run for further executed processors.

To save this information on a disk you will need to create an output file using e.g. LCIOOutputProcessor.

How to read custom parameters

Here is code example how to access attached parameters to the ReconstructedParticle:

// Simple utility function that extracts requested parameter from the PFO
float MyReadMarlinProcessor::getParameterFromPID(ReconstructedParticle* pfo, PIDHandler& pidHandler, std::string algorithmName, std::string parameterName){
    int algorithmID = pidHandler.getAlgorithmID(algorithmName);
    const ParticleID& pfoPID = pidHandler.getParticleID(pfo, algorithmID);
    const std::vector<float>& parameters = pfoPID.getParameters();
    int parIdx = pidHandler.getParameterIndex(algorithmID, parameterName);
    return parameters[parIdx]; 
}

void MyReadMarlinProcessor::processEvent(LCEvent* event){
    LCCollection* pfos = event->getCollection("PandoraPFOs");
    PIDHandler pidHandler(pfos);

    for(int i=0; i < pfos->getNumberOfElements(); ++i){
        ReconstructedParticle* pfo = static_cast <ReconstructedParticle*> ( pfos->getElementAt(i) );
        float awesomenessOfThisPFO = getParameterFromPID(pfo, pidHandler, "MyCustomParameters", "Awesomeness");
        float cutinessOfThisPFO = getParameterFromPID(pfo, pidHandler, "MyCustomParameters", "Cutiness");
    }
}

HowToAttachCustomParameterToLCIOObject (last edited 2022-06-20 16:31:04 by BohdanDudar)