Skip to content

Instantly share code, notes, and snippets.

@gadamc
Created September 22, 2011 11:54
Show Gist options
  • Save gadamc/1234620 to your computer and use it in GitHub Desktop.
Save gadamc/1234620 to your computer and use it in GitHub Desktop.
example of using a KAmper -- the KSimpleKamper1
void runTest(const char* input, const char * out)
{
KDataReader f(input);
TH1D hAmpHA("hAmpHeatA", "hAmpHeatA", 10000,-5000, 5000);
TH1D hAmpHC("hAmpHeatC", "hAmpHeatC", 10000,-5000, 5000);
TH1D hAmpIA("hAmpIonA", "hAmpIonA", 10000,-5000, 5000);
TH1D hAmpIB("hAmpIonB", "hAmpIonB", 10000,-5000, 5000);
TH1D hAmpIC("hAmpIonC", "hAmpIonC", 10000,-5000, 5000);
TH1D hAmpID("hAmpIonD", "hAmpIonD", 10000,-5000, 5000);
KEvent *e = f.GetEvent();
//results will be stored in this object by the KAmper
KPulseAnalysisRecord *prec = new KPulseAnalysisRecord;
//here's the KAmper
KSimpleKamper1 myKamper;
int heatMinPeak = 250;
int heatMaxPeak = 290;
int ionMinPeak = 6500;
int ionMaxPeak = 6700;
for(Int_t i = 0; i < f.GetEntries(); i++){
f.GetEntry(i);
if (i % 500 == 0) cout << "entry " << i << endl;
for(Int_t j = 0; j < e->GetNumBoloPulses(); j++){
KRawBoloPulseRecord *p = (KRawBoloPulseRecord *)e->GetBoloPulse(j);
if( strcmp(p->GetBolometerRecord()->GetDetectorName(), "FID802") != 0)
continue;
if(p->GetPulseLength() == 0)
continue;
//tell the KAmper to "MakeKamp" and it will process the raw data
//estimate the pulse amplitude and store it in the prec (KPulseAnalysisRecord) object
myKamper.MakeKamp(p,prec);
//here I am transferring the data in the prec into some histograms
//in order to view the results.
//this is easiest way to prototype and test KAmpers without having to deal
//with the overhead of creating KAmpEvents.
string name = p->GetChannelName();
if(strcmp(p->GetChannelName(),"chaleur FID802AB") == 0){
if(prec->GetPeakPosition() > heatMinPeak && prec->GetPeakPosition() < heatMaxPeak)
hAmpHA.Fill(prec->GetAmp());
}
else if(strcmp(p->GetChannelName(),"centre FID802AB") == 0){
if(prec->GetPeakPosition() > ionMinPeak && prec->GetPeakPosition() < ionMaxPeak)
hAmpIA.Fill(prec->GetAmp());
}
else if(strcmp(p->GetChannelName(),"garde FID802AB") == 0){
if(prec->GetPeakPosition() > ionMinPeak && prec->GetPeakPosition() < ionMaxPeak)
hAmpIB.Fill(prec->GetAmp());
}
else if(strcmp(p->GetChannelName(),"chaleur FID802CD") == 0){
if(prec->GetPeakPosition() > heatMinPeak && prec->GetPeakPosition() < heatMaxPeak)
hAmpHC.Fill(prec->GetAmp());
}
else if(strcmp(p->GetChannelName(),"centre FID802CD") == 0){
if(prec->GetPeakPosition() > ionMinPeak && prec->GetPeakPosition() < ionMaxPeak)
hAmpIA.Fill(prec->GetAmp());
}
else if(strcmp(p->GetChannelName(),"garde FID802CD") == 0){
if(prec->GetPeakPosition() > ionMinPeak && prec->GetPeakPosition() < ionMaxPeak)
hAmpIB.Fill(prec->GetAmp());
}
}
}
TFile fout(out,"recreate");
hAmpHA.Write();
hAmpHC.Write();
hAmpIA.Write();
hAmpIB.Write();
hAmpIC.Write();
hAmpID.Write();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment