7 #include <JANA/JApplication.h>
24 static pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
25 static set<int> runs_announced;
26 pthread_mutex_lock(&print_mutex);
27 bool print_messages =
false;
28 if(runs_announced.find(runnumber) == runs_announced.end()){
29 print_messages =
true;
30 runs_announced.insert(runnumber);
32 pthread_mutex_unlock(&print_mutex);
39 vector<const DBCALGeometry *> BCALGeomVec;
40 loop->Get(BCALGeomVec);
41 if(BCALGeomVec.size() == 0)
42 throw JException(
"Could not load DBCALGeometry object!");
43 m_BCALGeom = BCALGeomVec[0];
45 if(print_messages) jout <<
"in DBCALPoint_factory, loading constants ..." << endl;
48 attenuation_parameters.clear();
50 vector< vector<double> > attenuation_parameters_temp;
51 loop->GetCalib(
"/BCAL/attenuation_parameters", attenuation_parameters_temp);
54 for (
unsigned int i = 0; i < attenuation_parameters_temp.size(); i++){
55 attenuation_parameters.push_back(attenuation_parameters_temp.at(i));
58 if (PRINTCALIBRATION) {
60 for (
int module=1; module<=BCAL_NUM_MODULES; module++) {
62 for (
int sector=1; sector<=BCAL_NUM_SECTORS; sector++) {
63 printf(
"%2i %2i %2i %12.4f %12.4f %12.4f\n",
65 attenuation_parameters[channel][0],
66 attenuation_parameters[channel][1],
67 attenuation_parameters[channel][2]);
76 effective_velocities.clear();
79 vector <double> effective_velocities_temp;
80 loop->GetCalib(
"/BCAL/effective_velocities", effective_velocities_temp);
82 for (
unsigned int i = 0; i < effective_velocities_temp.size(); i++){
83 effective_velocities.push_back(effective_velocities_temp.at(i));
87 track_parameters.clear();
89 vector< vector<double> > track_parameters_temp;
90 loop->GetCalib(
"/BCAL/z_track_parms", track_parameters_temp);
93 for (
unsigned int i = 0; i < track_parameters_temp.size(); i++){
94 track_parameters.push_back(track_parameters_temp.at(i));
105 vector<const DBCALUnifiedHit*> hits;
107 if (hits.size() <= 0)
return NOERROR;
110 map< int, cellHits > cellHitMap;
111 for( vector< const DBCALUnifiedHit* >::const_iterator hitPtr = hits.begin();
112 hitPtr != hits.end();
120 if(hit.
end == m_BCALGeom->kUpstream){
121 cellHitMap[id].uphits.push_back( *hitPtr );
123 cellHitMap[id].dnhits.push_back( *hitPtr );
129 for( map< int, cellHits >::const_iterator mapItr = cellHitMap.begin();
130 mapItr != cellHitMap.end();
133 const vector<const DBCALUnifiedHit*> &uphits = mapItr->second.uphits;
134 const vector<const DBCALUnifiedHit*> &dnhits = mapItr->second.dnhits;
137 if(uphits.size()==0 || dnhits.size()==0)
continue;
148 for(
unsigned int i=1; i<uphits.size(); i++){
149 if(uphits[i]->E > uphit->
E) uphit = uphits[i];
152 for(
unsigned int i=1; i<dnhits.size(); i++){
153 if(dnhits[i]->E > dnhit->
E) dnhit = dnhits[i];
163 float cEff = GetEffectiveVelocity(table_id);
177 double attenuation_length = m_BCALGeom->GetBCAL_attenutation_length();
178 double attenuation_L1=-1., attenuation_L2=-1.;
179 GetAttenuationParameters(table_id, attenuation_length, attenuation_L1, attenuation_L2);
188 double track_p0 = -1.0;
189 double track_p1 = -1.0;
190 double track_p2 = -100.0;
191 GetTrackParameters(table_id, track_p0, track_p1, track_p2);
193 DBCALPoint *point =
new DBCALPoint(*uphit,*dnhit,m_z_target_center,attenuation_length,cEff,track_p0,track_p1,track_p2,m_BCALGeom);
195 point->AddAssociatedObject(uphit);
196 point->AddAssociatedObject(dnhit);
198 _data.push_back(point);
209 double &attenuation_L1,
double &attenuation_L2)
211 vector<double> &parms = attenuation_parameters.at(
id);
213 attenuation_length = parms[0];
214 attenuation_L1 = parms[1];
215 attenuation_L2 = parms[2];
222 return effective_velocities.at(
id);
226 double &track_p1,
double &track_p2)
228 vector<double> &z_parms = track_parameters.at(
id);
230 if(!z_parms.empty()){
231 track_p0 = z_parms[0];
232 track_p1 = z_parms[1];
233 track_p2 = z_parms[2];
237 jerr<<
"Failed to retrieve the z_track parameters from CCDB!!!" << endl;
bool GetAttenuationParameters(int id, double &attenuation_length, double &attenuation_L1, double &attenuation_L2)
DGeometry * GetDGeometry(unsigned int run_number)
double GetEffectiveVelocity(int id)
bool GetTrackParameters(int id, double &track_p0, double &track_p1, double &track_p2)
printf("string=%s", string)
jerror_t brun(JEventLoop *loop, int32_t runnumber)
bool GetTargetZ(double &z_target) const
z-location of center of target
jerror_t evnt(JEventLoop *loop, uint64_t eventnumber)