UberPlotsModule Class Reference

#include <UberPlotsModule.h>

Inheritance diagram for UberPlotsModule:

JobCModule List of all members.

Public Member Functions

 UberPlotsModule ()
 ~UberPlotsModule ()
void BeginJob ()
void EndJob ()
JobCResult Ana (const MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)
void Help ()

Static Private Member Functions

static int PlaneTrigger (float *qvec, int len)

Private Attributes

std::string fDirName
TH1F * h_mips
TH1F * h_mips24
TH1F * h_ph
TH1F * fStripOcc1 [60]
TH1F * fStripOcc2 [60]
TH2F * h_pse1
TH2F * h_pse2
TH2F * h_pso1
TH2F * h_pso2
TH2F * h_wpse1
TH2F * h_wpse2
TH2F * h_wpso1
TH2F * h_wpso2
TProfile * h_edep
TH1F * h_ptrig

Static Private Attributes

static TFile * fOut = 0

Detailed Description

Definition at line 25 of file UberPlotsModule.h.


Constructor & Destructor Documentation

UberPlotsModule::UberPlotsModule (  ) 

Definition at line 32 of file UberPlotsModule.cxx.

00033 {
00034 //======================================================================
00035 // does nothing
00036 //======================================================================
00037 
00038 }

UberPlotsModule::~UberPlotsModule (  ) 

Definition at line 42 of file UberPlotsModule.cxx.

00043 {
00044 //======================================================================
00045 // does nothing
00046 //======================================================================
00047 
00048 /*
00049   // seg faulted -- why?
00050      if(fOut) {
00051           delete fOut;
00052           fOut=0;
00053      }
00054 */
00055 }


Member Function Documentation

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

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 183 of file UberPlotsModule.cxx.

References fStripOcc1, fStripOcc2, MomNavigator::GetFragment(), UberRecord::GetHitList(), h_edep, h_mips, h_mips24, h_ph, h_pse1, h_pse2, h_pso1, h_pso2, h_ptrig, h_wpse1, h_wpse2, h_wpso1, h_wpso2, JobCResult::kAOK, JobCResult::kPassed, UberRecord::nhitplanes, PlaneTrigger(), and UberRecord::totmip.

00184 {
00185 //======================================================================
00186 // does the plotting
00187 //======================================================================
00188 const UberRecord* ur = 
00189     dynamic_cast<const UberRecord*>(mom->GetFragment("UberRecord"));
00190 
00191 if(!ur) return JobCResult::kAOK; // don't care if there isn't a record!
00192 
00193 // require it to be a pion, nooverlap
00194 
00195 //if(!( (ur->cpid.pid&0x04)&&(ur->cpid.nov==1)) ) return JobCResult::kAOK;
00196 
00197 // loop over hits the first time to fill array of mips in each plane
00198 float mip_by_plane[60]={0.0};
00199 const TClonesArray* hitlist = ur->GetHitList();
00200 for(int i=0; i<hitlist->GetSize(); i++){
00201     const UberHit* hit= static_cast<const UberHit*>(hitlist->At(i));
00202     if(!hit) continue;
00203     
00204     const int plane=hit->GetPlane();
00205     if((plane<0)||(plane>59)) continue;
00206     const int strip=hit->GetStrip();
00207     if((strip<0)||(strip>23)) continue;
00208 
00209     mip_by_plane[plane]+=(hit->GetPosMIP()+hit->GetNegMIP());
00210 
00211 }
00212 
00213 map<double,int> pmap;
00214 for(int i=0; i<60; i++){pmap.insert(pair<double,int>(mip_by_plane[i],i));}
00215 
00216 
00217 // ok, now apply a plane trigger!
00218 
00219 const int trig = PlaneTrigger(mip_by_plane, 60);
00220 h_ptrig->Fill(trig);
00221 
00222 
00223 // cut on the trigger
00224 
00225 const int lowtrig=2; // n in n/n+1 ... should make configurable
00226 
00227 // not failing it, just don't want to histogram it
00228 if(trig<lowtrig) return JobCResult::kAOK; 
00229 
00230 h_mips->Fill(ur->totmip);
00231 h_ph->Fill(ur->nhitplanes);
00232 
00233 for(int i=0; i<60; i++) h_edep->Fill(i, mip_by_plane[i]);
00234 
00235 // compute # of mips in first 24 planes
00236 double mips24=0.0;
00237 for(int i=1; i<24; i++) mips24+=mip_by_plane[i];
00238 h_mips24->Fill(mips24);
00239 
00240 // loop over hits again
00241 for(int i=0; i<hitlist->GetSize(); i++){
00242     const UberHit* hit= static_cast<const UberHit*>(hitlist->At(i));
00243     if(!hit) continue;
00244     
00245     const int plane=hit->GetPlane();
00246     if((plane<0)||(plane>59)) continue;
00247     const int strip=hit->GetStrip();
00248     if((strip<0)||(strip>23)) continue;
00249     
00250     // fill strip occupancy histograms
00251     if(hit->GetNegNPE()>0.0) {
00252         fStripOcc1[plane]->Fill(strip);
00253         if(plane%2==0) {
00254             h_pse1->Fill(plane,strip);
00255             h_wpse1->Fill(plane,strip,hit->GetNegMIP()/ur->totmip);
00256             }
00257         else {
00258             h_pso1->Fill(plane,strip);
00259             h_wpso1->Fill(plane,strip,hit->GetNegMIP()/ur->totmip);
00260             }
00261         }
00262     if(hit->GetPosNPE()>0.0) {
00263         fStripOcc2[plane]->Fill(strip);
00264         if(plane%2==0) {
00265             h_pse2->Fill(plane,strip);
00266             h_wpse2->Fill(plane,strip,hit->GetPosMIP()/ur->totmip);
00267             }
00268         else {
00269             h_pso2->Fill(plane,strip);
00270             h_wpso2->Fill(plane,strip,hit->GetPosMIP()/ur->totmip);
00271             }
00272         }
00273     }
00274 
00275 
00276   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00277 }

void UberPlotsModule::BeginJob (  )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 59 of file UberPlotsModule.cxx.

References fDirName, fOut, fStripOcc1, fStripOcc2, h_edep, h_mips, h_mips24, h_ph, h_pse1, h_pse2, h_pso1, h_pso2, h_ptrig, h_wpse1, h_wpse2, h_wpso1, h_wpso2, Msg::kDebug, and MSG.

00060 {
00061 //======================================================================
00062 // opens a file to write histograms to
00063 // creates some histograms
00064 //======================================================================
00065 
00066 MSG("CalDetDST", Msg::kDebug)<<"UberPlotsModule::BeginJob()"<<endl;
00067 
00068 if(!fOut){
00069      fOut = new TFile("upm.root", "recreate");
00070 }
00071 
00072 // force histograms into the file
00073 Bool_t old_dir_stat = TH1::AddDirectoryStatus();
00074 TH1::AddDirectory(kTRUE);
00075 
00076 fOut->cd();
00077 TDirectory* d = new TDirectory(fDirName.c_str(), fDirName.c_str());
00078 d->cd();
00079 
00080 // define histograms
00081 h_mips=new TH1F("mips", "MIPs", 1000, 0, 2000);
00082 h_mips24=new TH1F("mips24", "MIPs (first 24 planes)", 1000, 0, 2000);
00083 
00084 h_ph = new TH1F("ph", "# Planes Hit", 60, -0.5, 59.5);
00085 
00086 for(int i=0; i<60; i++){
00087     TString n1="strip_occ_neg_p";n1+=i;
00088     TString t1="Strip Occupancy (-) side Plane "; t1+=i;
00089     TString n2="strip_occ_pos_p";n2+=i;
00090     TString t2="Strip Occupancy (+) side Plane "; t2+=i;
00091     fStripOcc1[i] = new TH1F(n1.Data(),t1.Data(),24,-0.5,23.5);
00092     fStripOcc2[i] = new TH1F(n2.Data(),t2.Data(),24,-0.5,23.5);
00093 }
00094 
00095 h_pse1 = new TH2F("pse1", "Plane vs. Strip: Even Planes (-) side", 
00096                   60, -0.5, 59.5, 24, -0.5, 23.5);
00097 h_pse2 = new TH2F("pse2", "Plane vs. Strip: Even Planes (+) side", 
00098                   60, -0.5, 59.5, 24, -0.5, 23.5);
00099 h_pso1 = new TH2F("pso1", "Plane vs. Strip: Odd Planes (-) side", 
00100                   60, -0.5, 59.5, 24, -0.5, 23.5);
00101 h_pso2 = new TH2F("pso2", "Plane vs. Strip: Odd Planes (+) side", 
00102                   60, -0.5, 59.5, 24, -0.5, 23.5);
00103 
00104 h_wpse1 = new TH2F("wpse1", 
00105                    "Plane vs. Strip: Weighted by MIPs Even Planes (-) side", 
00106                    60, -0.5, 59.5, 24, -0.5, 23.5);
00107 h_wpse2 = new TH2F("wpse2", 
00108                    "Plane vs. Strip: Weighted by MIPs Even Planes (+) side", 
00109                    60, -0.5, 59.5, 24, -0.5, 23.5);
00110 h_wpso1 = new TH2F("wpso1", 
00111                    "Plane vs. Strip: Weighted by MIPs Odd Planes (-) side", 
00112                    60, -0.5, 59.5, 24, -0.5, 23.5);
00113 h_wpso2 = new TH2F("wpso2", 
00114                    "Plane vs. Strip: Weighted by MIPs Odd Planes (+) side", 
00115                    60, -0.5, 59.5, 24, -0.5, 23.5);
00116 
00117 h_ptrig = new TH1F("ptrig", "Plane Trigger", 7, -0.5, 6.5);
00118 h_ptrig->GetXaxis()->SetTitle("n for n/n+1");
00119 
00120 h_edep = new TProfile("edep", "MIPs vs. Plane", 60, -0.5, 59.5);
00121 
00122 // Last thing:
00123 // switch back to old add dir status so as not to hose user
00124 TH1::AddDirectory(old_dir_stat);
00125 }

void UberPlotsModule::Config ( const Registry r  )  [virtual]

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 130 of file UberPlotsModule.cxx.

References fDirName, and Registry::Get().

00131 {
00132 //======================================================================
00133 // Configure the module given the Registry r
00134 //======================================================================
00135   const char*    t;
00136 
00137   if (r.Get("DirName",t)) { fDirName = t; }
00138 
00139 }

const Registry & UberPlotsModule::DefaultConfig (  )  const [virtual]

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 143 of file UberPlotsModule.cxx.

References JobCModule::GetName(), Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

00144 {
00145 //======================================================================
00146 // Supply the default configuration for the module
00147 //======================================================================
00148   static Registry r; // Default configuration for module
00149 
00150   // Set name of config
00151   std::string name = this->JobCModule::GetName();
00152   name += ".config.default";
00153   r.SetName(name.c_str());
00154 
00155   // Set values in configuration
00156   r.UnLockValues();
00157 
00158   const char* s = "all";
00159   r.Set("DirName", s);
00160   
00161   r.LockValues();
00162 
00163   return r;
00164 }

void UberPlotsModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 169 of file UberPlotsModule.cxx.

References fOut.

00170 {
00171 //======================================================================
00172 // write and close file
00173 //======================================================================
00174 
00175      if(fOut->IsOpen()){
00176           fOut->Write();
00177           fOut->Close();
00178      }
00179 }

void UberPlotsModule::Help (  )  [virtual]

Implement to spew some useful help to cout

Reimplemented from JobCModule.

Definition at line 281 of file UberPlotsModule.cxx.

00282 {
00283 //======================================================================
00284 // I should print something here....
00285 //======================================================================
00286 }

int UberPlotsModule::PlaneTrigger ( float *  qvec,
int  len 
) [static, private]

Definition at line 291 of file UberPlotsModule.cxx.

References count.

Referenced by Ana().

00292     {
00293     // qvec= array of charge,pes,mips by plane
00294     // len= the length of qvec
00295     const float thresh = 0.0; // threshold to count a plane
00296     int trig=0;
00297     int lown=0; // n-1 for the lowest n to try (eg lown=1 implies 2/3)
00298     for(int i=0; i<len; i++){
00299         // form a window with j+1 elements
00300         // j=n in n/n+1
00301         for(int j=6; j>lown; j--){
00302             int count=0;
00303             // loop over the window, careful not to go overboard
00304             for(int k=i; (k<=i+j && k<len); k++){
00305                 if(qvec[k]>thresh) count++;
00306                 }
00307             // don't assign if we already have a more restrictive trigger
00308             if(count>=j && count>trig) { 
00309                 trig=j; // assign the trigger
00310                 // bump the window so we only look for more restrictive triggers 
00311                 lown=j;
00312                 }
00313             }
00314         }
00315     return trig;
00316     }


Member Data Documentation

std::string UberPlotsModule::fDirName [private]

Definition at line 55 of file UberPlotsModule.h.

Referenced by BeginJob(), and Config().

TFile * UberPlotsModule::fOut = 0 [static, private]

Definition at line 54 of file UberPlotsModule.h.

Referenced by BeginJob(), and EndJob().

TH1F* UberPlotsModule::fStripOcc1[60] [private]

Definition at line 60 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH1F* UberPlotsModule::fStripOcc2[60] [private]

Definition at line 61 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TProfile* UberPlotsModule::h_edep [private]

Definition at line 73 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH1F* UberPlotsModule::h_mips [private]

Definition at line 56 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH1F* UberPlotsModule::h_mips24 [private]

Definition at line 57 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH1F* UberPlotsModule::h_ph [private]

Definition at line 58 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH2F* UberPlotsModule::h_pse1 [private]

Definition at line 63 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH2F* UberPlotsModule::h_pse2 [private]

Definition at line 64 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH2F* UberPlotsModule::h_pso1 [private]

Definition at line 65 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH2F* UberPlotsModule::h_pso2 [private]

Definition at line 66 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH1F* UberPlotsModule::h_ptrig [private]

Definition at line 75 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH2F* UberPlotsModule::h_wpse1 [private]

Definition at line 68 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH2F* UberPlotsModule::h_wpse2 [private]

Definition at line 69 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH2F* UberPlotsModule::h_wpso1 [private]

Definition at line 70 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().

TH2F* UberPlotsModule::h_wpso2 [private]

Definition at line 71 of file UberPlotsModule.h.

Referenced by Ana(), and BeginJob().


The documentation for this class was generated from the following files:
Generated on Wed Sep 10 22:52:15 2014 for loon by  doxygen 1.4.7