42 std::map<double, double>
MakePulseHeightSums(std::vector<std::map<double, double> > timeHeightMapsVector,
double time_difference);
78 for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin();
79 mapIter != bank_to_detector_map.end(); mapIter++) {
81 std::string bankname = mapIter->first;
84 if (detname.substr(0,4) ==
"SiL1" && detname.substr(7,4) ==
"slow")
85 left_thin_banknames.push_back(bankname);
86 else if (detname.substr(0,4) ==
"SiL2" && detname.substr(5,4) ==
"slow")
87 left_thick_banknames.push_back(bankname);
88 else if (detname.substr(0,4) ==
"SiR1" && detname.substr(7,4) ==
"slow")
89 right_thin_banknames.push_back(bankname);
90 else if (detname.substr(0,4) ==
"SiR2" && detname.substr(5,4) ==
"slow")
91 right_thick_banknames.push_back(bankname);
94 int max_adc_value = 4096;
97 std::string histname =
"hdEdx_left";
98 std::string histtitle =
"dE/dx plot for the left arm";
99 hdEdx_left =
new TH2D(histname.c_str(), histtitle.c_str(), max_adc_value,0,max_adc_value, max_adc_value,0,max_adc_value);
100 hdEdx_left->GetXaxis()->SetTitle(
"Pulse Height in Si1");
101 hdEdx_left->GetYaxis()->SetTitle(
"Total Pulse Height in Si1 and Si2");
103 histname =
"hdEdx_right";
104 histtitle =
"dE/dx plot for the right arm";
105 hdEdx_right =
new TH2D(histname.c_str(), histtitle.c_str(), max_adc_value,0,max_adc_value, max_adc_value,0,max_adc_value);
106 hdEdx_right->GetXaxis()->SetTitle(
"Pulse Height in Si1");
107 hdEdx_right->GetYaxis()->SetTitle(
"Total Pulse Height in Si1 and Si2");
118 int midas_event_number = pheader->serial_number;
122 typedef pair<string, vector<TPulseIsland*> > TStringPulseIslandPair;
123 typedef map<string, vector<TPulseIsland*> >::iterator map_iterator;
127 TStringPulseIslandMap& pulse_islands_map =
133 std::vector<std::map<double, double> > thinSiLeft_TimeHeightMaps;
134 for (std::vector<std::string>::iterator bankNameIter = left_thin_banknames.begin();
135 bankNameIter != left_thin_banknames.end(); bankNameIter++) {
139 if (temp_vector.size() == 0)
continue;
143 std::map<double, double> thinLeftSum;
144 if (thinSiLeft_TimeHeightMaps.size() != 0)
147 std::vector<std::map<double, double> > totalLeft_TimeHeightMaps;
148 for (std::vector<std::string>::iterator leftThickIter = left_thick_banknames.begin();
149 leftThickIter != left_thick_banknames.end(); leftThickIter++) {
153 if (temp_vector.size() == 0)
continue;
157 if (thinLeftSum.size() != 0)
158 totalLeft_TimeHeightMaps.push_back(thinLeftSum);
160 std::map<double, double> totalLeftSum;
161 if (totalLeft_TimeHeightMaps.size() != 0)
164 for (std::map<double, double>::iterator thinHit = thinLeftSum.begin(), totalHit = totalLeftSum.begin();
165 thinHit != thinLeftSum.end() || totalHit != totalLeftSum.end(); thinHit++, totalHit++) {
167 hdEdx_left->Fill((*thinHit).second, (*totalHit).second);
176 std::vector<std::map<double, double> > thinSiRight_TimeHeightMaps;
177 for (std::vector<std::string>::iterator bankNameIter = right_thin_banknames.begin();
178 bankNameIter != right_thin_banknames.end(); bankNameIter++) {
182 if (temp_vector.size() == 0)
continue;
186 std::map<double, double> thinRightSum;
187 if (thinSiRight_TimeHeightMaps.size() != 0)
190 std::vector<std::map<double, double> > totalRight_TimeHeightMaps;
191 for (std::vector<std::string>::iterator rightThickIter = right_thick_banknames.begin();
192 rightThickIter != right_thick_banknames.end(); rightThickIter++) {
196 if (temp_vector.size() == 0)
continue;
200 if (thinRightSum.size() != 0)
201 totalRight_TimeHeightMaps.push_back(thinRightSum);
203 std::map<double, double> totalRightSum;
204 if (totalRight_TimeHeightMaps.size() != 0)
207 for (std::map<double, double>::iterator thinHit = thinRightSum.begin(), totalHit = totalRightSum.begin();
208 thinHit != thinRightSum.end() || totalHit != totalRightSum.end(); thinHit++, totalHit++) {
210 hdEdx_right->Fill((*thinHit).second, (*totalHit).second);
221 std::map<double, double> output;
223 for (std::vector<TPulseIsland*>::iterator pulseIter = thePulses.begin();
224 pulseIter != thePulses.end(); pulseIter++) {
226 output[(*pulseIter)->GetPulseTime()] = (*pulseIter)->GetPulseHeight();
235 std::map<double, double>
MakePulseHeightSums(std::vector<std::map<double, double> > timeHeightMapsVector,
double time_difference) {
238 std::vector<std::map<double, double>::iterator > pulseIters;
239 std::vector<std::map<double, double>::iterator > backwardIters;
241 for (
int b = 0; b < timeHeightMapsVector.size(); b++) {
242 pulseIters.push_back((timeHeightMapsVector.at(b)).begin());
243 backwardIters.push_back((timeHeightMapsVector.at(b)).end());
247 std::map<double, double> output;
249 while ( pulseIters.size() > 0 ) {
256 double min_time = 99999999999.;
257 for (
int b = 0; b < pulseIters.size(); ++b){
258 double time = (pulseIters.at(b))->first;
259 min_time = std::min(min_time , time);
266 double pulseHeight = 0;
267 double pulseTime = 0;
269 for (
int b = 0; b < pulseIters.size(); ++b){
270 std::pair<double, double> timeHeightPair = *(pulseIters.at(b));
272 if ( std::abs(timeHeightPair.first - min_time) < time_difference ) {
273 pulseHeight += timeHeightPair.second;
274 pulseTime += timeHeightPair.first;
277 ++(pulseIters.at(b));
284 output[pulseTime/nSummed] = pulseHeight;
289 for (
int b = pulseIters.size()-1; b >= 0 ; --b){
290 if (pulseIters.at(b) == backwardIters.at(b)){
291 pulseIters.erase(pulseIters.begin() + b);
292 backwardIters.erase(backwardIters.begin() + b);