diff --git a/NPLib/Detectors/ComptonTelescope/TComptonTelescopePhysics.cxx b/NPLib/Detectors/ComptonTelescope/TComptonTelescopePhysics.cxx index 88fc152d23cf293338054124691d80dd92d74de6..c8030d807ff8107d408a56fb52c3b39f22185247 100644 --- a/NPLib/Detectors/ComptonTelescope/TComptonTelescopePhysics.cxx +++ b/NPLib/Detectors/ComptonTelescope/TComptonTelescopePhysics.cxx @@ -126,7 +126,7 @@ void TComptonTelescopePhysics::BuildSimplePhysicalEvent() vector<TVector2> couple = Match_Front_Back(); EventMultiplicity = couple.size(); - //cout << "event multiplicity = " << couple.size() << endl; + //cout << "event multiplicity = " << couple.size() << endl; // keep only mult 1 couples //if (couple.size() == 1) { // pb if done here, so done in Match_Front_Back() @@ -307,6 +307,8 @@ void TComptonTelescopePhysics::PreTreat() ClearPreTreatedData(); // Front, energy + //cout << m_EventData->GetCTTrackerFrontEMult() << endl; + //m_EventData->Dump(); for (UShort_t i = 0; i < m_EventData->GetCTTrackerFrontEMult(); ++i) { //m_CounterEvt[1] = 1; // nb of events with at least one EF raw recorded //m_CounterHit[0] += 1; // nb of hits with EF raw diff --git a/Projects/ComptonTelescope/online/calibrations.txt b/Projects/ComptonTelescope/online/calibrations.txt index aeec75b7d0cbb27bf78009ef2ccaeef21432c84d..cc8a7785f072593cfee6ced97a6b9bb0ebfdb2b2 100644 --- a/Projects/ComptonTelescope/online/calibrations.txt +++ b/Projects/ComptonTelescope/online/calibrations.txt @@ -1,6 +1,6 @@ CalibrationFilePath -% ./calibrations/DSSSD_calibration_withPed_pol3_ok.txt ./calibrations/DSSSD_D1_Calibration_run10_newCal.txt +% ./calibrations/DSSSD_calibration_withPed_pol3_ok.txt ./calibrations/CeBr3_PED.txt ./calibrations/CeBr3_PED3.txt ./calibrations/CeBr3_PED4.txt diff --git a/Projects/ComptonTelescope/online/src/DecodeD.cpp b/Projects/ComptonTelescope/online/src/DecodeD.cpp index 43536304537b50e5a938de155b5f4f18359a2bf3..3ef51c8149014f24bed107e60cabd8fb34956b30 100644 --- a/Projects/ComptonTelescope/online/src/DecodeD.cpp +++ b/Projects/ComptonTelescope/online/src/DecodeD.cpp @@ -36,7 +36,7 @@ void DecodeD::setTree(const char* filename) t1->SetBranchAddress("sample", &event.sample); t1->SetBranchAddress("cm_data", &event.cm_data); t1->SetBranchAddress("timestamp", &event.timestamp); - #if __EVENTTYPE__ == frame_t && __EVENTTYPE__ != newframe_t + #if __OLDFRAME__ t1->SetBranchAddress("chain", &event.chain); t1->SetBranchAddress("nb_asic", &event.nb_asic); #endif @@ -105,7 +105,7 @@ void DecodeD::decodeEvent() case D_ROOT: if (cursor < length) { t1->GetEntry(cursor); - //#if __EVENTTYPE__ == newframe_t && __EVENTTYPE__ != frame_t + #if !__OLDFRAME__ for (int i = 0; i < 2; i++) { // 2 faces for (int j = 0; j < NBDETECTORS; j++) { if (event.chip_data[i][j]) { // Test if data is present @@ -119,7 +119,7 @@ void DecodeD::decodeEvent() } // end Test } // end loop on detectors } // end loop on faces - //#endif + #endif cursor++; } break; @@ -153,7 +153,7 @@ void DecodeD::Dump() return; } cout << "Timestamp: " << event.timestamp << endl; - #if __EVENTTYPE__ == frame_t && __EVENTTYPE__ != newframe_t + #if __OLDFRAME__ cout << "Chain: " << event.chain << " - Asic: " << event.nb_asic << endl; cout << "Chip data: " << event.chip_data << " Analog trigger: " << event.analog_trigger << " seu: " << event.seu << " Channel status: " << event.ch_status << " cm data: " << event.cm_data << endl; cout << "Samples: "; @@ -161,8 +161,7 @@ void DecodeD::Dump() cout << event.sample[k] << " "; } cout << endl; - #endif - #if __EVENTTYPE__ != frame_t && __EVENTTYPE__ == newframe_t + #else cout << "Chip data\tanalog trigger\tseu\tchannel status\tref channel\tcm data" << endl; for (int i = 0; i < 2; i++) { for (int j = 0; j < NBDETECTORS; j++) { @@ -174,6 +173,10 @@ void DecodeD::Dump() cout << endl; } } + cout << FaceType.size() << " " << DetNbr.size() << " " << StripNbr.size() << " " << Energy.size() << endl; + for (int n = 0; n < Energy.size(); n++) { + cout << FaceType[n] << " " << DetNbr[n] << " " << StripNbr[n] << " " << Energy[n] << endl; + } #endif } diff --git a/Projects/ComptonTelescope/online/src/DecodeD.h b/Projects/ComptonTelescope/online/src/DecodeD.h index 5e6479fd445702e5801d0ad66a8fcf73693dce26..11d90581eea68e87da7d91d732bbe7a0f90b002f 100644 --- a/Projects/ComptonTelescope/online/src/DecodeD.h +++ b/Projects/ComptonTelescope/online/src/DecodeD.h @@ -1,9 +1,12 @@ #ifndef DECODED_H #define DECODED_H -//#define __EVENTTYPE__ frame_t // To read data before conversion -#define __EVENTTYPE__ newframe_t // To read data after conversion - +#define __OLDFRAME__ 0 // To read data before conversion +#if __OLDFRAME__ + #define __EVENTTYPE__ frame_t // To read data before conversion +#else + #define __EVENTTYPE__ newframe_t // To read data after conversion +#endif // General C++ librairies #include <iostream> @@ -63,6 +66,7 @@ class DecodeD vector<int> FaceType; vector<int> DetNbr; vector<int> StripNbr; + //vector<int> Energy; vector<double> Energy; public: diff --git a/Projects/ComptonTelescope/online/src/online_coinc.cpp b/Projects/ComptonTelescope/online/src/online_coinc.cpp index 18ebf259785684deb34bf358480474bd2d53935f..a8ad64d2676ed419b98101a0e2e2cd48aae51346 100644 --- a/Projects/ComptonTelescope/online/src/online_coinc.cpp +++ b/Projects/ComptonTelescope/online/src/online_coinc.cpp @@ -83,7 +83,7 @@ int main(int argc, char** argv) #else string arg = "-D ./ComptonCAM.detector -C calibrations.txt -GH -E ./10He.reaction"; #endif - NPOptionManager::getInstance(arg); + NPOptionManager::getInstance(arg); // open ROOT output file RootOutput::getInstance("OnlineTree.root", "OnlineTree"); @@ -112,8 +112,8 @@ int main(int argc, char** argv) DecodeD* DD = new DecodeD(false); // Instantiates DecodeD object reading DSSSD(s) data flux // newframe_t* event; //DD -> setTree("/disk/proto-data/data/20210304_run2/bb7_3309-7_cs137_20210304_14h35_conv.root"); - //DD -> setTree("/disk/proto-data/data/20210305_run3/bb7_3309-7_cs137_20210305_14h53_conv.root"); - DD -> setTree("../data/20210305_run3/bb7_3309-7_cs137_20210305_14h53_conv.root"); + DD -> setTree("/disk/proto-data/data/20210305_run3/bb7_3309-7_cs137_20210305_14h53_conv.root"); + //DD -> setTree("../data/20210210_run1/bb7_3309-7_cs137-20210210_11h05_coinc_run1_conv.root"); int dlen = DD -> getLength(); int i = 0;// ROSMAP files loop counter @@ -126,8 +126,8 @@ int main(int argc, char** argv) ifstream iros, itrig; cout << "Loading data files " << std::flush; - //itrig.open("/disk/proto-data/data/20210305_run3/mfm_trigger_20210305_run3.raw", ios::binary); - itrig.open("../data/20210305_run3/mfm_trigger_20210305_run3.raw", ios::binary); + itrig.open("/disk/proto-data/data/20210305_run3/mfm_trigger_20210305_run3.raw", ios::binary); + //itrig.open("../data/20210210_run1/mfm_trigger_202102101104.raw", ios::binary); itrig.seekg(0, ios::end); int tlen = itrig.tellg(); itrig.seekg(0, ios::beg); @@ -136,8 +136,8 @@ int main(int argc, char** argv) itrig.close(); cout << "... " << std::flush; - //iros.open("/disk/proto-data/data/20210305_run3/mfm_rosmap_20210305_run3.raw", ios::binary); - iros.open("../data/20210305_run3/mfm_rosmap_20210305_run3.raw", ios::binary); + iros.open("/disk/proto-data/data/20210305_run3/mfm_rosmap_20210305_run3.raw", ios::binary); + //iros.open("../data/20210210_run1/mfm_rdd_rosmap_04_mfm_rosmap_04_2021-02-10_10_04_59.raw.0001", ios::binary); iros.seekg(0, ios::end); int rlen = iros.tellg(); iros.seekg(0, ios::beg); @@ -260,52 +260,10 @@ int main(int argc, char** argv) DR -> setRaw(rbuff); DR -> decodeBlobMFM(); -#ifdef __TEST_ZONE__ +//#ifdef __TEST_ZONE__ cout << "Entering test zone." << endl; - //DD -> setTree("/disk/proto-data/data/20210305_run3/bb7_3309-7_cs137_20210305_14h53.root"); - DD -> setTree("../data/20210305_run3/bb7_3309-7_cs137_20210305_14h53.root"); - #if 0 - int lblength = 50; - char* lb = new char[lblength]; - for (int j = 0; j<lblength; j++) {lb[j] = ' ';} - while (DR -> getCursor() < rlen) { - if (i%10000==0) { - for (int j = 0; j<lblength; j++) { - if ((int) lblength * DR -> getCursor() / rlen > j) - {lb[j] = '#';} } - cout << "\r[" << lb << "] " << i << ": " << DR -> getCursor() << "/" << rlen << "\r" << std::flush; - } - m_NPDetectorManager->ClearEventPhysics(); - m_NPDetectorManager->ClearEventData(); - ccamData -> SetCTCalorimeter(1, 4, DR->getPixelNumber(), DR->getTime(), DR->getData(), pixelNumber); - ccamData -> SetResetCount(cr); - m_NPDetectorManager->BuildPhysicalEvent(); - m_OutputTree->Fill(); - m_NPDetectorManager->CheckSpectraServer(); - i++; - DR -> decodeBlobMFM(); - } - #endif - DD -> decodeEvent(); - int td = DD -> getTime(); - int hist[10] = {0}; - int c = 0; - while (DD->getCursor() < dlen) { - DD -> decodeEvent(); - if (td == DD -> getTime()) { - c++; - } else { - hist[c]++; c = 0; - td = DD -> getTime(); - } -// cout << DD -> getTime() - td << ","; -// cout << DD -> getTime() << " " << td << " : " << DD -> getTime() - td << endl; - } - for (int i = 0; i<10; i++) { - cout << hist[i] << ", "; - } - cout << endl; -#else + +//#else DD -> rewind(); DD -> decodeEvent(); @@ -377,7 +335,7 @@ int main(int argc, char** argv) i++; } // End of main loop -#endif +//#endif } // End of mode if delete DR; @@ -406,194 +364,3 @@ int main(int argc, char** argv) } -/* - const bool loopForever = false; - //while (loopForever or i<12) // for Am data - while (loopForever or i<3) // for Bi data quick analysis - //while (loopForever or i<489) // for Bi data all events - { - // Load a root file and setup DecodeD - //DD -> setTree("../data/20200128_11h58_am241_conv.root"); - DD -> setTree("../data/bb7_3309-7_bi207_20210203_16h25_run8_conv.root"); - int dlength = DD -> getLength(); - - //while (DD -> getCursor() < dlength and (loopForever or i<12)) - while (DD -> getCursor() < dlength and (loopForever or i<3)) - { - // Load a ROSMAP file - std::ifstream is; -// i = 1; - switch (i % 3) { - case 3: is.open("./mfm.bin", std::ios::binary); break; - case 4: is.open("./133Ba.bin", std::ios::binary); break; - case 5: is.open("./241Am.bin", std::ios::binary); break; - case 0: is.open("./207Bi.bin", std::ios::binary); break; - case 1: is.open("./241Am-1.bin", std::ios::binary); break; - case 2: is.open("./241Am-2.bin", std::ios::binary); break; - } - is.seekg (0, std::ios::end); - int length = is.tellg(); - is.seekg (0, ios::beg); - char* buffer = new char [length]; - is.read(buffer, length); - is.close(); - i++; - - // Setup DecodeR - DR -> setRaw(buffer); - DR -> decodeRawMFM(); // get rid of the first two (empty) events - DR -> decodeRawMFM(); - - // Loop on some events - while (DD -> getCursor() < dlength and DR -> getCursor() < length) - { - // Clear raw and physics data - m_NPDetectorManager->ClearEventPhysics(); - m_NPDetectorManager->ClearEventData(); - - // Fill calorimeter data - DR -> decodeRawMFM(); - setCTCalorimeter(ccamData, DR, pixelNumber); - - // Fill DSSD data - DD -> decodeEvent(); - event = DD -> getEvent(); - setCTTracker(ccamData, event, &nb_asic, &chain, stripNumber); - - // Build physical event - m_NPDetectorManager->BuildPhysicalEvent(); - - // Fill object in output ROOT file - m_OutputTree->Fill(); - - // check spectra - m_NPDetectorManager->CheckSpectraServer(); - - c++; - //usleep(100);//Simulated 10kHz count rate - - }// End of loop on ROSMAP events - - delete [] buffer; - - }// End of loop on DSSSD data - - }// End of main loop - - // fill spectra - m_NPDetectorManager->WriteSpectra(); - - // delete Decoders - delete DR; - delete DD; - - // Essential - #if __cplusplus > 199711L && NPMULTITHREADING - m_NPDetectorManager->StopThread(); - #endif - RootOutput::Destroy(); - - return 0; -} - -*/ - - - - -/* - while (DD -> getCursor() < dlength) - { - // Clear raw and physics data - m_NPDetectorManager->ClearEventPhysics(); - m_NPDetectorManager->ClearEventData(); - - //Read some data - DD -> decodeEvent(); - event = DD -> getEvent(); - //Fill TComptonTelescopeData here (if possible) - for (vector<int>::iterator itchain = chain.begin(); itchain != chain.end(); ++itchain) {//Iterates on 2 faces - for (vector<int>::iterator itasic = nb_asic.begin(); itasic != nb_asic.end(); ++itasic) {//Iterates on 1 DSSSD - if (event->chip_data[*itchain][*itasic]) { // Test if data is present - switch (*itchain) { - case 0://Assuming 0 is front - to be checked - ccamData -> SetCTTrackerFrontTTowerNbr(1); - ccamData -> SetCTTrackerFrontTDetectorNbr(*itasic+1); - ccamData -> SetCTTrackerFrontTStripNbr(33); - ccamData -> SetCTTrackerFrontTTime(event->timestamp); - for (int k = 0; k < stripNumber; k++) {//Loop on strips - ccamData -> SetCTTrackerFrontETowerNbr(1); - ccamData -> SetCTTrackerFrontEDetectorNbr(*itasic+1); - ccamData -> SetCTTrackerFrontEStripNbr(k+1); - ccamData -> SetCTTrackerFrontEEnergy(event->sample[*itchain][*itasic][k]); - }//End of loop on strips - break; - case 1://Assuming 1 is back - to be checked - ccamData -> SetCTTrackerBackTTowerNbr(1); - ccamData -> SetCTTrackerBackTDetectorNbr(*itasic+1); - ccamData -> SetCTTrackerBackTStripNbr(33); - ccamData -> SetCTTrackerBackTTime(event->timestamp); - for (int k = 0; k < stripNumber; k++) {//Loop on strips - ccamData -> SetCTTrackerBackETowerNbr(1); - ccamData -> SetCTTrackerBackEDetectorNbr(*itasic+1); - ccamData -> SetCTTrackerBackEStripNbr(k+1); - ccamData -> SetCTTrackerBackEEnergy(event->sample[*itchain][*itasic][k]); - }//End of loop on strips - }//End switch - }//End if - }//End for - }//End for - - // Build physical event - m_NPDetectorManager->BuildPhysicalEvent(); - //Fill output tree - m_OutputTree->Fill(); - //check spectra - m_NPDetectorManager->CheckSpectraServer(); - - c++; - - }//End while - cout << "Read " << c << " DSSSD events from file" << endl; - - // Read from file - D -> setRaw(buffer); - - D -> decodeRawMFM(); // get rid of the first two (empty) events - D -> decodeRawMFM(); - - while (D -> getCursor() < length) - { - // Clear raw data and physics objects - m_NPDetectorManager->ClearEventPhysics(); - m_NPDetectorManager->ClearEventData(); - - // Read the actual data - D -> decodeRawMFM(); - //D -> Dump();//Optionnal print - - // Set ccamData (a better way is envisionned) - for (int i = 0; i < pixelNumber; ++i) { - ccamData -> SetCTCalorimeterETowerNbr(1); - ccamData -> SetCTCalorimeterEDetectorNbr( 1 ); - ccamData -> SetCTCalorimeterEChannelNbr( i );//PMTÂ pixel number - ccamData -> SetCTCalorimeterEEnergy( D -> getData()[i] ); - } - ccamData -> SetCTCalorimeterTTowerNbr( 1 ); - ccamData -> SetCTCalorimeterTDetectorNbr( 1 );//Triggered ASIC number - ccamData -> SetCTCalorimeterTChannelNbr( D -> getPixelNumber() );//Pixel that triggered - ccamData -> SetCTCalorimeterTTime( D -> getTime() ); - // ccamData -> Dump(); - - // Build physical event - m_NPDetectorManager->BuildPhysicalEvent(); - - // Fill object in output ROOT file - m_OutputTree->Fill(); - - // check spectra - m_NPDetectorManager->CheckSpectraServer(); - - c++; - usleep(100);//Simulated 10kHz count rate - }*/ diff --git a/Projects/ComptonTelescope/online/src/online_dsssd.cpp b/Projects/ComptonTelescope/online/src/online_dsssd.cpp index d78e46296b36e21cad857f951f0decc2b3a4cc0c..228f3e43e5044da909f1d33ce0e890100c4dc316 100644 --- a/Projects/ComptonTelescope/online/src/online_dsssd.cpp +++ b/Projects/ComptonTelescope/online/src/online_dsssd.cpp @@ -93,7 +93,8 @@ int main(int argc, char *argv[]) m_NPDetectorManager->ClearEventData(); // Fill data - //cout << "event size " << DD->getEventSize() << endl; + //cout << "event size " << DD->getEventSize() << endl; + //ccamData -> Dump(); for (int i = 0; i < DD->getEventSize(); i++) { //cout << i << endl; if (DD -> getFaceType(i) == 0) { // front