CDTrackerModule Class Reference

#include <CDTrackerModule.h>

Inheritance diagram for CDTrackerModule:

JobCModule List of all members.

Public Member Functions

 CDTrackerModule ()
JobCResult Ana (const MomNavigator *mom)
void HandleCommand (JobCommand *cmd)
void EndJob ()

Private Member Functions

void CleanDataMembers ()
void FillPID (CandCalDetSIHandle *CDSI)
void FillPID (const CandCalDetPIDHandle *cdpid)
void InitialiseTree ()
TFile * OpenFile (Int_t runNumber, Int_t runNumberSub)

Private Attributes

bool ffirstrecord
Float_t fBeamMomentum
Int_t fNumDeadChips
Float_t fTemperature
SimFlag::SimFlag_t fSimFlag
Int_t frun
Int_t fsubrun
Int_t fsnarl
Int_t fSec
Int_t fStartSnarl
Int_t fEndSnarl
Int_t fStartTime
Int_t fEndTime
Char_t ftag [256]
TFile * fsavefile
CDTrackerOptionsfTrkOpt
TTree * ftree
CDTrackInfofTrkInfo
TClonesArray * fTrkHits
TClonesArray * fStTrkHits
TClonesArray * fCCHits
TClonesArray * fXTalkHits
TClonesArray * fUnTrkHits
TClonesArray * fTruthHits
CDPIDInfofPID
Int_t fJustWriteTracks
Int_t fOverwriteFile
Int_t fWritePID
Int_t fWriteTruth

Detailed Description

Definition at line 30 of file CDTrackerModule.h.


Constructor & Destructor Documentation

CDTrackerModule::CDTrackerModule (  ) 

Definition at line 68 of file CDTrackerModule.cxx.

References fBeamMomentum, fCCHits, fEndSnarl, fEndTime, ffirstrecord, fJustWriteTracks, fNumDeadChips, fOverwriteFile, fPID, frun, fsavefile, fSec, fSimFlag, fsnarl, fStartSnarl, fStartTime, fStTrkHits, fsubrun, ftag, fTemperature, ftree, fTrkHits, fTrkInfo, fTrkOpt, fTruthHits, fUnTrkHits, fWritePID, fWriteTruth, fXTalkHits, and SimFlag::kUnknown.

00069 {
00070   ffirstrecord=true;
00071 
00072   fBeamMomentum=0;
00073   fNumDeadChips=-1;
00074   fTemperature=-1;
00075   fSimFlag=SimFlag::kUnknown;
00076   frun=0;
00077   fsubrun=0;
00078   fsnarl=0;
00079   fSec=-1;
00080   fStartSnarl=0;
00081   fEndSnarl=0;
00082   fStartTime=0;
00083   fEndTime=0;
00084   fsavefile=0;
00085   fJustWriteTracks=0;
00086   fOverwriteFile=0;
00087   fWritePID=0;
00088   sprintf(ftag,"SetFileIDToMakeThisShorter");
00089   fWriteTruth=0;
00090 
00091   //initialise pointers
00092   fTrkInfo=0;
00093   ftree=0;
00094   fPID=0;
00095 
00096   //"beam" tracked hits
00097   fTrkHits=new TClonesArray("CDTrackedHitInfo",1000);
00098   //cosmic counter hits
00099   fCCHits=new TClonesArray("CDTrackedHitInfo",1000); 
00100   //"cosmic" tracked hits
00101   fStTrkHits=new TClonesArray("CDTrackedHitInfo",1000);
00102   //xtalk hits 
00103   fXTalkHits=new TClonesArray("CDXTalkHitInfo",1000);
00104   //unidentified hits
00105   fUnTrkHits=new TClonesArray("CDTrackedHitInfo",1000);
00106   //the truth of the hits
00107   fTruthHits=new TClonesArray("CDTruthHitInfo",1000);
00108 
00109   //tracker options
00110   fTrkOpt=new CDTrackerOptions();
00111 }


Member Function Documentation

JobCResult CDTrackerModule::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 115 of file CDTrackerModule.cxx.

References SimFlag::AsString(), CleanDataMembers(), CDTrackerOptions::Cosmic(), count, fBeamMomentum, fCCHits, fEndSnarl, fEndTime, ffirstrecord, FillPID(), CandRecord::FindCandHandle(), RawRecord::FindRawBlock(), fJustWriteTracks, fNumDeadChips, fPID, frun, fsavefile, fSec, fSimFlag, fsnarl, fStartSnarl, fStartTime, fStTrkHits, fsubrun, fTemperature, ftree, fTrkHits, fTrkInfo, fTrkOpt, fTruthHits, fUnTrkHits, fWritePID, fWriteTruth, fXTalkHits, CandDigitListHandle::GetAbsTime(), CDTrackInfo::GetAngle(), CDTracker::GetCCStripMap(), RawDigitDataBlock::GetDatumIter(), MomNavigator::GetFragment(), RawDeadChipBlock::GetNumberOfEntries(), CandCalDetPIDHandle::GetOLChi2(), CandCalDetPIDHandle::GetPIDType(), RawRecord::GetRawHeader(), CDTrackInfo::GetResult(), RawDaqHeader::GetRun(), VldTimeStamp::GetSec(), VldContext::GetSimFlag(), RawDaqSnarlHeader::GetSnarl(), CDMapMaker::GetStripMap(), RawDaqHeader::GetSubRun(), Calibrator::GetTemperature(), VldContext::GetTimeStamp(), CDTracker::GetTrackedStripMap(), CDTracker::GetTrackInfo(), CDPIDInfo::GetTrueParticleMomentum(), CDTruthifier::GetTruthHitInfo(), RecMinosHdr::GetVldContext(), CandCalDetPIDHandle::InCERTime(), InitialiseTree(), Calibrator::Instance(), RawChannelId::IsSameChannel(), Detector::kCalDet, SimFlag::kData, Msg::kDebug, Dbi::kDefaultTask, Dbi::kDisabled, Msg::kError, Msg::kFatal, Msg::kInfo, JobCResult::kPassed, ElecType::kVA, Msg::kVerbose, Msg::kWarning, PlaneView::kX, PlaneView::kY, MAXMSG, MSG, CandCalDetPIDHandle::NoOverlap(), OpenFile(), CDTruthifier::ParticleMomentum(), CDTruthifier::RecoStdHep(), CalScheme::Reset(), CDTrackInfo::SetAbsTime(), JobCResult::SetFailed(), CDTrackInfo::SetRange(), and CDTrackInfo::SetTriggerTime().

00116 {
00117   //set the default result to passed
00118   JobCResult result(JobCResult::kPassed);
00119 
00120   CandRecord* candrec=dynamic_cast<CandRecord*>
00121     (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00122   if (candrec==0) {
00123     MSG("CDTrackerModule",Msg::kWarning) 
00124       <<"No PrimaryCandidateRecord in MOM." << endl;
00125     result.SetFailed();
00126     return result;
00127   }
00128 
00129   RawRecord *rr=dynamic_cast<RawRecord *>
00130     (mom->GetFragment("RawRecord"));
00131   if (rr==0) {
00132     MSG("CDTrackerModule",Msg::kWarning) 
00133       <<"No RawRecord in MOM." << endl;
00134     result.SetFailed();
00135     return result;
00136   }
00137 
00138   const RawDeadChipBlock* dcb=dynamic_cast<const RawDeadChipBlock*>
00139     (rr->FindRawBlock("RawDeadChipBlock"));
00140   if(dcb) {
00141     fNumDeadChips=dcb->GetNumberOfEntries();
00142     if (fNumDeadChips>0) {
00143       MAXMSG("CDTrackerModule",Msg::kDebug,100)
00144         <<"Found dead chips="<<fNumDeadChips<<endl;
00145     }
00146   }
00147   else {
00148     MAXMSG("CDTrackerModule",Msg::kWarning,10)
00149       <<"No RawDeadChipBlock present"<<endl;
00150   }
00151 
00152   const RawDaqSnarlHeader* snarlHdr =
00153     dynamic_cast<const RawDaqSnarlHeader*>(rr->GetRawHeader());
00154   if(snarlHdr){
00155     fsnarl=snarlHdr->GetSnarl();
00156     fSec=snarlHdr->GetVldContext().GetTimeStamp().GetSec();
00157     fEndSnarl=fsnarl;
00158     fEndTime=fSec;
00159 
00160     if(ffirstrecord) {
00161       fSimFlag=snarlHdr->GetVldContext().GetSimFlag();
00162       fStartTime=snarlHdr->GetVldContext().GetTimeStamp().GetSec();
00163       fStartSnarl=snarlHdr->GetSnarl();
00164       frun=snarlHdr->GetRun();
00165       fsubrun=snarlHdr->GetSubRun();//this isn't always right!
00166 
00167       /*
00168       DbiResultPtr<DbuSubRunSummary> dsrs(snarlHdr->GetVldContext(),
00169                                           Dbi::kDefaultTask,
00170                                           Dbi::kDisabled);
00171       MSG("CDTrackerModule",Msg::kInfo)
00172         <<"Number of rows in DbuSubRunSummary="<<dsrs.GetNumRows()
00173         <<endl;
00174       
00175       //get the database row
00176       if(dsrs.GetNumRows()==1) {
00177         fsubrun=dsrs.GetRow(0)->fSubRun;
00178         MSG("CDTrackerModule",Msg::kInfo)
00179           <<"Found subrun in database="<<fsubrun
00180           <<", run="<<dsrs.GetRow(0)->fRun<<endl
00181           <<"Start time="<<dsrs.GetRow(0)->fStartTime.GetSec()<<endl
00182           <<"End time  ="<<dsrs.GetRow(0)->fEndTime.GetSec()<<endl;
00183       }
00184       else{
00185         MSG("CDTrackerModule",Msg::kWarning)
00186           <<"Can't find subrun in database, #rows="<<dsrs.GetNumRows()
00187           <<", fsubrun="<<fsubrun<<endl;
00188       }
00189       */
00190       MSG("CDTrackerModule",Msg::kVerbose)<<"Subrun="<<fsubrun<<endl;
00191     }
00192   }
00193   else{
00194     MSG("CDTrackerModule",Msg::kWarning) 
00195       <<"No RawDaqSnarlHeader in MOM."<<endl;
00196     result.SetFailed();
00197     return result;
00198   }
00199 
00200   //get the temperature from the calibrator
00201   Calibrator& cal=Calibrator::Instance();
00202   cal.Reset(snarlHdr->GetVldContext());
00203   fTemperature=cal.GetTemperature();
00204   MAXMSG("CDTrackerModule",Msg::kDebug,20) 
00205     <<"Used Calibrator to get temperature="<<fTemperature<<" C"<<endl;
00206 
00207   int ExtTrigTime=0;//stores external trigger time of specific channel
00208   const RawDigitDataBlock *rddb=dynamic_cast<const RawDigitDataBlock *>
00209     (rr->FindRawBlock("RawDigitDataBlock"));
00210 
00211   //looping to find particular channel
00212   if (rddb) {
00213     RawChannelId id(Detector::kCalDet,ElecType::kVA,0,0x1602);
00214     id.SetModeBits(true,true,true);
00215     TIter it=rddb->GetDatumIter();
00216     while (TObject *obj=it.Next()) {
00217       RawVaDigit *rvd=dynamic_cast<RawVaDigit *>(obj);
00218       if (rvd) {
00219         RawChannelId rcid=rvd->GetChannel();
00220         if (rcid.IsSameChannel(id)) ExtTrigTime=rvd->GetTDC();
00221       }
00222     }
00223   }
00224     
00225   //work out the directory to write to
00226   if(ffirstrecord) {
00227     MSG("CDTrackerModule",Msg::kDebug)
00228       <<"Opening file..."<<endl;
00229     //open the output file
00230     fsavefile=this->OpenFile(frun,fsubrun);
00231     
00232     //create tree and initialise branches
00233     this->InitialiseTree();
00234     ffirstrecord=false;
00235     MSG("CDTrackerModule",Msg::kDebug) 
00236       <<"... file opened and tree initialised"<<endl;
00237 
00238     if (fSimFlag==SimFlag::kData){
00239       //note that only beam momentum for data is set here
00240       //for MC it is the largest stdhep TParticle momentum
00241       DbiResultPtr<CalDetBeamMomentum> cdbm(snarlHdr->GetVldContext(),
00242                                             Dbi::kDefaultTask,
00243                                             Dbi::kDisabled);
00244       
00245       MSG("CDTrackerModule",Msg::kDebug)
00246         <<"Number of rows in CalDetBeamMomentum="<<cdbm.GetNumRows()
00247         <<endl;
00248       
00249       //get the database row
00250       if(cdbm.GetNumRows()==1) {
00251         fBeamMomentum=cdbm.GetRow(0)->GetMomentum();
00252         MSG("CDTrackerModule",Msg::kInfo)
00253           <<"Found beam momentum in database="<<fBeamMomentum<<endl;
00254       }
00255       else{
00256         MSG("CDTrackerModule",Msg::kInfo)
00257           <<"Problem with beam momentum in database"
00258           <<", #rows="<<cdbm.GetNumRows()
00259           <<", beamMomentum="<<fBeamMomentum<<endl;
00260       }
00261     }
00262   }
00263   static Bool_t firstSnarl=true;
00264   if (firstSnarl){
00265     MSG("CDTrackerModule",Msg::kInfo)
00266       <<"Started tracking... (first snarl number="<<fsnarl
00267       <<", second="<<fSec<<")"<<endl;
00268     firstSnarl=false;
00269   }
00270 
00271   if (fWritePID){
00272     //make PID Info object
00273     fPID=new CDPIDInfo();
00274 
00275     //Get CandCalDetSIHandle and pass it to CDPIDInfo constructor
00276     CandCalDetSIHandle* cdsi=dynamic_cast<CandCalDetSIHandle*>
00277       (candrec->FindCandHandle("CandCalDetSIHandle"));
00278     
00279     //now fill CDPIDInfo with SI info object
00280     if(cdsi) {
00281       this->FillPID(cdsi);
00282     }
00283     else{      
00284       if (fSimFlag==SimFlag::kData){
00285         MSG("CDTrackerModule",Msg::kError)
00286           <<"No caldet SI handle; not filling CDPIDInfo!"<<endl;
00287       }
00288       //else simflag=MC and you don't expect to find such a handle
00289     }
00290 
00291     CandCalDetPIDHandle* cdpid=dynamic_cast<CandCalDetPIDHandle*>
00292       (candrec->FindCandHandle("CandCalDetPIDHandle"));
00293 
00294     //now fill CDPIDInfo object from cdpid
00295     if (cdpid){
00296       MSG("CalDetPID",Msg::kDebug) 
00297         <<"Tracker::particle="<<cdpid->GetPIDType()
00298         <<", nooverlap="<<cdpid->NoOverlap()
00299         <<", inckvtime="<<cdpid->InCERTime()
00300         <<", ol chi2="<<cdpid->GetOLChi2()
00301         <<endl;
00302       this->FillPID(cdpid);
00303     }
00304     else{
00305       if (fSimFlag==SimFlag::kData){
00306       MAXMSG("CDTrackerModule",Msg::kWarning,5) 
00307         <<"No caldet pid handle; not filling CDPIDInfo!"<<endl;
00308       }
00309       //else simflag=MC and you don't expect to find such a handle
00310     }
00311   }
00312 
00313   //Get CandDigitList
00314   CandDigitListHandle *digitlist=dynamic_cast<CandDigitListHandle*>
00315     (candrec->FindCandHandle("CandDigitListHandle"));
00316   if(digitlist==0) {
00317     MSG("CDTrackerModule", Msg::kFatal) 
00318       << "No CandDigitList in MOM." << endl;
00319     result.SetFailed();
00320     return result;
00321   }
00322 
00323   //Get CandStripList
00324   CandStripListHandle *striplist=dynamic_cast<CandStripListHandle*>
00325     (candrec->FindCandHandle("CandStripListHandle"));
00326   if(striplist==0) {
00327     MSG("CDTrackerModule", Msg::kFatal) 
00328       << "No CandStripList in MOM." << endl;
00329     result.SetFailed();
00330     return result;
00331   }
00332 
00334   //Write the truth information
00336   if (fWriteTruth){
00337     //check if the input file is not data
00338     if (fSimFlag!=SimFlag::kData){
00339       MAXMSG("CDTrackerModule", Msg::kVerbose,5)
00340         <<"fSimFlag="<<SimFlag::AsString(fSimFlag)
00341         <<". Accessing truth info..."<<endl; 
00342       //create a CDTruthifier
00343       CDTruthifier cdTruthifier;
00344       cdTruthifier.GetTruthHitInfo(mom,fTruthHits);
00345 
00346       Float_t beamP=0;
00347 
00348       //get the particle momentum
00349       //note that for kData the beam momentum is obtained 
00350       //from the caldet database table
00351       if (fWritePID && fPID){
00352         cdTruthifier.RecoStdHep(mom,fPID);
00353         beamP=fPID->GetTrueParticleMomentum();
00354       }
00355       else if (!fPID){
00356         //still want to get the beam momentum
00357         //even if not writing the whole CDPIDInfo object
00358         beamP=cdTruthifier.ParticleMomentum(mom);
00359       }
00360 
00361       //calculate the average beam momentum
00362       static Float_t count=0;
00363       MAXMSG("CDTrackerModule",Msg::kVerbose,200)
00364         <<"beamP="<<beamP<<", fBeamMomentum="<<fBeamMomentum
00365         <<", count="<<count<<endl;
00366       fBeamMomentum=fBeamMomentum*(count/(count+1))+beamP*(1/(count+1));
00367       count++;
00368     }
00369   }
00370 
00371   //make a map of the strips
00372   CDMapMaker *mpmkrStrips = new CDMapMaker(striplist);
00373 
00374   //cross talk removal code:
00375   CDCrossTalker xtalker(mpmkrStrips->GetStripMap(),0.9,
00376                         fTrkOpt->Cosmic());
00377   xtalker.GetXTalkStripInfo(fXTalkHits);
00378 
00379   //create tracker object
00380   CDTracker *tracker;
00381 
00382   //pass crosstalk removed map to the tracker:
00383   //if cosmic option set, use cosmic tracker otherwise beam tracker
00384   if(fTrkOpt->Cosmic()){
00385     tracker=new CDCosmicTracker(xtalker.GetCleanStripMap(),fTrkOpt);
00386   }
00387   else{
00388     tracker=new CDBeamMuTracker(xtalker.GetCleanStripMap(),fTrkOpt);
00389   }
00390   
00391   //Get track info from the tracker
00392   fTrkInfo=tracker->GetTrackInfo();
00393   
00394   //Set a few things that can't be set in the CDTracker objects:
00395   fTrkInfo->SetAbsTime(digitlist->GetAbsTime());//leave as digit
00396   fTrkInfo->SetTriggerTime(ExtTrigTime);
00397   
00398   //calculate pathlengths etc. for each hit in a track:
00399   CDTrackedHits trkHits(tracker->GetTrackedStripMap(PlaneView::kX),
00400                         tracker->GetTrackedStripMap(PlaneView::kY),
00401                         tracker->GetCCStripMap());
00402   
00403   //Use angles from the track info class to calculate track quantities:
00404   trkHits.GetTrackedStripInfo(fStTrkHits,fTrkInfo->GetAngle(0),
00405                               fTrkInfo->GetAngle(1));
00406   
00407   //Get Cosmic counter hit info
00408   trkHits.GetCCStripInfo(fCCHits);
00409   
00410   //Set trk range in TrackInfo object
00411   fTrkInfo->SetRange(trkHits.GetTrkRange());
00412   
00413   //alternative way to calculate pathlengths
00414   //only necessary for beam muons
00415   if(!fTrkOpt->Cosmic()){
00416     trkHits.GetTrackedStripInfo(fTrkHits);  
00417     //overwrite trk range if BeamTracker used
00418     fTrkInfo->SetRange(trkHits.GetTrkRange());
00419   }
00420 
00421   //Find unidentified hits in event
00422   //need to change the cross talker
00423   CDUnidentifiedHits uihStrips
00424     (mpmkrStrips->GetStripMap(),
00425      tracker->GetTrackedStripMap(PlaneView::kX),
00426      tracker->GetTrackedStripMap(PlaneView::kY),
00427      tracker->GetCCStripMap(),
00428      xtalker.GetXTalkStripMap());
00429 
00430   //get the unidentified strips
00431   uihStrips.GetUnidentifiedStripInfo(fUnTrkHits);
00432   
00433   //fill tree with info:
00434   if(fTrkInfo->GetResult(0)==1 && fTrkInfo->GetResult(1)==1){
00435     ftree->Fill();
00436   }
00437   else {
00438     result.SetFailed();
00439     if(!fJustWriteTracks)
00440       ftree->Fill();
00441   }
00442   
00443   //delete objects pointed to by local pointers
00444   delete tracker;
00445   delete mpmkrStrips;
00446 
00447   //clear the TClonesArrays and delete objects
00448   this->CleanDataMembers();
00449 
00450   return result;
00451 }

void CDTrackerModule::CleanDataMembers (  )  [private]

Definition at line 454 of file CDTrackerModule.cxx.

References fCCHits, fPID, fStTrkHits, fTrkHits, fTrkInfo, fTruthHits, fUnTrkHits, and fXTalkHits.

Referenced by Ana().

00455 {
00456   //Clear TClonesArrays for next event
00457   //Note: This used to use Delete but that is slower and only 
00458   //necessary for objects (stored in the TClonesArray) that 
00459   //allocate their own memory
00460   fTrkHits->Clear();
00461   fStTrkHits->Clear();
00462   fCCHits->Clear();
00463   fXTalkHits->Clear();
00464   fUnTrkHits->Clear();
00465   fTruthHits->Clear();
00466   
00467   //delete objects 
00468   if (fTrkInfo) delete fTrkInfo;
00469   if (fPID) delete fPID;
00470 
00471   //reinitialise pointers
00472   fTrkInfo=0;
00473   fPID=0;
00474 
00475   //Note: Don't delete the fTrkOpt, it is only created once
00476 }

void CDTrackerModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 583 of file CDTrackerModule.cxx.

References fBeamMomentum, fCCHits, fEndSnarl, fEndTime, frun, fsavefile, fSimFlag, fStartSnarl, fStartTime, fStTrkHits, fsubrun, ftree, fTrkHits, fTrkOpt, fTruthHits, fUnTrkHits, fXTalkHits, Msg::kDebug, Msg::kInfo, Msg::kWarning, and MSG.

00584 {
00585   MSG("CDTrackerModule",Msg::kDebug)<<"Running EndJob()"<<endl;  
00586   
00587   if (fsavefile!=0 && fsavefile->IsWritable()){
00588     fsavefile->cd();
00589     
00590     MSG("CDTrackerModule",Msg::kInfo)
00591       <<"Writing to file... "<<endl;
00592     //print where tree will be written
00593     fsavefile->pwd();
00594     ftree->Write();
00595     
00596     MSG("CDTrackerModule",Msg::kDebug)
00597       <<"Creating options tree..."<<endl;
00598     TTree opt_tree("TrackerOptions","Tracker Options");
00599     opt_tree.Branch("SimFlag",&fSimFlag,"SimFlag/I",32000);
00600     opt_tree.Branch("StartTime",&fStartTime,"StartTime/I",32000);
00601     opt_tree.Branch("EndTime",&fEndTime,"EndTime/I",32000);
00602     opt_tree.Branch("StartSnarl",&fStartSnarl,"StartSnarl/I",32000);
00603     opt_tree.Branch("EndSnarl",&fEndSnarl,"EndSnarl/I",32000);
00604     opt_tree.Branch("BeamMomentum",&fBeamMomentum,
00605                     "BeamMomentum/F",32000);
00606     opt_tree.Branch("Run",&frun,"run/I",32000);
00607     opt_tree.Branch("SubRun",&fsubrun,"subrun/I",32000);
00608     opt_tree.Branch("TrackerOptions","CDTrackerOptions",
00609                      &fTrkOpt,8000,1);
00610     
00611     MSG("CDTrackerModule",Msg::kInfo)
00612       <<"Time="<<fStartTime<<"->"<<fEndTime<<endl
00613       <<"Snarl="<<fStartSnarl<<"->"<<fEndSnarl<<endl;
00614 
00615     MSG("CDTrackerModule",Msg::kDebug)<<"Filling tree..."<<endl;
00616     opt_tree.Fill();
00617     opt_tree.Write();
00618     MSG("CDTrackerModule",Msg::kInfo)<<"Closing file..."<<endl;
00619     fsavefile->Close();
00620   }
00621   else {
00622     MSG("CDTrackerModule",Msg::kWarning)
00623       <<"File not writable!"<<endl;
00624   }
00625 
00626   delete fTrkHits;
00627   delete fCCHits;
00628   delete fStTrkHits;
00629   delete fXTalkHits;
00630   delete fUnTrkHits;
00631   delete fTruthHits;
00632 
00633   MSG("CDTrackerModule",Msg::kDebug)
00634     <<"End of CDTrackerModule::EndJob() reached"<<endl;
00635 }

void CDTrackerModule::FillPID ( const CandCalDetPIDHandle cdpid  )  [private]

Definition at line 727 of file CDTrackerModule.cxx.

References fPID, CandCalDetPIDHandle::GetInCERTimeBits(), CandCalDetPIDHandle::GetNoOverlapBits(), CandCalDetPIDHandle::GetOLChi2(), CandCalDetPIDHandle::GetPIDType(), CandCalDetPIDHandle::InCERTime(), Msg::kVerbose, MSG, CandCalDetPIDHandle::NoOverlap(), CDPIDInfo::SetInCERTime(), CDPIDInfo::SetInCERTimeBits(), CDPIDInfo::SetNoOverlap(), CDPIDInfo::SetNoOverlapBits(), CDPIDInfo::SetOLChi2(), and CDPIDInfo::SetPIDType().

00728 {
00729   //check handle exists and fill
00730   if(cdpid) {
00731     MSG("CDTrackerModule",Msg::kVerbose)
00732       <<"Filling CDPIDInfo object with CalDetPID info"<<endl;
00733     fPID->SetPIDType(cdpid->GetPIDType());
00734     fPID->SetNoOverlap(cdpid->NoOverlap());
00735     fPID->SetInCERTime(cdpid->InCERTime());
00736     fPID->SetNoOverlapBits(cdpid->GetNoOverlapBits());
00737     fPID->SetInCERTimeBits(cdpid->GetInCERTimeBits());
00738     fPID->SetOLChi2(cdpid->GetOLChi2());
00739   }
00740 }

void CDTrackerModule::FillPID ( CandCalDetSIHandle CDSI  )  [private]

Definition at line 744 of file CDTrackerModule.cxx.

References fPID, CandCalDetSIHandle::GetFafErr(), CandCalDetSIHandle::GetKovADC1(), CandCalDetSIHandle::GetKovADC2(), CandCalDetSIHandle::GetKovADC3(), CandCalDetSIHandle::GetKovTimeStamp1(), CandCalDetSIHandle::GetKovTimeStamp2(), CandCalDetSIHandle::GetKovTimeStamp3(), CandCalDetSIHandle::GetSnarlMaxTimeStamp(), CandCalDetSIHandle::GetSnarlMinTimeStamp(), CandCalDetSIHandle::GetSnarlTimeFrame(), CandCalDetSIHandle::GetSparseErr(), CandCalDetSIHandle::GetTickSinceLast(), CandCalDetSIHandle::GetTofADC0(), CandCalDetSIHandle::GetTofADC1(), CandCalDetSIHandle::GetTofADC2(), CandCalDetSIHandle::GetTofADCTimeStamp0(), CandCalDetSIHandle::GetTofADCTimeStamp1(), CandCalDetSIHandle::GetTofADCTimeStamp2(), CandCalDetSIHandle::GetTofTDC0(), CandCalDetSIHandle::GetTofTDC1(), CandCalDetSIHandle::GetTofTDC2(), CandCalDetSIHandle::GetTofTimeStamp(), CandCalDetSIHandle::GetTriggerPMT(), CandCalDetSIHandle::GetTrigSource(), CDPIDInfo::SetFafErr(), CDPIDInfo::SetIsEmpty(), CDPIDInfo::SetKovADC1(), CDPIDInfo::SetKovADC2(), CDPIDInfo::SetKovADC3(), CDPIDInfo::SetKovTimeStamp1(), CDPIDInfo::SetKovTimeStamp2(), CDPIDInfo::SetKovTimeStamp3(), CDPIDInfo::SetSnarlMaxTimeStamp(), CDPIDInfo::SetSnarlMinTimeStamp(), CDPIDInfo::SetSnarlTimeFrame(), CDPIDInfo::SetSparseErr(), CDPIDInfo::SetTickSinceLast(), CDPIDInfo::SetTofADC0(), CDPIDInfo::SetTofADC1(), CDPIDInfo::SetTofADC2(), CDPIDInfo::SetTofADCTimeStamp0(), CDPIDInfo::SetTofADCTimeStamp1(), CDPIDInfo::SetTofADCTimeStamp2(), CDPIDInfo::SetTofTDC0(), CDPIDInfo::SetTofTDC1(), CDPIDInfo::SetTofTDC2(), CDPIDInfo::SetTofTimeStamp(), CDPIDInfo::SetTriggerPMT(), and CDPIDInfo::SetTrigSource().

Referenced by Ana().

00745 {
00746   //check handle exists and fill
00747   if(cdsi) {
00748     fPID->SetIsEmpty(true);
00749     fPID->SetTriggerPMT(cdsi->GetTriggerPMT());
00750     fPID->SetFafErr(cdsi->GetFafErr());
00751     fPID->SetSparseErr(cdsi->GetSparseErr());
00752     fPID->SetTrigSource(cdsi->GetTrigSource());
00753     fPID->SetKovADC1(cdsi->GetKovADC1());
00754     fPID->SetKovADC2(cdsi->GetKovADC2());
00755     fPID->SetKovADC3(cdsi->GetKovADC3());
00756     fPID->SetKovTimeStamp1(cdsi->GetKovTimeStamp1());
00757     fPID->SetKovTimeStamp2(cdsi->GetKovTimeStamp2());
00758     fPID->SetKovTimeStamp3(cdsi->GetKovTimeStamp3());
00759     fPID->SetSnarlTimeFrame(cdsi->GetSnarlTimeFrame());
00760     fPID->SetSnarlMinTimeStamp(cdsi->GetSnarlMinTimeStamp());
00761     fPID->SetSnarlMaxTimeStamp(cdsi->GetSnarlMaxTimeStamp());
00762     fPID->SetTofTDC0(cdsi->GetTofTDC0());
00763     fPID->SetTofTDC1(cdsi->GetTofTDC1());
00764     fPID->SetTofTDC2(cdsi->GetTofTDC2());    
00765     fPID->SetTofADC0(cdsi->GetTofADC0());
00766     fPID->SetTofADC1(cdsi->GetTofADC1());
00767     fPID->SetTofADC2(cdsi->GetTofADC2());
00768     fPID->SetTofADCTimeStamp0(cdsi->GetTofADCTimeStamp0());
00769     fPID->SetTofADCTimeStamp1(cdsi->GetTofADCTimeStamp1());
00770     fPID->SetTofADCTimeStamp2(cdsi->GetTofADCTimeStamp2());
00771     fPID->SetTofTimeStamp(cdsi->GetTofTimeStamp());
00772     fPID->SetTickSinceLast(cdsi->GetTickSinceLast());
00773   }
00774 }

void CDTrackerModule::HandleCommand ( JobCommand cmd  )  [virtual]

Implement to handle a JobCommand

Reimplemented from JobCModule.

Definition at line 480 of file CDTrackerModule.cxx.

References fJustWriteTracks, fOverwriteFile, ftag, fTrkOpt, fWritePID, fWriteTruth, JobCommand::HaveCmd(), Msg::kWarning, MSG, JobCommand::PopCmd(), JobCommand::PopFloatOpt(), JobCommand::PopIntOpt(), JobCommand::PopOpt(), CDTrackerOptions::SetAcceptance(), CDTrackerOptions::SetAngleLimit(), CDTrackerOptions::SetHitsPerPlane(), CDTrackerOptions::SetMaxHotPlanes(), CDTrackerOptions::SetMinAngle(), CDTrackerOptions::SetMinHit(), CDTrackerOptions::SetMinVertAngle(), CDTrackerOptions::SetThresh(), CDTrackerOptions::SetTrackerOptions(), and CDTrackerOptions::SetTrkLenCut().

00481 {
00482 
00483   if (cmd->HaveCmd()) {                      // If we have a command...
00484     string sc = cmd->PopCmd();               // Get the command
00485     
00486     if (sc == "TrackOpt") {
00487       string st(cmd->PopOpt());
00488       fTrkOpt->SetTrackerOptions(st);
00489       return;
00490     }
00491 
00492     else if (sc == "ADCThreshold") {
00493       fTrkOpt->SetThresh(cmd->PopFloatOpt());
00494       return;
00495     }
00496 
00497     else if (sc == "MinNHits") {
00498       fTrkOpt->SetMinHit(cmd->PopIntOpt());
00499       return;
00500     }
00501     
00502     else if (sc == "MinTrkLen") {
00503       fTrkOpt->SetTrkLenCut(cmd->PopIntOpt());
00504       return;
00505     }
00506     
00507     else if (sc == "MaxAngle") {
00508       fTrkOpt->SetAngleLimit(cmd->PopFloatOpt());
00509       return;
00510     }
00511     
00512     else if (sc == "MinAngle") {
00513       fTrkOpt->SetMinAngle(cmd->PopFloatOpt());
00514       return;
00515     }
00516 
00517     else if (sc == "MinVertAngle") {
00518       fTrkOpt->SetMinVertAngle(cmd->PopFloatOpt());
00519       return;
00520     }
00521 
00522     else if (sc == "SearchRange") {
00523       fTrkOpt->SetAcceptance(cmd->PopIntOpt());
00524       return;
00525     }
00526 
00527     else if (sc == "HitsPerPlane") {
00528       fTrkOpt->SetHitsPerPlane(cmd->PopIntOpt());
00529       return;
00530     }
00531 
00532     else if (sc == "MaxHotPlanes") {
00533       fTrkOpt->SetMaxHotPlanes(cmd->PopIntOpt());
00534       return;
00535     }
00536 
00537     else if (sc == "FileID") {
00538       sprintf(ftag,"%s",cmd->PopOpt());
00539       return;      
00540     }
00541 
00542     else if (sc == "JustWriteTracks") {
00543       int tempNum=cmd->PopIntOpt();
00544       if(tempNum==0)
00545         fJustWriteTracks=0;
00546       if(tempNum>0) 
00547         fJustWriteTracks=1;
00548       return;      
00549     }
00550 
00551     else if (sc == "OverwriteFile") {
00552       int tempNum=cmd->PopIntOpt();
00553       if(tempNum==0)
00554         fOverwriteFile=0;
00555       if(tempNum>0) 
00556         fOverwriteFile=1;
00557       return;      
00558     }
00559 
00560     else if (sc == "WritePID") {
00561       int tempNum=cmd->PopIntOpt();
00562       if(tempNum==0)
00563         fWritePID=0;
00564       if(tempNum>0) 
00565         fWritePID=1;
00566       return;      
00567     }
00568     else if (sc == "WriteTruth") {
00569       int tempNum=cmd->PopIntOpt();
00570       if(tempNum==0)
00571         fWriteTruth=0;
00572       if(tempNum>0) 
00573         fWriteTruth=1;
00574       return; 
00575     }
00576     else MSG("CDTrackerModule",Msg::kWarning) 
00577       << "Don't understand '" << sc.c_str() << "'\n";
00578   }
00579 }

void CDTrackerModule::InitialiseTree (  )  [private]

Definition at line 703 of file CDTrackerModule.cxx.

References fCCHits, fNumDeadChips, fPID, fSec, fsnarl, fStTrkHits, fTemperature, ftree, fTrkHits, fTrkInfo, fTruthHits, fUnTrkHits, fWritePID, fWriteTruth, and fXTalkHits.

Referenced by Ana().

00704 {
00705   //create the tree
00706   ftree=new TTree("TrackerTree","Tracker Tree");
00707   
00708   //set tree branches  
00709   ftree->Branch("Snarl",&fsnarl,"snarl/I",32000);
00710   ftree->Branch("NumDeadChips",&fNumDeadChips,"NumDeadChips/I",32000);
00711   ftree->Branch("Sec",&fSec,"Sec/I",32000);
00712   ftree->Branch("Temperature",&fTemperature,"Temperature/F",32000);
00713   if(fWritePID==1) ftree->Branch("PIDInfo","CDPIDInfo",&fPID,8000,1);
00714   ftree->Branch("TrackInfo","CDTrackInfo",&fTrkInfo,8000,1);
00715   ftree->Branch("TrackedHitInfo","TClonesArray",&fTrkHits,8000,1);
00716   ftree->Branch("StraightTrackedHitInfo","TClonesArray",
00717                 &fStTrkHits,8000,1);
00718   ftree->Branch("CCHitInfo","TClonesArray",&fCCHits,8000,1);
00719   ftree->Branch("XTalkHitInfo","TClonesArray",&fXTalkHits,8000,1);
00720   ftree->Branch("UnTrackedHitInfo","TClonesArray",&fUnTrkHits,8000,1);
00721   if (fWriteTruth) ftree->Branch("TruthHitInfo","TClonesArray",
00722                                  &fTruthHits,8000,1);
00723 }

TFile * CDTrackerModule::OpenFile ( Int_t  runNumber,
Int_t  runNumberSub 
) [private]

Definition at line 639 of file CDTrackerModule.cxx.

References Form(), fOverwriteFile, ftag, Msg::kInfo, Msg::kVerbose, and MSG.

Referenced by Ana().

00641 {
00642   //create the tfile pointer to be returned
00643   TFile* outputFile=0;
00644   
00645   //get the environmental variable
00646   char *trackerdir=getenv("TRACKER_DIR");
00647   
00648   //use a string to hold env instead 
00649   string sTrackerDir="";
00650   
00651   if (trackerdir!=NULL) {
00652     sTrackerDir=trackerdir;
00653   }
00654   else {
00655     MSG("CDTrackerModule",Msg::kInfo) 
00656       <<"Environmental variable $TRACKER_DIR not set." 
00657       <<" Writing file(s) to current directory"<<endl;
00658     sTrackerDir=".";
00659   }
00660   
00661   //convert varaibles to string
00662   string sRunNumber=Form("%d",runNumber);
00663   string sRunNumberSub=Form("%d",runNumberSub);
00664   MSG("CDTrackerModule",Msg::kVerbose) 
00665     <<"srunnumbersub="<<sRunNumberSub<<endl;
00666   //string sDetector="";
00667   string sTag=ftag;
00668   string sBase=sTrackerDir+"/Tracker"+sRunNumber+"_"+
00669     sRunNumberSub+"_"+sTag;
00670   string sFileName=sBase+".root";
00671   
00672   //test if file already exists
00673   ifstream Test(sFileName.c_str());
00674   
00675   //open the appropriate file
00676   if(!Test || fOverwriteFile){
00677     outputFile=new TFile(sFileName.c_str(),"RECREATE");
00678     if(fOverwriteFile) {
00679        if(Test) Test.close();
00680     }
00681   }
00682   else {
00683     //Need new filename
00684     Int_t fred=1;
00685     while(Test) {
00686       Test.close();
00687       string sAppendage=Form("%d",fred);
00688       sFileName=sBase+"_"+sAppendage+".root";
00689       Test.open(sFileName.c_str());
00690       fred++;
00691     }
00692     outputFile = new TFile(sFileName.c_str(),"NEW");
00693     outputFile->SetCompressionLevel(9);
00694   }
00695   
00696   MSG("CDTrackerModule",Msg::kInfo) 
00697     <<"Output file opened: "<<sFileName<<endl;
00698   return outputFile;
00699 }


Member Data Documentation

Float_t CDTrackerModule::fBeamMomentum [private]

Definition at line 54 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

TClonesArray* CDTrackerModule::fCCHits [private]

Definition at line 78 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), CleanDataMembers(), EndJob(), and InitialiseTree().

Int_t CDTrackerModule::fEndSnarl [private]

Definition at line 63 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

Int_t CDTrackerModule::fEndTime [private]

Definition at line 65 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

bool CDTrackerModule::ffirstrecord [private]

Definition at line 51 of file CDTrackerModule.h.

Referenced by Ana(), and CDTrackerModule().

Int_t CDTrackerModule::fJustWriteTracks [private]

Definition at line 87 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and HandleCommand().

Int_t CDTrackerModule::fNumDeadChips [private]

Definition at line 55 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and InitialiseTree().

Int_t CDTrackerModule::fOverwriteFile [private]

Definition at line 88 of file CDTrackerModule.h.

Referenced by CDTrackerModule(), HandleCommand(), and OpenFile().

CDPIDInfo* CDTrackerModule::fPID [private]

Definition at line 85 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), CleanDataMembers(), FillPID(), and InitialiseTree().

Int_t CDTrackerModule::frun [private]

Definition at line 58 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

TFile* CDTrackerModule::fsavefile [private]

Definition at line 68 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

Int_t CDTrackerModule::fSec [private]

Definition at line 61 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and InitialiseTree().

SimFlag::SimFlag_t CDTrackerModule::fSimFlag [private]

Definition at line 57 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

Int_t CDTrackerModule::fsnarl [private]

Definition at line 60 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and InitialiseTree().

Int_t CDTrackerModule::fStartSnarl [private]

Definition at line 62 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

Int_t CDTrackerModule::fStartTime [private]

Definition at line 64 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

TClonesArray* CDTrackerModule::fStTrkHits [private]

Definition at line 76 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), CleanDataMembers(), EndJob(), and InitialiseTree().

Int_t CDTrackerModule::fsubrun [private]

Definition at line 59 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and EndJob().

Char_t CDTrackerModule::ftag[256] [private]

Definition at line 66 of file CDTrackerModule.h.

Referenced by CDTrackerModule(), HandleCommand(), and OpenFile().

Float_t CDTrackerModule::fTemperature [private]

Definition at line 56 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), and InitialiseTree().

TTree* CDTrackerModule::ftree [private]

Definition at line 72 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), EndJob(), and InitialiseTree().

TClonesArray* CDTrackerModule::fTrkHits [private]

Definition at line 75 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), CleanDataMembers(), EndJob(), and InitialiseTree().

CDTrackInfo* CDTrackerModule::fTrkInfo [private]

Definition at line 74 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), CleanDataMembers(), and InitialiseTree().

CDTrackerOptions* CDTrackerModule::fTrkOpt [private]

Definition at line 70 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), EndJob(), and HandleCommand().

TClonesArray* CDTrackerModule::fTruthHits [private]

Definition at line 83 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), CleanDataMembers(), EndJob(), and InitialiseTree().

TClonesArray* CDTrackerModule::fUnTrkHits [private]

Definition at line 80 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), CleanDataMembers(), EndJob(), and InitialiseTree().

Int_t CDTrackerModule::fWritePID [private]

Definition at line 89 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), HandleCommand(), and InitialiseTree().

Int_t CDTrackerModule::fWriteTruth [private]

Definition at line 90 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), HandleCommand(), and InitialiseTree().

TClonesArray* CDTrackerModule::fXTalkHits [private]

Definition at line 79 of file CDTrackerModule.h.

Referenced by Ana(), CDTrackerModule(), CleanDataMembers(), EndJob(), and InitialiseTree().


The documentation for this class was generated from the following files:
Generated on Thu Jul 10 22:52:34 2014 for loon by  doxygen 1.4.7