AlcapDAQ  1
Functions | Variables
MHitTime.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <TH1I.h>
#include "TGlobalData.h"
#include "TSetupData.h"

Go to the source code of this file.

Functions

INT MHitTime_init (void)
 
INT MHitTime (EVENT_HEADER *, void *)
 

Variables

HNDLE hDB
 
TGlobalDatagData
 
TSetupDatagSetup
 
static TH1I * hTime_MuSC
 
static std::map< std::string,
TH1I * > 
hEventTimes
 
static std::map< std::string,
TH1I * > 
hBlockTimes
 
static const double BLOCKLENGTH = 10000000.
 
static const double CUTWINDOW = 10000.
 
ANA_MODULE MHitTime_module
 

Function Documentation

INT MHitTime ( EVENT_HEADER *  pheader,
void *  pevent 
)

Definition at line 86 of file MHitTime.cpp.

References banks, CUTWINDOW, TSetupData::fBankToDetectorMap, TGlobalData::fPulseIslandToChannelMap, hTime_MuSC, and SUCCESS.

87 {
88 
89  // We assume the existance of all necessary TPI vectors
90  std::map< std::string, std::vector<TPulseIsland*> >& tpis = gData->fPulseIslandToChannelMap;
91  std::map< std::string, std::string>& dets = gSetup->fBankToDetectorMap;
92  std::map< std::string, std::string>& banks = gSetup->fDetectorToBankMap;
93 
94  std::vector<TPulseIsland*> muons = tpis.at(banks.at("muSC"));
95 
96  std::map< std::string, std::vector<TPulseIsland*> >::iterator iBank;
97  std::map< std::string, std::string>::iterator iDet;
98  std::vector<TPulseIsland*>::iterator cMuon;
99  std::map< std::string, std::vector<TPulseIsland*>::iterator > pulses;
100  for (iBank = tpis.begin(); iBank != tpis.end(); iBank++)
101  if(iBank->first != banks.at("muSC"))
102  pulses[iBank->first] = iBank->second.begin();
103 
104 
105  double t_mu;
106  double t[2];
107  std::string cDet, cBank;
108  for (cMuon = muons.begin(); cMuon != muons.end(); cMuon++) {
109  t_mu = (*cMuon)->GetPulseTime();
110  hTime_MuSC->Fill(t_mu);
111  for (iDet = dets.begin(); iDet != dets.end(); iDet++) {
112  cBank = iDet->first;
113  cDet = iDet->second;
114  std::vector<TPulseIsland*>::iterator& cPulse = pulses.at(cBank);
115  if (cPulse == tpis.at(cBank).end())
116  continue;
117  t[0] = (*cPulse)->GetPulseTime();
118  t[1] = t[0] - t_mu;
119  hBlockTimes.at(cDet)->Fill(t[0]);
120  while (t[1] < 0.) {
121  cPulse++;
122  t[0] = (*cPulse)->GetPulseTime();
123  t[1] = t[0] - t_mu;
124  hBlockTimes.at(cDet)->Fill(t[0]);
125  }
126  while (t[1] < CUTWINDOW) {
127  hEventTimes.at(cDet)->Fill(t[1]);
128  cPulse++;
129  t[0] = (*cPulse)->GetPulseTime();
130  t[1] = t[0] - t_mu;
131  hBlockTimes.at(cDet)->Fill(t[0]);
132  }
133  }
134  }
135 
136  // Are there any pulses left?
137  for (iDet = dets.begin(); iDet != dets.end(); iDet++) {
138  cBank = iDet->first;
139  cDet = iDet->second;
140  std::vector<TPulseIsland*>::iterator cPulse = pulses.at(cBank);
141  while(cPulse != tpis.at(cBank).end()) {
142  t[0] = (*cPulse)->GetPulseTime();
143  hBlockTimes[cDet]->Fill(t[0]);
144  cPulse++;
145  }
146  }
147 
148  return SUCCESS;
149 }
INT MHitTime_init ( void  )

Definition at line 60 of file MHitTime.cpp.

References BLOCKLENGTH, CUTWINDOW, TSetupData::fBankToDetectorMap, TGlobalData::fPulseIslandToChannelMap, hTime_MuSC, and SUCCESS.

61 {
62 
63  std::map< std::string, std::vector<TPulseIsland*> >& tpis = gData->fPulseIslandToChannelMap;
64  std::map< std::string, std::vector<TPulseIsland*> >::iterator iBank;
65  std::map< std::string, std::string> dets = gSetup->fBankToDetectorMap;
66 
67  std::string cBank, cDet;
68  hBlockTimes.clear();
69  hEventTimes.clear();
70  hTime_MuSC = new TH1I("hTime_MuSC", "Hit Times of MuSC;Block Hit Time (ns);Counts",
71  100, 0., BLOCKLENGTH);
72  for (iBank = tpis.begin(); iBank != tpis.end(); iBank++) {
73  cBank = iBank->first;
74  cDet = dets[cBank];
75  if (cDet == "muSC")
76  continue;
77  hBlockTimes[cDet] = new TH1I(("hBlockTime_" + cDet).c_str(), ("Block Hit Times of " + cDet + ";Time (ns); Counts").c_str(),
78  100, 0., BLOCKLENGTH);
79  hEventTimes[cDet] = new TH1I(("hEventTime_" + cDet).c_str(), ("Event Hit Times of " + cDet +";Time (ns); Counts").c_str(),
80  100, 0., CUTWINDOW);
81  }
82  return SUCCESS;
83 }

Variable Documentation

const double BLOCKLENGTH = 10000000.
static

Definition at line 42 of file MHitTime.cpp.

Referenced by MHitTime_init().

const double CUTWINDOW = 10000.
static

Definition at line 43 of file MHitTime.cpp.

Referenced by MHitTime(), and MHitTime_init().

TGlobalData* gData

Definition at line 54 of file analyzer.cpp.

TSetupData* gSetup

Definition at line 55 of file analyzer.cpp.

std::map< std::string, TH1I* > hBlockTimes
static

Definition at line 40 of file MHitTime.cpp.

HNDLE hDB

Definition at line 11 of file mucap_compress.cpp.

std::map< std::string, TH1I* > hEventTimes
static

Definition at line 39 of file MHitTime.cpp.

TH1I* hTime_MuSC
static

Definition at line 38 of file MHitTime.cpp.

Referenced by MHitTime(), and MHitTime_init().

ANA_MODULE MHitTime_module
Initial value:
=
{
"MHitTime",
"John R Quirk",
NULL,
NULL,
NULL,
NULL,
0,
NULL,
}

Definition at line 45 of file MHitTime.cpp.