Hi everyone,
This is my first post so if I’m doing something wrong or breaking site convention please let me know. I am hoping someone can help me solve this error that I’m getting. I am using beginInputFile() to access variables and then I want to fill histograms in execute(). I get a segmentation violation when I try to run this code (for now not even filling histograms, just trying to print out the value of the vector). The code I am posting below is a very condensed version but I think I included everything relevant. The error occurs when I try to print out the value of the pt vector.
#include <AsgTools/MessageCheck.h>
#include <MyAnalysis/Project1.h>
#include <xAODEventInfo/EventInfo.h>
#include <xAODJet/JetContainer.h>
#include <TSystem.h>
#include <PATInterfaces/CorrectionCode.h> // to check the return correction code status of tools
#include <TApplication.h>
#include <vector>
#include <xAODCore/ShallowAuxContainer.h>
#include <xAODCore/ShallowCopy.h>
#include <xAODCore/AuxContainerBase.h>
#include <JetCalibTools/IJetCalibrationTool.h>
Project1 :: Project1 (const std::string& name,
ISvcLocator *pSvcLocator)
: EL::AnaAlgorithm (name, pSvcLocator)
{
}
StatusCode Project1 :: beginInputFile ()
{
TTree* fChain = wk()->tree();
fChain->SetBranchAddress("tvar_event_AntiKt10OrigLCTopoTrimmedPtFrac5SmallR20_njets", &tvar_event_AntiKt10OrigLCTopoTrimmedPtFrac5SmallR20_njets);
fChain->SetBranchAddress("tvar_jet_AntiKt10OrigLCTopoTrimmedPtFrac5SmallR20_pt", &tvar_jet_AntiKt10OrigLCTopoTrimmedPtFrac5SmallR20_pt);
return StatusCode::SUCCESS;
}
StatusCode Project1 :: initialize ()
{
ANA_MSG_INFO ("in initialize");
return StatusCode::SUCCESS;
}
StatusCode Project1 :: execute ()
{
ANA_MSG_INFO ("in execute");
wk()->tree()->GetEntry (wk()->treeEntry());
ANA_MSG_INFO ("pt value: " << tvar_jet_AntiKt10OrigLCTopoTrimmedPtFrac5SmallR20_pt->at(0)); //here I try to print out the first value of this vector
return StatusCode::SUCCESS;
}
StatusCode Project1 :: finalize ()
{
ANA_MSG_INFO ("in finalize");
return StatusCode::SUCCESS;
}
I initialize the variables in my header file as:
Int_t tvar_event_AntiKt10OrigLCTopoTrimmedPtFrac5SmallR20_njets;
std::vector<float> *tvar_jet_AntiKt10OrigLCTopoTrimmedPtFrac5SmallR20_pt;
and the functions:
virtual StatusCode beginInputFile () override;
virtual StatusCode initialize () override;
virtual StatusCode execute () override;
virtual StatusCode finalize () override;
both in the public in my class in the header file.
The stack trace from the segmentation violation is:
#5 0x00007f68a5481a7d in Project1::execute (this=0xfe3c060) at /afs/cern.ch/user/b/blubis/ROOTAnalysisTutorial/source/MyAnalysis/Root/Project1.cxx:341
#6 0x00007f68a6d8e422 in EL::AnaAlgorithm::sysExecute() () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBase/21.2.48/InstallArea/x86_64-slc6-gcc62-opt/lib/libAnaAlgorithmLib.so
#7 0x00007f68a6dea19b in EL::AnaAlgorithmWrapper::execute() () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBase/21.2.48/InstallArea/x86_64-slc6-gcc62-opt/lib/libEventLoop.so
#8 0x00007f68a6e1308a in EL::Worker::algsExecute() () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBase/21.2.48/InstallArea/x86_64-slc6-gcc62-opt/lib/libEventLoop.so
#9 0x00007f68a6dfa7e2 in EL::DirectWorker::run() () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBase/21.2.48/InstallArea/x86_64-slc6-gcc62-opt/lib/libEventLoop.so
#10 0x00007f68a6df9f86 in EL::DirectDriver::doSubmit(EL::Job const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBase/21.2.48/InstallArea/x86_64-slc6-gcc62-opt/lib/libEventLoop.so
#11 0x00007f68a6dfcad4 in EL::Driver::submitOnly(EL::Job const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBase/21.2.48/InstallArea/x86_64-slc6-gcc62-opt/lib/libEventLoop.so
#12 0x00007f68a6dfd1b9 in EL::Driver::submit(EL::Job const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) const () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBase/21.2.48/InstallArea/x86_64-slc6-gcc62-opt/lib/libEventLoop.so
#13 0x00007f68bafd3551 in ?? ()
#14 0x0000000005abef90 in ?? ()
#15 0x0000000000000088 in ?? ()
#16 0x0000000005a617b0 in ?? ()
#17 0x0000000f00000001 in ?? ()
#18 0x00007f68bafd3110 in ?? ()
#19 0x0000000001e84830 in ?? ()
#20 0x0000000005a61828 in ?? ()
#21 0x00007f68bafd3110 in ?? ()
#22 0x0000000005b3aaf0 in ?? ()
#23 0x0000000000000015 in ?? ()
#24 0x0000000001990410 in ?? ()
#25 0x00007f68b5993675 in llvm::RuntimeDyldImpl::resolveExternalSymbols() () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBaseExternals/21.2.48/InstallArea/x86_64-slc6-gcc62-opt/lib/libCling.so
There are several things that are weirding me out about this, but the number one thing is that the code posted above worked for a hot second, once, then reverted right back to throwing up the same error (nothing changed, I swear). I’ve also got a segmentation violation, immediately ran the code again, got an error like
terminate called after throwing an instance of ‘std::out_of_range’
what(): vector::_M_range_check: __n (which is 2) >= this->size() (which is 0)
then ran again, and back to segmentation violation. So, from the time that it ran correctly and printed out the pt values, I’m pretty sure the vectors are storing the information, but now it’s like I can’t access the info and nothing is stored in the vector since according to the second error the size is 0. So obviously something is wrong with how I’m trying to access the data.
So bottom line, I’m very confused. Any help would be appreciated!
Thanks,
Billie
ROOT Version: 5.32/03
Platform: CentOS7
Compiler: gcc version 6.2.0