00001 #include "NueAna/ParticlePID/ParticleFinder/ParticleBeamMonAna.h"
00002
00003 #include "Conventions/BeamType.h"
00004 #include "Conventions/Detector.h"
00005 #include "Conventions/ReleaseType.h"
00006
00007 #include "BeamDataUtil/BDSpillAccessor.h"
00008 #include "BeamDataUtil/BeamMonSpill.h"
00009 #include "BeamDataUtil/BMSpillAna.h"
00010 #include "SpillTiming/SpillTimeFinder.h"
00011
00012
00013 #include "DcsUser/CoilTools.h"
00014 #include "TSystem.h"
00015
00016 #include "DataUtil/GetTempTags.h"
00017
00018
00019 CVSID("$Id: ParticleBeamMonAna.cxx,v 1.2 2009/06/23 18:19:15 rhatcher Exp $");
00020
00021
00022
00023 ParticleBeamMonAna::ParticleBeamMonAna()
00024 {
00025 fname="";
00026 }
00027
00028 ParticleBeamMonAna::~ParticleBeamMonAna()
00029 {}
00030
00031
00032 void ParticleBeamMonAna::ana(ParticleObjectHolder * poh, ParticleBeamMon * e)
00033 {
00034
00035 BDSpillAccessor& sa = BDSpillAccessor::Get();
00036 SpillTimeFinder &stf = SpillTimeFinder::Instance();
00037
00038
00039
00040 BeamType::BeamType_t beamtype;
00041 int zbeamtype;
00042
00043 BMSpillAna fBMSpillAna;
00044
00045
00046
00047
00048 VldContext evt_vldc = poh->GetHeader().GetVldContext();
00049
00050
00051
00052 std::string file = DataUtil::GetTempTagString(poh, "file");
00053 std::string filename = gSystem->BaseName(file.c_str());
00054
00055
00056
00057 if(evt_vldc.GetSimFlag() == SimFlag::kData)
00058 beamtype = DetermineBeamType(evt_vldc);
00059 else
00060 beamtype = DetermineBeamType(filename);
00061
00062
00063 if(beamtype==BeamType::kUnknown)
00064 {
00065 beamtype = DetermineBeamType(fname);
00066 }
00067
00068 e->beamtype=beamtype;
00069
00070
00071
00072 if (evt_vldc.GetSimFlag() != SimFlag::kData)
00073 return;
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 const BeamMonSpill* bms = sa.LoadSpill(evt_vldc.GetTimeStamp());
00084 VldTimeStamp bms_vts;
00085 if (!bms) {
00086 MSG("NueParticleBeamMon",Msg::kError) << "No ParticleBeamMonSpill found for " << evt_vldc << endl;
00087 bms_vts = VldTimeStamp::GetEOT();
00088 }else{
00089 bms_vts = bms->SpillTime();
00090 }
00091
00092
00093
00094
00095
00096 zbeamtype = BeamType::ToZarko(beamtype);
00097
00098
00099
00100 fBMSpillAna.SetSpill(*bms);
00101
00102
00103 fBMSpillAna.SetSnarlTime(evt_vldc.GetTimeStamp());
00104
00105 e->ResetAll();
00106 if (fBMSpillAna.SelectSpill())
00107 e->goodParticleBeamMon=1;
00108 else
00109 e->goodParticleBeamMon=0;
00110
00111 e->tortgt = bms->fTortgt;
00112 e->trtgtd = bms->fTrtgtd;
00113 e->tor101 = bms->fTor101;
00114 e->tr101d = bms->fTr101d;
00115
00116
00117 e->bI = e->GetPot();
00118
00119 double xbpm,ybpm,xrms,yrms;
00120 bms->BpmAtTarget(xbpm,ybpm,xrms,yrms);
00121 e->hpos2 = xbpm;
00122 e->vpos2 = ybpm;
00123
00124 for (Int_t i=0;i<6;++i){
00125 e->batchposx[i]=bms->fTargBpmX[i];
00126 e->batchposy[i]=bms->fTargBpmY[i];
00127 e->batchint[i]=bms->fBpmInt[i];
00128 }
00129
00130 e->hpos1 = bms->fTargProfX;
00131 e->vpos1 = bms->fTargProfY;
00132
00133 e->hbw = bms->fProfWidX;
00134 e->vbw = bms->fProfWidY;
00135
00136 e->hornI = bms->fHornCur;
00137
00138 e->bmst_vts = bms->SpillTime();
00139
00140 VldTimeStamp vtsdif = e->bmst_vts-evt_vldc.GetTimeStamp();
00141 e->dt_bmst=vtsdif.GetSeconds();
00142
00143 e->stnd_vts=stf.GetTimeOfNearestSpill(evt_vldc);
00144 e->dt_stnd=stf.GetTimeToNearestSpill(evt_vldc);
00145
00146
00147
00148 bool goodCoil = CoilTools::IsOK(evt_vldc) && !CoilTools::IsReverse(evt_vldc);
00149 goodCoil = goodCoil || (evt_vldc.GetDetector()==Detector::kFar);
00150
00151
00152
00153 }
00154
00155
00156 BeamType::BeamType_t ParticleBeamMonAna::DetermineBeamType(VldContext vc){
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 int time = vc.GetTimeStamp().GetSec();
00173
00174
00175
00176 BeamType::BeamType_t beam = BeamType::kUnknown;
00177
00178 if(time >= 1107216000 && time < 1109539850) beam = BeamType::kL100z200i;
00179 if(time >= 1109540615 && time < 1109899325) beam = BeamType::kL250z200i;
00180 if(time >= 1109899938 && time < 1110239564) beam = BeamType::kL100z200i;
00181 if(time >= 1110323763 && time < 1111622400) beam = BeamType::kL000z200i;
00182 if(time >= 1114892377 && time < 1115927583) beam = BeamType::kL100z200i;
00183 if(time >= 1115937438 && time < 1116604821) beam = BeamType::kL250z200i;
00184 if(time >= 1116618256 && time < 1122659668) beam = BeamType::kL010z185i;
00185 if(time >= 1122659886 && time < 1122922688) beam = BeamType::kL010z170i;
00186 if(time >= 1122922890 && time < 1123112674) beam = BeamType::kL010z200i;
00187 if(time >= 1123112803 && time < 1139605423) beam = BeamType::kL010z185i;
00188 if(time >= 1139605543 && time < 1140022084) beam = BeamType::kL010z000i;
00189 if(time >= 1140026702 && time < 1140908579) beam = BeamType::kL010z185i;
00190
00191 if(time >= 1149180600 && time < 1150047780) beam = BeamType::kL150z200i;
00192 if(time >= 1150047780 && time < 1151690460) beam = BeamType::kL250z200i;
00193 if(time >= 1153956600 && time < 1155510000) beam = BeamType::kL250z200i;
00194 if(time >= 1158004800 && time < 1158019870) beam = BeamType::kL010z200i;
00195 if(time >= 1158019870 && time < 1161892800) beam = BeamType::kL010z185i;
00196 if(time >= 1161892800 && time < 1184351737) beam = BeamType::kL010z185i;
00197 if(time >= 1184351737 && time < 1184708040) beam = BeamType::kL010z000i;
00198
00199
00200 if(time >= 1184800000 ) beam = BeamType::kL010z185i;
00201
00202 return beam;
00203
00204 }
00205
00206 BeamType::BeamType_t ParticleBeamMonAna::DetermineBeamType(std::string file)
00207 {
00208
00209
00210 BeamType::BeamType_t beam = BeamType::kUnknown;
00211 if(file.find("L010185")!=string::npos){ beam=BeamType::kL010z185i; }
00212 if(file.find("L100200")!=string::npos){ beam=BeamType::kL100z200i; }
00213 if(file.find("L250200")!=string::npos){ beam=BeamType::kL250z200i; }
00214 if(file.find("L150200")!=string::npos){ beam=BeamType::kL150z200i; }
00215 if(file.find("L010200")!=string::npos){ beam=BeamType::kL010z200i; }
00216 if(file.find("L010170")!=string::npos){ beam=BeamType::kL010z170i; }
00217 if(file.find("L010000")!=string::npos){ beam=BeamType::kL010z000i; }
00218
00219 return beam;
00220 }
00221
00222
00223