About MALorentzVector

Asked by Zhicheng Liu

Dear experts,

I want to realize energy smearing in ma5. My plan is to add some codes to the file "Build/SampleAnalyzer/User/Analyzer/user.cpp". Firstly, I try to rescale the energy by the following codes

 *************************************

 MAdouble64 E_j;
        E_j = (event.mc()->particles()[i]).e() * 0.9;

       ((event.mc()->particles()[i]).momentum()).SetE(E_j);
***************************************

 When recompiling the file "user.cpp " , there is a error messege

SampleAnalyzer/User/Analyzer/user.cpp:79:52: error: passing ‘const MA5::MALorentzVector’ as ‘this’ argument discards qualifiers [-fpermissive]
  ((event.mc()->particles()[i]).momentum()).SetE(E_j);

However, in "/madanalysis5/tools/SampleAnalyzer/Commons/Vector/MALorentzVector.h ", there indeed exist the method "SetE"
****
  // Simple mutators ---------------------------------------------
  void SetX (MAdouble64 x) {p_.SetX(x);}
  void SetY (MAdouble64 y) {p_.SetY(y);}
  void SetZ (MAdouble64 z) {p_.SetZ(z);}
  void SetT (MAdouble64 e) {e_=e; }
  void SetPx(MAdouble64 x) {p_.SetX(x);}
  void SetPy(MAdouble64 y) {p_.SetY(y);}
  void SetPz(MAdouble64 z) {p_.SetZ(z);}
  void SetE (MAdouble64 e) {e_=e; }
*****

Can you tell me How to solve the problem?
Thank you in advance !

Best,
Zhicheng Liu

Question information

Language:
English Edit question
Status:
Solved
For:
MadAnalysis 5 Edit question
Assignee:
No assignee Edit question
Solved by:
Benjamin Fuks
Solved:
Last query:
Last reply:
Revision history for this message
Best Benjamin Fuks (fuks) said :
#1

Hi Zhicheng,

The event.mc()->particles() object is a vector of **constant** particles that cannot therefore be modified. Try instead:
        MCParticleFormat mypart=event.mc()->particles()[i];
        double E_j = (event.mc()->particles()[i]).e() * 0.9;
        (mypart.momentum()).SetE(E_j);

Regards,

Benjamin

Revision history for this message
Zhicheng Liu (zhichengonly) said :
#2

Thanks Benjamin Fuks, that solved my question.