Error during the compilation of the program

Hi everibody
I’m trying to compile a new program with one class that it creates some vector with data. I want to use this vector in my program to fill some histograms.
When I try to run the program, root takes me out this error:

IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster11GetCentroidEv’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::GetCentroid()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster13isGoodClusterEiRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::isGoodCluster(int, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster8GetSum_qEv’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::GetSum_q()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster12GetN_ClusterEv’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::GetN_Cluster()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7ClusterC1ERSt3mapIiiSt4lessIiESaISt4pairIKiiEEERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::Cluster(std::map<int, int, std::less, std::allocator<std::pair<int const, int> > >&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN7Cluster8GetChambB5cxx11Ev’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_29’!
You are probably missing the definition of Cluster::GetChambabi:cxx11
Maybe you need to load the corresponding shared library?

where the various Cluster::GetChamb() etc are the function that I have declared in my Class Cluster.

The following is my class.h code:

#ifndef _CLUSTER_H_
#define _CLUSTER_H_

#include <iostream>
#include <vector>
#include <string.h>
#include <map>
#include "TROOT.h"

using namespace std;

class Cluster {
	public:
		Cluster(map<int, int> &map, string &name);
		void reset();
		vector<string> GetChamb();
		vector<double> GetCentroid();
		vector<int> GetClusterStrip();
		vector<int> GetClusterMax_q();
		vector<int> GetSum_q();
		//vector<int> GetN_Cluster();
		vector<int> GetPCB();
		int GetN_Cluster();
		bool isGoodCluster(int charge_min, string &name);
	private:
		vector<int> 	_strip;
		vector<string> 	_chamb;
		vector<int> 	_max_q;
		vector<double>	_centroid;
		vector<int>		_sum_q;
		vector<int>		_n_cluster;
		vector<int>		_pcb;
		int 			_n_clu;
		unsigned int	_n_holes;
};

#endif

while this is my class.cxx code:

#ifndef _CLUSTER_CXX_
#define	_CLUSTER_CXX_

#include "header_files/cluster.h"
#include "../prova.h"
#include <iostream>
#include <vector>
#include <string.h>
#include <map>
#include "TROOT.h"

using namespace std;

Cluster::Cluster(map<int, int> &map, string &name) 
{
	this->reset();
	if(map.size()>1){
		_n_clu = 0;
		vector<int> temp_cluster, temp_max_q, vec_strip, vec_max_q;
		for (std::map<int,int>::iterator it=map.begin(); it!=map.end(); it++){ 
			vec_strip.push_back(it->first);//copio gli elementi della mappa su due vettori d'appoggio
			vec_max_q.push_back(it->second);
		}
		unsigned int k = 0;//variabile che mi tiene conto dello scorrere degli elementi dei vettori 
		while(k<(vec_strip.size()-1)){//giro su tutto il vettore delle strip
			int j = 0; //variabile che mi tiene conto del numero di volte che sono entrato nel ciclo 
			double centroid_coord = 0; 
			int temp_q_sum = 0;//variabili per il calcolo del centroide
			while((k<(vec_strip.size()-1)) && ((vec_strip.at(k+1) - vec_strip.at(k)) <= 3)){//controllo cluster
				if((vec_strip.at(k+1) - vec_strip.at(k)) == 2) 
					_n_holes++;
				if(j<1){//ci entro solo all'inizio del cluster
					temp_cluster.push_back(vec_strip.at(k));//riempio i vettori con gli elementi dell'inizio del cluster
					temp_max_q.push_back(vec_max_q.at(k));
					centroid_coord += (vec_strip.at(k)*pitch*vec_max_q.at(k));
					temp_q_sum += vec_max_q.at(k);
				}
				temp_cluster.push_back(vec_strip.at(k+1));//riempio i vettori con gli elementi successivi del cluster
				temp_max_q.push_back(vec_max_q.at(k+1));
				centroid_coord += (vec_strip.at(k+1)*pitch*vec_max_q.at(k+1));
				temp_q_sum += vec_max_q.at(k+1);
				j++;//tiene conto della grandezza del cluster
				k++;
			}
			if(j > 10 || _n_holes > n_holes_max){//controllo che il cluster non sia troppo grande
				temp_cluster.clear();
				temp_max_q.clear();
				centroid_coord = 0;
				temp_q_sum = 0;
			}else if(j!= 0 && j<= 10){//controllo che il cluster ci sia e che sia minore di 10 strips. Inoltre calcolo il centroide
				_n_clu++;	
				for(UInt_t i = 0; i<temp_cluster.size(); i++){
					_strip.push_back(temp_cluster.at(i));//riempio il vettore con le strip del cluster
					_max_q.push_back(temp_max_q.at(i));//riempio il vettore con la carica delle strip
					_chamb.push_back(name); //riempio il vettore con il nome della camera a cui appartiene il cluster
					if(i == 0){ 
						_sum_q.push_back(temp_q_sum);
						_n_cluster.push_back(_n_clu);//do un numero al cluster
						_centroid.push_back(centroid_coord/temp_q_sum);//mi segno il valore del centroide del cluster
						_pcb.push_back((int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+1); 
						pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
					}else{
						_sum_q.push_back(0);
						_n_cluster.push_back(0);//do un numero al cluster
						_centroid.push_back(0);//mi segno il valore del centroide del cluster
						_pcb.push_back(0); 
					}
				}
				temp_cluster.clear();//svuoto entrambi i vettori dei cluster
				temp_max_q.clear();
			}
			while((k<(vec_strip.size()-1)) && ((vec_strip.at(k+1) - vec_strip.at(k))>3)){//se non c'è un cluster, comunque scorro sul vettore con il k
				k++;
			}
		}
	}
}
void Cluster::reset(){
	_strip.clear();
	_chamb.clear();
    _max_q.clear();
    _centroid.clear();
    _sum_q.clear();
    _n_cluster.clear();
    _pcb.clear();	
	_pcb_n_cluster.clear();
	_n_holes = 0;
}
vector<string> Cluster::GetChamb()
{
	return _chamb;
}
vector<double> Cluster::GetCentroid()
{
	return _centroid;
}
vector<int> Cluster::GetClusterStrip()
{
	return _strip;
}
vector<int>	Cluster::GetClusterMax_q()
{
	return _max_q;
}
vector<int> Cluster::GetSum_q()
{
	return _sum_q;
}
int Cluster::GetN_Cluster()
{
	return _n_clu;
}
vector<int> Cluster::GetPCB()
{
	return _pcb;
}
Cluster::isGoodCluster(int charge_min, string &name) const
{
	for(UInt_t i = 0; i<chamb.size(); i++){
		if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)
			return false;
	}
	return true;
}

What could be the probelm?

Hello,
could you provide MWE?

In witch way? This is the loop program in which the class is called:

#define prova_cxx
#include "prova.h"
#include <TH2.h>
#include <TH1.h>
#include <TLine.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <iostream>
#include <vector>
#include "TROOT.h"
#include <TLegend.h>
#include <fstream>
#include <algorithm>
#include <map>
#include <TGraph.h>
#include <TDirectory.h>
#include <math.h>
#include <TMultiGraph.h>
#include <TObject.h>
#include <TTree.h>
#include <string.h>
#include <TString.h>
#include <TProfile.h>
#include "header_files/cluster.h"

using namespace std;

void prova::Loop()
{
//   In a ROOT session, you can do:
//      root> .L prova.C
//      root> prova t
//      root> t.GetEntry(12); // Fill t data members with entry number 12
//      root> t.Show();       // Show values of entry 12
//      root> t.Show(16);     // Read and show values of entry 16
//      root> t.Loop();       // Loop on all entries
//

//     This is the loop skeleton where:
//    jentry is the global entry number in the chain
//    ientry is the entry number in the current Tree
//  Note that the argument to GetEntry must be:
//    jentry for TChain::GetEntry
//    ientry for TTree::GetEntry and TBranch::GetEntry
//
//       To read only selected branches, Insert statements like:
// METHOD1:
//    fChain->SetBranchStatus("*",0);  // disable all branches
//    fChain->SetBranchStatus("branchname",1);  // activate branchname
// METHOD2: replace line
//    fChain->GetEntry(jentry);       //read all branches
//by  b_branchname->GetEntry(ientry); //read only this branch
//	gROOT−>Reset();
//	gROOT−>SetStyle("Plain");
//	gStyle − > SetOptStat ( 1 1 1 1 1 1 ) ;
//	gStyle − > SetOptFit ( 1 1 1 1 ) ;
//	gStyle − > SetPalette ( 1 ) ;
//	gStyle − > SetOptTitle ( 0 ) ;
    if (fChain == 0) return;

	gErrorIgnoreLevel = kWarning;

    Long64_t nentries = fChain->GetEntriesFast(); 
    Long64_t nbytes = 0, nb = 0;
	//prendo il nome del run e lo uso per chiamarci i file su cui salvo gli output
	TString namefile =  ((TChain*)(fChain))->GetFile()->GetName();
	TString namef = namefile;
	namef.ReplaceAll("data/","");
	namef.Remove(namef.Index(".root"));
	TFile* f = new TFile(("/home/leonardo/Scrivania/Roba/TBReco/root_output/class_test_" + namef + ".root"), "RECREATE");
	_outdirname_lay = "LAYERS";
	f->mkdir(_outdirname_lay);
	
	//QUI CI VANNO LE DEFINIZIONI DEGLI HISTO PRIMA DI LOOPPARE SUGLI EVENTI
	//HISTO CAMERE
	vector<TH1F*> h_strip_chamb;
	vector<TH1F*> h_max_q_chamb;
	vector<TProfile*> profile_strip_max_q;
	vector<TH2F*> h2_strip_max_q_chamb;
	vector<TH1F*> h_number_strip_chamb;
	vector<TH1F*> h_number_cluster_chamb;
	vector<TH1F*> h_centroid_chamb;
	vector<TH1F*> h_sum_q_cluster_chamb;
	vector<TH2F*> h2_centroid_sum_q;
	//vector<TGraph*> centroid_reco_vs_real;
	TH1* evt_vs_layer = new TH1F("evt_vs_layer","Event vs layer turned on; Evt; Number of Layer",4,0.5,4.5);
	for(int j = 0; j<4; j++){
		h_strip_chamb.push_back(new TH1F(("h_strip_chamb_"+ to_string(j+1)).c_str(),("Histo strip chamb "+to_string(j+1)+";Strip;Entries").c_str(),530,500,1030));
		h_max_q_chamb.push_back(new TH1F(("h_max_q_chamb_"+ to_string(j+1)).c_str(),("Distribution charge max chamb "+to_string(j+1)+";Max_q;Entries").c_str(),150,0.0,2500));
		profile_strip_max_q.push_back(new TProfile(("profile_strip_max_q"+ to_string(j+1)).c_str(),("profile_strip_max_q"+to_string(j+1)+":Strip;Profile Max_q").c_str(),530,500,1030,0.0,2500));
		h2_strip_max_q_chamb.push_back(new TH2F(("h2_strip_max_q_chamb_"+ to_string(j+1)).c_str(),("Histo strip vs max_q chamb "+to_string(j+1)+";Strip;Max_q").c_str(),530,500,1030,150,0.0,2500));
        h_number_strip_chamb.push_back(new TH1F(("h_number_strip_chamb_"+ to_string(j+1)).c_str(),("Histo molteplicita' strip per evento chamb "+to_string(j+1)+";Number of strip;Event").c_str(),200,0.0,200));
        h_number_cluster_chamb.push_back(new TH1F(("h_number_cluster_chamb_"+ to_string(j+1)).c_str(),("Histo molteplicita' cluster per evento chamb "+to_string(j+1)+";Number of cluster;Event").c_str(),50,0.0,50));
        h_centroid_chamb.push_back(new TH1F(("h_centroid_chamb_"+ to_string(j+1)).c_str(),("Histo centroid chamb "+to_string(j+1)+";Centroid [mm];Entries").c_str(),200,0.0,2200));
        h_sum_q_cluster_chamb.push_back(new TH1F(("h_sum_q_cluster_chamb_"+ to_string(j+1)).c_str(),("Distribution sum of charge chamb "+to_string(j+1)+";Sum_q;Event").c_str(),500,0.0,10000));
		h2_centroid_sum_q.push_back(new TH2F(("h2_centroid_sum_q"+ to_string(j+1)).c_str(),("Centroid vs sum of charge chamb "+to_string(j+1)+";Centroid [mm];Sum_q").c_str(),200, 0.0, 2200, 500,0.0,10000));
		h2_extrapolate_pos.push_back(new TH2F(("h2_extrapolate_pos"+ to_string(j+1)).c_str(),("Extrapolate cluster position vs real position"+to_string(j+1)+";Extrapolate[mm];Real[mm]").c_str(),200,0.0,2200,200,0.0,2200));
		h2_extrapolate_pos_fit.push_back(new TH2F(("h2_extrapolate_pos_fit"+ to_string(j+1)).c_str(),("Extrapolate cluster position vs real position by fit"+to_string(j+1)+";Extrapolate[mm];Real[mm]").c_str(),200,0.0,2200,200,0.0,2200));
		h_residues_pos_fit.push_back(new TH1F(("h_residues_pos_hist"+ to_string(j+1)).c_str(),("Residues of extrapolate cluster position vs real position by fit"+to_string(j+1)+";Residues[mm];Entries").c_str(),200,-100,100));
		h_residues_pos.push_back(new TH1F(("h_residues_pos"+ to_string(j+1)).c_str(),("Residues of extrapolate cluster position vs real position"+to_string(j+1)+";Residues[mm];Entries").c_str(),200,-100,100));
	}
	gROOT->SetStyle("Plain");
	double percentual = 0;
	int just_one = 0;
	for (Long64_t jentry=0; jentry<nentries;jentry++) {
		percentual = (double)jentry/((double)nentries);
		if((fmod(percentual*100,5) < 0.9) && (just_one == 0)){ 
			cout<<"["<<(int)(percentual*100)<<"%]" <<endl;
			just_one ++;
		}else if(fmod(percentual*100,5) >= 0.9) just_one = 0;
    	Long64_t ientry = LoadTree(jentry);
    	if (ientry < 0) break;
    	nb = fChain->GetEntry(jentry);   nbytes += nb;
		n_event++;
		Inizializ();
		Int_t laytot=0;
//******MAPPE
		Mapping(ch1, _ch_p1);
		Mapping(ch2, _ch_p2);
		mapINFNcards();
		Mapping(ch3, _ch_p3);
		Mapping(ch4, _ch_p4);
		//HISTO DI TUTTA LA CAMERA
		Histo_Layer(h_strip_chamb,h_max_q_chamb,profile_strip_max_q,h2_strip_max_q_chamb,h_number_strip_chamb,ch1,0);
		Histo_Layer(h_strip_chamb,h_max_q_chamb,profile_strip_max_q,h2_strip_max_q_chamb,h_number_strip_chamb,ch2,1);
		Histo_Layer(h_strip_chamb,h_max_q_chamb,profile_strip_max_q,h2_strip_max_q_chamb,h_number_strip_chamb,ch3,2);
		Histo_Layer(h_strip_chamb,h_max_q_chamb,profile_strip_max_q,h2_strip_max_q_chamb,h_number_strip_chamb,ch4,3);
//******CLUSTER
		Cluster t1(ch1, _ch_p1);
		Cluster t2(ch2, _ch_p2);
		Cluster t3(ch3, _ch_p3);
		Cluster t4(ch4, _ch_p4);
//******EVENT DISPLAY
		gStyle->SetPalette(1);	

		evt_vs_layer->Fill(laytot);
		h_number_cluster_chamb[0]->Fill(t1.GetN_Cluster());
		h_number_cluster_chamb[1]->Fill(t2.GetN_Cluster());
		h_number_cluster_chamb[2]->Fill(t3.GetN_Cluster());
		h_number_cluster_chamb[3]->Fill(t4.GetN_Cluster());

		if(jentry < 100){
			cout<<"isGoodCluster dice che il cluster è ";
			if(t1.isGoodCluster(100,_ch_p1))
				cout<<"Buono"<<endl;
			else
				cout<<"Cattivo"<<endl;
		}

		vector<double> centroid_1 = t1.GetCentroid();
		vector<double> centroid_2 = t2.GetCentroid();
		vector<double> centroid_3 = t3.GetCentroid();
		vector<double> centroid_4 = t4.GetCentroid();
		vector<string> chamb_1 = t1.GetChamb();
		vector<string> chamb_2 = t2.GetChamb();
		vector<string> chamb_3 = t3.GetChamb();
		vector<string> chamb_4 = t4.GetChamb();
		vector<int>	q_sum_1 = t1.GetSum_q();
		vector<int>	q_sum_2 = t2.GetSum_q();
		vector<int>	q_sum_3 = t3.GetSum_q();
		vector<int>	q_sum_4 = t4.GetSum_q();

		for(unsigned int k = 0; k<chamb_1.size(); k++){
			if(centroid_1.at(k)!=0){
				h_centroid_chamb[0]->Fill(centroid_1.at(k));
				h_sum_q_cluster_chamb[0]->Fill(q_sum_1.at(k));
				h2_centroid_sum_q[0]->Fill(centroid_1.at(k),q_sum_1.at(k));
			}
		}
		for(unsigned int k = 0; k<chamb_2.size(); k++){
			if(centroid_2.at(k)!=0){
				h_centroid_chamb[1]->Fill(centroid_2.at(k));
				h_sum_q_cluster_chamb[1]->Fill(q_sum_2.at(k));
				h2_centroid_sum_q[1]->Fill(centroid_2.at(k),q_sum_2.at(k));
			}
		}
		for(unsigned int k = 0; k<chamb_3.size(); k++){
			if(centroid_3.at(k)!=0){
				h_centroid_chamb[2]->Fill(centroid_3.at(k));
				h_sum_q_cluster_chamb[2]->Fill(q_sum_3.at(k));
				h2_centroid_sum_q[2]->Fill(centroid_3.at(k),q_sum_3.at(k));
			}
		}
		for(unsigned int k = 0; k<chamb_4.size(); k++){
			if(centroid_4.at(k)!=0){
				h_centroid_chamb[3]->Fill(centroid_4.at(k));
				h_sum_q_cluster_chamb[3]->Fill(q_sum_4.at(k));
				h2_centroid_sum_q[3]->Fill(centroid_4.at(k),q_sum_4.at(k));
			}
		}
	}	
	for(UInt_t i = 0; i<h_strip_chamb.size(); i++){
		f->GetDirectory(_outdirname_lay)->WriteTObject(h_strip_chamb.at(i));
    	f->GetDirectory(_outdirname_lay)->WriteTObject(h_max_q_chamb.at(i));
    	f->GetDirectory(_outdirname_lay)->WriteTObject(h2_strip_max_q_chamb.at(i));
		f->GetDirectory(_outdirname_lay)->WriteTObject(profile_strip_max_q.at(i));
    	f->GetDirectory(_outdirname_lay)->WriteTObject(h_number_strip_chamb.at(i));
    	f->GetDirectory(_outdirname_lay)->WriteTObject(h_number_cluster_chamb.at(i));
    	f->GetDirectory(_outdirname_lay)->WriteTObject(h_centroid_chamb.at(i));
   	 	f->GetDirectory(_outdirname_lay)->WriteTObject(h_sum_q_cluster_chamb.at(i));
   	 	f->GetDirectory(_outdirname_lay)->WriteTObject(h2_centroid_sum_q.at(i));
	}
	cout<<"HISTO SALVATI IN "<<"/home/leonardo/Scrivania/Roba/TBReco/root_output/class_test_" + namef + ".root"<<endl;

	h_strip_chamb.clear();
    h_max_q_chamb.clear();
    h2_strip_max_q_chamb.clear();
    h_number_strip_chamb.clear();
    h_number_cluster_chamb.clear();
    h_centroid_chamb.clear();
    h_sum_q_cluster_chamb.clear();
    h2_centroid_sum_q.clear();
}
void prova::Inizializ(){

	n_clu_1 = 0;
	n_clu_2 = 0;
	n_clu_3 = 0;
	n_clu_4 = 0;
	for(int i = 0; i<20; i++)
		pcb_n_cluster[i] = 0;
	strip.clear();
	cluster_max_q.clear();
	chamb.clear();
	centroid.clear();
	q_sum.clear();
	n_cluster.clear();
	ch1.clear();
	ch2.clear();
	ch3.clear();
	ch4.clear();
}

void prova::Output_strip(ofstream &myfile)
{
	myfile.width(12);
	myfile<<"CHAMBER|";
	myfile.width(12);
	myfile<<"CLUSTER STRIP|";
	myfile.width(11);
	myfile<<"MAX_Q|";
	myfile.width(12);
	myfile<<"CENTROID|";
	myfile.width(12);
	myfile<<"SUM_Q|";
	myfile.width(13);
	myfile<<"N_CLUSTER|\n";
	for(UInt_t i = 0; i<chamb.size(); i++){
		myfile.width(11);
		myfile<<chamb.at(i)<<"|";
		myfile.width(13);
		myfile<<strip.at(i)<<"|";
		myfile.width(10);
		myfile<<cluster_max_q.at(i)<<"|";
		myfile.width(11);
		myfile<<centroid.at(i)<<"|";
		myfile.width(11);
		myfile<<q_sum.at(i)<<"|";
		myfile.width(11);
		myfile<<n_cluster.at(i)<<"|\n";
	}
}

void prova::Output_ped(ofstream &myfile)
{
	myfile.width(12);
	myfile<<"mmChamber|";
	myfile.width(12);
	myfile<<"mmLayer|";
	myfile.width(11);
	myfile<<"mmReadout|";
	myfile.width(12);
	myfile<<"mmStrip|";
	myfile.width(12);
	myfile<<"ped_mean|";
	myfile.width(13);
	myfile<<"ped_stdev|\n";
	for(UInt_t i = 0; i<ped_chamb->size(); i++){
		myfile.width(11);
		myfile<<ped_chamb->at(i)<<"|";
		myfile.width(11);
		myfile<<ped_layer->at(i)<<"|";
		myfile.width(10);
		myfile<<ped_readout->at(i)<<"|";
		myfile.width(11);
		myfile<<ped_Strip->at(i)<<"|";
		myfile.width(11);
		myfile<<ped_mean->at(i)<<"|";
		myfile.width(12);
		myfile<<ped_stdev->at(i)<<"|\n";
	}
}

void prova::Mapping(map<int,int> &map, string &name)
{
	for(UInt_t i = 0; i<mmChamber->size(); i++){
		if(mmChamber->at(i) == name){ 	
			/*for(UInt_t j = 0; j<ped_chamb->size(); j++){
				if((ped_chamb->at(j) == name) && (mmStrip->at(i) == ped_Strip->at(j)) && (max_q->at(i)/ped_stdev->at(j)>5)){*/
					map.insert(pair<int,int>(mmStrip->at(i),max_q->at(i)));
				//}
			//}
		}
	}
}
void prova::mapINFNcards()
{
	vector<int> prima, seconda;
	ifstream file;
	file.open ("/home/leonardo/Scrivania/Roba/TBReco/input_file/accoppiamento_strip.txt");
	if (file.is_open()){
	}else
		cout<<"ERROR OPENING FILE"<<endl;
	int x,y,z;
	string a,b,c;
	while(file>> a >> x >> b >> y >> c >> z){
		prima.push_back(x+512);
		seconda.push_back(y+512);
	}
//	for(UInt_t i = 0; i<prima.size(); i++){
//		cout<<"prima "<<prima.at(i)<<"   seconda "<<seconda.at(i)<<endl;
	//}
	for(UInt_t i = 0; i<prima.size(); i++){
		for(const auto& it: ch2){
			if(seconda.at(i) == it.first){
				ch2.insert(pair<int,int>(prima.at(i), it.second));
			}
		}
	}
}
void prova::Histo_Layer(vector<TH1F*>& h_strip, vector<TH1F*>& h_max_q, vector<TProfile*>& p_strip_q, vector<TH2F*>& h2_strip_q, vector<TH1F*>& h_molt,  map<int,int>& map, int i)
{
	
	for(const auto& it: map){
       	h_strip[i]->Fill(it.first);
   		h_max_q[i]->Fill(it.second);
		p_strip_q[i]->Fill(it.first,it.second);
        h2_strip_q[i]->Fill(it.first,it.second);
    }
	h_molt[i]->Fill(map.size());
}

void prova::Efficiency_1()
{
	double par[2];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2, super_eta = 0;
	if(n_clu_2 == 1 && n_clu_3 == 1 && n_clu_4 == 1 && (DAQCount(_ch_p2)==true) && (DAQCount(_ch_p3)==true) && (DAQCount(_ch_p4)==true)){ 
		eff_evt++;
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 2) && (centroid.at(k)!=0))
				temp_centroid_2 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 3) && (centroid.at(k)!=0))
				super_eta += centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 4) && (centroid.at(k)!=0))
				super_eta += centroid.at(k);
		}
		super_eta /= (2*cos(angle));
		parameters(temp_centroid_2, super_eta, x_axis[1], x_axis[3], par);
		if(par[1]<=0.404 && par[1]>= -0.404){
			den_eff[0] = den_eff[0] + 1;
			for(int i = 0; i<5; i++){
				max_road[i] = par[0]+5+par[1]*(x_axis[i]);
				min_road[i] = par[0]-5+par[1]*(x_axis[i]);
			}
			for(UInt_t i = 0; i<centroid.size(); i++){
				if((chamb.at(i) == "P1_M01") && (centroid.at(i) != 0))
					h2_extrapolate_pos[0]->Fill(par[0]+par[1],centroid.at(i));
				if((chamb.at(i) == "P1_M01") && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[0] && centroid.at(i)>=min_road[0])){
					num_eff[0] = num_eff[0] + 1;
					h_residues_pos[0]->Fill(centroid.at(i)-(par[0]+par[1]*x_axis[0]));
					break;
				}
			}
		}else{
			return;
		}
	}else{
		return;
	}
}
void prova::Efficiency_2()
{
	double par[2];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2, super_eta = 0;
	if(n_clu_1 == 1 && n_clu_3 == 1 && n_clu_4 == 1 && (DAQCount(_ch_p1)==true) && (DAQCount(_ch_p3)==true) && (DAQCount(_ch_p4)==true)){ 
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 1) && (centroid.at(k)!=0))
				temp_centroid_1 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 3) && (centroid.at(k)!=0))
				super_eta += centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 4) && (centroid.at(k)!=0))
				super_eta += centroid.at(k);
		}
		super_eta /= (2*cos(angle));
		parameters(temp_centroid_1, super_eta, x_axis[0], x_axis[3], par);
		if(par[1]<=0.404 && par[1] >= -0.404){
			den_eff[1] = den_eff[1] + 1;
			for(int i = 0; i<5; i++){
				max_road[i] = par[0]+5+par[1]*(x_axis[i]);
				min_road[i] = par[0]-5+par[1]*(x_axis[i]);
			}
			for(UInt_t i = 0; i<centroid.size(); i++){
				if((chamb.at(i) == "P2_M01") && (centroid.at(i) != 0))
					h2_extrapolate_pos[1]->Fill(par[0]+par[1]*x_axis[1],centroid.at(i));
				if((chamb.at(i) == "P2_M01") && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[1] && centroid.at(i)>=min_road[1])){
					num_eff[1] = num_eff[1] + 1;
					h_residues_pos[1]->Fill(centroid.at(i)-(par[0]+par[1]*x_axis[1]));
					break;
				}
			}
		}else{
			return;
		}
	}else
		return;
}
void prova::Efficiency_stereo()
{
	double par[2];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2;
	if(n_clu_1 == 1 && n_clu_2  == 1 && (DAQCount(_ch_p1)==true) && (DAQCount(_ch_p2)==true)){ 
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 1) && (centroid.at(k)!=0)){
				temp_centroid_1 = centroid.at(k);
			}
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 2) && (centroid.at(k)!=0)){
				temp_centroid_2 = centroid.at(k);
			}
		}
		//double start_point = (temp_centroid_1+temp_centroid_2)/2;
		parameters(temp_centroid_1, temp_centroid_2, x_axis[0], x_axis[1], par);
		if(par[1]<=0.404 && par[1] >= -0.404){
			den_eff[2] = den_eff[2] + 1;
			den_eff[3] = den_eff[3] + 1;
			for(int i = 0; i<5; i++){
				//max_road[i] = par[0]+Stereo_Road(start_point)+par[1]*(x_axis[i]);
				//min_road[i] = par[0]-Stereo_Road(start_point)+par[1]*(x_axis[i]);
				max_road[i] = par[0]+5+par[1]*(x_axis[i]);
				min_road[i] = par[0]-5+par[1]*(x_axis[i]);
			}
			//cout<<(temp_centroid_1+temp_centroid_2)/2<<endl;
			//cout<<Stereo_Road(start_point)<<endl;
			for(UInt_t i = 0; i<centroid.size(); i++){
				if((chamb.at(i) == "P3_M01") && (centroid.at(i) != 0))
					h2_extrapolate_pos[2]->Fill(par[0]+par[1]*x_axis[2],centroid.at(i));
				if((chamb.at(i) == "P3_M01") && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[2] && centroid.at(i)>=min_road[2])){
					num_eff[2] = num_eff[2] + 1;
					h_residues_pos[2]->Fill(centroid.at(i)-(par[0]+par[1]*x_axis[2]));
					break;
				}
			}
			for(UInt_t i = 0; i<centroid.size(); i++){
				if((chamb.at(i) == "P4_M01") && (centroid.at(i) != 0))
					h2_extrapolate_pos[3]->Fill(par[0]+par[1]*x_axis[4],centroid.at(i));
				if((chamb.at(i) == "P4_M01") && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[4] && centroid.at(i)>=min_road[4])){
					num_eff[3] = num_eff[3] + 1.;
					h_residues_pos[3]->Fill(centroid.at(i)-(par[0]+par[1]*x_axis[4]));
					break;
				}
			}
		}else{
			return;
		}
	}else
		return;
}
void prova::parameters(double &y1, double &y2, double &x1, double &x2, double par[2])
{
	par[0] = (x2*y1-x1*y2)/(x2-x1);
	par[1] = (y2-y1)/(x2-x1);
}

void prova::Efficiency_Fit_1()
{
	double par[3];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2, temp_centroid_3, temp_centroid_4;
	if(n_clu_2 == 1 && n_clu_3 == 1 && n_clu_4 == 1 && DAQCount(_ch_p2) && DAQCount(_ch_p3) && DAQCount(_ch_p4)){ 
		eff_evt++;
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 2) && (centroid.at(k)!=0))
				temp_centroid_2 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 3) && (centroid.at(k)!=0))
				temp_centroid_3 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 4) && (centroid.at(k)!=0))
				temp_centroid_4 = centroid.at(k);
		}
	}else
		return;
	FitParameters(temp_centroid_2, temp_centroid_3, temp_centroid_4, x_axis[1], x_axis[2], x_axis[4], par);
	/*if(n_event <= 100000){
		TCanvas *c = new TCanvas("c",("event_display " + to_string(par[2])).c_str());
		//cout<<"CHI QUADRO = "<<par[2]<<endl;
		TGraph *g = new TGraph();
		int k = 0;
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p1) && (centroid.at(i) != 0)){
				//cout<<centroid.at(i)<<endl;
				g->SetPoint(k,x_axis[0],centroid.at(i));
				k++;
			}
		}
		if(k == 0) g->RemovePoint(0);
		g->SetPoint(k+1,x_axis[1],temp_centroid_2);
		g->SetPoint(k+2,x_axis[2],temp_centroid_3);
		g->SetPoint(k+3,x_axis[4],temp_centroid_4);
		TF1 *f = new TF1("f", "[1]*x + [0]", x_axis[0], x_axis[4]);
		f->SetParameter(0, par[0]);
		f->SetParameter(1, par[1]);
		g->SetMarkerStyle(20);
		g->SetMarkerColor(kRed);
		g->SetTitle(("chi quadro = "+to_string(par[2])).c_str());
		g->Draw("AP");
		f->Draw("same");
		c->SaveAs(("/home/leonardo/Scrivania/Roba/TBReco/Event_display/event_display_" + to_string(par[2]) + ".pdf").c_str());
		//c->Print(("event_display_" + to_string(par[2]) + ".pdf").c_str(),"pdf");
	}*/
	if((par[1]<=0.404 && par[1] >= -0.404)){
		den_fit_eff[0] = den_fit_eff[0] + 1;
		for(int i = 0; i<5; i++){
			max_road[i] = par[0]+13+par[1]*(x_axis[i]);
			min_road[i] = par[0]-13+par[1]*(x_axis[i]);
		}
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p1) && (centroid.at(i) != 0))
				h2_extrapolate_pos_fit[0]->Fill(par[0]+par[1]*x_axis[0],centroid.at(i));
			if((chamb.at(i) == _ch_p1) && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[0] && centroid.at(i)>=min_road[0])){
				num_fit_eff[0] = num_fit_eff[0] + 1;
				h_residues_pos_fit[0]->Fill(centroid.at(i)-(par[0]+par[1]*x_axis[0]));
				break;
			}
		}	
	}else
		return;
}
void prova::Efficiency_Fit_2()
{
	double par[3];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2, temp_centroid_3, temp_centroid_4;
	if(n_clu_1 == 1 && n_clu_3 == 1 && n_clu_4 == 1 && DAQCount(_ch_p1) && DAQCount(_ch_p3) && DAQCount(_ch_p4)){ 
		eff_evt++;
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 1) && (centroid.at(k)!=0))
				temp_centroid_1 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 3) && (centroid.at(k)!=0))
				temp_centroid_3 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 4) && (centroid.at(k)!=0))
				temp_centroid_4 = centroid.at(k);
		}
	}else
		return;
	FitParameters(temp_centroid_1, temp_centroid_3, temp_centroid_4, x_axis[0], x_axis[2], x_axis[4], par);
	if((par[1]<=0.404 && par[1] >= -0.404)){
		den_fit_eff[1] = den_fit_eff[1] + 1;
		for(int i = 0; i<5; i++){
			max_road[i] = par[0]+13+par[1]*(x_axis[i]);
			min_road[i] = par[0]-13+par[1]*(x_axis[i]);
		}
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p2) && (centroid.at(i) != 0))
				h2_extrapolate_pos_fit[1]->Fill(par[0]+par[1]*x_axis[1],centroid.at(i));
			if((chamb.at(i) == _ch_p2) && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[1] && centroid.at(i)>=min_road[1])){
				num_fit_eff[1] = num_fit_eff[1] + 1;
				h_residues_pos_fit[1]->Fill(centroid.at(i)-(par[0]+par[1]*x_axis[1]));
				break;
			}
		}	
	}else
		return;
}
void prova::Efficiency_Fit_3()
{
	double par[3];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2, temp_centroid_3, temp_centroid_4;
	if(n_clu_1 == 1 && n_clu_2 == 1 && n_clu_4 == 1 && DAQCount(_ch_p1) && DAQCount(_ch_p2) && DAQCount(_ch_p4)){ 
		eff_evt++;
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 1) && (centroid.at(k)!=0))
				temp_centroid_1 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 2) && (centroid.at(k)!=0))
				temp_centroid_2 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 4) && (centroid.at(k)!=0))
				temp_centroid_4 = centroid.at(k);
		}
	}else
		return;
	FitParameters(temp_centroid_1, temp_centroid_2, temp_centroid_4, x_axis[0], x_axis[1], x_axis[4], par);
	if((par[1]<=0.404 && par[1] >= -0.404)){
		den_fit_eff[2] = den_fit_eff[2] + 1;
		for(int i = 0; i<5; i++){
			max_road[i] = par[0]+13+par[1]*(x_axis[i]);
			min_road[i] = par[0]-13+par[1]*(x_axis[i]);
		}
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p3) && (centroid.at(i) != 0))
				h2_extrapolate_pos_fit[2]->Fill(par[0]+par[1]*x_axis[2],centroid.at(i));
			if((chamb.at(i) == _ch_p3) && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[2] && centroid.at(i)>=min_road[2])){
				num_fit_eff[2] = num_fit_eff[2] + 1;
				h_residues_pos_fit[2]->Fill(centroid.at(i)-(par[0]+par[1]*x_axis[2]));
				break;
			}
		}	
	}else
		return;
}
void prova::Efficiency_Fit_4()
{
	double par[3];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2, temp_centroid_3, temp_centroid_4;
	if(n_clu_1 == 1 && n_clu_2 == 1 &&  n_clu_3 == 1 && DAQCount(_ch_p1) && DAQCount(_ch_p2) && DAQCount(_ch_p3)){ 
		eff_evt++;
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 1) && (centroid.at(k)!=0))
				temp_centroid_1 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 2) && (centroid.at(k)!=0))
				temp_centroid_2 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 3) && (centroid.at(k)!=0))
				temp_centroid_3 = centroid.at(k);
		}
	}else
		return;
	FitParameters(temp_centroid_1, temp_centroid_2, temp_centroid_3, x_axis[0], x_axis[1], x_axis[2], par);
	if((par[1]<=0.404 && par[1] >= -0.404)){
		den_fit_eff[3] = den_fit_eff[3] + 1;
		for(int i = 0; i<5; i++){
			max_road[i] = par[0]+13+par[1]*(x_axis[i]);
			min_road[i] = par[0]-13+par[1]*(x_axis[i]);
		}
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p4) && (centroid.at(i) != 0))
				h2_extrapolate_pos_fit[3]->Fill(par[0]+par[1]*x_axis[4],centroid.at(i));
			if((chamb.at(i) == _ch_p4) && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[4] && centroid.at(i)>=min_road[4])){
				num_fit_eff[3] = num_fit_eff[3] + 1;
				h_residues_pos_fit[3]->Fill(centroid.at(i)-(par[0]+par[1]*x_axis[4]));
				break;
			}
		}	
	}else
		return;
}
void prova::FitParameters(double &y1, double &y2, double &y3, double &x1, double &x2, double &x3, double par[3])
{
	TGraph *g = new TGraph();
	g->SetPoint(0,x1, y1);
	g->SetPoint(1,x2, y2);
	g->SetPoint(2,x3, y3);
	TF1 *f = new TF1("f", "[1]*x+[0]", x1, x3);
	g->Fit(f, "QR");
	par[0] = f->GetParameter(0);
	par[1] = f->GetParameter(1);
	par[2] = f->GetChisquare();
}
void prova::Efficiency_Position_1()
{
	double par[2];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2, super_eta = 0;
	if(n_clu_2 == 1 && n_clu_3 == 1 && n_clu_4 == 1 && DAQCount(_ch_p2) && DAQCount(_ch_p3) && DAQCount(_ch_p4)){ 
		eff_evt++;
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 2) && (centroid.at(k)!=0))
				temp_centroid_2 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 3) && (centroid.at(k)!=0))
				super_eta += centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 4) && (centroid.at(k)!=0))
				super_eta += centroid.at(k);
		}
		super_eta /= (2*cos(angle));
	}else
		return;
	parameters(temp_centroid_2, super_eta, x_axis[1], x_axis[3], par);
	if(par[1]<=0.404 && par[1]>= -0.404){
		den_eff_pos[0]->Fill(par[0]+par[1]*x_axis[0]);
		max_road[0] = par[0]+5+par[1]*x_axis[0];
		min_road[0] = par[0]-5+par[1]*x_axis[0];
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p1) && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[0] && centroid.at(i)>=min_road[0])){
				num_eff_pos[0]->Fill(par[0]+par[1]*x_axis[0]);
				break;
			}
		}
	}else
		return;
}
void prova::Efficiency_Position_2()
{
	double par[2];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[5], max_road[5];
	double temp_centroid_1, temp_centroid_2, super_eta = 0;
	if(n_clu_1 == 1 && n_clu_3 == 1 && n_clu_4 == 1 && DAQCount(_ch_p1) && DAQCount(_ch_p3) && DAQCount(_ch_p4)){ 
		eff_evt++;
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 1) && (centroid.at(k)!=0))
				temp_centroid_1 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 3) && (centroid.at(k)!=0))
				super_eta += centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 4) && (centroid.at(k)!=0))
				super_eta += centroid.at(k);
		}
		super_eta /= (2*cos(angle));
	}else
		return;
	parameters(temp_centroid_1, super_eta, x_axis[0], x_axis[3], par);
	if(par[1]<=0.404 && par[1]>= -0.404){
		den_eff_pos[1]->Fill(par[0]+par[1]*x_axis[1]);
		max_road[1] = par[0]+5+par[1]*x_axis[1];
		min_road[1] = par[0]-5+par[1]*x_axis[1];
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p2) && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[1] && centroid.at(i)>=min_road[1])){
				num_eff_pos[1]->Fill(par[0]+par[1]*x_axis[1]);
				break;
			}
		}
	}else
		return;
}
void prova::Efficiency_Position_Stereo()
{
	double par[2];
	double x_axis[5] = {1.,12.562,33.08,38.86,44.64};
	double min_road[4], max_road[4];
	double temp_centroid_1, temp_centroid_2;
	if(n_clu_1 == 1 && n_clu_2 == 1 && DAQCount(_ch_p1) && DAQCount(_ch_p2)){ 
		eff_evt++;
		for(UInt_t k =0; k<centroid.size(); k++){
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 1) && (centroid.at(k)!=0))
				temp_centroid_1 = centroid.at(k);
			if((((int)(atoi((chamb.at(k)).substr(1,1).c_str()))) == 2) && (centroid.at(k)!=0))
				temp_centroid_2 = centroid.at(k);
		}
	}else
		return;
	//double start_point = (temp_centroid_1+temp_centroid_2)/2;
	parameters(temp_centroid_1, temp_centroid_2, x_axis[0], x_axis[1], par);
	if(par[1]<=0.404 && par[1]>= -0.404){
		den_eff_pos[2]->Fill(par[0]+par[1]*x_axis[2]);
		den_eff_pos[3]->Fill(par[0]+par[1]*x_axis[4]);
	    //max_road[2] = par[0]+Stereo_Road(start_point)+par[1]*x_axis[2];
	    //min_road[2] = par[0]-Stereo_Road(start_point)+par[1]*x_axis[2];
	    //max_road[3] = par[0]+Stereo_Road(start_point)+par[1]*x_axis[4];
	    //min_road[3] = par[0]-Stereo_Road(start_point)+par[1]*x_axis[4];
		max_road[2] = par[0]+5+par[1]*x_axis[2];
		min_road[2] = par[0]-5+par[1]*x_axis[2];
		max_road[3] = par[0]+5+par[1]*x_axis[4];
		min_road[3] = par[0]-5+par[1]*x_axis[4];
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p3) && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[2] && centroid.at(i)>=min_road[2])){
				num_eff_pos[2]->Fill(par[0]+par[1]*x_axis[2]);
				break;
			}
		}
		for(UInt_t i = 0; i<centroid.size(); i++){
			if((chamb.at(i) == _ch_p4) && (centroid.at(i)!= 0) && (centroid.at(i)<=max_road[3] && centroid.at(i)>=min_road[3])){
				num_eff_pos[3]->Fill(par[0]+par[1]*x_axis[4]);
				break;
			}
		}
	}else
		return;
}
bool prova::DAQCount(string &name)
{
	for(UInt_t i = 0; i<chamb.size(); i++){
		if(chamb.at(i) == name && cluster_max_q.at(i)<100){
			n_volte++;
			return false;
		}
	}
	return true;
}

int prova::Stereo_Road(double &start_point)
{
	double base = (major_base/2)-start_point*tan(phi);
	return base*tan(angle)+sigma_road;
	//return 5;
}
	

In your “prova.cxx”, try to replace #include "header_files/cluster.h" with #include "header_files/cluster.cxx" (assuming that this “.cxx” file is also in “header_files”).

Or try:

root [0] .L cluster.cxx++
root [1] .L prova.cxx

The first substitution doesn’t work. In fact root doesn’t find the declaration of the function that I declared in cluster.h.
The compilation of cluster.cxx before prova.cxx give me some error because i use some variable defined in prova.h that he doesn’t find.
But if i try with:

root[0] .L prova.cxx++
root[1] prova t
root[2] t.Loop()

it returns:

Error in <TString::Replace>: first argument out of bounds: pos = -1, Length = 6
[0%]
/home/leonardo/Programs/rootbuild/bin/root.exe: symbol lookup error: /home/leonardo/Scrivania/Roba/TBReco/vediamosefunziona_cxx.so: undefined symbol: _ZN7ClusterC1ERSt3mapIiiSt4lessIiESaISt4pairIKiiEEERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

the [0%] is a part of my program that says me the percentage of data analized

If I simply copy-paste the code snippets as cluster.h and cluster.cxx and then try to compile the cluster.cxx in root I get

root [0] .L cluster.cxx++
Info in <TUnixSystem::ACLiC>: creating shared library /home/vladimir/tmp/root/./cluster_cxx.so
In file included from input_line_12:9:
././cluster.cxx:4:10: fatal error: 'header_files/cluster.h' file not found
#include "header_files/cluster.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~
Error in <ACLiC>: Dictionary generation failed!

This means that I cannot test that files and reproduce your problem. If you want to get help you should prepare MWE, i.e. minimal working example. As I shown your example is not MWE.

OK, I removed header_files and tried again:

root [0] .L cluster.cxx++
Info in <TUnixSystem::ACLiC>: creating shared library /home/vladimir/tmp/root/./cluster_cxx.so
In file included from input_line_12:9:
././cluster.cxx:5:10: fatal error: '../prova.h' file not found
#include "../prova.h"
         ^~~~~~~~~~~~
Error in <ACLiC>: Dictionary generation failed!

Again, I cannot reproduce your problem because you didn’t provide MWE.

Now let’s go on third round where I commented that header file:

root [0] .L cluster.cxx++
Info in <TUnixSystem::ACLiC>: creating shared library /home/vladimir/tmp/root/./cluster_cxx.so
In file included from input_line_12:9:
././cluster.cxx:35:41: error: use of undeclared identifier 'pitch'
                                        centroid_coord += (vec_strip.at(k)*pitch*vec_max_q.at(k));
                                                                           ^
././cluster.cxx:40:42: error: use of undeclared identifier 'pitch'
                                centroid_coord += (vec_strip.at(k+1)*pitch*vec_max_q.at(k+1));
                                                                     ^
././cluster.cxx:45:28: error: use of undeclared identifier 'n_holes_max'
                        if(j > 10 || _n_holes > n_holes_max){//controllo che il cluster non sia troppo grande
                                                ^
././cluster.cxx:60:58: error: use of undeclared identifier 'pitch'
                                                _pcb.push_back((int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+1); 
                                                                                                   ^
././cluster.cxx:61:7: error: use of undeclared identifier 'pcb_n_cluster'
                                                pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
                                                ^                                                                                                                                 
././cluster.cxx:61:57: error: use of undeclared identifier 'pitch'                                                                                                                
                                                pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
                                                                                                  ^
././cluster.cxx:61:79: error: no matching function for call to 'atoi'                                                                                                             
                                                pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;               
                                                                                                                        ^~~~
/usr/include/stdlib.h:104:12: note: candidate function not viable: no known conversion from 'std::__cxx11::string' (aka 'basic_string<char>') to 'const char *' for 1st argument  
extern int atoi (const char *__nptr)                                                                                                                                              
           ^
In file included from input_line_12:9:                                                                                                                                            
././cluster.cxx:86:2: error: use of undeclared identifier '_pcb_n_cluster'                                                                                                        
        _pcb_n_cluster.clear();                                                                                                                                                   
        ^
././cluster.cxx:117:10: error: C++ requires a type specifier for all declarations                                                                                                 
Cluster::isGoodCluster(int charge_min, string &name) const                                                                                                                        
         ^
././cluster.cxx:119:22: error: use of undeclared identifier 'chamb'                                                                                                               
        for(UInt_t i = 0; i<chamb.size(); i++){                                                                                                                                   
                            ^
././cluster.cxx:120:6: error: use of undeclared identifier 'chamb'                                                                                                                
                if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)                                                                                                         
                   ^                                                                                                                                                              
././cluster.cxx:120:29: error: use of undeclared identifier 'cluster_max_q'                                                                                                       
                if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)                                                                                                         
                                          ^
././cluster.cxx:1:2: error: unterminated conditional directive                                                                                                                    
#ifndef _CLUSTER_CXX_                                                                                                                                                             
 ^
Error in <ACLiC>: Dictionary generation failed!

Conclusion: the data that you provide to us not enough to reproduce your issue and to help you in any manner.

Before continue try the following: make a temporary directory, copy to there only necessary files (for example, copy just two, compile them, if there are errors about missing files just add that files, repeat). And after that if you see the same problem with compilation (I don’t understand do you mean compilation by a compiler like GCC or CLANG or ROOT/CLING compilation, please be more concrete) provides the MWE (files in the temporary directory) here so we could try on our side. Also give details how do you compile the file, what file and ROOT version, OS and compilers on your system.

IMHO, this is awful advise!

P.S. I didn’t thought that Ivannoli could mean compilation in ROOT/CLING.

Sorry man, this is the prova.h that i didn’t post before:

//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Fri Mar 30 12:27:06 2018 by ROOT version 6.12/06
// from TTree apv_raw/APVRawData
// found on file: ../TBReco/data/run177.root
//////////////////////////////////////////////////////////

#ifndef prova_h
#define prova_h

#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TH1F.h>
#include <TH2F.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <TCanvas.h>

// Header file for the classes stored in the TTree if any.
#include "vector"
#include "vector"
#include "vector"
#include "vector"
#include "vector"

using namespace std;

class prova {
public :
   TTree            *fChain;   //!pointer to the analyzed TTree or TChain
   Int_t            fCurrent; //!current Tree number in a TChain
// Fixed size dimensions of array or collections stored in the TTree if any.

   // Declaration of leaf types
   //IMPOSTO ANGOLO E LARGHEZZA IN STRIP DELLA ROAD
   //Double_t 	   cos(angle_2) = 0.982416299; 
   map<int,int>		infncard;
   string			_ch_p1 = "P1_M01", _ch_p2 = "P2_M01", _ch_p3 = "P3_M01", _ch_p4 = "P4_M01";
   Double_t 		_super_eta;
   Int_t 			_N_lay = 4;
   Int_t 			_N_pcb = 5;
   Int_t			eff_num = 0;
   Int_t			make_fit = 0;
   Double_t			pitch = 0.425; //mm
   //double			temp_centroid[4];
   int				n_volte = 0;
   int 				eff_evt = 0;
   int 				n_event = 0;	
   double			temp_centroid_pcb[20];
   int	        	n_clu_1, n_clu_2, n_clu_3, n_clu_4;
   int				pcb_n_cluster[20];
   double 			num_eff[4];
   double			den_eff[4];
   double			num_fit_eff[4];
   double			den_fit_eff[4];
   double			num_hist_eff[4];
   double			den_hist_eff[4];
   int 				n_holes_max = 2;
   Double_t			n_sigma = 4;
   Double_t		   	angle = 0.0261799, phi = 0.183;
   Double_t			major_base = 1319.2;
   Double_t			road_eta = 2;
   double			sigma_road = 1.;
   //Double_t		 	road_stereo = 2*(()*tan(angle) + sigma_road);
   map<int,int>		ch1, ch2, ch3, ch4;
   vector<double>	res_1, res_2, res_3, res_4;
   vector<TH1F*>	h_residues_pos;
   vector<TH1F*>	h_residues_pos_fit;
   vector<TH2F*>	h2_extrapolate_pos;
   vector<TH2F*>	h2_extrapolate_pos_fit;
   vector<TH1F*>	num_eff_pos; 
   vector<TH1F*>	den_eff_pos;
   vector<TH1F*>	eff_pos;
   ULong64_t    	evt;
   UInt_t      		error;
   Int_t          	daqTimeSec;
   Int_t           	daqTimeMicroSec;
   Int_t           	srsTimeStamp;
   UInt_t          	srsTrigger;
   vector<double>	*ped_stdev;
   vector<double>	*ped_mean;
   vector<char>		*ped_readout;
   vector<string>	*ped_chamb;
   vector<int>		*ped_Strip;
   vector<int>		*ped_layer;
   vector<unsigned int> *srsFec;
   vector<unsigned int> *srsChip;
   vector<unsigned int> *srsChan;
   vector<string>  	*mmChamber;
   vector<int>     	*mmLayer;
   vector<char>    	*mmReadout;
   vector<int>     	*mmStrip;
   vector<vector<short> > *raw_q;
   vector<short>   	*max_q;
   vector<int>     	*t_max_q;
   vector<int>		ped_strip_tmm;
   vector<string>	ped_chamb_tmm;
   vector<int>		strip;
   vector<int>		cluster_max_q;
   vector<string>	chamb;
   vector<int>		pcb;
   vector<double>	centroid;
   vector<int>		q_sum;
   vector<int>		n_cluster;

	
    // List of branches
    TBranch        *b_evt;   //!
    TBranch        *b_error;   //!
    TBranch        *b_daqTimeSec;   //!
    TBranch        *b_daqTimeMicroSec;   //!
    TBranch        *b_srsTimeStamp;   //!
    TBranch        *b_srsTrigger;   //!
    TBranch        *b_srsFec;   //!
    TBranch        *b_srsChip;   //!
    TBranch        *b_srsChan;   //!
    TBranch        *b_mmChamber;   //!
    TBranch        *b_mmLayer;   //!
   	TBranch        *b_mmReadout;   //!
   	TBranch        *b_mmStrip;   //!
   	TBranch        *b_raw_q;   //!
   	TBranch        *b_max_q;   //!
   	TBranch        *b_t_max_q;   //!

   prova(TTree *tree=0);
   virtual ~prova();
   virtual Int_t    Cut(Long64_t entry);
   virtual Int_t    GetEntry(Long64_t entry);
   virtual Long64_t LoadTree(Long64_t entry);
   virtual void     Init(TTree *tree);
   virtual void     Loop();
   virtual Bool_t   Notify();
   virtual void     Show(Long64_t entry = -1);
   //virtual void 	Cluster(map<int,int>&, string&, int&);
   virtual void		Mapping(map<int,int>&,string&);	
   virtual void		Output_ped(ofstream&);
   virtual void		Output_strip(ofstream&);
   //virtual void		Histo_PCB(vector<TH1F*>&, vector<TH1F*>&, vector<TH1F*>&, map<int,int>&, int strip_pcb[], int );
   virtual void		Inizializ();
   virtual bool		DAQCount(string&);
   virtual void 	Efficiency_Fit_1();
   virtual void 	Efficiency_Fit_2();
   virtual void 	Efficiency_Fit_3();
   virtual void 	Efficiency_Fit_4();
   virtual void		FitParameters(double&, double&, double&, double&, double&, double&, double par[]);
   virtual void 	Efficiency_1();
   virtual void 	Efficiency_2();
   virtual void 	Efficiency_stereo();
   virtual void 	parameters(double&, double&, double&, double&, double par[]);
   virtual void 	Efficiency_Position_1();
   virtual void 	Efficiency_Position_2();
   virtual void 	Efficiency_Position_Stereo();
   virtual int		Stereo_Road(double&);
   virtual void 	Histo_Layer(vector<TH1F*>&, vector<TH1F*>&, vector<TProfile*>&, vector<TH2F*>&, vector<TH1F*>&,  map<int,int>&, int );
   virtual void		mapINFNcards();
   //virtual void 	Histo_ped(map<int,int>&,vector<TH1F*>&, string&);
	private:
	 TString		_outdirname;
	 TString		_outdirname_pcb;
	 TString 		_outdirname_ped, _outdirname_lay;

};

#endif

#ifdef prova_cxx
prova::prova(TTree *tree) : fChain(0) 
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
   if (tree == 0) {
      TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("data/run177.root");
      if (!f || !f->IsOpen()) {
         f = new TFile("data/run177.root");
      }
      f->GetObject("apv_raw",tree);
   }
   Init(tree);
}

prova::~prova()
{
   if (!fChain) return;
   delete fChain->GetCurrentFile();
}

Int_t prova::GetEntry(Long64_t entry)
{
// Read contents of entry.
   if (!fChain) return 0;
   return fChain->GetEntry(entry);
}
Long64_t prova::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
   if (!fChain) return -5;
   Long64_t centry = fChain->LoadTree(entry);
   if (centry < 0) return centry;
   if (fChain->GetTreeNumber() != fCurrent) {
      fCurrent = fChain->GetTreeNumber();
      Notify();
   }
   return centry;
}

void prova::Init(TTree *tree)
{
   // The Init() function is called when the selector needs to initialize
   // a new tree or chain. Typically here the branch addresses and branch
   // pointers of the tree will be set.
   // It is normally not necessary to make changes to the generated
   // code, but the routine can be extended by the user if needed.
   // Init() will be called many times when running on PROOF
   // (once per file to be processed).

   // Set object pointer
   srsFec = 0;
   srsChip = 0;
   srsChan = 0;
   mmChamber = 0;
   mmLayer = 0;
   mmReadout = 0;
   mmStrip = 0;
   raw_q = 0;
   max_q = 0;
   t_max_q = 0;
   
// Set branch addresses and branch pointers
   if (!tree) return;
   fChain = tree;
   fCurrent = -1;
   fChain->SetMakeClass(1);

   fChain->SetBranchAddress("evt", &evt, &b_evt);
   fChain->SetBranchAddress("error", &error, &b_error);
   fChain->SetBranchAddress("daqTimeSec", &daqTimeSec, &b_daqTimeSec);
   fChain->SetBranchAddress("daqTimeMicroSec", &daqTimeMicroSec, &b_daqTimeMicroSec);
   fChain->SetBranchAddress("srsTimeStamp", &srsTimeStamp, &b_srsTimeStamp);
   fChain->SetBranchAddress("srsTrigger", &srsTrigger, &b_srsTrigger);
   fChain->SetBranchAddress("srsFec", &srsFec, &b_srsFec);
   fChain->SetBranchAddress("srsChip", &srsChip, &b_srsChip);
   fChain->SetBranchAddress("srsChan", &srsChan, &b_srsChan);
   fChain->SetBranchAddress("mmChamber", &mmChamber, &b_mmChamber);
   fChain->SetBranchAddress("mmLayer", &mmLayer, &b_mmLayer);
   fChain->SetBranchAddress("mmReadout", &mmReadout, &b_mmReadout);
   fChain->SetBranchAddress("mmStrip", &mmStrip, &b_mmStrip);
   fChain->SetBranchAddress("raw_q", &raw_q, &b_raw_q);
   fChain->SetBranchAddress("max_q", &max_q, &b_max_q);
   fChain->SetBranchAddress("t_max_q", &t_max_q, &b_t_max_q);
/*
   h_sum_q_cluster_ch1 = new TH1F("h_sum_q_cluster_ch1","Distribution sum of charge in cluster P1_M01;sum_q_P1_M01;Entry",150,0.0,5000.);	
   h_sum_q_cluster_ch2 = new TH1F("h_sum_q_cluster_ch2","Distribution sum of charge in cluster P2_M01;sum_q_P2_M01;Entry",150,0.0,5000.);	
   h_sum_q_cluster_ch3 = new TH1F("h_sum_q_cluster_ch3","Distribution sum of charge in cluster P3_M01;sum_q_P3_M01;Entry",150,0.0,5000.);	
   h_sum_q_cluster_ch4 = new TH1F("h_sum_q_cluster_ch4","Distribution sum of charge in cluster P4_M01;sum_q_P4_M01;Entry",150,0.0,5000.);	
   h_sum_q_centroid_ch1 = new TH2F("h_sum_q_centroid_ch1","Histo sum of charge vs centroid P1_M01;sum_q;Centroid",150,0.0,5000.,512,500.,1124.);	
   h_sum_q_centroid_ch2 = new TH2F("h_sum_q_centroid_ch2","Histo sum of charge vs centroid P2_M01;sum_q;Centroid",150,0.0,5000.,512,500.,1124.);	
   h_sum_q_centroid_ch3 = new TH2F("h_sum_q_centroid_ch3","Histo sum of charge vs centroid P3_M01;sum_q;Centroid",150,0.0,5000.,512,500.,1124.);	
   h_sum_q_centroid_ch4 = new TH2F("h_sum_q_centroid_ch4","Histo sum of charge vs centroid P4_M01;sum_q;Centroid",150,0.0,5000.,512,500.,1124.);	
  */
   Notify();
}

Bool_t prova::Notify()
{
   // The Notify() function is called when a new file is opened. This
   // can be either for a new TTree in a TChain or when when a new TTree
   // is started when using PROOF. It is normally not necessary to make changes
   // to the generated code, but the routine can be extended by the
   // user if needed. The return value is currently not used.

   return kTRUE;
}

void prova::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
   if (!fChain) return;
   fChain->Show(entry);
}
Int_t prova::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns  1 if entry is accepted.
// returns -1 otherwise.
   return 1;
}

#endif // #ifdef prova_cxx

so now you have:
prova.h
prova.cxx
cluster.h
cluster.cxx

this is the entire code of my program

I did as you said, I put all the files in one directory and i run prova.cxx in this way:

root[0] .L prova.cxx
root[1] prova t
root[2] t.Loop()

now the problem is

 *** Break *** segmentation violation

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum.
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6  0x00007f1c1ea52e17 in prova::Loop() () from /home/leonardo/Scrivania/Roba/TBReco/vediamosefunziona_cxx.so
#7  0x00007f1c1bf3a070 in ?? ()
#8  0x0000000101a14c08 in ?? ()
#9  0x000000000196b5d0 in ?? ()
#10 0x00007f1c272f3870 in ?? () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#11 0x00007fffbd2c3740 in ?? ()
#12 0x00007fffbd2c3380 in ?? ()
#13 0x00007f1c27284386 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) [clone .part.290] [clone .constprop.443] () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#14 0x00007f1c27288b1d in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#15 0x00007f1c27288d25 in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#16 0x00007f1c27317ed7 in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/leonardo/Programs/rootbuild/lib/libCling.so
#17 0x00007f1c2721052a in HandleInterpreterException (metaProcessor=0x1b02e70, input_line=0x61809c0 "#line 1 "ROOT_prompt_2"nt.Loop()", compRes=
0x7fffbd2c372c: cling::Interpreter::kSuccess, result=result
entry=0x7fffbd2c3740) at /home/leonardo/Programs/root-6.12.06/core/metacling/src/TCling.cxx:2071
===========================================================

Hello,

I saved code snippets from your first message as cluster.h and cluster.cxx (that file missed #endif). The code that you post for prova.h and prova.cxx is a bit contradicted. I saved them as prova.h and prova.cxx (please check if these are OK, because I had to merge two snippets and reformat all files to one style).

Now I get

root[0] .L prova.cxx
root[1] prova t;
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster13isGoodClusterEiRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::isGoodCluster(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster8GetChambB5cxx11Ev' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::GetChamb[abi:cxx11]()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7ClusterC1ERSt3mapIiiSt4lessIiESaISt4pairIKiiEEERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::Cluster(std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int> > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster11GetCentroidEv' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::GetCentroid()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster8GetSum_qEv' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::GetSum_q()
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7Cluster12GetN_ClusterEv' unresolved while linking function '_GLOBAL__sub_I_cling_module_28'!
You are probably missing the definition of Cluster::GetN_Cluster()
Maybe you need to load the corresponding shared library?

AFAIU, this means that cluster.cxx file is not processed. AFAIU, I have to load cluster class first but this raises another issue:

root[0] .L cluster.cxx
In file included from input_line_10:1:
/home/vladimir/tmp/root/cluster.cxx:40:46: error: use of undeclared identifier 'pitch'
          centroid_coord += (vec_strip.at(k)*pitch*vec_max_q.at(k));
                                             ^
/home/vladimir/tmp/root/cluster.cxx:45:46: error: use of undeclared identifier 'pitch'
        centroid_coord += (vec_strip.at(k+1)*pitch*vec_max_q.at(k+1));
                                             ^
/home/vladimir/tmp/root/cluster.cxx:50:31: error: use of undeclared identifier 'n_holes_max'
      if(j > 10 || _n_holes > n_holes_max)
                              ^
/home/vladimir/tmp/root/cluster.cxx:71:59: error: use of undeclared identifier 'pitch'
              _pcb.push_back((int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+1); 
                                                                 ^
/home/vladimir/tmp/root/cluster.cxx:72:8: error: use of undeclared identifier 'pcb_n_cluster'
              pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
              ^
/home/vladimir/tmp/root/cluster.cxx:72:58: error: use of undeclared identifier 'pitch'
              pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
                                                                ^
/home/vladimir/tmp/root/cluster.cxx:72:80: error: no matching function for call to 'atoi'
              pcb_n_cluster[(int)((((centroid_coord/temp_q_sum)/pitch)-1)/512)+((int)(atoi(name).substr(1,1).c_str())-1)*5] += 1;
                                                                                      ^~~~
/usr/include/stdlib.h:104:12: note: candidate function not viable: no known conversion from 'std::__cxx11::string' (aka 'basic_string<char>') to 'const char *' for 1st argument
extern int atoi (const char *__nptr)
           ^
In file included from input_line_10:1:
/home/vladimir/tmp/root/cluster.cxx:102:3: error: use of undeclared identifier '_pcb_n_cluster'
  _pcb_n_cluster.clear();
  ^
/home/vladimir/tmp/root/cluster.cxx:141:10: error: C++ requires a type specifier for all declarations
Cluster::isGoodCluster(int charge_min, string &name) const
         ^
/home/vladimir/tmp/root/cluster.cxx:143:23: error: use of undeclared identifier 'chamb'
  for(UInt_t i = 0; i<chamb.size(); i++)
                      ^
/home/vladimir/tmp/root/cluster.cxx:145:8: error: use of undeclared identifier 'chamb'
    if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)
       ^
/home/vladimir/tmp/root/cluster.cxx:145:31: error: use of undeclared identifier 'cluster_max_q'
    if(chamb.at(i) == name && cluster_max_q.at(i)<charge_min)
                              ^

At this point I think that your example has issues with the program itself not the ROOT. I don’t understand why you get SEGFAULT on this example, may be there is a problem with your ROOT installation. Are you sure that you were able to compile this code before?

P.S. I’m not sure about your code, I could modify it so that it could be compiled and be run but I don’t know what you do and what you want to achieve with it.


WBR, Vladimir Lomov

In fact, I wasn’t able to change these files in such a way as to make them compilable. I had to change too many parts of codes but stuck on code that I don’t understand completely (too many variables, some of them are used in different classes and etc).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.