9 #include "QDetChannelCollectionHandle.hh"
20 using namespace Diana;
24 fOutput = GetString(
"Output",
"jitter.txt");
29 Info(
"Tower is: %d", fTower);
32 Info(
"Reference Channel set to: %d", fRefCh);
36 fOFLabel = GetString(
"OFLabel",
"COF");
40 ev.
Require<QOFData>(fOFLabel,
"OFData");
56 const QOFData& ofd = ev.
Get<QOFData>(fOFLabel.c_str(),
"OFData");
57 const double& delay = ofd.GetDelay();
63 if(fDelays.find(
channel) != fDelays.end())
65 (fDelays.find(
channel)->second).Append(delay);
70 vecDelay.Append(delay);
78 GlobalHandle<QInt> dHandle(
"Dataset");
79 GlobalData().Get(
"",&dHandle,
"");
80 fDataset = dHandle.Get();
82 QDetChannelCollectionHandle dccHandle;
83 dccHandle.SetRun(fRun);
84 GlobalData().Get(
"",&dccHandle,
"");
85 const QDetChannelCollection& DCC = dccHandle.Get();
93 std::map<int,Diana::QVector > ::const_iterator mapIter;
94 for (mapIter=fDelays.begin(); mapIter!=fDelays.end(); ++mapIter)
96 int ch = mapIter->first;
97 Delays = mapIter->second;
102 double medianDelays = Delays.GetMedian();
103 double MADDelays = Delays.GetMedianAbsoluteDeviation();
105 for (
size_t j=0; j<Delays.Size(); j++)
107 if(Delays[j]>(medianDelays-3.*MADDelays) && Delays[j]<(medianDelays+3.*MADDelays))
109 Delays_red.Append(Delays[j]);
112 if(Delays_red.Size()>0) {
114 Delay = (Delays_red.Sum(Delays_red.Size(),0))/((
double) Delays_red.Size());
115 DelayRMS = (Delays_red.GetRMS(Delays_red.Size()))/(sqrt((
double) Delays_red.Size()));
117 fDelayRMS[ch]=DelayRMS;
122 std::cout << ch <<
" " << fDelay[ch] << std::endl;
127 const std::vector<int>& towers = DCC.GetTowers();
146 for(position = 1; position <= 4; position++)
148 fRefCh = FindChanWithPosInTowerFloor(position,fTower,1);
149 Info(
"Reference Channel set to: %d, Position: %d", fRefCh,position);
154 else if (fRefCh_IsSet) {
155 position = DCC.Get(fRefCh).fTd.fTdPos;
158 for (
size_t j=0; j<towers.size(); j++)
160 int tower = towers[j];
161 const std::vector<int>& floors = DCC.GetFloorsInTower(tower);
164 if (floors.size()>0) Info(
"Processing tower: %d",tower);
165 if (tower!=fTower) {Info(
"Skip tower %d",tower);
continue;}
166 else if (floors.size()==0) {Info(
"Tower %d has no floors",tower);
continue;}
168 int last_floor = floors[floors.size()-1];
171 for (
size_t i=0; i<floors.size(); i++)
173 int floor = floors[i];
174 if (floor == last_floor) fLastFloor =
true;
176 Info(
"Processing floor: %d, position: %d",floor,position);
177 position = ProcessFloor(position,tower,floor);
185 std::map<int,double>::const_iterator miter = fDelay.find(ch);
186 std::map<int,double>::const_iterator viter = fDelay.find(o_ch);
187 if (miter!=fDelay.end() && viter!=fDelay.end())
197 double jitterRMS = 0.;
198 std::map<int,double>::const_iterator miter = fDelayRMS.find(ch);
199 std::map<int,double>::const_iterator viter = fDelayRMS.find(o_ch);
200 if (miter!=fDelayRMS.end() && viter!=fDelayRMS.end())
203 jitterRMS = fDelayRMS[ch];
211 std::vector<int> chans;
213 QDetChannelCollectionHandle dccHandle;
214 dccHandle.SetRun(fRun);
215 GlobalData().Get(
"",&dccHandle,
"");
216 const QDetChannelCollection& DCC = dccHandle.Get();
218 const std::vector<int>& chTF = DCC.GetChannelsInTowerFloor(tower,floor);
220 for (
size_t i=0; i<chTF.size(); i++)
222 if (DCC.Get(chTF[i]).fTd.fTdPos == pos) chans.push_back(chTF[i]);
225 for (
size_t j=0; j<chans.size(); j++)
227 if (fGoodChannels.count(chans[j])>0)
230 std::cout <<
"good channels : " << chans[j] << std::endl;
251 jitterHandle.Set(jitterObj);
252 GlobalData().Set(&jitterHandle,fOutput);
263 double jitterRMS_rel;
265 for (
int i=0; i<ndet; i++)
267 pos[i] = start_pos+i;
268 if (pos[i]>4) pos[i]=pos[i]-4;
270 ch_pos[i] = FindChanWithPosInTowerFloor(pos[i],tower,floor);
271 jitter_rel = FindJitter(ch_pos[i],fRefCh);
272 jitterRMS_rel = FindJitterRMS(ch_pos[i],fRefCh);
273 if (jitter_rel!=0.) SaveJitter(ch_pos[i],jitter_rel,jitterRMS_rel);
#define REGISTER_MODULE(clazz)
Calculates mean value of OFDelay for all channels using pulser events (later used as a proxy for jitt...
int ProcessFloor(int pos, int tower, int floor)
ProcessFloor function.
void SaveJitter(int ch, double jitter, double jitter_error)
SaveJitter function.
void Init(Diana::QEvent &ev)
Init method.
int FindChanWithPosInTowerFloor(int pos, int tower, int floor)
FindPos function.
void Do(Diana::QEvent &ev)
Do method
double FindJitterRMS(int ch, int o_ch)
FindJitterRMS function.
double FindJitter(int ch, int o_ch)
FindJitter function.
void Require(const std::string &owner, const std::string &name) const
notify the QEvent that we need a QObject, if not found an exception is thrown
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
global handle for jitter by coincidence
void SetCalibLabel(const std::string &calibl)
void SetCalibVersion(const std::string &calibv)
Raw event: bolometer channel, trigger positions and types.
const int & GetChannelId() const
Get ChannelId.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...