2 #include <JANA/JApplication.h>
24 #include <TDirectory.h>
36 #include <JANA/JApplication.h>
37 #include <JANA/JFactory.h>
76 TDirectory *
main = gDirectory;
77 gDirectory->mkdir(
"FCAL_TimingOffsets")->cd();
80 for (
int i = 0; i <
nChan; ++i) {
81 Offsets[i] =
new TH1I(Form(
"Offset_%i",i),Form(
"Timing Offset for Channel %i",i),800,-50,50);
97 dynamic_cast<DApplication*
>(eventLoop->GetJApplication());
105 cerr <<
"No geometry accessbile." << endl;
106 return RESOURCE_UNAVAILABLE;
116 uint64_t eventnumber)
121 eventLoop->GetSingle(locTrigger);
127 vector< const DFCALGeometry* > geomVec;
128 eventLoop->Get( geomVec );
130 if( geomVec.size() != 1 ){
132 cerr <<
"No geometry accessbile." << endl;
133 return RESOURCE_UNAVAILABLE;
136 auto fcalGeom = geomVec[0];
139 double FCAL_C_EFFECTIVE = 15.0;
142 double locTargetZCenter = 0.0;
143 locTargetZCenter = locGeometry->
GetTargetZ(locTargetZCenter);
144 dTargetCenter.SetXYZ(0.0, 0.0, locTargetZCenter);
146 vector< const DFCALDigiHit* > digiHits;
147 vector< const DFCALHit* > hits;
148 vector<const DEventRFBunch*> locEventRFBunches;
149 vector< const DVertex* > kinfitVertex;
150 vector< const DTrackTimeBased* > locTrackTimeBased;
151 vector < const DFCALShower * > matchedShowers;
154 eventLoop->Get( hits );
156 vector< const DFCALShower* > locFCALShowers;
158 if( hits.size() < 500 ){
159 eventLoop->Get(locFCALShowers);
160 eventLoop->Get(locEventRFBunches);
161 eventLoop->Get(locTrackTimeBased);
164 double locStartTime = locEventRFBunches.empty() ? 0.0 : locEventRFBunches[0]->dTime;
170 for (
unsigned int i=0; i < locTrackTimeBased.size() ; ++i){
171 vector<DTrackFitter::Extrapolation_t>extrapolations=locTrackTimeBased[i]->extrapolations.at(
SYS_FCAL);
172 if (extrapolations.size()>0){
173 for (
unsigned int j=0; j< locFCALShowers.size(); ++j){
175 Double_t
x = locFCALShowers[j]->getPosition().X();
176 Double_t
y = locFCALShowers[j]->getPosition().Y();
177 pos=extrapolations[0].position;
178 Double_t trkmass = locTrackTimeBased[i]->mass();
179 Double_t FOM = TMath::Prob(locTrackTimeBased[i]->chisq, locTrackTimeBased[i]->Ndof);
180 Double_t dRho =
sqrt(((pos.X() -
x)*(pos.X() -
x)) + ((pos.Y() -
y)* (pos.Y() -
y)));
182 if(trkmass < 0.15 && dRho < 5 && FOM > 0.0001 ) {
183 matchedShowers.push_back(locFCALShowers[j]);
194 for(
unsigned int k=0; k<locFCALShowers.size(); k++)
196 if (find(matchedShowers.begin(), matchedShowers.end(),locFCALShowers[k]) != matchedShowers.end())
continue;
201 double pos_corrected_Z = locFCALShowers[k]->getPosition().Z();
204 vector <const DFCALCluster *> clusterVector;
205 s1->Get(clusterVector);
208 for (
unsigned int iCluster = 0; iCluster < clusterVector.size(); iCluster++){
210 const vector<DFCALCluster::DFCALClusterHit_t> hitVector = clusterVector[iCluster]->GetHits();
213 for (
unsigned int iHit = 0; iHit < 1; iHit++){
214 double hitEnergy = hitVector[iHit].E;
215 if (hitEnergy <= 0.4)
continue;
216 double hitTime = hitVector[iHit].t;
220 int chanx = hitVector[iHit].x;
221 int chany = hitVector[iHit].y;
222 int ChannelNumber = hitVector[iHit].ch;
224 dFCALblockcenter.SetXYZ(chanx, chany, pos_corrected_Z);
226 double locPathLength = (dFCALblockcenter - dTargetCenter).Mag();
227 double locDeltaT = hitTime - locPathLength/29.9792458 - locStartTime;
229 Offsets[ChannelNumber]->Fill(locDeltaT);
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static double blockLength()
jerror_t init(void)
Called once at program start.
uint32_t Get_L1FrontPanelTriggerBits(void) const
bool GetFCALZ(double &z_fcal) const
z-location of front face of CCAL in cm
JEventProcessor_FCAL_TimingOffsets()
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
DGeometry * GetDGeometry(unsigned int run_number)
~JEventProcessor_FCAL_TimingOffsets()
static TH1I * Offsets[nChan]
bool GetTargetZ(double &z_target) const
z-location of center of target
jerror_t fini(void)
Called after last event of last event source has been processed.
int main(int argc, char *argv[])
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.