HEP-KBFI / TallinnNtupleProducer

code, python scripts and config files for producing "plain" Tallinn Ntuples
3 stars 2 forks source link

Fix a couple of runtime problems #1

Closed ktht closed 2 years ago

ktht commented 2 years ago

The main problem that triggered this investigation was this line: https://github.com/HEP-KBFI/TallinnNtupleProducer/blob/ed53fc8e90e8df7959e21d1cdd0a63066d14c60b/Framework/bin/produceNtuple.cc#L248 The writer object was nullptr which is why the 2nd line that follows caused the segmentation violation. I'm not entirely sure how the ownership works here, but the C++ documentation says that if the object is not owned then the last get() call returns a nullptr. In any case, promoting the writer variable to unique_ptr seems to work.

The second error I got was related to the instantiation of EventInfo object in EventInfoReader: the AnalysisConfig object is created on stack, then its address is passed to EventInfo and then the AnalysisConfig object goes out of scope, thus rendering its pointer invalid. The solution is to move AnalysisConfig to heap.

The third error was caused by reading a collection that does not exist in the input Ntuple (GenPhotonCandidates). Swapped writers_genPhotonFilter for writers_met in the cfg file. Also limited the number of events to 100 -- just for testing.

I then got a fourth error that was related to lumiscale weights. I hacked the EvtWeightRecorder to see if I get any more errors -- and I unfortunately did, so that's where I stopped. I'm not going to push the hack I did here, but the rest of the changes in this PR should be solid.

Also, added .gitignroe, since there were too many artifacts created by scram after compiling the code, which we don't want to accidentally push to the repo.