|
|
|
|
|
const Int_t mMax = 100000; |
|
struct STGCVMMData |
|
{ |
|
// event information |
|
Int_t EventId; |
|
Int_t Sec; |
|
Int_t Rdo; |
|
Int_t n; |
|
|
|
//channel information |
|
Int_t Channel_Number[mMax]; |
|
Int_t Strip_Number[mMax]; |
|
Int_t FEB[mMax]; |
|
Int_t FEBVMM[mMax]; |
|
Int_t VMM[mMax]; |
|
Int_t CH[mMax]; |
|
Int_t BCID[mMax]; |
|
Int_t ADC[mMax]; |
|
Int_t TB[mMax]; |
|
|
|
}; |
|
|
|
size_t fttIndex = 0; |
|
TTree * mVMMTree; |
|
STGCVMMData mVMMData; |
|
|
|
void parse_evt_line( std::stringstream &ss ){ |
|
cout << ss.str() << endl; |
|
if ( mVMMData.EventId >= 0 ) |
|
mVMMTree->Fill(); |
|
string tok; |
|
ss >> tok; // STGC |
|
ss >> tok; // VMM: |
|
ss >> tok; // evt |
|
ss >> mVMMData.EventId; |
|
ss >> tok; // : |
|
ss >> tok; // sec |
|
ss >> mVMMData.Sec; |
|
ss >> tok; // , |
|
ss >> tok; // RDO |
|
ss >> mVMMData.Rdo; |
|
ss >> tok; // : |
|
ss >> tok; // hits |
|
ss >> mVMMData.n; |
|
fttIndex = 0; |
|
} |
|
|
|
void parse_feb_line( std::stringstream &ss ){ |
|
|
|
|
|
cout << ss.str() << endl; |
|
string tok; |
|
ss >> tok; // FEB |
|
ss >> mVMMData.FEB[fttIndex]; |
|
char buf[100]; |
|
ss.read( buf, 1 ); |
|
ss >> mVMMData.VMM[fttIndex]; |
|
ss >> tok; // [0xfeb_vmm], |
|
// cout << tok << endl;; |
|
ss >> tok; // ch |
|
ss >> mVMMData.CH[fttIndex]; |
|
ss >> tok; // : |
|
ss >> tok; // ADC |
|
ss >> mVMMData.ADC[fttIndex]; |
|
ss >> tok; // , |
|
ss >> tok; // BCID |
|
ss >> mVMMData.BCID[fttIndex]; |
|
ss >> tok; // , |
|
ss >> tok; // tb |
|
ss >> mVMMData.TB[fttIndex]; |
|
|
|
fttIndex++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
void read_RTS( string fn = "st_hltcosmic_22314049_raw_0000002.daq.dat" ){ |
|
|
|
mVMMData.EventId = -1; |
|
cout << " Booking the event tree " << endl; |
|
mVMMTree = new TTree("sTGC_DataDst","sTGC_DataDst"); |
|
mVMMTree->SetAutoSave(100000000); // 100 MB |
|
|
|
// Event information |
|
mVMMTree->Branch("mEvtID", &mVMMData.EventId, "Event/I"); |
|
mVMMTree->Branch("SEC", &mVMMData.Sec, "SEC/I"); |
|
mVMMTree->Branch("RDO", &mVMMData.Rdo, "RDO/I"); |
|
mVMMTree->Branch("n", &mVMMData.n, "n/I"); |
|
|
|
// Channel information |
|
mVMMTree->Branch("Channel_Number", mVMMData.Channel_Number, "Channel_Number[n]/I"); |
|
mVMMTree->Branch("Strip_Number", mVMMData.Strip_Number, "Strip_Number[n]/I"); |
|
mVMMTree->Branch("FEB", mVMMData.FEB, "FEB[n]/I"); |
|
mVMMTree->Branch("FEBVMM", mVMMData.FEBVMM, "FEBVMM[n]/I"); |
|
mVMMTree->Branch("VMM", mVMMData.VMM, "VMM[n]/I"); |
|
mVMMTree->Branch("CH", mVMMData.CH, "CH[n]/I"); |
|
mVMMTree->Branch("BCID", mVMMData.BCID, "BCID[n]/I"); |
|
mVMMTree->Branch("ADC", mVMMData.ADC, "ADC[n]/I"); |
|
mVMMTree->Branch("TB", mVMMData.TB, "TB[n]/I"); |
|
|
|
|
|
ifstream inf( fn.c_str() ); |
|
|
|
std::string line; |
|
while (std::getline(inf, line)) |
|
{ |
|
|
|
std::stringstream ss(line); |
|
if ( line.find( "STGC VMM: evt" ) != string::npos ) |
|
parse_evt_line( ss ); |
|
else if ( line.find( "FEB" ) != string::npos ) |
|
parse_feb_line( ss ); |
|
|
|
// process pair (a,b) |
|
} |
|
|
|
|
|
string ofn = fn + ".root"; |
|
TFile * fout = new TFile( ofn.c_str(), "RECREATE" ); |
|
fout->cd(); |
|
mVMMTree->Write(); |
|
fout->Write(); |
|
|
|
} |