StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
insertBadAnodes.C
1 //
2 // macro to transfer bad anodes data from ASCII file to data base
3 //
4 
5 #define NUMBER_OF_HYBRIDS 432
6 #include <fstream.h>
7 #include "/afs/rhic/star/packages/DEV/StRoot/StDbLib/StDbDefs.hh"
8 
9 void insertBadAnodes(char* unixTime = 0, Bool_t write = kFALSE)
10 {
11  Bool_t debug = kTRUE;
12 
13  // DB-specific libs
14  gSystem->Load("libStDb_Tables.so");
15  gSystem->Load("StDbLib");
16  gSystem->Load("StDbBroker");
17  gSystem->Load("St_base");
18  gSystem->Load("StUtilities");
19  gSystem->Load("StSvtClassLibrary");
20 
21  // input file
22  ifstream fileBad("badAnodes_01_21_04.txt");
23 
24  // out test file
25  if (debug)
26  ofstream fileout("outBadAnodesTest.txt");
27 
28  int barrel, ladder, wafer, hybrid;
29  int index, anode;
30 
31  // define IDs
32  int* rowIDs=new int[NUMBER_OF_HYBRIDS];
33 
34  StSvtConfig* config = new StSvtConfig();
35  config->setConfiguration("FULL");
36 
37  // define new table to be stored
38  svtBadAnodes_st *badAnodes = new svtBadAnodes_st[NUMBER_OF_HYBRIDS];
39 
40  for (int i=0;i<432;i++) {
41  rowIDs[i]=i;
42  for (int j=0;j<240;j++)
43  badAnodes[i].isBadAnode[j] = 0;
44  }
45 
46  while (kTRUE) {
47 
48  // read bad anodes file
49  fileBad >> barrel >> ladder >> wafer >> hybrid >> anode;
50 
51  index = config->getHybridIndex(barrel, ladder, wafer, hybrid);
52 
53  if (fileBad.eof()) break;
54 
55  badAnodes[index].isBadAnode[anode-1] = 1;
56  }
57 
58  if (debug)
59  for (int i=0;i<432;i++)
60  for (int j=0;j<240;j++) {
61  if (badAnodes[i].isBadAnode[j])
62  fileout << i << " " << j+1 << endl;
63  }
64 
65  if (write) {
67  StDbConfigNode* svtCalibNode = mgr->initConfig(dbCalibrations,dbSvt); StDbTable* svtCalibTable = svtCalibNode->addDbTable("svtBadAnodes");
68  svtCalibTable->SetTable((char*)badAnodes,NUMBER_OF_HYBRIDS,rowIDs);
69  mgr->setStoreTime(unixTime);
70  cout<<" Will attempt store with timestamp="<<mgr->getDateStoreTime()<<endl; mgr->storeDbTable(svtCalibTable);
71  delete [] badAnodes;
72  }
73 
74 }
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc&#39;d version of data for StRoot
Definition: StDbTable.cc:550
static StDbManager * Instance()
strdup(..) is not ANSI
Definition: StDbManager.cc:155