00001 #include "TME_SiArmTDiff.h"
00002 #include "RegisterModule.inc"
00003 #include "TGlobalData.h"
00004 #include "TSetupData.h"
00005 #include "ModulesOptions.h"
00006 #include "definitions.h"
00007 #include "TMuonEvent.h"
00008 #include "debug_tools.h"
00009
00010 #include <TH1F.h>
00011 #include <TH2F.h>
00012 #include <TCanvas.h>
00013 #include <TApplication.h>
00014
00015 #include <iostream>
00016 using std::cout;
00017 using std::endl;
00018
00019 extern MuonEventList gMuonEvents;
00020
00021 TME_SiArmTDiff::TME_SiArmTDiff(modules::options* opts):
00022 BaseModule("TME_SiArmTDiff",opts),fNullCount(0),fTdpCount(0){
00023 }
00024
00025 TME_SiArmTDiff::~TME_SiArmTDiff(){
00026 }
00027
00028 int TME_SiArmTDiff::BeforeFirstEntry(TGlobalData* gData,const TSetupData *setup){
00029 using namespace IDs;
00030 fSiL1.push_back(IDs::channel (kSiL1_1 , kNotApplicable ));
00031 fSiL1.push_back(IDs::channel (kSiL1_2 , kNotApplicable ));
00032 fSiL1.push_back(IDs::channel (kSiL1_3 , kNotApplicable ));
00033 fSiL1.push_back(IDs::channel (kSiL1_4 , kNotApplicable ));
00034 fSiL2 = new IDs::channel (kSiL2 , kNotApplicable );
00035 fSiR1.push_back(IDs::channel (kSiR1_1 , kNotApplicable ));
00036 fSiR1.push_back(IDs::channel (kSiR1_2 , kNotApplicable ));
00037 fSiR1.push_back(IDs::channel (kSiR1_3 , kNotApplicable ));
00038 fSiR1.push_back(IDs::channel (kSiR1_4 , kNotApplicable ));
00039 fSiR2 = new IDs::channel (kSiR2 , kNotApplicable );
00040
00041 fSiLTDiffs = new TH1F("hSiLTDiffs", "TDiffs Between thick and thin SiL", 5000, -5e3,5e3);
00042 fSiLTDiffs->SetXTitle("t_thick - t_thin (ns)");
00043
00044 fSiRTDiffs = new TH1F("hSiRTDiffs", "TDiffs Between thick and thin SiR", 5000, -5e3,5e3);
00045 fSiRTDiffs->SetXTitle("t_thick - t_thin (ns)");
00046
00047 return 0;
00048 }
00049
00050 int TME_SiArmTDiff::ProcessEntry(TGlobalData* gData,const TSetupData *setup){
00051
00052 for(MuonEventList::const_iterator i_tme=gMuonEvents.begin();
00053 i_tme!=gMuonEvents.end(); ++i_tme){
00054
00055
00056 if ( (*i_tme)->HasMuonPileup()) {
00057 continue;
00058 }
00059
00060 double tme_time= (*i_tme)->GetTime();
00061
00062
00063 for(DetectorList::const_iterator i_det=fSiL1.begin();
00064 i_det!=fSiL1.end(); ++i_det){
00065
00066 int SiL1_source_index=(*i_tme)->GetSourceIndex(*i_det);
00067 while(SiL1_source_index>-1){
00068 const IDs::source& SiL1_source=(*i_tme)->GetSource(SiL1_source_index);
00069
00070 int n_SiL1 = (*i_tme)->NumPulses(SiL1_source);
00071
00072 for(int i=0; i<n_SiL1; ++i){
00073 const TDetectorPulse* tdp=(*i_tme)->GetPulse(SiL1_source,i);
00074 double thin_time = tdp->GetTime();
00075
00076
00077 int SiL2_source_index=(*i_tme)->GetSourceIndex(*fSiL2);
00078 while (SiL2_source_index>-1) {
00079 const IDs::source& SiL2_source=(*i_tme)->GetSource(SiL2_source_index);
00080 int n_SiL2 = (*i_tme)->NumPulses(SiL2_source);
00081 for (int j=0; j<n_SiL2; ++j) {
00082 const TDetectorPulse* tdp_SiL2=(*i_tme)->GetPulse(SiL2_source,j);
00083 double thick_time = tdp_SiL2->GetTime();
00084 fSiLTDiffs->Fill(thick_time - thin_time);
00085 }
00086 SiL2_source_index=(*i_tme)->GetSourceIndex(*fSiL2,SiL2_source_index+1);
00087 }
00088 }
00089 SiL1_source_index=(*i_tme)->GetSourceIndex(*i_det,SiL1_source_index+1);
00090 }
00091 }
00092
00093
00094 for(DetectorList::const_iterator i_det=fSiR1.begin();
00095 i_det!=fSiR1.end(); ++i_det){
00096
00097 int SiR1_source_index=(*i_tme)->GetSourceIndex(*i_det);
00098 while(SiR1_source_index>-1){
00099 const IDs::source& SiR1_source=(*i_tme)->GetSource(SiR1_source_index);
00100
00101 int n_SiR1 = (*i_tme)->NumPulses(SiR1_source);
00102
00103 for(int i=0; i<n_SiR1; ++i){
00104 const TDetectorPulse* tdp=(*i_tme)->GetPulse(SiR1_source,i);
00105 double thin_time = tdp->GetTime();
00106
00107
00108 int SiR2_source_index=(*i_tme)->GetSourceIndex(*fSiR2);
00109 while (SiR2_source_index>-1) {
00110 const IDs::source& SiR2_source=(*i_tme)->GetSource(SiR2_source_index);
00111 int n_SiR2 = (*i_tme)->NumPulses(SiR2_source);
00112 for (int j=0; j<n_SiR2; ++j) {
00113 const TDetectorPulse* tdp_SiR2=(*i_tme)->GetPulse(SiR2_source,j);
00114 double thick_time = tdp_SiR2->GetTime();
00115 fSiRTDiffs->Fill(thick_time - thin_time);
00116 }
00117 SiR2_source_index=(*i_tme)->GetSourceIndex(*fSiR2,SiR2_source_index+1);
00118 }
00119 }
00120 SiR1_source_index=(*i_tme)->GetSourceIndex(*i_det,SiR1_source_index+1);
00121 }
00122 }
00123 }
00124
00125 return 0;
00126 }
00127
00128 int TME_SiArmTDiff::AfterLastEntry(TGlobalData* gData,const TSetupData *setup){
00129
00130 return 0;
00131 }
00132
00133 ALCAP_REGISTER_MODULE(TME_SiArmTDiff);