MadAnalysis / madanalysis5

A package for event file analysis and recasting of LHC results
http://madanalysis.irmp.ucl.ac.be
GNU General Public License v3.0
22 stars 18 forks source link

Not able to access genjets() in expert mode of MadAnalysis 5 v1.9.60. #266

Open meena91 opened 1 month ago

meena91 commented 1 month ago

Question

First I have produced tag_1_pythia8_events.hepmc.gz in MG5_aMC_v3_3_2  with Pythia8. Then I used Delphes v3.5.0 ./DelphesHepMC2 to convert HEP file into root files. I have saved genjets module FastJetFinder GenJetFinder { set InputArray NeutrinoFilter/filteredParticles set OutputArray genjets set JetAlgorithm 6 set ParameterR 0.4 set JetPTMin 1.0 }  "add Branch GenJetFinder/genjets GenJet Jet"in delphes card.  This is my loop in expert mode if (event.mc()!=0) { } if (event.rec()!=0 ) {std::cout << "Number of GenJets: " << event.rec()->genjets().size() << std::endl;} I am not getting error but genjets size is zero and there is no events for that. But I can see the events in delphes root files. Could you please help me in this case?

BFuks commented 1 month ago

Hi,

You should run Delphes from MA5 directly.

Regards,

Benjamin

meena91 commented 1 month ago

Dear Bejnamin,

Thank you for your reply. But I did not understand how I have to run delphes from MA5. Could you please elaborate it.

Thank you in advance, Meena

meena91 commented 1 month ago

Dear Benjamin,

I found some instruction /bin/ma5 -R set main.fastsim.package = delphes set main.fastsim.detector = cms import my_hepmc_file submit delphes_run

It will run on default card, but I want to use delphes_card_FCCeeDetWithSiTracking.tcl and AntiKt algorithm both at gen and reco -level. Could you please help how I have to modify these instructions? 

Thank you in Advance, Meena

BFuks commented 1 month ago

Hi,

The easiest way would be to replace the CMS delphes card by your delphes card.

Regards,

Benjamin

On 15 Oct 2024, at 15:52, meena91 @.***> wrote:

Dear Benjamin,

I found some instruction /bin/ma5 -R set main.fastsim.package = delphes set main.fastsim.detector = cms import my_hepmc_file submit delphes_run

It will run on default card, but I want to use delphes_card_FCCeeDetWithSiTracking.tcl and AntiKt algorithm both at gen and reco -level. Could you please help how I have to modify these instructions?

Thank you in Advance, Meena

— Reply to this email directly, view it on GitHub https://github.com/MadAnalysis/madanalysis5/issues/266#issuecomment-2413985399, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIWJNJ26TJPMSYJ5X6AWF63Z3UM25AVCNFSM6AAAAABP6S644WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJTHE4DKMZZHE. You are receiving this because you commented.

meena91 commented 1 month ago

Hi Benjamin,

I tried this way also, after  command "submit delphes_run" , I rename delphes_card_FCCeeDetWithSiTracking.tcl to delphes_cms.tcl in Input direcotry, then again I run Sample analyser on MG5_aMC_v3_3_2/MadAnalysis5/madanalysis5/delphes_run/Output/SAF/_defaultset/RecoEvents0_0/DelphesEvents.root Still there is same issue not able to access event.rec()->genjets()  while there are enough entries/events in DelphesEvents.root.  But I am able to access other gen particle with PDGID code in event.mc().

BFuks commented 1 month ago

Hi Meena,

Can you please check whether the genjets are available in the root file?

Regards,

Benjamin

On 16 Oct 2024, at 10:44, meena91 @.***> wrote:

Hi Benjamin,

I tried this way also, after command "submit delphes_run" , I rename delphes_card_FCCeeDetWithSiTracking.tcl to delphes_cms.tcl in Input direcotry, then again I run Sample analyser on MG5_aMC_v3_3_2/MadAnalysis5/madanalysis5/delphes_run/Output/SAF/_defaultset/RecoEvents0_0/DelphesEvents.root Still there is same issue not able to access event.rec()->genjets() while there are enough entries/events in DelphesEvents.root. But I am able to access other gen particle with PDGID code in event.mc().

— Reply to this email directly, view it on GitHub https://github.com/MadAnalysis/madanalysis5/issues/266#issuecomment-2416122171, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIWJNJYVTY4MNIYAJXGABGDZ3YRO3AVCNFSM6AAAAABP6S644WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJWGEZDEMJXGE. You are receiving this because you commented.

meena91 commented 1 month ago

In delphes card, this is the definition of genjets: add Branch GenJetFinder/genjets GenJet Jet so, In delphes, I can only middle name ( GenJet ) from this Branch GenJetFinder/genjets GenJet Jet. So, yes, I can see, also I am attaching the screenshot of root file branch.

Another example for reco-level jets are saved as  "add Branch JetEnergyScale/jets Jet Jet" in delphes card. So, we can Jet in delphes.root file and I am able to access that from SampleAnalyzer MA expert mode.

Best Regards, Meena

MA5_delphes_output
BFuks commented 1 month ago

Hi Meena,

I am sorry but I cannot do tests myself at the moment. Can you please try with the standard ATLAS or CMS card shipped with MA5 and tell me whether the problem persists?

Cheers,

Benjamin

On 16 Oct 2024, at 22:00, meena91 @.***> wrote:

In delphes card, this is the definition of genjets: add Branch GenJetFinder/genjets GenJet Jet so, In delphes, I can only middle name ( GenJet ) from this Branch GenJetFinder/genjets GenJet Jet. So, yes, I can see, also I am attaching the screenshot of root file branch.

Another example for reco-level jets are saved as "add Branch JetEnergyScale/jets Jet Jet" in delphes card. So, we can Jet in delphes.root file and I am able to access that from SampleAnalyzer MA expert mode.

Best Regards, Meena MA5_delphes_output.png (view on web) https://github.com/user-attachments/assets/3f0bd680-fddf-4ffb-9406-6b58c969f89c — Reply to this email directly, view it on GitHub https://github.com/MadAnalysis/madanalysis5/issues/266#issuecomment-2417830927, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIWJNJ57PBRXISFKMEC2YR3Z33AV3AVCNFSM6AAAAABP6S644WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJXHAZTAOJSG4. You are receiving this because you commented.

meena91 commented 1 month ago

Hi Benjamin,

Yes, I saw same issue with default cms card also. I tried both method for Branch in card default one is "add Branch GenJetFinder/jets GenJet Jet" and "add Branch GenJetFinder/genjets GenJet Jet"

Best Regards, Meena

BFuks commented 1 month ago

Hi Meena,

I do not remember the fundamental reason why genjets() have been made non-accessible anymore (they have been removed from tools/SampleAnalyzer/Interfaces/delphes/DelphesMemoryInterface.cpp). I imagine that this is because they are redundant with the information stored in event->mc()->particles() (from which you can easily extract genjets). I therefore see two solutions here:

I hope this helps.

Best regards,

Benjamin

On 16 Oct 2024, at 22:56, meena91 @.***> wrote:

Hi Benjamin,

Yes, I saw same issue with default cms card also. I tried both method for Branch in card default one is "add Branch GenJetFinder/jets GenJet Jet" and "add Branch GenJetFinder/genjets GenJet Jet"

Best Regards, Meena

— Reply to this email directly, view it on GitHub https://github.com/MadAnalysis/madanalysis5/issues/266#issuecomment-2417947949, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIWJNJ7B4VG4MQVOZO2VBO3Z33HIZAVCNFSM6AAAAABP6S644WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJXHE2DOOJUHE. You are receiving this because you commented.

meena91 commented 1 month ago

Dear Benjamin,

I tried both method but did not work. 1st method : Just uncommented the following lines in DelphesMemoryInterface.cpp and rerun the code but getting the same problem.

// --------------GenJet collection if (genjetsArray!=0) { for (MAuint32 i=0;i<static_cast(genjetsArray->GetEntries());i++) { Candidate cand = dynamic_cast<Candidate>(genjetsArray->At(i)); if (cand==0) { ERROR << "impossible to access the " << i+1 << "th genjet" << endmsg; continue; } RecJetFormat* genjet = myEvent.rec()->GetNewGenJet(); genjet->momentum = cand->Momentum; genjet->btag = cand->BTag; } }

void DelphesMemoryInterface::Initialize(TFolder* delphesFolder, const std::map<std::string,std::string>& table, MAbool MA5card) { // DelphesMA5 card ? delphesMA5card_=MA5card;

// Official Delphes collections GenJet_ = GetCollection(delphesFolder,table,"GenJet"); ...... }

2nd method: getting error that " no member named 'genjets' in 'MA5::MCParticleFormat''

for (MAuint32 i = 0; i < event.mc()->particles().size(); i++) { const MCParticleFormat* part = &(event.mc()->particles()[i]); cout<<" gen jets="<genjets().size<<endl; } error: no member named 'genjets' in 'MA5::MCParticleFormat'

Could you send me the modified DelphesMemoryInterface.cpp if I did not do it correctly. Is there any further command need to run after modifying DelphesMemoryInterface.cpp and before the delphes_run ?

Best Regards, Meena

BFuks commented 1 month ago

Hi Meena,

For the first method, uncommenting is not sufficient. You need to implement a new method in light of what is done for standard jets. For the second one, you need to test the PDGcode and statuscode of each MCParticleObject to select the particle-level jets.

Best regards,

Benjamin

On 17 Oct 2024, at 10:38, meena91 @.***> wrote:

Dear Benjamin,

I tried both method but did not work. 1st method : Just uncommented the following lines in DelphesMemoryInterface.cpp and rerun the code but getting the same problem.

// --------------GenJet collection if (genjetsArray!=0) { for (MAuint32 i=0;i<static_cast(genjetsArray->GetEntries());i++) { Candidate cand = dynamic_cast<Candidate>(genjetsArray->At(i)); if (cand==0) { ERROR << "impossible to access the " << i+1 << "th genjet" << endmsg; continue; } RecJetFormat* genjet = myEvent.rec()->GetNewGenJet(); genjet->momentum = cand->Momentum; genjet->btag = cand->BTag; } }

void DelphesMemoryInterface::Initialize(TFolder* delphesFolder, const std::mapstd::string,std::string& table, MAbool MA5card) { // DelphesMA5 card ? delphesMA5card_=MA5card;

// Official Delphes collections GenJet_ = GetCollection(delphesFolder,table,"GenJet"); ...... }

2nd method: getting error that " no member named 'genjets' in 'MA5::MCParticleFormat''

for (MAuint32 i = 0; i < event.mc()->particles().size(); i++) { const MCParticleFormat* part = &(event.mc()->particles()[i]); cout<<" gen jets="<genjets().size<<endl; } error: no member named 'genjets' in 'MA5::MCParticleFormat'

Could you send me the modified DelphesMemoryInterface.cpp if I did not do it correctly. Is there any further command need to run after modifying DelphesMemoryInterface.cpp and before the delphes_run ?

Best Regards, Meena

— Reply to this email directly, view it on GitHub https://github.com/MadAnalysis/madanalysis5/issues/266#issuecomment-2418917390, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIWJNJ5KCSTAJWLOGXW7LOTZ35ZQPAVCNFSM6AAAAABP6S644WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJYHEYTOMZZGA. You are receiving this because you commented.