Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CalDet2003PlotsModule.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CalDet2003PlotsModule.cxx,v 1.13 2008/06/12 19:23:53 rhatcher Exp $
00003 //
00004 // Fills histograms with data from UberRecords
00005 //
00006 // kordosky@hep.utexas.edu
00008 #include <cstdio>
00009 #include <cmath>
00010 #include "CalDetDST/CalDet2003PlotsModule.h"
00011 #include "TROOT.h"
00012 #include "TString.h"
00013 #include "TClonesArray.h"
00014 #include "TFile.h"
00015 #include "TH1.h"
00016 #include "TH2.h"
00017 #include "TProfile.h"
00018 #include "TProfile2D.h"
00019 #include "TDirectory.h"
00020 #include "TEventList.h"
00021 #include "MessageService/MsgService.h"
00022 #include "MinosObjectMap/MomNavigator.h"
00023 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00024 
00025 #include "CalDetDST/UberRecord.h"
00026 #include "CalDetDST/UberHit.h"
00027 
00028 int CalDet2003PlotsModule::fcount = 0;
00029 int CalDet2003PlotsModule::fNumObj = 0;
00030 std::string CalDet2003PlotsModule::fFilePath = "";
00031 std::string CalDet2003PlotsModule::fFileName = "CDPlots-default.root";
00032 TFile* CalDet2003PlotsModule::fOut=0;
00033 
00034 JOBMODULE(CalDet2003PlotsModule, "CalDet2003PlotsModule",
00035           "Make some plots from UberRecord");
00036 CVSID("$Id: CalDet2003PlotsModule.cxx,v 1.13 2008/06/12 19:23:53 rhatcher Exp $");
00037 //......................................................................
00038 
00039 CalDet2003PlotsModule::CalDet2003PlotsModule()
00040 {
00041 //======================================================================
00042 // does nothing
00043 //======================================================================
00044 
00045    fNumObj++;
00046 
00047 }
00048 
00049 //......................................................................
00050 
00051 CalDet2003PlotsModule::~CalDet2003PlotsModule()
00052 {
00053 //======================================================================
00054 // does nothing
00055 //======================================================================
00056    MSG("CalDetDST",Msg::kDebug)<<"in CalDet2003PlotsModule() Destructor"<<endl
00057                                <<"dir name "<<fDirName<<endl;
00058 
00059    fNumObj--;
00060    if(fNumObj==0){
00061       if(fOut){
00062          if(fOut->IsOpen()){
00063 //       fOut->cd();
00064             MSG("CalDetDST",Msg::kDebug)<<"cd'd to "<<fFileName<<endl;
00065 //       fOut->ls();
00066             fOut->Write();
00067             MSG("CalDetDST",Msg::kDebug)<<"wrote file "<<fFileName<<endl;
00068             fOut->Close();
00069             MSG("CalDetDST",Msg::kDebug)<<"closed file "<<fFileName<<endl;
00070             delete fOut;
00071             MSG("CalDetDST",Msg::kDebug)<<"deleted file "<<fFileName<<endl;
00072             fOut=0; 
00073          }
00074       }
00075    }       
00076    //  MSG("CalDetDST",Msg::kDebug)<<"~CalDet2003PlotsModule: printing fDir: "<<fDir<<endl;
00077    //fDir->Print();
00078    delete fDir;
00079    fDir=0;
00080 
00081 
00082    delete el_snarls;
00083 }
00084 
00085 //......................................................................
00086 
00087 void CalDet2003PlotsModule::BeginJob()
00088 {
00089 //======================================================================
00090 // opens a file to write histograms to
00091 // creates some histograms
00092 //======================================================================
00093    
00094    MSG("CalDetDST", Msg::kDebug)<<"CalDet2003PlotsModule::BeginJob()"<<endl;
00095 /*   
00096    if(!fOut){
00097       fOut = new TFile("upm.root", "recreate");
00098    }
00099 */ 
00100 // force histograms into the file
00101    Bool_t old_dir_stat = TH1::AddDirectoryStatus();
00102    TH1::AddDirectory(kTRUE);
00103    
00104    gROOT->cd();
00105    fDir = new TDirectory(fDirName.c_str(), fDirName.c_str());
00106    fDir->cd();
00107    
00108 // define histograms
00109 //tof histograms
00110    h_tdc0 = new TH1F("h_tdc0","TDC from TOF 0",4097,-0.5,4096.5);
00111    h_tdc1 = new TH1F("h_tdc1","TDC from TOF 1",4097,-0.5,4096.5);
00112    h_tdc2 = new TH1F("h_tdc2","TDC from TOF 2",4097,-0.5,4096.5);
00113    h_tdcdiff = new TH1F("h_tdcdiff","TDC2-TDC0",8193,-4096.5,4096.5);
00114    
00115 //cerenkov histograms
00116    h_cera0 = new TH1F("h_cera0","CER0 ADC",500,0,5000);
00117    h_cera1 = new TH1F("h_cera1","CER1 ADC",500,0,5000);
00118    h_cera2 = new TH1F("h_cera2","CER2 ADC",500,0,5000);
00119    
00120    h_cert0 = new TH1F("h_cert0","CER0 Time",500,-250,250);
00121    h_cert1 = new TH1F("h_cert1","CER1 Time",500,-250,250);
00122    h_cert2 = new TH1F("h_cert2","CER2 Time",500,-250,250);
00123    
00124 //hittime histograms
00125    h_hittime = new TH1F("h_hittime","Hit Times",801,-400.5,400.5);
00126    h_hittimenear = new TH1F("h_hittimenear","Hit Times, Near",801,-400.5,400.5);
00127    h_hittimefar = new TH1F("h_hittimefar","Hit Times, Far",801,-400.5,400.5);
00128 
00129    h_pid = new TH1F("h_pid","Particle Type",17,-0.5,16.5);
00130    h_nov = new TH1F("h_nov","Overlappers",2,0,2);
00131    h_inct = new TH1F("h_inct","Cerenkov in time",2,0,2);
00132    h_olchi2 = new TH1F("h_olchi2","Overlap Chi2",500,0,20);
00133    h_beamp = new TH1F("h_beamp","Beam Momentum",100,0,10);
00134    
00135 //number of hits histograms
00136    h_nhits = new TH1F("h_nhits","Total Number of Hits",2881,-.5,2880.5);
00137    h_nhitsfarnear = new TH2F("h_nhitsfarnear","Total Number of Hits Near vs. Far",
00138                              2881,-.5,2880.5,2881,-.5,2880.5);
00139    h_nhitsfar = 0; //comes from projection of above
00140    h_nhitsnear = 0; //comes from projection of above
00141       
00142 //number of hit strips histograms
00143    h_nhitstrips = new TH1F("h_nhitstrips","Total Number of Hit Strips",
00144                            201,-.5,200.5);
00145    h_nhitstripsfarnear = new TH2F("h_nhitstripsfarnear",
00146                                   "Total Number of Hit Strips Near vs. Far",
00147                                   201,-.5,200.5,201,-.5,200.5);
00148    h_nhitstripsfar = 0; //comes from projection of above
00149    h_nhitstripsnear = 0; //comes from projection of above
00150 
00151 //number of hit planes histograms
00152    h_nhitplanes = new TH1F("h_nhitplanes","Total Number of Hit Planes",
00153                            61,-.5,60.5);
00154    h_nhitplanesfarnear = new TH2F("h_nhitplanesfarnear",
00155                                   "Total Number of Hit Planes Near vs. Far",
00156                                   61,-.5,60.5,61,-.5,60.5);
00157    h_nhitplanesfar = 0; //comes from projection of above
00158    h_nhitplanesnear = 0; //comes from projection of above
00159       
00160 // strip vs. plane histograms
00161    h_svp = new TH2F("h_svp","Strip vs. Plane, both sides",60,0,60,24,0,24);
00162    h_svpfar = new TH2F("h_svpfar","Strip vs. Plane, Far",60,0,60,24,0,24);
00163    h_svpnear = new TH2F("h_svpnear","Strip vs. Plane, Near",60,0,60,24,0,24);
00164 
00165 // weighted strip vs. plane histograms
00166    h_wsvp = new TH2F("h_wsvp","Weighted Strip vs. Plane, both sides",
00167                      60,0,60,24,0,24);
00168    h_wsvpfar = new TH2F("h_wsvpfar","Weighted Strip vs. Plane, Far",
00169                         60,0,60,24,0,24);
00170    h_wsvpnear = new TH2F("h_wsvpnear","Weighted Strip vs. Plane, Near",
00171                          60,0,60,24,0,24);
00172 
00173 // total mip histograms
00174    h_tmip = new TH1F("h_tmip","Total MIP",140,0,700);
00175    h_tmipfarnear = new TH2F("h_tmipfarnear","Total MIP, Near vs. Far",
00176                             175,0,350,175,0,350);
00177    h_tmipfar = 0; //projection of above
00178    h_tmipnear = 0; //projection of above
00179 
00180 //mip vs. plane distributions
00181    h_mipvplane = new TH2F("h_mipvplane","MIP vs. Plane, both sides",
00182                           60,0,60,50,0,100);
00183    h_mipvplanefar = new TH2F("h_mipvplanefar","MIP vs. Plane, Far",
00184                           60,0,60,50,0,100);
00185    h_mipvplanenear = new TH2F("h_mipvplanenear","MIP vs. Plane, Near",
00186                           60,0,60,50,0,100);
00187 
00188    h_mipvplane_pfx = 0; //profile of above
00189    h_mipvplanefar_pfx = 0; //profile of above
00190    h_mipvplanenear_pfx = 0; //profile of above
00191    
00192    
00193    h_mipvplanediff = new TH2F("h_mipvplanediff","MIP (Far-Near) vs. Plane",
00194                               60,0,60,500,-50,50);
00195    h_mipvplaneratio = new TH2F("h_mipvplaneratio","Ratio MIP (Near/Far) vs. Plane",
00196                                60,0,60,100,-1,1);
00197 
00198    h_mipvplanediff_pfx = 0; //profile of above
00199    h_mipvplaneratio_pfx = 0; //profile of above
00200 
00201 //hit adc histograms
00202    h_hitadc = new TH1F("h_hitadc","Hit ADC",170,0,17000);
00203    h_hitadcfarnear = new TH2F("h_hitadcfarnear","Hit ADC Near vs. Far",
00204                               170,0,17000,170,0,17000);
00205    h_hitadcfar = 0; //projection of above
00206    h_hitadcnear = 0; //projection of above
00207       
00208    h_fartime = new TH1F("h_fartime","Far hit time-toftime", 1000,-500,500);
00209    h_neartime = new TH1F("h_neartime","Near hit time-toftime", 1000,-500,500);
00210 
00211    h_triggertime = new TH1F("h_triggertime","Trigger time",
00212                                9000,0,1800);
00213    h_triggertimenofar = new TH1F("h_triggertimenofar","Trigger time No Far",
00214                                9000,0,1800);
00215    h_triggertimenonear = new TH1F("h_triggertimenonear","Trigger time No Near",
00216                                9000,0,1800);
00217 
00218    // a couple of event lists
00219 
00220    el_snarls=new TEventList("snarls", "Offline snarl number");
00221    el_snarls->SetDirectory(0);
00222 
00223 //   MSG("CalDetDST",Msg::kDebug)<<"gROOT::ls BeginJob"<<endl;
00224 //   gROOT->ls();
00225 //   MSG("CalDetDST",Msg::kDebug)<<"fDir::ls BeginJob"<<endl;
00226 //   fDir->ls();
00227 // Last thing:
00228 // switch back to old add dir status so as not to hose user
00229 TH1::AddDirectory(old_dir_stat);
00230 }
00231 
00232 
00233 //......................................................................
00234 
00235 void CalDet2003PlotsModule::Config(const Registry& r)
00236 {
00237 //======================================================================
00238 // Configure the module given the Registry r
00239 //======================================================================
00240   const char*    t;
00241   if (r.Get("DirName",t)) { fDirName = t; }
00242 
00243   const char *f;
00244   if(r.Get("OutFilePath",f)) { fFilePath = f; }
00245 
00246   if(r.Get("FileName",f)){ fFileName = f;}
00247 }
00248 
00249 //......................................................................
00250 
00251 const Registry& CalDet2003PlotsModule::DefaultConfig() const
00252 {
00253 //======================================================================
00254 // Supply the default configuration for the module
00255 //======================================================================
00256   static Registry r; // Default configuration for module
00257 
00258   // Set name of config
00259   std::string name = this->JobCModule::GetName();
00260   name += ".config.default";
00261   r.SetName(name.c_str());
00262 
00263   // Set values in configuration
00264   r.UnLockValues();
00265 
00266   const char* s = "all";
00267   r.Set("DirName", s);
00268   
00269   const char* f = "./";
00270   r.Set("OutFilePath", f);
00271 
00272   const char *n = "CDPlots-default.root";
00273   r.Set("FileName",n);
00274   r.LockValues();
00275 
00276   return r;
00277 }
00278 
00279  
00280 //......................................................................
00281 
00282 void CalDet2003PlotsModule::EndJob()
00283 {
00284 //======================================================================
00285 // write and close file
00286 //======================================================================
00287    MSG("CalDetDST",Msg::kDebug)<<"in CalDet2003PlotsModule() EndJob()"<<endl
00288                                <<"dir name "<<fDirName<<endl;
00289 
00290    if(fFileName==""){
00291       MSG("CalDetDST",Msg::kError)<<"FileName not set.  Can Not write file."<<endl;
00292       return;
00293    }
00294       
00295 
00296 
00297    if(!fOut){
00298       MSG("CalDetDST",Msg::kDebug)<<"Making output file "<<fFileName<<endl;
00299       string fullfn = fFilePath+fFileName;
00300       fOut = new TFile(fullfn.c_str(), "recreate");
00301    }
00302 
00303 
00304    fDir->cd();
00305 
00306    MSG("CalDetDST",Msg::kDebug)<<"EndJob() cd'd"<<endl;
00307 
00308 
00309 //make projection and profile histograms
00310    h_nhitsfar = h_nhitsfarnear->ProjectionX(); 
00311    h_nhitsfar->SetNameTitle("h_nhitsfar","Number of Hits, Far");
00312    h_nhitsnear = h_nhitsfarnear->ProjectionY(); 
00313    h_nhitsnear->SetNameTitle("h_nhitsnear","Number of Hits, Near");
00314 
00315    MSG("CalDetDST",Msg::kDebug)<<"EndJob() made nhits proj"<<endl;
00316 
00317    h_nhitstripsfar = h_nhitstripsfarnear->ProjectionX();
00318    h_nhitstripsfar->SetNameTitle("h_nhitstripsfar","Number of Hit Strips, Far");
00319 
00320    h_nhitstripsnear = h_nhitstripsfarnear->ProjectionY(); 
00321    h_nhitstripsnear->SetNameTitle("h_nhitstripsnear","Number of Hit Strips, Near");
00322 
00323    MSG("CalDetDST",Msg::kDebug)<<"EndJob() made nhitstrips proj"<<endl;
00324 
00325    h_nhitplanesfar = h_nhitplanesfarnear->ProjectionX();
00326    h_nhitplanesfar->SetNameTitle("h_nhitplanesfar","Number of Hit Planes, Far");
00327 
00328    h_nhitplanesnear = h_nhitplanesfarnear->ProjectionY(); 
00329    h_nhitplanesnear->SetNameTitle("h_nhitplanesnear","Number of Hit Planes, Near");
00330 
00331    MSG("CalDetDST",Msg::kDebug)<<"EndJob() made nhitplanes proj"<<endl;
00332 
00333    h_tmipfar = h_tmipfarnear->ProjectionX();
00334    h_tmipfar->SetNameTitle("h_tmipfar","Total MIP, Far");
00335 
00336    h_tmipnear = h_tmipfarnear->ProjectionY();
00337    h_tmipnear->SetNameTitle("h_tmipnear","Total MIP, Near");
00338 
00339    MSG("CalDetDST",Msg::kDebug)<<"EndJob() made tmip proj"<<endl;
00340 
00341    h_mipvplane_pfx = h_mipvplane->ProfileX();
00342    h_mipvplane_pfx->SetNameTitle("h_mipvplane_pfx","MIP vs. Plane, Profile");
00343 
00344    h_mipvplanefar_pfx = h_mipvplanefar->ProfileX();
00345    h_mipvplanefar_pfx->SetNameTitle("h_mipvplanefar_pfx",
00346                                     "MIP vs. Plane Profile, Far");
00347 
00348    h_mipvplanenear_pfx = h_mipvplanenear->ProfileX();
00349    h_mipvplanenear_pfx->SetNameTitle("h_mipvplanenear_pfx",
00350                                     "MIP vs. Plane Profile, Near");
00351    
00352    h_mipvplanediff_pfx = h_mipvplanediff->ProfileX();
00353    h_mipvplanediff_pfx->SetNameTitle("h_mipvplanediff_pfx",
00354                                      "MIP vs. Plane diff Far-Near, Profile");
00355 
00356    h_mipvplaneratio_pfx = h_mipvplaneratio->ProfileX();
00357    h_mipvplaneratio_pfx->SetNameTitle("h_mipvplaneratio_pfx",
00358                                       "MIP vs. Plane Near/Far, Profile");
00359 
00360    MSG("CalDetDST",Msg::kDebug)<<"EndJob() made profs"<<endl;
00361 
00362    h_hitadcfar = h_hitadcfarnear->ProjectionX();
00363    h_hitadcfar->SetNameTitle("h_hitadcfar","Hit ADC, Far");
00364 
00365    h_hitadcnear = h_hitadcfarnear->ProjectionY();
00366    h_hitadcnear->SetNameTitle("h_hitadcnear","Hit ADC, Near");
00367 
00368    MSG("CalDetDST",Msg::kDebug)<<"EndJob() made adc proj"<<endl;
00369 
00370    fOut->cd();
00371    TDirectory *newdir=new TDirectory(fDirName.c_str(),fDirName.c_str());
00372    newdir->cd();
00373 //   MSG("CalDetDST",Msg::kDebug)<<"gROOT::ls"<<endl;
00374 //   gROOT->ls();
00375 //   MSG("CalDetDST",Msg::kDebug)<<"fDir::ls"<<endl;
00376 //   fDir->ls();
00377    fDir->GetList()->Write();
00378 
00379    // jam it for the stupid event list
00380    el_snarls->Write();
00381 
00382 
00383 //   newdir->ls();
00384 //   fDir->ls();
00385 //   fOut->Append(fDir);
00386    
00387 //   fDir->Write();
00388 /*
00389    MSG("CalDetDST",Msg::kDebug)<<"Appeneded directory "
00390                                <<fDirName<<" to "<<fFileName<<endl;
00391    MSG("CalDetDST",Msg::kDebug)<<"Directory "<<fDirName
00392                                <<" IsWritable? "<<fDir->IsWritable()<<endl;
00393    fDir->SetWritable();
00394    MSG("CalDetDST",Msg::kDebug)<<"Directory "<<fDirName
00395                                <<" IsWritable? "<<fDir->IsWritable()<<endl;
00396 */
00397 }
00398 
00399 //......................................................................
00400 
00401 JobCResult CalDet2003PlotsModule::Ana(const MomNavigator* mom)
00402 {
00403 //======================================================================
00404 // does the plotting
00405 //======================================================================
00406 
00407 if(fcount%1000==0){
00408    MSG("CalDetDST",Msg::kInfo)<<"On Event "<<fcount<<endl;
00409    // MAK: Feb 15, 2005
00410    // the following should be commented out in the CVS version
00411    //   system("date"); // list date
00412    //   system("tokens"); // list afs tokens
00413 }
00414 fcount++;
00415 
00416 const UberRecord* ur = 
00417     dynamic_cast<const UberRecord*>(mom->GetFragment("UberRecord"));
00418 
00419 if(!ur)   return JobCResult::kAOK; // don't care if there isn't a record!
00420 
00421 /*
00422 if(fFileName=="CDPlots-default"){
00423    MSG("CalDetDST",Msg::kDebug)<<"Trying to set filename"<<endl;
00424    const Int_t runnum = (ur->GetHeader()).GetRunNo();
00425    const Int_t subrunnum = (ur->GetHeader()).GetSubRunNo();
00426    char fn[100];
00427    sprintf(fn,"CDPlots-%d-%d.root",runnum,subrunnum);
00428    fFileName = fn;
00429    MSG("CalDetDST",Msg::kDebug)<<"Filename will be "<<fFileName<<endl;
00430 }
00431 */
00432 
00433 // fill event list
00434 el_snarls->Enter(ur->snarlno);
00435 
00436 //fill tdc hists
00437 h_tdc0->Fill(ur->toftdc[0]);
00438 h_tdc1->Fill(ur->toftdc[1]);
00439 h_tdc2->Fill(ur->toftdc[2]);
00440 h_tdcdiff->Fill(ur->toftdc[2]-ur->toftdc[0]);
00441 
00442 //fill cer hists
00443 h_cera0->Fill(ur->ceradc[0]);
00444 h_cera1->Fill(ur->ceradc[1]);
00445 h_cera2->Fill(ur->ceradc[2]);
00446 if(ur->ceradc[0]>0){
00447    h_cert0->Fill(ur->certime[0]-ur->toftime);
00448 }
00449 if(ur->ceradc[1]>0){
00450    h_cert1->Fill(ur->certime[1]-ur->toftime);
00451 }
00452 if(ur->ceradc[2]>0){
00453    h_cert2->Fill(ur->certime[2]-ur->toftime);
00454 }
00455 
00456 h_pid->Fill(ur->cpid.pid);
00457 h_nov->Fill(ur->cpid.nov);
00458 h_inct->Fill(ur->cpid.inct);
00459 h_olchi2->Fill(ur->cpid.olchi2);
00460 h_beamp->Fill(ur->GetHeader().GetBeamMomentum());
00461 
00462 const TClonesArray* hitlist = ur->GetHitList();
00463 int prevplane = -1;
00464 float planemip = 0.;
00465 float planemipfar = 0.;
00466 float planemipnear = 0.;
00467 float tmipfar = 0.;
00468 float tmipnear = 0.;
00469 int nhitsfar = 0;
00470 int nhitsnear = 0;
00471 int nhitstripsnear = 0;
00472 int nhitstripsfar = 0;
00473 int nhitplanesnear = 0;
00474 int nhitplanesfar = 0;
00475 Bool_t planehitnear = kFALSE;
00476 Bool_t planehitfar = kFALSE;
00477 for(int i=0; i<ur->nhitstrips; i++){
00478     const UberHit* uh = static_cast<const UberHit*>(hitlist->At(i));
00479     if(!uh) continue;
00480     
00481     //should never fail these by construction of hitlist, but . . .
00482     const int plane=uh->GetPlane();
00483     if((plane<0)||(plane>59)) continue;
00484     const int strip=uh->GetStrip();
00485     if((strip<0)||(strip>23)) continue;
00486 
00487     if(prevplane!=uh->GetPlane()&&prevplane!=-1){
00488        h_mipvplane->Fill(prevplane,planemip);
00489        h_mipvplanefar->Fill(prevplane,planemipfar);
00490        h_mipvplanenear->Fill(prevplane,planemipnear);
00491        h_mipvplanediff->Fill(prevplane,(planemipfar-planemipnear));
00492        if(planemipfar+planemipnear!=0){
00493           h_mipvplaneratio->Fill(prevplane,
00494                                  (planemipfar-planemipnear)/((planemipnear+planemipfar)/2.));
00495        }     
00496        if(planehitnear){
00497           nhitplanesnear++;
00498        }
00499        if(planehitfar){
00500           nhitplanesfar++;
00501        }
00502        planemip=0.;
00503        planemipfar=0.;
00504        planemipnear=0.;
00505        planehitnear = kFALSE;
00506        planehitfar = kFALSE;
00507     }
00508     prevplane = uh->GetPlane();
00509     planemip+=(uh->GetPosMIP()+uh->GetNegMIP());
00510     planemipfar+=uh->GetNegMIP();
00511     planemipnear+=uh->GetPosMIP();
00512     if(uh->GetPlane()!=0){
00513        tmipfar+=uh->GetNegMIP();
00514        tmipnear+=uh->GetPosMIP();
00515     }
00516     h_hitadc->Fill(uh->GetNegADC());
00517     h_hitadc->Fill(uh->GetPosADC());
00518     h_hitadcfarnear->Fill(uh->GetNegADC(),uh->GetPosADC());
00519     h_svp->Fill(uh->GetPlane(),uh->GetStrip());
00520     h_wsvp->Fill(uh->GetPlane(),uh->GetStrip(),uh->GetPosMIP()+uh->GetNegMIP());
00521 
00522     if(uh->GetPosADC()>0){
00523        h_hittime->Fill(uh->GetPosTime()-ur->toftime);
00524        h_hittimenear->Fill(uh->GetPosTime()-ur->toftime);
00525        h_svpnear->Fill(uh->GetPlane(),uh->GetStrip());
00526        h_wsvpnear->Fill(uh->GetPlane(),uh->GetStrip(),uh->GetPosMIP());
00527        if(uh->GetPlane()!=0){
00528           h_neartime->Fill(uh->GetPosTime()-ur->toftime);
00529        }
00530        nhitsnear++;
00531        nhitstripsnear++;
00532        planehitnear=kTRUE;
00533     }
00534     if(uh->GetNegADC()>0){
00535        h_hittime->Fill(uh->GetNegTime()-ur->toftime);
00536        h_hittimefar->Fill(uh->GetNegTime()-ur->toftime);
00537        h_svpfar->Fill(uh->GetPlane(),uh->GetStrip());
00538        h_wsvpfar->Fill(uh->GetPlane(),uh->GetStrip(),uh->GetNegMIP());
00539        if(uh->GetPlane()!=0){
00540           h_fartime->Fill(uh->GetNegTime()-ur->toftime);
00541        }
00542        nhitsfar++;
00543        nhitstripsfar++;
00544        planehitfar=kTRUE;
00545     }
00546 }
00547 //fill nhits hists
00548 h_nhits->Fill(ur->nhits);
00549 h_nhitsfarnear->Fill(nhitsfar,nhitsnear);
00550 
00551 //fill nhitstrips hists
00552 h_nhitstrips->Fill(ur->nhitstrips);
00553 h_nhitstripsfarnear->Fill(nhitstripsfar,nhitstripsnear);
00554 
00555 //fill nhitplanes hists
00556 h_nhitplanes->Fill(ur->nhitplanes);
00557 h_nhitplanesfarnear->Fill(nhitplanesfar,nhitplanesnear);
00558 
00559 //fill total mip hists
00560 h_tmip->Fill(ur->totmip);
00561 h_tmipfarnear->Fill(tmipfar,tmipnear);
00562 
00563 h_triggertime->Fill(ur->triggertime);
00564 if(tmipfar==0){
00565    h_triggertimenofar->Fill(ur->triggertime);
00566 }
00567 if(tmipnear==0){
00568    h_triggertimenonear->Fill(ur->triggertime);
00569 }
00570 
00571   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00572 }
00573 
00574 //......................................................................
00575 
00576 void CalDet2003PlotsModule::Help()
00577 {
00578 //======================================================================
00579 // I should print something here....
00580 //======================================================================
00581 }
00582 
00584 
00585 
00586 int CalDet2003PlotsModule::PlaneTrigger(float* qvec, int len)
00587     {
00588     // qvec= array of charge,pes,mips by plane
00589     // len= the length of qvec
00590     const float thresh = 0.0; // threshold to count a plane
00591     int trig=0;
00592     int lown=0; // n-1 for the lowest n to try (eg lown=1 implies 2/3)
00593     for(int i=0; i<len; i++){
00594         // form a window with j+1 elements
00595         // j=n in n/n+1
00596         for(int j=6; j>lown; j--){
00597             int count=0;
00598             // loop over the window, careful not to go overboard
00599             for(int k=i; (k<=i+j && k<len); k++){
00600                 if(qvec[k]>thresh) count++;
00601                 }
00602             // don't assign if we already have a more restrictive trigger
00603             if(count>=j && count>trig) { 
00604                 trig=j; // assign the trigger
00605                 // bump the window so we only look for more restrictive triggers 
00606                 lown=j;
00607                 }
00608             }
00609         }
00610     return trig;
00611     }

Generated on Mon Feb 15 11:06:26 2010 for loon by  doxygen 1.3.9.1