474 |
runlastentry = 0LL; |
runlastentry = 0LL; |
475 |
gltsync = 0; // Emiliano |
gltsync = 0; // Emiliano |
476 |
fUpdateRunInfo = true; // Emiliano |
fUpdateRunInfo = true; // Emiliano |
477 |
|
fUseDBinRunInfo = true; // Emiliano |
478 |
isSync = false; // by default assume that the level2 file(s) is(are) not sinchronized between L0/DB and L2, that is we miss some packets in L2 due to nested/DV-skipped events |
isSync = false; // by default assume that the level2 file(s) is(are) not sinchronized between L0/DB and L2, that is we miss some packets in L2 due to nested/DV-skipped events |
479 |
il0entry = 0LL; |
il0entry = 0LL; |
480 |
// hasL0EE = true; |
// hasL0EE = true; |
2821 |
run_tree->GetEntry(irun); |
run_tree->GetEntry(irun); |
2822 |
if (!GetOrbitalInfo()) |
if (!GetOrbitalInfo()) |
2823 |
cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated " << endl; |
cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated " << endl; |
2824 |
if (gltsync) |
if ( fUseDBinRunInfo ){ |
2825 |
delete gltsync; //Emiliano |
if (gltsync) |
2826 |
if (!dbc || (dbc && !dbc->IsConnected())) |
delete gltsync; //Emiliano |
2827 |
SetDBConnection(); //Emiliano |
if (!dbc || (dbc && !dbc->IsConnected())) |
2828 |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here) |
SetDBConnection(); //Emiliano |
2829 |
if (dbc){ |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here) |
2830 |
dbc->Close();// Emiliano |
if (dbc){ |
2831 |
delete dbc; |
dbc->Close();// Emiliano |
2832 |
dbc=0; |
delete dbc; |
2833 |
}; |
dbc=0; |
2834 |
}; |
} |
2835 |
|
} |
2836 |
|
} |
2837 |
// --------------------------------------------------------------- |
// --------------------------------------------------------------- |
2838 |
// retrieve OBT and absolute time of the event |
// retrieve OBT and absolute time of the event |
2839 |
// --------------------------------------------------------------- |
// --------------------------------------------------------------- |
2842 |
prevpktnum = pktnum; |
prevpktnum = pktnum; |
2843 |
if (GetOrbitalInfo()) { |
if (GetOrbitalInfo()) { |
2844 |
abstime = GetOrbitalInfo()->absTime; |
abstime = GetOrbitalInfo()->absTime; |
2845 |
obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano |
if ( fUseDBinRunInfo ) obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano |
2846 |
pktnum = GetOrbitalInfo()->pkt_num; // Emiliano |
pktnum = GetOrbitalInfo()->pkt_num; // Emiliano |
2847 |
} |
} |
2848 |
else { |
else { |
2849 |
abstime = GetRunInfo()->RUNHEADER_TIME; |
abstime = GetRunInfo()->RUNHEADER_TIME; |
2850 |
obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano |
if ( fUseDBinRunInfo ) obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano |
2851 |
pktnum = GetRunInfo()->RUNHEADER_PKT; // Emiliano |
pktnum = GetRunInfo()->RUNHEADER_PKT; // Emiliano |
2852 |
} |
} |
2853 |
|
|
2855 |
printf("0abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
printf("0abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
2856 |
printf("0 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
printf("0 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
2857 |
printf("0 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
printf("0 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
2858 |
printf("0 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
if ( fUseDBinRunInfo ) printf("0 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
2859 |
printf("0 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
printf("0 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
2860 |
printf("0 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
printf("0 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
2861 |
} |
} |
2878 |
} |
} |
2879 |
|
|
2880 |
// |
// |
2881 |
|
bool a = true; |
2882 |
|
bool b = true; |
2883 |
|
if ( fUseDBinRunInfo ){ |
2884 |
|
a = false; |
2885 |
|
b = false; |
2886 |
|
if ( obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) a = true; |
2887 |
|
if ( obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) b = true; |
2888 |
|
} |
2889 |
if ( iev < totrunentrymin || iev > totrunentrymax // entry is outside run limits |
if ( iev < totrunentrymin || iev > totrunentrymax // entry is outside run limits |
2890 |
|| iev == 0 // or it is the first entry |
|| iev == 0 // or it is the first entry |
2891 |
|| (!isSync && ( |
|| (!isSync && ( |
2892 |
(abstime <= GetRunInfo()->RUNHEADER_TIME && obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) // or it is outside obt limits (and abstime limits for security reasons) |
(abstime <= GetRunInfo()->RUNHEADER_TIME && a ) // or it is outside obt limits (and abstime limits for security reasons) |
2893 |
|| (abstime >= GetRunInfo()->RUNTRAILER_TIME && obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) ))// or it is outside obt limits (and abstime limits for security reasons) |
|| (abstime >= GetRunInfo()->RUNTRAILER_TIME && b ) ))// or it is outside obt limits (and abstime limits for security reasons) |
2894 |
){ // check on abstime and obt needed to handle nested+DV_skipped packets |
){ // check on abstime and obt needed to handle nested+DV_skipped packets |
2895 |
|
|
2896 |
// check for a new run (ma prima il primo!) |
// check for a new run (ma prima il primo!) |
2898 |
printf("1abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
printf("1abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
2899 |
printf("1 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
printf("1 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
2900 |
printf("1 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
printf("1 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
2901 |
printf("1 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
if ( fUseDBinRunInfo ) printf("1 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
2902 |
printf("1 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
printf("1 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
2903 |
printf("1 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
printf("1 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
2904 |
} |
} |
2925 |
totrunentry += GetRunInfo()->NEVENTS; |
totrunentry += GetRunInfo()->NEVENTS; |
2926 |
totrunentrymax = totrunentry - 1 - prevshift; // prevshift is needed to handle nested+DV_skipped packets |
totrunentrymax = totrunentry - 1 - prevshift; // prevshift is needed to handle nested+DV_skipped packets |
2927 |
irun = r; |
irun = r; |
2928 |
|
if ( fUseDBinRunInfo ){ |
2929 |
|
a = false; |
2930 |
|
b = false; |
2931 |
|
if ( obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) a = true; |
2932 |
|
if ( obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) b = true; |
2933 |
|
} |
2934 |
if ( (iev >= totrunentrymin && iev <= totrunentrymax) || // entry is inside run limits |
if ( (iev >= totrunentrymin && iev <= totrunentrymax) || // entry is inside run limits |
2935 |
( !isSync && |
( !isSync && |
2936 |
( abstime >= GetRunInfo()->RUNHEADER_TIME && obt >= gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) // or it is inside obt limits (and abstime limits for security reasons) |
( abstime >= GetRunInfo()->RUNHEADER_TIME && a // or it is inside obt limits (and abstime limits for security reasons) |
2937 |
&& abstime <= GetRunInfo()->RUNTRAILER_TIME && obt <= gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT))) // or it is inside obt limits (and abstime limits for security reasons) |
&& abstime <= GetRunInfo()->RUNTRAILER_TIME && b)) // or it is inside obt limits (and abstime limits for security reasons) |
2938 |
){ // check on abstime and obt needed to handle nested+DV_skipped packets |
){ // check on abstime and obt needed to handle nested+DV_skipped packets |
2939 |
if ( totrunentrymin > iev ){ // there is a shift (nested+DV_skipped packets) |
if ( totrunentrymin > iev ){ // there is a shift (nested+DV_skipped packets) |
2940 |
if ( !isSync ){ |
if ( !isSync ){ |
2959 |
|
|
2960 |
|
|
2961 |
// |
// |
2962 |
if (gltsync) |
if ( fUseDBinRunInfo ){ |
2963 |
delete gltsync; // Emiliano |
if (gltsync) |
2964 |
if (!dbc || (dbc && !dbc->IsConnected())) |
delete gltsync; // Emiliano |
2965 |
SetDBConnection(); //Emiliano |
if (!dbc || (dbc && !dbc->IsConnected())) |
2966 |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano |
SetDBConnection(); //Emiliano |
2967 |
TrkParams::Set(GetRunInfo(), dbc); |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano |
2968 |
if (dbc){ |
TrkParams::Set(GetRunInfo(), dbc); |
2969 |
dbc->Close(); // Emiliano |
if (dbc){ |
2970 |
delete dbc; |
dbc->Close(); // Emiliano |
2971 |
dbc=0; |
delete dbc; |
2972 |
} |
dbc=0; |
2973 |
if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano |
} |
2974 |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun |
if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano |
2975 |
<< " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun |
2976 |
cout |
<< " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; |
2977 |
<< " (NB!! in this case some events could be assigned to a wrong run)" |
cout |
2978 |
<< endl; |
<< " (NB!! in this case some events could be assigned to a wrong run)" |
2979 |
|
<< endl; |
2980 |
|
} |
2981 |
} |
} |
2982 |
// |
// |
2983 |
if (DBG) printf(" found \n"); |
if (DBG) printf(" found \n"); |
3034 |
printf("2abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
printf("2abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
3035 |
printf("2 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
printf("2 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
3036 |
printf("2 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
printf("2 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
3037 |
printf("2 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
if ( fUseDBinRunInfo ) printf("2 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
3038 |
printf("2 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
printf("2 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
3039 |
printf("2 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
printf("2 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
3040 |
} |
} |
3125 |
// update the tracker parameters |
// update the tracker parameters |
3126 |
// (non ho trovato nessun altro modo sicuro di farlo...) |
// (non ho trovato nessun altro modo sicuro di farlo...) |
3127 |
// ---------------------------------------------------- |
// ---------------------------------------------------- |
3128 |
if (!dbc || (dbc && !dbc->IsConnected())) |
if ( fUseDBinRunInfo ){ |
3129 |
SetDBConnection(); |
if (!dbc || (dbc && !dbc->IsConnected())) |
3130 |
TrkParams::Set(GetRunInfo(), dbc); |
SetDBConnection(); |
3131 |
if (dbc){ |
TrkParams::Set(GetRunInfo(), dbc); |
3132 |
dbc->Close(); |
if (dbc){ |
3133 |
delete dbc; |
dbc->Close(); |
3134 |
dbc=0; |
delete dbc; |
3135 |
}; |
dbc=0; |
3136 |
|
} |
3137 |
|
} |
3138 |
// cout << endl; |
// cout << endl; |
3139 |
prevshift = 0; |
prevshift = 0; |
3140 |
yprevshift = 0; |
yprevshift = 0; |