Skip to content

Commit

Permalink
Merge pull request #48 from dglazier/master
Browse files Browse the repository at this point in the history
update qadb
  • Loading branch information
dglazier committed Aug 21, 2022
2 parents 80c1ed9 + af8a7b8 commit 050b2f7
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 17 deletions.
53 changes: 39 additions & 14 deletions Clas12Banks/clas12reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,14 @@ namespace clas12 {
_pids.emplace_back(pidch);
}
else{
if(_bftbparts->getRows()){
if(_bftbparts->getRows()!=0){
_bparts->setEntry(i);
_bftbparts->setEntry(i);

auto pidch=_bparts->getPid();
auto pidch=_bftbparts->getPid();
if(pidch==0) //no PID use charge instead
pidch=_bparts->getCharge()*UndefPDG;

_pids.emplace_back(pidch);
}
else{//if not ftbased use FD based
Expand All @@ -271,15 +273,9 @@ namespace clas12 {
}
return _pids;
}
bool clas12reader::readEvent(){

//First get pid of tracks and save in _pids
//also responsible for calling hiporead()
preCheckPids();

//Second check qa
//Special run banks
if(_brunconfig.get())_event.getStructure(*_brunconfig.get());
bool clas12reader::checkQA(){

//check if event has QA requirements and those were met
if(_db!=nullptr){
if(_applyQA&&_db->qa()!=nullptr){
Expand All @@ -292,7 +288,38 @@ namespace clas12 {
_db->qa()->accumulateCharge(_brunconfig->getEvent());
}
}
return true;
}
bool clas12reader::justCheckQA(){
if(_brunconfig.get())_event.getStructure(*_brunconfig.get());
if(checkQA()==false) return false;
return true;
}
// double clas12reader::sumChargeFromQA(){
// while(_reader.next()){
// if(_nevent==_nToProcess){
// summary();
// return false; //reached supplied event limit
// }
// hipoRead();
// ++_nevent;
// if(justCheckQA())
// ++_nselected;
// }
// std::cout<<" clas12reader::sumChargeFromQA() "<<db()->qa()->getAccCharge()<<" from "<<_nselected <<" events out of "<<_nevent<<endl;
// return db()->qa()->getAccCharge();
// }

bool clas12reader::readEvent(){

//First get pid of tracks and save in _pids
//also responsible for calling hiporead()
preCheckPids();

//Second check qa
//Special run banks
if(_brunconfig.get())_event.getStructure(*_brunconfig.get());
if(checkQA()==false) return false;

//Third check if event is of the right type
if(!passPidSelect()){
Expand Down Expand Up @@ -532,15 +559,13 @@ namespace clas12 {
///connect to the data bases
void clas12reader::connectDataBases(clas12databases* db){
_db=db;
//void clas12reader::connectDataBases(){

_connectDB=true;

// if(_runNo==0){
_runNo=readQuickRunConfig(_filename);
//}

if(_verbose )std::cout<<"Connecting databases to run "<<_runNo<<std::endl;
if(_runNo!=0)_db->notifyRun(_runNo);
if(_runNo!=0)_db->notifyRun(_runNo);
}
/////////////////////////////////////////////////////////
///make a list of banks, required for writer
Expand Down
8 changes: 7 additions & 1 deletion Clas12Banks/clas12reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ namespace clas12 {
if(db()->qa()!=nullptr) return db()->qa()->getAccCharge();
return _runBeamCharge;
}

int getRunNumber()const {return _runNo;}//works if connectDatabases called

double getCurrApproxCharge(){return _runBeamCharge*_nevent/_reader.getEntries();}

void summary(){
Expand Down Expand Up @@ -314,7 +317,9 @@ namespace clas12 {

bool _applyQA=false;
bool _connectDB=false;

bool checkQA();
bool justCheckQA();

public:

//Database stuff
Expand All @@ -338,6 +343,7 @@ namespace clas12 {
}
}

//double sumChargeFromQA();

private:
///////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions Clas12Banks/qadb_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace clas12 {
///////////////////////////////////////////////////////
///Checks if an event passes all the QA requirements
bool qadb_reader::passQAReqs(int evNb){
//std::cout<<"DEBUG qadb_reader::passQAReqs "<<_runNb<<" "<<evNb<<std::endl;
if(_runNb==0) return true;//e.g. simulation

//First event always has index 0 which doesn't exist in qaDB
Expand All @@ -38,6 +39,8 @@ namespace clas12 {
if(passAsymReq && queried){
//If an event is Golden it won't have other defects
if(_reqGolden){
// std::cout<<"DEBUG qadb_reader::passQAReqs "<<_runNb<<" "<<evNb<<"isgolden "<<isGolden(_runNb,evNb)<<std::endl;

//If the event passes the requirements, add charge
if(isGolden(_runNb,evNb)){
_qa.AccumulateCharge();
Expand Down
1 change: 1 addition & 0 deletions Clas12Banks/rcdb_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ namespace clas12 {
fetcher.solenoid_current=getDoubleValue(runNb, "solenoid_current");
fetcher.solenoid_scale=getDoubleValue(runNb, "solenoid_scale");
fetcher.target_position=getDoubleValue(runNb, "target_position");
fetcher.target_polarization=getDoubleValue(runNb, "target_polarization");
fetcher.test=getDoubleValue(runNb, "test");
fetcher.torus_current=getDoubleValue(runNb, "torus_current");
fetcher.torus_scale=getDoubleValue(runNb, "torus_scale");
Expand Down
1 change: 1 addition & 0 deletions Clas12Banks/rcdb_vals.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace clas12 {
float solenoid_current{0}; //Solenoid current
float solenoid_scale{0}; //Solenoid scale factor
float target_position{0}; //Target position
float target_polarization{0}; //Target position
float test{0}; //Beam test
float torus_current{0}; //Torus current
float torus_scale{0}; //Torus scale factor
Expand Down
3 changes: 2 additions & 1 deletion RunRoot/Ex10_clas12DatabasesChain.C
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ void Ex10_clas12DatabasesChain(){
//cout<<"Event count: "<<rcdbData.event_count<<endl;
//cout<<"Beam energy: "<<rcdbData.beam_energy<<endl;
//cout<<"Beam current: "<<rcdbData.beam_current<<endl;

//cout<<"Target Polarisation: "<<rcdbData.target_polarization<<endl;

if(c12->ccdb()){
//cout<< ccdbElSF.size()<<endl; //-0.036
//cout<< ccdbElSF[0].size()<<endl; //-0.036
Expand Down
2 changes: 1 addition & 1 deletion clasqaDB

0 comments on commit 050b2f7

Please sign in to comment.