SC analysis compiles but fails at initialization of adc2d vectors

This commit is contained in:
2022-05-10 17:50:22 +02:00
parent 5e8ba967c8
commit fad81adb39

View File

@ -74,8 +74,8 @@ int main(int argc, char* argv[]) {
//char savename[128]; //char savename[128];
char histoname[256]; // VH 210902 char histoname[256]; // VH 210902
char savename[256]; // VH 210902 char savename[256]; // VH 210902
int filen = 352; int filen = 16;
int pedefilen = 5; int pedefilen = 1;
// create necessary directories with permissions drwxrwxr-x // create necessary directories with permissions drwxrwxr-x
// data/Mxxx // data/Mxxx
@ -119,14 +119,15 @@ int main(int argc, char* argv[]) {
jungfrauFile *thisfile = new jungfrauFile(); jungfrauFile *thisfile = new jungfrauFile();
vector<jungfrauPedestal*> pedestalObject_SC(NSC); //should call default constructor 16 times vector<jungfrauPedestal*> pedestalObject_SC; //( NSC, new jungfrauPedestal() ); //should call default constructor 16 times
pedestalObject_SC.reserve(NSC);
vector<TH2F*> pedestalsG0; vector<TH2F*> pedestalsG0;
pedestalsG0.reserve(NSC); pedestalsG0.reserve(NSC);
vector<TH2F*> pedeRMSG0; vector<TH2F*> pedeRMSG0;
pedeRMSG0.reserve(NSC); pedeRMSG0.reserve(NSC);
for (int sci = 0; sci < NSC; ++sci) { for (int sci = 0; sci < NSC; ++sci) {
//pedestalObject_SC[sci] = new jungfrauPedestal(); pedestalObject_SC.push_back( new jungfrauPedestal() );
pedestalObject_SC[sci]->pedestalSetNFrames(100); pedestalObject_SC.at(sci)->pedestalSetNFrames(100);
Char_t *pedehistoname = new Char_t[50]; Char_t *pedehistoname = new Char_t[50];
snprintf( pedehistoname, 50, "pedestalsG0_sc%d", sci ); snprintf( pedehistoname, 50, "pedestalsG0_sc%d", sci );
@ -134,8 +135,8 @@ int main(int argc, char* argv[]) {
snprintf( pedehistoname, 50, "pedeRMSG0_sc%d", sci ); snprintf( pedehistoname, 50, "pedeRMSG0_sc%d", sci );
pedeRMSG0.push_back( new TH2F( pedehistoname, "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ) ); pedeRMSG0.push_back( new TH2F( pedehistoname, "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ) );
} }
static vector< vector<uint16_t> > pedestals16_G0_start( NSC, vector<uint16_t>(NCH) ); //I suppose, this is to track pedestal shifting over the course of data taking vector< vector<uint16_t> > pedestals16_G0_start( NSC, vector<uint16_t>(NCH) ); //I suppose, this is to track pedestal shifting over the course of data taking
static vector< vector<double> > pedeRMS16_G0( NSC, vector<double>(NCH) ); vector< vector<double> > pedeRMS16_G0( NSC, vector<double>(NCH) );
for (int pedefilei = 0; pedefilei < pedefilen; ++pedefilei) { for (int pedefilei = 0; pedefilei < pedefilen; ++pedefilei) {
@ -155,7 +156,7 @@ int main(int argc, char* argv[]) {
// calculate pixel mask // calculate pixel mask
pixelMaskObject->maskIfGainNot( 0, thisfile->getFrameDataHandle(), pixel_mask ); pixelMaskObject->maskIfGainNot( 0, thisfile->getFrameDataHandle(), pixel_mask );
// caluclate pedestals // caluclate pedestals
pedestalObject_SC[ thisfile->currentSCnumber() ]->addFrameToPedestalCalculation( thisfile->getFrameDataHandle() ); pedestalObject_SC.at( thisfile->currentSCnumber() )->addFrameToPedestalCalculation( thisfile->getFrameDataHandle() );
} }
thisfile->close(); thisfile->close();
@ -165,13 +166,13 @@ int main(int argc, char* argv[]) {
for (int sci = 0; sci < NSC; ++sci) { for (int sci = 0; sci < NSC; ++sci) {
for (int i = 0; i < NCH; ++i) { for (int i = 0; i < NCH; ++i) {
if (pixel_mask[i] == true) { if (pixel_mask[i] == true) {
pedestalsG0[sci]->Fill( i%NC, i/NC, pedestalObject_SC[sci]->pedestalOfChannel(i) ); pedestalsG0.at(sci)->Fill( i%NC, i/NC, pedestalObject_SC[sci]->pedestalOfChannel(i) );
pedeRMSG0[sci]->Fill( i%NC, i/NC, pedestalObject_SC[sci]->rmsOfChannel(i) ); pedeRMSG0.at(sci)->Fill( i%NC, i/NC, pedestalObject_SC[sci]->rmsOfChannel(i) );
} }
} }
pedestalObject_SC[sci]->pedestalData((uint16_t*)(&pedestals16_G0_start[sci])); //this loads the pedestal data into the array pedestals16_G0_start pedestalObject_SC.at(sci)->pedestalData((uint16_t*)(pedestals16_G0_start.at(sci).data())); //this loads the pedestal data into the array pedestals16_G0_start
pedestalObject_SC[sci]->pedestalRMSData(pedeRMS16_G0[sci].data()); //same here pedestalObject_SC.at(sci)->pedestalRMSData(pedeRMS16_G0[sci].data()); //same here
pedestalObject_SC[sci]->pedestalResetUpdates(); pedestalObject_SC.at(sci)->pedestalResetUpdates();
//pedestalObject[sci]->pedestalClear(); //I don't need to clear if I only calculate pedestal once. //pedestalObject[sci]->pedestalClear(); //I don't need to clear if I only calculate pedestal once.
} }
@ -203,7 +204,15 @@ int main(int argc, char* argv[]) {
int adc2d_nbin= 1200; int adc2d_nbin= 1200;
if (isJF11) adc2d_nbin= 1600; if (isJF11) adc2d_nbin= 1600;
vector< vector <TH2I*> > adc2d; //(8, vector <TH2I*>(16) ); //declare vector <TH2I*> adc2d_1; //(8, vector <TH2I*>(16) ); //declare
vector <TH2I*> adc2d_2;
vector <TH2I*> adc2d_3;
vector <TH2I*> adc2d_4;
vector <TH2I*> adc2d_5;
vector <TH2I*> adc2d_6;
vector <TH2I*> adc2d_7;
vector <TH2I*> adc2d_8;
//adc2d.reserve(8);
/* /*
TH2I *adc2d_2[16]; = new TH2I("adc2d_2","",adc2d_nbin,-200-0.5,adc2d_nbin-200-0.5,65536,(65536*1-0.5),(65536*2-0.5)); TH2I *adc2d_2[16]; = new TH2I("adc2d_2","",adc2d_nbin,-200-0.5,adc2d_nbin-200-0.5,65536,(65536*1-0.5),(65536*2-0.5));
TH2I *adc2d_3[16]; = new TH2I("adc2d_3","",adc2d_nbin,-200-0.5,adc2d_nbin-200-0.5,65536,(65536*2-0.5),(65536*3-0.5)); TH2I *adc2d_3[16]; = new TH2I("adc2d_3","",adc2d_nbin,-200-0.5,adc2d_nbin-200-0.5,65536,(65536*2-0.5),(65536*3-0.5));
@ -214,17 +223,35 @@ int main(int argc, char* argv[]) {
TH2I *adc2d_8[16]; = new TH2I("adc2d_8","",adc2d_nbin,-200-0.5,adc2d_nbin-200-0.5,65536,(65536*7-0.5),(65536*8-0.5)); TH2I *adc2d_8[16]; = new TH2I("adc2d_8","",adc2d_nbin,-200-0.5,adc2d_nbin-200-0.5,65536,(65536*7-0.5),(65536*8-0.5));
*/ */
//initilaize cout << "Initialize vector of vectors..." << endl;
for ( int adci = 0; adci < 8; ++adci ) {
vector<TH2I*> v; //initialize
v.reserve(NSC); //for ( int adci = 0; adci < 8; ++adci ) {
//vector<TH2I*> v;
//v.reserve(NSC);
for ( int sci = 0; sci < NSC; ++sci ) { for ( int sci = 0; sci < NSC; ++sci ) {
Char_t *_histoname = new Char_t[50]; Char_t *_histoname = new Char_t[50];
snprintf( _histoname, 50, "adc2d_%d_sc%d", (adci+1), sci ); snprintf( _histoname, 50, "adc2d_1_sc%d", sci );
v.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*adci-0.5 ), ( 65536*( adci+1 )-0.5 ) ) ); adc2d_1.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*0-0.5 ), ( 65536*( 0+1 )-0.5 ) ) );
snprintf( _histoname, 50, "adc2d_2_sc%d", sci );
adc2d_2.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*1-0.5 ), ( 65536*( 1+1 )-0.5 ) ) );
snprintf( _histoname, 50, "adc2d_3_sc%d", sci );
adc2d_3.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*2-0.5 ), ( 65536*( 2+1 )-0.5 ) ) );
snprintf( _histoname, 50, "adc2d_4_sc%d", sci );
adc2d_4.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*3-0.5 ), ( 65536*( 3+1 )-0.5 ) ) );
snprintf( _histoname, 50, "adc2d_5_sc%d", sci );
adc2d_5.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*4-0.5 ), ( 65536*( 4+1 )-0.5 ) ) );
snprintf( _histoname, 50, "adc2d_6_sc%d", sci );
adc2d_6.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*5-0.5 ), ( 65536*( 5+1 )-0.5 ) ) );
snprintf( _histoname, 50, "adc2d_7_sc%d", sci );
adc2d_7.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*6-0.5 ), ( 65536*( 6+1 )-0.5 ) ) );
snprintf( _histoname, 50, "adc2d_8_sc%d", sci );
adc2d_8.push_back( new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*7-0.5 ), ( 65536*( 7+1 )-0.5 ) ) );
} }
adc2d.push_back(v); //adc2d.push_back(v);
} //}
cout << "Done." << endl;
//declare //declare
vector<TH1D*> adcpc_spec; vector<TH1D*> adcpc_spec;
@ -234,6 +261,8 @@ int main(int argc, char* argv[]) {
vector<TH2F*> pede_diff; vector<TH2F*> pede_diff;
pede_diff.reserve(NSC); pede_diff.reserve(NSC);
cout << "Initialize vectors of histograms..." << endl;
//initialize //initialize
for ( int sci = 0; sci < NSC; ++sci ) { for ( int sci = 0; sci < NSC; ++sci ) {
Char_t *_histoname = new Char_t[50]; Char_t *_histoname = new Char_t[50];
@ -245,7 +274,7 @@ int main(int argc, char* argv[]) {
pede_diff.push_back( new TH2F( _histoname, "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ) ); pede_diff.push_back( new TH2F( _histoname, "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ) );
} }
//HERE!!!! cout << "Done." << endl;
for (int filei = 0; filei < filen; filei++) { for (int filei = 0; filei < filen; filei++) {
@ -258,7 +287,7 @@ int main(int argc, char* argv[]) {
uint16_t* imagedptr = thisfile->getFrameDataHandle(); uint16_t* imagedptr = thisfile->getFrameDataHandle();
uint64_t scnumber = thisfile->currentSCnumber(); uint64_t scnumber = thisfile->currentSCnumber();
pedestalObject_SC[scnumber]->addG0FrameToPedestalCalculationWThreshold( imagedptr, pedestalObject_SC[scnumber], pedeRMS16_G0[scnumber].data() ); pedestalObject_SC.at(scnumber)->addG0FrameToPedestalCalculationWThreshold( imagedptr, pedestalObject_SC.at(scnumber), pedeRMS16_G0.at(scnumber).data() );
for (int i = 0; i < NCH; i++) { for (int i = 0; i < NCH; i++) {
@ -266,25 +295,25 @@ int main(int argc, char* argv[]) {
if (gain == 0) { if (gain == 0) {
int adcpc = (imagedptr[i]&0x3fff) - pedestalObject_SC[scnumber]->pedestalOfChannel(i); int adcpc = (imagedptr[i]&0x3fff) - pedestalObject_SC.at(scnumber)->pedestalOfChannel(i);
adcpc_spec[scnumber]->Fill(adcpc); adcpc_spec.at(scnumber)->Fill(adcpc);
if (i < (65536*1)) { if (i < (65536*1)) {
adc2d[0][scnumber]->Fill(adcpc,i); adc2d_1[scnumber]->Fill(adcpc,i);
} else if (i < (65536*2)) { } else if (i < (65536*2)) {
adc2d[1][scnumber]->Fill(adcpc,i); adc2d_2[scnumber]->Fill(adcpc,i);
} else if (i < (65536*3)) { } else if (i < (65536*3)) {
adc2d[2][scnumber]->Fill(adcpc,i); adc2d_3[scnumber]->Fill(adcpc,i);
} else if (i < (65536*4)) { } else if (i < (65536*4)) {
adc2d[3][scnumber]->Fill(adcpc,i); adc2d_4[scnumber]->Fill(adcpc,i);
} else if (i < (65536*5)) { } else if (i < (65536*5)) {
adc2d[4][scnumber]->Fill(adcpc,i); adc2d_5[scnumber]->Fill(adcpc,i);
} else if (i < (65536*6)) { } else if (i < (65536*6)) {
adc2d[5][scnumber]->Fill(adcpc,i); adc2d_6[scnumber]->Fill(adcpc,i);
} else if (i < (65536*7)) { } else if (i < (65536*7)) {
adc2d[6][scnumber]->Fill(adcpc,i); adc2d_7[scnumber]->Fill(adcpc,i);
} else if (i < (65536*8)) { } else if (i < (65536*8)) {
adc2d[7][scnumber]->Fill(adcpc,i); adc2d_8[scnumber]->Fill(adcpc,i);
} }
} }
} }
@ -338,11 +367,18 @@ int main(int argc, char* argv[]) {
//sprintf(savename,"/mnt/sls_det_storage/jungfrau_data1/jungfrau_ana_sophie/M%s_CalibAna/CuFluo_%s_file0to%d.root", module_str.c_str(), gain_str.c_str(), filen-1); //sprintf(savename,"/mnt/sls_det_storage/jungfrau_data1/jungfrau_ana_sophie/M%s_CalibAna/CuFluo_%s_file0to%d.root", module_str.c_str(), gain_str.c_str(), filen-1);
sprintf(savename,"%s/CuFluo_%s_file0to%d.root", anadata_loc.c_str(), gain_str.c_str(), filen-1); //uncomment for VH 210906 sprintf(savename,"%s/CuFluo_%s_file0to%d.root", anadata_loc.c_str(), gain_str.c_str(), filen-1); //uncomment for VH 210906
TFile* saved_file = new TFile((const char *)(savename),"RECREATE"); TFile* saved_file = new TFile((const char *)(savename),"RECREATE");
for ( int adci = 0; adci < 8; ++adci ) { //for ( int adci = 0; adci < 8; ++adci ) {
for ( int sci = 0; sci < 16; ++sci ) { for ( int sci = 0; sci < 16; ++sci ) {
adc2d[adci][sci]->Write(); adc2d_1[sci]->Write();
adc2d_2[sci]->Write();
adc2d_3[sci]->Write();
adc2d_4[sci]->Write();
adc2d_5[sci]->Write();
adc2d_6[sci]->Write();
adc2d_7[sci]->Write();
adc2d_8[sci]->Write();
} }
} //}
saved_file->Close(); saved_file->Close();
} // end if i creatHistoFile } // end if i creatHistoFile