# Vector in loop

Hi dear
I have int vector and loop over the size of this vector, and each elements at the vector has many elements. I need to delete element if one of the numbers has a certain value could you please help me with that.part of my code is below

vector particles = slowJet.constituents(ijet);// jet’s particles
int iSize = particles.size();

for( int injets=0; injets< iSize; ++injets){// loop over the particles inside the jets
if (abs(pythia.event[particles[injets]].id())!=13 ) njets.push_back(ijet);
if (abs(pythia.event[particles[injets]].id())==13 ) nmujets.push_back(ijet);
}

I do not know exactly what you are trying to do, but certainly is a general programming question and not specific to ROOT. Perhaps something like this would help you.

``````vector<int> particles = slowJet.constituents(ijet);// jet's particles
int iSize = particles.size();

bool hasmuon = false;
for( int p = 0; p < iSize; ++p) {  // loop over the particles inside the jets
if (abs(pythia.event[particles[p]].id())==13 ) {
hasmuon = true;
break;
}
}

if( hasmuon ) nmujets.push_back(ijet);
else          njets.push_back(ijet);``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.7568673,"math_prob":0.8897396,"size":578,"snap":"2023-14-2023-23","text_gpt3_token_len":152,"char_repetition_ratio":0.14808363,"word_repetition_ratio":0.0,"special_character_ratio":0.26124567,"punctuation_ratio":0.15517241,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96801853,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-20T10:32:47Z\",\"WARC-Record-ID\":\"<urn:uuid:8208cab9-e136-47fb-85b3-ae82cac23318>\",\"Content-Length\":\"17475\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:29330bb3-2dcb-4d6e-a70a-188cebba24ea>\",\"WARC-Concurrent-To\":\"<urn:uuid:5c158c22-6a1c-459e-8ef0-6da09bbb3fe9>\",\"WARC-IP-Address\":\"137.138.157.187\",\"WARC-Target-URI\":\"https://root-forum.cern.ch/t/vector-in-loop/19242\",\"WARC-Payload-Digest\":\"sha1:TCFR7OAEJG6DNMHO56QAVF6XSFQMKDNS\",\"WARC-Block-Digest\":\"sha1:FEK7XZDKAQ7NVQG3R7S2YNBLTY3QO3CI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296943471.24_warc_CC-MAIN-20230320083513-20230320113513-00696.warc.gz\"}"}