00001 #include "emcOFClusterContainer.h"
00002 #include "dEmcClusterLocalExtWrapper.h"
00003 #include "PHTypedNodeIterator.h"
00004 #include "PHIODataNode.h"
00005 #include "emcClusterContainerv1.h"
00006 #include <cassert>
00007 #include <cmath>
00008 #include "EmcIndexer.h"
00009
00010 namespace
00011 {
00012 template<class T>
00013 T*
00014 objectHandle(PHCompositeNode* node, const char* name)
00015 {
00016 PHTypedNodeIterator<T> iter(node);
00017 PHIODataNode<T>* objectNode = iter.find(name);
00018 if (!objectNode)
00019 {
00020 return 0;
00021 }
00022 else
00023 {
00024 T* rv = objectNode->getData();
00025 return rv;
00026 }
00027 }
00028
00029 emcOFClusterContainer gemcOFClusterContainer;
00030 }
00031
00032 using namespace std;
00033
00034
00035 emcOFClusterContainer::emcOFClusterContainer() : emcObjectFiller()
00036 {
00037 }
00038
00039
00040 emcOFClusterContainer::~emcOFClusterContainer()
00041 {
00042 }
00043
00044
00045 bool
00046 emcOFClusterContainer::canFill(PHObject& destination, int verbose) const
00047 {
00048 emcClusterContainerv1* tc =
00049 dynamic_cast<emcClusterContainerv1*>(&destination);
00050 if ( tc )
00051 {
00052 return true;
00053 }
00054 else
00055 {
00056 if ( verbose )
00057 {
00058 std::cerr << "emcOFClusterContainer::canFill : destination "
00059 << "is not an emcClusterContainerv1" << std::endl;
00060 }
00061 return false;
00062 }
00063 }
00064
00065
00066 bool
00067 emcOFClusterContainer::canFill(PHCompositeNode* topNode,
00068 PHObject& destination,
00069 int verbose) const
00070 {
00071 bool rv = canFill(destination);
00072 if ( rv )
00073 {
00074 dEmcClusterLocalExtWrapper* ct = objectHandle<dEmcClusterLocalExtWrapper>
00075 (topNode,"dEmcClusterLocalExt");
00076 if ( ct )
00077 {
00078 rv = true;
00079 }
00080 else
00081 {
00082 rv = false;
00083 }
00084 }
00085 return rv;
00086 }
00087
00088
00089 bool
00090 emcOFClusterContainer::fill(PHCompositeNode* topNode,
00091 PHObject& destination,
00092 int verbose)
00093 {
00094 assert(canFill(topNode,destination,false)==true);
00095 dEmcClusterLocalExtWrapper* cc = objectHandle<dEmcClusterLocalExtWrapper>
00096 (topNode,"dEmcClusterLocalExt");
00097 emcClusterContainerv1& clus =
00098 static_cast<emcClusterContainerv1&>(destination);
00099
00100 size_t nclusters = cc->RowCount();
00101
00102 clus.Reset();
00103
00104 for ( size_t i = 0; i < nclusters; ++i )
00105 {
00106 emcClusterContent* c = clus.addCluster(i);
00107 c->set_arm(cc->get_arm(i));
00108 c->set_chi2(cc->get_chi2(i));
00109 c->set_disp(cc->get_disp(1,i),cc->get_disp(0,i));
00110 c->set_e(cc->get_e(i));
00111 int is = EmcIndexer::
00112 sectorOfflineToOnline(cc->get_arm(i),cc->get_sector(i));
00113 c->set_ecore( (is<6) ? cc->get_ecore(i) : cc->get_ecorr(i) );
00114 c->set_ecent(cc->get_ecent(i));
00115 c->set_etofmin(cc->get_etofmin(i));
00116 c->set_etofmax(cc->get_etofmax(i));
00117 c->set_id(cc->get_id(i));
00118 c->set_ipos(cc->get_ind(1,i),cc->get_ind(0,i));
00119 c->set_quality(cc->get_qual(i));
00120 c->set_maps(cc->get_deadmap(i),cc->get_warnmap(i));
00121 c->set_multiplicity(cc->get_twrhit(i));
00122 c->set_padisp(cc->get_padisp(1,i),cc->get_padisp(0,i));
00123
00124 for ( int j = 0; j < cc->get_twrhit(i); ++j )
00125 {
00126 c->set_partesum(j,cc->get_partesum(j,i));
00127 c->set_towerid(j,cc->get_twrlist(j,i));
00128 }
00129
00130 c->set_prob_photon(cc->get_prob_photon(i));
00131 c->set_phi(cc->get_phi(i));
00132 c->set_pid(static_cast<int>(rint(cc->get_pid(i))));
00133 c->set_sector(cc->get_sector(i));
00134 c->set_tof(cc->get_tof(i));
00135 c->set_tofmin(cc->get_tofmin(i));
00136 c->set_tofmax(cc->get_tofmax(i));
00137 c->set_theta(cc->get_theta(i));
00138 c->set_type(cc->get_type(i));
00139 c->set_xyz(cc->get_xyz(0,i),cc->get_xyz(1,i),cc->get_xyz(2,i));
00140 }
00141 return true;
00142 }
00143
00144
00145 void
00146 emcOFClusterContainer::identify(std::ostream& os) const
00147 {
00148 os << "emcOFClusterContainer" << std::endl;
00149 }
00150
00151
00152 int
00153 emcOFClusterContainer::isValid() const
00154 {
00155 return 1;
00156 }
00157
00158
00159 void
00160 emcOFClusterContainer::Reset()
00161 {
00162 }