Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sly2j committed Mar 2, 2018
2 parents 46dee25 + ad1d641 commit 30deb3a
Show file tree
Hide file tree
Showing 210 changed files with 8,317 additions and 2,270,159 deletions.
Binary file modified .DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions bin/eviocure
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh -f

SCRIPT_DIR=`dirname $0`
DISTRO_DIR=$SCRIPT_DIR/../ ; export DISTRO_DIR
CLAS12DIR=$SCRIPT_DIR/../ ; export CLAS12DIR
CLARA_SERVICES=$DISTRO_DIR/lib/services; export CLARA_SERVICES
DATAMINING=$DISTRO_DIR ; export DATAMINING
TORUSMAP=$CLAS12DIR/etc/data/magfield/clas12-fieldmap-torus.dat ; export TORUSMAP
SOLENOIDMAP=$CLAS12DIR/etc/data/magfield/clas12-fieldmap-solenoid.dat ; export SOLENOIDMAP
MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX

#CLARA_HOME=`dirname $0`
#CLARA_SERVICES=`dirname $0`
#DATAMINING=`dirname $0`

echo +-------------------------------------------------------------------------
echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES
echo +-------------------------------------------------------------------------
echo "\n"

echo "INSTALLATION DIRECTORY = " $CLARA_HOME
echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/

#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $*
#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $*
java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.utils.EvioCure $*
15 changes: 15 additions & 0 deletions bin/jaw
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh -f

SCRIPT_DIR=`dirname $0`
DISTRO_DIR=$SCRIPT_DIR/../ ; export DISTRO_DIR
CLAS12DIR=$SCRIPT_DIR/../ ; export CLAS12DIR
CLARA_SERVICES=$DISTRO_DIR/lib/services; export CLARA_SERVICES
DATAMINING=$DISTRO_DIR ; export DATAMINING

java -Dsun.java2d.pmoffscreen=false -Xms1024m -Xmx2048m -cp "$DATAMINING/lib/utils/*" org.jlab.jnp.math.cli.MathCli $*

#*********************************************************
#---------------------------------------------------------
# JHEP math CLI interface.
#---------------------------------------------------------
#java -cp "target/jnp-math-1.0-SNAPSHOT-jar-with-dependencies.jar" org.jlab.jnp.math.cli.MathCli $*
12 changes: 10 additions & 2 deletions build-coatjava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mkdir -p coatjava/lib/utils
cp external-dependencies/jclara-4.3-SNAPSHOT.jar coatjava/lib/utils
cp external-dependencies/KPP-Monitoring-1.0.jar coatjava/lib/utils
cp external-dependencies/KPP-Plots-1.0.jar coatjava/lib/utils
cp external-dependencies/jaw-1.0.jar coatjava/lib/utils
mkdir -p coatjava/lib/services

### clean up any cache copies ###
Expand All @@ -26,10 +27,10 @@ cd common-tools/coat-lib
mvn package
if [ $? != 0 ] ; then echo "common tools failure 2" ; exit 1 ; fi
cd -
cp common-tools/coat-lib/target/coat-libs-5.0-SNAPSHOT.jar coatjava/lib/clas/
cp common-tools/coat-lib/target/coat-libs-5.1-SNAPSHOT.jar coatjava/lib/clas/

### create local mvn repo containing coat-libs and jcsg ##
mvn deploy:deploy-file -Dfile=./common-tools/coat-lib/target/coat-libs-5.0-SNAPSHOT.jar -DgroupId=org.jlab.clas -DartifactId=common-tools -Dversion=0.0 -Dpackaging=jar -Durl=file:./myLocalMvnRepo/ -DrepositoryId=myLocalMvnRepo -DupdateReleaseInfo=true
mvn deploy:deploy-file -Dfile=./common-tools/coat-lib/target/coat-libs-5.1-SNAPSHOT.jar -DgroupId=org.jlab.clas -DartifactId=common-tools -Dversion=0.0 -Dpackaging=jar -Durl=file:./myLocalMvnRepo/ -DrepositoryId=myLocalMvnRepo -DupdateReleaseInfo=true
if [ $? != 0 ] ; then echo "failed to create local mvn repo" ; exit 1 ; fi

### dc (depends on jcsg) ###
Expand Down Expand Up @@ -99,6 +100,13 @@ if [ $? != 0 ] ; then echo "rich failure" ; exit 1 ; fi
cd -
cp reconstruction/rich/target/clas12detector-rich-1.0-SNAPSHOT.jar coatjava/lib/services/

### fvt ###
cd reconstruction/fvt
mvn install
if [ $? != 0 ] ; then echo "fvt failure" ; exit 1 ; fi
cd -
cp reconstruction/fvt/target/clas12detector-fvt-1.0-SNAPSHOT.jar coatjava/lib/services/

### eb ###
cd reconstruction/eb
mvn install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum DetectorType {
RF (17, "RF"),
RICH (18, "RICH"),
RTPC (19, "RTPC"),
HEL (20, "HEL"),
ECIN (110, "ECIN"),
ECOUT (111, "ECOUT"),
ECTOT (112, "ECTOT"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class ConstantsManager {
private DatabaseConstantsDescriptor defaultDescriptor = new DatabaseConstantsDescriptor();
private volatile Map<Integer,DatabaseConstantsDescriptor> runConstants = new LinkedHashMap<Integer,DatabaseConstantsDescriptor>();
private String databaseVariation = "default";
private String timeStamp = "";

public ConstantsManager(){

Expand All @@ -40,6 +41,10 @@ public void setVariation(String variation){
this.databaseVariation = variation;
}

public void setTimeStamp(String timestamp){
this.timeStamp = timestamp;
}

public synchronized void init(List<String> tables){
this.defaultDescriptor.addTables(tables);
}
Expand Down Expand Up @@ -70,7 +75,8 @@ private synchronized void loadConstantsForRun(int run){
System.out.println("[ConstantsManager] ---> loading table for run = " + run);
DatabaseConstantsDescriptor desc = defaultDescriptor.getCopy(run);
DatabaseConstantProvider provider = new DatabaseConstantProvider(run,
this.databaseVariation);
this.databaseVariation, this.timeStamp);


List<String> tn = new ArrayList<String>(desc.getTableNames());
List<String> tk = new ArrayList<String>(desc.getTableKeys());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@

package org.jlab.detector.calib.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jlab.ccdb.CcdbPackage;
import javax.swing.JFrame;
import org.jlab.ccdb.Assignment;
import org.jlab.ccdb.CcdbPackage;

import org.jlab.ccdb.Directory;
import org.jlab.ccdb.JDBCProvider;
import org.jlab.ccdb.TypeTable;
import org.jlab.ccdb.TypeTableColumn;

import org.rcdb.RCDB;
import org.jlab.geom.base.ConstantProvider;
import org.jlab.utils.groups.IndexedTable;
import org.jlab.utils.groups.IndexedTableViewer;
Expand All @@ -39,8 +45,11 @@ public class DatabaseConstantProvider implements ConstantProvider {
private Integer runNumber = 10;
private Integer loadTimeErrors = 0;
private Boolean PRINTOUT_FLAG = false;
private Integer dataYear = 118;
private Integer dataMonth = 1;
private Date databaseDate = new Date();

private JDBCProvider provider;
private org.jlab.ccdb.JDBCProvider provider;

private int debugMode = 1;

Expand Down Expand Up @@ -69,6 +78,22 @@ public DatabaseConstantProvider(int run, String var){
this.initialize(address);
}

public DatabaseConstantProvider(int run, String var, String timestamp){

this.loadTimeErrors = 0;
this.runNumber = run;
this.variation = var;

String address = "mysql://[email protected]/clas12";

String envAddress = this.getEnvironment();
if(envAddress!=null) address = envAddress;
this.initialize(address);
if(timestamp.length()>8){
this.setTimeStamp(timestamp);
}
}

public DatabaseConstantProvider(String address){
this.initialize(address);
}
Expand Down Expand Up @@ -136,22 +161,39 @@ private void initialize(String address){
System.out.println("[DB] ---> open connection with : " + address);
System.out.println("[DB] ---> database variation : " + this.variation);
System.out.println("[DB] ---> database run number : " + this.runNumber);
System.out.println("[DB] ---> database time stamp : " + databaseDate);
}

provider.connect();

if(provider.getIsConnected()==true){
if(provider.isConnected()==true){
if(debugMode>0) System.out.println("[DB] ---> database connection : success");
} else {
System.out.println("[DB] ---> database connection : failed");
}

provider.setDefaultVariation(variation);
provider.setDefaultDate(databaseDate);
provider.setDefaultRun(this.runNumber);

//Directory dir = provider.getDirectory("/calibration/ftof/");
//Assignment asgmt = provider.getData("/test/test_vars/test_table");
}

public final void setTimeStamp(String timestamp){
String pattern = "MM/dd/yyyy";
SimpleDateFormat format = new SimpleDateFormat(pattern);

try {
databaseDate = format.parse(timestamp);
} catch (ParseException ex) {
System.out.println("\n\n ***** TIMESTAMP ERROR ***** error parsing timestamp : " + timestamp);
databaseDate = new Date();
System.out.println(" ***** TIMESTAMP WARNING ***** setting date to : " + databaseDate);

}

}
/**
* Reads calibration constants for given table in the database.
* @param table_name
Expand Down Expand Up @@ -184,8 +226,9 @@ public CalibrationConstants readConstants(String table_name){


for(int loop = 0; loop < ncolumns; loop++){
Vector<String> column = asgmt.getColumnValuesString(loop);
tableRows.add(column);
String name = typecolumn.get(loop).getName();
Vector<String> column = asgmt.getColumnValuesString(name);
tableRows.add(column);
}

int nrows = tableRows.get(0).size();
Expand Down Expand Up @@ -249,7 +292,8 @@ public IndexedTable readTable(String table_name,int nindex){


for(int loop = 0; loop < ncolumns; loop++){
Vector<String> column = asgmt.getColumnValuesString(loop);
String name = typecolumn.get(loop).getName();
Vector<String> column = asgmt.getColumnValuesString(name);
tableRows.add(column);
}

Expand Down Expand Up @@ -294,7 +338,8 @@ public void loadTable(String table_name){
//System.out.println("Reading column number " + loop
//+ " " + typecolumn.elementAt(loop).getCellType()
//+ " " + typecolumn.elementAt(loop).getName());
Vector<String> row = asgmt.getColumnValuesString(loop);
String name = typecolumn.get(loop).getName();
Vector<String> row = asgmt.getColumnValuesString(name);
String[] values = new String[row.size()];
for(int el = 0; el < row.size(); el++){
values[el] = row.elementAt(el);
Expand Down Expand Up @@ -425,26 +470,59 @@ public int getSize(String name){

public static void main(String[] args){

DatabaseConstantProvider provider = new DatabaseConstantProvider(10,"default");
IndexedTable table = provider.readTable("/test/fc/fadc");
//table.addConstrain(3, 0.0, 90.0);
provider.disconnect();
JFrame frame = new JFrame();
frame.setSize(600, 600);

/*
table.addRowAsDouble(new String[]{"21","7","1","0.5","0.1","0.6"});
table.addRowAsDouble(new String[]{"22","8","2","0.6","0.2","0.7"});
table.addRowAsDouble(new String[]{"23","9","3","0.7","0.3","0.8"});
table.addRowAsDouble(new String[]{"24","10","4","0.8","0.4","0.9"});
*/
//table.readFile("/Users/gavalian/Work/Software/Release-8.0/COATJAVA/coatjava/EC.table");
//table.show();
IndexedTableViewer canvas = new IndexedTableViewer(table);
frame.add(canvas);
frame.pack();
frame.setVisible(true);
table.show();

DatabaseConstantProvider provider = new DatabaseConstantProvider(10,"default");
IndexedTable table = provider.readTable("/test/fc/fadc");

provider.disconnect();
JFrame frame = new JFrame();
frame.setSize(600, 600);


IndexedTableViewer canvas = new IndexedTableViewer(table);
frame.add(canvas);
frame.pack();
frame.setVisible(true);
table.show();


String pattern = "MM/dd/yyyy";
SimpleDateFormat format = new SimpleDateFormat(pattern);
Date dateNow = new Date();
System.out.println(dateNow);

try {
Date dateThen = format.parse("01/23/2017");
System.out.println(dateThen);
} catch (ParseException ex) {
Logger.getLogger(DatabaseConstantProvider.class.getName()).log(Level.SEVERE, null, ex);
}

org.rcdb.JDBCProvider provider_rcdb = RCDB.createProvider("mysql://[email protected]/rcdb");
provider_rcdb.connect();

// The real database is going to be used for the example
// Run 31000 is used everywhere:
long runNumber = 2475;
System.out.println("Run Number = " + runNumber);
// get long value
long eventCount = provider_rcdb.getCondition(runNumber, "event_count").toLong();
System.out.println("event_count = " + eventCount);

// get bool value
boolean isValidRunEnd = provider_rcdb.getCondition(runNumber, "is_valid_run_end").toBoolean();
System.out.println("is_valid_run_end = " + isValidRunEnd);

// List all available condition names
// Vector<ConditionType> cndTypes = provider.getConditionTypes();
//HashMap<String, ConditionType> cndTypeByNames = provider.getConditionTypeByNames();
// get double
double sol_scale = provider_rcdb.getCondition(runNumber, "solenoid_scale").toDouble();
System.out.println("solenoid_scale = " + sol_scale);
double tor_scale = provider_rcdb.getCondition(runNumber, "torus_scale").toDouble();
System.out.println("torus_scale = " + tor_scale);
provider_rcdb.close();
}

}
Loading

0 comments on commit 30deb3a

Please sign in to comment.