Skip to content

Commit

Permalink
Merge pull request #8 from dglazier/RafoStartTime
Browse files Browse the repository at this point in the history
fix starttime vertex correction bug, add start time algorithm for hig…
  • Loading branch information
dglazier authored Sep 17, 2020
2 parents 2760a46 + 57c46dc commit cd0bc75
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 14 deletions.
77 changes: 68 additions & 9 deletions actions/C12StartTimeFromParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,43 @@

namespace chanser{

////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
class C12StartTimeFromParticle : public C12StartTime{

public:
C12StartTimeFromParticle() = default;

C12StartTimeFromParticle(TString timeParticle):_timeName(timeParticle){};

void SetC12(CLAS12FinalState* c12) final{
void SetC12(CLAS12FinalState* c12) override{
_c12fs=c12;
_fromTime=static_cast<CLAS12Particle*>(_c12fs->GetParticle(_timeName));
_bunchTime=_c12fs->BunchTime();
_sTimePeak=_c12fs->STimePeak();
}
void Reset() final{_timeZero=0;}
Double_t withParticle(CLAS12Particle* p) const final{
Double_t withParticle(CLAS12Particle* p) const override{
if(_timeZero==0) _timeZero=TimeZero(_fromTime->DeltaTime());
return _timeZero-p->Vertex().Z()/2.99792e+08*1E9;
//return _timeZero;
return _timeZero+p->Vertex().Z()/2.99792e+08*1E9;
}

const TString GetName() const final {return TString("C12StartTimeFromParticle = ")+_timeName;}
const TString GetName() const override {return TString("C12StartTimeFromParticle = ")+_timeName;}

const TString& TimeParticeName()const {return _timeName;}

protected:
CLAS12Particle* _fromTime{nullptr};//!
mutable Double_t _timeZero{0};
Double_t TimeZero(Float_t ptime) const;

private:

TString _timeName;
CLAS12Particle* _fromTime{nullptr};//!
Float_t _bunchTime{0};
Float_t _sTimePeak{0};
mutable Double_t _timeZero{0};

Double_t TimeZero(Float_t ptime) const;


ClassDefOverride(chanser::C12StartTimeFromParticle,1);
};
#pragma link C++ class chanser::C12StartTimeFromParticle;
Expand All @@ -57,5 +62,59 @@ namespace chanser{
return stime;
}

////////////////////////////////////////////////////////////
class C12StartTimeFromHighMomentum : public C12StartTimeFromParticle{

public:
C12StartTimeFromHighMomentum() = default;

C12StartTimeFromHighMomentum(TString timeParticle):C12StartTimeFromParticle(timeParticle){};

void SetC12(CLAS12FinalState* c12) override;

Double_t withParticle(CLAS12Particle* p) const final{
//Find the highest momentum particle
_fastest.SetXYZT(0,0,0,0);
CLAS12Particle* fastptr={nullptr};
for(auto* phigh : _possibleParticle){
if( phigh->P4().P() > _fastest.P()){
_fastest=phigh->P4();
fastptr=phigh;
}
}
//find the start time using the highest momentum particle and p
if(_timeZero==0) _timeZero=TimeZero(fastptr->DeltaTime());
return _timeZero - p->Vertex().Z()/2.99792e+08*1E9;
}
const TString GetName() const override {return TString("C12StartTimeFromHighMomentum = ") + TimeParticeName();}

private :

std::vector<CLAS12Particle*> _possibleParticle;//!
mutable HSLorentzVector _fastest;//!

ClassDefOverride(chanser::C12StartTimeFromHighMomentum,1);
};
#pragma link C++ class chanser::C12StartTimeFromHighMomentum;

inline void C12StartTimeFromHighMomentum::SetC12(CLAS12FinalState* c12) {

C12StartTimeFromParticle::SetC12(c12);

auto choices = TimeParticeName().Tokenize(":");
for(auto* particleName : *choices){
auto particle=static_cast<CLAS12Particle*>(_c12fs->GetParticle(particleName->GetName()));
if(particle==nullptr){
std::cerr<<"WARNING C12StartTimeFromHighMomentum no such particle "<<particleName->GetName()<<std::endl;
}

_possibleParticle.push_back(particle);
}
if(_possibleParticle.empty()){
std::cerr<<"ERROR C12StartTimeFromHighMomentum no correctly named particles given"<<std::endl;
exit(0);
}
return;
}

}
2 changes: 1 addition & 1 deletion core/CLAS12FinalState.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace chanser{
Float_t _startTime{0};

Float_t _bunchTime = 2.0080160*2;
Float_t _sTimePeak = 44.125;
Float_t _sTimePeak = 44.205;

ClassDefOverride(chanser::CLAS12FinalState,1);
};
Expand Down
9 changes: 5 additions & 4 deletions finalstates/Pi2/Create_Pi2.C
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
FS->UseOutputRootTree();
//FS->UseOutputHipoNtuple();

FS->SetStartTimePeak(43.9);
// FS->SetStartTimePeak(43.9);


//Truth Matching, before ParticleData so can add to that tree
Expand All @@ -17,8 +17,8 @@

// Make particle trees first in case want to add cut flags
ParticleDataManager pdm{"particle",1};
// pdm.SetParticleOut(new MyParticleOutEvent);
pdm.SetParticleOut("e-",new MVA_El_Data);
pdm.SetParticleOut(new CLAS12ParticleOutEvent0);
//pdm.SetParticleOut("e-",new MVA_El_Data);
FS->RegisterPostKinAction(pdm);


Expand Down Expand Up @@ -51,6 +51,7 @@


///StartTime
//StartTimeAction st("StartTime",new C12StartTimeFromHighMomentum("Electron:Pip:Pim"));
StartTimeAction st("StartTime",new C12StartTimeFromParticle("Electron"));
FS->RegisterPreTopoAction(st); //PRETOPO

Expand All @@ -61,7 +62,7 @@
FS->RegisterPreTopoAction(pcorrm); //PRETOPO

////Write to file for later processing
FS->WriteToFile("Pi2_Masked.root");
FS->WriteToFile("Pi_STElectronpZ.root");

FS->Print();
//Delete the final state rather than let ROOT try
Expand Down

0 comments on commit cd0bc75

Please sign in to comment.