Skip to content

Commit

Permalink
refactor!: remove main methods from monitoring classes
Browse files Browse the repository at this point in the history
they do not appear to be used; we can recover them from `git` history if
someone is relying on them (but they should be encouraged to use the
more general, in-use code)
  • Loading branch information
c-dilks committed Mar 7, 2025
1 parent 605697e commit 4d0680e
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 748 deletions.
53 changes: 0 additions & 53 deletions monitoring/src/main/java/org/jlab/clas12/monitoring/BAND.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,59 +230,6 @@ public void plot() {
System.out.println(String.format("saved "+outputDir+"/BAND.png"));

}
public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
GStyle.setPalette("kRainBow");
int count = 0;
int runNum = 0;
boolean useTB = true;
String filelist = "list_of_files.txt";
if(args.length>0)runNum=Integer.parseInt(args[0]);
if(args.length>1)filelist = args[1];
int maxevents = 20000000;
if(args.length>2)maxevents=Integer.parseInt(args[2]);
float Eb =6.42f;//10.6f;
if(args.length>3)Eb=Float.parseFloat(args[3]);
if(args.length>4)if(Integer.parseInt(args[4])==0)useTB=false;
String outputDir = runNum > 0 ? "plots"+runNum : "plots";
BAND ana = new BAND(runNum,outputDir,Eb,useTB);
List<String> toProcessFileNames = new ArrayList<String>();
File file = new File(filelist);
Scanner read;
try {
read = new Scanner(file);
do {
String filename = read.next();
toProcessFileNames.add(filename);

}while (read.hasNext());
read.close();
}catch(IOException e){
e.printStackTrace();
System.exit(100);
}
int progresscount=0;int filetot = toProcessFileNames.size();
for (String runstrg : toProcessFileNames) if( count<maxevents ){
progresscount++;
System.out.println(String.format(">>>>>>>>>>>>>>>> %s",runstrg));
File varTmpDir = new File(runstrg);
if(!varTmpDir.exists()){System.out.println("FILE DOES NOT EXIST");continue;}
System.out.println("READING NOW "+runstrg);
HipoDataSource reader = new HipoDataSource();
reader.open(runstrg);
int filecount = 0;
while(reader.hasEvent()&& count<maxevents ) {
DataEvent event = reader.getNextEvent();
ana.processEvent(event);
filecount++;count++;
if(count%10000 == 0) System.out.println(count/1000 + "k events (this is BAND analysis on "+runstrg+") ; progress : "+progresscount+"/"+filetot);
}
reader.close();
}
System.out.println("Total : " + count + " events");
ana.plot();
ana.write();
}

public void write() {
TDirectory dirout = new TDirectory();
Expand Down
73 changes: 0 additions & 73 deletions monitoring/src/main/java/org/jlab/clas12/monitoring/FT.java
Original file line number Diff line number Diff line change
Expand Up @@ -600,78 +600,5 @@ public void write() {
if(runNum>0) dirout.writeFile(outputDir+"/out_FT_"+runNum+".hipo");
else dirout.writeFile(outputDir+"/out_FT.hipo");
}
////////////////////////////////////////////////

public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
GStyle.setPalette("kRainBow");
int count = 0;
int runNum = 0;
boolean useTB = true;
String filelist = "list_of_files.txt";
if (args.length > 0) {
runNum = Integer.parseInt(args[0]);
}
if (args.length > 1) {
filelist = args[1];
}
if (args.length > 2) {
if (Integer.parseInt(args[2]) == 0) {
useTB = false;
}
}
String outputDir = runNum > 0 ? "plots"+runNum : "plots";
FT ana = new FT(runNum, outputDir, useTB);
List<String> toProcessFileNames = new ArrayList<>();
File file = new File(filelist);
Scanner read;
try {
read = new Scanner(file);
do {
String filename = read.next();
toProcessFileNames.add(filename);

} while (read.hasNext());
read.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(100);
}

int maxevents = 50000000;
if (args.length > 2) {
maxevents = Integer.parseInt(args[2]);
}
int progresscount = 0;
int filetot = toProcessFileNames.size();
for (String runstrg : toProcessFileNames) {
if (count < maxevents) {
progresscount++;
System.out.println(String.format(">>>>>>>>>>>>>>>> FT %s", runstrg));
File varTmpDir = new File(runstrg);
if (!varTmpDir.exists()) {
System.out.println("FILE DOES NOT EXIST");
continue;
}
System.out.println("READING NOW " + runstrg);
HipoDataSource reader = new HipoDataSource();
reader.open(runstrg);
int filecount = 0;
while (reader.hasEvent() && count < maxevents) {
DataEvent event = reader.getNextEvent();
ana.processEvent(event);
filecount++;
count++;
if (count % 10000 == 0) {
System.out.println(count / 1000 + "k events (this is FT on " + runstrg + ") progress : " + progresscount + "/" + filetot);
}
}
reader.close();
}
}
System.out.println("Total : " + count + " events");
ana.analyze();
ana.plot();
ana.write();
}
}
79 changes: 2 additions & 77 deletions monitoring/src/main/java/org/jlab/clas12/monitoring/HTCC.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ public int isSingle(double theta, double phi) {
return isSigleTheta * isSiglePhi;
}

public void processEvent(DataEvent event
) {
public void processEvent(DataEvent event) {
double startTime = 0;
double htccTime = 0;
int sector = 0;
Expand Down Expand Up @@ -258,83 +257,9 @@ public void processEvent(DataEvent event
}
}

}

public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
GStyle.setPalette("kRainBow");
int count = 0;
int runNum = 0;
boolean useTB = true;
String filelist = "list_of_files.txt";
if (args.length > 0) {
runNum = Integer.parseInt(args[0]);
}
if (args.length > 1) {
filelist = args[1];
}
int maxevents = 20000000;
if (args.length > 2) {
maxevents = Integer.parseInt(args[2]);
}
double Eb = 10.2;//10.6f;
if (args.length > 3) {
Eb = Double.parseDouble(args[3]);
}
if (args.length > 4) {
if (Integer.parseInt(args[4]) == 0) {
useTB = false;
}
}
String outputDir = runNum > 0 ? "plots"+runNum : "plots";
HTCC ana = new HTCC(runNum, outputDir);
List<String> toProcessFileNames = new ArrayList<String>();
File file = new File(filelist);
Scanner read;
try {
read = new Scanner(file);
do {
String filename = read.next();
toProcessFileNames.add(filename);

} while (read.hasNext());
read.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(100);
}
int progresscount = 0;
int filetot = toProcessFileNames.size();
for (String runstrg : toProcessFileNames) {
if (count < maxevents) {
progresscount++;
System.out.println(String.format(">>>>>>>>>>>>>>>> %s", runstrg));
File varTmpDir = new File(runstrg);
if (!varTmpDir.exists()) {
System.out.println("FILE DOES NOT EXIST");
continue;
}
System.out.println("READING NOW " + runstrg);
HipoDataSource reader = new HipoDataSource();
reader.open(runstrg);
int filecount = 0;
while (reader.hasEvent() && count < maxevents) {
DataEvent event = reader.getNextEvent();
ana.processEvent(event);
filecount++;
count++;
if (count % 10000 == 0) {
System.out.println(count / 1000 + "k events (this is HTCC analysis on " + runstrg + ") ; progress : " + progresscount + "/" + filetot);
}
}
reader.close();
}
}
System.out.println("Total : " + count + " events");
ana.plot();
ana.write();
}


public void write() {
TDirectory dirout = new TDirectory();
dirout.mkdir("/HTCC/");
Expand Down
53 changes: 0 additions & 53 deletions monitoring/src/main/java/org/jlab/clas12/monitoring/LTCC.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,59 +506,6 @@ public void plot() {
System.out.println(String.format("saved "+outputDir+"/LTCC.png"));

}
public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
GStyle.setPalette("kRainBow");
int count = 0;
int runNum = 0;
boolean useTB = true;
String filelist = "list_of_files.txt";
if(args.length>0)runNum=Integer.parseInt(args[0]);
if(args.length>1)filelist = args[1];
int maxevents = 20000000;
if(args.length>2)maxevents=Integer.parseInt(args[2]);
float Eb =6.42f;//10.6f;
if(args.length>3)Eb=Float.parseFloat(args[3]);
if(args.length>4)if(Integer.parseInt(args[4])==0)useTB=false;
String outputDir = runNum > 0 ? "plots"+runNum : "plots";
LTCC ana = new LTCC(runNum,outputDir,Eb,useTB);
List<String> toProcessFileNames = new ArrayList<String>();
File file = new File(filelist);
Scanner read;
try {
read = new Scanner(file);
do {
String filename = read.next();
toProcessFileNames.add(filename);

}while (read.hasNext());
read.close();
}catch(IOException e){
e.printStackTrace();
System.exit(100);
}
int progresscount=0;int filetot = toProcessFileNames.size();
for (String runstrg : toProcessFileNames) if( count<maxevents ){
progresscount++;
System.out.println(String.format(">>>>>>>>>>>>>>>> %s",runstrg));
File varTmpDir = new File(runstrg);
if(!varTmpDir.exists()){System.out.println("FILE DOES NOT EXIST");continue;}
System.out.println("READING NOW "+runstrg);
HipoDataSource reader = new HipoDataSource();
reader.open(runstrg);
int filecount = 0;
while(reader.hasEvent()&& count<maxevents ) {
DataEvent event = reader.getNextEvent();
ana.processEvent(event);
filecount++;count++;
if(count%10000 == 0) System.out.println(count/1000 + "k events (this is LTCC analysis on "+runstrg+") ; progress : "+progresscount+"/"+filetot);
}
reader.close();
}
System.out.println("Total : " + count + " events");
ana.plot();
ana.write();
}

public void write() {
TDirectory dirout = new TDirectory();
Expand Down
57 changes: 0 additions & 57 deletions monitoring/src/main/java/org/jlab/clas12/monitoring/RICH.java
Original file line number Diff line number Diff line change
Expand Up @@ -852,63 +852,6 @@ public void plot_Counters() {
return;
}


public static void main(String[] args) {
System.setProperty("java.awt.headless", "true");
GStyle.setPalette("kRainBow");
int count = 0;
int runNum = 0;
boolean useTB = true;
String filelist = "list_of_files.txt";
if(args.length>0)runNum=Integer.parseInt(args[0]);
if(args.length>1)filelist = args[1];
int maxevents = 20000000;
if(args.length>2)maxevents=Integer.parseInt(args[2]);
float Eb =10.2f;//10.6f;
if(args.length>3)Eb=Float.parseFloat(args[3]);
if(args.length>4)if(Integer.parseInt(args[4])==0)useTB=false;
String outputDir = runNum > 0 ? "plots"+runNum : "plots";
RICH ana = new RICH(runNum,outputDir,Eb,useTB);
List<String> toProcessFileNames = new ArrayList<String>();
File file = new File(filelist);
Scanner read;
try {
read = new Scanner(file);
do {
String filename = read.next();
toProcessFileNames.add(filename);

}while (read.hasNext());
read.close();
}catch(IOException e){
e.printStackTrace();
System.exit(100);
}
int progresscount=0;int filetot = toProcessFileNames.size();
for (String runstrg : toProcessFileNames) if( count<maxevents ){
progresscount++;
System.out.println(String.format(">>>>>>>>>>>>>>>> %s",runstrg));
File varTmpDir = new File(runstrg);
if(!varTmpDir.exists()){System.out.println("FILE DOES NOT EXIST");continue;}
System.out.println("READING NOW "+runstrg);
HipoDataSource reader = new HipoDataSource();
reader.open(runstrg);
int filecount = 0;
while(reader.hasEvent()&& count<maxevents ) {
DataEvent event = reader.getNextEvent();
ana.processEvent(event);
filecount++;count++;
if(count%100000 == 0) System.out.println(count/1000 + "k events (this is RICH analysis in "+runstrg+") ; progress : "+progresscount+"/"+filetot);
}
reader.close();
}
System.out.println("Total : " + count + " events");

ana.postProcess();
ana.plot();
ana.write();
}

public void postProcess(){
this.FillTimeHistogram();
this.CalcCounters();
Expand Down
Loading

0 comments on commit 4d0680e

Please sign in to comment.