~durga/mice-tofcalib/trunk

« back to all changes in this revision

Viewing changes to TofT0Calib.cc

  • Committer: Durga Rajaram
  • Date: 2013-08-01 07:05:35 UTC
  • Revision ID: durga@fnal.gov-20130801070535-hcua78p6mpdnsa2r
added data cards. added README -- instructions for running

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
:TWCalib( tw ), TriggerCalib( tr )
7
7
{
8
8
  NHistoBins = 200;
9
 
  minEntries = 1000;
 
9
  minEntries = 100;
10
10
  nSlabs = (station==0 || station==2)? 10 : 7;
11
11
  Station = station;
12
12
  stringstream stname;
18
18
:TWCalib( tw ), TriggerCalib(tr)
19
19
{
20
20
  NHistoBins = 1000;
21
 
  minEntries = 1000;
 
21
  minEntries = 100;
22
22
  nSlabs = (station==0 || station==2)? 10 : 7;
23
23
  Station = station;
24
24
  stringstream stname;
34
34
 
35
35
void TofT0Calib::FullCalib(int refSlA, int refSlB, bool verboseMode)
36
36
{
 
37
  cout << "fullcalib: " << Station << endl;
37
38
  SetAddresses(Station);
38
39
  MakeHistograms();
39
40
  FillHistograms();
58
59
    if(!plane){ Slab_A = i; Slab_B =refSl;}
59
60
    else { Slab_A = refSl; Slab_B = i;}
60
61
 
61
 
    cout<<Slab_A<<" "<<Slab_B<<" "<<hists[Slab_A][Slab_B][0]->GetEntries()<<endl;
 
62
    //cout<<Slab_A<<" "<<Slab_B<<" "<<hists[Slab_A][Slab_B][0]->GetEntries()<<endl;
 
63
    //cout<<"pcalib: " << Station << " " << Slab_A<<" "<<Slab_B<<" "<<hists[Slab_A][Slab_B][0]->GetEntries()<<endl;
62
64
    TF1 fgaus("fgaus","gaus");
63
65
    fgaus.SetLineWidth(1);
64
66
    fgaus.SetLineColor(4);
72
74
      if(!plane)
73
75
        _pmtPar.pmt = k;
74
76
      else _pmtPar.pmt = k-2;
 
77
      int histoMeanBin = hists[Slab_A][Slab_B][k]->GetXaxis()->FindBin( hists[Slab_A][Slab_B][k]->GetMean() );
 
78
      hists[Slab_A][Slab_B][k]->GetXaxis()->SetRange(histoMeanBin-120,histoMeanBin+120);
75
79
      if(hists[Slab_A][Slab_B][k]->GetEntries()>minEntries)
76
80
      {
77
81
        fgaus.SetParameters(0.,0.,0.);
78
82
        //int nfound = s1->Search( hists[Slab_A][Slab_B][k] );
79
 
        int nfound = s1->Search( hists[Slab_A][Slab_B][k],2,"goff");
80
 
        int histoMeanBin = hists[Slab_A][Slab_B][k]->GetXaxis()->FindBin( hists[Slab_A][Slab_B][k]->GetMean() );
81
 
        hists[Slab_A][Slab_B][k]->GetXaxis()->SetRange(histoMeanBin-120,histoMeanBin+120);
82
 
        //if(nfound!=3) { 
83
 
        if(!nfound) {
 
83
        int nfound = s1->Search( hists[Slab_A][Slab_B][k],2);
 
84
        // search for peaks; if < 3; rebin & search again; if still < 3, skip
 
85
        if(!nfound) { 
84
86
          hists[Slab_A][Slab_B][k]->Rebin();
85
 
          nfound = s1->Search( hists[Slab_A][Slab_B][k],2,"goff");
 
87
          nfound = s1->Search( hists[Slab_A][Slab_B][k],2);
86
88
          int histoMeanBin = hists[Slab_A][Slab_B][k]->GetXaxis()->FindBin( hists[Slab_A][Slab_B][k]->GetMean() );
87
89
          hists[Slab_A][Slab_B][k]->GetXaxis()->SetRange(histoMeanBin-60,histoMeanBin+60);
88
90
        }
89
 
        //if(nfound!=3) {
90
 
        if(!nfound){
 
91
        if(!nfound) {
 
92
          cout << "not found: " << k << " " << Slab_A << " " << Slab_B << endl;
 
93
          hists[Slab_A][Slab_B][k]->Write();
 
94
          SaveToFile(_pmtPar.st, _pmtPar.plane, _pmtPar.slab, _pmtPar.pmt, NoCalib, 2);
91
95
          k++;
92
96
          continue;
93
97
        }
126
130
        channelParTree->Fill();
127
131
        SaveToFile(_pmtPar.st, _pmtPar.plane, _pmtPar.slab, _pmtPar.pmt, _pmtPar.par, 2);
128
132
      }
129
 
      else  SaveToFile(_pmtPar.st, _pmtPar.plane, _pmtPar.slab, _pmtPar.pmt, NoCalib, 2);
 
133
      else {
 
134
        SaveToFile(_pmtPar.st, _pmtPar.plane, _pmtPar.slab, _pmtPar.pmt, NoCalib, 2);
 
135
        hists[Slab_A][Slab_B][k]->Write();
 
136
      }
130
137
 
131
138
      k++;
132
139
    }
182
189
        name3<<"St"<<Station<<"Pixel_h"<<j<<"v"<<k<<"_Pmt"<<i<<"_t0";
183
190
        //tr1[j][k].push_back( new TH1F(name3.str().c_str(), name3.str().c_str(),2400,-11e4,-5e4) );
184
191
        hists[j][k].push_back( new TH1F(name3.str().c_str(), name3.str().c_str(),NHistoBins,mean-5e4,mean+5e4) );
 
192
        //cout << "makehist: " << name3.str() << endl;
185
193
      }
186
194
    }
187
195
  }
217
225
    dataTree->GetEntry(i);
218
226
    i++;
219
227
 
 
228
    //cout << "slx = " << _slX << endl;
220
229
    if(_slX!=-99)
221
230
    {
222
231
      double tw0, tw1, tw2, tw3;
229
238
 
230
239
        if(tw0!=-99999 && tw1!=-99999 &&  tw2!=-99999 && tw3!=-99999  )
231
240
        {
 
241
          //cout << " correcting for tw" << endl;
232
242
          _t0 += tw0;
233
243
          _t1 += tw1;
234
244
          _t2 += tw2;
257
267
int TofT0Calib::T0Correction(int station, int plane, int slab, int pmt)
258
268
{
259
269
  double* T = GetParameters(station, plane, slab, pmt);
260
 
  if(!T)    return -99999;
 
270
  if(!T) {
 
271
    return -99999;
 
272
  }
261
273
 
262
274
  return - int( T[0] );
263
275
}
264
276
 
265
277
void TofT0Calib::Test()
266
278
{
267
 
  cout<<"Station "<<Station<<"  Calibration Test "<<endl;
 
279
  cout<<"TestStation "<<Station<<"  Calibration Test "<<endl;
268
280
  int trStation = TriggerCalib->GetStation();
269
281
  int _slA, _slB, _adc0, _adc1, _adc2, _adc3;
270
282
  double _t0, _t1, _t2, _t3, _t4, _t5, _t6, _t7;
401
413
  {
402
414
    dataTree->GetEntry(i);
403
415
    i++;
404
 
    cout << _slA << "  " << _slB << "  " << _slC << "  " << _slD << endl;
 
416
    //cout << _slA << "  " << _slB << "  " << _slC << "  " << _slD << endl;
405
417
    bool T0correction=false, TWcorrection=false;
406
418
    if(_slC!=-99)
407
419
    {
419
431
      if( t0_0!=-99999 && t0_1!=-99999 &&  t0_2!=-99999 && t0_3!=-99999 &&
420
432
          t0_4!=-99999 && t0_5!=-99999 &&  t0_6!=-99999 && t0_7!=-99999 && dt0!=-99999 )
421
433
      {
422
 
        if(i<1000) cout<<"TDC = "<<_t2<<" "<<t0_2<<endl;
 
434
        //if(i<1000) cout<<"TDC = "<<_t2<<" "<<t0_2<<endl;
423
435
        _t0 += t0_0;
424
436
        _t1 += t0_1;
425
437
        _t2 += t0_2;
657
669
{
658
670
  cout<<"=========  PMTCable Delay  ==========="<<endl;
659
671
  MiceTofCalib::PrintPMTParameters(2);
660
 
}
 
 
b'\\ No newline at end of file'
 
672
}