8 #include "marlin/VerbosityLevels.h"
10 #ifdef MARLIN_USE_AIDA
11 #include <marlin/AIDAProcessor.h>
12 #include <AIDA/IHistogramFactory.h>
13 #include <AIDA/ICloud1D.h>
15 #endif // MARLIN_USE_AIDA
18 using namespace lcio ;
19 using namespace marlin ;
30 _description =
"TrueJet does whatever it does ..." ;
37 registerInputCollection( LCIO::MCPARTICLE,
38 "MCParticleCollection" ,
39 "Name of the MCParticle collection" ,
41 std::string(
"MCParticlesSkimmed") );
43 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
44 "RecoParticleCollection" ,
45 "Name of the ReconstructedParticles input collection" ,
47 std::string(
"PandoraPFOs") ) ;
49 registerInputCollection( LCIO::LCRELATION,
51 "Name of the RecoMCTruthLink input collection" ,
53 std::string(
"RecoMCTruthLink") ) ;
59 registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
61 "Name of the TrueJetCollection output collection" ,
63 std::string(
"TrueJets") ) ;
65 registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
66 "FinalColourNeutrals" ,
67 "Name of the FinalColourNeutralCollection output collection" ,
69 std::string(
"FinalColourNeutrals") ) ;
71 registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
72 "InitialColourNeutrals" ,
73 "Name of the InitialColourNeutralCollection output collection" ,
75 std::string(
"InitialColourNeutrals") ) ;
78 registerOutputCollection( LCIO::LCRELATION,
80 "Name of the TrueJetPFOLink output collection" ,
82 std::string(
"TrueJetPFOLink") ) ;
84 registerOutputCollection( LCIO::LCRELATION,
85 "TrueJetMCParticleLink" ,
86 "Name of the TrueJetMCParticleLink output collection" ,
88 std::string(
"TrueJetMCParticleLink") ) ;
90 registerOutputCollection( LCIO::LCRELATION,
91 "FinalElementonLink" ,
92 "Name of the FinalElementonLink output collection" ,
94 std::string(
"FinalElementonLink") ) ;
96 registerOutputCollection( LCIO::LCRELATION,
97 "InitialElementonLink" ,
98 "Name of the InitialElementonLink output collection" ,
100 std::string(
"InitialElementonLink") ) ;
102 registerOutputCollection( LCIO::LCRELATION,
103 "FinalColourNeutralLink" ,
104 "Name of the FinalColourNeutralLink output collection" ,
106 std::string(
"FinalColourNeutralLink") ) ;
108 registerOutputCollection( LCIO::LCRELATION,
109 "InitialColourNeutralLink" ,
110 "Name of the InitialColourNeutralLink output collection" ,
112 std::string(
"InitialColourNeutralLink") ) ;
115 registerProcessorParameter(
"Whizard1",
116 "true: Input has MCParticles in Whizard1 convention ",
126 streamlog_out(DEBUG7) <<
" init called " << std::endl ;
150 streamlog_out(WARNING) <<
" processing event: " <<
evt->getEventNumber()
151 <<
" in run: " <<
evt->getRunNumber() << std::endl ;
152 streamlog_out(MESSAGE4) <<
" =====================================" << std::endl;
155 LCCollection* mcpcol = NULL;
159 catch( lcio::DataNotAvailableException&
e )
165 LCCollection* rmclcol = NULL;
169 catch( lcio::DataNotAvailableException& e )
171 streamlog_out(MESSAGE4) <<
_recoMCTruthLink <<
" collection not available" << std::endl;
179 if( mcpcol != NULL ){
181 if ( rmclcol != NULL ) {
reltrue =
new LCRelationNavigator( rmclcol ); }
190 streamlog_out(DEBUG4) <<
" Higgs-> gluon gluon event : TrueJet will not work correctly " << std::endl;
201 for (
int kk=1 ; kk <= 25 ; kk++ ) {
210 for (
int kk=1 ; kk <= 4000 ; kk++ ) {
228 for (
int k_py=1 ; k_py <=
nlund ; k_py++ ) {
229 streamlog_out(DEBUG0) <<
" Checking string at " << k_py <<
" k[k_py][2], jet[k_py] and k[k_py][1] : " <<
230 " " <<
k[k_py][2] <<
" , " <<
jet[k_py] <<
" , " <<
k[k_py][1] << std::endl;
231 if (
k[k_py][2] == 92 &&
jet[k_py] == 0 &&
k[k_py][1] < 30 ) {
232 streamlog_out(DEBUG4) <<
" string found at " << k_py <<std::endl;
244 for (
int k_py=1 ; k_py<=
nlund ; k_py++) {
245 if (
k[k_py][1] >= 30 ) {
267 streamlog_out(ERROR) <<
" inconsiency in jet finding : " << std::endl;
268 streamlog_out(ERROR) <<
" n_mixed/ njet/ 2*nstr+n_hard_lepton+2*nclu+nisr+n_beam_jet / n_jetless / n_hard_lepton: " << std::endl;
271 streamlog_out(ERROR) <<
" Event: " <<
evt->getEventNumber() <<
", run: " <<
evt->getRunNumber() << std::endl ;
272 streamlog_out(ERROR) << std::endl ;
276 streamlog_out(DEBUG3) <<
" HEPEVT relation table up with jet assignment " <<std::endl;
277 streamlog_out(DEBUG3) <<
" line status pdg parent first last px py "
278 <<
" pz E M jet companion type" << std::endl;
279 streamlog_out(DEBUG3) <<
" daughter "
280 <<
" jet" << std::endl;
282 for (
int k_py=1 ; k_py <=
nlund ; k_py++){
283 streamlog_out(DEBUG3) << std::setw(7) << k_py << std::setw(7) <<
k[k_py][1] <<
284 std::setw(12) <<
k[k_py][2] << std::setw(7) <<
k[k_py][3] <<
285 std::setw(7) <<
k[k_py][4] << std::setw(7) <<
k[k_py][5] <<
286 std::setw(12) <<
p[k_py][1] <<
287 std::setw(12) <<
p[k_py][2] << std::setw(12) <<
p[k_py][3] <<
288 std::setw(12) <<
p[k_py][4] << std::setw(12) <<
p[k_py][5] <<
290 std::setw(7) <<
jet[k_py] <<
291 std::setw(7) <<
companion[abs(
jet[k_py])] << std::setw(7) <<
type[abs(
jet[k_py])]<<std::endl;
293 streamlog_out(DEBUG3) <<
" jet fafp-beg qrk/lept fafp-end fafp-boson type dijet-beg dijet-end boson" << std::endl;
294 for (
int k_py=1 ; k_py <=
njet ; k_py++){
295 streamlog_out(DEBUG3) << std::setw(10) << k_py << std::setw(10) <<
fafp[k_py] <<
298 std::setw(10) <<
dijet_end[k_py] << std::setw(10) <<
boson[k_py]<<std::endl;
313 LCCollection* tjrcol = 0;
314 LCCollection* tjtcol = 0;
315 LCRelationNavigator truejet_pfo_Nav(LCIO::RECONSTRUCTEDPARTICLE , LCIO::RECONSTRUCTEDPARTICLE ) ;
316 LCRelationNavigator truejet_truepart_Nav(LCIO::RECONSTRUCTEDPARTICLE , LCIO::MCPARTICLE ) ;
326 double str_tmom[3]={0}, str_mom[3]={0}, str_tmomS[3]={0} , str_tE=0 , str_E=0 , str_tES=0;
328 streamlog_out(DEBUG8) <<
" Number of jets found : " <<
njet << std::endl;
330 double tmomS[25][3]={0.} ;
332 int pid_type[25]={0} ;
333 for (
int i_jet=1; i_jet<=
njet ; i_jet++ ) {
336 ReconstructedParticleImpl* true_jet =
new ReconstructedParticleImpl;
338 pid_type[i_jet] = -
type[i_jet] ;
340 jet_vec->addElement(true_jet);
343 streamlog_out(DEBUG1) << std::endl;
344 streamlog_out(DEBUG1) <<
" Following jet " << i_jet <<
" ( "<< true_jet <<
")" << std::endl;
345 streamlog_out(DEBUG1) <<
" ============================= " << std::endl;
346 streamlog_out(DEBUG1) <<
" HEPEVT relation table with jet assignment and pfo(s), if any " <<std::endl;
347 streamlog_out(DEBUG1) <<
" line mcp status pdg parent first last jet pfo(s)" << std::endl;
348 streamlog_out(DEBUG1) <<
" daughter daugther " << std::endl;
351 ReconstructedParticleImpl* true_jet ;
352 for (
int k_py=1 ; k_py<=
nlund ; k_py++){
353 int i_jet = abs(
jet[k_py]);
356 true_jet =
dynamic_cast<ReconstructedParticleImpl*
>(jet_vec->getElementAt(i_jet-1));
360 streamlog_out(DEBUG1) << std::setw(10) << k_py <<
" (" <<
mcp_pyjets[k_py] <<
")" << std::setw(10) <<
k[k_py][1]%30 <<
361 std::setw(10) <<
k[k_py][2] << std::setw(10) <<
k[k_py][3] <<
362 std::setw(10) <<
k[k_py][4] << std::setw(10) <<
k[k_py][5] << std::setw(10) <<
jet[k_py] ;
366 if (
k[k_py][1] == 1 &&
k[k_py][2] == 22 && jet[
k[k_py][3]] < 0 &&
k[
k[k_py][3]][2] != 22 ) {
368 truejet_truepart_Nav.addRelation( true_jet,
mcp_pyjets[k_py], ( jet[k_py]>0 ? -(
k[k_py][1])%30 : 0.0 )) ;
370 truejet_truepart_Nav.addRelation( true_jet,
mcp_pyjets[k_py], ( jet[k_py]>0 ?
k[k_py][1]%30 : 0.0 )) ;
373 if ( rmclcol != NULL ) {
389 if ( recovec.size() > 0 ) {
395 if ( ! seen[
k[k_py][3]] ) {
397 tmomS[i_jet][0]+=
p[k_py][1] ;
398 tmomS[i_jet][1]+=
p[k_py][2] ;
399 tmomS[i_jet][2]+=
p[k_py][3] ;
400 tES[i_jet]+=
p[k_py][4] ;
402 streamlog_out(DEBUG3) <<
" Ancestor of true particle " << k_py <<
" already seen, not added again to true-of-seen " << std::endl;
405 streamlog_out(DEBUG1) <<
" recovec size is " << recovec.size() ;
406 int last_winner = i_jet ;
407 for (
unsigned i_reco=0 ; i_reco<recovec.size() ; i_reco++ ) {
412 ReconstructedParticle* reco_part =
dynamic_cast<ReconstructedParticle*
>(recovec[i_reco]);
414 if (truejet_pfo_Nav.getRelatedFromObjects(reco_part).size() == 0 ) {
415 streamlog_out(DEBUG3) <<
" recopart " << i_reco ;
416 bool split_between_jets =
false;
417 int winner=i_jet , wgt_trk[26]={0} , wgt_clu[26]={0} ;
419 LCObjectVec recomctrues =
reltrue->getRelatedToObjects(reco_part);
420 static FloatVec recomctrueweights;
421 recomctrueweights =
reltrue->getRelatedToWeights(reco_part);
422 streamlog_out(DEBUG3) <<
" mctrues of this reco " << recomctrues.size() << std::endl ;
423 for (
unsigned k_mcp_of_reco=0 ; k_mcp_of_reco<recomctrues.size() ; k_mcp_of_reco++ ) {
424 MCParticle* an_mcp =
dynamic_cast<MCParticle*
>(recomctrues[k_mcp_of_reco]);
425 int jetoftrue=jet[an_mcp->ext<
MCPpyjet>()];
426 if ( jetoftrue != i_jet ) split_between_jets =
true;
427 wgt_trk[jetoftrue]+=int(recomctrueweights[k_mcp_of_reco])%10000 ;
428 wgt_clu[jetoftrue]+=int(recomctrueweights[k_mcp_of_reco])/10000 ;
429 streamlog_out(DEBUG1) <<
" weights for jet " << jetoftrue <<
" : " << int(recomctrueweights[k_mcp_of_reco])
430 <<
" " << int(recomctrueweights[k_mcp_of_reco])%10000
431 <<
" " << int(recomctrueweights[k_mcp_of_reco])/10000 << std::endl ;
433 if ( split_between_jets ) {
434 double wgt_trk_max=0, wgt_clu_max=0 ;
435 int imax_trk=0, imax_clu=0;
437 for (
int j_jet=1 ; j_jet <=
njet ; j_jet++ ) {
438 streamlog_out(DEBUG3) <<
" jetweights for " << j_jet <<
" " << wgt_trk[j_jet] <<
" " << wgt_clu[j_jet] ;
439 if ( wgt_trk[j_jet] > wgt_trk_max ) {
440 imax_trk= j_jet ; wgt_trk_max = wgt_trk[j_jet] ;
442 if ( wgt_clu[j_jet] > wgt_clu_max ) {
443 imax_clu= j_jet ; wgt_clu_max = wgt_clu[j_jet] ;
446 streamlog_out(DEBUG3) <<
" " << imax_clu <<
" " << imax_trk <<
" " << wgt_clu_max <<
" " << wgt_trk_max ;
447 if ( imax_clu == imax_trk || wgt_trk_max >= 750 ) {
449 }
else if ( wgt_trk_max == 0 ) {
452 streamlog_out(DEBUG3) <<
" was ? " << imax_clu <<
" " << imax_trk <<
" " << wgt_clu_max <<
" " << wgt_trk_max << std::endl;
453 for (
int j_jet=1 ; j_jet <=
njet ; j_jet++ ) {
454 streamlog_out(DEBUG3) <<
" was jetweights for " << j_jet <<
" " << wgt_trk[j_jet] <<
" " << wgt_clu[j_jet] << std::endl;
457 if ( imax_clu > 0 ) {
466 if ( winner > 0 && winner != last_winner ) true_jet =
dynamic_cast<ReconstructedParticleImpl*
>(jet_vec->getElementAt(winner-1));
468 streamlog_out(DEBUG3) <<
" and the winner is " << winner <<
" ( i_jet is " << i_jet <<
" ) " ;
470 last_winner = winner ;
472 const double* mom = reco_part->getMomentum();
474 for (
int xyz=0 ; xyz<3 ; xyz++) {
475 mom2[xyz]=mom[xyz]+true_jet->getMomentum()[xyz] ;
476 psq+= mom2[xyz]*mom2[xyz];
479 E = reco_part->getEnergy()+true_jet->getEnergy();
480 q = reco_part->getCharge()+true_jet->getCharge();
481 true_jet->setCharge(q);
482 true_jet->setEnergy(E);
483 true_jet->setMass(sqrt(E*E-psq));
484 true_jet->setMomentum(mom2);
485 streamlog_out(DEBUG1) <<
" " << reco_part ;
486 pid_type[winner] =
type[winner] ;
488 true_jet->addParticle(reco_part);
493 truejet_pfo_Nav.addRelation( true_jet, reco_part , 1.0 );
500 streamlog_out(WARNING) <<
" reco particle " << i_reco <<
" of pythia-particle " << k_py
501 <<
" has weights = 0 to ALL MCPs ??? " << std::endl;
502 streamlog_out(WARNING) <<
" Event: " <<
evt->getEventNumber() <<
", run: " <<
evt->getRunNumber() << std::endl ;
507 streamlog_out(DEBUG1) <<
" " << reco_part <<
" seen more than once ! " << std::endl;
512 if ( seen[
k[k_py][3]] ) {
514 streamlog_out(DEBUG2) <<
" Ancestor of true particle " << k_py <<
" was seen, so particle " << k_py
515 <<
" is marked as seen (even if it wasn't seen itself " << std::endl;
518 streamlog_out(DEBUG1) << std::endl;
524 for (
int i_jet=1; i_jet<=
njet ; i_jet++ ) {
526 true_jet =
dynamic_cast<ReconstructedParticleImpl*
>(jet_vec->getElementAt(i_jet-1));
527 ParticleIDImpl* pid =
new ParticleIDImpl;
529 pid->setType(pid_type[i_jet]);
530 true_jet->addParticleID(pid);
531 true_jet->ext<
TJindex>()=i_jet;
535 for (
int i_jet=1; i_jet<=
njet ; i_jet++ ) {
537 true_jet =
dynamic_cast<ReconstructedParticleImpl*
>(jet_vec->getElementAt(i_jet-1));
539 const double* mom = true_jet->getMomentum();
541 streamlog_out(DEBUG5) << std::endl;
542 streamlog_out(DEBUG9) <<
" summary " << i_jet <<
" " <<
type[i_jet]%100 <<
" " << true_jet->getEnergy() <<
" "
543 <<
tE[i_jet] <<
" " << tES[i_jet] << std::endl ;
544 streamlog_out(DEBUG5) <<
" jet " <<std::setw(4)<< i_jet <<
" (seen) p : "
545 << mom[0] <<
" " << mom[1] <<
" " << mom[2]
546 <<
" " <<
" E " << true_jet->getEnergy()<< std::endl;
547 streamlog_out(DEBUG5) <<
" " <<
" (true) p : "
548 <<
tmom[i_jet][0] <<
" " <<
tmom[i_jet][1] <<
" " <<
tmom[i_jet][2]
549 <<
" " <<
" E " <<
tE[i_jet] << std::endl;
550 streamlog_out(DEBUG5) <<
" " <<
" (true of seen) p : "
551 << tmomS[i_jet][0] <<
" " << tmomS[i_jet][1] <<
" " << tmomS[i_jet][2]
552 <<
" " <<
" E " << tES[i_jet] << std::endl;
553 streamlog_out(DEBUG5) <<
" ancestor 1" << std::setw(4)<<
elementon[i_jet] <<
" p : "
555 <<
" " <<
" E " <<
p[
elementon[i_jet]][4]<< std::endl;
556 streamlog_out(DEBUG5) <<
" ancestor 2" << std::setw(4)<<
fafp_last[i_jet] <<
" p : "
558 <<
" " <<
" E " <<
p[
fafp_last[i_jet]][4]<< std::endl;
559 streamlog_out(DEBUG5) <<
" ancestor 3" << std::setw(4)<<
fafp[i_jet] <<
" p : "
560 <<
p[
fafp[i_jet]][1] <<
" " <<
p[
fafp[i_jet]][2] <<
" " <<
p[
fafp[i_jet]][3]
561 <<
" " <<
" E " <<
p[
fafp[i_jet]][4]<< std::endl;
562 streamlog_out(DEBUG5) << std::endl;
564 streamlog_out(DEBUG5) <<
" Character of jet " << i_jet <<
" : "<<
type[i_jet]%100 <<
" (1=string, 2=lepton , "
565 <<
"3=cluster, 4=isr, 5=overlay, 6=M.E. photon)." << std::endl;
566 streamlog_out(DEBUG5) <<
" Jet from boson ? " << (
type[i_jet]>=100 ?
type[i_jet]/100 : 0)
567 <<
" (0 not from boson, !=0 from boson radiated of that jet)." << std::endl;
568 streamlog_out(DEBUG5) <<
" No. of FSRs : " <<
nfsr[i_jet] << std::endl;
569 streamlog_out(DEBUG5) <<
" Jet has no energy ? " << (
tE[i_jet]<0.001) << std::endl;
571 streamlog_out(DEBUG5) << std::endl;
573 str_E+= true_jet->getEnergy(); str_tE+=
tE[i_jet]; str_tES+= tES[i_jet];
574 for (
int i=0 ; i<3 ; i++ ) {
576 str_tmom[i]+=
tmom[i_jet][i];
577 str_tmomS[i]+=tmomS[i_jet][i];
583 if ( i_jet%2 == odd_even &&
type[i_jet]%100 <= 3 ) {
584 streamlog_out(DEBUG6) <<
" Mass of jet " << i_jet-1 <<
" and " << i_jet << std::endl;
585 double masssq = str_E*str_E - str_mom[0]*str_mom[0] - str_mom[1]*str_mom[1] - str_mom[2]*str_mom[2] ;
587 streamlog_out(DEBUG6) <<
" Seen " << sqrt(masssq) << std::endl;
589 double masssq_t = str_tE*str_tE - str_tmom[0]*str_tmom[0] - str_tmom[1]*str_tmom[1] - str_tmom[2]*str_tmom[2] ;
590 if ( masssq_t > 0. ) {
591 streamlog_out(DEBUG6) <<
" true " << sqrt(masssq_t) << std::endl;
593 masssq = str_tES*str_tES - str_tmomS[0]*str_tmomS[0] - str_tmomS[1]*str_tmomS[1] - str_tmomS[2]*str_tmomS[2] ;
595 streamlog_out(DEBUG6) <<
" true of seen " << sqrt(masssq) << std::endl;
597 if (
type[i_jet]%100 == 3 ) {
600 double clu_mass=0 , clu_E= 0., clu_P[4]= {0,0,0};
602 if (
k[j_py][3] ==
k[elementon[i_jet]][4] ) {
603 clu_E +=
p[j_py][4] ; clu_P[1] +=
p[j_py][1] ; clu_P[2] +=
p[j_py][2] ; clu_P[3] +=
p[j_py][3] ;
606 clu_mass=sqrt(clu_E*clu_E-clu_P[1]*clu_P[1]-clu_P[2]*clu_P[2]-clu_P[3]*clu_P[3] );
607 streamlog_out(DEBUG6) <<
" string mass : " << clu_mass << std::endl;
608 }
else if (
type[i_jet]%100 == 2 ) {
609 double dilept_mass=0 , dilept_E= 0., dilept_P[4]= {0,0,0};
610 for (
int j_jet=i_jet-1 ; j_jet<=i_jet ; j_jet++ ) {
612 dilept_P[1] +=
p[elementon[j_jet]][1] ;
613 dilept_P[2] +=
p[elementon[j_jet]][2] ;
614 dilept_P[3] +=
p[elementon[j_jet]][3] ;
616 dilept_mass=sqrt(dilept_E*dilept_E-dilept_P[1]*dilept_P[1]-dilept_P[2]*dilept_P[2]-dilept_P[3]*dilept_P[3] );
617 streamlog_out(DEBUG6) <<
" string mass : " << dilept_mass << std::endl;
620 streamlog_out(DEBUG6) <<
" string mass : " <<
p[
k[
elementon[i_jet]][4]][5] << std::endl;
623 streamlog_out(DEBUG6) << std::endl;
624 str_tE=0; str_tES=0; str_E=0;
625 for (
int i=0 ; i<3 ; i++ ) {
626 str_tmom[i]=0. ; str_tmomS[i]=0. ; str_mom[i]=0. ;
628 if ( masssq_t > 0. ) {
630 if (
type[i_jet]%100 == 1 &&
type[i_jet-1]%100 == 1 &&
nfsr[i_jet]+
nfsr[i_jet-1]==0) {
632 streamlog_out(ERROR) <<
" bad match M (sum/initial) " <<
" " << sqrt(masssq_t)
633 <<
" / " <<
p[
k[
elementon[i_jet]][4]][5] << std::endl;
634 streamlog_out(ERROR) <<
" E (sum/initial) " <<
" " <<
tE[i_jet]+
tE[i_jet-1]
635 <<
" / " <<
p[
k[
elementon[i_jet]][4]][4] << std::endl;
637 streamlog_out(DEBUG9) <<
"list HEPEVT relation table up with jet assignment " <<std::endl;
638 streamlog_out(DEBUG9) <<
"list line status pdg parent first last px py pz "
639 <<
" E M jet companion type" << std::endl;
640 streamlog_out(DEBUG9) <<
"list daughter "
641 <<
" jet" << std::endl;
642 for (
int i_py=1 ; i_py <=
nlund ; i_py++){
643 streamlog_out(DEBUG9) <<
"list "<< std::setw(7) << i_py << std::setw(7) <<
k[i_py][1] <<
644 std::setw(12) <<
k[i_py][2] << std::setw(7) <<
k[i_py][3] <<
645 std::setw(7) <<
k[i_py][4] << std::setw(7) <<
k[i_py][5] <<
646 std::setw(12) <<
p[i_py][1] <<
647 std::setw(12) <<
p[i_py][2] << std::setw(12) <<
p[i_py][3] <<
648 std::setw(12) <<
p[i_py][4] << std::setw(12) <<
p[i_py][5] <<
650 std::setw(7) <<
jet[i_py] <<
651 std::setw(7) <<
companion[abs(
jet[i_py])] << std::setw(7) <<
type[abs(
jet[i_py])]<<std::endl;
653 streamlog_out(DEBUG9) <<
"list of individual particles with bad parent/kid energy " <<std::endl;
654 for (
int i_py=1 ; i_py<=
nlund ; i_py++ ) {
655 if (
jet[i_py] == i_jet ||
jet[i_py] == i_jet -1 ) {
656 if (
k[i_py][1] == 11 ) {
658 for (
int jj=
k[i_py][4] ; jj <=
k[i_py][5] ; jj++ ) {
661 if ( (abs(e_kid -
p[i_py][4])/
p[i_py][4] ) > 0.001 ) {
662 streamlog_out(DEBUG9) << i_py <<
" " <<
k[i_py][4] <<
" " <<
k[i_py][5] <<
" "
663 << e_kid <<
" " <<
p[i_py][4] << std::endl ;
668 streamlog_out(WARNING) <<
" jet fafp-beg qrk/lept fafp-end fafp-boson "
669 <<
"type dijet-beg dijet-end boson" << std::endl;
670 for (
int j_jet=i_jet-1 ; j_jet <= i_jet ; j_jet++){
671 streamlog_out(WARNING) << std::setw(10) << i_jet << std::setw(10) <<
fafp[j_jet] <<
674 std::setw(10) <<
dijet_end[j_jet] << std::setw(10) <<
boson[j_jet]<<std::endl;
676 streamlog_out(ERROR) <<
" Event: " <<
evt->getEventNumber() <<
", run: " <<
evt->getRunNumber() << std::endl ;
677 streamlog_out(ERROR) << std::endl ;
679 streamlog_out(DEBUG8) <<
" bad match M (sum/initial) " <<
" " << sqrt(masssq_t)
680 <<
" / " <<
p[
k[
elementon[i_jet]][4]][5] << std::endl;
681 streamlog_out(DEBUG8) <<
" E (sum/initial) " <<
" " <<
tE[i_jet]+
tE[i_jet-1]
682 <<
" / " <<
p[
k[
elementon[i_jet]][4]][4] << std::endl;
683 streamlog_out(DEBUG8) <<
" (As the energy matches well, this is probably due to the B-field) " <<std::endl;
684 streamlog_out(DEBUG8) <<
" Event: " <<
evt->getEventNumber() <<
", run: " <<
evt->getRunNumber() << std::endl ;
685 streamlog_out(DEBUG8) << std::endl;
702 LCRelationNavigator FinalColourNeutral_Nav(LCIO::RECONSTRUCTEDPARTICLE , LCIO::RECONSTRUCTEDPARTICLE ) ;
703 LCRelationNavigator FinalElementon_Nav(LCIO::RECONSTRUCTEDPARTICLE , LCIO::MCPARTICLE ) ;
705 for (
int k_dj_end=1; k_dj_end<=
n_dje ; k_dj_end++ ) {
706 double E=0, M=0 , mom[3]={} ;
int pdg[26]={};
711 for (
int jj=0 ; jj<3 ; jj++ ) {
712 mom[jj] =
tmom[jets_end[1][k_dj_end]][jj];
713 psqrs += mom[jj]*mom[jj];
726 int first=
nlund , last=0;
727 for (
int j_jet_end=1 ; j_jet_end<=
jets_end[0][k_dj_end] ; j_jet_end++ ) {
733 int this_first=0, this_last=
nlund;
740 this_last=
elementon[jets_end[j_jet_end][k_dj_end]] ;
750 this_last =
k[
k[
elementon[jets_end[j_jet_end][k_dj_end]]][5]][5];
756 this_last =
k[
elementon[jets_end[j_jet_end][k_dj_end]]][5];
759 this_last =
elementon[jets_end[j_jet_end][k_dj_end]];
764 if ( this_first < first ) {
767 if ( this_last > last ) {
773 if (
k[
elementon[jets_end[j_jet_end][k_dj_end]]][4] != 0 ) {
774 pdg[0]=
k[
k[
elementon[jets_end[j_jet_end][k_dj_end]]][4]][2];
776 pdg[0]=
k[
elementon[jets_end[j_jet_end][k_dj_end]]][2];
780 if ( last == first ) {
782 for (
int ll=1 ; ll<=3 ; ll++ ) {
783 mom[ll-1] =
p[first][ll];
787 for (
int j_jet_end=1 ; j_jet_end<=
jets_end[0][k_dj_end] ; j_jet_end++ ) {
788 for (
int k_py=first ; k_py<=last ; k_py++ ) {
790 if ( abs(
jet[k_py]) ==
jets_end[j_jet_end][k_dj_end] ) {
792 for (
int ll=1 ; ll<=3 ; ll++ ) {
793 mom[ll-1] +=
p[k_py][ll];
795 if (
type[
jets_end[j_jet_end][k_dj_end]]%100 != 3 ) {
break;}
802 for (
int ii=0 ; ii<3 ; ii++ ) {
803 psqrs += mom[ii]*mom[ii];
808 ReconstructedParticleImpl* fafpf =
new ReconstructedParticleImpl;
812 fafpf->setMomentum(mom);
813 for(
int j_jet_end=1 ; j_jet_end<=
jets_end[0][k_dj_end] ; j_jet_end++) {
814 fafpf->addParticle(dynamic_cast<ReconstructedParticle*>(jet_vec->getElementAt(
jets_end[j_jet_end][k_dj_end]-1)) );
816 ParticleIDImpl* pid[26];
817 pid[0] =
new ParticleIDImpl;
818 pid[0]->setPDG(pdg[0]);
820 fafpf->addParticleID(pid[0]);
821 for (
int j_jet_end=1 ; j_jet_end<=
jets_end[0][k_dj_end] ; j_jet_end++ ) {
822 pid[j_jet_end]=
new ParticleIDImpl;
823 pid[j_jet_end]->setPDG(pdg[j_jet_end]);
824 pid[j_jet_end]->setType(
type[
jets_end[j_jet_end][k_dj_end]]);
825 fafpf->addParticleID(pid[j_jet_end]);
827 FinalElementon_Nav.addRelation( jet_vec->getElementAt(
jets_end[j_jet_end][k_dj_end]-1) ,
830 FinalColourNeutral_Nav.addRelation( jet_vec->getElementAt(
jets_end[j_jet_end][k_dj_end]-1) , fafpf);
832 fafpf_vec->addElement(fafpf);
841 LCRelationNavigator InitialElementon_Nav(LCIO::RECONSTRUCTEDPARTICLE , LCIO::MCPARTICLE ) ;
842 LCRelationNavigator InitialColourNeutral_Nav(LCIO::RECONSTRUCTEDPARTICLE , LCIO::RECONSTRUCTEDPARTICLE ) ;
844 for (
int k_dj_begin=1 ; k_dj_begin<=
n_djb ; k_dj_begin++ ) {
845 double E=0, M=0 , mom[3]={0} ;
858 int first=
nlund , last=0;
862 first=
fafp[jets_begin[1][k_dj_begin]] ;
863 last=
fafp[jets_begin[1][k_dj_begin]] ;
868 for (
int j_jet_begin=1 ; j_jet_begin<=
jets_begin[0][k_dj_begin] ; j_jet_begin++ ) {
872 bool take_genpart =
false;
873 if (
k[gen_part][4] == 0 ) {
875 }
else if (
k [
k [gen_part] [4]][2] !=
k[gen_part][2] ||
k [
k [gen_part] [4]][1] == 0 ) {
878 if ( take_genpart ) {
879 if ( gen_part < first ) {
882 if ( gen_part > last ) {
886 if (
k[gen_part][4] < first ) {
887 first=
k[gen_part][4] ;
889 if (
k[gen_part][5] > last ) {
890 last=
k[gen_part][5] ;
895 pdg[j_jet_begin]=
k[
elementon[jets_begin[j_jet_begin][k_dj_begin]]][2];
896 int last_backtrack =
fafp[jets_begin[j_jet_begin][k_dj_begin]] ;
897 int this_pdg =
k[last_backtrack][2] ;
899 while (
k[last_backtrack][2] == this_pdg ) {
900 last_backtrack =
k[last_backtrack][3];
901 if ( last_backtrack == 0 )
break;
904 if ( last_backtrack > 0) {
905 if ( abs(
k[last_backtrack][2]) > 21 && abs(
k[last_backtrack][2]) <= 39 ) {
907 bosonid = abs(
k[last_backtrack][2]) ;
908 streamlog_out(DEBUG3) <<
" elementon " <<
fafp[jets_begin[j_jet_begin][k_dj_begin]]
909 <<
" has explicit mother with PDG = " << bosonid << std::endl;
915 pdg[0]=abs(
k[
fafp[jets_begin[j_jet_begin][k_dj_begin]]][2]);
918 else if ( bosonid==23 && abs(
k[
fafp[jets_begin[j_jet_begin][k_dj_begin]]][2]) != pdg[0] ) {
925 if (
k[last][2] == 92 ) { first = last ; }
929 if ( last == first ) {
931 for (
int ll=1 ; ll<=3 ; ll++ ) {
932 mom[ll-1] =
p[first][ll];
937 for (
int j_jets_begin=1 ; j_jets_begin<=
jets_begin[0][k_dj_begin] ; j_jets_begin++ ) {
938 for (
int k_py=first ; k_py<=last ; k_py++ ) {
939 if ( abs(
jet[k_py]) ==
jets_begin[j_jets_begin][k_dj_begin] &&
k[k_py][3] < first ) {
941 for (
int ll=1 ; ll<=3 ; ll++ ) {
942 mom[ll-1] +=
p[k_py][ll];
951 for (
int ii=1 ; ii<=3 ; ii++ ) {
952 psqrs += mom[ii-1]*mom[ii-1];
958 ReconstructedParticleImpl* fafpi =
new ReconstructedParticleImpl;
962 fafpi->setMomentum(mom);
963 ParticleIDImpl* pid[26] ;
964 pid[0]=
new ParticleIDImpl;
965 pid[0]->setPDG(pdg[0]);
967 fafpi->addParticleID(pid[0]);
968 for(
int j_jet_begin=1 ; j_jet_begin<=
jets_begin[0][k_dj_begin] ; j_jet_begin++) {
969 pid[j_jet_begin]=
new ParticleIDImpl;
970 pid[j_jet_begin]->setPDG(pdg[j_jet_begin]);
971 pid[j_jet_begin]->setType(
type[
jets_begin[j_jet_begin][k_dj_begin]]);
972 fafpi->addParticleID(pid[j_jet_begin]);
973 fafpi->addParticle(dynamic_cast<ReconstructedParticle*>(jet_vec->getElementAt(
jets_begin[j_jet_begin][k_dj_begin]-1)));
975 fafpi_vec->addElement(fafpi);
977 for (
int j_jet_begin=1 ; j_jet_begin<=
jets_begin[0][k_dj_begin] ; j_jet_begin++ ) {
978 InitialElementon_Nav.addRelation( jet_vec->getElementAt(
jets_begin[j_jet_begin][k_dj_begin]-1),
980 InitialColourNeutral_Nav.addRelation( jet_vec->getElementAt(jets_begin[j_jet_begin][k_dj_begin]-1) , fafpi);
993 LCCollection* tjfpcol = 0;
994 LCCollection* tjlpcol = 0;
995 LCCollection* tjfccol = 0;
996 LCCollection* tjlccol = 0;
997 tjrcol = truejet_pfo_Nav.createLCCollection() ;
998 tjtcol = truejet_truepart_Nav.createLCCollection() ;
999 tjfpcol = InitialElementon_Nav.createLCCollection() ;
1000 tjlpcol = FinalElementon_Nav.createLCCollection() ;
1001 tjfccol = InitialColourNeutral_Nav.createLCCollection() ;
1002 tjlccol = FinalColourNeutral_Nav.createLCCollection() ;
1013 streamlog_out(DEBUG4) <<
" HEPEVT relation table up with jet assignment, extended status codes, and PFOs w. energy (if any) " <<std::endl;
1014 streamlog_out(DEBUG4) <<
" line status pdg first last first last colour anti- px py pz "
1015 <<
" E M jet companion type PFO/Energy" << std::endl;
1016 streamlog_out(DEBUG4) <<
" init ext'd parent daughter colour "
1017 <<
" jet" << std::endl;
1020 for (
int i_py=1 ; i_py <= std::min(
nlund,200) ; i_py++){
1023 if (
jet[i_py] != 0 ) {
1024 static FloatVec www;
1025 www = truejet_truepart_Nav.getRelatedFromWeights(
mcp_pyjets[i_py]);
1029 if (
k[i_py][1] > 0 &&
k[i_py][1] < 30 ) {
1031 streamlog_out(DEBUG4) << std::setw(4) << i_py << std::setw(7) <<
k[i_py][1] << std::setw(5) << istat <<
1032 std::setw(7) <<
k[i_py][2] << std::setw(7) <<
k[i_py][3] << std::setw(5) <<
k[i_py][6] <<
1033 std::setw(7) <<
k[i_py][4] << std::setw(5) <<
k[i_py][5] <<
1034 std::setw(7) <<
k[i_py][7] << std::setw(7) <<
k[i_py][8] <<
1035 std::setw(12) <<
p[i_py][1] <<
1036 std::setw(12) <<
p[i_py][2] << std::setw(12) <<
p[i_py][3] <<
1037 std::setw(12) <<
p[i_py][4] << std::setw(12) <<
p[i_py][5] <<
1039 std::setw(7) <<
jet[i_py] <<
1042 streamlog_out(DEBUG3) << std::setw(4) << i_py << std::setw(7) <<
k[i_py][1] << std::setw(5) << istat <<
1043 std::setw(5) <<
k[i_py][2] << std::setw(7) <<
k[i_py][3] << std::setw(5) <<
k[i_py][6] <<
1044 std::setw(7) <<
k[i_py][4] << std::setw(5) <<
k[i_py][5] <<
1045 std::setw(7) <<
k[i_py][7] << std::setw(7) <<
k[i_py][8] <<
1046 std::setw(12) <<
p[i_py][1] <<
1047 std::setw(12) <<
p[i_py][2] << std::setw(12) <<
p[i_py][3] <<
1048 std::setw(12) <<
p[i_py][4] << std::setw(12) <<
p[i_py][5] <<
1050 std::setw(7) <<
jet[i_py] <<
1056 if ( recovec.size() > 0 ) {
1057 for (
unsigned i_reco=0 ; i_reco<recovec.size() ; i_reco++ ) {
1058 if (
k[i_py][1] > 0 &&
k[i_py][1] < 30 ) {
1060 ReconstructedParticle* reco_part =
dynamic_cast<ReconstructedParticle*
>(recovec[i_reco]);
1061 streamlog_out(DEBUG4) <<
" [" << std::setw(8) << reco_part->getEnergy() <<
"] ";
1063 ReconstructedParticle* reco_part =
dynamic_cast<ReconstructedParticle*
>(recovec[i_reco]);
1064 streamlog_out(DEBUG3) <<
" [" << std::setw(10) << reco_part <<
" /"<< std::setw(8) << reco_part->getEnergy() <<
"] ";
1067 }
else if ( istat == 1 ) {
1068 if (
k[i_py][1] > 0 &&
k[i_py][1] < 30 ) {
1069 streamlog_out(DEBUG4) <<
" [" << std::setw(10) <<
"N.A "<<
" /"<< std::setw(8) <<
"N.A "<<
"] ";
1071 streamlog_out(DEBUG3) <<
" [" << std::setw(10) <<
"N.A "<<
" /"<< std::setw(8) <<
"N.A "<<
"] ";
1075 if (
k[i_py][1] > 0 &&
k[i_py][1] < 30 ) {
1076 streamlog_out(DEBUG4) << std::endl;
1078 streamlog_out(DEBUG3) << std::endl;
1081 streamlog_out(DEBUG6) << std::endl;
1083 streamlog_out(DEBUG6) <<
" jet fafp-beg qrk/lept fafp-end fafp-boson type "
1084 <<
"dijet-beg dijet-end boson" << std::endl;
1085 for (
int i_jet=1 ; i_jet <=
njet ; i_jet++){
1086 streamlog_out(DEBUG6) << std::setw(10) << i_jet << std::setw(10) <<
fafp[i_jet] <<
1088 std::setw(10) <<
fafp_boson[i_jet] << std::setw(10) <<
type[i_jet] <<
1090 std::setw(10) <<
dijet_end[i_jet] << std::setw(10) <<
boson[i_jet]<<std::endl;
1092 streamlog_out(DEBUG6) << std::endl;
1093 streamlog_out(DEBUG6) <<
" Colour-neutral objects at the beginning of the parton shower " << std::endl;
1094 streamlog_out(DEBUG6) <<
" number px py pz E M "
1095 <<
" type PDGs jets " << std::endl;
1097 for (
unsigned i_cn_b=0 ; i_cn_b<fafpi_vec->size() ; i_cn_b++ ) {
1099 ReconstructedParticle* fafpi =
dynamic_cast<ReconstructedParticle*
>(fafpi_vec->at(i_cn_b));
1100 LCObjectVec jts = InitialColourNeutral_Nav.getRelatedFromObjects(fafpi);
1102 const double* mom=fafpi->getMomentum();
1103 streamlog_out(DEBUG6) << std::setw(7) << i_cn_b+1 << std::setw(12) << mom[0] <<
1104 std::setw(12) << mom[1] << std::setw(12) << mom[2] <<
1105 std::setw(12) <<fafpi->getEnergy() << std::setw(12) << fafpi->getMass() <<
1106 std::setw(7) << fafpi->getParticleIDs()[0]->getType() <<
" " ;
1107 for (
unsigned i_pid=0 ; i_pid < fafpi->getParticleIDs().size() ; i_pid++ ) {
1108 if (fafpi->getParticleIDs()[i_pid]->getType()>=100 ) glurad=1;
1109 if (i_pid < fafpi->getParticleIDs().size()-1 ) {
1110 streamlog_out(DEBUG6) << std::setw(3)<< fafpi->getParticleIDs()[i_pid]->getPDG() <<
"," ;
1112 streamlog_out(DEBUG6) << std::setw(3)<< fafpi->getParticleIDs()[i_pid]->getPDG() <<
" " ;
1115 for (
unsigned j_jet_begin=0 ; j_jet_begin<jts.size() ; j_jet_begin++ ) {
1116 int i_jet=jts[j_jet_begin]->ext<
TJindex>();
1117 if ( j_jet_begin < jts.size()-1 ) {
1118 streamlog_out(DEBUG6) << std::setw(3) << i_jet <<
"," ;
1120 streamlog_out(DEBUG6) << std::setw(3) << i_jet ;
1123 streamlog_out(DEBUG6) << std::endl;
1125 if ( glurad == 1 ) {
1126 streamlog_out(DEBUG6) << std::endl;
1127 streamlog_out(DEBUG6) <<
" gluon radiation in event : "<< std::endl;
1128 for (
unsigned j_cn_b=0 ; j_cn_b<fafpi_vec->size() ; j_cn_b++ ) {
1130 ReconstructedParticle* fafpi =
dynamic_cast<ReconstructedParticle*
>(fafpi_vec->at(j_cn_b));
1131 LCObjectVec jts = InitialColourNeutral_Nav.getRelatedFromObjects(fafpi);
1133 for (
unsigned j_pid_cn_b=1 ; j_pid_cn_b < fafpi->getParticleIDs().size() ; j_pid_cn_b++ ) {
1134 if (fafpi->getParticleIDs()[j_pid_cn_b]->getType()>=100 ) {
1135 int i_jet=jts[j_pid_cn_b-1]->ext<
TJindex>();
1136 streamlog_out(DEBUG6) << std::setw(18)<< i_jet <<
" is from "
1137 << fafpi->getParticleIDs()[j_pid_cn_b]->getType()/100 << std::endl;
1143 streamlog_out(DEBUG6) << std::endl;
1144 streamlog_out(DEBUG6) <<
" Colour-neutral objects at the end of the parton shower " << std::endl;
1145 streamlog_out(DEBUG6) <<
" number px py pz E M "
1146 <<
" type PDGs jets " << std::endl;
1147 for (
unsigned i_cn_e=0 ; i_cn_e<fafpf_vec->size() ; i_cn_e++ ) {
1149 ReconstructedParticle* fafpf =
dynamic_cast<ReconstructedParticle*
>(fafpf_vec->at(i_cn_e));
1150 LCObjectVec jts = FinalColourNeutral_Nav.getRelatedFromObjects(fafpf);
1152 const double* mom=fafpf->getMomentum();
1153 streamlog_out(DEBUG6) << std::setw(7) << i_cn_e+1 << std::setw(12) << mom[0] <<
1154 std::setw(12) << mom[1] << std::setw(12) << mom[2] <<
1155 std::setw(12) <<fafpf->getEnergy() << std::setw(12) << fafpf->getMass() <<
1156 std::setw(7) << fafpf->getParticleIDs()[0]->getType() <<
" ";
1157 if ( fafpf->getParticleIDs().size() < 3 ) streamlog_out(DEBUG6) << std::setw(3) <<
" ";
1158 for (
unsigned i_pid=0 ; i_pid < fafpf->getParticleIDs().size() ; i_pid++ ) {
1159 if (i_pid < fafpf->getParticleIDs().size()-1 ) {
1160 streamlog_out(DEBUG6) << std::setw(3)<< fafpf->getParticleIDs()[i_pid]->getPDG() <<
"," ;
1162 streamlog_out(DEBUG6) << std::setw(3)<< fafpf->getParticleIDs()[i_pid]->getPDG() <<
" " ;
1165 if ( jts.size() < 2 ) streamlog_out(DEBUG6) << std::setw(3) <<
" ";
1166 for (
unsigned j_jet_end=0 ; j_jet_end<jts.size() ; j_jet_end++ ) {
1167 int i_jet=jts[j_jet_end]->ext<
TJindex>();
1168 if ( j_jet_end < jts.size()-1 ) {
1169 streamlog_out(DEBUG6) << std::setw(3) << i_jet <<
"," ;
1171 streamlog_out(DEBUG6) << std::setw(3) << i_jet ;
1174 streamlog_out(DEBUG6) << std::endl;
1176 streamlog_out(DEBUG6) << std::endl;
1194 const double* ptemp;
1196 bool _generator_input_format =
false;
1197 int higgs_line = 0 ;
1199 int nMCP = mcpcol->getNumberOfElements() ;
1203 if ( nMCP > 4000 ) {
1204 streamlog_out(WARNING) <<
" More than 4000 MCParticles in event " <<
evt->getEventNumber()
1205 <<
", run " <<
evt->getRunNumber() << std::endl ;
1208 for(
int j_mcp=0; j_mcp< std::min(nMCP,4000) ; j_mcp++){
1210 MCParticle* mcp =
dynamic_cast<MCParticle*
>( mcpcol->getElementAt( j_mcp ) ) ;
1216 if ( j_mcp == 0 && mcp->getSimulatorStatus()==0 ) { _generator_input_format = true ; }
1220 ptemp=mcp->getMomentum();
1221 p[k_py][1]=ptemp[0];
1222 p[k_py][2]=ptemp[1];
1223 p[k_py][3]=ptemp[2];
1224 p[k_py][4]=mcp->getEnergy();
1225 p[k_py][5]=mcp->getMass();
1226 k[k_py][1]=mcp->getGeneratorStatus();
1227 if (
k[k_py][1] == 2 ) {
k[k_py][1]=11 ;}
1228 if (
k[k_py][1] == 3 ) {
k[k_py][1]=21 ;}
1229 if (
k[k_py][1] == 4 ) {
k[k_py][1]=22 ;}
1230 if (mcp->isOverlay() ) {
k[k_py][1]=
k[k_py][1]+30 ; }
1231 k[k_py][2]=mcp->getPDG();
1232 if ( abs(
k[k_py][2]) == 6 ) {
_top_event = true ; }
1233 if (
k[k_py][2] == 25 ) {
1241 for (
int j_py=1; j_py <=
nlund ; j_py++ ) {
1248 streamlog_out(DEBUG1) <<
" before Motherless check: first_line = " <<
first_line << std::endl ;
1250 for(
int j_mcp=0; j_mcp< nMCP ; j_mcp++){
1252 MCParticle* mcp =
dynamic_cast<MCParticle*
>( mcpcol->getElementAt( j_mcp ) ) ;
1257 if ( mcp->getParents().size() != 0 ) {
1258 k[i_py][3]=mcp->getParents()[0]->ext<
MCPpyjet>();
1259 if (
k[i_py][3] == higgs_line ) {
1260 if (
k[i_py][2] == 21 ) {
1265 if ( i_py >
first_line+1 && ! mcp->isOverlay() &&
k[i_py][3] == 0 && abs(mcp->getPDG()) != 6 && abs(mcp->getPDG()) != 24 ) {
1266 streamlog_out(MESSAGE4) <<
" Motherless generator particle " << i_py <<
". pdg: " << mcp->getPDG() << std::endl ;
1267 streamlog_out(MESSAGE4) <<
" Event: " <<
evt->getEventNumber() <<
", run: " <<
evt->getRunNumber() << std::endl ;
1273 k[i_py][7]=mcp->getColorFlow()[0];
1274 k[i_py][8]=mcp->getColorFlow()[1];
1276 if ( mcp->getParents().size() > 1 ) {
1277 k[i_py][6]=mcp->getParents()[mcp->getParents().size()-1]->ext<
MCPpyjet>();
1282 if ( mcp->getDaughters().size() != 0 ) {
1296 if ( ! _generator_input_format ) {
1297 if (
k[i_py][1]!=0 ) {
1298 int has_genstat0_daughter=0;
1299 for (
unsigned i_dau=0 ; i_dau < mcp->getDaughters().size() ; i_dau++ ) {
1300 int j_dau=mcp->getDaughters()[i_dau]->ext<
MCPpyjet>();
1301 if ( mcp->getDaughters()[i_dau]->getGeneratorStatus()==0 || (mcp->getDaughters()[i_dau]->getSimulatorStatus()==0 &&
k[j_dau][1]==1 )) {
1302 has_genstat0_daughter=1;
1305 if ( has_genstat0_daughter==1 ) {
1307 if (
k[i_py][1] < 30 ) {
1311 for (
unsigned i_dau=0 ; i_dau < mcp->getDaughters().size() ; i_dau++ ) {
1312 int j_dau=mcp->getDaughters()[i_dau]->ext<
MCPpyjet>();
1313 if (
k[j_dau][1] < 30 ) {
1322 for (
unsigned i_dau=0 ; i_dau < mcp->getDaughters().size() ; i_dau++ ) {
1323 int j_dau=mcp->getDaughters()[i_dau]->ext<
MCPpyjet>();
1324 if (
k[j_dau][1] < 30 ) {
1336 for (
unsigned i_dau=0 ; i_dau < mcp->getDaughters().size() ; i_dau++ ) {
1337 int j_dau=mcp->getDaughters()[i_dau]->ext<
MCPpyjet>();
1338 if ( j_dau <
k[i_py][4] ||
k[i_py][4] == 0 ) {
1341 if ( j_dau >
k[i_py][5] ) {
1344 if ( abs(
k[i_py][2]) == 6 ) {
1345 if (
k[
k[i_py][4]][2] != 94 ) {
1346 k[i_py][5]=
k[i_py][4]+1;
1347 k[
k[i_py][5]][3] = i_py;
1368 streamlog_out(DEBUG4) <<
" HEPEVT relation table before 94-fixing" <<std::endl;
1369 streamlog_out(DEBUG4) <<
" line status pdg parent first last second anti " << std::endl;
1370 streamlog_out(DEBUG4) <<
" daughter daugther parent colour colour " << std::endl;
1371 for (
int j_py=1 ; j_py<=
nlund ; j_py++ ) {
1372 if (
k[j_py][1] != 0 &&
k[j_py][1] < 30 ) {
1373 streamlog_out(DEBUG4) << std::setw(10) << j_py << std::setw(10) <<
k[j_py][1] <<
1374 std::setw(10) <<
k[j_py][2] << std::setw(10) <<
k[j_py][3] <<
1375 std::setw(10) <<
k[j_py][4] << std::setw(10) <<
k[j_py][5] <<
1376 std::setw(10) <<
k[j_py][6] << std::setw(10)<<
k[j_py][7] << std::setw(10) <<
k[j_py][8] << std::endl;
1378 streamlog_out(DEBUG3) << std::setw(10) << j_py << std::setw(10) <<
k[j_py][1] <<
1379 std::setw(10) <<
k[j_py][2] << std::setw(10) <<
k[j_py][3] <<
1380 std::setw(10) <<
k[j_py][4] << std::setw(10) <<
k[j_py][5] <<
1381 std::setw(10) <<
k[j_py][6] << std::setw(10)<<
k[j_py][7] << std::setw(10) <<
k[j_py][8] << std::endl;
1387 for (
int i_py=1 ; i_py<=
nlund ; i_py++ ) {
1397 if (
k[i_py][2] == 94 &&
k[i_py][1] < 30 ) {
1410 int mothers[10] ={0};
1411 int daughters[10][10] ={0};
1416 int first_94_mother=
k[line94][3];
1417 int last_94_mother=
k[line94][6];
1418 int first_94_daughter =
k[line94][4];
1419 int last_94_daughter =
k[line94][5];
1422 for (
int mother = first_94_mother ; mother <= last_94_mother; mother++ ) {
1423 if ( (abs(
k[mother][2]) == 24 && abs(
k[
k[mother][3]][2]) !=6 ) ||
k[mother][2]==23 ||
k[mother][2]==25 )
continue;
1424 if ( abs(
k[mother][4]) != line94 )
continue;
1428 mothers[i_mo]=mother;
1430 daughters[i_mo][0]=0;
1431 int pdg_mother=
k[mother][2];
1433 for (
int ip=1; ip <=5 ; ip++ ) {
1434 p_mother[ip]=
p[mother][ip];
1437 if (
k[mother][4] == line94 &&
k[mother][5] == line94 ) {
1442 int n_94_mother = 0 ;
1443 for (
int j_py = first_94_mother ; j_py <= last_94_mother ; j_py++ ) {
1444 if (
k[j_py][4] == line94 ) { n_94_mother++ ; }
1446 if ( n_94_mother == 2 ) {
1447 if (
k[mother][2] > 0 ) {
1448 k[mother][7] = i_py ;
k[mother][8] = 0 ;
1449 k[
k[mother][3]][7] = i_py ; k[k[mother][3]][8] = 0 ;
1451 k[mother][7] = 0 ;
k[mother][8] = i_py ;
1452 k[
k[mother][3]][7] = 0 ; k[k[mother][3]][8] = i_py ;
1456 k[oma][7] =
k[mother][7] ;
k[oma][8]=
k[mother][8] ;
1465 double min_dist = 1.0e20;
1466 for (
int daughter=first_94_daughter ; daughter <= last_94_daughter ; daughter++ ) {
1467 if (
k[daughter][2] == pdg_mother ) {
1468 double dist=((p_mother[1]-
p[daughter][1])*(p_mother[1]-
p[daughter][1]) +
1469 (p_mother[2]-
p[daughter][2])*(p_mother[2]-
p[daughter][2]) +
1470 (p_mother[3]-
p[daughter][3])*(p_mother[3]-
p[daughter][3]));
1471 if ( dist < min_dist ) {
1472 best_match=daughter;
1478 if ( best_match == 0 ) {
1479 streamlog_out(ERROR) <<
" No best match ... " << std::endl;
1483 daughters[i_mo][0]=i_dau;
1484 daughters[i_mo][i_dau]=best_match;
1490 bool found_daughter = false ;
1491 for (
int daughter=
k[mother][4] ; daughter <=
k[mother][5] ; daughter++ ) {
1492 if (
k[daughter][3] == mother && daughter != line94 ) {
1493 found_daughter =
true;
1495 daughters[i_mo][0]=i_dau;
1496 daughters[i_mo][i_dau]=daughter;
1500 if ( ! found_daughter ) {
1501 streamlog_out(ERROR) <<
" Only daughter of the mother of a 94 is neither the 94, "
1502 <<
"nor a particle with same pdg as the mother " << std::endl;
1506 if (daughters[i_mo][0] == 0 ) {
1507 streamlog_out(ERROR) <<
" Did not find any daughters to the mother of a 94" << std::endl;
1513 for (
int j_mo=1 ; j_mo <= mothers[0] ; j_mo++ ) {
1515 int mother=mothers[j_mo];
1517 for (
int j_dau=1 ; j_dau <= daughters[j_mo][0] ; j_dau++ ) {
1518 int daughter=daughters[j_mo][j_dau];
1519 if ( j_dau == 1 )
k[mother][4]=daughter;
1520 k[mother][5]=daughter;
1521 k[daughter][3]=mother;
1528 streamlog_out(DEBUG3) <<
" HEPEVT relation table, after 94 fixing" <<std::endl;
1529 streamlog_out(DEBUG3) <<
" line status pdg parent first last second anti " << std::endl;
1530 streamlog_out(DEBUG3) <<
" daughter daugther parent colour coulour " << std::endl;
1532 for (
int j_py=1 ; j_py<=
nlund ; j_py++ ) {
1533 streamlog_out(DEBUG3) << std::setw(10) << j_py << std::setw(10) <<
k[j_py][1] <<
1534 std::setw(10) <<
k[j_py][2] << std::setw(10) <<
k[j_py][3] <<
1535 std::setw(10) <<
k[j_py][4] << std::setw(10) <<
k[j_py][5] << std::setw(10) <<
k[j_py][6] <<
1536 std::setw(10) <<
k[j_py][7] << std::setw(10) <<
k[j_py][8] << std::endl;
1542 int first_94_mother=
k[line94][3];
1543 int last_94_mother=
k[line94][6];
1544 int first_94_daughter =
k[line94][4];
1545 int last_94_daughter =
k[line94][5];
1549 bool inconsitent_pid =
1550 ((
k[first_94_daughter][2] !=
k[first_94_mother][2] &&
k[first_94_daughter][2] !=
k[last_94_mother][2] ) ||
1551 (
k[ last_94_daughter][2] !=
k[first_94_mother][2] &&
k[ last_94_daughter][2] !=
k[last_94_mother][2] )) ;
1553 bool inconsitent_E =
1554 ( abs((
p[last_94_mother][4]+
p[first_94_mother][4]) -
p[line94][4])/
p[line94][4] > 0.001 ) ;
1556 bool gluon_daughters = (
k[first_94_daughter][2] == 21 ||
k[last_94_daughter][2] == 21 ) ;
1558 if ( ( inconsitent_pid || inconsitent_E ) && ( ! gluon_daughters )) {
1559 int right_mother = 0 ;
1560 int sought_mother = 0 ;
1567 right_mother = first_94_mother;
1569 right_mother = last_94_mother;
1573 if ( inconsitent_pid ) {
1574 if (
k[first_94_daughter][2]*
k[last_94_daughter][2] > 0 ) {
1576 streamlog_out(ERROR) <<
" 94 DAUGHTERS wrong of 94 on line " << line94
1577 <<
" : both fermions or both anti-fermions " <<std::endl;
1580 }
else if (
k[first_94_mother][2]*
k[last_94_mother][2] > 0 ) {
1582 streamlog_out(DEBUG4) <<
" 94 MOTHERS wrong of 94 on line " << line94
1583 <<
" : both fermions or both anti-fermions " <<std::endl;
1591 streamlog_out(ERROR) <<
" 94 on line " << line94 <<
" is wrong : differnt PDGs, but both mothers and daughters are "
1592 <<
"fermions/anti-fermion pairs ??? " <<std::endl;
1600 if (
k[first_94_daughter][2] ==
k[right_mother][2] ) {
1601 sought_mother = last_94_daughter;
1603 sought_mother = first_94_daughter;
1607 double target[5]={0};
1608 for (
int jjj=1 ; jjj<=4 ; jjj++ ){target[jjj]=
p[line94][jjj]-
p[right_mother][jjj];}
1609 for (
int search_line = line94-1 ; search_line >= 1 ; search_line-- ) {
1610 if (
k[search_line][2] ==
k[sought_mother][2] ) {
1611 if ( abs(
p[search_line][1] - target[1])/ abs(target[1]) < 0.05 &&
1612 abs(
p[search_line][2] - target[2])/ abs(target[2]) < 0.05 &&
1613 abs(
p[search_line][3] - target[3])/ abs(target[3]) < 0.05 ) {
1614 new_mother=search_line;
1619 if ( new_mother != 0 ) { break ; }
1620 if ( ! first ) { break ; }
1625 if ( new_mother == 0 ) {
1626 streamlog_out(ERROR) <<
" 94 on line " << line94 <<
" is wrong, but could not figure out un what way. " ;
1628 if ( new_mother < right_mother ) {
1629 first_94_mother = new_mother ; last_94_mother = right_mother ;
1631 first_94_mother = right_mother ; last_94_mother = new_mother ;
1635 k[line94][3] = first_94_mother ;
k[line94][6] = last_94_mother ;
1636 k[first_94_mother][4] = line94 ;
k[first_94_mother][5] = line94 ;
1637 k[last_94_mother][4] = line94 ;
k[last_94_mother][5] = line94 ;
1643 int ihard_lepton_1[4011]={0} ;
1644 int ihard_lepton[4011]={0};
1657 for (
int k_py=
nlund ; k_py>= 1 ; k_py-- ) {
1658 if ( abs(
k[k_py][2]) == 6 ) {
1665 for (
int k_py= start_loop ; k_py<=
nlund ; k_py++ ) {
1666 if ( ( abs(
k[k_py][2]) >= 11 && abs(
k[k_py][2]) <= 16 ) ) {
1667 streamlog_out(DEBUG1) <<
" found lepton, k_py = " << k_py <<
", k[k_py][3] = "
1668 <<
k[k_py][3] <<
", k[3][3] = " <<
k[3][3] << std::endl ;
1670 (( !
_whiz1 ) && ((
k [
k[k_py][3]][1] == 21 ) || ( (abs(
k [
k[k_py][3]][2]) == 23 ||
1671 abs(
k [
k[k_py][3]][2]) == 24 ) &&
k[
k [
k[k_py][3]][3]][1] == 21 )) ) ||
1672 (
_whiz1 && ((
k[k_py][3] == 3 &&
k[3][3] > 0) || (
k[k_py][3] == -1) ||
1673 (
k[k_py][3] == 1 &&
k[k_py][4] ==
k[k_py][5] && abs(
k[
k[k_py][5]][2])==11 ))) ) {
1678 streamlog_out(DEBUG4) <<
" lepton on line " << k_py <<
" hard according to condition 1 " << std::endl;
1680 else if (abs(
k[
k[k_py][3]][2]) == 25 ||
1681 ((abs(
k[
k[k_py][3]][2]) == 24 || abs(
k[
k[k_py][3]][2]) == 23) &&
1682 abs(
k[
k[
k[k_py][3]][3]][2]) == 25)) {
1686 streamlog_out(DEBUG4) <<
" lepton on line " << k_py <<
" hard according to condition 2 " << std::endl;
1688 else if (
k[
k[
k[k_py][3]][3]][1] == 22 &&
k[k_py][1] < 20 ) {
1693 streamlog_out(DEBUG4) <<
" lepton on line " << k_py <<
" hard according to condition 3 " << std::endl;
1695 else if (
_top_event && ( abs(
k[
k[k_py][3]][2]) == 24) ) {
1696 int oma =
k[k_py][3] ;
1698 if ( oma < 3 ) break ;
1699 if ( abs(
k[
k[oma][3]][2]) == 24 ) {
1701 }
else if ( abs(
k[
k[oma][3]][2]) == 6 ) {
1705 streamlog_out(DEBUG4) <<
" lepton on line " << k_py <<
" hard according to condition 4 " << std::endl;
1727 if ( ihard_lepton[j_lept] == 0 ) {
1729 if ( ihard_lepton_1[l_lept] != 0 ) {
1730 ihard_lepton[j_lept]= ihard_lepton_1[l_lept];
1731 ihard_lepton_1[l_lept]= 0;
1736 int k_py = ihard_lepton[j_lept] ;
1739 int hint_companion = 0 ;
1740 int boson_companion = 0 ;
1741 int fallback_companion = 0;
1744 int l_py = ihard_lepton_1[l_lept] ;
1748 if ( (
k[l_py][2] > 0 &&
k[l_py][7] ==
k[k_py][8] &&
k[l_py][7] != 0 ) ||
1749 (
k[l_py][2] < 0 &&
k[l_py][8] ==
k[k_py][7] &&
k[l_py][8] != 0 ) ){
1750 streamlog_out(DEBUG4) <<
" hint match for lepton on lines " << l_py <<
" and " << k_py << std::endl;
1751 hint_companion = l_lept;
1754 if (
k[l_py][3] ==
k[k_py][3] ) {
1755 if (
k[
k[l_py][3]][2] == 23 ||
k[
k[l_py][3]][2] == 24 ||
k[
k[l_py][3]][2] == 25 ) {
1756 streamlog_out(DEBUG4) <<
" boson match for lepton on lines " << l_py <<
" and " << k_py << std::endl;
1757 boson_companion = l_lept;
1760 if (
k[l_py][7] == 0 &&
k[l_py][8]==0 &&
k[k_py][7] == 0 &&
k[k_py][8]==0 ) {
1762 fallback_companion = l_lept ;
1768 if ( n_hint == 1 ) {
1770 ihard_lepton[j_lept+1]= ihard_lepton_1[hint_companion] ;
1771 ihard_lepton_1[hint_companion]=0;
1773 }
else if (n_boson == 1 ) {
1775 ihard_lepton[j_lept+1]=ihard_lepton_1[boson_companion] ;
1776 ihard_lepton_1[boson_companion]=0;
1780 if ( n_hint > 1 || n_boson > 1 ) {
1781 streamlog_out(DEBUG4)<<
" Problem finding companion lepton to lepton on line " << k_py
1782 <<
" : n_boson = " << n_boson <<
" , n_hint = " << n_hint << std::endl;
1785 if (fallback_companion != 0 ) {
1788 ihard_lepton[j_lept+1]=ihard_lepton_1[fallback_companion];
1789 ihard_lepton_1[fallback_companion]=0;
1817 int beamrem=ihard_lepton[1];
1819 ihard_lepton[j_lept-1]=ihard_lepton[j_lept];
1826 lept = ihard_lepton[j_lept];
1827 streamlog_out(DEBUG4) <<
" assigning leptons to jets: ihard_lepton[" << j_lept <<
"] = " << ihard_lepton[j_lept]
1832 lept = ihard_lepton[j_lept];
1833 streamlog_out(DEBUG4) <<
" assigning leptons to jets: ihard_lepton[" << j_lept <<
"] = " << ihard_lepton[j_lept]
1834 <<
" and has PDG " <<
k[lept][2] <<
" jet : " <<
current_jet+j_lept<< std::endl ;
1847 if ( oma < 3 ) break ;
1848 if ( abs(
k[
k[oma][3]][2]) == 24 ) {
1850 }
else if ( abs(
k[
k[oma][3]][2]) == 6 ) {
1851 fafp_top =
k[oma][3];
1862 while (
k[lept][2] != 94 &&
k[lept][1] != 1 &&
k[lept][4] ==
k[lept][5] ) {
1866 streamlog_out(DEBUG2)<<
" after looping to stable : " << lept <<
" " <<
k[lept][2] << std::endl;
1870 bool is_elementon = true ;
1871 if (
k[lept][1] != 1 && (
k[lept][4] ==
k[lept][5] &&
k[lept][4] != 0 )) {
1873 if (
k[ida][2] ==
k[lept][2] ) {
1874 is_elementon =
false;
1878 if ( is_elementon ) {
1895 for (
int k_py=1; k_py<=
nlund ; k_py++ ) {
1899 if (
k[k_py][1] == 1 ) {
1900 jet[k_py] = abs(
jet[
k[k_py][3]]);
1901 if (
k[k_py][2] == 22 &&
k[
k[k_py][3] ][2] ==
k[
elementon[
jet[k_py]]][2] ) {
1916 int clu=0 , jet1=0, jet2=0;
1919 for (
int k_py=1; k_py<=
nlund ; k_py++ ) {
1920 streamlog_out(DEBUG0) <<
" Checking cluster at " << k_py <<
" k[k_py][2], and k[k_py][1] : " <<
1921 " " <<
k[k_py][2] <<
" , " <<
k[k_py][1] << std::endl;
1922 if (
k[k_py][2] == 91 &&
k[k_py][1] < 30 ) {
1923 streamlog_out(DEBUG4) <<
" cluster found at " << k_py <<std::endl;
1928 if (
nclu == 0 )
return;
1930 for (
int i_clu=1 ; i_clu<=
nclu ; i_clu++ ) {
1944 elementon[jet2]=elementon[jet1];
1945 while (
k[elementon[jet2]+1][4] == clu ) {
1946 elementon[jet2]=elementon[jet2]+1;
1948 streamlog_out(DEBUG4) <<
" Assigning jets " << jet1 <<
" or " << jet2
1949 <<
" to CLUSTER at " << clu << std::endl;
1959 int phots[4011]={0};
1962 for (
int k_py=1; k_py<=
nlund ; k_py++ ) {
1963 streamlog_out(DEBUG0) <<
" Checking photon at " << k_py <<
" k[k_py][2], and k[k_py][1] : " <<
1964 " " <<
k[k_py][2] <<
" , " <<
k[k_py][1] << std::endl;
1965 if (
k[k_py][2] == 22 &&
k[k_py][1] < 30 ) {
1966 if ( ( !
_whiz1 ) && (
k [
k[k_py][3]][1] == 21 ) ) {
1969 streamlog_out(DEBUG4) <<
" photon on line " << k_py <<
" hard according to condition 1 " << std::endl;
1971 else if (abs(
k[
k[k_py][3]][2]) == 25 ) {
1974 streamlog_out(DEBUG4) <<
" photon on line " << k_py <<
" hard according to condition 2 " << std::endl;
1979 if (
nphot == 0 )
return;
1981 for (
int i_phot=1 ; i_phot<=
nphot ; i_phot++ ) {
1988 if (
k[ phots[i_phot]][1] == 1 ) {
1994 for (
int k_py=1; k_py<=
nlund ; k_py++ ) {
1999 jet[k_py] = abs(
jet[
k[k_py][3]]);
2012 for (
int k_py=1; k_py<=
nlund ; k_py++ ) {
2013 if ( (( !
_whiz1 ) && ( (
k[k_py][3] == 3 ||
k[k_py][3] == 4 ) && (
k[k_py][2]==22 ) && (
k[k_py][1] < 20 ) )) ||
2014 ((
_whiz1 ) && ( (
k[k_py][3] == 1 ||
k[k_py][3] == 3 ||
k[k_py][3] == 0 ) && (
k[k_py][2]==22 ) &&
2015 (
k[k_py][4]==
k[k_py][5]) && (
k[
k[k_py][4]][2] ==22) && (
k[
k[k_py][4]][1] != 0) ) )){
2024 for (
int j_isr=1 ; j_isr<=
nisr ; j_isr++ ) {
2027 if (
k[ iisr[j_isr]][1] == 1 ) {
2034 for (
int k_py=1; k_py<=
nlund ; k_py++ ) {
2039 jet[k_py] = abs(
jet[
k[k_py][3]]);
2048 int n_left=0, sstr=0,lquark=0,lstr=0, istr=0,str_nb=0,jet1=0,jet2=0,istr_previous=0,iback=0;
2049 int str_index[4011]={0}, rev_index[4011]={0};
2053 for (
int k_py=1 ; k_py<=
nlund ; k_py++ ) {
2055 if (
jet[k_py] != 0 ) {
2061 for (
int j_jet=
njet-2*
nstr ; j_jet>=1 ; j_jet-- ) {
2082 for (
int k_py=1 ; k_py<=
nlund ; k_py++ ) {
2083 streamlog_out(DEBUG0) <<
" particle " << k_py <<
" with PDG " <<
k[k_py][2]
2084 <<
" is assigned to jet " <<
jet[k_py] << std::endl;
2086 if (
jet[k_py]==0 &&
k[k_py][2] != 91 &&
k[k_py][2] != 94 &&
k[k_py][2] != 21 &&
k[k_py][2] != 23 &&
2087 k[k_py][2] != 24 &&
k[k_py][2] != 25 &&
k[k_py][1] < 30 ){
2091 str_index[n_left]=k_py;
2092 rev_index[k_py]=n_left;
2093 if ( sstr == 0 &&
k[k_py][2] == 92 ) {
2103 lquark=str_index[sstr-1];
2105 if (
k[
k[lquark][4]][2] != 92 ) {
2108 while ( lll >=
k[str_index[sstr]][3] ) {
2109 if (
k[lll][4] == str_index[sstr] ) {
2115 if ( lll >
k[str_index[sstr]][3] ) {
2119 streamlog_out(ERROR) <<
" INFO: Non-contigous string ancestors (1)" << std::endl;
2120 streamlog_out(ERROR) <<
" Event: " <<
evt->getEventNumber() <<
", run: " <<
evt->getRunNumber() << std::endl ;
2121 streamlog_out(ERROR) << std::endl ;
2129 lstr=
k[lquark][4] ; istr=lstr ; str_nb =
nstr ;
2130 streamlog_out(DEBUG3) <<
" sstr, lstr, lquark, current_jet, str_nb " << sstr <<
" " << lstr <<
" "
2131 << lquark <<
" " <<
current_jet <<
" " << str_nb << std::endl;
2139 while( istr >= str_index[sstr]) {
2141 streamlog_out(DEBUG1) <<
" calculating jet1/2 from current_jet = " <<
current_jet <<
", str_nb = " << str_nb << std::endl;
2142 streamlog_out(DEBUG1) <<
" istr = " << istr <<
", k[istr][3] = " <<
k[istr][3] <<
", lquark = " << lquark << std::endl;
2146 elementon[jet1]=
k[istr][3] ; elementon[jet2]=lquark ;
2149 streamlog_out(DEBUG4) <<
" Assigning jets " << jet1 <<
" or " << jet2 <<
" to STRING at " << istr << std::endl;
2153 streamlog_out(DEBUG4) <<
" Assigned jets " << std::endl;
2160 istr_previous=istr ;
2161 iback=str_index[rev_index[istr]-1] ; istr =
k[iback][3] ;
2162 if ( istr < str_index[sstr] ) break ;
2167 int lquark_start = str_index[rev_index[
k[istr_previous][3]]-1] ;
2168 lquark=str_index[rev_index[k[istr_previous][3]]-1] ;
2170 if ( k[lquark][4] != istr && lquark > 0 ) {
2177 streamlog_out(DEBUG3) <<
" Non-contigous string ancestors (2) " << std:: endl;
2178 while ( lquark>-1 && k[lquark][4] != istr ) {
2182 if ( lquark <= 0 ) {
2183 lquark = lquark_start ;
2184 while ( lquark<
nlund && ( k[lquark][4] != istr || lquark == k[istr][3] )) {
2187 if ( lquark >=
nlund ) {
2188 streamlog_out(ERROR) <<
" ERROR: Quack ?! " << std::endl ;
2189 streamlog_out(ERROR) <<
" Event: " <<
evt->getEventNumber() <<
", run: " <<
evt->getRunNumber() << std::endl ;
2190 streamlog_out(ERROR) << std::endl ;
2204 double dir_diff[4]={0};
2205 int first_p1=0, first_p2=0;
2206 streamlog_out(DEBUG4) <<
" assign_jet: elementon[" << jet1 <<
"] = " <<
elementon[jet1]
2207 <<
", elementon[" << jet2 <<
"] = " <<
elementon[jet2] << std::endl;
2217 streamlog_out(DEBUG4) <<
" back in assign_jets for jet " << jet1 <<
" fafp_last = " <<
fafp_last[jet1]
2218 <<
" nfsr = " <<
nfsr[jet1]<<
" boson = " <<
boson[jet1]
2219 <<
" fafp_boson = " <<
fafp_boson[jet1] << std::endl;
2222 streamlog_out(DEBUG4) <<
" back in assign_jets for jet " << jet2 <<
" fafp_last = " <<
fafp_last[jet2]
2223 <<
" nfsr = " <<
nfsr[jet2]<<
" boson = " <<
boson[jet2]
2224 <<
" fafp_boson = " <<
fafp_boson[jet2] << std::endl;
2235 for (
int kk=1; kk<=3 ; kk++ ) {
2237 absp_2+=
p[elementon[jet2]][kk]*
p[elementon[jet2]][kk] ;
2240 absp_1=sqrt(absp_1);
2241 absp_2=sqrt(absp_2);
2242 for (
int kk=1; kk<=3 ; kk++ ) {
2247 for (
int k_py_had=
k[this_string][4]; k_py_had<=
k[this_string][5] ; k_py_had++ ) {
2248 if (
k[k_py_had][3] == this_string ) {
2250 for (
int jj=1 ; jj<=3 ; jj++ ) {
2251 dot+=dir_diff[jj]*
p[k_py_had][jj] ;
2255 jet[k_py_had] = jet1 ;
2257 jet[k_py_had] = jet2 ;
2266 if (
jet[k_py] == 0 &&
k[k_py][1] < 30 ) {
2268 jet[k_py] = abs(
jet[
k[k_py][3]]);
2269 if (
k[k_py][2] == 21 || abs(
k[k_py][2])<=6 ) {
2273 if (
jet[k_py] != 0 ) streamlog_out(DEBUG1) <<
" Particle " << k_py
2274 <<
" assigned to jet " << abs(
jet[
k[k_py][3]]) << std::endl;
2280 void TrueJet::first_parton(
int this_partic,
int this_jet,
int& first_partic,
int& last_94_parent,
int& nfsr_here,
int& info,
int& info2)
2282 int this_quark=0,quark_pdg=0,boson_ancestor=0,istat=0,boson_last_94_parent=0,istat2=0;
2284 this_quark=this_partic;
2285 jet[this_quark]=-this_jet;
2286 quark_pdg=
k[this_quark][2];
2288 streamlog_out(DEBUG4) <<
" first_parton: this_quark = " << this_quark
2289 <<
", quark_pdg = " << quark_pdg << std::endl;
2300 while (
k[this_quark][3] > 0 &&
2301 abs(
k[
k[this_quark][3]][2]) != 11 && abs(
k[
k[this_quark][3]][2]) != 21 && abs(
k[
k[this_quark][3]][2]) != 22
2302 && abs(
k[
k[this_quark][3]][2]) != 23 && abs(
k[
k[this_quark][3]][2]) != 24 && abs(
k[
k[this_quark][3]][2]) != 25 ) {
2305 streamlog_out(DEBUG3) <<
" start of while loop: this_quark = " << this_quark
2306 <<
", its PDG = " <<
k[this_quark][2]
2307 <<
", its parent = " <<
k[this_quark][3]
2308 <<
", parent's PDG = " << abs(
k[
k[this_quark][3]][2])
2309 <<
", quark_pdg = " << quark_pdg << std::endl;
2313 this_quark=
k[this_quark][3];
2314 if ( quark_pdg == 21 || abs(quark_pdg) == 24 ) {
2320 quark_pdg=
k[this_quark][2];
2327 if ( this_jet != 0 ) {
jet[this_quark]=-this_jet;}
2332 if (
k[this_quark+1][2] == 22 &&
k[this_quark+1][3] ==
k[this_quark][3] ) {
2334 streamlog_out(DEBUG5) <<
" FSR from " << this_quark << std::endl;
2335 if ( this_jet != 0 ) {
2340 jet[this_quark+1]=this_jet;
2341 nfsr_here=nfsr_here+1;
2345 streamlog_out(DEBUG3) <<
" end of while loop: this_quark = " << this_quark
2346 <<
", its PDG = " <<
k[this_quark][2]
2347 <<
", its parent = " <<
k[this_quark][3]
2348 <<
", parent's PDG = " << abs(
k[
k[this_quark][3]][2])
2349 <<
", quark_pdg = " << quark_pdg << std::endl;
2358 int resonance_insertion = 0;
2359 streamlog_out(DEBUG3) <<
" resonance_insertion check : " << abs(
k[
k[this_quark][3]][2]) << std::endl;
2360 if ( abs(
k[
k[this_quark][3]][2]) == 23 || abs(
k[
k[this_quark][3]][2]) == 24 ) {
2361 int lanc =
k[
k[this_quark][3]][3];
2362 streamlog_out(DEBUG1) <<
" lanc = " << lanc <<
" " << k[lanc][2] <<
" " << k[lanc][1] << std::endl ;
2363 if ( ( ( abs(k[lanc][2]) == 11 || abs(k[lanc][2]) == 22 ) && k[lanc][1] == 21 ) ||
2364 ( abs(k[lanc][2]) == 25 ) ){
2365 resonance_insertion = 1;
2369 streamlog_out(DEBUG3) <<
" resonance_insertion = " << resonance_insertion << std::endl;
2375 if ( resonance_insertion == 0 && ( abs(
k[
k[this_quark][3]][2]) == 21 || abs(
k[
k[this_quark][3]][2]) == 24 )) {
2381 streamlog_out(DEBUG3) <<
" in while loop calling first_parton with: k[this_quark][3] = " <<
k[this_quark][3] << std::endl;
2382 first_parton(
k[this_quark][3],0 ,boson_ancestor, boson_last_94_parent, nfsr_here, istat,istat2);
2392 info= boson_ancestor;
2393 info2= boson_last_94_parent;
2415 if ( last_94_parent == 0 ) {last_94_parent=this_quark;}
2417 first_partic = this_quark;
2418 streamlog_out(DEBUG4) <<
" first_parton, return: = first_partic " << first_partic
2419 <<
", last_94_parent = " << last_94_parent << std::endl;
2430 if ( abs(k2)>16)
return 0 ;
2431 if ( abs(k2) > 10 ) {
2436 return k2 > 0 ? k2l/2 : k2l/2 ;
2442 for (
int k_jet=1 ; k_jet<=
njet ; k_jet++ ) {
2444 for (
int i=0 ; i<3 ; i++ ) {
2448 for (
int i_py=1 ; i_py<=
nlund ; i_py++){
2449 if (
jet[i_py]>0 ) {
2450 if (
k[i_py][1] == 11 ) {
2452 for (
int jj=
k[i_py][4] ; jj <=
k[i_py][5] ; jj++ ) {
2455 if ( abs(Ekid-
p[i_py][4])/
p[i_py][4] > 0.001 ) {
2456 streamlog_out(DEBUG3) <<
" Particle " << i_py <<
" has energy " <<
p[i_py][4] <<
2457 " , but the sum of its genstat1 kids is " << Ekid << std::endl;
2458 streamlog_out(DEBUG3) <<
" indicating that Geant did something fishy and un-documented in MCParticle "
2460 streamlog_out(DEBUG3) <<
" (Counter-meassures taken, so it should be OK.) " << std::endl ;
2461 streamlog_out(DEBUG3) <<
" Event: " <<
evt->getEventNumber() <<
", run: " <<
evt->getRunNumber() << std::endl;
2462 streamlog_out(DEBUG3) << std::endl ;
2463 const double* v =
mcp_pyjets[
k[i_py][4]]->getVertex();
2464 if ( v[0]*v[0] + v[1]*v[1] > 10. ) {
2465 if (
k[i_py][1] < 30 ) {
2468 for (
int j_dau=
k[i_py][4] ; j_dau <=
k[i_py][5] ; j_dau++ ) {
2470 if (
k[j_dau][1] < 30 ) {
2477 }
else if (
k[i_py][1] == 0 ) {
2478 for (
unsigned i_dau=0 ; i_dau <
mcp_pyjets[i_py]->getDaughters().size() ; i_dau++ ) {
2480 if (
k[j_dau][1] < 30 ) {
2488 for (
int i_py=1 ; i_py<=
nlund ; i_py++){
2489 ijet=abs(
jet[i_py]);
2491 if (
k[i_py][1]%30 == 1 ) {
2503 tmom[ijet][0]+=
p[i_py][1] ;
2504 tmom[ijet][1]+=
p[i_py][2] ;
2505 tmom[ijet][2]+=
p[i_py][3] ;
2506 tE[ijet]+=
p[i_py][4] ;
2514 for (
int k_jet=1 ; k_jet <=
njet ; k_jet++ ) {
2515 if ( k_jet <= 2*
nstr ){
2517 }
else if ( k_jet<= 2*
nstr+2*
nclu ){
2525 }
else if ( k_jet<=
njet ){
2528 if (
boson[k_jet] != 0 ) {
2539 if ( k_jet%2 == 0 ) {
2556 for (
int k_jet=1 ; k_jet<=
njet ; k_jet++ ) {
2560 for (
int k_jet=1 ; k_jet<=
njet ; k_jet++ ) {
2561 if (
type[k_jet] == 4 ||
type[k_jet] == 6 ) {
2565 if (
type[k_jet]%100 <= 3 ) {
2567 bool k_lept=(abs(
k[
fafp[k_jet]][2])>=11 && abs(
k[
fafp[k_jet]][2])<=16);
2569 streamlog_out(DEBUG4) << std::endl;
2571 for (
int j_jet=1 ; j_jet<=
njet ; j_jet++ ) {
2572 if (
type[j_jet]%100 <= 3 ) {
2574 bool j_lept=(abs(
k[
fafp[j_jet]][2])>=11 && abs(
k[
fafp[j_jet]][2])<=16);
2578 bool colour_connected = ((
k[
fafp[j_jet]][2]<0 &&
k[
fafp[k_jet]][2]>0 &&
2579 k[
fafp[j_jet]][8] ==
k[fafp[k_jet]][7] &&
k[fafp[j_jet]][8] != 0 ) ||
2580 (
k[fafp[j_jet]][2]>0 &&
k[fafp[k_jet]][2]<0 &&
2581 k[fafp[j_jet]][7] ==
k[fafp[k_jet]][8] &&
k[fafp[j_jet]][7] != 0 ));
2582 bool no_colour = (
k[fafp[j_jet]][7]+
k[fafp[j_jet]][8]+
k[fafp[k_jet]][7]+
k[fafp[k_jet]][8] == 0 );
2584 bool boson_connected = (
k[fafp[j_jet]][3]==
k[fafp[k_jet]][3] &&
2585 ( abs(
k[
k[fafp[k_jet]][3]][2]) == 6 ||
2586 k[
k[fafp[k_jet]][3]][2] == 23 ||
2587 abs(
k[
k[fafp[k_jet]][3]][2]) == 24 ||
2588 k[
k[fafp[k_jet]][3]][2] == 25 ));
2589 bool same_parent = (
k[fafp[j_jet]][3]==
k[fafp[k_jet]][3] &&
k[fafp[k_jet]][3] != 0 );
2590 bool same_family = (
flavour(
k[fafp[k_jet]][2]) ==
flavour(
k[fafp[j_jet]][2])) ;
2597 if (( fafp[j_jet] == fafp[k_jet] ) ||
2600 (no_colour && (same_parent && same_family)) ||
2601 (
companion[k_jet] == j_jet && abs(
k[fafp[k_jet]][2]) != 6) ) {
2606 if ( k_jet != j_jet ) {
2607 streamlog_out(DEBUG4) <<
" Jet " << k_jet <<
" was grouped with jet " << j_jet <<
" .";
2608 streamlog_out(DEBUG4) <<
" fafp of the jets are " << fafp[k_jet] <<
" (pdg " <<
k[fafp[k_jet]][2]
2609 <<
") and " << fafp[j_jet] <<
" (pdg " <<
k[fafp[j_jet]][2] <<
" ) ." ;
2610 if (
k[fafp[k_jet]][3] != 0 ) {
2611 streamlog_out(DEBUG4) <<
" parents of the fafp of the jets are " <<
k[fafp[k_jet]][3]<<
" and " <<
k[fafp[j_jet]][3] <<
" .";
2613 streamlog_out(DEBUG4) <<
" colour-connection : " << colour_connected<< std::endl;
2619 streamlog_out(DEBUG4) <<
" group of jet " << k_jet <<
" : " ;
2620 bool compthere=
false;
2621 for (
int i_grp=1 ; i_grp <=
group[0][k_jet] ; i_grp++ ) {
2622 streamlog_out(DEBUG4) <<
group[i_grp][k_jet] <<
" " ;
2626 streamlog_out(ERROR) <<
" jet " << k_jet <<
" : companion " <<
companion[k_jet] <<
" not in group " << std::endl;
2628 streamlog_out(DEBUG4) << std::endl;
2630 streamlog_out(ERROR) <<
" jet " << k_jet <<
" ungrouped " << std::endl;
2652 for (
int k_jet=1; k_jet<=
njet ; k_jet++ ) {
2656 if (
group[0][k_jet] > 0 ) {
2657 for (
int i_djb=1; i_djb<=
n_djb ; i_djb++ ) {
2659 for (
int i_grpmbr=1 ; i_grpmbr<=
group[0][k_jet] ; i_grpmbr++ ) {
2673 for (
int i_grpmbr=0 ; i_grpmbr<=
group[0][k_jet] ; i_grpmbr++ ){
2679 for (
int i_dje=1 ; i_dje<=
n_dje ; i_dje++ ) {
2705 for (
int k_jet=1 ; k_jet<=
njet ; k_jet++ ) {
2706 if (
type[k_jet]/100 != 0 ){
2709 if (
tE[k_jet]<0.000001 ) {
2712 if (
jet[k_jet]==0 &&
k[k_jet][1]==1 ) {
2715 if ( (
type[k_jet]%100== 3) && (
tE[k_jet]> 0.0000001 ) &&
2722 for (
int k_jet=1 ; k_jet<=
njet-1 ; k_jet+=2 ) {
2723 if ((
type[k_jet]%100==1) &&
2724 (
k[
fafp[k_jet]][4] !=
k[
fafp[k_jet+1]][4]) &&
2725 ( !( (
k[
fafp[k_jet]][2] > 0 &&
k[
fafp[k_jet]][7] ==
k[
fafp[k_jet+1]][8]) ||
2726 (
k[
fafp[k_jet]][2] < 0 &&
k[
fafp[k_jet]][8] ==
k[
fafp[k_jet+1]][7] )) ) &&
2727 (
k[
fafp[k_jet]][3] !=
k[
fafp[k_jet+1]][3]) ) {
2729 int ii =
fafp[k_jet];
2730 while ( ii <=
nlund ) {
std::string _recoParticleCollectionName
std::string _finalColourNeutralCollectionName
Example processor for marlin.
virtual void init()
Called at the begin of the job before anything is read.
virtual void end()
Called after data processing for clean up.
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
std::string _trueJetPFOLink
std::string _finalColourNeutralLink
std::string _finalElementonLink
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
LCRelationNavigator * reltrue
virtual void check(LCEvent *evt)
std::string _recoMCTruthLink
void stdhep_reader_bug_workaround(int line94)
std::string _initialColourNeutralLink
std::string _initialElementonLink
std::string _trueJetCollectionName
ouput collection names.
std::string _trueJetMCParticleLink
void getPyjets(LCCollection *mcpcol)
std::vector< LCCollection * > LCCollectionVec
std::string _initialColourNeutralCollectionName
std::string _MCParticleColllectionName
Input collection name.
void first_parton(int this_partic, int this_jet, int &first_partic, int &last_94_parent, int &nfsr, int &info, int &info2)
void assign_jet(int jet1, int jet2, int this_fafp)