12 #include <JANA/JApplication.h>
30 #include <TDirectory.h>
35 #include <TProfile2D.h>
72 TDirectory *
main = gDirectory;
73 gDirectory->mkdir(
"fcal")->cd();
78 fcal_num_events =
new TH1D(
"fcal_num_events",
"FCAL number of events",1, 0.5, 1.5);
80 m_digInt =
new TH1I(
"digHitE",
"FCAL Raw Pulse Integral; Integral [2 V * 4 ns / 4096]; Pulses / ( 100 * 2 V * 4 ns / 4096 )", 300, 0, 30000 );
81 m_digCoarseT =
new TH1I(
"digCoarseTime",
"FCAL Raw Pulse Coarse Time; Time [4 ns]; Pulses / 4 ns", 100, 0, 100 );
83 m_digCoarseTChan =
new TProfile(
"digCoarseTChan",
"FCAL Coarse Time vs. Channel; Channel Index; Average Time [4 ns]",
85 m_digPreciseT =
new TH1I(
"digPreciseT",
"FCAL Raw Pulse Precise Time; Time [62.5 ps]; Pulses / 62.5 ps", 64, -0.5, 63.5 );
86 m_digPreciseTChan =
new TProfile(
"digPreciseTChan",
"FCAL Precise Time vs. Channel; Channel Index; Average Time [62.5 ps]",
88 m_digT =
new TH1I(
"digT",
"FCAL Pulse Time; t [62.5 ps]; Pulses / 625 ps", 500, 0, 5000 );
89 m_digT0 =
new TH1I(
"digT0",
"FCAL Pulse Energy Weighted Average Time; t_{0} [62.5 ps]; Events / 625 ps", 500, 0, 5000 );
90 m_digTmT0 =
new TH1I(
"digTmT0",
"FCAL Pulse Local Time; t - t_{0} [62.5 ps]; Pulses / 625 ps", 200, -1000, 1000 );
91 m_digTmT02D =
new TH2F(
"digTmT02D",
"FCAL Pulse Local Time [62.5 ps]; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
92 m_digPed =
new TH1I(
"digPed",
"FCAL Pedestal (All Channels); ADC Counts; Pules / 10 Counts", 100, 0, 1000 );
93 m_digPedChan =
new TProfile(
"digPedChan",
"FCAL Pedestal vs. Channel; Channel Index; Average Pedestal [ADC Counts]", 2800,-0.5,2799.5 );
94 m_digPed2D =
new TH2F(
"digPed2D",
"FCAL Pedestal [ADC Counts]; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
95 m_digPedSq2D =
new TH2F(
"digPedSq2D",
"FCAL Pedestal^{2} [ADC Counts^{2}]; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
96 m_digQual =
new TH1I(
"digQual",
"FCAL Hit Quality; Quality Factor Index; Number of Pulses", 16, -0.5, 15.5 );
97 m_digNUnder =
new TH1I(
"digNUnder",
"FCAL Number of Underflows per Event; Number of Underflows; Events / 1",
99 m_digNOver =
new TH1I(
"digNOver",
"FCAL Number of Overflows per Event; Number of Overflows; Events / 1",
101 m_digN =
new TH1I(
"digN",
"FCAL Number of Raw Hits per Event; Number of Hits; Events / 5", 600, 0, 3000 );
102 m_digPeakV =
new TH1I(
"digPeakV",
"FCAL Pulse Peak; Peak Sample [Volts]; Pulses / 10 mV", 210, 0, 2.1 );
103 m_digPeakV2D =
new TProfile2D(
"digPeakV2D",
"FCAL Pulse Peak [Volts]; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
104 m_digOcc2D =
new TH2F(
"digOcc2D",
"FCAL Pulse Occupancy; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
105 m_digIntVsPeak =
new TH2I(
"digIntVsPeak",
"FCAL Pulse Integral vs. Peak Sample; Peak Sample [ADC Units]; Integral [ADC Units]", 200, 0, 4000, 200, 0, 40000 );
106 m_digIntToPeak =
new TH1I(
"digIntToPeak",
"Pedestal Subtracted Integral to Peak Ratio (Peak > 200); Ratio; Pulses / 0.1", 200, 0, 20 );
112 m_hitN =
new TH1I(
"hitN",
"FCAL Number of Hits; Number of Hits; Events / 5 Hits", 600, 0, 3000 );
113 m_hitE =
new TH1I(
"hitE",
"FCAL Hit Energy; Energy [MeV]; Hits / 100 MeV", 100, 0, 10000 );
114 m_hitETot =
new TH1I(
"hitETot",
"FCAL Hit Total Energy; Energy [MeV]; Events / 100 MeV", 100, 0, 10000 );
115 m_hitT =
new TH1I(
"hitT",
"FCAL Hit Time; t [ns]; Hits / 4 ns", 100, 0, 400 );
116 m_hitT0 =
new TH1I(
"hitT0",
"FCAL Hit Energy Weighted Average Time; t_{0} [ns]; Events / 4 ns", 100, 0, 400 );
117 m_hitTmT0 =
new TH1I(
"hitTmT0",
"FCAL Hit Local Time; t-t_{0} [ns]; Hits / 0.4 ns", 100, -20, 20 );
118 m_hitE2D =
new TH2F(
"hitE2D",
"FCAL Hit Average Energy [MeV]; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
119 m_hitTmT02D =
new TH2F(
"hitTmT02D",
"FCAL Hit Local Time [ns]; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
120 m_hitTmT0Sq2D =
new TH2F(
"hitTmT0Sq2D",
"FCAL Hit Local Time^{2} [ns^{2}]; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
121 m_hitOcc2D =
new TH2F(
"hitOcc2D",
"FCAL Hit Occupancy; column; row", 61, -1.5, 59.5, 61, -1.5, 59.5 );
127 m_clusN =
new TH1I(
"clusN",
"FCAL Number of Clusters; Number of Clusters; Events", 40, -0.5, 39.5 );
128 m_clusE =
new TH1I(
"clusE",
"FCAL Cluster Energy; Energy [MeV]; Clusters / 50 MeV", 100, 0, 15000 );
129 m_clusETot =
new TH1I(
"clusETot",
"FCAL Cluster Total Energy; Energy [MeV]; Events / 100 MeV", 100, 0, 15000 );
130 m_clusT =
new TH1I(
"clusT",
"FCAL Cluster Time; t [ns]; Clusters / 4 ns", 100, 0, 400 );
131 m_clusT0 =
new TH1I(
"clusT0",
"FCAL Cluster Energy Weighted Average Time; t_{0} [ns]; Events / 4 ns]", 100, 0, 400 );
132 m_clusTmT0 =
new TH1I(
"clusTmT0",
"FCAL Cluster Local Time; t - t_{0} [ns]; Clusters / 0.8 ns", 100, -40, 40 );
133 m_clusXYHigh =
new TH2I(
"clusXYHigh",
"FCAL Cluster Positions (E > 200 MeV); x [cm]; y [cm]", 100, -150, 150, 100, -150, 150 );
134 m_clusXYLow =
new TH2I(
"clusXYLow",
"FCAL Cluster Positions (E < 200 MeV); x [cm]; y [cm]", 100, -150, 150, 100, -150, 150 );
135 m_clusPhi =
new TH1I(
"clusPhi",
"FCAL Cluster #phi; #phi [rad]; Clusters / 62.8 mrad", 100, -3.14, 3.14 );
136 m_clusPhi->SetMinimum( 0 );
137 m_clus2GMass =
new TH1I(
"clus2GMass",
"FCAL 2 Cluster Invariant Mass E > 1 GeV; Invariant Mass [GeV]", 500, 0.0, 0.6 );
143 m_show2GMass =
new TH1I(
"show2GMass",
"FCAL 2 Shower Invariant Mass E > 1 GeV; Invariant Mass [GeV]", 500, 0.0, 1.0 );
144 m_showZvsE =
new TH2I(
"showZvsE",
"FCAL z_{shower} vs. E_{shower}; E_{shower} [GeV]; z_{shower} [cm]", 120, 0.0, 6.0, 120, 620, 680 );
145 m_showECorVsE =
new TH2I(
"showECorVsE",
"FCAL E_{shower}/E_{cluster} vs. E_{shower}; E_{shower} [GeV]; E_{shower}/E_{cluster}", 200, 0.0, 6.0, 200, 0.0, 2.0 );
146 m_showTsMTcVsZ =
new TH2I(
"showTsMTcVsZ",
"FCAL t_{shower} - t_{cluster} vs. z_{shower}; z_{shower} cm; t_{shower} - t_{cluster} [ns]", 120, 620, 680, 120, -6, 6 );
172 cerr <<
"No geometry accessbile to FCAL_online monitoring plugin." << endl;
173 return RESOURCE_UNAVAILABLE;
185 vector< const DFCALGeometry* > geomVec;
186 vector< const DFCALDigiHit* > digiHits;
187 vector< const DFCALHit* > hits;
188 vector< const DFCALCluster* > clusterVec;
189 vector< const DFCALShower* > showerVec;
196 eventLoop->GetSingle(trig);
204 bool locIsHDDMEvent = eventLoop->GetJEvent().GetStatusBit(
kSTATUS_HDDM);
205 if (!locIsHDDMEvent) goodtrigger=0;
213 eventLoop->Get( geomVec );
214 eventLoop->Get( digiHits );
215 eventLoop->Get( hits );
216 if( hits.size() <= 500 ){
217 eventLoop->Get( clusterVec );
218 eventLoop->Get( showerVec );
236 double totIntegral = 0;
237 double intWeightTime = 0;
246 map< const DFCALDigiHit*, pair<const Df250PulseIntegral*, const Df250PulsePedestal*> > pi_pp_cache;
247 map< const DFCALDigiHit*, const Df250PulseData* > pd_cache;
249 for( vector< const DFCALDigiHit* >::const_iterator dHitItr = digiHits.begin();
250 dHitItr != digiHits.end(); ++dHitItr ){
252 totIntegral += (**dHitItr).pulse_integral;
253 intWeightTime += (**dHitItr).pulse_integral * (**dHitItr).pulse_time;
261 dHit.GetSingle( pulseInt );
262 if( pulseInt ) pulseInt->GetSingle( pulsePed );
263 dHit.GetSingle( pulseDat );
265 pi_pp_cache[&dHit] = pair<const Df250PulseIntegral*, const Df250PulsePedestal*>(pulseInt, pulsePed);
266 pd_cache[&dHit] = pulseDat;
269 intWeightTime /= totIntegral;
282 for( vector< const DFCALHit* >::const_iterator hit_itr = hits.begin();
283 hit_itr != hits.end(); ++hit_itr ){
285 hitETot += (**hit_itr).E;
286 hitEwtT += (**hit_itr).E * (**hit_itr).t;
296 for( vector< const DFCALCluster*>::const_iterator clusItr = clusterVec.begin();
297 clusItr != clusterVec.end(); ++clusItr ){
299 clusETot += (**clusItr).getEnergy();
300 clusEwtT += (**clusItr).getEnergy() * (**clusItr).getTime();
303 clusEwtT /= clusETot;
309 japp->RootFillLock(
this);
311 if( digiHits.size() > 0 )
312 fcal_num_events->Fill(1);
314 m_digT0->Fill( intWeightTime );
315 m_digN->Fill( digiHits.size() );
320 for( vector< const DFCALDigiHit* >::const_iterator dHitItr = digiHits.begin();
321 dHitItr != digiHits.end(); ++dHitItr ){
328 m_digOcc2D->Fill( dHit.
column, dHit.
row );
331 pair<const Df250PulseIntegral*, const Df250PulsePedestal*> &pulseX = pi_pp_cache[&dHit];
339 if( pulseDat || (pulseInt && pulsePed) ){
341 double pulse_peak, pulse_integral,
pedestal, nsamples_integral, nsamples_pedestal;
345 pulse_integral = pulseDat->
integral;
352 pulse_integral = pulseInt->
integral;
355 nsamples_pedestal = 1;
358 double peakV = pulse_peak * 2.0 / 4096;
360 m_digPeakV->Fill( peakV );
361 m_digPeakV2D->Fill( dHit.
column, dHit.
row, peakV );
367 if( pulse_peak == 4096 ) ++nOverflow;
369 m_digIntVsPeak->Fill( pulse_peak, pulse_integral );
371 double integral = (double)( pulse_integral -
373 nsamples_integral/nsamples_pedestal ) );
374 double peak = (double)( pulse_peak - pedestal/nsamples_pedestal );
376 if( pulse_peak > 300 )
377 m_digIntToPeak->Fill( integral / peak );
389 if( digiHits.size() > 0 )
390 m_digTmT0->Fill( dHit.
pulse_time - intWeightTime );
392 m_digCoarseT->Fill( coarseT );
393 m_digCoarseTChan->Fill( chan, coarseT );
394 m_digPreciseT->Fill( preciseT );
395 m_digPreciseTChan->Fill( chan, preciseT );
397 m_digPedChan->Fill( chan, dHit.
pedestal );
400 m_digQual->Fill( dHit.
QF );
402 m_digNOver->Fill( nOverflow );
418 m_hitETot->Fill( hitETot*
k_to_MeV );
419 m_hitT0->Fill( hitEwtT );
421 m_hitN->Fill( hits.size() );
422 for( vector< const DFCALHit* >::const_iterator hit_itr = hits.begin();
423 hit_itr != hits.end(); ++hit_itr ){
427 double locTime = ( hit.
t - hitEwtT )*
k_to_nsec;
429 m_hitE->Fill( hit.
E*k_to_MeV );
432 if( hits.size() > 1 )
433 m_hitTmT0->Fill( locTime );
435 if (fabs(locTime) < 20){
436 m_hitTmT02D->Fill( hit.
column, hit.
row, locTime );
437 m_hitTmT0Sq2D->Fill( hit.
column, hit.
row, locTime*locTime );
441 m_hitE2D->Fill( hit.
column, hit.
row, hit.
E*k_to_MeV );
449 if( hits.size() > 500 ){
450 japp->RootFillUnLock(
this);
465 m_clusN->Fill( clusterVec.size() );
467 if( clusterVec.size() > 0 ){
469 m_clusT0->Fill( clusEwtT );
470 m_clusETot->Fill( clusETot * k_to_MeV );
473 for( vector< const DFCALCluster*>::const_iterator clusItr = clusterVec.begin();
474 clusItr != clusterVec.end(); ++clusItr ){
481 double clusR =
sqrt( clusX * clusX + clusY * clusY );
486 m_clusPhi->Fill( clus1Mom.Phi() );
488 m_clusT->Fill( cluster.
getTime() );
490 if( clusterVec.size() > 1 )
491 m_clusTmT0->Fill( cluster.
getTime() - clusEwtT );
505 ( clusR < 20*
k_cm ) ||
509 for( vector< const DFCALCluster*>::const_iterator clus2Itr = clusItr + 1;
510 clus2Itr != clusterVec.end(); ++clus2Itr ){
517 double clus2R =
sqrt( clus2X * clus2X + clus2Y * clus2Y );
524 ( clus2R < 20*
k_cm ) ||
536 m_clus2GMass->Fill( ( gam1 + gam2 ).M() );
550 for( vector< const DFCALShower* >::const_iterator showItr = showerVec.begin();
551 showItr != showerVec.end(); ++showItr ){
556 show.GetSingle( clus );
557 if( clus == NULL )
continue;
560 clusMom.SetZ( clusMom.Z() - m_targetZ );
564 showMom.SetZ( showMom.Z() - m_targetZ );
574 for( vector< const DFCALShower* >::const_iterator show2Itr = showItr + 1;
575 show2Itr != showerVec.end(); ++show2Itr ){
587 show2Mom.SetZ( show2Mom.Z() - m_targetZ );
593 m_show2GMass->Fill( ( gam1 + gam2 ).M() );
598 japp->RootFillUnLock(
this);
uint32_t QF
Quality Factor from FPGA algorithms.
DVector3 getCentroid() const
~JEventProcessor_FCAL_online()
uint32_t nsamples_integral
number of samples used in integral
TLorentzVector DLorentzVector
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
uint32_t pulse_peak
from Pulse Pedestal Data word
jerror_t init(void)
Called once at program start.
uint32_t pedestal
pedestal info used by FPGA (if any)
jerror_t fini(void)
Called after last event of last event source has been processed.
uint32_t nsamples_integral
number of samples used in integral
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
uint32_t GetNHits(void) const
static evioFileChannel * chan
DGeometry * GetDGeometry(unsigned int run_number)
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
int channel(int row, int column) const
uint32_t integral
from Pulse Integral Data word
uint32_t pedestal
from Pulse Integral Data word (future)
uint32_t nsamples_pedestal
number of samples used in pedestal
static TH1I * pedestal[nChan]
JEventProcessor_FCAL_online()
DVector3 getPosition() const
bool GetTargetZ(double &z_target) const
z-location of center of target
int main(int argc, char *argv[])
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.