1273 |
stringstream oss; |
stringstream oss; |
1274 |
// |
// |
1275 |
oss.str(""); |
oss.str(""); |
1276 |
oss << "lock table GL_RUN write, GL_ROOT write, GL_RAW write, GL_TIMESYNC write, GL_RESURS_OFFSET write, GL_PARAM write, GL_TLE write, GL_RUN_FRAGMENTS write, GL_RUN_TRASH write, GL_CALO_CALIB write, GL_CALOPULSE_CALIB write, GL_TRK_CALIB write, GL_S4_CALIB write, ROOT_TABLE_MERGING write, ROOT_TABLE write, _RUNID_GEN write;"; |
oss << "lock table GL_RUN write, GL_ROOT write, GL_RAW write, GL_TIMESYNC write, GL_RESURS_OFFSET write, GL_PARAM write, GL_TLE write, GL_RUN_FRAGMENTS write, GL_RUN_TRASH write, GL_CALO_CALIB write, GL_CALOPULSE_CALIB write, GL_TRK_CALIB write, GL_S4_CALIB write, ROOT_TABLE_MERGING write, ROOT_TABLE_BAD write, ROOT_TABLE write, _RUNID_GEN write;"; |
1277 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
1278 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1279 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1464 |
// PUBLIC FUNCTIONS |
// PUBLIC FUNCTIONS |
1465 |
// |
// |
1466 |
|
|
1467 |
|
// /** |
1468 |
|
// * Insert a new row into GL_RAW table. |
1469 |
|
// */ |
1470 |
|
// Int_t PamelaDBOperations::insertPamelaRawFile(){ |
1471 |
|
// // |
1472 |
|
// stringstream oss; |
1473 |
|
// // |
1474 |
|
// Bool_t idr = this->SetID_RAW(); |
1475 |
|
// if ( idr ) return(1); |
1476 |
|
// // |
1477 |
|
// oss.str(""); |
1478 |
|
// if ( STATIC ){ |
1479 |
|
// oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
1480 |
|
// << this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
1481 |
|
// } else { |
1482 |
|
// oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
1483 |
|
// }; |
1484 |
|
// if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
1485 |
|
// // |
1486 |
|
// idr = this->SetID_RAW(); |
1487 |
|
// if ( !idr ) throw -11; |
1488 |
|
// // |
1489 |
|
// return(0); |
1490 |
|
// } |
1491 |
/** |
/** |
1492 |
* Insert a new row into GL_RAW table. |
* Insert a new row into GL_RAW table. |
1493 |
*/ |
*/ |
1494 |
Int_t PamelaDBOperations::insertPamelaRawFile(){ |
Int_t PamelaDBOperations::insertPamelaRawFile(){ |
1495 |
|
|
1496 |
|
// |
1497 |
|
Bool_t idr = this->SetID_RAW(); |
1498 |
|
if ( idr ) return(1); |
1499 |
|
|
1500 |
|
GL_RAW glraw = GL_RAW(); |
1501 |
|
|
1502 |
|
glraw.PATH = GetRawPath(); |
1503 |
|
glraw.NAME = GetRawFile(); |
1504 |
|
glraw.BOOT_NUMBER = 0;//??? |
1505 |
|
|
1506 |
|
if( insertPamelaRawFile(&glraw) )return(1); |
1507 |
|
// |
1508 |
|
idr = this->SetID_RAW(); |
1509 |
|
if ( !idr ) throw -11; |
1510 |
|
|
1511 |
|
return(0); |
1512 |
|
} |
1513 |
|
/** |
1514 |
|
* Insert a new row into GL_RAW table. |
1515 |
|
*/ |
1516 |
|
Int_t PamelaDBOperations::insertPamelaRawFile(GL_RAW *glraw){ |
1517 |
// |
// |
1518 |
stringstream oss; |
if(!glraw)return(1);//?? |
1519 |
// |
// |
1520 |
Bool_t idr = this->SetID_RAW(); |
stringstream oss; |
1521 |
if ( idr ) return(1); |
// |
1522 |
// |
oss.str(""); |
1523 |
oss.str(""); |
if ( STATIC ){ |
1524 |
if ( STATIC ){ |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
1525 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
<< glraw->PATH << "', '" << glraw->NAME << "')"; |
1526 |
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
} else { |
1527 |
} else { |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << glraw->NAME << "')"; |
1528 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
}; |
1529 |
}; |
if ( debug ) cout <<oss.str().c_str() <<endl; |
1530 |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
1531 |
// |
// |
1532 |
idr = this->SetID_RAW(); |
oss.str(""); |
1533 |
if ( !idr ) throw -11; |
oss << "SELECT ID FROM GL_RAW WHERE NAME=\""<<glraw->NAME<<"\";"; |
1534 |
// |
if ( debug ) cout << oss.str().c_str()<<endl; |
1535 |
return(0); |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
1536 |
|
// |
1537 |
|
TSQLResult *result = 0; |
1538 |
|
TSQLRow *row = 0; |
1539 |
|
result = conn->Query(oss.str().c_str()); |
1540 |
|
if ( result == NULL ) throw -4; |
1541 |
|
row = result->Next(); |
1542 |
|
if ( !row ) return(1); |
1543 |
|
glraw->ID = (UInt_t)atoll(row->GetField(0)); |
1544 |
|
if ( debug ) printf(" The ID of the RAW file is %u \n",glraw->ID); |
1545 |
|
delete result; |
1546 |
|
delete row; |
1547 |
|
// |
1548 |
|
return(0); |
1549 |
} |
} |
1550 |
|
|
1551 |
|
|
1852 |
return(signal); |
return(signal); |
1853 |
} |
} |
1854 |
|
|
1855 |
|
// /** |
1856 |
|
// * Insert all the new rows into GL_ROOT. |
1857 |
|
// * The raw file indicates in the parameters should be already been stored in the database. |
1858 |
|
// */ |
1859 |
|
// Int_t PamelaDBOperations::insertPamelaRootFile(){ |
1860 |
|
// stringstream oss; |
1861 |
|
// TSQLResult *result = 0; |
1862 |
|
// TSQLRow *row = 0; |
1863 |
|
// UInt_t idtimesync = 0; |
1864 |
|
// // |
1865 |
|
// // |
1866 |
|
// if ( chewbacca ){ |
1867 |
|
// oss.str(""); |
1868 |
|
// oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
1869 |
|
// if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
1870 |
|
// result = conn->Query(oss.str().c_str()); |
1871 |
|
// // |
1872 |
|
// if ( !result ) throw -3; |
1873 |
|
// // |
1874 |
|
// row = result->Next(); |
1875 |
|
// // |
1876 |
|
// if ( !row ) throw -3; |
1877 |
|
// idtimesync = (UInt_t)atoll(row->GetField(0)); |
1878 |
|
// } else { |
1879 |
|
// oss.str(""); |
1880 |
|
// if ( STATIC ){ |
1881 |
|
// oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1882 |
|
// << " LEFT JOIN GL_ROOT " |
1883 |
|
// << " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1884 |
|
// << " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
1885 |
|
// << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1886 |
|
// } else { |
1887 |
|
// oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1888 |
|
// << " LEFT JOIN GL_ROOT " |
1889 |
|
// << " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1890 |
|
// << " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
1891 |
|
// << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1892 |
|
// }; |
1893 |
|
// result = conn->Query(oss.str().c_str()); |
1894 |
|
// // |
1895 |
|
// if ( !result ) throw -12; |
1896 |
|
// // |
1897 |
|
// row = result->Next(); |
1898 |
|
// // |
1899 |
|
// if ( !row ) throw -10; |
1900 |
|
// if ( row != NULL && (UInt_t)atoll(row->GetField(0))>0 ){ |
1901 |
|
// idroot = (UInt_t)atoll(row->GetField(2)); |
1902 |
|
// return(1); |
1903 |
|
// }; |
1904 |
|
// // |
1905 |
|
// // determine which timesync has to be used |
1906 |
|
// // |
1907 |
|
// oss.str(""); |
1908 |
|
// oss << "SELECT GL_TIMESYNC.ID FROM GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW ORDER BY GL_TIMESYNC.ID DESC LIMIT 1;"; |
1909 |
|
// result = conn->Query(oss.str().c_str()); |
1910 |
|
// // |
1911 |
|
// if ( !result ) throw -3; |
1912 |
|
// // |
1913 |
|
// row = result->Next(); |
1914 |
|
// // |
1915 |
|
// if ( !row ) throw -3; |
1916 |
|
// idtimesync = (UInt_t)atoll(row->GetField(0)); |
1917 |
|
// }; |
1918 |
|
// // |
1919 |
|
// oss.str(""); |
1920 |
|
// if ( STATIC ){ |
1921 |
|
// oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
1922 |
|
// << this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
1923 |
|
// } else { |
1924 |
|
// oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
1925 |
|
// << this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
1926 |
|
// }; |
1927 |
|
// // |
1928 |
|
// if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
1929 |
|
// if (conn->Query(oss.str().c_str()) == 0) throw -4; |
1930 |
|
// // |
1931 |
|
// delete result; |
1932 |
|
// // |
1933 |
|
// oss.str(""); |
1934 |
|
// // oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
1935 |
|
// if ( STATIC ){ |
1936 |
|
// oss << "SELECT ID FROM GL_ROOT WHERE PATH='" << this->GetRootPath().Data() << "' and NAME='"<< this->GetRootFile().Data() <<"';"; |
1937 |
|
// } else { |
1938 |
|
// oss << "SELECT ID FROM GL_ROOT WHERE PATH='$PAM_L0' and NAME='"<< this->GetRootFile().Data() <<"';"; |
1939 |
|
// }; |
1940 |
|
// // |
1941 |
|
// if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
1942 |
|
// result = conn->Query(oss.str().c_str()); |
1943 |
|
// if ( !result ) throw -12; |
1944 |
|
// row = result->Next(); |
1945 |
|
// if ( !row ) throw -3; |
1946 |
|
// this->SetID_ROOT((UInt_t)atoll(row->GetField(0))); |
1947 |
|
// if ( debug ) printf(" The ID of the ROOT file is %u \n",this->GetID_ROOT()); |
1948 |
|
// // |
1949 |
|
// delete result; |
1950 |
|
// // |
1951 |
|
// return(0); |
1952 |
|
// } |
1953 |
/** |
/** |
1954 |
* Insert all the new rows into GL_ROOT. |
* Insert all the new rows into GL_ROOT. |
1955 |
* The raw file indicates in the parameters should be already been stored in the database. |
* The raw file indicates in the parameters should be already been stored in the database. |
1956 |
*/ |
*/ |
1957 |
Int_t PamelaDBOperations::insertPamelaRootFile(){ |
Int_t PamelaDBOperations::insertPamelaRootFile(){ |
1958 |
|
|
1959 |
|
stringstream oss; |
1960 |
|
TSQLResult *result = 0; |
1961 |
|
TSQLRow *row = 0; |
1962 |
|
// |
1963 |
|
// ---------------------- |
1964 |
|
// determine the timesync |
1965 |
|
// ---------------------- |
1966 |
|
UInt_t idtimesync = 0; |
1967 |
|
// |
1968 |
|
if ( chewbacca ){ |
1969 |
|
oss.str(""); |
1970 |
|
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
1971 |
|
if ( debug ) printf(" %s \n",oss.str().c_str()); |
1972 |
|
result = conn->Query(oss.str().c_str()); |
1973 |
|
// |
1974 |
|
if ( !result ) throw -3; |
1975 |
|
// |
1976 |
|
row = result->Next(); |
1977 |
|
// |
1978 |
|
if ( !row ) throw -3; |
1979 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
1980 |
|
} else { |
1981 |
|
oss.str(""); |
1982 |
|
if ( STATIC ){ |
1983 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1984 |
|
<< " LEFT JOIN GL_ROOT " |
1985 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1986 |
|
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
1987 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1988 |
|
} else { |
1989 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1990 |
|
<< " LEFT JOIN GL_ROOT " |
1991 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1992 |
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
1993 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1994 |
|
}; |
1995 |
|
result = conn->Query(oss.str().c_str()); |
1996 |
|
// |
1997 |
|
if ( !result ) throw -12; |
1998 |
|
// |
1999 |
|
row = result->Next(); |
2000 |
|
// |
2001 |
|
if ( !row ) throw -10; |
2002 |
|
if ( row != NULL && (UInt_t)atoll(row->GetField(0))>0 ){ |
2003 |
|
idroot = (UInt_t)atoll(row->GetField(2)); |
2004 |
|
delete row; |
2005 |
|
delete result; |
2006 |
|
return(1); |
2007 |
|
}; |
2008 |
|
// |
2009 |
|
// determine which timesync has to be used |
2010 |
|
// |
2011 |
|
oss.str(""); |
2012 |
|
oss << "SELECT GL_TIMESYNC.ID FROM GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW ORDER BY GL_TIMESYNC.ID DESC LIMIT 1;"; |
2013 |
|
result = conn->Query(oss.str().c_str()); |
2014 |
|
// |
2015 |
|
if ( !result ) throw -3; |
2016 |
|
// |
2017 |
|
row = result->Next(); |
2018 |
|
// |
2019 |
|
if ( !row ) throw -3; |
2020 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
2021 |
|
}; |
2022 |
|
|
2023 |
|
delete row; |
2024 |
|
delete result; |
2025 |
|
|
2026 |
|
// ---------------------- |
2027 |
|
// insert root file |
2028 |
|
// ---------------------- |
2029 |
|
|
2030 |
|
GL_ROOT glroot = GL_ROOT(); |
2031 |
|
|
2032 |
|
glroot.ID_RAW = GetID_RAW(); |
2033 |
|
glroot.ID_TIMESYNC = idtimesync; |
2034 |
|
glroot.PATH = GetRootPath(); |
2035 |
|
glroot.NAME = GetRootFile(); |
2036 |
|
|
2037 |
|
if ( insertPamelaRootFile(&glroot) )return 1; |
2038 |
|
|
2039 |
|
SetID_ROOT(glroot.ID); |
2040 |
|
|
2041 |
|
|
2042 |
|
return (0); |
2043 |
|
} |
2044 |
|
/** |
2045 |
|
* Insert all the new rows into GL_ROOT. |
2046 |
|
* The raw file indicates in the parameters should be already been stored in the database. |
2047 |
|
*/ |
2048 |
|
Int_t PamelaDBOperations::insertPamelaRootFile(GL_ROOT *glroot){ |
2049 |
|
|
2050 |
|
|
2051 |
|
|
2052 |
stringstream oss; |
stringstream oss; |
2053 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
2054 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
|
UInt_t idtimesync = 0; |
|
|
// |
|
2055 |
// |
// |
|
if ( chewbacca ){ |
|
|
oss.str(""); |
|
|
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
|
|
if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -3; |
|
|
// |
|
|
row = result->Next(); |
|
|
// |
|
|
if ( !row ) throw -3; |
|
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
|
|
} else { |
|
|
oss.str(""); |
|
|
if ( STATIC ){ |
|
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
|
|
<< " LEFT JOIN GL_ROOT " |
|
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
|
|
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
|
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
|
|
} else { |
|
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
|
|
<< " LEFT JOIN GL_ROOT " |
|
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
|
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
|
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
|
|
}; |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -12; |
|
|
// |
|
|
row = result->Next(); |
|
|
// |
|
|
if ( !row ) throw -10; |
|
|
if ( row != NULL && (UInt_t)atoll(row->GetField(0))>0 ){ |
|
|
idroot = (UInt_t)atoll(row->GetField(2)); |
|
|
return(1); |
|
|
}; |
|
|
// |
|
|
// determine which timesync has to be used |
|
|
// |
|
|
oss.str(""); |
|
|
oss << "SELECT GL_TIMESYNC.ID FROM GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW ORDER BY GL_TIMESYNC.ID DESC LIMIT 1;"; |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -3; |
|
|
// |
|
|
row = result->Next(); |
|
|
// |
|
|
if ( !row ) throw -3; |
|
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
|
|
}; |
|
2056 |
// |
// |
2057 |
oss.str(""); |
oss.str(""); |
2058 |
if ( STATIC ){ |
if ( STATIC ){ |
2059 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
2060 |
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
<< glroot->ID_RAW << "', '" << glroot->ID_TIMESYNC << "', '" << glroot->PATH << "', '" << glroot->NAME << "')"; |
2061 |
} else { |
} else { |
2062 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
2063 |
<< this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
<< glroot->ID_RAW << "', '" << glroot->ID_TIMESYNC << "', '$PAM_L0', '" << glroot->NAME << "')"; |
2064 |
}; |
}; |
2065 |
// |
// |
2066 |
if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
if ( debug ) printf("%s \n",oss.str().c_str()); |
2067 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
2068 |
// |
// |
2069 |
delete result; |
delete result; |
2071 |
oss.str(""); |
oss.str(""); |
2072 |
// oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
// oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
2073 |
if ( STATIC ){ |
if ( STATIC ){ |
2074 |
oss << "SELECT ID FROM GL_ROOT WHERE PATH='" << this->GetRootPath().Data() << "' and NAME='"<< this->GetRootFile().Data() <<"';"; |
oss << "SELECT ID FROM GL_ROOT WHERE PATH='" << glroot->PATH << "' and NAME='"<< glroot->NAME <<"';"; |
2075 |
} else { |
} else { |
2076 |
oss << "SELECT ID FROM GL_ROOT WHERE PATH='$PAM_L0' and NAME='"<< this->GetRootFile().Data() <<"';"; |
oss << "SELECT ID FROM GL_ROOT WHERE PATH='$PAM_L0' and NAME='"<< glroot->NAME <<"';"; |
2077 |
}; |
}; |
2078 |
// |
// |
2079 |
if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
if ( debug ) printf("%s \n",oss.str().c_str()); |
2080 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
2081 |
if ( !result ) throw -12; |
if ( !result ) throw -12; |
2082 |
row = result->Next(); |
row = result->Next(); |
2083 |
if ( !row ) throw -3; |
if ( !row ) throw -3; |
2084 |
this->SetID_ROOT((UInt_t)atoll(row->GetField(0))); |
|
2085 |
if ( debug ) printf(" The ID of the ROOT file is %u \n",this->GetID_ROOT()); |
glroot->ID = (UInt_t)atoll(row->GetField(0)); |
2086 |
|
|
2087 |
|
if ( debug ) printf(" The ID of the ROOT file is %u \n",glroot->ID); |
2088 |
// |
// |
2089 |
delete result; |
delete result; |
2090 |
// |
// |
4641 |
return(0); |
return(0); |
4642 |
}; |
}; |
4643 |
|
|
4644 |
|
// /** |
4645 |
|
// * Fill the GL_TRK_CALIB table |
4646 |
|
// */ |
4647 |
|
// void PamelaDBOperations::HandleTRK_CALIB(Bool_t pk1, Bool_t pk2){ |
4648 |
|
// // |
4649 |
|
// TSQLResult *result = 0; |
4650 |
|
// TSQLRow *row = 0; |
4651 |
|
// // |
4652 |
|
// stringstream oss; |
4653 |
|
// oss.str(""); |
4654 |
|
// // |
4655 |
|
// UInt_t totime = 0; |
4656 |
|
// // |
4657 |
|
// if ( !pk1 && !pk2 ){ |
4658 |
|
// if ( IsDebug() ) printf(" Cannot handle trk calibration with both packet missing!\n"); |
4659 |
|
// return; |
4660 |
|
// }; |
4661 |
|
// // |
4662 |
|
// // check if the calibration has already been inserted |
4663 |
|
// // |
4664 |
|
// oss.str(""); |
4665 |
|
// oss << " SELECT ID FROM GL_TRK_CALIB WHERE " |
4666 |
|
// << " BOOT_NUMBER = "<< this->GetBOOTnumber(); // |
4667 |
|
// oss << " AND ( ( "; |
4668 |
|
// if ( pk1 ){ |
4669 |
|
// oss << " OBT1 = "<< obt1 << " AND " |
4670 |
|
// << " PKT1 = "<< pkt1 |
4671 |
|
// << " ) OR ( "; |
4672 |
|
// } else { |
4673 |
|
// oss << " PKT1 = "<< pkt2-1 |
4674 |
|
// << " ) OR ( "; |
4675 |
|
// }; |
4676 |
|
// if ( pk2 ){ |
4677 |
|
// oss << " OBT2 = "<< obt2 << " AND " |
4678 |
|
// << " PKT2 = "<< pkt2; |
4679 |
|
// } else { |
4680 |
|
// oss << " PKT2 = "<< pkt1+1; |
4681 |
|
// }; |
4682 |
|
// oss << " ) );"; |
4683 |
|
// // |
4684 |
|
// if ( IsDebug() ) printf(" Check if the trk calibration has already been inserted: query is \n %s \n",oss.str().c_str()); |
4685 |
|
// result = conn->Query(oss.str().c_str()); |
4686 |
|
// // |
4687 |
|
// if ( !result ) throw -4; |
4688 |
|
// // |
4689 |
|
// row = result->Next(); |
4690 |
|
// // |
4691 |
|
// if ( row ){ |
4692 |
|
// // |
4693 |
|
// if ( IsDebug() ) printf(" Trk calibration already inserted in the DB\n"); |
4694 |
|
// if ( PEDANTIC ) throw -80; |
4695 |
|
// // |
4696 |
|
// } else { |
4697 |
|
// // |
4698 |
|
// // we have to insert a new calibration, check where to place it |
4699 |
|
// // |
4700 |
|
// oss.str(""); |
4701 |
|
// oss << " SELECT ID,TO_TIME FROM GL_TRK_CALIB WHERE " |
4702 |
|
// << " FROM_TIME < "<< fromtime << " AND " |
4703 |
|
// << " TO_TIME > "<< fromtime << ";"; |
4704 |
|
// // |
4705 |
|
// if ( IsDebug() ) printf(" Check where to place the trk calibration: query is \n %s \n",oss.str().c_str()); |
4706 |
|
// result = conn->Query(oss.str().c_str()); |
4707 |
|
// // |
4708 |
|
// if ( !result ) throw -4; |
4709 |
|
// // |
4710 |
|
// row = result->Next(); |
4711 |
|
// // |
4712 |
|
// if ( !row ){ |
4713 |
|
// // |
4714 |
|
// // no calibrations in the db contain our calibration |
4715 |
|
// // |
4716 |
|
// if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
4717 |
|
// if ( fromtime < 1150871000 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode |
4718 |
|
// // |
4719 |
|
// oss.str(""); |
4720 |
|
// oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
4721 |
|
// << " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;"; |
4722 |
|
// // |
4723 |
|
// if ( IsDebug() ) printf(" Check the upper limit for calibration: query is \n %s \n",oss.str().c_str()); |
4724 |
|
// result = conn->Query(oss.str().c_str()); |
4725 |
|
// // |
4726 |
|
// if ( !result ) throw -4; |
4727 |
|
// // |
4728 |
|
// row = result->Next(); |
4729 |
|
// if ( !row ){ |
4730 |
|
// totime = numeric_limits<UInt_t>::max(); |
4731 |
|
// } else { |
4732 |
|
// totime = (UInt_t)atoll(row->GetField(0)); |
4733 |
|
// }; |
4734 |
|
// // |
4735 |
|
// } else { |
4736 |
|
// // |
4737 |
|
// // determine upper and lower limits and make space for the new calibration |
4738 |
|
// // |
4739 |
|
// totime = (UInt_t)atoll(row->GetField(1)); |
4740 |
|
// // |
4741 |
|
// oss.str(""); |
4742 |
|
// oss << " UPDATE GL_TRK_CALIB SET " |
4743 |
|
// << " TO_TIME = "<< fromtime << " WHERE " // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[ |
4744 |
|
// << " ID = "<< row->GetField(0) << ";"; |
4745 |
|
// // |
4746 |
|
// if ( IsDebug() ) printf(" Make space for the new trk calibration: query is \n %s \n",oss.str().c_str()); |
4747 |
|
// result = conn->Query(oss.str().c_str()); |
4748 |
|
// // |
4749 |
|
// if ( !result ) throw -4; |
4750 |
|
// // |
4751 |
|
// }; |
4752 |
|
// // |
4753 |
|
// oss.str(""); |
4754 |
|
// oss << " INSERT INTO GL_TRK_CALIB (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) " |
4755 |
|
// << " VALUES (NULL,' " |
4756 |
|
// << idroot << "',"; |
4757 |
|
// // |
4758 |
|
// if ( !pk1 ){ |
4759 |
|
// oss << "NULL,"; |
4760 |
|
// } else { |
4761 |
|
// oss << "'" |
4762 |
|
// << t1 << "',"; |
4763 |
|
// }; |
4764 |
|
// // |
4765 |
|
// if ( !pk2 ){ |
4766 |
|
// oss << "NULL,'"; |
4767 |
|
// } else { |
4768 |
|
// oss << "'" |
4769 |
|
// << t2 << "','"; |
4770 |
|
// }; |
4771 |
|
// // |
4772 |
|
// oss << fromtime << "','" |
4773 |
|
// << totime << "','" |
4774 |
|
// << obt1 << "','" |
4775 |
|
// << pkt1 << "','" |
4776 |
|
// << obt2 << "','" |
4777 |
|
// << pkt2 << "','" |
4778 |
|
// << this->GetBOOTnumber() << "','" |
4779 |
|
// << valid << "');"; |
4780 |
|
// // |
4781 |
|
// if ( IsDebug() ) printf(" Insert the new trk calibration: query is \n %s \n",oss.str().c_str()); |
4782 |
|
// // |
4783 |
|
// result = conn->Query(oss.str().c_str()); |
4784 |
|
// // |
4785 |
|
// if ( !result ) throw -4; |
4786 |
|
// // |
4787 |
|
// }; |
4788 |
|
// // |
4789 |
|
// }; |
4790 |
/** |
/** |
4791 |
* Fill the GL_TRK_CALIB table |
* Fill the GL_TRK_CALIB table |
4792 |
*/ |
*/ |
4793 |
void PamelaDBOperations::HandleTRK_CALIB(Bool_t pk1, Bool_t pk2){ |
void PamelaDBOperations::HandleTRK_CALIB(Bool_t pk1, Bool_t pk2){ |
4794 |
// |
|
4795 |
TSQLResult *result = 0; |
GL_TRK_CALIB *glcal = new GL_TRK_CALIB(); |
|
TSQLRow *row = 0; |
|
|
// |
|
|
stringstream oss; |
|
|
oss.str(""); |
|
|
// |
|
|
UInt_t totime = 0; |
|
|
// |
|
|
if ( !pk1 && !pk2 ){ |
|
|
if ( IsDebug() ) printf(" Cannot handle trk calibration with both packet missing!\n"); |
|
|
return; |
|
|
}; |
|
|
// |
|
|
// check if the calibration has already been inserted |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " SELECT ID FROM GL_TRK_CALIB WHERE " |
|
|
<< " BOOT_NUMBER = "<< this->GetBOOTnumber(); // |
|
|
oss << " AND ( ( "; |
|
|
if ( pk1 ){ |
|
|
oss << " OBT1 = "<< obt1 << " AND " |
|
|
<< " PKT1 = "<< pkt1 |
|
|
<< " ) OR ( "; |
|
|
} else { |
|
|
oss << " PKT1 = "<< pkt2-1 |
|
|
<< " ) OR ( "; |
|
|
}; |
|
|
if ( pk2 ){ |
|
|
oss << " OBT2 = "<< obt2 << " AND " |
|
|
<< " PKT2 = "<< pkt2; |
|
|
} else { |
|
|
oss << " PKT2 = "<< pkt1+1; |
|
|
}; |
|
|
oss << " ) );"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" Check if the trk calibration has already been inserted: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
|
row = result->Next(); |
|
|
// |
|
|
if ( row ){ |
|
4796 |
// |
// |
4797 |
if ( IsDebug() ) printf(" Trk calibration already inserted in the DB\n"); |
glcal->ID = 0; |
4798 |
if ( PEDANTIC ) throw -80; |
glcal->ID_ROOT_L0 = GetID_ROOT(); |
4799 |
// |
glcal->EV_ROOT_CALIBTRK1 = t1; |
4800 |
} else { |
glcal->EV_ROOT_CALIBTRK2 = t2; |
4801 |
|
glcal->FROM_TIME = fromtime; |
4802 |
|
glcal->TO_TIME = 0; |
4803 |
|
glcal->OBT1 = obt1; |
4804 |
|
glcal->OBT2 = obt2; |
4805 |
|
glcal->PKT1 = pkt1; |
4806 |
|
glcal->PKT2 = pkt2; |
4807 |
|
glcal->BOOT_NUMBER = GetBOOTnumber(); |
4808 |
|
glcal->VALIDATION = valid; |
4809 |
// |
// |
4810 |
// we have to insert a new calibration, check where to place it |
HandleTRK_CALIB(glcal); |
4811 |
// |
// |
4812 |
oss.str(""); |
delete glcal; |
4813 |
oss << " SELECT ID,TO_TIME FROM GL_TRK_CALIB WHERE " |
} |
4814 |
<< " FROM_TIME < "<< fromtime << " AND " |
/** |
4815 |
<< " TO_TIME > "<< fromtime << ";"; |
* Fill the GL_TRK_CALIB table |
4816 |
|
*/ |
4817 |
|
void PamelaDBOperations::HandleTRK_CALIB(GL_TRK_CALIB *glcal){ |
4818 |
|
|
4819 |
|
Bool_t pk1 = (glcal->OBT1>0&&glcal->PKT1>0); |
4820 |
|
Bool_t pk2 = (glcal->OBT2>0&&glcal->PKT2>0); |
4821 |
|
UInt_t boot_number = glcal->BOOT_NUMBER; |
4822 |
|
UInt_t obt1 = glcal->OBT1; |
4823 |
|
UInt_t obt2 = glcal->OBT2; |
4824 |
|
UInt_t pkt1 = glcal->PKT1; |
4825 |
|
UInt_t pkt2 = glcal->PKT2; |
4826 |
|
UInt_t fromtime = glcal->FROM_TIME; |
4827 |
|
UInt_t totime = 0; |
4828 |
|
UInt_t idroot = glcal->ID_ROOT_L0; |
4829 |
|
UInt_t t1 = glcal->EV_ROOT_CALIBTRK1; |
4830 |
|
UInt_t t2 = glcal->EV_ROOT_CALIBTRK2; |
4831 |
|
UInt_t valid = glcal->VALIDATION; |
4832 |
// |
// |
4833 |
if ( IsDebug() ) printf(" Check where to place the trk calibration: query is \n %s \n",oss.str().c_str()); |
TSQLResult *result = 0; |
4834 |
result = conn->Query(oss.str().c_str()); |
TSQLRow *row = 0; |
4835 |
// |
// |
4836 |
if ( !result ) throw -4; |
stringstream oss; |
4837 |
|
oss.str(""); |
4838 |
// |
// |
|
row = result->Next(); |
|
4839 |
// |
// |
4840 |
if ( !row ){ |
if ( !pk1 && !pk2 ){ |
4841 |
// |
if ( IsDebug() ) printf(" Cannot handle trk calibration with both packet missing!\n"); |
4842 |
// no calibrations in the db contain our calibration |
return; |
|
// |
|
|
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
|
|
if ( fromtime < 1150871000 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
|
|
<< " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" Check the upper limit for calibration: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
|
row = result->Next(); |
|
|
if ( !row ){ |
|
|
totime = numeric_limits<UInt_t>::max(); |
|
|
} else { |
|
|
totime = (UInt_t)atoll(row->GetField(0)); |
|
|
}; |
|
|
// |
|
|
} else { |
|
|
// |
|
|
// determine upper and lower limits and make space for the new calibration |
|
|
// |
|
|
totime = (UInt_t)atoll(row->GetField(1)); |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " UPDATE GL_TRK_CALIB SET " |
|
|
<< " TO_TIME = "<< fromtime << " WHERE " // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[ |
|
|
<< " ID = "<< row->GetField(0) << ";"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" Make space for the new trk calibration: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
4843 |
}; |
}; |
4844 |
// |
// |
4845 |
oss.str(""); |
// check if the calibration has already been inserted |
|
oss << " INSERT INTO GL_TRK_CALIB (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) " |
|
|
<< " VALUES (NULL,' " |
|
|
<< idroot << "',"; |
|
4846 |
// |
// |
4847 |
if ( !pk1 ){ |
oss.str(""); |
4848 |
oss << "NULL,"; |
oss << " SELECT ID FROM GL_TRK_CALIB WHERE " |
4849 |
|
<< " BOOT_NUMBER = "<< boot_number; // |
4850 |
|
oss << " AND FROM_TIME="<<fromtime; /// NEWNEWNEW -- VA BENE ?!?!?!?! |
4851 |
|
oss << " AND ( ( "; |
4852 |
|
if ( pk1 ){ |
4853 |
|
oss << " OBT1 = "<< obt1 << " AND " |
4854 |
|
<< " PKT1 = "<< pkt1 |
4855 |
|
<< " ) OR ( "; |
4856 |
} else { |
} else { |
4857 |
oss << "'" |
oss << " PKT1 = "<< pkt2-1 |
4858 |
<< t1 << "',"; |
<< " ) OR ( "; |
4859 |
}; |
}; |
4860 |
// |
if ( pk2 ){ |
4861 |
if ( !pk2 ){ |
oss << " OBT2 = "<< obt2 << " AND " |
4862 |
oss << "NULL,'"; |
<< " PKT2 = "<< pkt2; |
4863 |
} else { |
} else { |
4864 |
oss << "'" |
oss << " PKT2 = "<< pkt1+1; |
4865 |
<< t2 << "','"; |
}; |
4866 |
}; |
oss << " ) );"; |
|
// |
|
|
oss << fromtime << "','" |
|
|
<< totime << "','" |
|
|
<< obt1 << "','" |
|
|
<< pkt1 << "','" |
|
|
<< obt2 << "','" |
|
|
<< pkt2 << "','" |
|
|
<< this->GetBOOTnumber() << "','" |
|
|
<< valid << "');"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" Insert the new trk calibration: query is \n %s \n",oss.str().c_str()); |
|
4867 |
// |
// |
4868 |
|
if ( IsDebug() ) printf(" Check if the trk calibration has already been inserted: query is \n %s \n",oss.str().c_str()); |
4869 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
4870 |
// |
// |
4871 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
4872 |
// |
// |
4873 |
}; |
row = result->Next(); |
|
// |
|
|
}; |
|
|
|
|
|
/** |
|
|
* Scan tracker calibrations packets, fill the GL_TRK_CALIB table |
|
|
*/ |
|
|
Int_t PamelaDBOperations::insertTRK_CALIB(){ |
|
|
// |
|
|
CalibTrk1Event *caltrk1 = 0; |
|
|
CalibTrk2Event *caltrk2 = 0; |
|
|
TTree *tr1 = 0; |
|
|
TTree *tr2 = 0; |
|
|
EventHeader *eh1 = 0; |
|
|
PscuHeader *ph1 = 0; |
|
|
EventHeader *eh2 = 0; |
|
|
PscuHeader *ph2 = 0; |
|
|
// |
|
|
PacketType *pctp=0; |
|
|
EventCounter *codt2=0; |
|
|
// |
|
|
Int_t nevents1 = 0; |
|
|
Int_t nevents2 = 0; |
|
|
// |
|
|
fromtime = 0; |
|
|
// |
|
|
obt1 = 0; |
|
|
pkt1 = 0; |
|
|
obt2 = 0; |
|
|
pkt2 = 0; |
|
|
// |
|
|
tr1 = (TTree*)file->Get("CalibTrk1"); |
|
|
if ( !tr1 || tr1->IsZombie() ) throw -22; |
|
|
tr2 = (TTree*)file->Get("CalibTrk2"); |
|
|
if ( !tr2 || tr2->IsZombie() ) throw -23; |
|
|
// |
|
|
tr1->SetBranchAddress("CalibTrk1", &caltrk1); |
|
|
tr1->SetBranchAddress("Header", &eh1); |
|
|
nevents1 = tr1->GetEntries(); |
|
|
tr2->SetBranchAddress("CalibTrk2", &caltrk2); |
|
|
tr2->SetBranchAddress("Header", &eh2); |
|
|
nevents2 = tr2->GetEntries(); |
|
|
// |
|
|
if ( !nevents1 && !nevents2 ) return(1); |
|
|
// |
|
|
t2 = -1; |
|
|
Int_t pret2 = 0; |
|
|
Int_t t2t1cal = 0; |
|
|
// |
|
|
for (t1=0; t1 < nevents1; t1++){ |
|
|
// |
|
|
pret2 = t2; |
|
|
tr1->GetEntry(t1); |
|
|
// |
|
|
ph1 = eh1->GetPscuHeader(); |
|
|
obt1 = ph1->GetOrbitalTime(); |
|
|
pkt1 = ph1->GetCounter(); |
|
|
fromtime = this->GetAbsTime(ph1->GetOrbitalTime()); |
|
|
// |
|
|
// valid = 1; |
|
|
// // |
|
|
// if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1 |
|
|
// |
|
4874 |
// |
// |
4875 |
if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
if ( row ){ |
|
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ |
|
|
// |
|
|
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1); |
|
|
// |
|
|
valid = ValidateTrkCalib( caltrk1, eh1 ); |
|
|
if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; |
|
|
// |
|
|
// Do we have the second calibration packet? |
|
|
// |
|
|
while ( t2t1cal < t1+1 ){ // get the calibration packet2 that follows the packet1 |
|
|
// |
|
|
t2++; |
|
|
// |
|
|
pret2 = t2 - 1; // EMILIANO |
|
|
// |
|
|
if ( t2 < nevents2 ){ |
|
|
tr2->GetEntry(t2); |
|
|
codt2 = eh2->GetCounter(); |
|
|
t2t1cal = codt2->Get(pctp->CalibTrk1); |
|
|
// |
|
|
ph2 = eh2->GetPscuHeader(); |
|
|
obt2 = ph2->GetOrbitalTime(); |
|
|
pkt2 = ph2->GetCounter(); |
|
|
// |
|
|
if ( IsDebug() ) printf(" This is a trk calibration2 at obt %u pkt %u t2 is %u , t2t1cal is %u \n",obt2,pkt2,t2,t2t1cal); |
|
|
// if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 |
|
|
// |
|
|
} else { |
|
|
// |
|
|
// running out of vector without finding the corresponding calibration, sig |
|
|
// |
|
|
if ( IsDebug() ) printf(" t2 >= nevents2 \n"); |
|
|
pret2 = t2; |
|
|
obt2 = 0; |
|
|
// pkt2 = pkt1+2; |
|
|
pkt2 = 0; |
|
|
t2t1cal = t1+1; |
|
|
}; |
|
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) && (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
|
|
|
|
|
// EMILIANO |
|
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
|
|
// // if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
|
|
// if ( IsDebug() ) printf(" running out of vector without finding the corresponding calibration, sig \n"); |
|
|
// // |
|
|
// // running out of vector without finding the corresponding calibration, sig |
|
|
// // |
|
|
// pret2 = t2; |
|
|
// obt2 = 0; |
|
|
// // pkt2 = pkt1+2; |
|
|
// pkt2 = 0; |
|
|
// t2t1cal = t1+1; |
|
|
// }; |
|
|
|
|
|
|
|
4876 |
// |
// |
4877 |
}; |
if ( IsDebug() ) printf(" Trk calibration already inserted in the DB\n"); |
4878 |
// |
if ( PEDANTIC ) throw -80; |
|
if ( IsDebug() ) printf(" Check if trk calibration2 exists \n"); |
|
|
// |
|
|
// EMILIANO |
|
|
if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
|
|
// if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
|
|
if ( IsDebug() ) printf(" The calibration found is outside the interval, sig \n"); |
|
4879 |
// |
// |
4880 |
// running out of vector without finding the corresponding calibration, sig |
} else { |
|
// |
|
|
pret2 = t2; |
|
|
obt2 = 0; |
|
|
pkt2 = 0; |
|
|
}; |
|
|
// |
|
|
// The calibration is good |
|
|
// |
|
|
if ( this->PKT(pkt2) == this->PKT(pkt1)+1 ){ |
|
4881 |
// |
// |
4882 |
if ( IsDebug() ) printf(" Found trk calibration2 at obt %u pkt %u t2 is %u \n",obt2,pkt2,t2); |
// we have to insert a new calibration, check where to place it |
|
if ( IsDebug() ) printf(" The trk calibration2 at obt %u pkt %u t2 is %u is good \n",obt2,pkt2,t2); |
|
4883 |
// |
// |
4884 |
UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); |
oss.str(""); |
4885 |
if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl; |
oss << " SELECT ID,TO_TIME FROM GL_TRK_CALIB WHERE " |
4886 |
valid = valid & valid2; |
<< " FROM_TIME < "<< fromtime << " AND " |
4887 |
|
<< " TO_TIME > "<< fromtime << ";"; |
4888 |
// |
// |
4889 |
// Handle good calib |
if ( IsDebug() ) printf(" Check where to place the trk calibration: query is \n %s \n",oss.str().c_str()); |
4890 |
|
result = conn->Query(oss.str().c_str()); |
4891 |
// |
// |
4892 |
this->HandleTRK_CALIB(true,true); |
if ( !result ) throw -4; |
4893 |
// |
// |
4894 |
// Check for missing calibtrk1 |
row = result->Next(); |
4895 |
// |
// |
4896 |
if ( t2 != pret2+1 ){ |
if ( !row ){ |
4897 |
// |
// |
4898 |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u pret2 is %u \n",obt2,pkt2,t2,pret2); |
// no calibrations in the db contain our calibration |
4899 |
// |
// |
4900 |
while ( t2 > pret2+1 ){ |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
4901 |
|
if ( fromtime < 1150871000 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode |
4902 |
|
// |
4903 |
|
oss.str(""); |
4904 |
|
oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
4905 |
|
<< " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;"; |
4906 |
// |
// |
4907 |
// handle missing calib1 |
if ( IsDebug() ) printf(" Check the upper limit for calibration: query is \n %s \n",oss.str().c_str()); |
4908 |
|
result = conn->Query(oss.str().c_str()); |
4909 |
// |
// |
4910 |
pret2++; |
if ( !result ) throw -4; |
4911 |
// |
// |
4912 |
obt1 = 0; |
row = result->Next(); |
4913 |
pkt1 = 0; |
if ( !row ){ |
4914 |
|
totime = numeric_limits<UInt_t>::max(); |
4915 |
|
} else { |
4916 |
|
totime = (UInt_t)atoll(row->GetField(0)); |
4917 |
|
}; |
4918 |
// |
// |
4919 |
tr2->GetEntry(pret2); |
} else { |
|
ph2 = eh2->GetPscuHeader(); |
|
|
obt2 = ph2->GetOrbitalTime(); |
|
|
pkt2 = ph2->GetCounter(); |
|
4920 |
// |
// |
4921 |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
// determine upper and lower limits and make space for the new calibration |
4922 |
// |
// |
4923 |
valid = 0; |
totime = (UInt_t)atoll(row->GetField(1)); |
4924 |
this->HandleTRK_CALIB(false,true); |
// |
4925 |
|
oss.str(""); |
4926 |
|
oss << " UPDATE GL_TRK_CALIB SET " |
4927 |
|
<< " TO_TIME = "<< fromtime << " WHERE " // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[ |
4928 |
|
<< " ID = "<< row->GetField(0) << ";"; |
4929 |
|
// |
4930 |
|
if ( IsDebug() ) printf(" Make space for the new trk calibration: query is \n %s \n",oss.str().c_str()); |
4931 |
|
result = conn->Query(oss.str().c_str()); |
4932 |
|
// |
4933 |
|
if ( !result ) throw -4; |
4934 |
// |
// |
|
}; |
|
|
// |
|
4935 |
}; |
}; |
4936 |
// |
// |
4937 |
} else if ( this->PKT(pkt2) > this->PKT(pkt1)+1 ){ |
oss.str(""); |
4938 |
|
oss << " INSERT INTO GL_TRK_CALIB (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) " |
4939 |
|
<< " VALUES (NULL,' " |
4940 |
|
<< idroot << "',"; |
4941 |
// |
// |
4942 |
// Check for missing calibtrk2 |
if ( !pk1 ){ |
4943 |
|
oss << "NULL,"; |
4944 |
|
} else { |
4945 |
|
oss << "'" |
4946 |
|
<< t1 << "',"; |
4947 |
|
}; |
4948 |
// |
// |
4949 |
if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
if ( !pk2 ){ |
4950 |
t2 = pret2; |
oss << "NULL,'"; |
4951 |
|
} else { |
4952 |
|
oss << "'" |
4953 |
|
<< t2 << "','"; |
4954 |
|
}; |
4955 |
// |
// |
4956 |
// handle missing calib2 |
oss << fromtime << "','" |
4957 |
|
<< totime << "','" |
4958 |
|
<< obt1 << "','" |
4959 |
|
<< pkt1 << "','" |
4960 |
|
<< obt2 << "','" |
4961 |
|
<< pkt2 << "','" |
4962 |
|
<< boot_number << "','" |
4963 |
|
<< valid << "');"; |
4964 |
// |
// |
4965 |
obt2 = 0; |
if ( IsDebug() ) printf(" Insert the new trk calibration: query is \n %s \n",oss.str().c_str()); |
4966 |
pkt2 = 0; |
// |
4967 |
valid = 0; |
result = conn->Query(oss.str().c_str()); |
4968 |
this->HandleTRK_CALIB(true,false); |
// |
4969 |
|
if ( !result ) throw -4; |
4970 |
// |
// |
|
}; |
|
|
// |
|
|
} else { |
|
|
// |
|
|
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u OUTSIDE the considered time interval \n",fromtime,obt1,pkt1); |
|
|
// if ( PEDANTIC ) throw -79; |
|
|
// |
|
4971 |
}; |
}; |
4972 |
// |
|
4973 |
}; |
oss.str(""); |
4974 |
// |
oss << " SELECT ID FROM GL_TRK_CALIB ORDER BY ID DESC LIMIT 1 ;"; |
4975 |
// we have one more calib pkt2 ! |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
4976 |
// |
result = conn->Query(oss.str().c_str()); |
4977 |
t2++; |
if ( !result ) throw -4;; |
4978 |
while ( t2 < nevents2 ){ |
row = result->Next(); |
4979 |
|
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
4980 |
|
|
4981 |
// |
// |
4982 |
// handle missing calib1 |
}; |
4983 |
|
|
4984 |
|
/** |
4985 |
|
* Scan tracker calibrations packets, fill the GL_TRK_CALIB table |
4986 |
|
*/ |
4987 |
|
Int_t PamelaDBOperations::insertTRK_CALIB(){ |
4988 |
|
// |
4989 |
|
CalibTrk1Event *caltrk1 = 0; |
4990 |
|
CalibTrk2Event *caltrk2 = 0; |
4991 |
|
TTree *tr1 = 0; |
4992 |
|
TTree *tr2 = 0; |
4993 |
|
EventHeader *eh1 = 0; |
4994 |
|
PscuHeader *ph1 = 0; |
4995 |
|
EventHeader *eh2 = 0; |
4996 |
|
PscuHeader *ph2 = 0; |
4997 |
|
// |
4998 |
|
PacketType *pctp=0; |
4999 |
|
EventCounter *codt2=0; |
5000 |
|
// |
5001 |
|
Int_t nevents1 = 0; |
5002 |
|
Int_t nevents2 = 0; |
5003 |
|
// |
5004 |
|
fromtime = 0; |
5005 |
// |
// |
|
if ( IsDebug() ) printf(" t2 is %u nevents2 is %u \n",t2,nevents2); |
|
5006 |
obt1 = 0; |
obt1 = 0; |
5007 |
pkt1 = 0; |
pkt1 = 0; |
5008 |
|
obt2 = 0; |
5009 |
|
pkt2 = 0; |
5010 |
// |
// |
5011 |
tr2->GetEntry(t2); |
tr1 = (TTree*)file->Get("CalibTrk1"); |
5012 |
ph2 = eh2->GetPscuHeader(); |
if ( !tr1 || tr1->IsZombie() ) throw -22; |
5013 |
obt2 = ph2->GetOrbitalTime(); |
tr2 = (TTree*)file->Get("CalibTrk2"); |
5014 |
pkt2 = ph2->GetCounter(); |
if ( !tr2 || tr2->IsZombie() ) throw -23; |
5015 |
// |
// |
5016 |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
tr1->SetBranchAddress("CalibTrk1", &caltrk1); |
5017 |
valid = 0; |
tr1->SetBranchAddress("Header", &eh1); |
5018 |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
nevents1 = tr1->GetEntries(); |
5019 |
// EMILIANO |
tr2->SetBranchAddress("CalibTrk2", &caltrk2); |
5020 |
if ( this->PKT(pkt2) >= this->PKT(pktfirst) && this->PKT(pkt2 <= upperpkt) && this->OBT(obt2) >= this->OBT(obtfirst) && this->OBT(obt2) <= upperobt ){ |
tr2->SetBranchAddress("Header", &eh2); |
5021 |
// if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
nevents2 = tr2->GetEntries(); |
5022 |
// |
// |
5023 |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
if ( !nevents1 && !nevents2 ) return(1); |
5024 |
// |
// |
5025 |
this->HandleTRK_CALIB(false,true); |
t2 = -1; |
5026 |
// |
Int_t pret2 = 0; |
5027 |
}; |
Int_t t2t1cal = 0; |
5028 |
|
// |
5029 |
|
bool MISSING_pkt1 = true; |
5030 |
|
bool MISSING_pkt2 = true; |
5031 |
|
int ncalib = 0; |
5032 |
|
bool try_to_recover = false; |
5033 |
// |
// |
5034 |
t2++; |
for (t1=0; t1 < nevents1; t1++){//loop over packet1 |
5035 |
|
// |
5036 |
|
pret2 = t2; |
5037 |
|
tr1->GetEntry(t1); |
5038 |
|
// |
5039 |
|
ph1 = eh1->GetPscuHeader(); |
5040 |
|
obt1 = ph1->GetOrbitalTime(); |
5041 |
|
pkt1 = ph1->GetCounter(); |
5042 |
|
fromtime = GetAbsTime(ph1->GetOrbitalTime()); |
5043 |
|
// |
5044 |
|
// chek if the packet number and obt are consistent with the other packets ??? |
5045 |
|
// |
5046 |
|
if ( PKT(pkt1) >= PKT(pktfirst) && PKT(pkt1) <= upperpkt && OBT(obt1) >= OBT(obtfirst) && OBT(obt1) <= upperobt ){ |
5047 |
|
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ |
5048 |
|
// |
5049 |
|
if ( IsDebug() ) printf("\n Trk calibration1 %u at time %u obt %u pkt %u \n",t1,fromtime,obt1,pkt1); |
5050 |
|
// |
5051 |
|
valid = ValidateTrkCalib( caltrk1, eh1 ); |
5052 |
|
if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; |
5053 |
|
// |
5054 |
|
// Do we have the second calibration packet? |
5055 |
|
// |
5056 |
|
if ( IsDebug() ) cout << " Loop over calibration2 to search associated calibration: "<<endl; |
5057 |
|
while ( t2t1cal < t1+1 ){ // get the calibration packet2 that follows the packet1 |
5058 |
|
// |
5059 |
|
t2++; |
5060 |
|
// |
5061 |
|
pret2 = t2 - 1; // EMILIANO |
5062 |
|
// |
5063 |
|
if ( t2 < nevents2 ){ |
5064 |
|
tr2->GetEntry(t2); |
5065 |
|
codt2 = eh2->GetCounter(); |
5066 |
|
t2t1cal = codt2->Get(pctp->CalibTrk1); |
5067 |
|
// |
5068 |
|
ph2 = eh2->GetPscuHeader(); |
5069 |
|
obt2 = ph2->GetOrbitalTime(); |
5070 |
|
pkt2 = ph2->GetCounter(); |
5071 |
|
// |
5072 |
|
if ( IsDebug() ) printf(" >> trk calibration2 at obt %u pkt %u t2 is %u , t2t1cal is %u \n",obt2,pkt2,t2,t2t1cal); |
5073 |
|
// if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 |
5074 |
|
// |
5075 |
|
} else { |
5076 |
|
// |
5077 |
|
// running out of vector without finding the corresponding calibration, sig |
5078 |
|
// |
5079 |
|
if ( IsDebug() ) printf(" t2 >= nevents2 \n"); |
5080 |
|
pret2 = t2; |
5081 |
|
obt2 = 0; |
5082 |
|
// pkt2 = pkt1+2; |
5083 |
|
pkt2 = 0; |
5084 |
|
t2t1cal = t1+1; |
5085 |
|
}; |
5086 |
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) && (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
5087 |
|
|
5088 |
|
// EMILIANO |
5089 |
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
5090 |
|
// // if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
5091 |
|
// if ( IsDebug() ) printf(" running out of vector without finding the corresponding calibration, sig \n"); |
5092 |
|
// // |
5093 |
|
// // running out of vector without finding the corresponding calibration, sig |
5094 |
|
// // |
5095 |
|
// pret2 = t2; |
5096 |
|
// obt2 = 0; |
5097 |
|
// // pkt2 = pkt1+2; |
5098 |
|
// pkt2 = 0; |
5099 |
|
// t2t1cal = t1+1; |
5100 |
|
// }; |
5101 |
|
|
5102 |
|
|
5103 |
|
// |
5104 |
|
}; |
5105 |
|
// |
5106 |
|
if ( IsDebug() ) printf(" Check if trk calibration2 is the right one \n"); |
5107 |
|
// |
5108 |
|
// EMILIANO |
5109 |
|
if ( ( PKT(pkt2) < PKT(pktfirst) || PKT(pkt2) > upperpkt) || (OBT(obt2) < OBT(obtfirst) || OBT(obt2) > upperobt) ){ |
5110 |
|
// if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
5111 |
|
if ( IsDebug() ) printf(" *WARNING* The calibration found is outside the interval, sig \n"); |
5112 |
|
// |
5113 |
|
// running out of vector without finding the corresponding calibration, sig |
5114 |
|
// |
5115 |
|
pret2 = t2; |
5116 |
|
obt2 = 0; |
5117 |
|
pkt2 = 0; |
5118 |
|
}; |
5119 |
|
if ( PKT(pkt2) == PKT(pkt1)+1 ){ |
5120 |
|
if ( IsDebug() ) cout << " ...OK"<<endl; |
5121 |
|
// ======================= |
5122 |
|
// The calibration is good |
5123 |
|
// ======================= |
5124 |
|
// |
5125 |
|
// if ( IsDebug() ) printf(" Found trk calibration2 at obt %u pkt %u t2 is %u \n",obt2,pkt2,t2); |
5126 |
|
// if ( IsDebug() ) printf(" Trk calibration2 at obt %u pkt %u t2 is %u is good \n",obt2,pkt2,t2); |
5127 |
|
// if ( IsDebug() ) printf("\n Trk calibration2 at time %u obt %u pkt %u \n",fromtime,obt2,pkt2); |
5128 |
|
if ( IsDebug() ) printf(" Trk calibration2 %u at time %u obt %u pkt %u \n",t2,fromtime,obt2,pkt2); |
5129 |
|
// |
5130 |
|
UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); |
5131 |
|
if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl; |
5132 |
|
// valid = valid & valid2; |
5133 |
|
valid = valid & valid2; //QUESTO VA CAMBIATO |
5134 |
|
// |
5135 |
|
// Handle good calib |
5136 |
|
// |
5137 |
|
MISSING_pkt1 = false; |
5138 |
|
MISSING_pkt2 = false; |
5139 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5140 |
|
// |
5141 |
|
// Check for missing calibtrk1 |
5142 |
|
// |
5143 |
|
if ( t2 != pret2+1 ){ |
5144 |
|
// |
5145 |
|
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u pret2 is %u \n",obt2,pkt2,t2,pret2); |
5146 |
|
// |
5147 |
|
while ( t2 > pret2+1 ){ |
5148 |
|
// |
5149 |
|
// handle missing calib1 |
5150 |
|
// |
5151 |
|
pret2++; |
5152 |
|
// |
5153 |
|
obt1 = 0; |
5154 |
|
pkt1 = 0; |
5155 |
|
// |
5156 |
|
tr2->GetEntry(pret2); |
5157 |
|
ph2 = eh2->GetPscuHeader(); |
5158 |
|
obt2 = ph2->GetOrbitalTime(); |
5159 |
|
pkt2 = ph2->GetCounter(); |
5160 |
|
// |
5161 |
|
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
5162 |
|
// |
5163 |
|
valid = 0; |
5164 |
|
MISSING_pkt1 = true; |
5165 |
|
MISSING_pkt2 = false; |
5166 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5167 |
|
// |
5168 |
|
}; |
5169 |
|
// |
5170 |
|
}; |
5171 |
|
// |
5172 |
|
} else if ( this->PKT(pkt2) > this->PKT(pkt1)+1 ){ |
5173 |
|
// |
5174 |
|
// Check for missing calibtrk2 |
5175 |
|
// |
5176 |
|
if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
5177 |
|
t2 = pret2; |
5178 |
|
// |
5179 |
|
// handle missing calib2 |
5180 |
|
// |
5181 |
|
obt2 = 0; |
5182 |
|
pkt2 = 0; |
5183 |
|
valid = 0; |
5184 |
|
MISSING_pkt1 = false; |
5185 |
|
MISSING_pkt2 = true; |
5186 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5187 |
|
// |
5188 |
|
}; |
5189 |
|
// |
5190 |
|
} else { |
5191 |
|
// |
5192 |
|
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u OUTSIDE the considered time interval \n",fromtime,obt1,pkt1); |
5193 |
|
// if ( PEDANTIC ) throw -79; |
5194 |
|
// |
5195 |
|
}; |
5196 |
|
// |
5197 |
|
|
5198 |
|
if( !(MISSING_pkt1&MISSING_pkt2) ){ |
5199 |
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5200 |
|
ncalib++; |
5201 |
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
5202 |
|
} |
5203 |
|
|
5204 |
|
}; //end loop on pkt1 |
5205 |
|
|
5206 |
|
|
5207 |
|
|
5208 |
// |
// |
5209 |
}; |
// we have one more calib pkt2 ! |
5210 |
|
// |
5211 |
|
t2++; |
5212 |
|
while ( t2 < nevents2 ){ |
5213 |
|
// |
5214 |
|
// handle missing calib1 |
5215 |
|
// |
5216 |
|
if ( IsDebug() ) printf(" t2 is %u nevents2 is %u \n",t2,nevents2); |
5217 |
|
obt1 = 0; |
5218 |
|
pkt1 = 0; |
5219 |
|
// |
5220 |
|
tr2->GetEntry(t2); |
5221 |
|
ph2 = eh2->GetPscuHeader(); |
5222 |
|
obt2 = ph2->GetOrbitalTime(); |
5223 |
|
pkt2 = ph2->GetCounter(); |
5224 |
|
// |
5225 |
|
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
5226 |
|
valid = 0; |
5227 |
|
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
5228 |
|
// EMILIANO |
5229 |
|
if ( this->PKT(pkt2) >= this->PKT(pktfirst) && this->PKT(pkt2 <= upperpkt) && this->OBT(obt2) >= this->OBT(obtfirst) && this->OBT(obt2) <= upperobt ){ |
5230 |
|
// if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
5231 |
|
// |
5232 |
|
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
5233 |
|
// |
5234 |
|
MISSING_pkt1 = true; |
5235 |
|
MISSING_pkt2 = false; |
5236 |
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5237 |
|
ncalib++; |
5238 |
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
5239 |
|
// |
5240 |
|
}; |
5241 |
|
// |
5242 |
|
t2++; |
5243 |
|
// |
5244 |
|
}; |
5245 |
|
|
5246 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5247 |
|
// ----------------------------------------------------------------- |
5248 |
|
// in case of corruption, check if the calibration can be recovered |
5249 |
|
// from another chewbacca file |
5250 |
|
// ----------------------------------------------------------------- |
5251 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5252 |
|
|
5253 |
|
// cout <<" TRY TO RECOVER ?? "<<try_to_recover<<endl; |
5254 |
|
|
5255 |
|
if(chewbacca&&try_to_recover){ |
5256 |
|
|
5257 |
|
|
5258 |
|
if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl; |
5259 |
|
|
5260 |
|
TSQLResult *result = 0; |
5261 |
|
TSQLRow *row = 0; |
5262 |
|
// |
5263 |
|
stringstream oss; |
5264 |
|
oss.str(""); |
5265 |
|
// |
5266 |
|
|
5267 |
|
//////////////////////////////////////////////////////////////////////// |
5268 |
|
// retrieve the name of the current file: |
5269 |
|
//////////////////////////////////////////////////////////////////////// |
5270 |
|
oss.str(""); |
5271 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << GetID_ROOT() <<";"; |
5272 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5273 |
|
|
5274 |
|
result = conn->Query(oss.str().c_str()); |
5275 |
|
if ( !result ) throw -4;; |
5276 |
|
row = result->Next(); |
5277 |
|
TString thisfilename = (TString)row->GetField(0); |
5278 |
|
if ( IsDebug() ) cout << "Current file ==> "<<thisfilename<<endl; |
5279 |
|
|
5280 |
|
//////////////////////////////////////////////////////////////////////// |
5281 |
|
// read all the calibrations inserted |
5282 |
|
//////////////////////////////////////////////////////////////////////// |
5283 |
|
oss.str(""); |
5284 |
|
oss << " SELECT "; |
5285 |
|
oss << " ID,FROM_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,TO_TIME"; |
5286 |
|
oss << " FROM GL_TRK_CALIB "; |
5287 |
|
oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; "; |
5288 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5289 |
|
|
5290 |
|
result = conn->Query(oss.str().c_str()); |
5291 |
|
if ( !result ) throw -4;; |
5292 |
|
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5293 |
|
|
5294 |
|
// ----------------------------------- |
5295 |
|
// loop over calibrations ... |
5296 |
|
// ----------------------------------- |
5297 |
|
UInt_t nn=0; |
5298 |
|
do { |
5299 |
|
row = result->Next(); |
5300 |
|
if(!row)break; |
5301 |
|
|
5302 |
|
UInt_t id = (UInt_t)atoll(row->GetField(0)); |
5303 |
|
UInt_t fromtime = (UInt_t)atoll(row->GetField(1)); |
5304 |
|
UInt_t obt1 = (UInt_t)atoll(row->GetField(2)); |
5305 |
|
UInt_t pkt1 = (UInt_t)atoll(row->GetField(3)); |
5306 |
|
UInt_t obt2 = (UInt_t)atoll(row->GetField(4)); |
5307 |
|
UInt_t pkt2 = (UInt_t)atoll(row->GetField(5)); |
5308 |
|
UInt_t boot = (UInt_t)atoll(row->GetField(6)); |
5309 |
|
UInt_t valid = (UInt_t)atoll(row->GetField(7)); |
5310 |
|
bool MISSING_pkt1 = (row->GetFieldLength(8)==0); |
5311 |
|
bool MISSING_pkt2 = (row->GetFieldLength(9)==0); |
5312 |
|
UInt_t totime = (UInt_t)atoll(row->GetField(10)); |
5313 |
|
|
5314 |
|
// ------------------------------------- |
5315 |
|
// ...check if the entry is corrupted... |
5316 |
|
// ------------------------------------- |
5317 |
|
cout <<"*** "<< MISSING_pkt1 << MISSING_pkt2 << valid <<endl; |
5318 |
|
bool CORRUPTED = (MISSING_pkt1||MISSING_pkt2||!valid); |
5319 |
|
|
5320 |
|
if ( IsDebug() ) cout << "("<<nn<<") ID = "<<id<<" from GL_TRK_CALIB ==> corrupted ? "<<CORRUPTED<<endl; |
5321 |
|
|
5322 |
|
// if( !CORRUPTED )continue; // nothing to do |
5323 |
|
|
5324 |
|
///////////////////////////////////////////////////////// |
5325 |
|
// if it is corrupted, ...look for ather chewbacca files |
5326 |
|
// containing the same calibrations ... |
5327 |
|
///////////////////////////////////////////////////////// |
5328 |
|
|
5329 |
|
bool this_MISSING_pkt1 = false; |
5330 |
|
bool this_MISSING_pkt2 = false; |
5331 |
|
int this_t1=0; |
5332 |
|
int this_t2=0;; |
5333 |
|
UInt_t this_valid = 0; |
5334 |
|
|
5335 |
|
TString path = ""; |
5336 |
|
TString name = ""; |
5337 |
|
TString raw = ""; |
5338 |
|
UInt_t obt0 = 0; |
5339 |
|
UInt_t timesync = 0; |
5340 |
|
UInt_t boot_number = 0; |
5341 |
|
bool FOUND = false; |
5342 |
|
|
5343 |
|
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
5344 |
|
|
5345 |
|
// for(int itable=0; itable<2; itable++){ |
5346 |
|
for(int itable=0; itable<1; itable++){ |
5347 |
|
|
5348 |
|
// ------------------------------------------------------ |
5349 |
|
// loop over both ROOT_TABLE and ROOT_TABLE_BAD |
5350 |
|
// ------------------------------------------------------ |
5351 |
|
|
5352 |
|
TString table = "ROOT_TABLE"; |
5353 |
|
if(itable==1)table = "ROOT_TABLE_BAD"; |
5354 |
|
|
5355 |
|
oss.str(""); |
5356 |
|
oss << " SELECT "; |
5357 |
|
oss << " FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,BOOT_NUMBER,INPUT_NAME "; |
5358 |
|
oss << " FROM "<<table; |
5359 |
|
oss << " WHERE 1 " << endl; |
5360 |
|
oss << " AND FILE_NAME != \""<< thisfilename<<"\""; |
5361 |
|
if( !MISSING_pkt1 ){ |
5362 |
|
oss << " AND "; |
5363 |
|
oss << " PKT_NUMBER_INIT < "<<pkt1; |
5364 |
|
oss << " AND "; |
5365 |
|
oss << " PKT_NUMBER_FINAL > "<<pkt1; |
5366 |
|
oss << " AND "; |
5367 |
|
oss << " PKT_OBT_INIT < "<<obt1; |
5368 |
|
oss << " AND "; |
5369 |
|
oss << " PKT_OBT_FINAL > "<<obt1; |
5370 |
|
}else{ |
5371 |
|
if(pkt2>1) pkt1 = pkt2-1;//serve dopo |
5372 |
|
} |
5373 |
|
if( !MISSING_pkt2 ){ |
5374 |
|
oss << " AND "; |
5375 |
|
oss << " PKT_NUMBER_INIT < "<<pkt2; |
5376 |
|
oss << " AND "; |
5377 |
|
oss << " PKT_NUMBER_FINAL > "<<pkt2; |
5378 |
|
oss << " AND "; |
5379 |
|
oss << " PKT_OBT_INIT < "<<obt2; |
5380 |
|
oss << " AND "; |
5381 |
|
oss << " PKT_OBT_FINAL > "<<obt2; |
5382 |
|
}else{ |
5383 |
|
if(pkt1>0) pkt2 = pkt1+1;//serve dopo |
5384 |
|
} |
5385 |
|
if( boot> 0 ){ |
5386 |
|
oss << " AND "; |
5387 |
|
oss << " BOOT_NUMBER = "<<boot; |
5388 |
|
}else{ |
5389 |
|
} |
5390 |
|
oss << " ORDER BY BAD_PKT_CALREAD ASC; "; |
5391 |
|
|
5392 |
|
TSQLResult *result2 = 0; |
5393 |
|
TSQLRow *row2 = 0; |
5394 |
|
|
5395 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5396 |
|
result2 = conn->Query(oss.str().c_str()); |
5397 |
|
if ( !result2 ) throw -4;; |
5398 |
|
if ( IsDebug() ) cout <<"Rows: "<<result2->GetRowCount()<<endl; |
5399 |
|
|
5400 |
|
// ------------------------------------------------------ |
5401 |
|
// loop over files containing repetition (if any) |
5402 |
|
// ------------------------------------------------------ |
5403 |
|
do { |
5404 |
|
row2 = result2->Next(); |
5405 |
|
if(!row2)break; |
5406 |
|
|
5407 |
|
// ------------------------------------------------------ |
5408 |
|
// ... a repetition is found ... |
5409 |
|
// ------------------------------------------------------ |
5410 |
|
path = (TString)row2->GetField(0); |
5411 |
|
name = (TString)row2->GetField(1); |
5412 |
|
raw = (TString)row2->GetField(5); |
5413 |
|
obt0 = (UInt_t)atoll(row2->GetField(2)); |
5414 |
|
timesync = (UInt_t)atoll(row2->GetField(3)); |
5415 |
|
boot_number = (UInt_t)atoll(row2->GetField(4)); |
5416 |
|
|
5417 |
|
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
5418 |
|
// cout << path <<endl; |
5419 |
|
cout << "File : " <<name <<endl; |
5420 |
|
// cout << obt0 <<endl; |
5421 |
|
// cout << timesync <<endl; |
5422 |
|
cout << "boot n. : "<<boot_number <<endl; |
5423 |
|
// cout << raw <<endl; |
5424 |
|
|
5425 |
|
// ------------------------------------------------------ |
5426 |
|
// ... retrieve the calibration packets. |
5427 |
|
// ------------------------------------------------------ |
5428 |
|
TFile *file = new TFile(path+"/"+name); |
5429 |
|
if(!file)throw -100; |
5430 |
|
if(file->IsZombie())throw -100; |
5431 |
|
// |
5432 |
|
tr1 = (TTree*)file->Get("CalibTrk1"); |
5433 |
|
if ( !tr1 || tr1->IsZombie() ) throw -22; |
5434 |
|
tr2 = (TTree*)file->Get("CalibTrk2"); |
5435 |
|
if ( !tr2 || tr2->IsZombie() ) throw -23; |
5436 |
|
// |
5437 |
|
tr1->SetBranchAddress("CalibTrk1", &caltrk1); |
5438 |
|
tr1->SetBranchAddress("Header", &eh1); |
5439 |
|
nevents1 = tr1->GetEntries(); |
5440 |
|
tr2->SetBranchAddress("CalibTrk2", &caltrk2); |
5441 |
|
tr2->SetBranchAddress("Header", &eh2); |
5442 |
|
nevents2 = tr2->GetEntries(); |
5443 |
|
for(this_t1=0; this_t1<nevents1; this_t1++){ |
5444 |
|
tr1->GetEntry(this_t1); |
5445 |
|
if( |
5446 |
|
(UInt_t)eh1->GetPscuHeader()->GetCounter() == pkt1 && |
5447 |
|
true) break; |
5448 |
|
this_MISSING_pkt1 = true; |
5449 |
|
} |
5450 |
|
for(this_t2=0; this_t2<nevents2; this_t2++){ |
5451 |
|
tr2->GetEntry(this_t2); |
5452 |
|
if( |
5453 |
|
(UInt_t)eh2->GetPscuHeader()->GetCounter() == pkt2 && |
5454 |
|
true) break; |
5455 |
|
this_MISSING_pkt2 = true; |
5456 |
|
} |
5457 |
|
this_valid = |
5458 |
|
ValidateTrkCalib( caltrk1, eh1, file ) |
5459 |
|
* |
5460 |
|
ValidateTrkCalib( caltrk2, eh2, file ); |
5461 |
|
|
5462 |
|
// --------------------------------------------------------------------- |
5463 |
|
// accept the calibration if it is better than the previous: |
5464 |
|
// |
5465 |
|
// - if the new calibration is perfect (both valid packets) |
5466 |
|
// - if the new calibration has both the packets and the previous does not |
5467 |
|
// --------------------------------------------------------------------- |
5468 |
|
if( |
5469 |
|
( !this_MISSING_pkt1&&!this_MISSING_pkt2&&this_valid )|| |
5470 |
|
( (MISSING_pkt1||MISSING_pkt2) && (!this_MISSING_pkt1&&!this_MISSING_pkt2) )|| |
5471 |
|
false)FOUND=true; |
5472 |
|
|
5473 |
|
if(file)file->Close(); |
5474 |
|
|
5475 |
|
if(FOUND)break; |
5476 |
|
|
5477 |
|
}while(1);//endl loop over root table entries |
5478 |
|
|
5479 |
|
if(FOUND)break; |
5480 |
|
|
5481 |
|
}//end loop over tables |
5482 |
|
|
5483 |
|
if(FOUND){ |
5484 |
|
|
5485 |
|
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
5486 |
|
|
5487 |
|
//////////////////////////////////////////// |
5488 |
|
// insert a new entry in GL_TRK_CALIB and |
5489 |
|
// modify the time-tag of the previous one |
5490 |
|
//////////////////////////////////////////// |
5491 |
|
|
5492 |
|
// --------------------------------------------------------------------- |
5493 |
|
// step 1: insert a new raw file in GL_RAW |
5494 |
|
// --------------------------------------------------------------------- |
5495 |
|
// |
5496 |
|
// check if the raw file already exist |
5497 |
|
// |
5498 |
|
UInt_t id_raw = 0; |
5499 |
|
oss.str(""); |
5500 |
|
oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
5501 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5502 |
|
|
5503 |
|
result = conn->Query(oss.str().c_str()); |
5504 |
|
if ( !result ) throw -4;; |
5505 |
|
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5506 |
|
if( result->GetRowCount() == 0){ |
5507 |
|
if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
5508 |
|
// - - - - - - - - - - - |
5509 |
|
// insert new raw file |
5510 |
|
// - - - - - - - - - - - |
5511 |
|
GL_RAW glraw = GL_RAW(); |
5512 |
|
glraw.PATH = gSystem->DirName(raw.Data()); |
5513 |
|
glraw.NAME = gSystem->BaseName(raw.Data()); |
5514 |
|
glraw.BOOT_NUMBER = boot_number; |
5515 |
|
// |
5516 |
|
insertPamelaRawFile( &glraw ); |
5517 |
|
// |
5518 |
|
id_raw = glraw.ID; |
5519 |
|
}else{ |
5520 |
|
row = result->Next(); |
5521 |
|
id_raw = (UInt_t)atoll(row->GetField(0)); |
5522 |
|
} |
5523 |
|
if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
5524 |
|
|
5525 |
|
// --------------------------------------------------------------------- |
5526 |
|
// step 1(bis): retrieve the timesync id associated to the file |
5527 |
|
// (NB, uso lo stesso associato al file iniziale) |
5528 |
|
// --------------------------------------------------------------------- |
5529 |
|
UInt_t idtimesync = 0; |
5530 |
|
oss.str(""); |
5531 |
|
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
5532 |
|
if ( debug ) printf(" %s \n",oss.str().c_str()); |
5533 |
|
result = conn->Query(oss.str().c_str()); |
5534 |
|
if ( !result ) throw -3; |
5535 |
|
row = result->Next(); |
5536 |
|
if ( !row ) throw -3; |
5537 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
5538 |
|
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
5539 |
|
|
5540 |
|
// --------------------------------------------------------------------- |
5541 |
|
// step 2: insert a new root file in GL_ROOT |
5542 |
|
// --------------------------------------------------------------------- |
5543 |
|
// |
5544 |
|
// check if the raw file already exist |
5545 |
|
// |
5546 |
|
UInt_t id_root = 0; |
5547 |
|
oss.str(""); |
5548 |
|
oss << "SELECT ID FROM GL_ROOT where NAME=\"" << gSystem->BaseName(name.Data()) <<"\";"; |
5549 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5550 |
|
|
5551 |
|
result = conn->Query(oss.str().c_str()); |
5552 |
|
if ( !result ) throw -4;; |
5553 |
|
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5554 |
|
if( result->GetRowCount() == 0){ |
5555 |
|
if ( IsDebug() ) cout << " << Insert new ROOT file >> "<<endl; |
5556 |
|
// - - - - - - - - - - - |
5557 |
|
// insert new root file |
5558 |
|
// - - - - - - - - - - - |
5559 |
|
GL_ROOT glroot = GL_ROOT(); |
5560 |
|
glroot.ID_RAW = id_raw; |
5561 |
|
glroot.ID_TIMESYNC = idtimesync; |
5562 |
|
glroot.PATH = path; |
5563 |
|
glroot.NAME = name; |
5564 |
|
// |
5565 |
|
insertPamelaRootFile( &glroot ); |
5566 |
|
// |
5567 |
|
id_root = glroot.ID; |
5568 |
|
}else{ |
5569 |
|
row = result->Next(); |
5570 |
|
if(row)id_root = (UInt_t)atoll(row->GetField(0)); |
5571 |
|
} |
5572 |
|
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
5573 |
|
|
5574 |
|
// --------------------------------------------------------------------- |
5575 |
|
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
5576 |
|
// --------------------------------------------------------------------- |
5577 |
|
if ( IsDebug() ) cout << " << Modify time-tag of calibration ID="<<id<<" >> "<<endl; |
5578 |
|
oss.str(""); |
5579 |
|
oss << " UPDATE GL_TRK_CALIB SET " |
5580 |
|
<< " TO_TIME=0 , FROM_TIME=0 WHERE " |
5581 |
|
<< " ID = "<< id << ";"; |
5582 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5583 |
|
result = conn->Query(oss.str().c_str()); |
5584 |
|
if ( !result ) throw -4;; |
5585 |
|
|
5586 |
|
// --------------------------------------------------------------------- |
5587 |
|
// step 4: insert the new calibration: |
5588 |
|
// --------------------------------------------------------------------- |
5589 |
|
if ( IsDebug() ) cout << " << Insert new TRK calibration >> "<<endl; |
5590 |
|
// |
5591 |
|
GL_TRK_CALIB glcal = GL_TRK_CALIB(); |
5592 |
|
// |
5593 |
|
glcal.ID_ROOT_L0 = id_root; |
5594 |
|
glcal.EV_ROOT_CALIBTRK1 = this_t1; |
5595 |
|
glcal.EV_ROOT_CALIBTRK2 = this_t2; |
5596 |
|
glcal.FROM_TIME = fromtime; |
5597 |
|
glcal.TO_TIME = totime; |
5598 |
|
glcal.OBT1 = obt1; |
5599 |
|
glcal.OBT2 = obt2; |
5600 |
|
glcal.PKT1 = pkt1; |
5601 |
|
glcal.PKT2 = pkt1; |
5602 |
|
glcal.BOOT_NUMBER = GetBOOTnumber(); |
5603 |
|
glcal.VALIDATION = this_valid; |
5604 |
|
// |
5605 |
|
HandleTRK_CALIB(&glcal); |
5606 |
|
if ( IsDebug() ) cout << "ID = "<<glcal.ID<<endl; |
5607 |
|
// |
5608 |
|
|
5609 |
|
} |
5610 |
|
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
5611 |
|
|
5612 |
|
}while(1);//end loop over calibrations |
5613 |
|
|
5614 |
|
|
5615 |
|
if( result )delete result; |
5616 |
|
if( row )delete row; |
5617 |
|
|
5618 |
|
|
5619 |
|
|
5620 |
|
|
5621 |
|
|
5622 |
|
|
5623 |
|
} |
5624 |
|
|
5625 |
|
|
5626 |
|
// // ------------------------------ |
5627 |
|
// // try to recover the calibration |
5628 |
|
// // ------------------------------ |
5629 |
|
// cout << "TRY TO RECOVER TRACKER CALIBRATION"<<endl; |
5630 |
|
// // |
5631 |
|
// ULong64_t time = 0; //absolute time |
5632 |
|
// string path[100]; //mettere un limite massimo |
5633 |
|
// int nrows = 0; |
5634 |
|
// UInt_t pkt = 0; |
5635 |
|
// UInt_t obt = 0; |
5636 |
|
// char *type = ""; |
5637 |
|
// EventHeader *eh = new EventHeader(); |
5638 |
|
// CalibTrk1Event *c = new CalibTrk1Event(); |
5639 |
|
|
5640 |
|
// // |
5641 |
|
// if(which_is_not_valid==1 || which_is_not_valid==3){ |
5642 |
|
// // |
5643 |
|
// cout << "PKT1 --> missing or corrupted "<<endl; |
5644 |
|
// type = "CalibTrk1"; |
5645 |
|
// pkt = pkt1; |
5646 |
|
// obt = obt1; |
5647 |
|
// time = this->GetAbsTime(obt1); |
5648 |
|
// if( pkt1 == 0 ){//missing |
5649 |
|
// time = this->GetAbsTime(obt2); |
5650 |
|
// pkt = pkt2-1; |
5651 |
|
// } |
5652 |
|
// // |
5653 |
|
// }else if (which_is_not_valid==2 || which_is_not_valid==3){ |
5654 |
|
// // |
5655 |
|
// cout << "PKT2--> missing or corrupted "<<endl; |
5656 |
|
// type = "CalibTrk2 "; |
5657 |
|
// pkt = pkt2; |
5658 |
|
// obt = obt2; |
5659 |
|
// time = this->GetAbsTime(obt2); |
5660 |
|
// if( pkt2 == 0 ){//missing |
5661 |
|
// time = this->GetAbsTime(obt1); |
5662 |
|
// pkt = pkt1+1; |
5663 |
|
// } |
5664 |
|
// // |
5665 |
|
// }else{ |
5666 |
|
// cout << "this should not happen!!! "<<endl; |
5667 |
|
// trow -666; |
5668 |
|
// } |
5669 |
|
|
5670 |
|
// nrows = Query_ROOT_TABLE(time,conn,path);// get the list of file which might contain the packet |
5671 |
|
|
5672 |
|
|
5673 |
|
// for(int r=0; r<nrows; r++){ //loop over rows |
5674 |
|
// if(path)cout << r << " >>>> "<<(path+r)->c_str() << endl; |
5675 |
|
// /// verifica che il file non sia quello gia` aperto |
5676 |
|
// } |
5677 |
|
|
5678 |
|
// //////////////////////////////////////////////////////////////////////// |
5679 |
|
|
5680 |
|
// TSQLResult *result = 0; |
5681 |
|
// TSQLRow *row = 0; |
5682 |
|
// // |
5683 |
|
// stringstream oss; |
5684 |
|
// oss.str(""); |
5685 |
|
// // ---------------------------------------- |
5686 |
|
// // read the id of last calibration inserted |
5687 |
|
// // ---------------------------------------- |
5688 |
|
// oss.str(""); |
5689 |
|
// oss << " SELECT "; |
5690 |
|
// oss << " (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) "; |
5691 |
|
// oss << " ORDER BY ID DESC LIMIT 1; "; |
5692 |
|
|
5693 |
|
// result = conn->Query(oss.str().c_str()); |
5694 |
|
// row = result->Next(); |
5695 |
|
// if( !row )throw -666; |
5696 |
|
|
5697 |
|
// if( result )delete result; |
5698 |
|
// if( row )delete row; |
5699 |
|
|
5700 |
|
// UInt_t id = (UInt_t)atoll(row->GetField(0)); |
5701 |
|
|
5702 |
|
// // ------------------------------------- |
5703 |
|
// // ...and modify it with new parameters |
5704 |
|
// // ------------------------------------- |
5705 |
|
|
5706 |
|
|
5707 |
|
// } |
5708 |
// |
// |
5709 |
return(0); |
return(0); |
5710 |
}; |
}; |
6535 |
|
|
6536 |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
6537 |
|
|
6538 |
// get the closest VALIDATED calibration before the run start (t2) |
// get the closest calibration before the run start (t2) |
6539 |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
6540 |
|
|
6541 |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
7229 |
* Rearrange calibration tables |
* Rearrange calibration tables |
7230 |
* |
* |
7231 |
**/ |
**/ |
7232 |
UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){ |
UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh , TFile *file){ |
7233 |
|
|
7234 |
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
if(!caltrk) return 0; |
|
UInt_t timeaftercalib=120000; //2000; |
|
|
// ---------- |
|
|
// Check CRCs |
|
|
// ---------- |
|
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
|
|
if( caltrk->crc_hcal[ipkt] )return 0; // :-( |
|
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-( |
|
|
} |
|
|
// ----------------------- |
|
|
// Check missing packets: |
|
|
// ----------------------- |
|
|
// Readout order: |
|
|
// ------------------ |
|
|
// DSP packet board |
|
|
// ------------------ |
|
|
// 12 0 1 |
|
|
// 10 1 1 |
|
|
// 8 2 1 |
|
|
// 4 3 1 |
|
|
// 6 4 1 |
|
|
// 2 5 1 |
|
|
// ------------------ |
|
|
// 11 0 2 |
|
|
// 9 1 2 |
|
|
// 7 2 2 |
|
|
// 3 3 2 |
|
|
// 5 4 2 |
|
|
// 1 5 2 |
|
|
// ------------------ |
|
|
// ------------------------------------------------- |
|
|
// Check if it is first or second calibration packet |
|
|
// ------------------------------------------------- |
|
|
UInt_t build=0; |
|
|
TString classname = caltrk->GetName(); |
|
|
UInt_t base=0; |
|
|
UInt_t mask=0; |
|
|
if(classname.Contains("CalibTrk1Event")){ |
|
|
base=12; |
|
|
mask=0x03F000; |
|
|
} |
|
|
if(classname.Contains("CalibTrk2Event")){ |
|
|
base=18; |
|
|
mask=0xFC0000; |
|
|
} |
|
|
// ------------------------------------------------- |
|
|
// Count number of packets and set build variable |
|
|
// ------------------------------------------------- |
|
|
Int_t npkts=0; |
|
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
|
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
|
|
npkts++; |
|
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
|
|
} |
|
|
} |
|
|
// if( npkts==6 )return 1; // :-) |
|
7235 |
|
|
7236 |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
if ( IsDebug() ) cout << "ValidateTrkCalib:"<<endl; |
7237 |
|
|
7238 |
// ----------------------------------------------- |
UInt_t validate = 1; |
7239 |
// If missing packets: check the acq configuration |
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
7240 |
// (some DSPs might be excluded from acquisition) |
UInt_t timeaftercalib=120000; //2000; |
7241 |
// ----------------------------------------------- |
TString classname = caltrk->GetName(); |
7242 |
|
|
7243 |
// ----------------------------------------------- |
// ---------------------------------- |
7244 |
// retrieve the first run header after calib |
// Check CRCs and failed calibrations |
7245 |
// ----------------------------------------------- |
// ---------------------------------- |
7246 |
PacketType *pctp; |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
7247 |
EventCounter *cod; |
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
7248 |
cod = eh->GetCounter(); |
if( caltrk->crc_hcal[ipkt] ){ |
7249 |
Int_t irun = cod->Get(pctp->RunHeader); |
// if(IsDebug())cout<<"(CRC Header)"; |
7250 |
TTree *rh=(TTree*)file->Get("RunHeader"); |
validate = 0; |
7251 |
if ( !rh || rh->IsZombie() ) throw -17; |
if(IsDebug())cout <<endl<<" *** CRC *** (header DSPn "<<caltrk->DSPnumber[ipkt]<<")"; |
7252 |
if( rh->GetEntries() == irun ){ |
|
7253 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
} |
7254 |
return 0; // :-( |
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
7255 |
} |
// if(IsDebug())cout<<"(CRC Pkt-"<<ilad<<")"; |
7256 |
|
if(IsDebug())cout <<endl<<" *** CRC *** (data DSPn "<<caltrk->DSPnumber[ipkt]<<" ladder "<<ilad<<")"; |
7257 |
|
validate = 0; |
7258 |
|
} |
7259 |
|
if( !(caltrk->ncalib_event[ipkt]==0 && caltrk->cal_flag[ipkt]==0) ){ |
7260 |
|
if(IsDebug())cout <<endl<<" *** FAILURE *** (data DSPn "<<caltrk->DSPnumber[ipkt]<<")"; |
7261 |
|
validate = 0; |
7262 |
|
} |
7263 |
|
}else{ |
7264 |
|
// validate=0; |
7265 |
|
if(IsDebug())cout <<endl<<" *** DSPn *** ("<< caltrk->DSPnumber[ipkt] <<" @pkt "<<ipkt<<")"; |
7266 |
|
} |
7267 |
|
} |
7268 |
|
|
7269 |
RunHeaderEvent *run = 0; |
// ----------------------- |
7270 |
EventHeader *hrun = 0; |
// Check missing packets: |
7271 |
rh->SetBranchAddress("RunHeader", &run); |
// ----------------------- |
7272 |
rh->SetBranchAddress("Header", &hrun); |
// Readout order: |
7273 |
rh->GetEntry(irun); |
// ------------------ |
7274 |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
// DSP packet board |
7275 |
|
// ------------------ |
7276 |
if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
// 12 0 1 |
7277 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
// 10 1 1 |
7278 |
return 0; // :-( |
// 8 2 1 |
7279 |
} |
// 4 3 1 |
7280 |
|
// 6 4 1 |
7281 |
if( !run->RM_ACQ_AFTER_CALIB ){ |
// 2 5 1 |
7282 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
// ------------------ |
7283 |
return 0; // :-( |
// 11 0 2 |
7284 |
} |
// 9 1 2 |
7285 |
|
// 7 2 2 |
7286 |
|
// 3 3 2 |
7287 |
|
// 5 4 2 |
7288 |
|
// 1 5 2 |
7289 |
|
// ------------------ |
7290 |
|
// ------------------------------------------------- |
7291 |
|
// Check if it is first or second calibration packet |
7292 |
|
// ------------------------------------------------- |
7293 |
|
UInt_t build=0; |
7294 |
|
UInt_t base=0; |
7295 |
|
UInt_t mask=0; |
7296 |
|
if(classname.Contains("CalibTrk1Event")){ |
7297 |
|
base=12; |
7298 |
|
mask=0x03F000; |
7299 |
|
} |
7300 |
|
if(classname.Contains("CalibTrk2Event")){ |
7301 |
|
base=18; |
7302 |
|
mask=0xFC0000; |
7303 |
|
} |
7304 |
|
// ---------------------------------------------------- |
7305 |
|
// Count number of valid packets and set build variable |
7306 |
|
// ---------------------------------------------------- |
7307 |
|
if(IsDebug())cout <<endl<< " DSP: "; |
7308 |
|
Int_t npkts=0; |
7309 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
7310 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
7311 |
|
if(IsDebug())cout <<" "<<caltrk->DSPnumber[ipkt]; |
7312 |
|
npkts++; |
7313 |
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
7314 |
|
// cout << caltrk->DSPnumber[ipkt] |
7315 |
|
}; |
7316 |
|
} |
7317 |
|
if(IsDebug())cout << " ==> "<< hex << build << dec; |
7318 |
|
// ---------------------------------------------------- |
7319 |
|
// If the number of valid packets is 6, ok exit... |
7320 |
|
// ---------------------------------------------------- |
7321 |
|
if( npkts==6 ){ |
7322 |
|
return validate; // exit |
7323 |
|
} |
7324 |
|
//////////////////////////////////////////////////////// |
7325 |
|
// ...otherwise there might be some missing packets |
7326 |
|
// |
7327 |
|
// In this case check the acq configuration |
7328 |
|
// (some DSPs might be excluded from acquisition) |
7329 |
|
//////////////////////////////////////////////////////// |
7330 |
|
|
7331 |
|
if(!eh || !file || (file&&file->IsZombie()) ){ |
7332 |
|
if ( IsDebug() )cout << " *** MISSING VIEW *** eh="<<eh<<" file="<<file<<" cannot validate"<<endl; |
7333 |
|
return (0); |
7334 |
|
} |
7335 |
|
|
7336 |
|
// ----------------------------------------------- |
7337 |
|
// retrieve the first run header after calib |
7338 |
|
// ----------------------------------------------- |
7339 |
|
|
7340 |
|
PacketType *pctp; |
7341 |
|
EventCounter *cod; |
7342 |
|
cod = eh->GetCounter(); |
7343 |
|
Int_t irun = cod->Get(pctp->RunHeader); |
7344 |
|
TTree *rh=(TTree*)file->Get("RunHeader"); |
7345 |
|
if ( !rh || rh->IsZombie() ) throw -17; |
7346 |
|
if( rh->GetEntries() <= irun ){ |
7347 |
|
if ( IsDebug() ) cout << " *** MISSING-PKT *** no runs after calib (1) -- cannot validate :-( "<<endl; |
7348 |
|
return 0; // :-( |
7349 |
|
} |
7350 |
|
RunHeaderEvent *run = 0; |
7351 |
|
EventHeader *hrun = 0; |
7352 |
|
rh->SetBranchAddress("RunHeader", &run); |
7353 |
|
rh->SetBranchAddress("Header", &hrun); |
7354 |
|
rh->GetEntry(irun); |
7355 |
|
if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
7356 |
|
if ( IsDebug() ) cout << " *** MISSING-PKT *** no runs after calib (2) -- cannot validate :-( "<<endl; |
7357 |
|
return 0; // :-( |
7358 |
|
} |
7359 |
|
|
7360 |
UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
7361 |
if( dtime > timeaftercalib ){ |
if( dtime > timeaftercalib ){ |
7362 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
if ( IsDebug() ) cout << " *** MISSING-PKT *** run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
7363 |
return 0; // :-( |
return 0; // :-( |
7364 |
} |
} |
|
|
|
7365 |
|
|
7366 |
|
if ( IsDebug() ) cout <<endl<< " ACQ_BUILD_INFO ==> "<<hex<<(run->ACQ_BUILD_INFO & mask)<<dec; |
7367 |
|
|
7368 |
|
if( (run->ACQ_BUILD_INFO & mask) != build ){ |
7369 |
|
validate=0; // :-( |
7370 |
|
cout <<endl<< " *** MISSING-PKT *** packet mismatch: ACQ_BUILD_INFO="<<hex<<(run->ACQ_BUILD_INFO&mask)<<" != "<<build<<dec; |
7371 |
|
}; |
7372 |
|
|
7373 |
|
return validate; |
7374 |
|
|
|
if( (run->ACQ_BUILD_INFO & mask) != build ){ |
|
|
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
|
|
return 0; // :-( |
|
|
} |
|
|
return 1; // :-) |
|
7375 |
|
|
7376 |
} |
} |
7377 |
|
// UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){ |
7378 |
|
|
7379 |
|
// if(!caltrk || !eh) return 0; |
7380 |
|
|
7381 |
|
// Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
7382 |
|
// UInt_t timeaftercalib=120000; //2000; |
7383 |
|
// // ---------- |
7384 |
|
// // Check CRCs |
7385 |
|
// // ---------- |
7386 |
|
// for(Int_t ipkt=0; ipkt<6; ipkt++){ |
7387 |
|
// if( caltrk->crc_hcal[ipkt] )return 0; // :-( |
7388 |
|
// for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-( |
7389 |
|
// } |
7390 |
|
// // ----------------------- |
7391 |
|
// // Check missing packets: |
7392 |
|
// // ----------------------- |
7393 |
|
// // Readout order: |
7394 |
|
// // ------------------ |
7395 |
|
// // DSP packet board |
7396 |
|
// // ------------------ |
7397 |
|
// // 12 0 1 |
7398 |
|
// // 10 1 1 |
7399 |
|
// // 8 2 1 |
7400 |
|
// // 4 3 1 |
7401 |
|
// // 6 4 1 |
7402 |
|
// // 2 5 1 |
7403 |
|
// // ------------------ |
7404 |
|
// // 11 0 2 |
7405 |
|
// // 9 1 2 |
7406 |
|
// // 7 2 2 |
7407 |
|
// // 3 3 2 |
7408 |
|
// // 5 4 2 |
7409 |
|
// // 1 5 2 |
7410 |
|
// // ------------------ |
7411 |
|
// // ------------------------------------------------- |
7412 |
|
// // Check if it is first or second calibration packet |
7413 |
|
// // ------------------------------------------------- |
7414 |
|
// UInt_t build=0; |
7415 |
|
// TString classname = caltrk->GetName(); |
7416 |
|
// UInt_t base=0; |
7417 |
|
// UInt_t mask=0; |
7418 |
|
// if(classname.Contains("CalibTrk1Event")){ |
7419 |
|
// base=12; |
7420 |
|
// mask=0x03F000; |
7421 |
|
// } |
7422 |
|
// if(classname.Contains("CalibTrk2Event")){ |
7423 |
|
// base=18; |
7424 |
|
// mask=0xFC0000; |
7425 |
|
// } |
7426 |
|
// // ------------------------------------------------- |
7427 |
|
// // Count number of packets and set build variable |
7428 |
|
// // ------------------------------------------------- |
7429 |
|
// Int_t npkts=0; |
7430 |
|
// for(Int_t ipkt=0; ipkt<6; ipkt++){ |
7431 |
|
// if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
7432 |
|
// npkts++; |
7433 |
|
// build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
7434 |
|
// } |
7435 |
|
// } |
7436 |
|
// // if( npkts==6 )return 1; // :-) |
7437 |
|
|
7438 |
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
7439 |
|
|
7440 |
|
// // ----------------------------------------------- |
7441 |
|
// // If missing packets: check the acq configuration |
7442 |
|
// // (some DSPs might be excluded from acquisition) |
7443 |
|
// // ----------------------------------------------- |
7444 |
|
|
7445 |
|
// // ----------------------------------------------- |
7446 |
|
// // retrieve the first run header after calib |
7447 |
|
// // ----------------------------------------------- |
7448 |
|
// PacketType *pctp; |
7449 |
|
// EventCounter *cod; |
7450 |
|
// cod = eh->GetCounter(); |
7451 |
|
// Int_t irun = cod->Get(pctp->RunHeader); |
7452 |
|
// TTree *rh=(TTree*)file->Get("RunHeader"); |
7453 |
|
// if ( !rh || rh->IsZombie() ) throw -17; |
7454 |
|
// if( rh->GetEntries() == irun ){ |
7455 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
7456 |
|
// return 0; // :-( |
7457 |
|
// } |
7458 |
|
|
7459 |
|
// RunHeaderEvent *run = 0; |
7460 |
|
// EventHeader *hrun = 0; |
7461 |
|
// rh->SetBranchAddress("RunHeader", &run); |
7462 |
|
// rh->SetBranchAddress("Header", &hrun); |
7463 |
|
// rh->GetEntry(irun); |
7464 |
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
7465 |
|
|
7466 |
|
// if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
7467 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
7468 |
|
// return 0; // :-( |
7469 |
|
// } |
7470 |
|
|
7471 |
|
// if( !run->RM_ACQ_AFTER_CALIB ){ |
7472 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
7473 |
|
// return 0; // :-( |
7474 |
|
// } |
7475 |
|
|
7476 |
|
// UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
7477 |
|
// if( dtime > timeaftercalib ){ |
7478 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
7479 |
|
// return 0; // :-( |
7480 |
|
// } |
7481 |
|
|
7482 |
|
|
7483 |
|
|
7484 |
|
// if( (run->ACQ_BUILD_INFO & mask) != build ){ |
7485 |
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
7486 |
|
// return 0; // :-( |
7487 |
|
// } |
7488 |
|
// return 1; // :-) |
7489 |
|
|
7490 |
|
// } |
7491 |
|
|
7492 |
/** |
/** |
7493 |
* |
* |