FEDRA emulsion software from the OPERA Collaboration
EdbScan2DB Class Reference

#include <TOracleServerE2WX.h>

Inheritance diagram for EdbScan2DB:
Collaboration diagram for EdbScan2DB:

Public Member Functions

void AddBrick (EdbScanProc &sproc)
 
ULong64_t AddHeaderOperation (const char *note)
 
void DumpListOfHeaderOperations ()
 
 EdbScan2DB ()
 
int InitDB (const char *conn, const char *user, const char *pwd)
 
void LoadCalibration (EdbScanProc &sproc, EdbID edbid)
 
ULong64_t LoadCalibrationZone (EdbScanProc &sproc, EdbID edbid, ULong64_t operation)
 
void LoadPrediction (EdbScanProc &sproc, EdbID edbid)
 
void LoadSBData (EdbScanProc &sproc, EdbID id, ULong64_t operation)
 
void LoadSBDataOld (EdbScanProc &sproc, EdbID id, ULong64_t operation)
 
void LoadVolume (EdbScanProc &sproc, EdbID edbid, EdbID idstop)
 
ULong64_t LoadZone (EdbSegP &s, int plate, ULong64_t operation, ULong64_t series, const char *cmt)
 
void Print ()
 
 ~EdbScan2DB ()
 

Public Attributes

ULong64_t eBrick
 
ULong64_t eCalibrationHeaderOperation
 
ULong64_t eCalibrationProgramsettings
 
TOracleServerE2WXeDB
 
Int_t eERROR
 
ULong64_t eEvent
 
ULong64_t eEventBrick
 
ULong64_t eFeedbackProgramsettings
 
ULong64_t eHeaderProgramsettings
 
TString eID_SET
 
ULong64_t eIdMachine
 
Int_t eIDPATH
 
ULong64_t eIdRequester
 
Int_t eIsBlackCS
 
ULong64_t ePredictionHeaderOperation
 
ULong64_t ePredictionProgramsettings
 
ULong64_t eVolumeHeaderOperation
 
ULong64_t eVolumeProgramsettings
 
Bool_t eWriteRawCalibrationData
 
Int_t eX_marks
 

Constructor & Destructor Documentation

◆ EdbScan2DB()

EdbScan2DB::EdbScan2DB ( )
976 {
977  eX_marks=0;
979  eDB=0;
980  eBrick=0;
981  eEvent=0;
982  eEventBrick=0;
983  eIsBlackCS=0;
984  eIDPATH=-1;
985  eIdMachine=0;
986  eIdRequester=0;
995  eERROR=0;
996 }
ULong64_t eCalibrationProgramsettings
Definition: TOracleServerE2WX.h:113
ULong64_t ePredictionHeaderOperation
Definition: TOracleServerE2WX.h:118
ULong64_t eCalibrationHeaderOperation
Definition: TOracleServerE2WX.h:117
Bool_t eWriteRawCalibrationData
Definition: TOracleServerE2WX.h:124
ULong64_t eEvent
Definition: TOracleServerE2WX.h:106
Int_t eX_marks
Definition: TOracleServerE2WX.h:121
Int_t eERROR
Definition: TOracleServerE2WX.h:128
ULong64_t eHeaderProgramsettings
Definition: TOracleServerE2WX.h:112
ULong64_t eIdRequester
Definition: TOracleServerE2WX.h:111
ULong64_t eBrick
Definition: TOracleServerE2WX.h:104
Int_t eIsBlackCS
Definition: TOracleServerE2WX.h:107
ULong64_t eIdMachine
Definition: TOracleServerE2WX.h:110
ULong64_t eFeedbackProgramsettings
Definition: TOracleServerE2WX.h:116
ULong64_t eEventBrick
Definition: TOracleServerE2WX.h:105
ULong64_t eVolumeProgramsettings
Definition: TOracleServerE2WX.h:115
TOracleServerE2WX * eDB
Definition: TOracleServerE2WX.h:102
Int_t eIDPATH
Definition: TOracleServerE2WX.h:108
ULong64_t eVolumeHeaderOperation
Definition: TOracleServerE2WX.h:119
ULong64_t ePredictionProgramsettings
Definition: TOracleServerE2WX.h:114

◆ ~EdbScan2DB()

EdbScan2DB::~EdbScan2DB ( )
inline
132 {}

Member Function Documentation

◆ AddBrick()

void EdbScan2DB::AddBrick ( EdbScanProc sproc)
1579 {
1580  Log(2,"EdbScan2DB::AddBrick","%d",eEventBrick);
1581  if(eDB->IfEventBrick( eEventBrick, eID_SET.Data()))
1582  {
1583  Log(2,"EdbScan2DB::AddBrick","%d is already in DB, do nothing",eEventBrick);
1584  if(!eDB->TestLoad()) return;
1585  }
1586 
1587  //========== Loading X ray mark sets in global RS to get ZEROX,ZEROY ===========//
1588  EdbMarksSet msXG;
1589  sproc.ReadMarksSet(msXG,eBrick,"map.XG",'_','S');
1590  float ZEROX = msXG.eXmin;
1591  float ZEROY = msXG.eYmin;
1592 
1593  //========== Loading Optical ray mark sets in local (and corrected) RS to get brick dimension ==========//
1594  EdbMarksSet msOL;
1595  if (eX_marks) sproc.ReadMarksSet(msOL,eBrick,"map.LL",'_','L');
1596  else sproc.ReadMarksSet(msOL,eBrick,"map.OL",'_','S');
1597  float MINX = msOL.eXmin + ZEROX;
1598  float MAXX = msOL.eXmax + ZEROX;
1599  float MINY = msOL.eYmin + ZEROY;
1600  float MAXY = msOL.eYmax + ZEROY;
1601  float MINZ = -72800.;
1602  float MAXZ = 0.;
1603  float ZEROZ = MAXZ;
1604  const char *BS_ID = eID_SET.Data();
1605 
1606  if( eDB->AddEventBrick(Form(
1607  "%d, %12.2f, %12.2f, %12.2f, %12.2f, %12.2f, %12.2f, %s, %d, %12.2f, %12.2f, %12.2f",
1608  eEventBrick, MINX, MAXX, MINY, MAXY, MINZ, MAXZ, BS_ID, eBrick, ZEROX, ZEROY, ZEROZ
1609  )) )
1610  {
1611  //========== Adding template mark sets ==========//
1612  EdbMarksBox *mbOL = msOL.GetAbsolute();
1613  for (int imarks=0;imarks<mbOL->GetN();imarks++)
1614  {
1615  EdbMark *mark = mbOL->GetMark(imarks);
1616  const char *shape = eX_marks? "'L'" : "'S'";
1617  eDB->AddTemplateMarkSets(Form(
1618  "%lld, %d, %f, %f, %d, %d, %s, %d",
1619  eEventBrick,
1620  mark->GetID(),
1621  mark->GetX(),
1622  mark->GetY(),
1623  1,2, //markrow, markcol (boh...)
1624  shape,
1625  mark->Flag()
1626  ));
1627  }
1628  //========== Adding plates ======================//
1629  TString filename=Form("%s/b%06d/b%06d.geometry",sproc.eProcDirClient.Data(),eBrick,eBrick);
1630  FILE *fp=0;
1631  if ((fp=fopen( filename.Data(), "r" ))==NULL) {
1632  Log(1,"AddBrick","ERROR! Cannot open file %s",filename); return;
1633  }
1634  while (!feof(fp))
1635  {
1636  int iplate;
1637  float z;
1638  if (fscanf(fp,"%d %f",&iplate,&z)!=2) continue;
1639  char dataplate[50];
1640  sprintf(dataplate,"%d, %12.2f",iplate, z);
1641  eDB->AddPlate( eEventBrick, dataplate);
1642  }
1643  }
1644  else eERROR++;
1645 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
Definition: EdbFiducial.h:21
Float_t GetY() const
Definition: EdbFiducial.h:36
Float_t GetX() const
Definition: EdbFiducial.h:35
Int_t Flag() const
Definition: EdbFiducial.h:39
Int_t GetID() const
Definition: EdbFiducial.h:34
Definition: EdbFiducial.h:55
Int_t GetN() const
Definition: EdbFiducial.cxx:703
EdbMark * GetMark(int i) const
Definition: EdbFiducial.cxx:709
Definition: EdbFiducial.h:88
EdbMarksBox * GetAbsolute() const
Definition: EdbFiducial.h:109
Float_t eXmin
Definition: EdbFiducial.h:96
Float_t eYmin
Definition: EdbFiducial.h:97
Float_t eYmax
Definition: EdbFiducial.h:97
Float_t eXmax
Definition: EdbFiducial.h:96
TString eID_SET
Definition: TOracleServerE2WX.h:109
TString eProcDirClient
Definition: EdbScanProc.h:14
int ReadMarksSet(EdbMarksSet &ms, int brick, const char *filename, char spacer='_', char shape='S')
Definition: EdbScanProc.cxx:3099
ULong64_t IfEventBrick(ULong64_t id_eventbrick, const char *id_set)
Definition: TOracleServerE2WX.cxx:196
Int_t AddTemplateMarkSets(char *datamarks)
Definition: TOracleServerE2WX.cxx:658
Int_t AddPlate(ULong64_t id_eventbrick, const char *dataplate)
Definition: TOracleServerE2WX.cxx:249
Int_t AddEventBrick(const char *str)
Definition: TOracleServerE2WX.cxx:182
Bool_t TestLoad()
Definition: TOracleServerE2WX.h:34
EdbScanProc * sproc
Definition: comptonmap.cpp:29
string filename
Definition: emthickness.cpp:34
#define NULL
Definition: nidaqmx.h:84

◆ AddHeaderOperation()

ULong64_t EdbScan2DB::AddHeaderOperation ( const char *  note = "")
1035 {
1036  return eDB->AddProcessOperation(
1037  eIdMachine,
1039  eIdRequester,
1040  0, // id_parent_operation
1041  eEventBrick,
1042  0, // id_plate
1043  2, // driverlevel
1044  0, // Id_plate_calibrations : Null on Header Operation
1045  eDB->Timestamp(), // starttime
1046  eDB->Timestamp(), // finishtime
1047  "'Y'",
1048  notes // notes
1049  );
1050 }
const char * Timestamp()
Definition: TOracleServerE2WX.cxx:38
ULong64_t AddProcessOperation(ULong64_t id_machine, ULong64_t id_programsettings, ULong64_t id_requester, ULong64_t id_parent_operation, ULong64_t id_eventbrick, Int_t id_plate, Int_t driverlevel, ULong64_t id_calibration, const char *starttime, const char *finishtime, const char *success, const char *notes)
Definition: TOracleServerE2WX.cxx:142

◆ DumpListOfHeaderOperations()

void EdbScan2DB::DumpListOfHeaderOperations ( )
1649 {
1650  eDB->MyQuery( Form(
1651  "select ID,to_char(starttime),to_char(notes) from opera.tb_proc_operations where \
1652  id_eventbrick=%lld and id_programsettings=%s",
1653  eEventBrick,
1655  ));
1656  eDB->MyQuery( Form(
1657  "select ID,to_char(starttime),to_char(notes) from opera.tb_proc_operations where \
1658  id_eventbrick=%lld and id_programsettings=%s",
1659  eEventBrick,
1661  ));
1662 }
Int_t MyQuery(const char *sqlquery)
Definition: TOracleServerE2WX.cxx:57
const char * Ostr(ULong64_t num)

◆ InitDB()

int EdbScan2DB::InitDB ( const char *  conn,
const char *  user,
const char *  pwd 
)
1026 {
1027  eDB = new TOracleServerE2WX( conn, user, pwd );
1028  if(!eDB) return 0;
1029  eDB->SetTransactionRW();
1030  return 1;
1031 }
Definition: TOracleServerE2WX.h:14
Int_t SetTransactionRW()
Definition: TOracleServerE2WX.h:56

◆ LoadCalibration()

void EdbScan2DB::LoadCalibration ( EdbScanProc sproc,
EdbID  edbid 
)
1418 {
1419  Log( 2,"EdbScan2DB::LoadCalibration","Load dataset: %s",edbid.AsString() );
1420  if(!eDB) return;
1421 
1423 
1425  if(ss)
1426  {
1427  int n = ss->eIDS.GetEntries();
1428  for(int i=0; i<n; i++)
1429  {
1430  EdbID *id = ss->GetID(i);
1431  EdbPlateP *plate = ss->GetPlate(id->ePlate);
1432  if(plate)
1433  {
1434  ULong64_t plateCalibrationOperation = eDB->AddProcessOperation(
1435  eIdMachine,
1437  eIdRequester,
1438  eCalibrationHeaderOperation, // id_parent_operation
1439  eEventBrick,
1440  id->ePlate, // id_plate
1441  1, // driverlevel
1442  0, // calibration operation : NULL for Header Operation
1443  eDB->Timestamp(), // starttime
1444  eDB->Timestamp(), // finishtime
1445  "'Y'",
1446  "Calibration area" // notes
1447  );
1448  eDB->AddPlateCalibration(eEventBrick, plateCalibrationOperation, plate); // load Aff
1449 
1451  ULong64_t id_calib_zone = LoadCalibrationZone( sproc, *id, plateCalibrationOperation );
1452  //
1453  //========== Adding views and their microtracks ==========//
1454  EdbRunTracking rt;
1455  rt.ePredictionScan=true;
1456  sproc.InitRunAccess( rt, *id );
1457  eDB->AddViews(rt, eEventBrick, id_calib_zone, true);
1458  int nvpa = rt.GetNviewsPerArea();
1459  //
1460  //========= Adding basetracks assuming that microtracks already added ==========//
1461  EdbDataPiece dp;
1462  sproc.MakeFileName(dp.eFileNameCP,*id,"cp.root");
1463  dp.InitCouplesTree();
1464  eDB->AddBaseTracks(dp.eCouplesTree, eEventBrick, id_calib_zone, nvpa, true);
1465  dp.CloseCPData();
1466  }
1467  }
1468  }
1469  }
1470 }
Definition: EdbDataSet.h:25
int InitCouplesTree(const char *mode="READ")
Definition: EdbDataSet.cxx:1244
TString eFileNameCP
root-style text cuts
Definition: EdbDataSet.h:49
void CloseCPData()
Definition: EdbDataSet.cxx:91
TTree * eCouplesTree
Definition: EdbDataSet.h:54
Definition: EdbID.h:7
char * AsString() const
Definition: EdbID.cxx:24
Definition: EdbBrick.h:13
Int_t GetNviewsPerArea()
Definition: EdbRunAccess.h:108
Definition: EdbRunTracking.h:18
bool ePredictionScan
Definition: EdbRunTracking.h:61
ULong64_t AddHeaderOperation(const char *note)
Definition: TOracleServerE2WX.cxx:1034
ULong64_t LoadCalibrationZone(EdbScanProc &sproc, EdbID edbid, ULong64_t operation)
Definition: TOracleServerE2WX.cxx:1053
EdbScanSet * ReadScanSetGlobal(EdbID id, bool x_marks)
Definition: EdbScanProc.cxx:1480
bool InitRunAccess(EdbRunAccess &ra, int id[4], bool do_update=false)
Definition: EdbScanProc.cxx:2383
void MakeFileName(TString &s, int id[4], const char *suffix, bool inplate=true)
Definition: EdbScanProc.cxx:1885
Definition: EdbScanSet.h:11
Int_t AddViews(EdbRunTracking &rt, ULong64_t id_eventbrick, ULong64_t id_zone, bool usebuffer=true)
Definition: TOracleServerE2WX.cxx:260
Int_t AddBaseTracks(TTree *tree, ULong64_t id_eventbrick, ULong64_t id_zone, Int_t nvpa, bool usebuffer)
Definition: TOracleServerE2WX.cxx:455
Int_t AddPlateCalibration(ULong64_t id_eventbrick, ULong64_t id_process_operation, EdbPlateP *plate)
Definition: TOracleServerE2WX.cxx:682
ss
Definition: energy.C:62
Int_t plate
Definition: merge_Energy_SytematicSources_Electron.C:1
UInt_t id
Definition: tlg2pattern.C:118

◆ LoadCalibrationZone()

ULong64_t EdbScan2DB::LoadCalibrationZone ( EdbScanProc sproc,
EdbID  edbid,
ULong64_t  operation 
)
1054 {
1055  EdbPattern pred;
1056  sproc.ReadPred(pred,id,-1);
1057  EdbSegP *spred = pred.GetSegment(0);
1058  if(!spred) return 0;
1059 
1060  return eDB->MyQueryInsertReturning(
1061  Form("INSERT INTO OPERA.TB_ZONES (ID_EVENTBRICK, ID_PLATE, ID_PROCESSOPERATION, \
1062  MINX, MAXX, MINY, MAXY, RAWDATAPATH, STARTTIME, ENDTIME, SERIES,\
1063  TXX, TXY, TYX, TYY, TDX, TDY) VALUES \
1064  (%s, %s, %s, %.2f, %.2f, %.2f, %.2f, %s, %s, %s, %s, 1, 0, 0, 1, 0, 0)",
1065  eDB->Ostr(eEventBrick),
1066  eDB->Ostr(id.ePlate),
1067  eDB->Ostr(operation),
1068  spred->X() - spred->SX(),
1069  spred->X() + spred->SX(),
1070  spred->Y() - spred->SY(),
1071  spred->Y() + spred->SY(),
1072  "'Local RawdataPath'",
1073  eDB->Timestamp(),
1074  eDB->Timestamp(),
1075  eDB->Ostr(id.eMajor) // or minor?
1076  ), "ID");
1077 }
Definition: EdbPattern.h:280
int ReadPred(EdbPattern &pred, int id[4], int flag=-1)
Definition: EdbScanProc.h:68
Definition: EdbSegP.h:18
Float_t SY() const
Definition: EdbSegP.h:160
Float_t X() const
Definition: EdbSegP.h:170
Float_t Y() const
Definition: EdbSegP.h:171
Float_t SX() const
Definition: EdbSegP.h:159
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
ULong64_t MyQueryInsertReturning(const char *query, const char *var)
Definition: TOracleServerE2WX.cxx:73

◆ LoadPrediction()

void EdbScan2DB::LoadPrediction ( EdbScanProc sproc,
EdbID  edbid 
)
1103 {
1104  Log( 1,"EdbScan2DB::LoadPrediction","Load dataset: %s",edbid.AsString() );
1106  EdbScanSet *ss = sproc.ReadScanSet(edbid);
1107 
1108  EdbID *idstart = ss->GetID(0);
1109  TString str;
1110  sproc.MakeFileName(str,*idstart,"sbt.root");
1111  EdbRunTracking rtpath;
1112  rtpath.ePredictionScan=true;
1113  TTree *t = rtpath.InitSBtree(str.Data(),"READ");
1114 
1115  int nsbt = (int) t->GetEntries();
1116  for (int ipath=0;ipath<nsbt;ipath++) { // scanback paths of most downstream plate (could be connected to CS
1117  rtpath.GetSBtreeEntry(ipath, *t);
1119  rtpath.ePred.ID(),idstart->ePlate,eIsBlackCS );
1120  }
1121  rtpath.CloseSBtree(t);
1122 
1123 
1124  for (int ip=0; ip<ss->eIDS.GetEntries(); ip++)
1125  {
1126  EdbID *id = ss->GetID(ip);
1127  EdbPlateP *plate = ss->GetPlate(id->ePlate);
1128 
1129  ULong64_t id_calibration_operation = eDB->GetProcessOperationID (
1130  eEventBrick,
1133  id->ePlate
1134  );
1135  ULong64_t platePredictionOperation = eDB->AddProcessOperation( // Adding prediction operation
1136  eIdMachine,
1138  eIdRequester,
1139  ePredictionHeaderOperation, // id_parent_operation
1140  eEventBrick,
1141  plate->ID(), // id_plate
1142  1, // driverlevel
1143  id_calibration_operation, // calibration operation : NULL for Header Operation
1144  eDB->Timestamp(), // starttime
1145  eDB->Timestamp(), // finishtime
1146  "'Y'",
1147  "Prediction area" // notes
1148  );
1149  LoadSBData(sproc,*id, platePredictionOperation);
1150  }
1151 }
TTree * t
Definition: check_shower.C:4
Int_t ePlate
Definition: EdbID.h:11
EdbSegP ePred
Definition: EdbRunTracking.h:50
static TTree * InitSBtree(const char *file_name="sbt.root", const char *mode="RECREATE")
Definition: EdbRunTracking.cxx:434
static void CloseSBtree(TTree *tree)
Definition: EdbRunTracking.cxx:547
bool GetSBtreeEntry(int entry, TTree &tsbt)
Definition: EdbRunTracking.cxx:515
void LoadSBData(EdbScanProc &sproc, EdbID id, ULong64_t operation)
Definition: TOracleServerE2WX.cxx:1154
EdbScanSet * ReadScanSet(EdbID id)
Definition: EdbScanProc.cxx:1521
Int_t ID() const
Definition: EdbSegP.h:144
Int_t AddScanbackPath(ULong64_t id_eventbrick, ULong64_t id_header_operation, int id_path, int id_start_plate, int skipCSconnection)
Definition: TOracleServerE2WX.cxx:598
Int_t GetProcessOperationID(char *id_eventbrick, char *id_programsettings, char *id)
Definition: TOracleServerE2.cxx:938

◆ LoadSBData()

void EdbScan2DB::LoadSBData ( EdbScanProc sproc,
EdbID  id,
ULong64_t  operation 
)
1155 {
1156  // Do not load all microtracks but only one's assigned to path
1157  //======== load scanback data for one plate ==============//
1158 
1159  TString rstr;
1160  sproc.MakeFileName( rstr, id, "sbt.root" );
1161  EdbRunTracking rtsb;
1162  rtsb.ePredictionScan=true;
1163  Log(1,"EdbScan2DB::LoadSBData","open %s",rstr.Data());
1164  TTree *tsbt = rtsb.InitSBtree(rstr.Data(),"READ");
1165  if(tsbt)
1166  {
1167  int nsbt = (int) tsbt->GetEntries();
1168 
1169  int id_basetrack=1;
1170  for (int ipath=0;ipath<nsbt;ipath++)
1171  {
1172  rtsb.GetSBtreeEntry( ipath, *tsbt);
1173  ULong64_t id_path = eDB->GetId_ScanbackPath(
1174  eEventBrick,
1176  rtsb.ePred.ID()
1177  );
1178  if(!id_path) {
1179  eDB->AddScanbackPath( eEventBrick, operation, rtsb.ePred.ID(), id.ePlate, 1 );
1180  id_path = eDB->GetId_ScanbackPath( eEventBrick, operation, rtsb.ePred.ID() );
1181  }
1182  ULong64_t id_pred_zone = LoadZone( rtsb.ePred, id.ePlate, operation,
1183  id_path, "'Local RawdataPath'");
1184 
1185  //========= Adding views and their microtracks ==========//
1186  int id_view = id_path;
1187  int side[2]={1,2};
1188  float zd[2]={214+45,0}, zu[2]={214,-45};
1189  for(int iside=0; iside<2; iside++) // add up/down views
1190  {
1191  eDB->MyQuery( Form(
1192  "INSERT INTO OPERA.TB_VIEWS (ID_EVENTBRICK, ID_ZONE, SIDE, ID, DOWNZ, UPZ, POSX, POSY)\
1193  VALUES (%s, %s, %d, %d, %.2f, %.2f, %.2f, %.2f)",
1194  eDB->Ostr(eEventBrick),
1195  eDB->Ostr(id_pred_zone),
1196  side[iside],
1197  id_view,
1198  zd[iside],
1199  zu[iside],
1200  rtsb.ePred.X(),
1201  rtsb.ePred.Y()
1202  ));
1203  }
1204  EdbSegP s,s1,s2;
1205  if( rtsb.GetSegmentsForDB(s,s1,s2) >=0 )
1206  {
1207  int id_down=1;
1208  int id_up=1;
1209  s1.SetID(id_up);
1210  s2.SetID(id_down);
1211  eDB->AddMicroTrack( eEventBrick, id_pred_zone, 2, id_view, s1 );
1212  printf("z = %f\n",s1.Z());
1213  eDB->AddMicroTrack( eEventBrick, id_pred_zone, 1, id_view, s2 );
1214  printf("z = %f\n",s2.Z());
1215  eDB->AddBaseTrack( Form(
1216  "%s, %s ,%d, %2f, %2f, %2f, %2f, %2f, %2f, %2f, %d, %ld, %d, %ld",
1217  eDB->Ostr(eEventBrick),
1218  eDB->Ostr(id_pred_zone),
1219  id_basetrack,
1220  rtsb.eNext.X(), rtsb.eNext.Y(),
1221  rtsb.eNext.TX(),rtsb.eNext.TY(),
1222  rtsb.eNext.W(), rtsb.eNext.Volume(), rtsb.eNext.Chi2(),
1223  1, id_down, 2, id_up
1224  ));
1225  }
1226  else // no any candidates
1227  {
1228  id_basetrack=0;
1229  }
1230  eDB->AddScanbackPrediction( Form(
1231  "%s, %s ,%d, %f, %f, %f, %f, NULL, NULL, NULL, NULL, NULL, %s, %s,'N', %d",
1232  eDB->Ostr(eEventBrick),
1233  eDB->Ostr(id_path),
1234  id.ePlate,
1235  rtsb.ePred.X(),
1236  rtsb.ePred.Y(),
1237  rtsb.ePred.TX(),
1238  rtsb.ePred.TY(),
1239  eDB->Ostr(id_pred_zone),
1240  eDB->Ostr(id_basetrack),
1241  0
1242  ));
1243  }
1244  rtsb.CloseSBtree(tsbt);
1245  }
1246  else
1247  {
1248  Log(1,"EdbScan2DB::LoadSBData","ERROR! can not open %s!",rstr.Data());
1249  }
1250 }
int GetSegmentsForDB(EdbSegP &s, EdbSegP &s1, EdbSegP &s2)
Definition: EdbRunTracking.cxx:688
EdbSegP eNext
Definition: EdbRunTracking.h:52
ULong64_t LoadZone(EdbSegP &s, int plate, ULong64_t operation, ULong64_t series, const char *cmt)
Definition: TOracleServerE2WX.cxx:1080
Float_t TX() const
Definition: EdbSegP.h:172
Float_t Volume() const
Definition: EdbSegP.h:155
void SetID(int id)
Definition: EdbSegP.h:125
Float_t Chi2() const
Definition: EdbSegP.h:154
Float_t Z() const
Definition: EdbSegP.h:150
Float_t W() const
Definition: EdbSegP.h:148
Float_t TY() const
Definition: EdbSegP.h:173
Int_t AddBaseTrack(const char *data)
Definition: TOracleServerE2WX.cxx:99
Int_t AddMicroTrack(char *datamicro)
Definition: TOracleServerE2WX.cxx:108
Int_t AddScanbackPrediction(char *dataprediciton)
Definition: TOracleServerE2WX.cxx:130
ULong64_t GetId_ScanbackPath(ULong64_t id_eventbrick, ULong64_t id_process_operation, int path)
Definition: TOracleServerE2.cxx:1230
EdbSegP * s1
Definition: tlg2pattern.C:30
EdbSegP * s2
Definition: tlg2pattern.C:31
EdbSegP * s
Definition: tlg2pattern.C:32

◆ LoadSBDataOld()

void EdbScan2DB::LoadSBDataOld ( EdbScanProc sproc,
EdbID  id,
ULong64_t  operation 
)

! Deprecated due to a problem of duplication of all raw data for each prediction - useless and time consuming =VT:2/08/2017

1255 {
1256  //======== load scamback data for one plate ==============//
1258 
1259  TString rstr;
1260  sproc.MakeFileName( rstr, id, "sbt.root" );
1261  EdbRunTracking rtsb; rtsb.ePredictionScan=true;
1262  TTree *tsbt = rtsb.InitSBtree(rstr.Data(),"READ");
1263  int nsbt = (int) tsbt->GetEntries();
1264 
1265  int id_basetrack=1;
1266  for (int ipath=0;ipath<nsbt;ipath++)
1267  {
1268  //=================== For each path ================//
1269  rtsb.GetSBtreeEntry( ipath, *tsbt);
1270  ULong64_t id_path = eDB->GetId_ScanbackPath( eEventBrick, ePredictionHeaderOperation, rtsb.ePred.ID() );
1271  if(!id_path) {
1272  eDB->AddScanbackPath( eEventBrick, operation, rtsb.ePred.ID(), id.ePlate, 1 );
1273  id_path = eDB->GetId_ScanbackPath( eEventBrick, operation, rtsb.ePred.ID() );
1274  }
1275  //char *SERIES = id_path;
1276  // SERIES = 101,102 or 103 (intercalibration with 3 zones)
1277  // SERIES = 0 (intercalibration with a single zone)
1278  // SERIES = PATH_ID (zone coming from a scan-back)
1279  // SERIES = ??? (zone coming from a total-scan)
1280  /*********** Adding one path-predicition zone ***********/
1281  ULong64_t id_pred_zone = LoadZone( rtsb.ePred, id.ePlate, operation,
1282  id_path, "'Local RawdataPath'");
1283 
1284  //========= Adding views and their microtracks ==========//
1285  EdbRunTracking rt;
1286  rt.ePredictionScan=true;
1287  sproc.InitRunAccess( rt, rtsb.eIdf );
1288  eDB->AddViews(rt, eEventBrick, id_pred_zone, true);
1289  int nvpa = rt.GetNviewsPerArea();
1290  EdbRun *run = rt.GetRun();
1291 
1292  Long_t id_view_up = 0;
1293  Long_t id_view_down = 0;
1294  Long_t id_up = 0;
1295  Long_t id_down = 0;
1296  if (rtsb.eStatus==0) // in case of basetrack found
1297  {
1298  id_view_down = (rtsb.eS1.Aid(0))*nvpa+rtsb.eS1.Aid(1);
1299  id_view_up = (rtsb.eS2.Aid(0))*nvpa+rtsb.eS2.Aid(1);
1300  id_down = id_view_down*100000 + 10000*1 + rtsb.eS1.Vid(1)%100000;
1301  id_up = id_view_up *100000 + 10000*2 + rtsb.eS2.Vid(1)%100000;
1302  Log(2,"EdbScan2DB::LoadSBData","Add BT (with top mt and bottom mt, nvpa=%d) id_down=%ld id_up=%ld",nvpa,id_down,id_up);
1303  }
1304  else if (rtsb.eStatus==1) // in case of microtrack bottom found
1305  {
1306  id_view_down = (rtsb.eS1.Aid(0))*nvpa+rtsb.eS1.Aid(1);
1307  id_view_up = (rtsb.eS1.Aid(0))*nvpa+rtsb.eS1.Aid(1);
1308  id_down = id_view_down*100000 + 10000*1 + rtsb.eS1.Vid(1)%100000;
1309  id_up = id_view_up *100000 + 10000*2 + rtsb.eS1.Vid(1)%100000 + 20000;
1310 
1311  EdbView *view = run->GetEntry(rtsb.eS1.Vid(0));
1312  float dz = view->GetHeader()->GetZ2()-view->GetHeader()->GetZ3();
1313 
1314  // adding fake mt top
1315  eDB->AddMicroTrack( Form(
1316  "%s, %s ,%d, %d, %d, %2f, %2f, %2f, %2f, %2f, %2f, %2f",
1317  eDB->Ostr(eEventBrick),
1318  eDB->Ostr(id_pred_zone),
1319  2, id_up, id_view_up,
1320  rtsb.eS1.X() - dz*rtsb.eS1.TX(), rtsb.eS1.Y() - dz*rtsb.eS1.TY(),
1321  rtsb.eS1.TX(), rtsb.eS1.TY(),
1322  0, 0, -1
1323  ));
1324  Log(2,"EdbScan2DB::LoadSBData","Fake MT bottom added (and BT with MT top real and MT bottom fake)");
1325  }
1326  else if (rtsb.eStatus==2) // in case of microtrack top found
1327  {
1328  id_view_down = (rtsb.eS2.Aid(0))*nvpa+rtsb.eS2.Aid(1);
1329  id_view_up = (rtsb.eS2.Aid(0))*nvpa+rtsb.eS2.Aid(1);
1330  id_down = id_view_down*100000 + 10000*1 + rtsb.eS2.Vid(1)%100000 + 20000;
1331  id_up = id_view_up *100000 + 10000*2 + rtsb.eS2.Vid(1)%100000;
1332 
1333  EdbView *view = run->GetEntry(rtsb.eS2.Vid(0));
1334  float dz = view->GetHeader()->GetZ2()-view->GetHeader()->GetZ3();
1335 
1336  // adding fake mt bottom
1337  eDB->AddMicroTrack( Form(
1338  "%s, %s ,%d, %d, %d, %2f, %2f, %2f, %2f, %2f, %2f, %2f",
1339  eDB->Ostr(eEventBrick),
1340  eDB->Ostr(id_pred_zone),
1341  1, id_down, id_view_down,
1342  rtsb.eS2.X() - dz*rtsb.eS2.TX(),
1343  rtsb.eS2.Y() - dz*rtsb.eS2.TY(),
1344  rtsb.eS2.TX(),
1345  rtsb.eS2.TY(),
1346  0, 0, -1
1347  ));
1348  Log(2,"EdbScan2DB::LoadSBData","Fake MT top added (and BT with MT bottom real and MT top fake)");
1349  }
1350  /*
1351  else // no any candidates (stat=-1)
1352  {
1353  id_view_up=0;
1354  id_view_down=0;
1355  id_down = 10000*1 + id_basetrack;
1356  id_up = 10000*2 + id_basetrack;
1357  float dz = 200;
1358  eDB->AddMicroTrack( Form(
1359  "%s, %s ,%d, %d, %d, %2f, %2f, %2f, %2f, %2f, %2f, %2f",
1360  eDB->Ostr(eEventBrick),
1361  eDB->Ostr(id_pred_zone),
1362  2, id_up, id_view_up,
1363  rtsb.eS1.X() - dz*rtsb.eS1.TX(), rtsb.eS1.Y() - dz*rtsb.eS1.TY(),
1364  rtsb.eS1.TX(), rtsb.eS1.TY(),
1365  0, 0, -1
1366  ));
1367  }
1368  */
1369  if(rtsb.eStatus==0||rtsb.eStatus==1||rtsb.eStatus==2) // exist some candidate
1370  {
1371  eDB->AddBaseTrack( Form(
1372  "%s, %s ,%d, %2f, %2f, %2f, %2f, %2f, %2f, %2f, %d, %ld, %d, %ld",
1373  eDB->Ostr(eEventBrick),
1374  eDB->Ostr(id_pred_zone),
1375  id_basetrack,
1376  rtsb.eNext.X(), rtsb.eNext.Y(),
1377  rtsb.eNext.TX(),rtsb.eNext.TY(),
1378  rtsb.eNext.W(), rtsb.eNext.Volume(), rtsb.eNext.Chi2(),
1379  1, id_down, 2, id_up
1380  ));
1381  eDB->AddScanbackPrediction( Form(
1382  "%s, %s ,%d, %f, %f, %f, %f, NULL, NULL, NULL, NULL, NULL, %s, %s,'N', %d",
1383  eDB->Ostr(eEventBrick),
1384  eDB->Ostr(id_path),
1385  id.ePlate,
1386  rtsb.ePred.X(),
1387  rtsb.ePred.Y(),
1388  rtsb.ePred.TX(),
1389  rtsb.ePred.TY(),
1390  eDB->Ostr(id_pred_zone),
1391  eDB->Ostr(id_basetrack),
1392  0
1393  ));
1394  id_basetrack++;
1395  }
1396  else // no any candidates
1397  {
1398  eDB->AddScanbackPrediction( Form(
1399  "%s, %s ,%d, %f, %f, %f, %f, NULL, NULL, NULL, NULL, NULL, %s, %s,'N', %d",
1400  eDB->Ostr(eEventBrick),
1401  eDB->Ostr(id_path),
1402  id.ePlate,
1403  rtsb.ePred.X(),
1404  rtsb.ePred.Y(),
1405  rtsb.ePred.TX(),
1406  rtsb.ePred.TY(),
1407  eDB->Ostr(id_pred_zone),
1408  eDB->Ostr(0),
1409  0
1410  ));
1411  }
1412  }
1413  rtsb.CloseSBtree(tsbt);
1414 }
brick dz
Definition: RecDispMC.C:107
EdbRun * GetRun() const
Definition: EdbRunAccess.h:123
Int_t eStatus
Definition: EdbRunTracking.h:53
Int_t eIdf[4]
Definition: EdbRunTracking.h:59
EdbSegP eS1
Definition: EdbRunTracking.h:51
EdbSegP eS2
Definition: EdbRunTracking.h:51
Definition: EdbRun.h:74
EdbView * GetEntry(int entry, int ih=1, int icl=0, int iseg=1, int itr=0, int ifr=0)
Definition: EdbRun.cxx:489
Int_t Aid(int i) const
Definition: EdbSegP.h:166
Int_t Vid(int i) const
Definition: EdbSegP.h:165
Float_t GetZ2() const
Definition: EdbView.h:111
Float_t GetZ3() const
Definition: EdbView.h:112
Definition: EdbView.h:134
EdbViewHeader * GetHeader() const
Definition: EdbView.h:163
EdbRun * run
Definition: check_raw.C:38

◆ LoadVolume()

void EdbScan2DB::LoadVolume ( EdbScanProc sproc,
EdbID  edbid,
EdbID  idstop 
)
1474 {
1475  Log( 2,"EdbScan2DB::LoadVolume","Load dataset: %s",idvol.AsString() );
1476  if(!eDB) return;
1477 
1479 
1480  EdbScanSet *ss = sproc.ReadScanSet(idvol);
1481  if(ss)
1482  {
1483  ULong64_t id_volume = eDB->AddVolume(eEventBrick, eVolumeHeaderOperation, idvol.eMajor );
1484 
1485  int n = ss->eIDS.GetEntries();
1486  for(int i=0; i<n; i++) {
1487  EdbID *id = ss->GetID(i);
1488  EdbPlateP *plate = ss->GetPlate(id->ePlate);
1489 
1490  if(plate) {
1491 
1492  ULong64_t plateVolumeOperation = eDB->AddProcessOperation( // Adding volume operation
1493  eIdMachine,
1495  eIdRequester,
1496  eVolumeHeaderOperation, // id_parent_operation
1497  eEventBrick,
1498  id->ePlate, // id_plate
1499  1, // driverlevel
1500  0, // calibration operation : NULL for Header Operation
1501  eDB->Timestamp(), // starttime
1502  eDB->Timestamp(), // finishtime
1503  "'Y'",
1504  "Volume area" // notes
1505  );
1506  EdbPattern pred;
1507  sproc.ReadPred( pred, *id, -1 );
1508  EdbSegP *spred = pred.GetSegment(0);
1509  ULong64_t id_volume_zone = LoadZone( *spred, id->ePlate, plateVolumeOperation, id_volume, "'Local RawdataPath'");
1510 
1511  //============= Loading views and their microtracks ==========//
1512  EdbRunTracking rt;
1513  rt.ePredictionScan=true;
1514  sproc.InitRunAccess( rt, *id );
1515  eDB->AddViews(rt, eEventBrick, id_volume_zone, true);
1516  int nvpa = rt.GetNviewsPerArea();
1517 
1518  //========= Adding basetracks assuming that microtracks already added ==========//
1519  EdbDataPiece dp;
1520  sproc.MakeFileName(dp.eFileNameCP,*id,"cp.root");
1521  dp.InitCouplesTree();
1522  eDB->AddBaseTracks(dp.eCouplesTree, eEventBrick, id_volume_zone,nvpa, true);
1523  dp.CloseCPData();
1524 
1525  //=========== Adding volume slice ==========//
1526  eDB->MyQuery(Form("\
1527  INSERT INTO OPERA.TB_VOLUME_SLICES \
1528  (ID_EVENTBRICK, ID_VOLUME, ID_PLATE, MINX, MINY, MAXX, MAXY, ID_ZONE, DAMAGED) \
1529  VALUES (%lld, %s, %d, %.2f, %.2f, %.2f, %.2f, %s, %s)",
1530  eEventBrick,
1531  eDB->Ostr(id_volume),
1532  id->ePlate,
1533  spred->X() - spred->SX(),
1534  spred->X() + spred->SX(),
1535  spred->Y() - spred->SY(),
1536  spred->Y() + spred->SY(),
1537  eDB->Ostr(id_volume_zone),
1538  "'N'" //'N' - for "not damaged"
1539  ));
1540 
1541  }
1542  }
1543  if (eIDPATH>=0) {
1544  //====== Read path informations ======//
1545  TString filename;
1546  sproc.MakeFileName(filename,idstop,"stopping_points.txt",false);
1547  EdbPattern pat;
1548  sproc.ReadPatTXT(filename, pat);
1549  int id_stopping_plate=0;
1550  for (int ip=0;ip<pat.N();ip++)
1551  {
1552  EdbSegP *s = pat.GetSegment(ip);
1553  s->SetPID(s->Flag());
1554  s->SetFlag(0);
1555  if (s->ID()==eIDPATH) id_stopping_plate=s->PID();
1556  }
1557  if (!id_stopping_plate) {
1558  Log(1,"EdbScan2DB::LoadVolume", "ERROR: informations about the path %d not found in %s\n",eIDPATH,filename);
1559  }
1560  else
1561  {
1562  //========= Adding in TB_B_SBPATHS_VOLUMES ==========//
1563  eDB->AddBSBpathsVolumes(Form(
1564  "%lld, %s, %d, %s, %d, %d",
1565  eEventBrick,
1567  eIDPATH,
1569  idvol.eMajor,
1570  id_stopping_plate
1571  ));
1572  }
1573  }
1574  }
1575 }
int ReadPatTXT(EdbPattern &pred, EdbID id, const char *suffix, int flag=-1)
Definition: EdbScanProc.h:61
void SetPID(int pid)
Definition: EdbSegP.h:126
Int_t PID() const
Definition: EdbSegP.h:145
void SetFlag(int flag)
Definition: EdbSegP.h:127
Int_t Flag() const
Definition: EdbSegP.h:146
Int_t N() const
Definition: EdbPattern.h:89
Int_t AddBSBpathsVolumes(char *databsbpathsvolumes)
Definition: TOracleServerE2WX.cxx:668
ULong64_t AddVolume(ULong64_t id_eventbrick, ULong64_t id_process_operation, int ivolume)
Definition: TOracleServerE2WX.cxx:643

◆ LoadZone()

ULong64_t EdbScan2DB::LoadZone ( EdbSegP s,
int  plate,
ULong64_t  operation,
ULong64_t  series,
const char *  cmt 
)
1081 {
1082  return eDB->MyQueryInsertReturning(
1083  Form("INSERT INTO OPERA.TB_ZONES (ID_EVENTBRICK, ID_PLATE, ID_PROCESSOPERATION, \
1084  MINX, MAXX, MINY, MAXY, RAWDATAPATH, STARTTIME, ENDTIME, SERIES,\
1085  TXX, TXY, TYX, TYY, TDX, TDY) VALUES \
1086  (%s, %s, %s, %.2f, %.2f, %.2f, %.2f, %s, %s, %s, %s, 1, 0, 0, 1, 0, 0)",
1087  eDB->Ostr(eEventBrick),
1088  eDB->Ostr(plate),
1089  eDB->Ostr(operation),
1090  s.X() - s.SX(),
1091  s.X() + s.SX(),
1092  s.Y() - s.SY(),
1093  s.Y() + s.SY(),
1094  cmt,
1095  eDB->Timestamp(),
1096  eDB->Timestamp(),
1097  eDB->Ostr(series)
1098  ), "ID");
1099 }

◆ Print()

void EdbScan2DB::Print ( )
1000 {
1001  printf("\n=============== EdbScan2DB settings ================\n");
1002  printf("eID_SET = %s\n" ,eID_SET.Data());
1003  printf("eBrick = %lld\n", eBrick);
1004  printf("eEvent = %lld\n", eEvent);
1005  printf("eEventBrick = %lld\n",eEventBrick);
1006  printf("eIdMachine = %lld\n",eIdMachine);
1007  printf("eIdRequester = %lld\n",eIdRequester );
1008  printf("eHeaderProgramsettings = %lld\n",eHeaderProgramsettings);
1009  printf("eCalibrationProgramsettings = %lld\n",eCalibrationProgramsettings );
1010  printf("ePredictionProgramsettings = %lld\n",ePredictionProgramsettings );
1011  printf("eVolumeProgramsettings = %lld\n",eVolumeProgramsettings );
1012  printf("eFeedbackProgramsettings = %lld\n",eFeedbackProgramsettings );
1013  printf("eCalibrationHeaderOperation = %lld\n",eCalibrationHeaderOperation );
1014  printf("ePredictionHeaderOperation = %lld\n",ePredictionHeaderOperation );
1015  printf("eVolumeHeaderOperation = %lld\n",eVolumeHeaderOperation );
1016  printf("eIsBlackCS = %d\n" , eIsBlackCS);
1017  if(eDB) {
1018  printf("=========== Database settings ================\n");
1019  eDB->Print();
1020  }
1021  printf("================================================\n\n");
1022 }
void Print()
Definition: TOracleServerE2WX.cxx:27

Member Data Documentation

◆ eBrick

ULong64_t EdbScan2DB::eBrick

◆ eCalibrationHeaderOperation

ULong64_t EdbScan2DB::eCalibrationHeaderOperation

◆ eCalibrationProgramsettings

ULong64_t EdbScan2DB::eCalibrationProgramsettings

◆ eDB

TOracleServerE2WX* EdbScan2DB::eDB

◆ eERROR

Int_t EdbScan2DB::eERROR

◆ eEvent

ULong64_t EdbScan2DB::eEvent

◆ eEventBrick

ULong64_t EdbScan2DB::eEventBrick

◆ eFeedbackProgramsettings

ULong64_t EdbScan2DB::eFeedbackProgramsettings

◆ eHeaderProgramsettings

ULong64_t EdbScan2DB::eHeaderProgramsettings

◆ eID_SET

TString EdbScan2DB::eID_SET

◆ eIdMachine

ULong64_t EdbScan2DB::eIdMachine

◆ eIDPATH

Int_t EdbScan2DB::eIDPATH

◆ eIdRequester

ULong64_t EdbScan2DB::eIdRequester

◆ eIsBlackCS

Int_t EdbScan2DB::eIsBlackCS

◆ ePredictionHeaderOperation

ULong64_t EdbScan2DB::ePredictionHeaderOperation

◆ ePredictionProgramsettings

ULong64_t EdbScan2DB::ePredictionProgramsettings

◆ eVolumeHeaderOperation

ULong64_t EdbScan2DB::eVolumeHeaderOperation

◆ eVolumeProgramsettings

ULong64_t EdbScan2DB::eVolumeProgramsettings

◆ eWriteRawCalibrationData

Bool_t EdbScan2DB::eWriteRawCalibrationData

◆ eX_marks

Int_t EdbScan2DB::eX_marks

The documentation for this class was generated from the following files: