• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ THaEvData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中THaEvData的典型用法代码示例。如果您正苦于以下问题:C++ THaEvData类的具体用法?C++ THaEvData怎么用?C++ THaEvData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了THaEvData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Load

//_____________________________________________________________________________
void CrateLoc::Load( const THaEvData& evdata )
{
  // Load one data word from crate/slot/chan address

  if( evdata.GetNumHits(crate,slot,chan) > 0 ) {
    data = evdata.GetData(crate,slot,chan,0);
  }
}
开发者ID:hansenjo,项目名称:analyzer,代码行数:9,代码来源:BdataLoc.C


示例2: main

int main(int argc, char* argv[])
{

   if (argc < 2) {
      cout << "You made a mistake... \n" << endl;
      cout << "Usage:   tdecex filename" << endl;
      cout << "  where 'filename' is the CODA file"<<endl;
      cout << "\n... exiting." << endl;
      exit(0);
   }
   TString filename = argv[1];
   THaCodaFile datafile;
   if (datafile.codaOpen(filename) != S_SUCCESS) {
        cout << "ERROR:  Cannot open CODA data" << endl;
        cout << "Perhaps you mistyped it" << endl;
        cout << "... exiting." << endl;
        exit(0);
   }
   THaEvData *evdata = new THaCodaDecoder();
   THaGenDetTest mydetector;
   mydetector.init();

// Loop over a finite number of events

   int NUMEVT=50000;   
   int ievent;
   for (ievent=0; ievent<NUMEVT; ievent++) {
     if ( ievent > 0 && (
        ( (ievent <= 1000) && ((ievent%100) == 0) ) ||
        ( (ievent > 1000) && ((ievent%1000) == 0) ) ) )
              cout << "\n ---- Event " << ievent <<endl;
     int status = datafile.codaRead();  
     if ( status != S_SUCCESS ) {
        if ( status == EOF) {
           cout << "This is end of file !" << endl;
           cout << "... exiting " << endl;
           goto Finish;
        } else {
  	   cout << hex << "ERROR: codaRread status = " << status << endl;
           exit(0);
        }
     }
     evdata->LoadEvent( datafile.getEvBuffer() );   
     mydetector.process_event(evdata);

   }  //  end of event loop

Finish:
   cout << "\n Finished processing " << ievent << " events " << endl;
}
开发者ID:hansenjo,项目名称:analyzer,代码行数:50,代码来源:tdecex_main.C


示例3: Decode

//_____________________________________________________________________________
Int_t Gmp_Raster::Decode( const THaEvData& evdata )
{

  // clears the event structure
  // loops over all modules defined in the detector map
  // copies raw data into local variables
  // pedestal subtraction is not foreseen for the raster


  ClearEvent();

  UInt_t chancnt = 0;
  Int_t chan = 0;
  Int_t data = 0;
  Int_t k = 0;

  for (Int_t i = 0; i < fDetMap->GetSize(); i++ ){
    THaDetMap::Module* d = fDetMap->GetModule( i );

    for (Int_t j=0; j< evdata.GetNumChan( d->crate, d->slot ); j++) {
      chan = evdata.GetNextChan( d->crate, d->slot, j);
      if ((chan>=d->lo)&&(chan<=d->hi)) {
	data = evdata.GetData( d->crate, d->slot, chan, 0 );
	k = chancnt+d->first + chan - d->lo -1;
	if (k<2) {
	  fRawPos(k)= data;
	  fNfired++;
	}
	else if (k<4) {
	  fRawSlope(k-2)= data;
	  fNfired++;
	}
	else {
	  Warning( Here("Decode()"), "Illegal detector channel: %d", k );
	}
      }
    }
    chancnt+=d->hi-d->lo+1;
  }

  if (fNfired!=4) {
    Warning( Here("Decode()"), "Number of fired Channels out of range. Setting beam position to nominal values");
  }
  return 0;
}
开发者ID:xulongwu4,项目名称:gmp_tools,代码行数:46,代码来源:Gmp_Raster.C


示例4: FindWord

//____________________________________________________________________
Int_t THaQWEAKHelicityReader::FindWord( const THaEvData& evdata, 
				     const ROCinfo& info )
// find the index of the word we are looking for given a header
// or simply return the index already stored in ROC info (in that case
// the header stored in ROC info needs to be 0 
{
  Int_t len = evdata.GetRocLength(info.roc);
  if (len <= 4) 
    return -1;

  Int_t i;
  if( info.header == 0 )
    i = info.index;
  else {
    for( i=0; i<len &&
	   (evdata.GetRawData(info.roc, i) & 0xffff000) != info.header;
	 ++i) {}
    i += info.index;
  }
  return (i < len) ? i : -1;
}
开发者ID:hansenjo,项目名称:analyzer,代码行数:22,代码来源:THaQWEAKHelicityReader.C


示例5: LoadData

Int_t THaScaler::LoadData(const THaEvData& evdata) {
// Load data from THaEvData object.  Return of 0 is ok.
// Note: GetEvBuffer is no faster than evdata.Get...
  static int ldebug = 0;
  static Int_t data[2*SCAL_NUMBANK*SCAL_NUMCHAN+100];
  new_load = kFALSE;
  Int_t nlen = 0;
  if (evstr_type == 1) {  // data in the event stream (physics triggers)
    if (!evdata.IsPhysicsTrigger()) return 0;  
    nlen = evdata.GetRocLength(crate); 
    if (nlen == 0) return 0;
  } else {  // traditional scaler event type 140
    if (evdata.GetEvType() != 140) return 0;   
    nlen = evdata.GetEvLength();
  }
  if (ldebug) cout << "Loading evdata, bank =  "<<bankgroup<<"  "<<evstr_type<<"  "<<crate<<"  "<<evdata.GetEvType()<<"   "<<nlen<<endl;
  Int_t maxlen = sizeof(data)/sizeof(Int_t);
  if (nlen > maxlen) nlen = maxlen;
  for (Int_t i = 0; i < nlen; i++) {
    if (evstr_type == 1) {
      data[i] = evdata.GetRawData(crate, i);
    } else {
      data[i] = evdata.GetRawData(i);
    }
    if (ldebug) {
      cout << "  data["<<i<<"] = "<<data[i]<<"  =0x"<<hex<<data[i]<<dec<<endl;
    } 
  }
  ExtractRaw(data,nlen);  
  return 0;
};
开发者ID:JeffersonLab,项目名称:d2n_analyzer,代码行数:31,代码来源:THaScaler.C


示例6: Decode

//_____________________________________________________________________________
Int_t THaBPM::Decode( const THaEvData& evdata )
{

  // clears the event structure
  // loops over all modules defined in the detector map
  // copies raw data into local variables
  // performs pedestal subtraction

  const char* const here = "Decode()";

  for (Int_t i = 0; i < fDetMap->GetSize(); i++ ){
    THaDetMap::Module* d = fDetMap->GetModule( i );
    for (Int_t j=0; j< evdata.GetNumChan( d->crate, d->slot ); j++) {
      Int_t chan = evdata.GetNextChan( d->crate, d->slot, j);
      if ((chan>=d->lo)&&(chan<=d->hi)) {
	Int_t data = evdata.GetData( d->crate, d->slot, chan, 0 );
	UInt_t k = d->first + chan - d->lo -1;
	if ((k<NCHAN)&&(fRawSignal(k)==-1)) {
	  fRawSignal(k)= data;
	  fNfired++;
	}
	else {
	  Warning( Here(here), "Illegal detector channel: %d", k );
	}
      }
    }
  }

  if (fNfired!=NCHAN) {
    Warning( Here(here), "Number of fired Channels out of range. "
	     "Setting beam position to nominal values");
  }
  else {
    fCorSignal=fRawSignal;
    fCorSignal-=fPedestals;
  }

  return 0;
}
开发者ID:xulongwu4,项目名称:analyzer,代码行数:40,代码来源:THaBPM.C


示例7: main

int main(int argc, char* argv[])
{

   if (argc < 2) {
      cout << "You made a mistake... \n" << endl;
      cout << "Usage:   epicsd filename" << endl;
      cout << "  where 'filename' is the CODA file"<<endl;
      cout << "\n... exiting." << endl;
      exit(0);
   }
   TString filename = argv[1];
   THaCodaFile datafile;
   if (datafile.codaOpen(filename) != S_SUCCESS) {
        cout << "ERROR:  Cannot open CODA data" << endl;
        cout << "Perhaps you mistyped it" << endl;
        cout << "... exiting." << endl;
        exit(0);
   }
      
   THaEvData *evdata = new THaCodaDecoder();

// Loop over a finite number of events

   int NUMEVT=1000000;
   for (int i=0; i<NUMEVT; i++) {

     int status = datafile.codaRead();  
	                                            
     if ( status != S_SUCCESS ) {
        if ( status == EOF) {
           cout << "This is end of file !" << endl;
           cout << "... exiting " << endl;
           exit(1);
        } else {
  	   cout << hex << "ERROR: codaRread status = " << status << endl;
           exit(0);
        }
     }

     evdata->LoadEvent( datafile.getEvBuffer() );

     if(evdata->IsEpicsEvent()) {

       cout << "Some epics data --> "<<endl;
       cout << "hac_bcm_average "<<
	 evdata->GetEpicsData("hac_bcm_average")<<endl;
       cout << "IPM1H04A.XPOS  "<<
         evdata->GetEpicsData("IPM1H04A.XPOS")<<endl;
       cout << "IPM1H04A.YPOS  "<<
         evdata->GetEpicsData("IPM1H04A.YPOS")<<endl;

     }

   }  //  end of event loop


}
开发者ID:JeffersonLab,项目名称:d2n_analyzer,代码行数:57,代码来源:epics_main.C


示例8: Decode

//_____________________________________________________________________________
Int_t THaVDC::Decode( const THaEvData& evdata )
{
  // Decode data from VDC planes

#ifdef WITH_DEBUG
  // Save current event number for diagnostics
  fEvNum = evdata.GetEvNum();
  if( fDebug>1 ) {
    cout << "=========================================\n";
    cout << "Event: " << fEvNum << endl;
  }
#endif

  fLower->Decode(evdata);
  fUpper->Decode(evdata);

  return 0;
}
开发者ID:hansenjo,项目名称:analyzer,代码行数:19,代码来源:THaVDC.C


示例9: main

int main(int argc, char* argv[])
{

   int debug=0;
   if (argc > 1) debug=1;

// CODA file "snippet.dat" is a disk file of CODA data.  
   THaCodaFile datafile;   //     We could also open the data using a 
                        //     different constructor:                   
                        //     THaCodaFile datafile("snippet.dat");

   TString filename("snippet.dat");
   if (datafile.codaOpen(filename) != S_SUCCESS) {
        cout << "ERROR:  Cannot open CODA data" << endl;
        exit(0);
   }
      
   THaEvData *evdata = new THaCodaDecoder();

// Loop over events
 
   int NUMEVT=100;
   int ievent;
   for (ievent=0; ievent<NUMEVT; ievent++) {

     int status = datafile.codaRead();  
	                                            
     if ( status != S_SUCCESS ) {
        if ( status == EOF) {
           cout << "This is normal end of file.  Goodbye !" << endl;
        } else {
  	   cout << hex << "ERROR: codaRread status = " << status << endl;
        }
        goto Finish;
     }

// load_evbuffer() must be called each event before you access evdata contents.
// If you use the version of load_evbuffer() shown here, 
// evdata uses its private crate map (recommended).
// Alternatively you could use load_evbuffer(int* evbuffer, haCrateMap& map)
     
     evdata->LoadEvent( datafile.getEvBuffer() );   

     cout << "\nEvent type   " << dec << evdata->GetEvType() << endl;
     cout << "Event number " << evdata->GetEvNum()  << endl;
     cout << "Event length " << evdata->GetEvLength() << endl;
     if (evdata->IsPhysicsTrigger() ) { // triggers 1-14
        cout << "Physics trigger " << endl;
     }
     if(evdata->IsScalerEvent()) cout << "Scaler `event' " << endl;

// Now we want data from a particular crate and slot.
// E.g. crates are 1,2,3,13,14,15 (roc numbers), Slots are 1,2,3... 
// This is like what one might do in a detector decode() routine.

      int crate = 1;    // for example
      int slot = 24;

//  Here are raw 32-bit CODA words for this crate and slot
      cout << "Raw Data Dump for crate "<<dec<<crate<<" slot "<<slot<<endl; 
      int hit;
      for(hit=0; hit<evdata->GetNumRaw(crate,slot); hit++) {
        cout<<dec<<"raw["<<hit<<"] =   ";
        cout<<hex<<evdata->GetRawData(crate,slot,hit)<<endl;  
      }
// You can alternatively let evdata print out the contents of a crate and slot:
      evdata->PrintSlotData(crate,slot);

      if (evdata->IsPhysicsTrigger()) {
// Below are interpreted data, device types are ADC, TDC, or scaler.
// One needs to know the channel number within the device
        int channel = 7;    // for example
        cout << "Device type = ";
        cout << evdata->DevType(crate,slot) << endl;
        for (hit=0; hit<evdata->GetNumHits(crate,slot,channel); hit++) {
	   cout << "Channel " <<dec<<channel<<" hit # "<<hit<<"  ";
           cout << "data = " << evdata->GetData(crate,slot,channel,hit)<<endl;
        }
// Helicity data
        cout << "Helicity on left spectrometer "<<evdata->GetHelicity("left")<<endl;
        cout << "Helicity on right spectrometer "<<evdata->GetHelicity("right")<<endl;
        cout << "Helicity "<<evdata->GetHelicity()<<endl;
      }

// Scalers:  Although the getData methods works if you happen
// to know what crate & slot contain scaler data, here is
// another way to get scalers directly from evdata

      for (slot=0; slot<5; slot++) {
        cout << "\n scaler slot -> " << dec << slot << endl;; 
        for (int chan=0; chan<16; chan++) {
	  cout << "Scaler chan " <<  chan << "  ";
          cout << evdata->GetScaler("left",slot,chan);
          cout << "  "  << evdata->GetScaler(7,slot,chan) << endl;
	}
      }
 

   }  //  end of event loop

//.........这里部分代码省略.........
开发者ID:JeffersonLab,项目名称:d2n_analyzer,代码行数:101,代码来源:tdecpr_main.C


示例10: Decode

//_____________________________________________________________________________
Int_t THaVDCPlane::Decode( const THaEvData& evData )
{
  // Converts the raw data into hit information
  // Logical wire numbers a defined by the detector map. Wire number 0
  // corresponds to the first defined channel, etc.

  // TODO: Support "reversed" detector map modules a la MWDC

  if (!evData.IsPhysicsTrigger()) return -1;

  // the event's T0-shift, due to the trigger-type
  // only an issue when adding in un-retimed trigger types
  Double_t evtT0=0;
  if ( fglTrg && fglTrg->Decode(evData)==kOK ) evtT0 = fglTrg->TimeOffset();

  Int_t nextHit = 0;

  bool only_fastest_hit = false, no_negative = false;
  if( fVDC ) {
    // If true, add only the first (earliest) hit for each wire
    only_fastest_hit = fVDC->TestBit(THaVDC::kOnlyFastest);
    // If true, ignore negative drift times completely
    no_negative      = fVDC->TestBit(THaVDC::kIgnoreNegDrift);
  }

  // Loop over all detector modules for this wire plane
  for (Int_t i = 0; i < fDetMap->GetSize(); i++) {
    THaDetMap::Module * d = fDetMap->GetModule(i);

    // Get number of channels with hits
    Int_t nChan = evData.GetNumChan(d->crate, d->slot);
    for (Int_t chNdx = 0; chNdx < nChan; chNdx++) {
      // Use channel index to loop through channels that have hits

      Int_t chan = evData.GetNextChan(d->crate, d->slot, chNdx);
      if (chan < d->lo || chan > d->hi)
	continue; //Not part of this detector

      // Wire numbers and channels go in the same order ...
      Int_t wireNum  = d->first + chan - d->lo;
      THaVDCWire* wire = GetWire(wireNum);
      if( !wire || wire->GetFlag() != 0 ) continue;

      // Get number of hits for this channel and loop through hits
      Int_t nHits = evData.GetNumHits(d->crate, d->slot, chan);

      Int_t max_data = -1;
      Double_t toff = wire->GetTOffset();

      for (Int_t hit = 0; hit < nHits; hit++) {

	// Now get the TDC data for this hit
	Int_t data = evData.GetData(d->crate, d->slot, chan, hit);

	// Convert the TDC value to the drift time.
	// Being perfectionist, we apply a 1/2 channel correction to the raw
	// TDC data to compensate for the fact that the TDC truncates, not
	// rounds, the data.
	Double_t xdata = static_cast<Double_t>(data) + 0.5;
	Double_t time = fTDCRes * (toff - xdata) - evtT0;

	// If requested, ignore hits with negative drift times
	// (due to noise or miscalibration). Use with care.
	// If only fastest hit requested, find maximum TDC value and record the
	// hit after the hit loop is done (see below).
	// Otherwise just record all hits.
	if( !no_negative || time > 0.0 ) {
	  if( only_fastest_hit ) {
	    if( data > max_data )
	      max_data = data;
	  } else
	    new( (*fHits)[nextHit++] )  THaVDCHit( wire, data, time );
	}

    // Count all hits and wires with hits
    //    fNWiresHit++;

      } // End hit loop

      // If we are only interested in the hit with the largest TDC value
      // (shortest drift time), it is recorded here.
      if( only_fastest_hit && max_data>0 ) {
	Double_t xdata = static_cast<Double_t>(max_data) + 0.5;
	Double_t time = fTDCRes * (toff - xdata) - evtT0;
	new( (*fHits)[nextHit++] ) THaVDCHit( wire, max_data, time );
      }
    } // End channel index loop
  } // End slot loop

  // Sort the hits in order of increasing wire number and (for the same wire
  // number) increasing time (NOT rawtime)

  fHits->Sort();

  if ( fDebug > 3 ) {
    printf("\nVDC %s:\n",GetPrefix());
    int ncol=4;
    for (int i=0; i<ncol; i++) {
      printf("     Wire    TDC  ");
//.........这里部分代码省略.........
开发者ID:xulongwu4,项目名称:analyzer-1.6,代码行数:101,代码来源:THaVDCPlane.C


示例11: ReadData

//____________________________________________________________________
Int_t THaQWEAKHelicityReader::ReadData( const THaEvData& evdata ) 
{
  // Obtain the present data from the event for QWEAK helicity mode.

  static const char* here = "THaQWEAKHelicityReader::ReadData";

  //  std::cout<<" kHel, kTime, kRing="<< kHel<<" "<<kTime<<" "<<kRing<<endl;
  //     for (int jk=0; jk<3; jk++)
  //     {
  //       std::cout<<" which="<<jk
  // 	       <<" roc="<<fROCinfo[jk].roc
  // 	       <<" header="<<fROCinfo[jk].header
  // 	       <<" index="<<fROCinfo[jk].index 
  // 	       <<endl;
  //     }
  
  //  std::cout<<" fHaveROCs="<<fHaveROCs<<endl;
  if( !fHaveROCs ) {
    ::Error( here, "ROC data (detector map) not properly set up." );
    return -1;
  }
  Int_t hroc = fROCinfo[kHel].roc;
  Int_t len = evdata.GetRocLength(hroc);
  if (len <= 4) 
    return -1;

  Int_t ihel = FindWord( evdata, fROCinfo[kHel] );
  if (ihel < 0) {
    ::Error( here , "Cannot find helicity" );
    return -1;
  }
  Int_t data = evdata.GetRawData( hroc, ihel );  
  fPatternTir =(data & 0x20)>>5;
  fHelicityTir=(data & 0x10)>>4;
  fTSettleTir =(data & 0x40)>>6;
 
  hroc=fROCinfo[kTime].roc;
  len = evdata.GetRocLength(hroc);
  if (len <= 4) 
    {
      ::Error( here, "length of roc event not matching expection ");
      return -1;
    }
  Int_t itime = FindWord (evdata, fROCinfo[kTime] );
  if (itime < 0) {
    ::Error( here, "Cannot find timestamp" );
    return -1;
  }
  
  fTimeStampTir=static_cast<UInt_t> (evdata.GetRawData( hroc, itime ));  
  
  // Invert the gate polarity if requested
  //  if( fNegGate )
  //  fGate = !fGate;
  
  hroc=fROCinfo[kRing].roc;
  len = evdata.GetRocLength(hroc);
  if (len <= 4) 
    {
      ::Error( here, "length of roc event not matching expection (message 2)");
      //  std::cout<<" len ="<<len<<endl;
      //      std::cout<<"kRING="<<kRing<<" hroc="<<hroc<<endl;
      return -1;
    }
  Int_t index=0;
  while (index < len && fIRing == 0) 
    {
      Int_t header=evdata.GetRawData(hroc,index++);
      if ((header & 0xffff0000) == 0xfb1b0000) 
	{
	  fIRing = header & 0x3ff;
	}
    }
   
  //  std::cout<<" fIRing ="<<fIRing<<" index="<<index<<endl;


  if(fIRing>kHelRingDepth)
    {
      ::Error( here, "Ring depth to large ");
      return -1;
    }
  for(int i=0;i<fIRing; i++)
    {
      fTimeStampRing[i]=evdata.GetRawData(hroc,index++);
      data=evdata.GetRawData(hroc,index++);
      fHelicityRing[i]=(data & 0x1);
      fPatternRing[i]= (data & 0x10)>>4;
      fT3Ring[i]=evdata.GetRawData(hroc,index++);
      fU3Ring[i]=evdata.GetRawData(hroc,index++);
      fT5Ring[i]=evdata.GetRawData(hroc,index++);
      fT10Ring[i]=evdata.GetRawData(hroc,index++);
    }

  //    Print();
  
  FillHisto(); 

  return 0;
//.........这里部分代码省略.........
开发者ID:hansenjo,项目名称:analyzer,代码行数:101,代码来源:THaQWEAKHelicityReader.C


示例12: PrintEvNum

//_____________________________________________________________________________
void THaDebugModule::PrintEvNum( const THaEvData& evdata ) const
{
    // Print current event number
    cout << "======>>>>>> Event " << (UInt_t)evdata.GetEvNum() << endl;
}
开发者ID:JeffersonLab,项目名称:d2n_analyzer,代码行数:6,代码来源:THaDebugModule.C


示例13: main

int main(int argc, char* argv[]) {

   int i,iev,evnum,trig,iskip,status;
   Int_t clkp, clkm, lastclkp, lastclkm;
   Float_t sum,asy;
   TString filename = "run.dat";
   
   char bank[100] = "EvLeft";  // Event stream, Left HRS
   cout << "Analyzing CODA file  "<<filename<<endl;   
   cout << "Bank = "<<bank<<endl<<flush;

   evnum = 10000000;
   if (argc > 1) evnum = atoi(argv[1]);

   THaScaler *scaler = new THaScaler(bank);

   if (scaler->Init("1-10-2004") == -1) {  
      cout << "Error initializing scaler "<<endl;
      return 1;
   }

   THaCodaData *coda = new THaCodaFile(filename);
   THaEvData *evdata = new THaCodaDecoder();

// Pedestals.  Left, Right Arms.  u1,u3,u10,d1,d3,d10
   Float_t bcmpedL[NBCM] = { 188.2, 146.2, 271.6, 37.8, 94.2, 260.2 };
   Float_t bcmpedR[NBCM] = { 53.0, 41.8, 104.1, 0., 101.6, 254.6 };
   Float_t bcmped[NBCM];

   if (strcmp(bank,"EvLeft") == 0) {
     cout << "Using Left Arm BCM pedestals"<<endl;
     for (i = 0; i < NBCM; i++) {
       bcmped[i] = bcmpedL[i];
     }
   } else {
     cout << "Using Right Arm BCM pedestals"<<endl;
     for (i = 0; i < NBCM; i++) {
       bcmped[i] = bcmpedR[i];
     }
   }

// Initialize root and output
   TROOT scalana("scalroot","Hall A scaler analysis");
   TFile hfile("scaler.root","RECREATE","Scaler data in Hall A");

// Define the ntuple here
//                   0   1  2   3  4   5  6  7   8  9 10 11  12   13   14
   char rawrates[]="time:u1:u3:u10:d1:d3:d10:t1:t2:t3:t4:t5:clkp:clkm:tacc:";
//                      15 16   17  18  19   20  21   22  23  24  25  26
   char asymmetries[]="au1:au3:au10:ad1:ad3:ad10:at1:at2:at3:at4:at5:aclk";
   int nlen = strlen(rawrates) + strlen(asymmetries);
   char *string_ntup = new char[nlen+1];
   strcpy(string_ntup,rawrates);
   strcat(string_ntup,asymmetries);
   TNtuple *ntup = new TNtuple("ascal","Scaler Rates",string_ntup);

   Float_t farray_ntup[27];     // Note, dimension is same as size of string_ntup (i.e. nlen+1)

   status = 0;
   iev = 0;
   iskip = 0;
   lastclkp = 0;
   lastclkm = 0;

   while (status == 0) {

     if(coda) status = coda->codaRead();
     if (status != 0) {
       cout << "coda status nonzero.  assume EOF"<<endl;
       goto quit;
     }
      evdata->LoadEvent(coda->getEvBuffer());

// Dirty trick to average over larger time intervals (depending on 
// SKIPEVENT) to reduce the fluctuations due to clock.  
     if (evdata->GetRocLength(MYROC) > 16) iskip++;
     if (SKIPEVENT != 0 && iskip < SKIPEVENT) continue;
     iskip = 0;

     scaler->LoadData(*evdata);

// Not every trigger has new scaler data, so skip if not new.
     if ( !scaler->IsRenewed() ) {
       cout << "not renewed "<<endl<<flush;
       continue;
     }

     if (iev++ > evnum) goto quit;

// Fill the ntuple here

// Note, we must average the two helicities here to get non-helicity rates
     Double_t time = (scaler->GetPulser(1,"clock") + scaler->GetPulser(-1,"clock"))/1024;
     farray_ntup[0] = time;
     farray_ntup[1] = 0.5*(scaler->GetBcmRate(1,"bcm_u1") + scaler->GetBcmRate(-1,"bcm_u1"));
     farray_ntup[2] = 0.5*(scaler->GetBcmRate(1,"bcm_u3") + scaler->GetBcmRate(-1,"bcm_u3"));
     farray_ntup[3] = 0.5*(scaler->GetBcmRate(1,"bcm_u10") + scaler->GetBcmRate(-1,"bcm_u10"));
     farray_ntup[4] = 0.5*(scaler->GetBcmRate(1,"bcm_d1") + scaler->GetBcmRate(-1,"bcm_d1"));
     farray_ntup[5] = 0.5*(scaler->GetBcmRate(1,"bcm_d3") + scaler->GetBcmRate(-1,"bcm_d3"));
     farray_ntup[6] = 0.5*(scaler->GetBcmRate(1,"bcm_d10") + scaler->GetBcmRate(-1,"bcm_d10"));
//.........这里部分代码省略.........
开发者ID:JeffersonLab,项目名称:d2n_analyzer,代码行数:101,代码来源:tscalevt_main.C


示例14: Decode

//____________________________________________________________________
Int_t THaADCHelicity::Decode( const THaEvData& evdata )
{
    // Decode Helicity data.
    // Return 1 if helicity was assigned, 0 if not, -1 if error.

    // Only the first two channels defined in the detector map are used
    // here, regardless of how they are defined (consecutive channels
    // in same module or otherwise). ReadDatabase guarantees that two channels
    // are present and warns about extra channels.

    if( !fIsInit )
        return -1;

    Int_t ret = 0;
    bool gate_high = false;

    for( Int_t i = 0; i < fNchan; ++i ) {
        Int_t roc = fAddr[i].roc, slot = fAddr[i].slot, chan = fAddr[i].chan;
        if ( !evdata.GetNumHits( roc, slot, chan ))
            continue;

        Double_t data =
            static_cast<Double_t>(evdata.GetData( roc, slot, chan, 0 ));

        if (fDebug >= 3) {
            cout << "crate "<<roc<<"   slot "<<slot<<"   chan "
                 <<chan<<"   data "<<data<<"   ";
            if (data > fThreshold)
                cout << "  above cut !";
            cout << endl;
        }

        // Assign gate and helicity bit data. The first data channel is
        // the helicity bit, the second, the gate.
        switch(i) {
        case 0:
            fADC_hdata = data;
            break;
        case 1:
            fADC_Gate = data;
            gate_high = fInvertGate ? (data < fThreshold) : (data >= fThreshold);
            break;
        }
    }

    // Logic: if gate==0 helicity remains unknown. If gate==1
    // (or we are ingoring the gate) then helicity is determined by
    // the helicity bit.
    if( gate_high || fIgnoreGate ) {
        fADC_Hel = ( fADC_hdata >= fThreshold ) ? kPlus : kMinus;
        ret = 1;
    }

    // fHelicity may be reassigned by derived classes, so we must keep the ADC
    // result separately. But within this class, the two are the same.
    if( fSign >= 0 )
        fHelicity = fADC_Hel;
    else
        fHelicity = ( fADC_Hel == kPlus ) ? kMinus : kPlus;

    if (fDebug >= 3) {
        cout << "ADC helicity info "<<endl
             << "Gate "<<fADC_Gate<<"  helic. bit "<<fADC_hdata
             << "    ADC helicity "<<fADC_Hel
             << "    resulting helicity"<<fHelicity<<endl;
    }

    return ret;
}
开发者ID:hansenjo,项目名称:analyzer,代码行数:70,代码来源:THaADCHelicity.C


示例15: main

int main(int argc, char* argv[])
{
  // Initialize the analysis clock
  clock_t t;
  t = clock();

  // Define the data file to be analyzed
  TString filename("snippet.dat");

  // Define the analysis debug output
  ofstream *debugfile = new ofstream;;
  debugfile->open ("tstfadc_main_debug.txt");
  
  // Initialize the CODA decoder
  THaCodaFile datafile(filename);
  THaEvData *evdata = new CodaDecoder();

  // Initialize the evdata debug output
  evdata->SetDebug(1);
  evdata->SetDebugFile(debugfile);

  // Initialize root and output
  TROOT fadcana("tstfadcroot", "Hall C analysis");
  hfile = new TFile("tstfadc.root", "RECREATE", "fadc module data");

  // Loop over events
  cout << "***************************************" << endl;
  cout << NUMEVENTS << " events will be processed" << endl;
  cout << "***************************************" << endl;
  uint32_t iievent = 1;
  //for(uint32_t ievent = 0; ievent < NUMEVENTS; ievent++) {
  for(uint32_t ievent = 0; ievent < iievent; ievent++) {
    // Read in data file
    int status = datafile.codaRead();
    if (status == S_SUCCESS) {
      UInt_t *data = datafile.getEvBuffer();
      evdata->LoadEvent(data);

      if (debugfile) *debugfile << "****************" << endl;
      if (debugfile) *debugfile << "Event Number = " << evdata->GetEvNum() << endl;
      if (debugfile) *debugfile << "****************\n" << endl;

      // Loop over slots
      for(uint32_t islot = SLOTMIN; islot < NUMSLOTS; islot++) {
      	//if (evdata->GetNumRaw(CRATE5, islot) != 0) {
	//if (evdata->GetNumRaw(CRATE10, islot) != 0) {
	if (evdata->GetNumRaw(CRATE12, islot) != 0) {
	  Fadc250Module *fadc = NULL;
	  //fadc = dynamic_cast <Fadc250Module*> (evdata->GetModule(CRATE5, islot));   // Bryan's setup
	  //fadc = dynamic_cast <Fadc250Module*> (evdata->GetModule(CRATE10, islot));  // Alex's setup
	  fadc = dynamic_cast <Fadc250Module*> (evdata->GetModule(CRATE12, islot));    // Mark's setup
	  if (fadc != NULL) {
	    //fadc->CheckDecoderStatus();
	    if (debugfile) *debugfile << "\n///////////////////////////////\n"
				      << "Results for crate " 
				      << fadc->GetCrate() << ", slot " 
				      << fadc->GetSlot() << endl;
				      
	    if (debugfile) *debugfile << hex << "fadc pointer = " << fadc << "\n" << dec 
				      << "///////////////////////////////\n" << endl;
	    
	    // Loop over channels
	    for (uint32_t chan = 0; chan < NADCCHAN; chan++) {
	      // Initilize variables
	      Int_t  fadc_mode, num_fadc_events, num_fadc_samples;
	      Bool_t raw_mode; 
	      fadc_mode = num_fadc_events = num_fadc_samples = raw_mode = 0;
	      // Acquire the FADC mode
	      fadc_mode = fadc->GetFadcMode(); fadc_mode_const = fadc_mode;
	      if (debugfile) *debugfile << "Channel " << chan << " is in FADC Mode " << fadc_mode << endl;
	      raw_mode  = ((fadc_mode == 1) || (fadc_mode == 8) || (fadc_mode == 10));
	      // Generate FADC plots
	      GeneratePlots(fadc_mode, islot, chan);

	      // Acquire the number of FADC events
	      num_fadc_events = fadc->GetNumFadcEvents(chan);
	      // If in raw mode, acquire the number of FADC samples
	      if (raw_mode) {
		num_fadc_samples = 0;
		num_fadc_samples = fadc->GetNumFadcSamples(chan, ievent);
	      }
	      if (num_fadc_events > 0) {
	      	for (Int_t jevent = 0; jevent < num_fadc_events; jevent++) {
		  // Debug output
		  if ((fadc_mode == 1 || fadc_mode == 8) && num_fadc_samples > 0) 
		    if (debugfile) *debugfile << "FADC EMULATED PI DATA = " << fadc->GetEmulatedPulseIntegralData(chan) << endl;
		  if (fadc_mode == 7 || fadc_mode == 8 || fadc_mode == 9 || fadc_mode == 10) {
		    if (fadc_mode != 8) {if (debugfile) *debugfile << "FADC PI DATA = " << fadc->GetPulseIntegralData(chan, jevent) << endl;}
		    if (debugfile) *debugfile << "FADC PT DATA = " << fadc->GetPulseTimeData(chan, jevent) << endl;
		    if (debugfile) *debugfile << "FADC PPED DATA = " << fadc->GetPulsePedestalData(chan, jevent) << endl;
		    if (debugfile) *debugfile << "FADC PPEAK DATA = " << fadc->GetPulsePeakData(chan, jevent) << endl;
		  }
		  // Fill histos
	      	  if ((fadc_mode == 1 || fadc_mode == 8) && num_fadc_samples > 0) h_pinteg[islot][chan]->Fill(fadc->GetEmulatedPulseIntegralData(chan));
		  else if (fadc_mode == 7 || fadc_mode == 8 || fadc_mode == 9 || fadc_mode == 10) {
		    if (fadc_mode != 8) {h_pinteg[islot][chan]->Fill(fadc->GetPulseIntegralData(chan, jevent));}
		    h_ptime[islot][chan]->Fill(fadc->GetPulseTimeData(chan, jevent));
		    h_pped[islot][chan]->Fill(fadc->GetPulsePedestalData(chan, jevent));
		    h_ppeak[islot][chan]->Fill(fadc->GetPulsePeakData(chan, jevent));
		  }
//.........这里部分代码省略.........
开发者ID:hansenjo,项目名称:analyzer,代码行数:101,代码来源:tstfadc_main.C


示例16: Decode

//_____________________________________________________________________________
Int_t THaScintillator::Decode( const THaEvData& evdata )
{
  // Decode scintillator data, correct TDC times and ADC amplitudes, and copy
  // the data to the local data members.
  // This implementation makes the following assumptions about the detector map:
  // - The first half of the map entries corresponds to ADCs,
  //   the second half, to TDCs.
  // - The first fNelem detector channels correspond to the PMTs on the
  //   right hand side, the next fNelem channels, to the left hand side.
  //   (Thus channel numbering for each module must be consecutive.)

  // Loop over all modules defined for this detector

  for( Int_t i = 0; i < fDetMap->GetSize(); i++ ) {
    THaDetMap::Module* d = fDetMap->GetModule( i );
    bool adc = ( d->model ? fDetMap->IsADC(d) : (i < fDetMap->GetSize()/2) );

    // Loop over all channels that have a hit.
    for( Int_t j = 0; j < evdata.GetNumChan( d->crate, d->slot ); j++) {

      Int_t chan = evdata.GetNextChan( d->crate, d->slot, j );
      if( chan < d->lo || chan > d->hi ) continue;     // Not one of my channels

#ifdef WITH_DEBUG
      Int_t nhit = evdata.GetNumHits(d->crate, d->slot, chan);
      if( nhit > 1 )
        if (d->model != 250)
	Warning( Here("Decode"), "%d hits on %s channel %d/%d/%d",
		 nhit, adc ? "ADC" : "TDC", d->crate, d->slot, chan );
#endif
      // Get the data. Scintillators are assumed to have only single hit (hit=0)
      Int_t data = evdata.GetData( d->crate, d->slot, chan, 0 );

      // Get the detector channel number, starting at 0
      Int_t k = d->first + chan - d->lo - 1;

#ifdef WITH_DEBUG
      if( k<0 || k>NDEST*fNelem ) {
	// Indicates bad database
	Warning( Here("Decode()"), "Illegal detector channel: %d", k );
	continue;
      }
//        cout << "adc,j,k = " <<adc<<","<<j<< ","<<k<< endl;
#endif
      // Copy the data to the local variables.
      DataDest* dest = fDataDest + k/fNelem;
      k = k % fNelem;
      if( adc ) {
	dest->adc[k]   = static_cast<Double_t>( data );
	dest->adc_p[k] = data - dest->ped[k];
	dest->adc_c[k] = dest->adc_p[k] * dest->gain[k];
	(*dest->nahit)++;
      } else {
	dest->tdc[k]   = static_cast<Double_t>( data );
	dest->tdc_c[k] = (data - dest->offset[k])*fTdc2T;
	(*dest->nthit)++;
      }
    }
  }
  if ( fDebug > 3 ) {
    printf("\n\nEvent %d   Trigger %d Scintillator %s\n:",
	   evdata.GetEvNum(), evdata.GetEvType(), GetPrefix() );
    printf("   paddle  Left(TDC    ADC   ADC_p)   Right(TDC   ADC   ADC_p)\n");
    for ( int i=0; i<fNelem; i++ ) {
      printf("     %2d     %5.0f    %5.0f  %5.0f     %5.0f    %5.0f  %5.0f\n",
	     i+1,fLT[i],fLA[i],fLA_p[i],fRT[i],fRA[i],fRA_p[i]);
    }
  }

  return fLTNhit+fRTNhit;
}
开发者ID:xulongwu4,项目名称:analyzer-1.6,代码行数:72,代码来源:THaScintillator.C


示例17: main

int main(int argc, char* argv[])
{

   if (argc < 2) {
      cout << "You made a mistake... \n" << endl;
      cout << "Usage:   prfact filename" << endl;
      cout << "  where 'filename' is the CODA file"<<endl;
      cout << "\n... exiting." << endl;
      exit(0);
   }
   TString filename = argv[1];
   THaCodaFile datafile;
   if (datafile.codaOpen(filename) != S_SUCCESS) {
        cout << "ERROR:  Cannot open CODA data" << endl;
        cout << "Perhaps you mistyped it" << endl;
        cout << "... exiting." << endl;
        exit(0);
   }
      
   THaEvData *evdata = new THaCodaDecoder();

   // Can tell evdata whether to use evtype 
   // 133 or 120 for prescale data.  Default is 120.
   evdata->SetOrigPS(133);   // args are 120 or 133
   cout << "Origin of PS data "<<evdata->GetOrigPS()<<endl;

// Loop over a finite number of events

   int NUMEVT=100000;
   for (int i=0; i<NUMEVT; i++) {

     int status = datafile.codaRead();  
	                                            
     if ( status != S_SUCCESS ) {
        if ( status == EOF) {
           cout << "This is end of file !" << endl;
           cout << "... exiting " << endl;
           exit(1);
        } else {
  	   cout << hex << "ERROR: codaRread status = " << status << endl;
           exit(0);
        }
     }

     evdata->LoadEvent( datafile.getEvBuffer() );   

     if(evdata->IsPrescaleEvent()) {
       cout <<"\n Prescale factors from CODA file = " << filename << endl;
       cout <<"\n Trigger      Prescale Factor"<< endl;
       for (int trig=1; trig<=8; trig++) {
	 cout <<"   "<<dec<<trig<<"             ";
         int ps = evdata->GetPrescaleFactor(trig);
         int psmax;
	 if (trig <= 4) psmax = 16777216;  // 2^24
         if (trig >= 5) psmax = 65536;     // 2^16
         ps = ps % psmax;
         if (ps == 0) ps = psmax;
         cout << ps << endl;
       }
       cout << "\nReminder: A 'zero' was interpreted as maximum."<<endl;
       cout << "Max for trig 1-4 = 2^24, for trig 5-8 = 2^16 \n"<<endl;
       exit(0);
     }

   }  //  end of event loop

   cout << "ERROR: prescale factors not found in the first "; 
   cout << dec << NUMEVT << " events " << endl;

}
开发者ID:hansenjo,项目名称:analyzer,代码行数:70,代码来源:prfact_main.C


示例18: main

int main(int argc, char* argv[]) {
   int helicity, qrt, gate, timestamp;
   int len, data, status, nscaler, header;
   int numread, badread, i, found, index;
   int ring_clock, ring_qrt, ring_helicity;
   int ring_trig, ring_bcm, ring_l1a, ring_v2fh; 
   int sum_clock, sum_trig, sum_bcm, sum_l1a;
   int inquad, nrread, q1_helicity;
   int ring_data[MAXRING], rloc;
   if (argc < 2) {
      cout << "You made a mistake... bye bye !\n" << endl;
      cout << "Usage:   'tscalroc" << MYROC << " filename'" << endl;
      cout << "  where 'filename' is the CODA file."<<endl;
      exit(0);
   }
// Setup 
// Pedestals. 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ THash类代码示例发布时间:2022-05-31
下一篇:
C++ THTTPHdrVal类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap