# Compiler Error when filling Ntuples with a vector

**URL:** <https://geant4-forum.web.cern.ch/t/compiler-error-when-filling-ntuples-with-a-vector/13114>\
**Category:** Recording, Visualizing and Persisting Data\
**Created:** [October 27, 2024, 3:13pm UTC](https://geant4-forum.web.cern.ch/t/compiler-error-when-filling-ntuples-with-a-vector/13114 "2024-10-27T15:13:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dboccanf](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/dboccanf/32/8549_2.png) [@dboccanf](https://geant4-forum.web.cern.ch/u/dboccanf)\
**Post date:** [October 27, 2024, 3:13pm UTC](https://geant4-forum.web.cern.ch/t/compiler-error-when-filling-ntuples-with-a-vector/13114/1 "2024-10-27T15:13:52Z")

</div>

Please fill out the following information to help in answering your question, and also see [tips for posting code snippets](https://geant4-forum.web.cern.ch/t/how-to-post-code-snippets/9944). If you don’t provide this information it will take more time to help with your problem!

_Geant4 Version:11.2.2_  
_Operating System:Ubuntu 22.04_  
_Compiler/Version:11.4.0_  
_CMake Version:3.22.1_

* * *

Dear Experts,

I’m running example B5 to learn how to fill ntuples with std::vectors. The example compiles and runs without problems. I tried to add a column myself to see if I could do it and the program does not compile anymore. Here’s what I did:

In EventAction.hh

```auto
class EventAction : public G4UserEventAction
private:
  std::vector<G4double> vec_test;

```

In EventAction.cc

```auto
void EventAction::BeginOfEventAction(const G4Event*)
{
  vec_test={0.1, 0.2, 0.3};
}
void EventAction::EndOfEventAction(const G4Event* event)
{
  analysisManager->FillNtupleDColumn(8, vec_test);
  analysisManager->AddNtupleRow();
}

```

And of course in RunAction.cc

```auto
analysisManager->CreateNtupleDColumn("Test", fEventAction->vec_test);

```

The compiler error I get is:

```auto
/home/dboccanfuso/geant4_local/test_range/B5/src/EventAction.cc: In member function ‘virtual void B5::EventAction::EndOfEventAction(const G4Event*)’:
/home/dboccanfuso/geant4_local/test_range/B5/src/EventAction.cc:240:37: error: no matching function for call to ‘G4GenericAnalysisManager::FillNtupleDColumn(int, std::vector<double>&)’
  240 | analysisManager->FillNtupleDColumn(8, vec_test);

```

I don’t see where my error lies.

---

<div class="post-metadata">

**Author:** ![bmorgan](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/bmorgan/32/7_2.png) [@bmorgan](https://geant4-forum.web.cern.ch/u/bmorgan)\
**Post date:** [October 28, 2024, 1:21pm UTC](https://geant4-forum.web.cern.ch/t/compiler-error-when-filling-ntuples-with-a-vector/13114/3 "2024-10-28T13:21:18Z")

</div>

Pinging @ivana and @gybarran for their input.

---

<div class="post-metadata">

**Author:** ![ivana](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/ivana/32/186_2.png) [@ivana](https://geant4-forum.web.cern.ch/u/ivana)\
**Post date:** [November 7, 2024, 10:46am UTC](https://geant4-forum.web.cern.ch/t/compiler-error-when-filling-ntuples-with-a-vector/13114/4 "2024-11-07T10:46:30Z")

</div>

Hello,

You should remove the line

```cpp
analysisManager->FillNtupleDColumn(8, vec_test);

```

as the function `FillNtupleDColumn` should be used for columns of the `double` value type. To fill a vector, the vector should be updated in your application, and then it will be filled (saved) automatically at `AddNtupleRow()` call.

For example, in your use case:

```cpp
void EventAction::EndOfEventAction(const G4Event* event)
{
  vec_test[0] = 0.5;
  vec_test[1] = 0.6;
  // Fill columns of value types is present
  analysisManager->AddNtupleRow();
}

```

You can find the example of usage of ntuple vector columns in basic example B5.

Best regards,
