src/common/MMuSCTimeDifferences.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <iostream>
#include "midas.h"
#include <TH2.h>
#include <TDirectory.h>
#include "TGlobalData.h"
#include "TSetupData.h"
#include "TPulseIsland.h"

Go to the source code of this file.

Functions

INT MMuSCTimeDifferences_init (void)
INT MMuSCTimeDifferences (EVENT_HEADER *, void *)
int FillCoincidenceTimeHistogram (int tMusc, const std::vector< TPulseIsland * > &pulses, int start, TH1 *h, TH2 *hAmp, double t_low, double t_high, bool PP, TH1 *h_PP, TH2 *hAmp_PP, const std::string &bank_name)
bool IsPileupProtected (double t, const std::vector< TPulseIsland * > &p, double window, int *lPP, const std::string &bank_name)
double GetTime (const TPulseIsland *p, const TSetupData *setup, const std::string &bank_name)

Variables

HNDLE hDB
TGlobalDatagData
 Object to hold data used and produced by modules throughout alcapana stage of analysis.
TSetupDatagSetup
 Hardware information about digitizers and detectors to be used during alcapana stage of analysis.
ANA_MODULE MMuSCTimeDifferences_module
static TH1 ** hTime
static TH2 ** hAmplitudeVsTime
static TH1 ** hTime_PP
static TH2 ** hAmplitudeVsTime_PP
static int * last
static std::vector< std::string > detectors
static int nr_detectors

Function Documentation

int FillCoincidenceTimeHistogram ( int  tMusc,
const std::vector< TPulseIsland * > &  pulses,
int  start,
TH1 *  h,
TH2 *  hAmp,
double  t_low,
double  t_high,
bool  PP,
TH1 *  h_PP,
TH2 *  hAmp_PP,
const std::string &  bank_name 
)

Definition at line 174 of file MMuSCTimeDifferences.cpp.

References GetTime().

00177 {
00178   for(int p = start; p < (int)pulses.size(); ++p){
00179     
00180     double tDiff = GetTime(pulses[p],gSetup, bank_name) - tMusc;
00181     if(tDiff < t_low){
00182       start = p;
00183       continue;
00184     }
00185     if(tDiff > t_high) break;
00186     h->Fill(tDiff);
00187     hAmp->Fill(tDiff, pulses[p]->GetPulseHeight());
00188     if(PP){
00189       h_PP->Fill(tDiff);
00190       hAmp_PP->Fill(tDiff, pulses[p]->GetPulseHeight());
00191     }
00192   }
00193 
00194   return start;
00195 }

double GetTime ( const TPulseIsland p,
const TSetupData setup,
const std::string &  bank_name 
)
bool IsPileupProtected ( double  t,
const std::vector< TPulseIsland * > &  p,
double  window,
int *  lPP,
const std::string &  bank_name 
)

Definition at line 197 of file MMuSCTimeDifferences.cpp.

References GetTime().

00197                                                                                                                        {
00198   if(t < window || t > 1.12E8-window) return false; // very basic bookending
00199   for(unsigned i = *lPP; i < p.size(); ++i){
00200     double t2 = GetTime(p[i],gSetup,bank_name);
00201     if(t2 < t-window){
00202       *lPP = i;
00203     }
00204     if(t2 > t+window) break;
00205     if(t != t2 && t2 > t-window && t2 < t+window) return false;
00206   }
00207   return true;
00208 }

INT MMuSCTimeDifferences ( EVENT_HEADER *  pheader,
void *  pevent 
)

This method processes one MIDAS block, producing a vector of TOctalFADCIsland objects from the raw Octal FADC data.

Definition at line 138 of file MMuSCTimeDifferences.cpp.

References detectors, FillCoincidenceTimeHistogram(), TGlobalData::fPulseIslandToChannelMap, TSetupData::GetBankName(), GetTime(), hAmplitudeVsTime, hAmplitudeVsTime_PP, hTime, hTime_PP, IsPileupProtected(), last, and nr_detectors.

00138                                                              {
00139   double t_low = -10000;
00140   double t_high = 10000;
00141 
00142   // Some typedefs
00143   typedef map<string, vector<TPulseIsland*> > TStringPulseIslandMap;
00144   
00145   // Fetch a reference to the gData structure that stores a map
00146   // of (bank_name, vector<TPulseIsland*>) pairs
00147   TStringPulseIslandMap& pulse_islands_map =
00148     gData->fPulseIslandToChannelMap;
00149   
00150   // Let's loop over the muSC times
00151   std::string str_MuSC = gSetup->GetBankName("muSc");
00152   int lPP = 0;
00153   for(int i=0; i<nr_detectors; ++i) last[i] = 0;
00154   
00155   for(std::vector<TPulseIsland*>::iterator it_Musc = pulse_islands_map[str_MuSC].begin(); 
00156       it_Musc != pulse_islands_map[str_MuSC].end(); ++it_Musc){
00157     
00158     double tMusc = GetTime(*it_Musc,gSetup,str_MuSC);
00159     
00160     bool PP = IsPileupProtected(tMusc, pulse_islands_map[str_MuSC], 10000, &lPP,str_MuSC);
00161     
00162     std::string bank_name;
00163     for(int i=0; i<nr_detectors; ++i){
00164       bank_name=gSetup->GetBankName(detectors[i]);
00165       last[i] = FillCoincidenceTimeHistogram(tMusc, pulse_islands_map[bank_name], 
00166                                              last[i], hTime[i], hAmplitudeVsTime[i], t_low, t_high,
00167                                              PP, hTime_PP[i], hAmplitudeVsTime_PP[i], bank_name);
00168     }
00169   }
00170   
00171   return SUCCESS;
00172 }

INT MMuSCTimeDifferences_init (  ) 

This method initializes histograms.

Definition at line 76 of file MMuSCTimeDifferences.cpp.

References detectors, TSetupData::fBankToDetectorMap, TGlobalData::fPulseIslandToChannelMap, hAmplitudeVsTime, hAmplitudeVsTime_PP, hTime, hTime_PP, last, and nr_detectors.

00077 {
00078   gDirectory->mkdir("MuSC_TimingCorrelations")->cd();
00079   // Let's find all detector names other than muSC
00080   for(std::map<std::string, std::string>::iterator it = gSetup->fBankToDetectorMap.begin();
00081       it != gSetup->fBankToDetectorMap.end(); ++it){
00082     if(it->first != std::string("") && it->first != std::string("blank")){
00083       if(it->second != std::string("muSc")) detectors.push_back(it->second);
00084     }
00085   }
00086   std::cout << "Number of detectors fo Time Correlations: " << detectors.size() << std::endl;
00087   std::cout << "Size of Bank to Detector map: " << gSetup->fBankToDetectorMap.size() << std::endl;
00088   std::cout << "Size of TPI map: " << gData->fPulseIslandToChannelMap.size() << std::endl;
00089 
00090   nr_detectors = detectors.size();
00091   hTime = new TH1*[nr_detectors];
00092   hTime_PP = new TH1*[nr_detectors];
00093   hAmplitudeVsTime = new TH2*[nr_detectors];
00094   hAmplitudeVsTime_PP = new TH2*[nr_detectors];
00095   last = new int[nr_detectors];
00096   
00097   for(int i = 0; i<nr_detectors; ++i){
00098     last[i] = 0;
00099 
00100     std::string hName("hMuSC_");
00101     hName += detectors[i];
00102     hName += "_Timediff";
00103     std::string hTitle("Tdiff for ");
00104     hTitle += detectors[i];
00105     hTitle += " - muSC";
00106     hTime[i] = new TH1F(hName.c_str(), hTitle.c_str(), 500, -13000, 13000);
00107     hTime[i]->GetXaxis()->SetTitle("Time difference [ns]");
00108     hName += "_PP";
00109     hTitle += " with PP";
00110     hTime_PP[i] = new TH1F(hName.c_str(), hTitle.c_str(), 500, -13000, 13000);
00111     hTime_PP[i]->GetXaxis()->SetTitle("Time difference [ns]");
00112        
00113     hName = "hMuSC_";
00114     hName += detectors[i];
00115     hName += "_AmplitudeVsTdiff";
00116     hTitle = "Amplitude versus tdiff for ";
00117     hTitle += detectors[i];
00118     hTitle += " - muSC";
00119     hAmplitudeVsTime[i] = new TH2F(hName.c_str(), hTitle.c_str(), 250, -5000, 5000,
00120                                    250, 0, 3000);
00121     hAmplitudeVsTime[i]->GetXaxis()->SetTitle("Time difference [ns]");
00122     hAmplitudeVsTime[i]->GetYaxis()->SetTitle("Amplitude");
00123     hName += "_PP";
00124     hTitle += " with PP";
00125     hAmplitudeVsTime_PP[i] = new TH2F(hName.c_str(), hTitle.c_str(), 250, -5000, 5000,
00126                                       250, 0, 3000);
00127     hAmplitudeVsTime_PP[i]->GetXaxis()->SetTitle("Time difference [ns]");
00128     hAmplitudeVsTime_PP[i]->GetYaxis()->SetTitle("Amplitude");
00129   }
00130   gDirectory->cd("/");
00131 
00132   return SUCCESS;
00133 }


Variable Documentation

std::vector<std::string> detectors [static]
TH2** hAmplitudeVsTime [static]

Definition at line 60 of file MMuSCTimeDifferences.cpp.

Referenced by MMuSCTimeDifferences(), and MMuSCTimeDifferences_init().

TH2** hAmplitudeVsTime_PP [static]

Definition at line 62 of file MMuSCTimeDifferences.cpp.

Referenced by MMuSCTimeDifferences(), and MMuSCTimeDifferences_init().

HNDLE hDB
TH1** hTime [static]

Definition at line 59 of file MMuSCTimeDifferences.cpp.

Referenced by MMuSCTimeDifferences(), and MMuSCTimeDifferences_init().

TH1** hTime_PP [static]

Definition at line 61 of file MMuSCTimeDifferences.cpp.

Referenced by MMuSCTimeDifferences(), and MMuSCTimeDifferences_init().

int* last [static]

Definition at line 63 of file MMuSCTimeDifferences.cpp.

Referenced by MMuSCTimeDifferences(), and MMuSCTimeDifferences_init().

Initial value:
{
        "MMuSCTimeDifferences",        
        "Peter Winter",                
        MMuSCTimeDifferences,          
        NULL,                          
        NULL,                          
        MMuSCTimeDifferences_init,     
        NULL,                          
        NULL,                          
        0,                             
        NULL,                          
}

Definition at line 45 of file MMuSCTimeDifferences.cpp.

int nr_detectors [static]

Definition at line 65 of file MMuSCTimeDifferences.cpp.

Referenced by MMuSCTimeDifferences(), and MMuSCTimeDifferences_init().


Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1