00001
00002
00003
00004
00005
00006
00007
00009
00010 #include "PhotonTransport/SimpleTransport.h"
00011 #include "PhotonTransport/PhotonSignal.h"
00012 #include "Simulation/FLSHitList.h"
00013 #include "Simulation/TruthFilter.h"
00014
00015 #include "JobControl/Exception.h"
00016 #include "Geometry/CellUniqueId.h"
00017 #include "Geometry/PlaneGeo.h"
00018 #include "Geometry/CellGeo.h"
00019 #include "RawData/RawDigit.h"
00020 #include "RawData/DAQHeader.h"
00021
00022
00023
00024 #include <cmath>
00025 #include <iostream>
00026
00027 using namespace photrans;
00028 using namespace std;
00029
00030 MODULE_DECL(SimpleTransport);
00031
00032 SimpleTransport::SimpleTransport(const char* version) :
00033 PhotonTransporter(),
00034 jobc::Module("SimpleTransport"),
00035 fMeVToNPhot(0),
00036 fCollectionEff(0),
00037 fAttenLength(0)
00038 {
00039 this->SetCfgVersion(version);
00040
00041 }
00042
00043
00044
00045 SimpleTransport::~SimpleTransport()
00046 {
00047 }
00048
00049
00050
00051 void SimpleTransport::Update(const cfg::Config& c)
00052 {
00053 c("MeVToNPhot"). Get(fMeVToNPhot);
00054 c("CollectionEff").Get(fCollectionEff);
00055 c("AttenLength"). Get(fAttenLength);
00056 c("MessageLevel"). Get(msglevel);
00057 }
00058
00059
00060
00061 jobc::Result SimpleTransport::Reco(edm::EventHandle& evt)
00062 {
00063
00064 std::vector<const rawdata::DAQHeader*> header;
00065 short int det = rawdata::kFar;
00066 try{ evt.DAQ().Get("./",header); }
00067 catch(edm::Exception e){
00068 std::cerr << "Error retrieving daq header, while looking "<<
00069 "in SimpleTransport::Reco(), using default fardet geometry" << std::endl;
00070 }
00071 if(header.size() > 0) det = header[0]->DetId();
00072 geo::Geometry& fGeo = geo::Geometry::Instance(evt.Header().Run(), det);
00073
00074 vector<const sim::FLSHitList*> hitlist(0);
00075 sim::TruthFilter::GetFilteredHits(evt,hitlist);
00076 vector<photrans::PhotonSignal> photlist(0);
00077
00078 int nhits = 0;
00079
00080 int planeId = -1;
00081 int cellId = -1;
00082
00083 float fGeVToMeV = 1000.;
00084
00085
00086
00087 for (unsigned int i=0; i<hitlist.size(); ++i) {
00088
00089
00090
00091 float edep = 0.;
00092 double time = 0.;
00093
00094 float dist=0.;
00095
00096 unsigned short trkid = 0;
00097
00098 for (unsigned int j=0; j< hitlist[i]->fHits.size(); ++j) {
00099 ++nhits;
00100
00101
00102
00103
00104 if(planeId!=hitlist[i]->fHits[j].fPlaneId || cellId!=hitlist[i]->fHits[j].fCellId)
00105 try{
00106
00107 planeId=hitlist[i]->fHits[j].fPlaneId;
00108 cellId=hitlist[i]->fHits[j].fCellId;
00109
00110
00111
00112
00113
00114
00115
00116
00117 }catch(...){printf("bad photon geometry\n");continue;}
00118
00119
00120 edep = hitlist[i]->fHits[j].fEdep;
00121 time = hitlist[i]->fHits[j].fT;
00122
00123
00124
00125
00126 dist = fGeo.
00127 Plane((unsigned int)planeId).
00128 Cell((unsigned int)cellId).
00129 DistToReadOut(0.5*(hitlist[i]->fHits[j].fEntryZ +
00130 hitlist[i]->fHits[j].fExitZ));
00131 trkid = hitlist[i]->fHits[j].fTrackId;
00132
00133 photrans::PhotonSignal
00134 photon(time,int(edep*fMeVToNPhot*fGeVToMeV*fCollectionEff*exp(-dist/fAttenLength)));
00135 photon.SetPlaneCell(planeId, cellId);
00136 photon.SetTrackId(trkid);
00137
00138 if(photon.NPhoton() > 0.) photlist.push_back(photon);
00139
00140 }
00141
00142 }
00143
00144 if(msglevel>=INFO)cout << "Read " << nhits << " FLS hits" << endl;
00145 if(msglevel>=INFO)cout << "Created " << photlist.size() << " photon signals" << endl;
00146
00147 for (unsigned int i=0; i<photlist.size(); ++i)
00148 evt.Raw().Put(photlist[i],"");
00149
00150 photlist.clear();
00151
00152 return jobc::kPassed;
00153
00154 }