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

Public Member Functions | |
| CustomLightInjector () | |
| ~CustomLightInjector () | |
| 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 |
| Double_t | fPhotonRate |
| VldTimeStamp | fPulseTime |
| VldContext | fContext |
| int | fCurrentSnarl |
Static Private Attributes | |
| RawChannelId | fRcid1 |
| RawChannelId | fRcid2 |
A playground class for doing a wierd light injections to test DetSim.
Definition at line 20 of file CustomLightInjector.h.
|
|
Definition at line 51 of file CustomLightInjector.cxx. 00051 : 00052 fCurrentSnarl(0) 00053 { }
|
|
|
Definition at line 57 of file CustomLightInjector.cxx. 00058 {
00059 }
|
|
|
Implement this for read only access to the MomNavigator Reimplemented from JobCModule. Definition at line 250 of file CustomLightInjector.cxx. References MomNavigator::FragmentIter(), fRcid1, fRcid2, RawDigit::GetADC(), RawDigit::GetChannel(), DigiSignal::GetCharge(), RawDigitDataBlock::GetDatumIter(), RawRecord::GetRawBlockIter(), Truthifier::GetSignal(), Truthifier::Instance(), and RawChannelId::IsSameChannel(). 00251 {
00252 const Truthifier& truth = Truthifier::Instance(mom);
00253
00254 std::vector<int> adcs1(0);
00255 std::vector<int> adcs2(0);
00256 std::vector<float> q1(0);
00257 std::vector<float> q2(0);
00258
00259
00260 // Get the RawDigitDataBlock.
00261 TObject* tobj;
00262 TIter fragiter = mom->FragmentIter();
00263 while( ( tobj = fragiter.Next() ) ) {
00264 RawRecord* rawRec = dynamic_cast<RawRecord*>(tobj);
00265 if(rawRec) {
00266 TIter itr = rawRec->GetRawBlockIter();
00267 RawDataBlock* rawBlk;
00268 while ( ( rawBlk = dynamic_cast<RawDataBlock*>(itr.Next()) ) ) {
00269 RawDigitDataBlock* rddb = dynamic_cast<RawDigitDataBlock*>(rawBlk);
00270 if(rddb) {
00271 //cout << "Ana context: " << rawRec->GetRawHeader()->GetVldContext().AsString() << endl;
00272 //PlexHandle plex(rawRec->GetRawHeader()->GetVldContext());
00273
00274 TIter iter = rddb->GetDatumIter();
00275 while( (tobj=iter.Next() ) ) {
00276
00277 // Process a digit.
00278
00279 RawDigit* rawDigit = dynamic_cast<RawDigit *>(tobj);
00280 //cout << *rawDigit << endl;
00281
00282 if(rawDigit) {
00283 if(rawDigit->GetChannel().IsSameChannel(fRcid1)) {
00284 q1.push_back(truth.GetSignal(rawDigit)->GetCharge()/Munits::fC);
00285 adcs1.push_back(rawDigit->GetADC());
00286 }
00287 else if(rawDigit->GetChannel().IsSameChannel(fRcid2))
00288 adcs2.push_back(rawDigit->GetADC());
00289 else {
00290 //cout << "Xtalk chan? " << *rawDigit << endl;
00291 }
00292
00293 }
00294
00295 }
00296
00297 }
00298 }
00299 }
00300 } // It's so ugly!
00301
00302 for(UInt_t i=0;i<5;i++) {
00303 if(adcs1.size()>i) cout << "\t" << adcs1[i];
00304 else cout << "\t" << 0;
00305 }
00306 for(UInt_t i=0;i<5;i++) {
00307 if(q1.size()>i) cout << "\t" << q1[i];
00308 else cout << "\t" << 0;
00309 }
00310
00311 cout << endl;
00312
00313
00314 return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00315 }
|
|
|
Implement for notification of begin of job Reimplemented from JobCModule. Definition at line 63 of file CustomLightInjector.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 97 of file CustomLightInjector.cxx. References fContext, fDate, fDetector, fPhotonRate, fPulseTime, fRate, fTime, and Registry::Get(). 00098 {
00099 //======================================================================
00100 // Configure the module given the Registry r
00101 //======================================================================
00102 int tmpi;
00103 double tmpd;
00104
00105 if (r.Get("detectorType",tmpi)) { fDetector = tmpi; }
00106 if (r.Get("rate",tmpd)) { fRate = tmpd; }
00107 if (r.Get("date",tmpi)) { fDate = tmpi; }
00108 if (r.Get("time",tmpi)) { fTime = tmpi; }
00109 r.Get("photonRate",fPhotonRate);
00110
00111 fPulseTime = VldTimeStamp(fDate,fTime,0);
00112 fContext = VldContext(Detector::CharToEnum((char)fDetector),
00113 SimFlag::kReroot,
00114 fPulseTime);
00115 }
|
|
|
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 CustomLightInjector.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("photonRate", 0.0);
00089
00090 r.LockValues();
00091
00092 return r;
00093 }
|
|
|
Implement if your module needs to read data from some external source and fill mom |
|
|
Reimplemented from JobCInputModule. Definition at line 119 of file CustomLightInjector.cxx. References VldTimeStamp::Add(), RecDataRecord< T >::AdoptComponent(), RecDataRecord< T >::AdoptTemporary(), fContext, fCurrentSnarl, fDate, fDetector, fPhotonRate, fPulseTime, fRate, fRcid1, fRcid2, fTime, VldContext::GetDetector(), JobCInputModule::GetMom(), PlexHandle::GetPixelSpotId(), PlexHandle::GetRawChannelId(), RecRecordImp< T >::GetTempTags(), gSystem(), hostname, run(), Registry::Set(), and SimSnarlHeader::TrimCodename(). Referenced by GoTo(), Next(), and Prev(). 00120 {
00121 MomNavigator* mom = this->GetMom();
00122 assert(mom);
00123 mom -> Clear(); // Moving on so clear contents of Mom
00124
00125
00126 // Make a SimSnarl.
00127 Int_t run = 1000;
00128 Int_t trigbits = 0;
00129 Short_t subrun = 0;
00130 Short_t runtype = 0;
00131 Int_t errcode = 0;
00132 Int_t timeframe = -1;
00133
00134 // Increment the time by the pulse rate.
00135 int secs;
00136 double frac = frexp(fRate*fCurrentSnarl,&secs);
00137 int nsecs = int(frac*1e9);
00138 VldTimeStamp offset(secs,nsecs);
00139 fPulseTime = VldTimeStamp(fDate,fTime,0);
00140 fPulseTime.Add(offset);
00141
00142 // Reset the context.
00143 fContext = VldContext(Detector::CharToEnum((char)fDetector),
00144 SimFlag::kMC,
00145 fPulseTime);
00146
00147 VldTimeStamp now;
00148 std::string codename = SimSnarlHeader::TrimCodename("$Name: $");
00149 std::string hostname(gSystem->HostName());
00150
00151 SimSnarlHeader simheader(fContext,run,subrun,runtype,
00152 errcode,fCurrentSnarl,trigbits,timeframe,-1,
00153 now,codename,hostname);
00154
00155 SimSnarlRecord* simsnarl = new SimSnarlRecord(simheader);
00156
00157 simsnarl->GetTempTags().Set("stream","SimSnarl"); // no idea....
00158
00159 // Give it to mom.
00160 mom -> AdoptFragment(simsnarl);
00161
00162 // Add the DigiPE list to the simsnarl.
00163 TObjArray* PeList = new TObjArray(0);
00164 PeList->SetName("DigiListPe");
00165 PeList->SetOwner(true);
00166
00167 // Find out how many of them to make.
00168 gRandom->SetSeed(fCurrentSnarl);
00169
00170 // Make the photoelectron objects.
00171 // i.e:
00172 // DigiPE* pe = new DigiPE(time, fPsid, NULL);
00173 // PeList->Add(pe);
00174
00176
00177 PlexHandle plex(fContext);
00178 PlexStripEndId seid1(fContext.GetDetector(),
00179 1, 10, StripEnd::kWest);
00180
00181 PlexStripEndId seid2(fContext.GetDetector(),
00182 5, 15, StripEnd::kWest);
00183
00184 PlexPixelSpotId psid1 = plex.GetPixelSpotId(seid1);
00185 PlexPixelSpotId psid2 = plex.GetPixelSpotId(seid2);
00186
00187 fRcid1 = plex.GetRawChannelId(psid1);
00188 fRcid2 = plex.GetRawChannelId(psid2);
00189
00190 //cout << "Injecting on " << psid1.AsString() << "->" << fRcid1.AsString() << endl;
00191 //cout << " and " << psid2.AsString() << "->" << fRcid2.AsString() << endl;
00192
00193
00194 float npe = 0;
00195 for(int i=0;i<1*fCurrentSnarl;i++) {
00196 npe++;
00197 double time = double(i) * fPhotonRate*Munits::ns;
00198 DigiPE* pe;
00199 pe = new DigiPE(time, psid1, DigiSignal::kGenuine);
00200 PeList->Add(pe);
00201 pe = new DigiPE(time, psid2, DigiSignal::kGenuine);
00202 PeList->Add(pe);
00203 }
00204
00205 cout << npe;
00206
00208
00209
00210 simsnarl->AdoptTemporary(PeList);
00211
00212 TClonesArray *new_arr = new TClonesArray("DigiScintHit",0);
00213 new_arr->SetName("DigiScintHits");
00214 simsnarl->AdoptComponent(new_arr);
00215
00216
00217 return JobCResult::kAOK;
00218 }
|
|
|
Reimplemented from JobCInputModule. Definition at line 42 of file CustomLightInjector.h. References Get(). 00042 { return this->Get();};
|
|
||||||||||||||||
|
Reimplemented from JobCInputModule. Definition at line 242 of file CustomLightInjector.cxx. References fCurrentSnarl, and Get(). 00243 {
00244 fCurrentSnarl = snarl;
00245 return this->Get();
00246 }
|
|
|
Reimplemented from JobCInputModule. Definition at line 222 of file CustomLightInjector.cxx. References fCurrentSnarl, and Get(). 00223 {
00224 //======================================================================
00225 // Advance the position in the stream n record sets. Load the records
00226 // at the last position
00227 //======================================================================
00228 fCurrentSnarl+=n;
00229 return this->Get();
00230 }
|
|
|
Reimplemented from JobCInputModule. Definition at line 234 of file CustomLightInjector.cxx. References fCurrentSnarl, and Get(). 00235 {
00236 if(fCurrentSnarl>0) fCurrentSnarl-=n;
00237 return this->Get();
00238 }
|
|
|
Definition at line 66 of file CustomLightInjector.h. |
|
|
Definition at line 71 of file CustomLightInjector.h. |
|
|
Definition at line 60 of file CustomLightInjector.h. |
|
|
Definition at line 58 of file CustomLightInjector.h. |
|
|
Definition at line 62 of file CustomLightInjector.h. |
|
|
Definition at line 65 of file CustomLightInjector.h. |
|
|
Definition at line 59 of file CustomLightInjector.h. |
|
|
Definition at line 45 of file CustomLightInjector.cxx. |
|
|
Definition at line 46 of file CustomLightInjector.cxx. |
|
|
Definition at line 61 of file CustomLightInjector.h. |
1.3.9.1