554 |
use_CAL && |
use_CAL && |
555 |
calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view |
calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view |
556 |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
557 |
|
cp && ci && |
558 |
true){ |
true){ |
559 |
|
|
560 |
|
|
576 |
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; |
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; |
577 |
return; |
return; |
578 |
}; |
}; |
579 |
if( use_TOF ){ |
if( use_TOF && op && oi ){ |
580 |
|
|
581 |
Int_t nphit_p =0; |
Int_t nphit_p =0; |
582 |
Int_t nphit_i =0; |
Int_t nphit_i =0; |
1520 |
if(SELLI==0){ |
if(SELLI==0){ |
1521 |
if ( irun < 0 ){ |
if ( irun < 0 ){ |
1522 |
irun = 0; |
irun = 0; |
1523 |
run->GetEntry(0); |
run->GetEntry(irun); |
1524 |
runfirstentry = 0ULL; |
runfirstentry = 0ULL; |
1525 |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL; |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL; |
1526 |
}; |
return(true); |
1527 |
while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
}; |
1528 |
|
|
1529 |
|
if( !GetOrbitalInfo() ){ |
1530 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1531 |
|
return(false); |
1532 |
|
} |
1533 |
|
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
1534 |
|
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
1535 |
|
while ( GetOrbitalInfo()->absTime > GetRunInfo()->RUNTRAILER_TIME && irun < run->GetEntries() ){ |
1536 |
|
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
1537 |
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
1538 |
irun++; |
irun++; |
1539 |
run->GetEntry(irun); |
run->GetEntry(irun); |
1540 |
runfirstentry = runlastentry+1ULL; |
runfirstentry = runlastentry+1ULL; |
1541 |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
1542 |
}; |
}; |
1543 |
|
|
1544 |
// |
// |
1545 |
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
if |
1546 |
|
( irun == oldrun || irun >= run->GetEntries() ) return(false); |
1547 |
// |
// |
1548 |
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
1549 |
// |
// |
2220 |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
2221 |
pam_tree_clone[i]->BranchRef(); |
pam_tree_clone[i]->BranchRef(); |
2222 |
cout << "Tracker : branch TrkLevel1"<<endl; |
cout << "Tracker : branch TrkLevel1"<<endl; |
2223 |
|
cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
2224 |
}; |
}; |
2225 |
if(TRK2) { |
if(TRK2) { |
2226 |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
2302 |
void PamLevel2::FillCloneTrees(){ |
void PamLevel2::FillCloneTrees(){ |
2303 |
|
|
2304 |
// cout << "PamLevel2::FillCloneTrees()" << irunentry << endl; |
// cout << "PamLevel2::FillCloneTrees()" << irunentry << endl; |
2305 |
|
|
2306 |
for(Int_t i=0; i<NCLONES; i++){ |
for(Int_t i=0; i<NCLONES; i++){ |
2307 |
if(pam_tree_clone[i])pam_tree_clone[i]->Fill(); |
if(pam_tree_clone[i])pam_tree_clone[i]->Fill(); |
2308 |
} |
} |
2309 |
if(sel_tree_clone)sel_tree_clone->Fill(); |
if(sel_tree_clone)sel_tree_clone->Fill(); |
2310 |
// if( irunentry == 0 || run_tree_clone->GetEntries()==0 )run_tree_clone->Fill(); |
|
|
Int_t nstoredruns = run_tree_clone->GetEntries(); |
|
|
if( irun == nstoredruns )run_tree_clone->Fill(); |
|
|
else if( irun > nstoredruns || irun < nstoredruns-1){ |
|
|
cout << " PamLevel2::FillCloneTrees() -- ERROR -- current run "<< irun <<" stored runs "<< nstoredruns <<endl; |
|
|
} |
|
2311 |
} |
} |
2312 |
|
|
2313 |
|
|
2348 |
} |
} |
2349 |
|
|
2350 |
/** |
/** |
2351 |
* Method to get both level2-trees entry and corresponding run entry. |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
2352 |
*/ |
*/ |
|
|
|
|
|
|
2353 |
Int_t PamLevel2::GetEntry(Int_t iee){ |
Int_t PamLevel2::GetEntry(Int_t iee){ |
2354 |
|
|
2355 |
if(!pam_tree){ |
if(!pam_tree){ |
2367 |
if( !pam_tree->GetEntry(ii) ) return 0; |
if( !pam_tree->GetEntry(ii) ) return 0; |
2368 |
//------------------------------- |
//------------------------------- |
2369 |
ii = iee; |
ii = iee; |
2370 |
UpdateRunInfo(run_tree,ii); |
Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
2371 |
if(SELLI==0)irunentry = iee-runfirstentry; |
if(SELLI==0)irunentry = iee-runfirstentry; |
2372 |
|
if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
2373 |
|
|
2374 |
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
2375 |
|
|
2400 |
return NULL; |
return NULL; |
2401 |
} |
} |
2402 |
Int_t irootnew = run_obj->ID_ROOT_L0; |
Int_t irootnew = run_obj->ID_ROOT_L0; |
2403 |
// cout << "iroot "<<iroot<<endl; |
// cout << "iroot "<<iroot<<endl; |
2404 |
// cout << "irootnew "<<irootnew<<endl; |
// cout << "irootnew "<<irootnew<<endl; |
2405 |
|
|
2406 |
//=================================== |
//=================================== |
2407 |
// load the level0 file |
// load the level0 file |
2428 |
// cout<<"DB already connected"<<endl; |
// cout<<"DB already connected"<<endl; |
2429 |
} |
} |
2430 |
GL_ROOT glroot = GL_ROOT(); |
GL_ROOT glroot = GL_ROOT(); |
2431 |
if( glroot.Query_GL_ROOT(iroot,dbc) )return NULL; |
if( glroot.Query_GL_ROOT(iroot,dbc) ){ |
2432 |
|
cout << "TTree* PamLevel2::GetYodaTree( ) -- ERROR -- level0 file iroot = "<<iroot<< " does not exists"<<endl; |
2433 |
|
return NULL; |
2434 |
|
}; |
2435 |
TString filename = glroot.PATH + glroot.NAME; |
TString filename = glroot.PATH + glroot.NAME; |
2436 |
if(l0_file){ |
if(l0_file){ |
2437 |
l0_file->Close(); |
l0_file->Close(); |
2456 |
trk0_obj->Set(); |
trk0_obj->Set(); |
2457 |
}; |
}; |
2458 |
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
|
TrkParams::SetCalib(run_obj,dbc); |
|
2459 |
} |
} |
2460 |
//--------------------------------------------------- |
//--------------------------------------------------- |
2461 |
// CALORIMETER: |
// CALORIMETER: |
2470 |
|
|
2471 |
}; |
}; |
2472 |
|
|
2473 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
2474 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
2475 |
|
} |
2476 |
|
|
2477 |
|
TrkParams::SetCalib(run_obj,dbc); |
2478 |
|
|
2479 |
|
|
2480 |
|
// cout << l0_tree << endl; |
2481 |
|
|
2482 |
return l0_tree; |
return l0_tree; |
2483 |
|
|
2484 |
} |
} |
2495 |
// if file is NOT a preselected file |
// if file is NOT a preselected file |
2496 |
// --------------------------------- |
// --------------------------------- |
2497 |
Int_t quellagiusta = irunentry + run_obj->EV_FROM; |
Int_t quellagiusta = irunentry + run_obj->EV_FROM; |
2498 |
// ------------------------------------------ |
|
2499 |
// otherwise read the "preselected-list" tree |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
2500 |
// ------------------------------------------ |
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
2501 |
|
// cout << " time "<< GetOrbitalInfo()->absTime << endl; |
2502 |
|
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
2503 |
|
|
2504 |
|
if( !GetOrbitalInfo() ){ |
2505 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
2506 |
|
return 0; |
2507 |
|
} |
2508 |
|
|
2509 |
|
// --------------------------------------------------------------------- |
2510 |
|
// ATTENTION!!! |
2511 |
|
// If data are not pre-processed with cleaner, the level0 tree may contain |
2512 |
|
// spurious nested physics packets. |
2513 |
|
// The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries |
2514 |
|
// while level2 tree DOES NOT!! |
2515 |
|
// This means that "quellagiusta" in these cases is not correct. |
2516 |
|
// In order to retrieve the correct level0 event, I implemented a check |
2517 |
|
// of the OBT and pkt-number. In case of mismatch, the level0 entry number |
2518 |
|
// is shift forward until when the packets match. |
2519 |
|
// --------------------------------------------------------------------- |
2520 |
|
Int_t answer = 0; |
2521 |
|
Int_t shift =0; |
2522 |
|
do{ |
2523 |
|
if(shift>0){ |
2524 |
|
cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" )"<<endl; |
2525 |
|
} |
2526 |
|
answer = l0_tree->GetEntry(quellagiusta+shift); |
2527 |
|
shift++; |
2528 |
|
if( !GetEventHeader() ){ |
2529 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
2530 |
|
return 0; |
2531 |
|
} |
2532 |
|
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
2533 |
|
// cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; |
2534 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
2535 |
|
// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; |
2536 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
2537 |
|
|
2538 |
|
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+shift) < GetYodaTree()->GetEntries() ); |
2539 |
|
|
2540 |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
2541 |
return GetYodaTree()->GetEntry(quellagiusta); |
// return GetYodaTree()->GetEntry(quellagiusta); |
2542 |
|
|
2543 |
return 1; |
return answer; |
2544 |
|
|
2545 |
} |
} |