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

Commit

Permalink
Merge pull request #67 from PChatagnon/master
Browse files Browse the repository at this point in the history
CND reconstruction fixed
  • Loading branch information
raffaelladevita authored Jan 10, 2018
2 parents 3390c31 + 3cc40e0 commit ec14e19
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,15 @@ public static DataBank fillCndHitBanks(DataEvent event, ArrayList<CndHit> hitlis

}

public void appendCNDBanks(DataEvent event,ArrayList<CndHit> hitlist) {
if(hitlist.size()!=0){
DataBank bank = this.fillCndHitBanks((DataEvent) event, hitlist);
//bank.show();
event.appendBanks(bank);
//event.show();
}
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ public class CNDCalibrationEngine extends ReconstructionEngine {

public CNDCalibrationEngine() {
super("CND", "chatagnon", "1.0");

}

int Run = -1;

RecoBankWriter rbc;
//test
static int enb =0;
static int ecnd=0;
Expand All @@ -41,38 +42,42 @@ public CNDCalibrationEngine() {

@Override
public boolean processDataEvent(DataEvent event) {
//event.show();
//System.out.println("in data process ");
ArrayList<HalfHit> halfhits = new ArrayList<HalfHit>();
ArrayList<CndHit> hits = new ArrayList<CndHit>();

//test
if(event.hasBank("CVTRec::Tracks")){
hcvt++;
}
// if(event.hasBank("CVTRec::Tracks")){
// hcvt++;
// }

halfhits = HitReader.getCndHalfHits(event);
//1) exit if halfhit list is empty
if(halfhits.size()==0 )
if(halfhits.size()==0 ){
// System.out.println("fin de process (0) : ");
// event.show();
return true;

}
// update calibration constants based on run number if changed
setRunConditionsParameters(event);

//2) find the CND hits from these half-hits
CndHitFinder hitFinder = new CndHitFinder();
hits = hitFinder.findHits(halfhits,0);

CvtGetHTrack cvttry = new CvtGetHTrack();
cvttry.getCvtHTrack(event); // get the list of helix associated with the event
int flag=0;

//int flag=0;
for (CndHit hit : hits){ // findlength for charged particles
double length =hitFinder.findLength(hit, cvttry.getHelices(),0);
if (length!=0){
hit.set_tLength(length); // the path length is non zero only when there is a match with cvt track
if(flag==0){match++;}
flag=1;
//if(flag==0){match++;}
//flag=1;
}

}

// GetVertex getVertex = new GetVertex();
Expand All @@ -82,28 +87,54 @@ public boolean processDataEvent(DataEvent event) {
// }
//

// if(hits.size()!=0){
//
// DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits);
//// System.out.println("event before process : ");
//// event.show();
// event.appendBanks(outbank);
// //System.out.println("event after process : ");
// //event.show();
// ecnd++;
// if(event.hasBank("CVTRec::Tracks")){
// posmatch++;
// //event.getBank("MC::Particle").show();
// //outbank.show();
// }
//
// }
//// System.out.println("fin de process : ");
//// event.show();
// return true;
// }
if(hits.size()!=0){

DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits);
event.appendBank(outbank);
ecnd++;
if(event.hasBank("CVTRec::Tracks")){
posmatch++;
//event.getBank("MC::Particle").show();
//outbank.show();
}

}
return true;
// DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits);
// event.appendBanks(outbank);
// event.show();
// System.out.println("in process event ");
rbc.appendCNDBanks(event,hits);
// ecnd++;
// if(event.hasBank("CVTRec::Tracks")){
// posmatch++;
//event.getBank("MC::Particle").show();
//outbank.show();
// }
// event.show();

} return true;

}

@Override
public boolean init() {
// TODO Auto-generated method stub

rbc = new RecoBankWriter();
System.out.println("in init ");
return true;
}


public void setRunConditionsParameters(DataEvent event) {
if(event.hasBank("RUN::config")==false) {
System.err.println("RUN CONDITIONS NOT READ!");
Expand All @@ -125,7 +156,7 @@ public void setRunConditionsParameters(DataEvent event) {

public static void main (String arg[]) throws IOException {
CNDCalibrationEngine en = new CNDCalibrationEngine();

en.init();
//String input = "/Users/ziegler/Workdir/Files/GEMC/ForwardTracks/pi-.r100.evio";
//String input = "/projet/nucleon/silvia/test.hipo";
Expand All @@ -136,39 +167,51 @@ public static void main (String arg[]) throws IOException {
//String input = "/projet/nucleon/silvia/test.rec.hipo";
//String input = "/projet/nucleon/pierre/test_out3.hipo";
//String input = "/projet/nucleon/silvia/test.hipo";
String input = "/projet/nucleon/pierre/CND_run2052_2053/ctof_cnd_2052_2053.hipo";
String input = "/projet/nucleon/pierre/RecCND/clas_002227.evio.18.hipo";
//String input = "/projet/nucleon/pierre/RecCND/test.hipo";
//String input = "/projet/nucleon/silvia/CLARA/out_clasdispr_small.00849.hipo";
HipoDataSource reader = new HipoDataSource();
reader.open(input);
String outputFile="/projet/nucleon/pierre/CND_run2052_2053/test.hipo";
String outputFile="/projet/nucleon/pierre/RecCND/test1.hipo";
HipoDataSync writer = new HipoDataSync();
writer.open(outputFile);


while(reader.hasEvent()) {
enb++;
DataEvent event = (DataEvent) reader.getNextEvent();

System.out.println("event nb "+enb);
event.show();

//event.show();
//System.out.println("event nb "+enb);

// System.out.println("event avant process ");
// event.show();

//event.getBank("MC::Particle").show();
//if(event.hasBank("CVTRec::Tracks")){event.getBank("CVTRec::Tracks").show();};
en.processDataEvent(event);
if(event.hasBank("CND::hits")){
event.show();
event.getBank("CND::hits").show();
event.getBank("CND::adc").show();
event.getBank("CND::tdc").show();
}

// System.out.println("event après process ");
// event.show();

//System.out.println("avant write ");
writer.writeEvent(event);


if(enb==20) break;

//System.out.println("après write ");

// if(event.hasBank("CND::hits")){
// //event.show();
// System.out.println("event nb "+enb);
// event.getBank("CND::hits").show();
// event.getBank("CND::adc").show();
// event.getBank("CND::tdc").show();
// }



if(enb==30) break;

}
writer.close();

//some statitics on cvt/cnd matching
System.out.println("enb "+enb);
System.out.println("ecnd "+ecnd);
Expand All @@ -177,7 +220,20 @@ public static void main (String arg[]) throws IOException {
System.out.println("match "+match);
System.out.println("%match cnd "+100.*match/posmatch);
System.out.println("Done");


HipoDataSource sortie = new HipoDataSource();
sortie.open(outputFile);

System.out.println("Fichier de sortie : ");
while(sortie.hasEvent()) {

DataEvent event = (DataEvent) sortie.getNextEvent();
//event.show();

}
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CNDEngine() {
}

int Run = -1;

RecoBankWriter rbc;
//test
static int enb =0;
static int ecnd=0;
Expand Down Expand Up @@ -83,13 +83,17 @@ public boolean processDataEvent(DataEvent event) {

if(hits.size()!=0){

DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits);
event.appendBank(outbank);
ecnd++;
if(event.hasBank("CVTRec::Tracks")){
posmatch++;
}
// DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits);
// event.appendBanks(outbank);
// event.show();
System.out.println("in process event ");
rbc.appendCNDBanks(event,hits);
// ecnd++;
// if(event.hasBank("CVTRec::Tracks")){
// posmatch++;
//event.getBank("MC::Particle").show();
//outbank.show();
// }
}
return true;
}
Expand Down Expand Up @@ -169,4 +173,4 @@ public static void main (String arg[]) throws IOException {
System.out.println("Done");
}

}
}

0 comments on commit ec14e19

Please sign in to comment.