How to clear vector

Hi,
I want to clear a vector after every event. but its giving some error like

Error: Function destroy(i,finish) is not defined in current scope _vector.h:162:
*** Interpreter error recovered ***

I wants to clear ch, ph vectots for every event and bkg_ch and bkg_ph only at the start.

thanks in advance
with best regards
sunil

Here is my code


void nu_dynamics3(){
const Int_t fTracks = 5000;
std::vector<float*> ch;
std::vector<float*> ph;
std::vector<float*> bkg_ch;
std::vector<float*> bkg_ph;
Short_t tpcref;
Int_t neutral,bemcClus, new_neutral;
Int_t nrefcharge;
Int_t charge;
Float_t vertex;
Float_t eta_proj[fTracks];
Float_t phi_proj[fTracks];
Int_t ctb, zdc, bbc;

Short_t iEvt, nEvt,fitpoints;
Int_t charge, neutral;
Float_t pT_total, pt_T, zvertex,dca,pt,;

Float_t dca;
Float_t pt, bemcEt,tpcpT ;
Int_t refcharge, nrefcharge, new_neutral;

Float_t etatb[fTracks];
Float_t phitb[fTracks];
Float_t eta_proj[fTracks];
Float_t phi_proj[fTracks];
Float_t pT[fTracks];
Float_t DCA[fTracks];
Short_t PossHits[fTracks];
Short_t Fitpoints[fTracks];
Short_t pid[fTracks];
Float_t etabt[fTracks];
Float_t phibt[fTracks];
Float_t energybt[fTracks];
Float_t pt_charge[fTracks] ;
Float_t eta_charge[fTracks];
Float_t phi_charge[fTracks];
Float_t energy_photon[fTracks];
Float_t eta_photon[fTracks];
Float_t phi_photon[fTracks];

TVector mTrackChargeCollection;
TVector mTrackGammaCollection;
TVector mBkgChargeCollection;
TVector mBkgPhotonCollection;

mBkgChargeCollection.Clear();
mBkgPhotonCollection.Clear();
bkg_ch.clear(); bkg_ph.clear();
//////files to be open
Int_t maxfile=3;
Int_t M =0;
TString filename[maxfile];
filename[0]=“D_301.root”;
filename[1]=“D_308.root”;
filename[2]=“D_309.root”;

for(int ifl=0;ifl<maxfile;ifl++){
TFile file = new TFile(filename[ifl].Data(),“r”);
cout<<"to get tree “<<filename[ifl].Data()<<endl;
cout<<“Opening the input file.”<<endl;
TTree bt = (TTree)file->Get(“ttree”);
cout<<“Input file opened.”<<endl;
bt->SetBranchAddress(“iEvt”, &iEvt);
bt->SetBranchAddress(“pt_T”, &pt_T);
bt->SetBranchAddress(“zvertex”, &zvertex);
bt->SetBranchAddress(“tpcref”, &tpcref);
bt->SetBranchAddress(“charge”, &charge);
bt->SetBranchAddress(“neutral”, &neutral);
bt->SetBranchAddress(“pid”, pid);
bt->SetBranchAddress(“Fitpoints”, Fitpoints);
bt->SetBranchAddress(“PossHits”, PossHits);
bt->SetBranchAddress(“etatb”, etatb);
bt->SetBranchAddress(“phitb”, phitb);
bt->SetBranchAddress(“pT”, pT);
bt->SetBranchAddress(“DCA”, DCA);
bt->SetBranchAddress(“etabt”, etabt);
bt->SetBranchAddress(“phibt”, phibt);
bt->SetBranchAddress(“energybt”, energybt);
bt->SetBranchAddress(“bbc”, &bbc);
bt->SetBranchAddress(“zdc”, &zdc);
bt->SetBranchAddress(“ctb”, &ctb);
Int_t entries =(Int_t)bt->GetEntries();
cout<<”# of events
**** "<< entries<<endl;
Int_t Photon, Charge;
for(Int_t i=0;i<entries;i++){
bt->GetEntry(i);M++;
mTrackChargeCollection.Clear();
mTrackGammaCollection.Clear();
ch.clear();ph.clear();
Photon=0; Charge=0;
if(zvertex < 30 && zvertex > -30 && ctb>1 && zdc >1 && bbc>1){
if(tpcref>0){
for(Int_t ic=0; ic<charge; ic++){
if(Fitpoints[ic] > 14 && PossHits[ic] > 10){
if(Fitpoints[ic]/(Float_t)PossHits[ic]<0.55){
if(pT[ic]>0.1 && pT[ic]<5 && etatb[ic]> 0 && etatb[ic]<1.0 && DCA[ic]<3.0){
Float_t TrackForCharge = new Float_t[4];
TrackForCharge[0]=pT;
TrackForCharge[1]=etatb;
TrackForCharge[2]=phitb;
TrackForCharge[3]=Charge;
ch.push_back(TrackForCharge);
bkg_ch.push_back(TrackForCharge);
cout<<ch.size()<< ‘\t’<< bkg_ch.size()<<endl;
Charge++;
}
}
}
}
for(Int_t in=0; in<neutral; in++){
if(energybt[in]>0.4 && etabt[in]>0.0 &&etabt[in]<=1.0){
Float_t TrackForGamma = new Float_t[4];
TrackForGamma[0]=energybt;
TrackForGamma[1]=etabt;
TrackForGamma[2]=phibt;
TrackForGamma[3]=Photon;
ph.push_back(TrackForGamma);
bkg_ph.push_back(TrackForGamma);
cout<< " llllll "<<ph.size()<<’\t’<<bkg_ph.size()<<endl;
Photon++;
}
}
}
}
/
for(UInt_t i=0;i<Charge;i++){
for(UInt_t j=i+1;j<Photon;j++){
}
}
/
if(M%1000==0)cout<< " I am here sdfhsdjfhhdhfghdfhghdf "<< M<<endl;
//cout<< M <<’\t’<< Photon <<’\t’<< Charge<< endl;
}//end of event loop
}// end of max file
}

You need to create a dictionary for vector<float*> and/or compile your script.

Philippe

PS. Please do not post several time the same question.

Hi,
How to create a dictionary for vector<float*>. could you please help me.

thanks and regards
sunil

Hi,
see e.g. root.cern.ch/phpBB2/viewtopic.php?t=4936
Axel.