| 1516 |
rt->SetBranchAddress("RunTrailer", &runt); |
rt->SetBranchAddress("RunTrailer", &runt); |
| 1517 |
rt->SetBranchAddress("Header", &eht); |
rt->SetBranchAddress("Header", &eht); |
| 1518 |
// |
// |
| 1519 |
|
TTree *T = (TTree*)file->Get("Physics"); |
| 1520 |
|
if ( !T || T->IsZombie() ) throw -16; |
| 1521 |
|
EventHeader *eh = 0; |
| 1522 |
|
T->SetBranchAddress("Header", &eh); |
| 1523 |
|
// |
| 1524 |
|
if ( !(rh->GetEntries()) && !(rt->GetEntries()) && !(T->GetEntries()) ) return(16); |
| 1525 |
|
// |
| 1526 |
UInt_t obtt = 0; |
UInt_t obtt = 0; |
| 1527 |
UInt_t obth = 0; |
UInt_t obth = 0; |
| 1528 |
UInt_t pktt = 0; |
UInt_t pktt = 0; |
| 1597 |
// |
// |
| 1598 |
if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){ |
if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){ |
| 1599 |
// |
// |
| 1600 |
if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER \n"); |
if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER evbefh = %u \n",evbefh); |
| 1601 |
// |
// |
| 1602 |
if ( mishead && mistrail && evbefh == 1 ){ |
if ( evbefh == 0 ) { |
| 1603 |
// |
// |
| 1604 |
signal = 8; |
signal = 8; |
| 1605 |
if ( IsDebug() ) printf(" Not supported yet: run with no events, no runtrailer, no runheader \n"); |
if ( IsDebug() ) printf(" Not supported yet: run with no events, no runtrailer, no runheader \n"); |
| 1717 |
// ( runhead_time <= _our_runhead_time && runtrail_time >= _our_runtrail_time) && |
// ( runhead_time <= _our_runhead_time && runtrail_time >= _our_runtrail_time) && |
| 1718 |
// ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) && |
// ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) && |
| 1719 |
// ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) ) |
// ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) ) |
| 1720 |
|
// || |
| 1721 |
|
// ( runhead_time = _our_runhead_time && runtrail_time = _our_runtrail_time && nevents > 100 ) |
| 1722 |
|
// ) |
| 1723 |
|
// || |
| 1724 |
|
// ( runhead_time = _our_runhead_time && runtrail_time > _our_runtrail_time && nevents > 100 ) |
| 1725 |
|
// ) |
| 1726 |
|
// || |
| 1727 |
|
// ( runhead_time < _our_runhead_time && runtrail_time = _our_runtrail_time && nevents > 100 ) |
| 1728 |
// ) |
// ) |
| 1729 |
// |
// |
| 1730 |
oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE " |
oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE " |
| 1740 |
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 1741 |
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 1742 |
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 1743 |
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") OR " |
| 1744 |
|
<< " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " // these two lines in a certain way disable the patch below... |
| 1745 |
|
<< " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100) OR" // |
| 1746 |
|
<< " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " // |
| 1747 |
|
<< " RUNTRAILER_TIME>" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100) OR" // |
| 1748 |
|
<< " (RUNHEADER_TIME<" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " // |
| 1749 |
|
<< " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100)" // |
| 1750 |
|
<< " ));"; |
| 1751 |
// |
// |
| 1752 |
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
| 1753 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1769 |
// |
// |
| 1770 |
// the run has already been inserted |
// the run has already been inserted |
| 1771 |
// |
// |
| 1772 |
// return(true); //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here |
if ( signal && IsDebug() ) printf(" The run has already been inserted \n"); |
| 1773 |
|
return(true); //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here |
| 1774 |
// |
// |
| 1775 |
// PATCH! |
// PATCH! |
| 1776 |
// we keep the processing run if (in order of growing importance) 1) we have the runtrailer while the old run doesn't have it 2) we have the runheader |
// we keep the processing run if (in order of growing importance) 1) we have the runtrailer while the old run doesn't have it 2) we have the runheader |
| 4694 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 4695 |
TSQLResult *result2 = 0; |
TSQLResult *result2 = 0; |
| 4696 |
TSQLRow *row2 = 0; |
TSQLRow *row2 = 0; |
| 4697 |
|
TSQLResult *result3 = 0; |
| 4698 |
|
TSQLRow *row3 = 0; |
| 4699 |
oss.str(""); |
oss.str(""); |
| 4700 |
oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN order by RUNHEADER_TIME asc;"; |
oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME,NEVENTS FROM GL_RUN order by RUNHEADER_TIME asc;"; |
| 4701 |
// oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;"; |
// oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;"; |
| 4702 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 4703 |
// |
// |
| 4711 |
thisrht = (UInt_t)atoll(row->GetField(2)); |
thisrht = (UInt_t)atoll(row->GetField(2)); |
| 4712 |
thisrtt = (UInt_t)atoll(row->GetField(3)); |
thisrtt = (UInt_t)atoll(row->GetField(3)); |
| 4713 |
// |
// |
| 4714 |
|
if ( (UInt_t)atoll(row->GetField(4)) > 1 ){ |
| 4715 |
|
// |
| 4716 |
|
// |
| 4717 |
|
// |
| 4718 |
|
oss.str(""); |
| 4719 |
|
oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!=" |
| 4720 |
|
<< thisid << " AND RUNHEADER_TIME=" |
| 4721 |
|
<< thisrht << " AND RUNTRAILER_TIME!=" |
| 4722 |
|
<< thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;"; |
| 4723 |
|
result3 = conn->Query(oss.str().c_str()); |
| 4724 |
|
if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str()); |
| 4725 |
|
if ( result3 ){ |
| 4726 |
|
row3 = result3->Next(); |
| 4727 |
|
// |
| 4728 |
|
while ( row3 ){ |
| 4729 |
|
// |
| 4730 |
|
// 2 runs with same runheader |
| 4731 |
|
// |
| 4732 |
|
printf(" CHECK n.4 RUNs %u and %u HAVE SAME RUNHEADER \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
| 4733 |
|
row3 = result3->Next(); |
| 4734 |
|
}; |
| 4735 |
|
}; |
| 4736 |
|
// |
| 4737 |
|
oss.str(""); |
| 4738 |
|
oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!=" |
| 4739 |
|
<< thisid << " AND RUNHEADER_TIME!=" |
| 4740 |
|
<< thisrht << " AND RUNTRAILER_TIME=" |
| 4741 |
|
<< thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;"; |
| 4742 |
|
result3 = conn->Query(oss.str().c_str()); |
| 4743 |
|
if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str()); |
| 4744 |
|
if ( result3 ){ |
| 4745 |
|
row3 = result3->Next(); |
| 4746 |
|
// |
| 4747 |
|
while ( row3 ){ |
| 4748 |
|
// |
| 4749 |
|
// 2 runs with same runtrailer |
| 4750 |
|
// |
| 4751 |
|
printf(" CHECK n.5 RUNs %u and %u HAVE SAME RUNTRAILER \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
| 4752 |
|
row3 = result3->Next(); |
| 4753 |
|
}; |
| 4754 |
|
}; |
| 4755 |
|
// |
| 4756 |
|
oss.str(""); |
| 4757 |
|
oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!=" |
| 4758 |
|
<< thisid << " AND RUNHEADER_TIME>" |
| 4759 |
|
<< thisrht << " AND RUNTRAILER_TIME<" |
| 4760 |
|
<< thisrtt << " order by RUNHEADER_TIME asc;"; |
| 4761 |
|
result3 = conn->Query(oss.str().c_str()); |
| 4762 |
|
if ( result3 ){ |
| 4763 |
|
row3 = result3->Next(); |
| 4764 |
|
// |
| 4765 |
|
while ( row3 ){ |
| 4766 |
|
// |
| 4767 |
|
// run contained in the checked one |
| 4768 |
|
// |
| 4769 |
|
printf(" CHECK n.6 RUN %u CONTAINS RUN %u \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
| 4770 |
|
row3 = result3->Next(); |
| 4771 |
|
}; |
| 4772 |
|
}; |
| 4773 |
|
// |
| 4774 |
|
oss.str(""); |
| 4775 |
|
oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!=" |
| 4776 |
|
<< thisid << " AND RUNHEADER_TIME=" |
| 4777 |
|
<< thisrht << " AND RUNTRAILER_TIME=" |
| 4778 |
|
<< thisrtt << " AND ID_RUN_FRAG!=" |
| 4779 |
|
<< thisid << " order by RUNHEADER_TIME asc;"; |
| 4780 |
|
result3 = conn->Query(oss.str().c_str()); |
| 4781 |
|
if ( result3 ){ |
| 4782 |
|
row3 = result3->Next(); |
| 4783 |
|
// |
| 4784 |
|
while ( row3 ){ |
| 4785 |
|
// |
| 4786 |
|
// duplicated run |
| 4787 |
|
// |
| 4788 |
|
printf(" CHECK n.7 RUNs %u and %u HAVE SAME RUNTRAILER AND RUNHEADER (ARE THE SAME?) \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
| 4789 |
|
row3 = result3->Next(); |
| 4790 |
|
}; |
| 4791 |
|
}; |
| 4792 |
|
}; |
| 4793 |
|
// |
| 4794 |
// if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){ |
// if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){ |
| 4795 |
// if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){ |
// if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){ |
| 4796 |
if ( (thisrht < prevrtt) && (thisrht != prevrht) ){ |
if ( (thisrht < prevrtt) && (thisrht != prevrht) ){ |
| 4797 |
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
| 4798 |
printf(" CHECK n.1 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrht-prevrtt),previd,thisid); |
printf(" CHECK n.1 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-prevrtt),previd,thisid); |
| 4799 |
TString prevf = ""; |
TString prevf = ""; |
| 4800 |
TString thisf = ""; |
TString thisf = ""; |
| 4801 |
oss.str(""); |
oss.str(""); |
| 4816 |
// |
// |
| 4817 |
if ( (thisrtt < prevrht) && (thisrht != prevrht) ){ |
if ( (thisrtt < prevrht) && (thisrht != prevrht) ){ |
| 4818 |
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
| 4819 |
printf(" CHECK n.2 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrtt-prevrht),previd,thisid); |
printf(" CHECK n.2 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrtt-prevrht),previd,thisid); |
| 4820 |
TString prevf = ""; |
TString prevf = ""; |
| 4821 |
TString thisf = ""; |
TString thisf = ""; |
| 4822 |
oss.str(""); |
oss.str(""); |
| 4823 |
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; |
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; |
| 4824 |
result2 = conn->Query(oss.str().c_str()); |
result2 = conn->Query(oss.str().c_str()); |
| 4825 |
if ( !result2 ) throw -4;; |
if ( !result2 ) throw -4; |
| 4826 |
row2 = result2->Next(); |
row2 = result2->Next(); |
| 4827 |
prevf = (TString)row2->GetField(0); |
prevf = (TString)row2->GetField(0); |
| 4828 |
oss.str(""); |
oss.str(""); |
| 4837 |
// |
// |
| 4838 |
if ( (thisrht > thisrtt) && (thisrht != prevrht) ){ |
if ( (thisrht > thisrtt) && (thisrht != prevrht) ){ |
| 4839 |
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
| 4840 |
printf(" CHECK n.3 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrht-thisrtt),previd,thisid); |
printf(" CHECK n.3 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-thisrtt),previd,thisid); |
| 4841 |
TString prevf = ""; |
TString prevf = ""; |
| 4842 |
TString thisf = ""; |
TString thisf = ""; |
| 4843 |
oss.str(""); |
oss.str(""); |