12 #include <JANA/JApplication.h>
36 #include <TDirectory.h>
41 #include <TProfile2D.h>
78 TDirectory *
main = gDirectory;
79 gDirectory->mkdir(
"ccal")->cd();
81 ccal_num_events =
new TH1D(
"ccal_num_events",
"CCAL Number of Events",1,0.5,1.5);
85 hdigN =
new TH1I(
"digN",
"CCAL Number of DigiHits; Number of DigiHits; Events", 144, 0, 144 );
86 hdigOcc2D =
new TH2F(
"digOcc2D",
"CCAL DigiHit Occupancy; column; row", 12, -0.5, 11.5, 12, -0.5, 11.5 );
87 hdigInt =
new TH1I(
"digInt",
"CCAL Pulse Integral", 300, 0, 30000);
88 hdigPeak =
new TH1I(
"digPeak",
"CCAL Pulse Peak", 300, 0, 5000);
89 hdigT =
new TH1I(
"digT",
"CCAL Pulse Time; Time [4 ns]; Pulses / ns", 4096, 0, 4096);
90 hdigPed =
new TH1I(
"digPed",
"CCAL Pedestal (All Channels); ADC Counts; Pulses / 10 Counts", 100, 0, 1000);
91 hdigPedChan =
new TProfile(
"digPedChan",
"CCAL Pedestal vs. Channel; ccal id; Average Pedestal [ADC Counts]", 144, -0.5, 143.5);
92 hdigPed2D =
new TH2F(
"digPed2D",
"CCAL Pedestals [ADC Counts]; column; row",12, -0.5, 11.5, 12, -0.5, 11.5);
93 hdigPedSq2D =
new TH2F(
"digPedSq2D",
"CCAL Pedestals Squared [ADC Counts]; column; row", 12, -0.5, 11.5, 12, -0.5, 11.5);
94 hdigIntVsPeak =
new TH2I(
"digIntVsPeak",
"CCAL Pulse Integral vs. Peak Sample; Peak Sample [ADC Units]; Integral [ADC Units]", 200, 0, 4000, 200, 0, 40000 );
95 hdigQF =
new TH1I(
"digQual",
"CCAL Hit Quality; Quality Factor Index; Number of Pulses", 16, -0.5, 15.5 );
101 hhitN =
new TH1I(
"hitN",
"CCAL Number of Hits; Number of Hits; Events", 144, 0, 144 );
102 hhitE =
new TH1I(
"hitE",
"CCAL Hit Energy; Energy [MeV]; Hits / 100 MeV", 100, 0, 10000 );
103 hhitETot =
new TH1I(
"hitETot",
"CCAL Hit Total Energy; Energy [MeV]; Events / 100 MeV", 120, 0, 12000 );
104 hhitiop =
new TH1I(
"hitiop",
"CCAL Pulse Integral over Peak", 300, 0, 300);
105 hhitT =
new TH1I(
"hitT",
"CCAL Hit Time; t [ns]; Hits / 4 ns", 100, -100, 300 );
106 hhitE2D =
new TH2F(
"hitE2D",
"CCAL Hit Average Energy [MeV]; column; row", 12, -0.5, 11.5, 12, -0.5, 11.5 );
107 hhitOcc2D =
new TH2F(
"hitOcc2D",
"CCAL Hit Occupancy; column; row", 12, -0.5, 11.5, 12, -0.5, 11.5 );
113 hclusN =
new TH1I(
"clusN",
"CCAL Number of Clusters; Number of Clusters; Events", 10, -0.5, 9.5 );
114 hclusE =
new TH1I(
"clusE",
"CCAL Cluster Energy; Energy [MeV]; Clusters / 50 MeV", 100, 0, 15000 );
115 hclusETot =
new TH1I(
"clusETot",
"CCAL Cluster Total Energy; Energy [MeV]; Events / 100 MeV", 100, 0, 15000 );
116 hclusT =
new TH1I(
"clusT",
"CCAL Cluster Time; t [ns]; Clusters / 4 ns", 100, -100, 300 );
117 hclusDime =
new TH1I(
"clusDime",
"CCAL Cluster Dimension; Modules in Cluster", 50, -0.5, 49.5);
118 hclusXYHigh =
new TH2I(
"clusXYHigh",
"CCAL Cluster Positions (E > 200 MeV); x [cm]; y [cm]", 100, -12.5, 12.5, 100, -12.5, 12.5 );
119 hclusXYLow =
new TH2I(
"clusXYLow",
"CCAL Cluster Positions (E < 200 MeV); x [cm]; y [cm]", 100, -12.5, 12.5, 100, -12.5, 12.5 );
120 hclusPhi =
new TH1I(
"clusPhi",
"CCAL Cluster #phi; #phi [rad]; Clusters / 62.8 mrad", 100, -3.14, 3.14 );
121 hclusPhi->SetMinimum( 0 );
122 hclus2GMass =
new TH1I(
"clus2GMass",
"CCAL 2 Cluster Invariant Mass E > 1 GeV; Invariant Mass [GeV]", 500, 0.0, 0.6 );
123 hclus2GMass_fcal =
new TH1I(
"clus2GMass_fcal",
"Invariant Mass, 1 CCAL & 1 FCAL Cluster E > 1 GeV; Invariant Mass [GeV]", 500, 0.0, 0.6 );
124 hclusOccEmax =
new TH2I(
"clusOccEmax",
"Occupancy when E_{max} > 3 GeV and E_{cl}-E_{max} < 1.0 GeV; column; row", 12, -0.5, 11.5, 12, -0.5, 11.5);
128 hcomp_bfdt =
new TH1F(
"comp_bfdt",
"FCAL Shower Time - Beam Time; t_{fcal}-t_{beam} [ns]; Counts / 0.5 ns", 400, -100., 100.);
129 hcomp_fcdt =
new TH1F(
"comp_fcdt",
"CCAL Time - FCAL Time; t_{fcal}-t_{ccal} [ns]; Counts / 0.5 ns", 400, -100., 100.);
130 hcomp_bcdt_full =
new TH1F(
"comp_bcdt_full",
"CCAL Shower Time - Beam Time (No Cuts); t_{ccal}-t_{beam} [ns]; Counts / 0.5 ns", 400, -100., 100.);
132 hcomp_cratio =
new TH1F(
"comp_cratio",
"CCAL Energy over Calculated Compton Energy; #frac{E_{ccal}}{E_{comp}}", 200, 0., 2.);
133 hcomp_cfbratio =
new TH1F(
"comp_cfbratio",
"Energy Conservation; #frac{E_{ccal}+E_{fcal}-E_{beam}}{E_{beam}}", 200, -1., 1.);
134 hcomp_cfb2d =
new TH2F(
"comp_cfb2d",
"Reconstructed Energy vs. Calculated Compton Energy; #frac{E_{ccal,comp}+E_{fcal,comp}}{E_{beam}}; #frac{E_{ccal}+E_{fcal}}{E_{beam}}", 200, 0., 1.5, 200, 0., 1.5);
135 hcomp_pfpc =
new TH1F(
"comp_pfpc",
"FCAL - CCAL Azimuthal Angle; #phi_{fcal}-#phi_{ccal} [deg]; Counts / 0.5 degrees", 1440, -360., 360.);
136 hcomp_cxy =
new TH2F(
"comp_cxy",
"Reconstructed Compton Positions in CCAL; x_{ccal} [cm]; y_{ccal} [cm]", 200, -12.5, 12.5, 200, -12.5, 12.5);
137 hcomp_fxy =
new TH2F(
"comp_fxy",
"Reconstructed Compton Positions in FCAL; x_{fcal} [cm]; y_{fcal} [cm]", 200, -30., 30., 200, -30., 30.);
138 hcomp_bcdt =
new TH1F(
"comp_bcdt",
"CCAL Shower Time - Beam Time; t_{ccal}-t_{beam} [ns]; Counts / 0.5 ns", 400, -100., 100.);
140 hcomp_cratio_bkgd =
new TH1F(
"comp_cratio_bkgd",
"CCAL Energy over Calculated Compton Energy (Accidentals); #frac{E_{ccal}}{E_{comp}}", 200, 0., 2.);
141 hcomp_cfbratio_bkgd =
new TH1F(
"comp_cfbratio_bkgd",
"Energy Conservation (Accidentals); #frac{E_{ccal}+E_{fcal}-E_{beam}}{E_{beam}}", 200, -1., 1.);
142 hcomp_cfb2d_bkgd =
new TH2F(
"comp_cfb2d_bkgd",
"Reconstructed Energy vs. Calculated Compton Energy (Accidentals); #frac{E_{ccal,comp}+E_{fcal,comp}}{E_{beam}}; #frac{E_{ccal}+E_{fcal}}{E_{beam}}", 200, 0., 1.5, 200, 0., 1.5);
143 hcomp_pfpc_bkgd =
new TH1F(
"comp_pfpc_bkgd",
"FCAL - CCAL Azimuthal Angle (Accidentals); #phi_{fcal}-#phi_{ccal} [deg]; Counts / 0.5 degrees", 1440, -360., 360.);
144 hcomp_cxy_bkgd =
new TH2F(
"comp_cxy_bkgd",
"Reconstructed Compton Positions in CCAL (Accidentals); x_{ccal} [cm]; y_{ccal} [cm]", 200, -12.5, 12.5, 200, -12.5, 12.5);
145 hcomp_fxy_bkgd =
new TH2F(
"comp_fxy_bkgd",
"Reconstructed Compton Positions in FCAL (Accidentals); x_{fcal} [cm]; y_{fcal} [cm]", 200, -30., 30., 200, -30., 30.);
146 hcomp_bcdt_bkgd =
new TH1F(
"comp_bcdt_bkgd",
"CCAL Shower Time - Beam Time (Accidentals); t_{ccal}-t_{beam} [ns]; Counts / 0.5 ns", 400, -100., 100.);
148 hfcalOcc =
new TH2F(
"fcalOcc",
"FCAL Occupancy for events > 0.5 GeV; x_{fcal} [cm]; y_{fcal} [cm]", 200, -30., 30., 200, -30., 30.);
150 hNPhotons =
new TH1I(
"NPhotons",
"Number of Beam Photons per Event",80,-0.5,79.5);
176 cerr <<
"No geometry accessbile to CCAL_online monitoring plugin." << endl;
177 return RESOURCE_UNAVAILABLE;
180 vector< double > ccal_gains_ch;
181 eventLoop->GetCalib(
"/CCAL/gains",ccal_gains_ch);
182 for(
unsigned int ii=0; ii<ccal_gains_ch.size(); ii++) {
183 cout << ii <<
" " << ccal_gains_ch[ii] << endl;
196 vector< const DCCALGeometry* > geomVec;
197 vector< const DCCALDigiHit* > digiHits;
198 vector< const DCCALHit* > hits;
199 vector< const DCCALShower* > CCALshowerVec;
200 vector< const DFCALShower* > FCALshowerVec;
201 vector< const DBeamPhoton* > beam_photons;
212 eventLoop->GetSingle(trig);
213 eventLoop->GetSingle(dtrig);
224 bool locIsHDDMEvent = eventLoop->GetJEvent().GetStatusBit(
kSTATUS_HDDM);
225 if (!locIsHDDMEvent) goodtrigger=0;
235 eventLoop->Get( geomVec );
236 eventLoop->Get( digiHits );
237 eventLoop->Get( hits );
238 if( hits.size() <= 50 ) {
239 eventLoop->Get( CCALshowerVec );
240 eventLoop->Get( FCALshowerVec );
241 eventLoop->Get( beam_photons );
247 float hitETot = 0., showETot = 0.;
248 for( vector< const DCCALHit*>::const_iterator hitItr = hits.begin();
249 hitItr != hits.end(); ++hitItr ) { hitETot += (**hitItr).E; }
250 for( vector< const DCCALShower*>::const_iterator showItr = CCALshowerVec.begin();
251 showItr != CCALshowerVec.end(); ++showItr ) { showETot += (**showItr).E; }
257 japp->RootFillLock(
this);
263 if( digiHits.size() > 0 )
264 ccal_num_events->Fill(1);
266 hdigN->Fill( digiHits.size() );
268 for( vector< const DCCALDigiHit* >::const_iterator dHitItr = digiHits.begin();
269 dHitItr != digiHits.end(); ++dHitItr ) {
274 hdigOcc2D->Fill( dHit.
column, dHit.
row );
279 hdigPedChan->Fill( chan, dHit.
pedestal );
282 hdigQF->Fill( dHit.
QF );
292 hhitETot->Fill( hitETot );
293 hhitN->Fill( hits.size() );
295 for( vector< const DCCALHit* >::const_iterator hit_itr = hits.begin();
296 hit_itr != hits.end(); ++hit_itr ){
300 hhitE->Fill( hit.
E );
312 if( hits.size() > 50 ){
313 japp->RootFillUnLock(
this);
328 hclusN->Fill( CCALshowerVec.size() );
330 if( CCALshowerVec.size() > 0 )
331 hclusETot->Fill( showETot *
k_to_MeV );
333 for( vector< const DCCALShower*>::const_iterator showItr = CCALshowerVec.begin();
334 showItr != CCALshowerVec.end(); ++showItr ){
338 double showX = shower.
x1;
339 double showY = shower.
y1;
340 double showR =
sqrt( showX*showX + showY*showY );
341 double showE = shower.
E;
342 double showEmax = shower.
Emax;
343 int idmax = shower.
idmax;
344 int ccal_col = idmax%12;
345 int ccal_row = idmax/12;
348 show1Mom.SetX( showX );
349 show1Mom.SetY( showY );
350 show1Mom.SetZ( ZCCAL );
351 show1Mom.SetMag( showE );
353 hclusPhi->Fill( show1Mom.Phi() );
354 hclusE->Fill( showE * k_to_MeV );
355 hclusT->Fill( shower.
time );
356 hclusDime->Fill( shower.
dime );
358 if( showE > 200*
k_MeV )
359 hclusXYHigh->Fill( showX, showY );
361 hclusXYLow->Fill( showX, showY );
363 if( (showEmax > 3.0) && (showE - showEmax < 1.0) )
364 hclusOccEmax->Fill( ccal_col, ccal_row );
366 if( ( showE < 1*
k_GeV ) ||
367 ( showR < 8*
k_cm ) ||
371 for( vector< const DCCALShower*>::const_iterator show2Itr = showItr + 1;
372 show2Itr != CCALshowerVec.end(); ++show2Itr ){
376 double show2X = shower2.
x;
377 double show2Y = shower2.
y;
379 double show2R =
sqrt( show2X * show2X + show2Y * show2Y );
381 if( ( shower2.
E < 1*
k_GeV ) ||
382 ( show2R < 8*
k_cm ) ||
387 show2Mom.SetX( show2X );
388 show2Mom.SetY( show2Y );
389 show2Mom.SetZ( ZCCAL );
390 show2Mom.SetMag( shower2.
E );
395 hclus2GMass->Fill( ( gam1 + gam2 ).M() );
403 for( vector< const DFCALShower*>::const_iterator showFItr = FCALshowerVec.begin();
404 showFItr != FCALshowerVec.end(); ++showFItr ){
409 showFMom.SetZ( showFMom.Z() - m_targetZ );
415 for( vector< const DCCALShower*>::const_iterator showCItr = CCALshowerVec.begin();
416 showCItr != CCALshowerVec.end(); ++showCItr ){
420 double showCX = showC.
x1;
421 double showCY = showC.
y1;
422 double showCR =
sqrt( showCX*showCX + showCY*showCY );
425 showCMom.SetX( showCX );
426 showCMom.SetY( showCY );
427 showCMom.SetZ( ZCCAL );
428 showCMom.SetMag( showC.
E );
430 if( ( showC.
E < 1*
k_GeV ) ||
431 ( showCR < 5*
k_cm ) ||
438 hclus2GMass->Fill( ( gam1 + gam2 ).M() );
446 hNPhotons->Fill( beam_photons.size() );
447 for(
unsigned int ib = 0; ib < beam_photons.size(); ++ib) {
450 double beam_t = beam_photon->
time();
452 for(
unsigned int ih = 0; ih < FCALshowerVec.size(); ++ih) {
453 const DFCALShower *fcal_shower = FCALshowerVec[ih];
454 double fcal_e = fcal_shower->
getEnergy();
460 if(fcal_e<0.5)
continue;
462 hfcalOcc->Fill( fcal_x, fcal_y );
464 double dt_fcal_bm = fcal_t - beam_t;
465 hcomp_bfdt->Fill(dt_fcal_bm);
467 double phif = atan2(fcal_y,fcal_x);
468 double rf = hypot(fcal_x,fcal_y);
469 double zf = fcal_z - m_targetZ;
470 double ecompf = 1. / ( 1./beam_e + (1.-cos(rf/zf)) / me);
472 for(
unsigned int ic = 0; ic < CCALshowerVec.size(); ++ic) {
473 const DCCALShower *ccal_shower = CCALshowerVec[ic];
474 double ccal_e = ccal_shower->
E;
475 double ccal_x = ccal_shower->
x1;
476 double ccal_y = ccal_shower->
y1;
477 double ccal_t = ccal_shower->
time;
479 if(ccal_e<1.5)
continue;
481 double dt_cc_bm = ccal_t - beam_t;
482 double dt_fc_cc = ccal_t - fcal_t;
483 hcomp_fcdt->Fill( dt_fc_cc );
484 hcomp_bcdt_full->Fill( dt_cc_bm );
486 double phic = atan2(ccal_y,ccal_x);
487 double rc = hypot(ccal_x,ccal_y);
488 double zc = ZCCAL - m_targetZ;
489 double ecompc = 1. / (1./beam_e + (1.-cos(rc/zc)) / me);
491 if(dt_fc_cc < 15. || dt_fc_cc > 30.)
continue;
493 if(dt_fcal_bm > 15. && dt_fcal_bm < 23.) {
495 hcomp_cratio->Fill( ccal_e/ecompc );
496 hcomp_cfbratio->Fill( (ccal_e+fcal_e-beam_e)/beam_e );
497 hcomp_cxy->Fill( ccal_x, ccal_y );
498 hcomp_fxy->Fill( fcal_x, fcal_y );
499 hcomp_cfb2d->Fill( (ecompc+ecompf)/beam_e, (ccal_e+fcal_e)/beam_e );
500 hcomp_pfpc->Fill( (phif-phic)*180./pi );
502 hcomp_bcdt->Fill(dt_cc_bm);
504 }
else if( (dt_fcal_bm > -15. && dt_fcal_bm < 1.) || (dt_fcal_bm > 37. && dt_fcal_bm < 53.) ) {
506 hcomp_cratio_bkgd->Fill( ccal_e/ecompc );
507 hcomp_cfbratio_bkgd->Fill( (ccal_e+fcal_e-beam_e)/beam_e );
508 hcomp_cxy_bkgd->Fill( ccal_x, ccal_y );
509 hcomp_fxy_bkgd->Fill( fcal_x, fcal_y );
510 hcomp_cfb2d_bkgd->Fill( (ecompc+ecompf)/beam_e, (ccal_e+fcal_e)/beam_e );
511 hcomp_pfpc_bkgd->Fill( (phif-phic)*180./pi );
513 hcomp_bcdt_bkgd->Fill(dt_cc_bm);
521 japp->RootFillUnLock(
this);
int channel(int row, int column) const
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
JEventProcessor_CCAL_online()
TLorentzVector DLorentzVector
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t init(void)
Called once at program start.
bool Get_IsPhysicsEvent(void) const
uint32_t pedestal
pedestal info used by FPGA (if any)
static evioFileChannel * chan
DGeometry * GetDGeometry(unsigned int run_number)
jerror_t fini(void)
Called after last event of last event source has been processed.
~JEventProcessor_CCAL_online()
DLorentzVector lorentzMomentum(void) const
uint32_t QF
Quality Factor from FPGA algorithms.
uint32_t pulse_peak
maximum sample in pulse
DVector3 getPosition() const
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
bool GetTargetZ(double &z_target) const
z-location of center of target
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
int main(int argc, char *argv[])
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.