14 #include <JANA/JEvent.h>
26 return thit1->
E>thit2->
E;
30 for( vector<const DFCALHit*>::const_iterator fcalhits_itr = fcalhits.begin();
31 fcalhits_itr != fcalhits.end(); fcalhits_itr++) {
32 if(theClusterHit.
id == (*fcalhits_itr)->id)
45 MIN_CLUSTER_BLOCK_COUNT = 2;
46 MIN_CLUSTER_SEED_ENERGY = 0.035;
48 MAX_HITS_FOR_CLUSTERING = 250;
50 gPARMS->SetDefaultParameter(
"FCAL:MIN_CLUSTER_BLOCK_COUNT", MIN_CLUSTER_BLOCK_COUNT);
51 gPARMS->SetDefaultParameter(
"FCAL:MIN_CLUSTER_SEED_ENERGY", MIN_CLUSTER_SEED_ENERGY);
52 gPARMS->SetDefaultParameter(
"FCAL:MAX_HITS_FOR_CLUSTERING", MAX_HITS_FOR_CLUSTERING);
53 gPARMS->SetDefaultParameter(
"FCAL:TIME_CUT",TIME_CUT,
"time cut for associating FCAL hits together into a cluster");
63 double fcalFrontFaceZ;
76 cerr <<
"No geometry accessbile." << endl;
77 return RESOURCE_UNAVAILABLE;
80 fcalFaceZ_TargetIsZeq0 = fcalFrontFaceZ - targetZ;
92 vector<const DFCALHit*> fcalhits;
93 eventLoop->Get(fcalhits);
97 if(fcalhits.size() > MAX_HITS_FOR_CLUSTERING)
return NOERROR;
99 vector<const DFCALGeometry*> geomVec;
100 eventLoop->Get(geomVec);
112 for (vector<const DFCALHit*>::const_iterator hit = fcalhits.begin();
113 hit != fcalhits.end(); hit++ ) {
114 if ( (**hit).E < 1
e-6 )
continue;
115 hits->
hit[nhits].
id = (**hit).id;
116 hits->
hit[nhits].
ch = fcalGeom.
channel( (**hit).row, (**hit).column );
117 hits->
hit[nhits].
x = (**hit).x;
118 hits->
hit[nhits].
y = (**hit).y;
119 hits->
hit[nhits].
E = (**hit).E;
120 hits->
hit[nhits].
t = (**hit).t;
125 cout <<
"ERROR: FCALCluster_factory: number of hits "
126 << nhits <<
" larger than " << FCAL_USER_HITS_MAX << endl;
134 for (
int i = 0; i < nhits; i++ ) {
138 const unsigned int max = 999;
140 unsigned int clusterCount = 0;
142 for ( iter=0; iter < 99; iter++ ) {
147 bool something_changed =
false;
148 for (
unsigned int c = 0;
c < clusterCount;
c++ ) {
150 something_changed |= clusterList[
c]->
update( hits, fcalFaceZ_TargetIsZeq0 );
152 if (something_changed) {
153 for (
unsigned int c = 0;
c < clusterCount;
c++ ) {
157 for (
int h = 0;
h < nhits;
h++ ) hitUsed[
h] = 0;
166 for (
int ih = 0; ih < hits->
nhits; ih++ ) {
167 double energy = hits->
hit[ih].
E;
169 if (energy < MIN_CLUSTER_SEED_ENERGY)
171 double totalAllowed = 0;
172 for (
unsigned int c = 0;
c < clusterCount;
c++ ) {
177 if (energy > totalAllowed) {
180 clusterList[clusterCount]->
addHit(ih,1.);
181 clusterList[clusterCount]->
update( hits, fcalFaceZ_TargetIsZeq0 );
185 for (
unsigned int c = 0;
c < clusterCount;
c++ ) {
186 int nh_clust = clusterList[
c]->
getHits();
192 if (energy > totalAllowed) {
193 if ( clusterList[
c]->getHits() == 0 ) {
210 for (
int ih = 0; ih < hits->
nhits; ih++ ) {
211 if ( hitUsed[ih] < 0)
213 double totalExpected = 0;
217 for (
unsigned int c = 0;
c < clusterCount;
c++ ) {
218 if (clusterList[
c]->getHits() > 0) {
223 for (
unsigned int c = 0;
c < clusterCount;
c++ ) {
224 if (clusterList[
c]->getHits() > 0) {
228 && fabs(clusterList[
c]->getTimeMaxE()
229 -hits->
hit[ih].
t)<TIME_CUT ) {
230 clusterList[
c]->
addHit(ih,expected/totalExpected);
238 for (
unsigned int c = 0;
c < clusterCount;
c++) {
239 unsigned int blockCount = clusterList[
c]->
getHits();
241 if (blockCount < MIN_CLUSTER_BLOCK_COUNT) {
242 delete clusterList[
c];
250 const vector<DFCALCluster::DFCALClusterHit_t> &clusterHits = clusterList[
c]->
GetHits();
251 for(
size_t loc_i = 0; loc_i < clusterHits.size(); loc_i++) {
253 if( clusterHit != NULL )
254 clusterList[
c]->AddAssociatedObject( clusterHit );
257 _data.push_back( clusterList[
c] );
const vector< DFCALClusterHit_t > GetHits() const
#define FCAL_USER_HITS_MAX
jerror_t evnt(JEventLoop *eventLoop, uint64_t eventnumber)
bool GetFCALZ(double &z_fcal) const
z-location of front face of CCAL in cm
double getEallowed(const int ihit) const
jerror_t brun(JEventLoop *eventLoop, int32_t runnumber)
DGeometry * GetDGeometry(unsigned int run_number)
void saveHits(const userhits_t *const hit)
bool update(const userhits_t *const hitList, double fcalFaceZ)
int addHit(const int ihit, const double frac)
int channel(int row, int column) const
bool FCALHitsSort_C(const DFCALHit *const &thit1, const DFCALHit *const &thit2)
const DFCALHit * GetDFCALHitFromClusterHit(const DFCALCluster::DFCALClusterHit_t &theClusterHit, const vector< const DFCALHit * > &fcalhits)
bool GetTargetZ(double &z_target) const
z-location of center of target
double getEexpected(const int ihit) const