00001 #include "PlotIntegralRatios.h"
00002 #include "RegisterModule.inc"
00003 #include "TGlobalData.h"
00004 #include "TSetupData.h"
00005 #include "ModulesOptions.h"
00006 #include "definitions.h"
00007 #include "TIntegralRatioAnalysedPulse.h"
00008
00009 #include <TH1F.h>
00010 #include <TH2F.h>
00011
00012 #include "debug_tools.h"
00013
00014 #include <iostream>
00015 using std::cout;
00016 using std::endl;
00017
00018 extern SourceAnalPulseMap gAnalysedPulseMap;
00019
00020 PlotIntegralRatios::PlotIntegralRatios(modules::options* opts):
00021 BaseModule("PlotIntegralRatios",opts),
00022 fSource(opts->GetString("source","SiR2-*#IntegralRatio#any")){
00023 fShiftFull=opts->GetDouble("shift_full",0);
00024 fShiftDifference=opts->GetDouble("shift_diff",0);
00025 }
00026
00027 PlotIntegralRatios::~PlotIntegralRatios(){
00028 }
00029
00030 int PlotIntegralRatios::BeforeFirstEntry(TGlobalData* gData,const TSetupData *setup){
00031 SourcePlots_t tmp;
00032 for(SourceAnalPulseMap::const_iterator i_source = gAnalysedPulseMap.begin();
00033 i_source!=gAnalysedPulseMap.end(); ++i_source){
00034 if(i_source->first.matches(fSource)){
00035 tmp.src=i_source->first;
00036
00037 tmp.ratio=new TH1F(
00038 modules::parser::ToCppValid("h"+tmp.src.str()+"_ratio").c_str(),
00039 ("Ratio of integrals for "+tmp.src.str()).c_str(),
00040 1000,0,1);
00041 tmp.ratio->SetXTitle("Ratio of total to tail integral");
00042
00043
00044 tmp.ratio_zoomed=new TH1F(
00045 modules::parser::ToCppValid("h"+tmp.src.str()+"_ratio_zoomed").c_str(),
00046 ("Zoomed Ratio of integrals for "+tmp.src.str()).c_str(),
00047 2000,0.1,0.25);
00048 tmp.ratio_zoomed->SetXTitle("Ratio of total to tail integral");
00049
00050
00051 tmp.full_integral=new TH1F(
00052 modules::parser::ToCppValid("h"+tmp.src.str()+"_integral").c_str(),
00053 ("Integrals for "+tmp.src.str()).c_str(),
00054 1000,0,-1);
00055 tmp.full_integral->SetXTitle("Total integral");
00056
00057
00058
00059
00060
00061
00062
00064
00065
00066
00067
00068
00069
00070
00072
00073 tmp.full_v_tail=new TH2F(
00074 modules::parser::ToCppValid("h"+tmp.src.str()+"_2d").c_str(),
00075 ("Integrals for "+tmp.src.str()).c_str(),
00076 400,0,-1,400,0,-1);
00077 tmp.full_v_tail->SetXTitle("tail integral");
00078 tmp.full_v_tail->SetYTitle("full integral");
00079
00080
00081 tmp.full_v_ratio=new TH2F(
00082 modules::parser::ToCppValid("h"+tmp.src.str()+"_integral_v_ratio").c_str(),
00083 ("Integral vs ratio of tail to integral for "+tmp.src.str()).c_str(),
00084 400,0,-3,400,0,-1);
00085 tmp.full_v_ratio->SetXTitle("ratio of tail to full integrals");
00086 tmp.full_v_ratio->SetYTitle("full integral");
00087
00088
00089 tmp.diff_v_ratio=new TH2F(
00090 modules::parser::ToCppValid("h"+tmp.src.str()+"_diff_v_ratio").c_str(),
00091 ("Difference vs ratio of tail to integral for "+tmp.src.str()).c_str(),
00092 400,0,-1,400,0,-1);
00093 tmp.diff_v_ratio->SetXTitle("ratio of tail to full integrals");
00094 tmp.diff_v_ratio->SetYTitle("differente of tail to full integrals");
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 fSourcesToPlot.push_back(tmp);
00135 }
00136 }
00137 if(fSourcesToPlot.empty()){
00138 cout<<"PlotIntegralRatios:BeforeFirstEntry: Error: No sources in gAnalysedPulseMap match "<<fSource<<endl;
00139 return 1;
00140 }
00141 return 0;
00142 }
00143
00144 int PlotIntegralRatios::ProcessEntry(TGlobalData* gData,const TSetupData *setup){
00145 TIntegralRatioAnalysedPulse* pulse=0;
00146 for(SourceList_t::const_iterator i_source=fSourcesToPlot.begin();
00147 i_source!=fSourcesToPlot.end(); ++i_source){
00148 const AnalysedPulseList& pulseList=gAnalysedPulseMap.at(i_source->src);
00149 for(AnalysedPulseList::const_iterator i_pulse=pulseList.begin();
00150 i_pulse!=pulseList.end(); ++i_pulse){
00151 if(i_pulse==pulseList.begin()){
00152 pulse=dynamic_cast<TIntegralRatioAnalysedPulse*>(*i_pulse);
00153 if(!pulse) {
00154 cout<<"PlotIntegralRatios::ProcessEntry: Error: Pulses in "<<i_source->src
00155 <<" aren't of type TIntegralRatioAnalysedPulse"<<endl;
00156 return 2;
00157 }
00158 }else{
00159 pulse=static_cast<TIntegralRatioAnalysedPulse*>(*i_pulse);
00160 }
00161 double ratio=pulse->GetIntegralRatio();
00162 double full=pulse->GetIntegral();
00163 double tail=pulse->GetIntegralSmall();
00164 double diff=full-2*tail-fShiftDifference;
00165 i_source->ratio->Fill(ratio);
00166 i_source->ratio_zoomed->Fill(ratio);
00167 i_source->full_integral->Fill(full);
00168 i_source->full_v_tail->Fill(tail,full);
00169 i_source->full_v_ratio->Fill(ratio,full);
00170 i_source->diff_v_ratio->Fill(ratio,diff);
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 }
00183
00184 }
00185 return 0;
00186 }
00187
00188 int PlotIntegralRatios::AfterLastEntry(TGlobalData* gData,const TSetupData *setup){
00189 return 0;
00190 }
00191
00192 ALCAP_REGISTER_MODULE(PlotIntegralRatios,source,shift_full, shift_diff);