• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

beamtime/cern-nov10/go4/TCernNov10Proc.cxx (r4864/r3159)

Go to the documentation of this file.
00001 #include "TCernNov10Proc.h"
00002 
00003 #include "TGo4Version.h"
00004 #if __GO4BUILDVERSION__ > 40502
00005 #include "go4iostream.h"
00006 #else
00007 #include "Riostream.h"
00008 #endif
00009 #include "TH1.h"
00010 #include "TSystem.h"
00011 #include "TH2.h"
00012 #include <stdlib.h>
00013 
00014 #include "TCernNov10Param.h"
00015 
00016 
00017 #include "TGo4WinCond.h"
00018 #include "TGo4PolyCond.h"
00019 #include "TGo4Picture.h"
00020 #include "TGo4Analysis.h"
00021 #include "TGo4MbsEvent.h"
00022 #include "TRocParam.h"
00023 
00024 #include "roc/Board.h"
00025 #include "roc/Message.h"
00026 
00027 #include "spadic/Message.h"
00028 
00029 
00030 #define __SPADIC_DEBUG__ 0
00031 
00032 #define MADC_DEBUG 0
00033 
00034 #define L1182_DEBUG 0
00035 
00036 
00037 #define V550_READ_PED 1
00038 
00039 
00040 
00041 //***********************************************************
00042 // this one is used in standard factory
00043 TCernNov10Proc::TCernNov10Proc(const char* name) : TRocProc(name)
00044 {
00045    cout << "**** TCernNov10Proc: Create instance nov 16" << name << endl;
00046    
00047    fParam->triggerSignal = 10;
00048 
00049    fCernNov10Par = (TCernNov10Param*) MakeParameter("CernNov10Par", "TCernNov10Param");
00050 
00051    fVulomSyncs = MakeTH1('I', "VULOM/Syncs", "Number of sync messages from VULOM", 65536, 0, 65536.);
00052 
00053    for (int n=0;n<NUM_SCALERS;n++)
00054       fVulomScalers[n] = MakeTH1('I', Form("VULOM/Scaler%d", n), "Distribution of scaler signals", 16, 0, 16.);
00055 
00056 
00057    if (!ReadMapmtGeometry("mapmt-geometry.txt"))
00058       if (!ReadMapmtGeometry("beamtime/cern-nov10/go4/mapmt-geometry.txt"))
00059         if (!ReadMapmtGeometry(Form("%s/beamtime/cern-nov10/go4/mapmt-geometry.txt", gSystem->Getenv("ROCSYS"))))
00060            ReadMapmtGeometry("dummy.txt");
00061 
00062    fMAPMT_entry = MakeTH2('I', "MAPMT/mapmt_detector", "Number of hits per MAPMT channels", 24, -8., 16., 24, 0., 24.);
00063    fMAPMT_integral = MakeTH2('D', "MAPMT/mapmt_integral", "Integral of ADC values per MAPMT channels", 24, -8., 16., 24, 0., 24.);
00064    fMAPMT_mean = MakeTH2('D', "MAPMT/mapmt_mean", "Mean ADC values per MAPMT channels", 24, -8., 16., 24, 0., 24.);
00065 
00066    fMAPMT_adc = MakeTH1('I', "MAPMT/mapmt_adc", "Distribution of corrected ADC values", 1024, 0., 4096.);
00067    fMAPMT_tshift = MakeTH1('I', "MAPMT/mapmt_tshift", "Distribution of difference between AUX2 and MAPMT hit", 1024, 0., 4096.);
00068 
00069    fMAPMT_cond = MakeWinCond("MAPMT_adccond", 0., 1500., "mapmt_adc");
00070    fMAPMT_tcond = MakeWinCond("MAPMT_timecond", 600., 900., "mapmt_tshift");
00071 
00072 
00073    for (int n=0;n<2;n++) {
00074       fSTStm[n] = MakeTH1('I', Form("STS/STS%dtm", n), Form("Time correlation on STS%d to SYNC0 signal", n), 500, -1000., 4000.);
00075       lastSync[n] = 0;
00076       for (int j=0;j<NX_HISTORY;j++) lastNx[n][j] = 0;
00077    }
00078 
00079 
00080    /* simple SPADIC online JAM:*/
00081    TString obname;
00082    TString obtitle;
00083    TString foldername;
00084 
00085    UInt_t sid, ch;
00086 
00087    for (sid = 1; sid < MAX_SPADIC; sid++) {
00088 
00089       obname.Form("Spadic_%d/Spadic%d_2D", sid, sid);
00090       obtitle.Form("All channels of spadic %d", sid);
00091       fSpadic_2D[sid] = MakeTH2('I', obname.Data(), obtitle.Data(),
00092                       TRACE_SIZE, 0, TRACE_SIZE,  NUM_SPADIC_CHA, 0, NUM_SPADIC_CHA);
00093 
00094       obname.Form("Spadic_%d/Spadic%d_2Dcomp", sid, sid);
00095       obtitle.Form("Compensated channels of spadic %d", sid);
00096       fSpadic_2Dcomp[sid] = MakeTH2('I', obname.Data(), obtitle.Data(),
00097                TRACE_SIZE, 0, TRACE_SIZE,  NUM_SPADIC_CHA, 0, NUM_SPADIC_CHA);
00098                
00099       obname.Form("Spadic_%d/Spadic%d_2Dcompswap", sid, sid);
00100       obtitle.Form("Compensated swapped channels of spadic %d", sid);
00101       fSpadic_2DcompSwap[sid] = MakeTH2('I', obname.Data(), obtitle.Data(),
00102                TRACE_SIZE, 0, TRACE_SIZE,  NUM_SPADIC_CHA, 0, NUM_SPADIC_CHA);
00103                
00104       obname.Form("Spadic_%d/Spadic%2d_Intensity", sid, sid);
00105       obtitle.Form("Intensity (integral) of spadic %d signals", sid);
00106       fSpadic_Intensity[sid] = MakeTH1('I', obname.Data(), obtitle.Data(), 1000, 0, 3000);
00107 
00108       obname.Form("Spadic%d_IntensityGate", sid);
00109       obtitle.Form("Peak defining gate %d", sid);
00110       fSpadic_cond[sid] = MakeWinCond(obname.Data(), 500, 5000, fSpadic_Intensity[sid]->GetName());
00111 
00112       obname.Form("Spadic_%d/Spadic%d_SHAPE", sid, sid);
00113       obtitle.Form("Average pulse shape of spadic %d", sid);
00114       fSpadic_shape[sid] = MakeTH1('D', obname.Data(), obtitle.Data(), TRACE_SIZE, 0, TRACE_SIZE);
00115 
00116       obname.Form("Spadic_%d/Spadic%d_SHAPEcnt", sid, sid);
00117       obtitle.Form("Counts for average pulse shape of spadic %d", sid);
00118       fSpadic_shapecnt[sid] = MakeTH1('D', obname.Data(), obtitle.Data(), TRACE_SIZE, 0, TRACE_SIZE);
00119 
00120       obname.Form("Spadic_%d/Spadic%d_SHAPE_pi", sid, sid);
00121       obtitle.Form("Average pulse shape of spadic %d (pion)", sid);
00122       fSpadic_pi_shape[sid] = MakeTH1('D', obname.Data(), obtitle.Data(), TRACE_SIZE, 0, TRACE_SIZE);
00123 
00124       obname.Form("Spadic_%d/Spadic%d_SHAPEcnt_pi", sid, sid);
00125       obtitle.Form("Counts for average pulse shape of spadic %d (pion)", sid);
00126       fSpadic_pi_shapecnt[sid] = MakeTH1('D', obname.Data(), obtitle.Data(), TRACE_SIZE, 0, TRACE_SIZE);
00127 
00128       obname.Form("Spadic_%d/Spadic%d_SHAPE_el", sid, sid);
00129       obtitle.Form("Average pulse shape of spadic %d (electron)", sid);
00130       fSpadic_el_shape[sid] = MakeTH1('D', obname.Data(), obtitle.Data(), TRACE_SIZE, 0, TRACE_SIZE);
00131 
00132       obname.Form("Spadic_%d/Spadic%d_SHAPEcnt_el", sid, sid);
00133       obtitle.Form("Counts for average pulse shape of spadic %d (electron)", sid);
00134       fSpadic_el_shapecnt[sid] = MakeTH1('D', obname.Data(), obtitle.Data(), TRACE_SIZE, 0, TRACE_SIZE);
00135       
00136                // peak heightfrom bin
00137        obname.Form("Spadic_%d/Spadic%d_PeakHeight", sid, sid);
00138        obtitle.Form("Spadic %d peak height", sid);
00139        fSpadic_peak[sid] = MakeTH1('I', obname.Data(), obtitle.Data(), 255, 0., 255., "pulseheight");
00140 
00141          // mean position from window
00142        obname.Form("Spadic_%d/Spadic%d_PeakPos", sid, sid);
00143        obtitle.Form("Spadic %d peak position", sid);
00144        fSpadic_meanpos[sid] = MakeTH1('I', obname.Data(), obtitle.Data(), TRACE_SIZE, 0., TRACE_SIZE, "time (40ns)");
00145       
00146        obname.Form("Spadic%d_PeakGate", sid);
00147        obtitle.Form("Peak defining gate %d", sid);
00148        fSpadic_peakcond[sid] = MakeWinCond(obname.Data(), 7.5, 12.5, fSpadic_meanpos[sid]->GetName());
00149       
00150       for (ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00151          // trace histogram:
00152          obname.Form("Spadic_%d/Channel%d/Spadic%d_ch%d_trace", sid, ch, sid, ch);
00153          obtitle.Form("Trace %2d  %2d", sid, ch);
00154          fSpadic_trace[sid][ch] = MakeTH1('I', obname.Data(), obtitle.Data(),
00155                TRACE_SIZE, 0, TRACE_SIZE, "time (40ns)");
00156 
00157          obname.Form("Spadic_%d/Channel%d/Spadic%d_ch%d_compens", sid, ch, sid, ch);
00158          obtitle.Form("Compensated %2d  %2d", sid, ch);
00159          fSpadic_compens[sid][ch] = MakeTH1('F', obname.Data(), obtitle.Data(),
00160                TRACE_SIZE, 0, TRACE_SIZE, "time (40ns)");
00161       }
00162 
00163       obname.Form("Traces_Spadic%d", sid);
00164       pSpadic_traces[sid] = GetPicture(obname.Data());
00165       if (pSpadic_traces[sid] == 0) {
00166          obtitle.Form("Pulse Traces of Spadic %d", sid);
00167          pSpadic_traces[sid] = new TGo4Picture(obname.Data(), obtitle.Data());
00168          pSpadic_traces[sid]->SetDivision(NUM_SPADIC_CHA / 4, 4);
00169 
00170          for (ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00171             pSpadic_traces[sid]->Pic(ch / 4, ch % 4)->AddObject(fSpadic_trace[sid][ch]);
00172             pSpadic_traces[sid]->Pic(ch / 4, ch % 4)->SetAutoScale(kFALSE);
00173             pSpadic_traces[sid]->Pic(ch / 4, ch % 4)->SetRangeY(0, 255);
00174          }
00175          
00176          AddPicture(pSpadic_traces[sid]);
00177       }
00178 
00179    }
00180    
00181    if (GetPicture("AllSpadics")==0) {
00182       TGo4Picture* pic = new TGo4Picture("AllSpadics", "Superposition of all shapes");
00183       int numy = 4;
00184       int numx = (MAX_SPADIC-1) / numy;
00185       if (numx*numy < (MAX_SPADIC - 1)) numx++;
00186       pic->SetDivision(numy, numx);
00187       
00188       for (sid = 1; sid < MAX_SPADIC; sid++) {
00189          int nx = (sid-1) / numy;
00190          int ny = (sid-1) % numy;
00191          
00192          pic->Pic(ny, nx)->SetAutoScale(kFALSE);
00193          pic->Pic(ny, nx)->SetRangeY(0, 255);
00194          
00195          for (ch = 0; ch < NUM_SPADIC_CHA; ch++) 
00196             pic->Pic(ny, nx)->AddObject(fSpadic_trace[sid][ch]);
00197       }
00198       AddPicture(pic);
00199    }
00200    
00201     if (GetPicture("SpadicsPulses")==0) {
00202        TGo4Picture* pic = new TGo4Picture("SpadicsPulses", "Spadic pulses");
00203        pic->SetDivision(MAX_SPADIC-1, 3);
00204        for (sid = 1; sid < MAX_SPADIC; sid++) {
00205           pic->Pic(sid-1, 0)->AddObject(fSpadic_shape[sid]);
00206           pic->Pic(sid-1, 1)->AddObject(fSpadic_peak[sid]);
00207           pic->Pic(sid-1, 2)->AddObject(fSpadic_meanpos[sid]);
00208           pic->Pic(sid-1, 2)->AddCondition(fSpadic_peakcond[sid]);
00209        }
00210        AddPicture(pic);
00211     }
00212 
00213     if (GetPicture("SpadicPulsesIds")==0) {
00214        TGo4Picture* pic = new TGo4Picture("SpadicPulsesIds", "Spadic pulses identification");
00215        pic->SetDivision(MAX_SPADIC-1, 3);
00216        for (sid = 1; sid < MAX_SPADIC; sid++) {
00217           pic->Pic(sid-1, 0)->AddObject(fSpadic_shape[sid]);
00218           pic->Pic(sid-1, 1)->AddObject(fSpadic_pi_shape[sid]);
00219           pic->Pic(sid-1, 2)->AddObject(fSpadic_el_shape[sid]);
00220        }
00221        AddPicture(pic);
00222     }
00223 
00224 
00225    if (GetPicture("CompensSpadics")==0) {
00226       TGo4Picture* pic = new TGo4Picture("CompensSpadics", "Superposition of all shapes");
00227       int numy = 4;
00228       int numx = (MAX_SPADIC-1) / numy;
00229       if (numx*numy < (MAX_SPADIC - 1)) numx++;
00230       pic->SetDivision(numy, numx);
00231       
00232       for (sid = 1; sid < MAX_SPADIC; sid++) {
00233          int nx = (sid-1) / numy;
00234          int ny = (sid-1) % numy;
00235          
00236          pic->Pic(ny, nx)->SetAutoScale(kFALSE);
00237          pic->Pic(ny, nx)->SetRangeY(-20, 60);
00238          
00239          for (ch = 0; ch < NUM_SPADIC_CHA; ch++) 
00240             pic->Pic(ny, nx)->AddObject(fSpadic_compens[sid][ch]);
00241       }
00242       AddPicture(pic);
00243    }
00244 
00245    if (GetPicture("Muenster")==0) {
00246       TGo4Picture* pic = new TGo4Picture("Muenster", "Combination of muenster spadics together");
00247       pic->SetDivision(2, 2);
00248       pic->Pic(0, 0)->AddObject(fSpadic_2D[3], "lego2");
00249       pic->Pic(0, 0)->SetRangeZ(0, 255);
00250       pic->Pic(0, 0)->SetAutoScale(kFALSE);
00251          
00252       pic->Pic(0, 1)->AddObject(fSpadic_2D[2], "lego2");
00253       pic->Pic(0, 1)->SetRangeZ(0, 255);
00254       pic->Pic(0, 1)->SetAutoScale(kFALSE);
00255       
00256       pic->Pic(1, 0)->AddObject(fSpadic_2D[1], "lego2");
00257       pic->Pic(1, 0)->SetRangeZ(0, 255);
00258       pic->Pic(1, 0)->SetAutoScale(kFALSE);
00259       
00260       pic->Pic(1, 1)->AddObject(fSpadic_2D[6], "lego2");
00261       pic->Pic(1, 1)->SetRangeZ(0, 255);
00262       pic->Pic(1, 1)->SetAutoScale(kFALSE);
00263       
00264       AddPicture(pic);
00265    }
00266 
00267    if (GetPicture("MuensterComp")==0) {
00268       TGo4Picture* pic = new TGo4Picture("MuensterComp", "Combination of Muenster spadics");
00269       pic->SetDivision(2, 2);
00270       pic->Pic(0, 0)->AddObject(fSpadic_2Dcomp[3], "lego2");
00271       pic->Pic(0, 0)->SetRangeZ(-10, 100);
00272       pic->Pic(0, 0)->SetAutoScale(kFALSE);
00273 
00274       
00275       pic->Pic(0, 1)->AddObject(fSpadic_2Dcomp[2], "lego2");
00276       pic->Pic(0, 1)->SetRangeZ(-10, 100);
00277       pic->Pic(0, 1)->SetAutoScale(kFALSE);
00278       
00279       pic->Pic(1, 0)->AddObject(fSpadic_2Dcomp[1], "lego2");
00280       pic->Pic(1, 0)->SetRangeZ(-10, 100);
00281       pic->Pic(1, 0)->SetAutoScale(kFALSE);
00282       
00283       pic->Pic(1, 1)->AddObject(fSpadic_2Dcomp[6], "lego2");
00284       pic->Pic(1, 1)->SetRangeZ(-10, 100);
00285       pic->Pic(1, 1)->SetAutoScale(kFALSE);
00286       
00287       AddPicture(pic);
00288    }
00289 
00290    if (GetPicture("MuensterCompSwap")==0) {
00291       TGo4Picture* pic = new TGo4Picture("MuensterCompSwap", "Swapped combination of Muenster spadics");
00292       pic->SetDivision(2, 2);
00293       pic->Pic(0, 0)->AddObject(fSpadic_2Dcomp[3], "lego2");
00294       pic->Pic(0, 0)->SetRangeZ(-10, 100);
00295       pic->Pic(0, 0)->SetAutoScale(kFALSE);
00296 
00297       
00298       pic->Pic(0, 1)->AddObject(fSpadic_2DcompSwap[1], "lego2");
00299       pic->Pic(0, 1)->SetRangeZ(-10, 100);
00300       pic->Pic(0, 1)->SetAutoScale(kFALSE);
00301       
00302       pic->Pic(1, 0)->AddObject(fSpadic_2Dcomp[2], "lego2");
00303       pic->Pic(1, 0)->SetRangeZ(-10, 100);
00304       pic->Pic(1, 0)->SetAutoScale(kFALSE);
00305       
00306       pic->Pic(1, 1)->AddObject(fSpadic_2DcompSwap[6], "lego2");
00307       pic->Pic(1, 1)->SetRangeZ(-10, 100);
00308       pic->Pic(1, 1)->SetAutoScale(kFALSE);
00309       
00310       AddPicture(pic);
00311    }
00312 
00313 
00314 
00315    // 1182 histo
00316    for (int n=0;n<8;n++) {
00317       obname.Form("1182/1182_channel%d", n);
00318       obtitle.Form("1182 Channel %d", n);
00319       f1182h[n] = MakeTH1('I', obname.Data(), obtitle.Data(), 1024, 0, 4096.);
00320    }
00321 
00322    fCh_Pb = MakeTH2('I', "1182/Ch_Pb", "Cherenkov - Pb", 512, 0., 4096., 512, 0., 4096., "Cherenkov", "Pb");
00323    fS1_Pb = MakeTH2('I', "1182/S1_Pb", "1182  S1_Pb", 512, 0., 4096., 512, 0., 4096., "S1", "Pb");
00324    fS1_S2 = MakeTH2('I', "1182/S1_S2", "1182  S1_S2", 512, 0., 4096., 512, 0., 4096., "S1", "S2");
00325    fS1_S3 = MakeTH2('I', "1182/S1_S3", "1182  S1_S3", 512, 0., 4096., 512, 0., 4096., "S1", "S3");
00326    fS2_S3 = MakeTH2('I', "1182/S2_S3", "1182  S2_S3", 512, 0., 4096., 512, 0., 4096., "S2", "S3");
00327    
00328    
00329    Double_t pion_pnts[3][2] = { {713, 1198}, {815, 826}, {614, 704} };
00330    fPionCond = MakePolyCond("PionCond", 3, pion_pnts);
00331    fPionCond->SetHistogram(fCh_Pb->GetName());
00332 
00333    Double_t electron_pnts[4][2] = { {834, 1644}, {819, 2041}, {1083, 2102}, {1091, 1704} };
00334    fElectronCond = MakePolyCond("ElectronCond", 4, electron_pnts);
00335    fElectronCond->SetHistogram(fCh_Pb->GetName());
00336 
00337    
00338    // 1183 histo
00339    for (int n=0;n<8;n++) {
00340       obname.Form("1183/1183_channel%d", n);
00341       obtitle.Form("1183 Channel %d", n);
00342       f1183h[n] = MakeTH1('I', obname.Data(), obtitle.Data(), 1024, 0, 8192.);
00343    }
00344 
00345      
00346     /*********** MADCs *************/
00347    for (int mad = 0; mad < MAX_MADC; mad++) {
00348 
00349       obname.Form("MADC%d/MADC%d_sample", mad,mad);
00350       obtitle.Form("Sample of MADC%d readout", mad);
00351       fMadc_trace[mad]=MakeTH1('I', obname.Data(), obtitle.Data(), N_MADC_CHA, 0, N_MADC_CHA,"channel No.");
00352 
00353       for (int ch = 0; ch < N_MADC_CHA; ch++) {
00354          obname.Form("MADC%d/MADC%d_ch%d", mad,mad,ch);
00355          obtitle.Form("MADC %d Channel %d", mad, ch);
00356          fMadc_adc[mad][ch] = MakeTH1('I', obname.Data(), obtitle.Data(), 0x3FF, 0, 0x3FF);
00357 
00358          obname.Form("MADC%d/MADC%d_ch%d_pion", mad,mad,ch);
00359          obtitle.Form("MADC %d Channel %d pion", mad, ch);
00360          fMadc_pion[mad][ch] = MakeTH1('I', obname.Data(), obtitle.Data(), 0x3FF, 0, 0x3FF);
00361 
00362          obname.Form("MADC%d/MADC%d_ch%d_electron", mad,mad,ch);
00363          obtitle.Form("MADC %d Channel %d electron", mad, ch);
00364          fMadc_electron[mad][ch] = MakeTH1('I', obname.Data(), obtitle.Data(), 0x3FF, 0, 0x3FF);
00365 
00366       }
00367 
00368       obname.Form("MADC%d_overview", mad);
00369       pMadc_overview[mad] = GetPicture(obname.Data());
00370       if (pMadc_overview[mad] == 0) {
00371          obtitle.Form("Channels overview MADC %2d", mad);
00372          pMadc_overview[mad] = new TGo4Picture(obname.Data(), obtitle.Data());
00373          pMadc_overview[mad]->SetDivision(8, 4);
00374          for(int y=0; y<8;++y)
00375             for(int x=0;x<4;++x) {
00376                pMadc_overview[mad]->Pic(y, x)->AddObject(fMadc_adc[mad][4*y+x]);
00377                pMadc_overview[mad]->Pic(y, x)->SetFillAtt(5, 3001);
00378                pMadc_overview[mad]->Pic(y, x)->SetRangeX(0, 200);
00379                pMadc_overview[mad]->Pic(y, x)->SetLogScale(1, 1);
00380             }
00381          AddPicture(pMadc_overview[mad]);
00382       }
00383 
00384       obname.Form("MADC%d_pion", mad);
00385       if (GetPicture(obname.Data()) == 0) {
00386          obtitle.Form("Pion channels overview MADC %2d", mad);
00387          TGo4Picture* pic = new TGo4Picture(obname.Data(), obtitle.Data());
00388          pic->SetDivision(8, 4);
00389          for(int y=0; y<8;++y)
00390             for(int x=0;x<4;++x) {
00391                pic->Pic(y, x)->AddObject(fMadc_pion[mad][4*y+x]);
00392                pic->Pic(y, x)->SetFillAtt(5, 3001);
00393                pic->Pic(y, x)->SetRangeX(0, 200);
00394                pic->Pic(y, x)->SetLogScale(1, 1);
00395             }
00396          AddPicture(pic);
00397       }
00398 
00399 
00400       obname.Form("MADC%d_electron", mad);
00401       if (GetPicture(obname.Data()) == 0) {
00402          obtitle.Form("Electron channels overview MADC %2d", mad);
00403          TGo4Picture* pic = new TGo4Picture(obname.Data(), obtitle.Data());
00404          pic->SetDivision(8, 4);
00405          for(int y=0; y<8;++y)
00406             for(int x=0;x<4;++x) {
00407                pic->Pic(y, x)->AddObject(fMadc_electron[mad][4*y+x]);
00408                pic->Pic(y, x)->SetFillAtt(5, 3001);
00409                pic->Pic(y, x)->SetRangeX(0, 200);
00410                pic->Pic(y, x)->SetLogScale(1, 1);
00411             }
00412          AddPicture(pic);
00413       }
00414 
00415    }
00416    printf("Histograms created \n");
00417    fflush ( stdout);
00418 
00419    /* some histograms for MADC data:*/
00420 
00421 /*   
00422    // si strip fifo contents:
00423    obname.Form("MADC/SiStrip/Fifo0_Trace");
00424    obtitle.Form("SiStrip Fifo 0 channels trace");
00425    fMadc_si_fifo0_trace= MakeTH1('I', obname.Data(), obtitle.Data(),
00426                   N_SISTRIP_CHA, 0, N_SISTRIP_CHA,"channel number");
00427    obname.Form("MADC/SiStrip/Fifo0_Acc");
00428    obtitle.Form("SiStrip Fifo 0 channels accumulated");
00429    fMadc_si_fifo0_acc=MakeTH1('I', obname.Data(), obtitle.Data(),
00430                   N_SISTRIP_CHA, 0, N_SISTRIP_CHA,"channel number");
00431    obname.Form("MADC/SiStrip/Fifo1_Trace");
00432    obtitle.Form("SiStrip Fifo 1 channels trace");
00433    fMadc_si_fifo1_trace=MakeTH1('I', obname.Data(), obtitle.Data(),
00434                   N_SISTRIP_CHA, 0, N_SISTRIP_CHA,"channel number");
00435    obname.Form("MADC/SiStrip/Fifo1_Acc");
00436    obtitle.Form("SiStrip Fifo 1 channels accumulated");
00437 
00438    fMadc_si_fifo1_acc= MakeTH1('I', obname.Data(), obtitle.Data(),
00439                   N_SISTRIP_CHA, 0, N_SISTRIP_CHA,"channel number");
00440    
00441    obname.Form("MADC/SiStrip/Pedestal_Trace");
00442    obtitle.Form("SiStrip pedestals trace");
00443    fMadc_si_ped_trace= MakeTH1('I', obname.Data(), obtitle.Data(),
00444                   N_SISTRIP_CHA, 0, N_SISTRIP_CHA,"channel number");
00445    obname.Form("MADC/SiStrip/Pedestal_Acc");
00446    obtitle.Form("SiStrip pedestals accumulated");
00447    fMadc_si_ped_acc=MakeTH1('I', obname.Data(), obtitle.Data(),
00448                   N_SISTRIP_CHA, 0, N_SISTRIP_CHA,"channel number");
00449 */
00450 
00451 }
00452 
00453 //***********************************************************
00454 TCernNov10Proc::~TCernNov10Proc()
00455 {
00456 }
00457 
00458 bool TCernNov10Proc::ReadMapmtGeometry(const char* fname)
00459 {
00460    for (int ncell=0; ncell<NUM_MAPMP_CELLS; ncell++) {
00461       fMAPMTCells[ncell].xbin = 0.;
00462       fMAPMTCells[ncell].ybin = 0.;
00463       fMAPMTCells[ncell].xcoord = 0.;
00464       fMAPMTCells[ncell].ycoord = 0.;
00465       fMAPMTCells[ncell].mapmt = 0;
00466       fMAPMTCells[ncell].pixel = 0;
00467       fMAPMTCells[ncell].feb = 0;
00468       fMAPMTCells[ncell].channel = 0;
00469    }
00470 
00471    std::ifstream f(fname);
00472    if (!f)  {
00473       printf("MAPMT geometry file not found %s\n", fname);
00474       return false;
00475    }
00476 
00477    char sbuf[1024];
00478 
00479    // skip first two lines
00480    f.getline(sbuf, sizeof(sbuf));
00481    f.getline(sbuf, sizeof(sbuf));
00482 
00483    int nread = 0;
00484 
00485    while (!f.eof()) {
00486       f.getline(sbuf, sizeof(sbuf));
00487 
00488       if (strlen(sbuf)==0) break;
00489 
00490       int mapmt(0), pixel(0), feb(0), channel(0);
00491       float xcoord(0.), ycoord(0.), xbin(0.), ybin(0.);
00492 
00493       if (sscanf(sbuf, "%d %d %d %d %f %f %f %f", &mapmt, &pixel, &feb, &channel, &xcoord, &ycoord, &xbin, &ybin)!=8) {
00494          printf("MAPMT read line %d format error %s\n", nread, sbuf);
00495          return false;
00496       }
00497 
00498       int ncell = channel + (feb==2 ? 128 : 0);
00499 
00500 
00501       /* this was fix for wrong data in first geometry file */
00502 //      if (mapmt == 2) ncell+=64;
00503 //      if (mapmt == 4) ncell-=64;
00504 
00505       if ((ncell<0) || (ncell>=NUM_MAPMP_CELLS)) {
00506          printf("MAPMT read wrong cell address %d in line %d\n", ncell, nread);
00507          return false;
00508       }
00509 
00510       printf("ncell = %d xbin = %3.1f ybin = %3.1f\n", ncell, xbin, ybin);
00511 
00512       fMAPMTCells[ncell].xbin = xbin;
00513       fMAPMTCells[ncell].ybin = ybin;
00514       fMAPMTCells[ncell].xcoord = xcoord;
00515       fMAPMTCells[ncell].ycoord = ycoord;
00516       fMAPMTCells[ncell].mapmt = mapmt;
00517       fMAPMTCells[ncell].pixel = pixel;
00518       fMAPMTCells[ncell].feb = feb;
00519       fMAPMTCells[ncell].channel = channel;
00520 
00521       nread++;
00522    }
00523 
00524    if (nread!=NUM_MAPMP_CELLS) {
00525       printf("MAPMT geometry read %d lines, expected %d\n", nread, NUM_MAPMP_CELLS);
00526       return false;
00527    }
00528 
00529    printf("Load MAPMT geometry from file %s done\n", fname);
00530 
00531    return true;
00532 }
00533 
00534 void TCernNov10Proc::ProcessRocMsg(roc::Message* msg)
00535 {
00536    // this is a place for nx-specific code.
00537    // Here coming hits which are not involved in any kind of calibration procedure
00538 
00539    if ((msg->getRocNumber() == 1) || (msg->getRocNumber() == 2)) {
00540       
00541       int stsid = msg->getRocNumber()-1;
00542 
00543       uint64_t fulltm = msg->getMsgFullTime(ROC[msg->getRocNumber()].fCurrEpoch);
00544       
00545       if (msg->isSyncMsg()) {
00546          
00547 //         printf("SYNC %10lu  diff %lu\n", fulltm, fulltm - lastNx);
00548          lastSync[stsid] = fulltm;
00549          for (int j=0;j<NX_HISTORY;j++) {
00550             if (lastNx[stsid][j]>fulltm)
00551                fSTStm[stsid]->Fill(roc::Message::CalcDistance(fulltm, lastNx[stsid][j]));
00552             else 
00553                fSTStm[stsid]->Fill(-1.*roc::Message::CalcDistance(lastNx[stsid][j], fulltm));
00554          }
00555       } else
00556       if (msg->isHitMsg()) {
00557          for (int j=0;j<NX_HISTORY-1;j++)
00558             lastNx[stsid][j] = lastNx[stsid][j+1];
00559          lastNx[stsid][NX_HISTORY-1] = fulltm;
00560 //         printf("NX %10lu  diff %lu\n", fulltm, fulltm - lastSync);
00561          uint64_t dist = roc::Message::CalcDistance(lastSync[stsid], fulltm);
00562          fSTStm[stsid]->Fill(1*dist);
00563       }
00564       
00565    } else
00566 
00567 
00568    if ((msg->getRocNumber() == fCernNov10Par->mapmtRoc) && (msg->isHitMsg())) {
00569 
00570       int ncell(0);
00571 
00572       switch (msg->getNxNumber()) {
00573          case 0: ncell = msg->getNxChNum(); break;
00574          case 2: ncell = 128 + msg->getNxChNum(); break;
00575          default: return; // ignore any other possible nxyters
00576       }
00577       
00578       
00579       uint64_t fulltm = msg->getMsgFullTime(ROC[fCernNov10Par->mapmtRoc].fCurrEpoch);
00580       
00581       uint64_t dist = roc::Message::CalcDistance(ROC[fCernNov10Par->mapmtRoc].fLastSyncTm[0], fulltm);
00582 
00583       fMAPMT_tshift->Fill(dist);
00584 
00585       // calculate corrected (inverse) ADC value, mapmtPedestal can be changed in parameter editor in the Go4 GUI
00586       int rADC = fCernNov10Par->mapmtPedestal - msg->getNxAdcValue();
00587 
00588       // fill histogram with all MAPMT ADC values to have reference for condition
00589       fMAPMT_adc->Fill(rADC);
00590 
00591       double xbin = fMAPMTCells[ncell].xbin;
00592       double ybin = fMAPMTCells[ncell].ybin;
00593 
00594       fCernNov10Event->fMAPM_X[ncell]=xbin;                     // store mapped info to ROOT tree
00595       fCernNov10Event->fMAPM_Y[ncell]=ybin;
00596       fCernNov10Event->fMAPM_Integral[ncell]=rADC;
00597       fCernNov10Event->fMAPM_DeltaT[ncell]=dist;
00598 
00599 //      printf("GET HIT ncell = %d xbin = %3.1f ybin = %3.1f\n", ncell, xbin, ybin);
00600 
00601        // if condition is ok, fill XY histogram.
00602        // Condition range can be modified in the condition editor in the Go4 GUI
00603        if (fMAPMT_cond->Test(rADC) && fMAPMT_tcond->Test(dist)) {
00604           fMAPMT_entry->Fill(xbin, ybin);
00605           fMAPMT_integral->Fill(xbin, ybin, rADC);
00606 
00607           int nbin = fMAPMT_entry->GetBin(fMAPMT_entry->GetXaxis()->FindBin(xbin), fMAPMT_entry->GetYaxis()->FindBin(ybin));
00608 
00609           double entries = fMAPMT_entry->GetBinContent(nbin);
00610           double integral = fMAPMT_integral->GetBinContent(nbin);
00611           fMAPMT_mean->SetBinContent(nbin, (entries <= 0.) ? 0. : integral/entries);
00612        }
00613     }
00614 }
00615 
00616 
00617 //-----------------------------------------------------------
00618 // event function
00619 Bool_t TCernNov10Proc::BuildEvent(TGo4EventElement* outevnt)
00620 {
00621    fIsPion = kFALSE;
00622    fIsElectron = kFALSE;
00623    
00624    fDoStopAnalysis = false;
00625 
00626    fCernNov10Event= dynamic_cast<TCernNov10Event*>(outevnt);
00627    if(fCernNov10Event==0) {
00628       GO4_STOP_ANALYSIS_MESSAGE("**** TCernNov10Proc: Fatal error: output event is not a TCernNov10Event!!! STOP GO4");
00629    }
00630 
00631 
00632    
00633    Bool_t res = TRocProc::BuildEvent(outevnt);
00634 
00635    if (fDoStopAnalysis) {
00636       
00637       for (UInt_t sid = 1; sid < MAX_SPADIC; sid++) {
00638          for (UInt_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00639             TGo4Analysis::Instance()->SendObjectToGUI(fSpadic_trace[sid][ch]);
00640             TGo4Analysis::Instance()->SendObjectToGUI(fSpadic_compens[sid][ch]);
00641          }
00642          TGo4Analysis::Instance()->SendObjectToGUI(fSpadic_2Dcomp[sid]);
00643          TGo4Analysis::Instance()->SendObjectToGUI(fSpadic_2DcompSwap[sid]);
00644       }
00645       
00646       TGo4Analysis::Instance()->SetRunning(kFALSE);
00647    }
00648    
00649    return res;
00650 
00651 }
00652 
00653 void TCernNov10Proc::ProcessSubevent(TGo4MbsSubEvent* subevt)
00654 {
00655    if (subevt->GetProcid() == roc::proc_Triglog) {
00656       Int_t sync_num = subevt->Data(0);
00657 
00658       // just to see that sync number is changing
00659       fVulomSyncs->Fill(sync_num % 65536);
00660 
00661       fCernNov10Event->fVulomSyncNumber=sync_num;
00662 
00663       int indx = 1;
00664 
00665       // accumulate scaler counters, while every event all scalers are reset
00666       for (int nscaler = 0; nscaler < NUM_SCALERS; nscaler++)
00667          for (int n = 0; n<16; n++)
00668                          {
00669                                  Int_t val=subevt->Data(indx++);
00670                                  fVulomScalers[nscaler]->Fill(n,val);
00671                                  fCernNov10Event->fVulomScaler[nscaler][n]=val;
00672                          }
00673       return;
00674    }
00675 
00676    if (subevt->GetProcid() == roc::proc_TRD_MADC) {
00677       // TRD MADC data + silicon strips + cherenkov
00678            ProcessMADCSub(subevt);
00679            return;
00680    }
00681 
00682    if (subevt->GetProcid() == roc::proc_TRD_Spadic) {
00683       // TRD Spadic data
00684            ProcessSpadic(subevt);
00685       return;
00686    }
00687 }
00688 
00689 
00690 void TCernNov10Proc::ProcessSpadic(TGo4MbsSubEvent* psubevt)
00691 {
00692    UInt_t sid = psubevt->GetSubcrate(); // susibo id number
00693    if (sid > MAX_SPADIC) {
00694       cout << "**** TSpadicProc: Skipping subevent with invalid Susibo id "
00695             << sid << ", maximum allowed is " << MAX_SPADIC << endl;
00696       return;
00697    }
00698 
00699    spadic::Message mess((uint8_t*) psubevt->GetDataField());
00700    if (!mess.CheckMessage()) {
00701        cout  << "**** TSpadicProc: Skipping subevent with invalid message, sid: " << sid << endl;
00702        return;
00703    }
00704    if (__SPADIC_DEBUG__) {
00705        cout << " - Message sid:" << sid << ", status:" << mess.GetStatusNumber();
00706        cout << ", evid:" << mess.GetEventIDNumber() << ", ts:" << mess.GetTimeStamp() << endl;
00707    }
00708 
00709    double AverTrace[TRACE_SIZE];
00710    for (int n=0;n<TRACE_SIZE;n++) AverTrace[n] = 0.;
00711         
00712 
00713    for (UInt_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00714       // generate sample trace histograms:
00715       TH1* tracehis = fSpadic_trace[sid][ch]; // the original sample
00716       for (UInt_t bin = 0; bin < TRACE_SIZE; bin++) {
00717          uint8_t val = mess.Sample(ch, bin);
00718          AverTrace[bin] += val;
00719          tracehis->SetBinContent(bin + 1, (int) val);
00720          fCernNov10Event->fSpadicPulse[sid][ch][bin]=val;
00721          fSpadic_2D[sid]->SetBinContent((ch+1)*(TRACE_SIZE+2) + bin + 1, val);
00722       }
00723    }// for ch
00724 
00725    for (int n=0;n<TRACE_SIZE;n++) AverTrace[n] = AverTrace[n] / NUM_SPADIC_CHA;
00726 
00727    unsigned maxch1(0), maxch2(0);
00728    double maxsum1(0), maxsum2(0);
00729 
00730    // find two most powerfull channels
00731    for (UInt_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00732       double sum = 0;
00733       for (UInt_t bin = 0; bin < TRACE_SIZE-1; bin++) 
00734          sum += (mess.Sample(ch, bin) - AverTrace[bin]);
00735       if (sum>maxsum1) {
00736          maxsum2 = maxsum1; 
00737          maxch2 = maxch1;
00738          maxsum1 = sum;
00739          maxch1 = ch;
00740       } else
00741       if (sum>maxsum2) {
00742          maxsum2 = sum; 
00743          maxch2 = ch;
00744       }
00745    }
00746    
00747    // calculate average without two maximum channel
00748    for (int n=0;n<TRACE_SIZE;n++) AverTrace[n] = 0;
00749    for (UInt_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00750       if ((ch==maxch1) || (ch==maxch2)) continue;
00751       for (UInt_t bin = 0; bin < TRACE_SIZE; bin++)
00752          AverTrace[bin] += mess.Sample(ch, bin);
00753    }
00754    
00755    for (int n=0;n<TRACE_SIZE;n++) AverTrace[n] = AverTrace[n] / (NUM_SPADIC_CHA - 2.);
00756 
00757    for (UInt_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00758       // generate compensated sample trace histograms:
00759       TH1* tracehis = fSpadic_compens[sid][ch]; 
00760       // tracehis->Reset("");
00761 
00762       double maxh(0), pmax(0), intens(0);
00763 
00764       for (unsigned bin = 0; bin < TRACE_SIZE; bin++) {
00765             double val = 1.*mess.Sample(ch, bin) - AverTrace[bin];
00766             if (bin == TRACE_SIZE - 1) val = 0.;
00767             
00768             if (val>maxh) { maxh = val; pmax = bin; }
00769             tracehis->SetBinContent(bin + 1, val);
00770             if (val>0) intens+=val;
00771             
00772             fSpadic_2Dcomp[sid]->SetBinContent((ch+1)*(TRACE_SIZE+2) + bin + 1, val);
00773             fSpadic_2DcompSwap[sid]->SetBinContent((NUM_SPADIC_CHA-ch-1 +1)*(TRACE_SIZE+2) + bin + 1, val);
00774       }
00775 
00776       fSpadic_Intensity[sid]->Fill(intens);
00777 
00778       if (fSpadic_cond[sid]->Test(intens)) {
00779          fSpadic_peak[sid]->Fill(maxh);
00780          fSpadic_meanpos[sid]->Fill(pmax);
00781          
00782          if (fCernNov10Par->spadic_movie == (int)sid) fDoStopAnalysis = true;
00783          
00784          if (fSpadic_peakcond[sid]->Test(pmax))
00785             for (unsigned bin = 0; bin < TRACE_SIZE; bin++) {
00786                double val = fSpadic_compens[sid][ch]->GetBinContent(bin+1);
00787                double weight = fSpadic_shapecnt[sid]->GetBinContent(bin+1);
00788                double value0 = fSpadic_shape[sid]->GetBinContent(bin+1);
00789             
00790                fSpadic_shape[sid]->SetBinContent(bin+1, (value0 * weight + val) / (weight + 1.));
00791                fSpadic_shapecnt[sid]->SetBinContent(bin+1, weight+1.);
00792             }
00793              
00794          if (fIsPion) 
00795             for (unsigned bin = 0; bin < TRACE_SIZE; bin++) {
00796                double val = fSpadic_compens[sid][ch]->GetBinContent(bin+1);
00797                double weight = fSpadic_pi_shapecnt[sid]->GetBinContent(bin+1);
00798                double value0 = fSpadic_pi_shape[sid]->GetBinContent(bin+1);
00799             
00800                fSpadic_pi_shape[sid]->SetBinContent(bin+1, (value0 * weight + val) / (weight + 1.));
00801                fSpadic_pi_shapecnt[sid]->SetBinContent(bin+1, weight+1.);
00802             }
00803                 
00804           if (fIsElectron) 
00805              for (unsigned bin = 0; bin < TRACE_SIZE; bin++) {
00806                 double val = fSpadic_compens[sid][ch]->GetBinContent(bin+1);
00807                
00808                 double weight = fSpadic_el_shapecnt[sid]->GetBinContent(bin+1);
00809                 double value0 = fSpadic_el_shape[sid]->GetBinContent(bin+1);
00810             
00811                 fSpadic_el_shape[sid]->SetBinContent(bin+1, (value0 * weight + val) / (weight + 1.));
00812                 fSpadic_el_shapecnt[sid]->SetBinContent(bin+1, weight+1.);
00813              }
00814       }
00815             
00816    }// for ch
00817    
00818 //   if (fCernNov10Par->spadic_movie>0) {
00819 //      TGo4Analysis::Instance()->SendObjectToGUI(fSpadic_2Dcomp[sid]);
00820 //      TGo4Analysis::Instance()->SendObjectToGUI(fSpadic_2DcompSwap[sid]);
00821 //   }
00822 }
00823 
00824 
00825 void  TCernNov10Proc::ProcessMADCSub(TGo4MbsSubEvent* subevt)
00826 {
00827         Int_t *pdata = subevt->GetDataField();
00828         UInt_t lwords = subevt->GetIntLen();
00829         
00830 //      printf("TOTALLEN = %u\n", lwords);
00831         
00832         const int numtags = 7;
00833         
00834         const uint64_t tags[numtags] = { 0x3035357676353530ULL,  // v550
00835                                         0x3238313131313832ULL,  // 1182
00836                                         0x3338313131313833ULL,  // 1183
00837                                         0x3637313131313736ULL,  // 1176
00838                                         0x3164616d6d616431ULL,  // mad1
00839                                         0x3264616d6d616432ULL,  // mad2
00840                                         0x3364616d6d616433ULL   // mad3
00841                                       };
00842         Int_t* tagpos[numtags];
00843         Int_t taglen[numtags];
00844         
00845         for (int n=0;n<numtags;n++) {
00846            tagpos[n] = 0;
00847            taglen[n] = 0;
00848         }
00849         
00850         int lasttag = -1;
00851         
00852 //      Int_t* p0 = pdata;
00853         
00854         for (UInt_t cur = 0; cur < lwords; ++cur) {
00855            uint64_t* ptag = (uint64_t*) pdata;
00856            
00857 //         printf("DATA 0x%x\n", *pdata);
00858            
00859            bool find = false;
00860            
00861            for (int ntag=0;ntag<numtags;ntag++)
00862               if (*ptag == tags[ntag]) {
00863                  if (lasttag>=0) {
00864                     taglen[lasttag] = pdata - tagpos[lasttag];
00865                     lasttag = -1;
00866                  }
00867                  
00868                  if (tagpos[ntag]==0) {
00869 //                  printf("TAG %d  pos %u\n", ntag, pdata - p0);
00870                  
00871                     pdata+=2; cur+=1;
00872                     tagpos[ntag] = pdata;
00873                     lasttag = ntag;
00874                  } else {
00875                     printf("FORMAT ERROR found tag %lld twice\n", tags[ntag]);
00876                     pdata+=2; cur+=1;
00877                  }
00878 
00879                  find = true;
00880                  break;
00881 
00882               }
00883             
00884             if (!find) pdata++;
00885         }
00886 
00887         if (lasttag>=0) 
00888            taglen[lasttag] = pdata - tagpos[lasttag];
00889 /*      
00890         for (int ntag=0;ntag<numtags;ntag++)
00891            if (tagpos[ntag])
00892               printf("TAG %d POS %lu LEN %d\n", ntag, tagpos[ntag] - p0, taglen[ntag]);
00893         
00894         exit(1);
00895 */
00896 
00897         // actually process data in subroutines:
00898 
00899         if (tagpos[0] && taglen[0]) ProcessSi(tagpos[0], taglen[0]); // v550
00900         if (tagpos[1] && taglen[1]) Process1182(tagpos[1], taglen[1]); // 1182
00901         if (tagpos[2] && taglen[2]) Process1183(tagpos[2], taglen[2]); // 1183
00902         if (tagpos[3] && taglen[3]) ProcessTDC(tagpos[3], taglen[3]);  // 1176
00903         if (tagpos[4] && taglen[4]) ProcessMADC(0, tagpos[4], taglen[4]);  // mad1
00904         if (tagpos[5] && taglen[5]) ProcessMADC(1, tagpos[5], taglen[5]);  // mad2
00905         if (tagpos[6] && taglen[6]) ProcessMADC(2, tagpos[6], taglen[6]);  // mad3
00906 
00907 }
00908 
00909 
00910 void TCernNov10Proc::ProcessMADC(int i, int* pdata, int len) 
00911 {
00912 //      printf("MADC %d len %d  \n", i, len);
00913 
00914         if(i>=MAX_MADC) return;
00915         if(len<2) return;
00916         
00917         fMadc_trace[i]->Reset("");
00918         
00919         int* cursor= pdata;
00920         // skip event header:
00921         unsigned int header=*cursor;
00922         if ((header & 0xff000000) >> 24 != 0x40) 
00923            printf("madc(%d) header error: 0x%08x, expected 0x40nnnnnn \n",i,header);
00924         cursor++;
00925         for(int cnt=0;cnt<len-2;cnt++) {
00926                 unsigned int val=*cursor++;
00927                 
00928                 if ((val & 0xff000000) != 0x4000000)
00929                     printf("madc(%d) seq %u value 0x%08x error, expected 0x04nnnnnn\n", i,cnt, val);
00930 
00931                 unsigned chanid= (val >> 16) & 0x1f;
00932                 unsigned adc = val & 0x1fff;
00933                 
00934                 fMadc_trace[i]->Fill(chanid, adc);
00935                 
00936                 fMadc_adc[i][chanid]->Fill(adc);
00937                 if (fIsPion) fMadc_pion[i][chanid]->Fill(adc);
00938                 if (fIsElectron) fMadc_electron[i][chanid]->Fill(adc);
00939                 
00940                 fCernNov10Event->fMadc[i][chanid] = adc; // to output event, store to root tree
00941         }
00942         int trailer=*cursor;
00943         if ((trailer & 0xf0000000) >> 24 != 0xc0) 
00944            printf("madc(%d) trailer error: 0x%08x, expected 0xcnnnnnnnn \n",i, trailer);
00945 
00946 //      printf("madc(%d) trailer: 0x%08x \n",i,trailer);
00947 //#endif
00948 }
00949 
00950 void TCernNov10Proc::Process1182(int* pdata, int len) 
00951 {
00952    for(int ch=0; ch<8 ;++ch) fData1182[ch]=0;
00953 
00954    if (len == 6) { // this was original format
00955    
00956       pdata++;
00957       pdata++;
00958       for (int n=0;n<4;n++) {
00959          int val = *pdata++;
00960          
00961          int val_l = val & 0xffff;
00962          int val_h = val >> 16;
00963          
00964          fData1182[n*2]=val_l;
00965          f1182h[n*2]->Fill(val_l);
00966 
00967          fData1182[n*2+1]=val_h;
00968          f1182h[n*2+1]->Fill(val_h);
00969       }
00970    } else {
00971 
00972       if (len < 2 + 8) {
00973          cout <<"TCernNov10Proc:Process1182 data length"<< len << "not sufficient!" <<endl;
00974          return;
00975       }
00976    
00977       // skip event header:
00978       int header = *pdata++;
00979       if (L1182_DEBUG)  printf("1182 header:0x%0x \n",header);
00980 
00981       // skip status
00982       int status = *pdata++;
00983       if (L1182_DEBUG) 
00984          printf("1182 status:0x%0x :  \n"
00985               "        conversion complete    (bit0): 0x%x\n"
00986               "        conversion in progress (bit1): 0x%x\n"
00987               "        front(1)/rear(0) panel (bit2): 0x%x\n"
00988               "        Event buffer not full  (bit3): 0x%x\n"
00989               "        Event count       (bits 4..7): 0x%x\n"
00990               "        should be 0            (bit8): 0x%x\n"
00991               "        should be 0            (bit9): 0x%x\n",
00992                      status, status & 1, (status >> 1) & 1 , (status >> 2) & 1, (status >> 3) & 1,
00993                      (status >> 4) & 0xf,  (status >> 8) & 1, (status >> 9) & 1);
00994      for(int ch=0;ch<8;++ch) {
00995          int val = *pdata++;
00996          fData1182[ch] = val;
00997          f1182h[ch]->Fill(val);
00998          fCernNov10Event->fData1182[ch]=val; // output event to root tree
00999      }
01000   }
01001   
01002   fCh_Pb->Fill(fData1182[0], fData1182[1]);
01003   
01004   fIsPion = fPionCond->Test(fData1182[0], fData1182[1]);
01005   fIsElectron = fElectronCond->Test(fData1182[0], fData1182[1]);
01006 
01007   fS1_Pb->Fill(fData1182[3], fData1182[1]);
01008   fS1_S2->Fill(fData1182[3], fData1182[4]);
01009   fS1_S3->Fill(fData1182[3], fData1182[5]);
01010   fS2_S3->Fill(fData1182[4], fData1182[5]);
01011 }
01012 
01013 
01014 void TCernNov10Proc::Process1183(int* pdata, int len) 
01015 {
01016    for(int ch=0; ch<8 ;++ch) fData1183[ch]=0;
01017 
01018    if (len == 6) { // this was original format
01019    
01020       pdata++;
01021       pdata++;
01022       for (int n=0;n<4;n++) {
01023          int val = *pdata++;
01024          
01025          int val_l = val & 0xffff;
01026          int val_h = val >> 16;
01027          
01028          fData1183[n*2]=val_l;
01029          f1183h[n*2]->Fill(val_l);
01030 
01031          fData1183[n*2+1]=val_h;
01032          f1183h[n*2+1]->Fill(val_h);
01033       }
01034    } else {
01035 
01036       if (len < 2 + 8) {
01037          cout <<"TCernNov10Proc::Process1183 data length"<< len << "not sufficient!" <<endl;
01038          return;
01039       }
01040    
01041       // skip event header:
01042       int header = *pdata++;
01043       if (L1182_DEBUG) printf("1183 header:0x%0x \n",header);
01044       
01045       // skip status:
01046       int status = *pdata++;
01047       if (L1182_DEBUG)
01048         printf("1183 status:0x%0x :  \n"
01049              "        conversion complete    (bit0): 0x%x\n"
01050              "        conversion in progress (bit1): 0x%x\n"
01051              "        front(1)/rear(0) panel (bit2): 0x%x\n"
01052              "        Event buffer not full  (bit3): 0x%x\n"
01053              "        Event count       (bits 4..7): 0x%x\n"
01054              "        should be 0            (bit8): 0x%x\n"
01055              "        should be 0            (bit9): 0x%x\n",
01056                      status, status & 1, (status >> 1) &1 , (status >> 2) &1, (status >> 3) &1,
01057                      (status >> 4) & 0xf,  (status >> 8) &1, (status >> 9) &1);
01058 
01059      for(int ch=0;ch<8;++ch) {
01060         int val = *pdata++;
01061         fData1183[ch]=val;
01062         f1183h[ch]->Fill(val);
01063         fCernNov10Event->fData1183[ch]=val; // output event to root tree
01064      }
01065   }
01066 }
01067 
01068 
01069 void TCernNov10Proc::ProcessTDC(int* pdata, unsigned int len) {
01070 
01071         // TODO
01072 
01073 }
01074 
01075 void TCernNov10Proc::ProcessSi(int* pdata, unsigned int len) {
01076 
01077         // TODO
01078 /*        
01079         
01080         if(len<3) return;
01081 
01082     UInt_t status=*pdata++;
01083     if (MADC_DEBUG) printf("Silicon/v550 status:0x%0x \n",status);
01084 
01085     #ifdef      V550_READ_PED
01086 
01087         UInt_t numchan=*pdata++;
01088 //      if(numchan > N_SISTRIP_CHA)
01089 //                                      {
01090 //              cout << "TCernNov10Proc:Process - Si number of channels " << numchan
01091 //                                                                                              << "out of range - max=" <<N_SISTRIP_CHA << endl;
01092 //              return;
01093 //                                      }
01094     if (MADC_DEBUG) printf("Silicon/v550 number of channels :0x%0x \n",numchan);
01095 
01096         if(len < numchan + 2)
01097                 {
01098                         cout << "TCernNov10Proc:ProcessSi - data length " << len
01099                                                 << "not sufficient for num pedestal channels="<<numchan <<", skipping." << endl;
01100                                 return;
01101                 }
01102         for(int c=0;c<N_SISTRIP_CHA;++c)
01103         {
01104                 fSiPedestals[c]=0;
01105         }
01106         fMadc_si_ped_trace->Reset("");
01107         for (UShort_t i=0;i<numchan;i++)
01108               {
01109                         UInt_t val=*pdata++;
01110                         UInt_t ch=(val >> 12) & 0x7FF;
01111                         UInt_t adc=val & 0xFFF;
01112                         if (MADC_DEBUG) printf("si strip channel: %d has id 0x%0x, adc:0x%0x \n",i,ch,adc);
01113 
01114                         UInt_t cix=i; // channel index is order in subevent?
01115                         //UInt_t cix=ch; // or taken from decoded data?
01116 
01117                         if(cix >= N_SISTRIP_CHA)
01118                                 {
01119                                 cout << "TCernNov10Proc:Proces - Si channel " << cix
01120                                                                                 << "out of range - max=" <<N_SISTRIP_CHA << endl;
01121                                         continue;
01122                                 }
01123                         fSiPedestals[cix]=adc;
01124                         fMadc_si_ped_trace->AddBinContent(1 + cix, (Double_t) adc);
01125                         fMadc_si_ped_acc->AddBinContent(1 + cix, (Double_t) adc);
01126 
01127               }
01128 
01129 #else
01130         UInt_t bothcount=*pdata++;
01131         UShort_t wcount0=(bothcount >> 16);
01132         UShort_t wcount1=(bothcount & 0xFFFF);
01133 #ifdef MADC_DEBUG
01134         printf("Silicon/v550 wc0:0x%0x wc1:0x%0x\n",wcount0, wcount1);
01135 #endif
01136         if(len < wcount0 + wcount1 + 4)
01137                 {
01138                         cout << "TCernNov10Proc:ProcessSi data length" << len
01139                                                 << "not sufficient!" << endl;
01140                                 return;
01141                 }
01142         for(int c=0;c<N_SISTRIP_CHA;++c)
01143                 {
01144                         fSiFifo0[c]=0;
01145                         fSiFifo1[c]=0;
01146                 }
01147         fMadc_si_fifo0_trace->Reset("");
01148                 for (UShort_t i=0;i<wcount0;i++)
01149                       {
01150                                 UInt_t val=*pdata++;
01151                                 UInt_t ch=(val >> 12) & 0x7FF;
01152                                 UInt_t adc=val & 0xFFF;
01153                                 if (MADC_DEBUG) printf("si strip channel 0: %d has id 0x%0x, adc:0x%0x \n",i,ch,adc);
01154                                 if(ch >= N_SISTRIP_CHA)
01155                                         {
01156                                         cout << "TCernNov10Proc:Process fifo0 - Si channel " << ch
01157                                                                                         << "out of range - max=" <<N_SISTRIP_CHA << endl;
01158                                                 continue;
01159                                         }
01160                                 fSiFifo0[ch]=adc;
01161                                 fMadc_si_fifo0_trace->AddBinContent(ch + 1, (Double_t) adc);
01162                                 fMadc_si_fifo0_acc->AddBinContent(ch + 1, (Double_t) adc);
01163 
01164                       }
01165                 fMadc_si_fifo1_trace->Reset("");
01166                 for (UShort_t i=0;i<wcount1;i++)
01167               {
01168                                 UInt_t val=*pdata++;
01169                                 UInt_t ch=(val >> 12) & 0x7FF;
01170                                 UInt_t adc=val & 0xFFF;
01171                                 if (MADC_DEBUG) printf("si strip channel 0: %d has id 0x%0x, adc:0x%0x \n",i,ch,adc);
01172                                 if(ch >= N_SISTRIP_CHA)
01173                                 {
01174                                         cout << "TCernNov10Proc:Process fifo1 - Si channel " << ch
01175                                                         << "out of range - max=" <<N_SISTRIP_CHA << endl;
01176                                         continue;
01177                                 }
01178                                 fSiFifo1[ch]=adc;
01179                                 fMadc_si_fifo1_trace->AddBinContent(ch + 1, (Double_t) adc);
01180                                 fMadc_si_fifo1_acc->AddBinContent(ch + 1, (Double_t) adc);
01181 
01182               }
01183 
01184 
01185 
01186 
01187 #endif
01188 
01189 */
01190 
01191 }
01192 

Generated on Tue Dec 10 2013 04:52:16 for ROCsoft by  doxygen 1.7.1