#include <ToyMCModule.h>
Inheritance diagram for ToyMCModule:

Public Member Functions | |
| ToyMCModule () | |
| ~ToyMCModule () | |
| void | BeginJob () |
| const Registry & | DefaultConfig () const |
| void | Config (const Registry &r) |
| JobCResult | Get () |
| JobCResult | Next (int n=1) |
| JobCResult | Prev (int n=1) |
| JobCResult | GoTo (int run, int snarl, int searchDir=0) |
| JobCResult | Ana (const MomNavigator *mom) |
| JobCResult | GoTo (const VldContext &) |
| virtual JobCResult | Get (MomNavigator *mom) |
Private Attributes | |
| Int_t | fDetector |
| Double_t | fRate |
| Int_t | fDate |
| Int_t | fTime |
| Int_t | fStartPlane |
| Int_t | fStopPlane |
| Double_t | fStartX |
| Double_t | fStartY |
| Double_t | fDX |
| Double_t | fDY |
| Double_t | fEnergyPerPlane |
| VldContext | fContext |
| int | fCurrentSnarl |
|
|
Definition at line 49 of file ToyMCModule.cxx. References LoadMinosPDG(). 00049 : 00050 fCurrentSnarl(0) 00051 { 00052 LoadMinosPDG(); 00053 }
|
|
|
Definition at line 57 of file ToyMCModule.cxx. 00058 {
00059 }
|
|
|
Implement this for read only access to the MomNavigator Reimplemented from JobCModule. Definition at line 313 of file ToyMCModule.cxx. References CandRecord::FindCandHandle(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), MSG, JobCResult::SetFailed(), and JobCResult::SetWarning(). 00314 {
00315 //const Truthifier& truth = Truthifier::Instance(mom);
00316
00317 // Find PrimaryCandidateRecord fragment in MOM.
00318 CandRecord *candrec = dynamic_cast<CandRecord *>
00319 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00320 if (candrec == 0) {
00321 MSG("toymc", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00322 << endl;
00323 JobCResult result;
00324 result.SetWarning().SetFailed();
00325 return result;
00326 }
00327
00328 // Get CandDigits.
00329 CandDigitListHandle *cdlh_ptr = dynamic_cast<CandDigitListHandle *>
00330 (candrec->FindCandHandle("CandDigitListHandle", "canddigitlist"));
00331
00332 if(cdlh_ptr==0) return JobCResult::kError;
00333 CandDigitListHandle cdlh = *cdlh_ptr;
00334
00335 CandDigitHandleItr cdhItr(cdlh.GetDaughterIterator());
00336 //while(CandDigitHandle *cdh = cdhItr()) {
00337 //cout << truth.BestSEIdOfDigit(*cdh).AsString() << endl;
00338 //}
00339
00340
00341 return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00342 }
|
|
|
Implement for notification of begin of job Reimplemented from JobCModule. Definition at line 63 of file ToyMCModule.cxx. 00064 {
00065 }
|
|
|
Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables. Reimplemented from JobCModule. Definition at line 103 of file ToyMCModule.cxx. References fDate, fDetector, fDX, fDY, fEnergyPerPlane, fRate, fStartPlane, fStartX, fStartY, fStopPlane, fTime, and Registry::Get(). 00104 {
00105 //======================================================================
00106 // Configure the module given the Registry r
00107 //======================================================================
00108 int tmpi;
00109 double tmpd;
00110
00111 if (r.Get("DetectorType",tmpi)) { fDetector = tmpi; }
00112 if (r.Get("Rate",tmpd)) { fRate = tmpd; }
00113 if (r.Get("Date",tmpi)) { fDate = tmpi; }
00114 if (r.Get("Time",tmpi)) { fTime = tmpi; }
00115
00116 r.Get("StartPlane",fStartPlane);
00117 r.Get("StopPlane",fStopPlane);
00118 r.Get("StartX",fStartX);
00119 r.Get("StartY",fStartY);
00120 r.Get("DX",fDX);
00121 r.Get("DY",fDY);
00122 r.Get("EnergyPerPlane",fEnergyPerPlane);
00123 }
|
|
|
Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like: const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; } Reimplemented from JobCModule. Definition at line 70 of file ToyMCModule.cxx. References JobCModule::GetName(), Registry::LockValues(), Registry::Set(), and Registry::UnLockValues(). 00071 {
00072 //======================================================================
00073 // Get the default configuration for this module
00074 //======================================================================
00075 static Registry r; // Default configuration for module
00076
00077 // Set name of config
00078 std::string name = this->GetName();
00079 name += ".config.default";
00080 r.SetName(name.c_str());
00081
00082 // Set values in configuration
00083 r.UnLockValues();
00084 r.Set("DetectorType", 2);
00085 r.Set("Rate", 1.0);
00086 r.Set("Date", 20030101);
00087 r.Set("Time", 000000);
00088 r.Set("StartPlane", 1);
00089 r.Set("StopPlane", 50);
00090 r.Set("StartX", 0.30*Munits::m);
00091 r.Set("StartY", 0.30*Munits::m);
00092 r.Set("DX", 0.*Munits::m);
00093 r.Set("DY", 0.*Munits::m);
00094
00095 r.Set("EnergyPerPlane",2.0*Munits::MeV);
00096 r.LockValues();
00097
00098 return r;
00099 }
|
|
|
Implement if your module needs to read data from some external source and fill mom |
|
|
Reimplemented from JobCInputModule. Definition at line 127 of file ToyMCModule.cxx. References VldTimeStamp::Add(), RecDataRecord< T >::AdoptComponent(), fContext, fCurrentSnarl, fDate, fDetector, fDX, fDY, fRate, fStartX, fStartY, fTime, UgliPlnHandle::GetCenter(), UgliStripHandle::GetHalfLength(), UgliStripHandle::GetHalfThickness(), UgliStripHandle::GetHalfWidth(), JobCInputModule::GetMom(), UgliGeomHandle::GetScintPlnHandle(), UgliStripHandle::GetSEId(), UgliScintPlnHandle::GetStripHandleVector(), RecRecordImp< T >::GetTempTags(), UgliStripHandle::GlobalToLocal(), gSystem(), hostname, UgliStripHandle::IsValid(), UgliScintPlnHandle::IsValid(), PlexPlaneId::IsValid(), min, MSG, run(), Registry::Set(), and SimSnarlHeader::TrimCodename(). Referenced by GoTo(), Next(), and Prev(). 00128 {
00129 MomNavigator* mom = this->GetMom();
00130 assert(mom);
00131 mom -> Clear(); // Moving on so clear contents of Mom
00132
00133 MSG("ToyMC",Msg::kInfo) << "Toy MC running." << endl;
00134
00135 // Make a SimSnarl.
00136 Int_t run = 1000;
00137 Int_t trigbits = 0;
00138 Short_t subrun = 0;
00139 Short_t runtype = 0;
00140 Int_t errcode = 0;
00141 Int_t timeframe = -1;
00142 Int_t spilltype = -1;
00143
00144 // Increment the time by the pulse rate.
00145 int secs;
00146 double frac = frexp(fRate*fCurrentSnarl,&secs);
00147 int nsecs = int(frac*1e9);
00148 VldTimeStamp offset(secs,nsecs);
00149 VldTimeStamp fPulseTime = VldTimeStamp(fDate,fTime,0);
00150 fPulseTime.Add(offset);
00151
00152 // Reset the context.
00153 fContext = VldContext(Detector::CharToEnum((char)fDetector),
00154 SimFlag::kMC,
00155 fPulseTime);
00156
00157 VldTimeStamp now;
00158 std::string codename = SimSnarlHeader::TrimCodename("$Name: $");
00159 std::string hostname(gSystem->HostName());
00160
00161 SimSnarlHeader simheader(fContext,run,subrun,runtype,
00162 errcode,fCurrentSnarl,trigbits,timeframe,spilltype,
00163 now,codename,hostname);
00164
00165 SimSnarlRecord* simsnarl = new SimSnarlRecord(simheader);
00166
00167 simsnarl->GetTempTags().Set("stream","SimSnarl"); // no idea....
00168
00169 // Give it to mom.
00170 mom -> AdoptFragment(simsnarl);
00171
00172 // Generate the event:
00173 gRandom->SetSeed(fCurrentSnarl);
00174
00175
00176 UgliGeomHandle ugli(fContext);
00177
00178 std::vector<DigiScintHit> hits;
00179
00180 for(int plane=fStartPlane;plane<=fStopPlane;plane++) {
00181 PlexPlaneId planeId(Detector::CharToEnum((char)fDetector),plane);
00182 if(!(planeId.IsValid())) break;
00183
00184 UgliScintPlnHandle uplane = ugli.GetScintPlnHandle(planeId);
00185 if(!(uplane.IsValid())) break;
00186 std::vector<UgliStripHandle> strips = uplane.GetStripHandleVector();
00187
00188
00189 // Find the strip that best matches our coordinates.
00190 double min = 1e19;
00191 UgliStripHandle ustrip;
00192
00193 TVector3 x(fStartX + (double)(fCurrentSnarl)*fDX,
00194 fStartY + (double)(fCurrentSnarl)*fDY,
00195 uplane.GetCenter().z());
00196
00197
00198 for(UInt_t istrip = 0;istrip<strips.size(); istrip++) {
00199 if(strips[istrip].IsValid()) {
00200 double dist = fabs(strips[istrip].GlobalToLocal(x).y());
00201 if(dist<min) {
00202 min = dist;
00203 ustrip = strips[istrip];
00204 }
00205 }
00206 }
00207 if(!ustrip.IsValid()) break;
00208
00209 // Find the coords on the strip.
00210 TVector3 x0 = ustrip.GlobalToLocal(x);
00211
00212 MSG("ToyMC",Msg::kInfo) << "Plane " << plane
00213 << " x: (" << x.x() <<","<< x.y() <<","<< x.z() << ")\t"
00214 << "x0: (" << x0.x() <<","<< x0.y() <<","<< x0.z() << ")\t"
00215 //<< "x1: (" << x1.x() <<","<< x1.y() <<","<< x1.z() << ")\t"
00216 //<< "x2: (" << x2.x() <<","<< x2.y() <<","<< x2.z() << ")"
00217 << endl;
00218
00219 // Ensure we're in the scintillator.
00220 if( x0.y() > ustrip.GetHalfWidth()) {
00221 x0.SetY(ustrip.GetHalfWidth()-1.0*Munits::mm);
00222 }
00223
00224 if( x0.y() < -ustrip.GetHalfWidth()) {
00225 x0.SetY(-ustrip.GetHalfWidth()+1.0*Munits::mm);
00226 }
00227
00228
00229 if( fabs(x0.x()) > ustrip.GetHalfLength() ) {
00230 MSG("ToyMC",Msg::kWarning) << "Outside strip length!" << endl;
00231 break;
00232 }
00233 TVector3 x1 = x0;
00234 x1.SetZ(-(ustrip.GetHalfThickness()));
00235 TVector3 x2 = x0;
00236 x2.SetZ( (ustrip.GetHalfThickness()));
00237
00238 double t1 = (x.z() - (ustrip.GetHalfThickness()))/Munits::c_light;
00239 double t2 = (x.z() + (ustrip.GetHalfThickness()))/Munits::c_light;
00240
00241 DigiScintHit hit(1, // track ID <<","<<
00242 13, // muon,
00243 1e9,
00244 ustrip.GetSEId(),
00245 t1,
00246 x1.x(), x1.y(), x1.z(),
00247 t2,
00248 x2.x(), x2.y(), x2.z(),
00249 (ustrip.GetHalfThickness())*2,
00250 fEnergyPerPlane);
00251 MSG("ToyMC",Msg::kVerbose) << hit;
00252 hits.push_back(hit);
00253
00254 }
00255
00256 TClonesArray *hitlist = new TClonesArray("DigiScintHit",hits.size());
00257 hitlist->SetName("DigiScintHits");
00258 for(unsigned int i=0;i<hits.size();i++) {
00259 new ((*hitlist)[i]) DigiScintHit( hits[i] );
00260 }
00261 simsnarl->AdoptComponent(hitlist);
00262
00263 // Add truth.
00264 // New TClonesArray of the right size
00265 TClonesArray* newstdhep = new TClonesArray("TParticle",2);
00266 newstdhep->SetName("StdHep");
00267 new((*newstdhep)[0])
00268 TParticle(13, // muon
00269 0, 0, 0, 0, 0,
00270 0.,0.,10000.,10000.,
00271 0.,0.,1.0,0);
00272 new((*newstdhep)[1])
00273 TParticle(13, // muon
00274 0, 0, 0, 0, 0,
00275 0.,0.,10000.,10000.,
00276 0.,0.,1.0,0);
00277
00278 simsnarl->AdoptComponent(newstdhep);
00279
00280 return JobCResult::kAOK;
00281 }
|
|
|
Reimplemented from JobCInputModule. Definition at line 39 of file ToyMCModule.h. References Get(). 00039 { return this->Get();};
|
|
||||||||||||||||
|
Reimplemented from JobCInputModule. Definition at line 305 of file ToyMCModule.cxx. References fCurrentSnarl, and Get(). 00306 {
00307 fCurrentSnarl = snarl;
00308 return this->Get();
00309 }
|
|
|
Reimplemented from JobCInputModule. Definition at line 285 of file ToyMCModule.cxx. References fCurrentSnarl, and Get(). 00286 {
00287 //======================================================================
00288 // Advance the position in the stream n record sets. Load the records
00289 // at the last position
00290 //======================================================================
00291 fCurrentSnarl+=n;
00292 return this->Get();
00293 }
|
|
|
Reimplemented from JobCInputModule. Definition at line 297 of file ToyMCModule.cxx. References fCurrentSnarl, and Get(). 00298 {
00299 if(fCurrentSnarl>0) fCurrentSnarl-=n;
00300 return this->Get();
00301 }
|
|
|
Definition at line 56 of file ToyMCModule.h. Referenced by Get(). |
|
|
Definition at line 57 of file ToyMCModule.h. |
|
|
Definition at line 45 of file ToyMCModule.h. |
|
|
Definition at line 43 of file ToyMCModule.h. |
|
|
Definition at line 51 of file ToyMCModule.h. |
|
|
Definition at line 52 of file ToyMCModule.h. |
|
|
Definition at line 53 of file ToyMCModule.h. Referenced by Config(). |
|
|
Definition at line 44 of file ToyMCModule.h. |
|
|
Definition at line 47 of file ToyMCModule.h. Referenced by Config(). |
|
|
Definition at line 49 of file ToyMCModule.h. |
|
|
Definition at line 50 of file ToyMCModule.h. |
|
|
Definition at line 48 of file ToyMCModule.h. Referenced by Config(). |
|
|
Definition at line 46 of file ToyMCModule.h. |
1.3.9.1