CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorMuonSystemMap1D.cc

Go to the documentation of this file.
00001 /*
00002  * Package:     CommonAlignmentProducer
00003  * Class  :     AlignmentMonitorMuonSystemMap1D
00004  *
00005  * Original Author:  Jim Pivarski
00006  *         Created:  Mon Nov 12 13:30:14 CST 2007
00007  *
00008  * $Id: AlignmentMonitorMuonSystemMap1D.cc,v 1.6 2011/10/12 22:59:47 khotilov Exp $
00009  */
00010 
00011 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h"
00012 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h"
00013 #include "Alignment/MuonAlignmentAlgorithms/interface/MuonResidualsFromTrack.h"
00014 
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 #include "FWCore/Utilities/interface/InputTag.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "FWCore/Framework/interface/EventSetup.h"
00019 #include "FWCore/ServiceRegistry/interface/Service.h"
00020 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00021 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00022 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00023 
00024 #include "TH1F.h"
00025 #include "TH2F.h"
00026 
00027 
00028 class AlignmentMonitorMuonSystemMap1D: public AlignmentMonitorBase
00029 {
00030 public:
00031   AlignmentMonitorMuonSystemMap1D(const edm::ParameterSet& cfg);
00032   virtual ~AlignmentMonitorMuonSystemMap1D() {}
00033 
00034   void book();
00035 
00036   void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection& iTrajTracks);
00037   void processMuonResidualsFromTrack(MuonResidualsFromTrack &mrft, const edm::Event &iEvent);
00038 
00039   void afterAlignment(const edm::EventSetup &iSetup);
00040 
00041 private:
00042 
00043   // parameters
00044   edm::InputTag m_muonCollectionTag;
00045   double m_minTrackPt;
00046   double m_maxTrackPt;
00047   double m_minTrackP;
00048   double m_maxTrackP;
00049   double m_maxDxy;
00050   int m_minTrackerHits;
00051   double m_maxTrackerRedChi2;
00052   bool m_allowTIDTEC;
00053   int m_minNCrossedChambers;
00054   int m_minDT13Hits;
00055   int m_minDT2Hits;
00056   int m_minCSCHits;
00057   bool m_doDT;
00058   bool m_doCSC;
00059   bool m_useStubPosition;
00060   bool m_createNtuple;
00061 
00062   // counter
00063   long m_counter_event;
00064   long m_counter_track;
00065   long m_counter_trackmoment;
00066   long m_counter_trackdxy;
00067   long m_counter_trackokay;
00068   long m_counter_dt;
00069   long m_counter_13numhits;
00070   long m_counter_2numhits;
00071   long m_counter_csc;
00072   long m_counter_cscnumhits;
00073 
00074   // histogram helper
00075   class MuonSystemMapPlot1D
00076   {
00077   public:
00078     MuonSystemMapPlot1D(std::string name, AlignmentMonitorMuonSystemMap1D *module, int bins, double low, double high, bool xy, bool add_1d);
00079 
00080     void fill_x_1d(double residx, double chi2, int dof);
00081     void fill_x(char charge, double abscissa, double residx, double chi2, int dof);
00082     void fill_y(char charge, double abscissa, double residy, double chi2, int dof);
00083     void fill_dxdz(char charge, double abscissa, double slopex, double chi2, int dof);
00084     void fill_dydz(char charge, double abscissa, double slopey, double chi2, int dof);
00085 
00086   private:
00087     std::string m_name;
00088     int m_bins;
00089     bool m_xy;
00090     bool m_1d;
00091     TH1F *m_x_1d;
00092     TH2F *m_x_2d, *m_y_2d, *m_dxdz_2d, *m_dydz_2d;
00093   };
00094 
00095   MuonSystemMapPlot1D *m_DTvsz_station[4][14]; // [station][sector]
00096   MuonSystemMapPlot1D *m_CSCvsr_me[2][4][36];  // [endcap][station][chamber]
00097   MuonSystemMapPlot1D *m_DTvsphi_station[4][5];// [station][wheel]
00098   MuonSystemMapPlot1D *m_CSCvsphi_me[2][4][3]; // [endcap][station][ring]
00099 
00100   std::vector<MuonSystemMapPlot1D*> m_plots;
00101 
00102   std::string num02d(int num);
00103 
00104   // optional debug ntuple
00105   TTree *m_cscnt;
00106 
00107   struct MyCSCDetId
00108   {
00109     void init(CSCDetId &id)
00110     {
00111       e = id.endcap();
00112       s = id.station();
00113       r = id.ring();
00114       c = id.chamber();
00115       t = id.iChamberType();
00116     }
00117     Short_t e, s, r, c;
00118     Short_t t; // type 1-10: ME1/a,1/b,1/2,1/3,2/1...4/2
00119   };
00120   MyCSCDetId m_id;
00121 
00122   struct MyTrack
00123   {
00124     Int_t q;
00125     Float_t pt, pz;
00126   };
00127   MyTrack m_tr;
00128 
00129   struct MyResidual
00130   {
00131     Float_t res, slope, rho, phi, z;
00132   };
00133   MyResidual m_re;
00134 
00135   UInt_t m_run;
00136 };
00137 
00138 
00139 
00140 AlignmentMonitorMuonSystemMap1D::AlignmentMonitorMuonSystemMap1D(const edm::ParameterSet& cfg)
00141    : AlignmentMonitorBase(cfg, "AlignmentMonitorMuonSystemMap1D")
00142    , m_muonCollectionTag(cfg.getParameter<edm::InputTag>("muonCollectionTag"))
00143    , m_minTrackPt(cfg.getParameter<double>("minTrackPt"))
00144    , m_maxTrackPt(cfg.getParameter<double>("maxTrackPt"))
00145    , m_minTrackP(cfg.getParameter<double>("minTrackP"))
00146    , m_maxTrackP(cfg.getParameter<double>("maxTrackP"))
00147    , m_maxDxy(cfg.getParameter<double>("maxDxy"))
00148    , m_minTrackerHits(cfg.getParameter<int>("minTrackerHits"))
00149    , m_maxTrackerRedChi2(cfg.getParameter<double>("maxTrackerRedChi2"))
00150    , m_allowTIDTEC(cfg.getParameter<bool>("allowTIDTEC"))
00151    , m_minNCrossedChambers(cfg.getParameter<int>("minNCrossedChambers"))
00152    , m_minDT13Hits(cfg.getParameter<int>("minDT13Hits"))
00153    , m_minDT2Hits(cfg.getParameter<int>("minDT2Hits"))
00154    , m_minCSCHits(cfg.getParameter<int>("minCSCHits"))
00155    , m_doDT(cfg.getParameter<bool>("doDT"))
00156    , m_doCSC(cfg.getParameter<bool>("doCSC"))
00157    , m_useStubPosition(cfg.getParameter<bool>("useStubPosition"))
00158    , m_createNtuple(cfg.getParameter<bool>("createNtuple"))
00159 {
00160   if (m_createNtuple)
00161   {
00162     edm::Service<TFileService> fs;
00163     m_cscnt = fs->make<TTree>("mualNtuple", "mualNtuple");
00164     m_cscnt->Branch("id", &m_id.e,"e/S:s:r:c:t");
00165     m_cscnt->Branch("tr", &m_tr.q,"q/I:pt/F:pz");
00166     m_cscnt->Branch("re", &m_re.res, "res/F:slope:rho:phi:z");
00167     m_cscnt->Branch("run", &m_run, "run/i");
00168   }
00169 }
00170 
00171 
00172 std::string AlignmentMonitorMuonSystemMap1D::num02d(int num)
00173 {
00174   assert(num>=0 && num <100);
00175   char tmp[4];
00176   sprintf(tmp, "%02d", num);
00177   return std::string(tmp);
00178 }
00179 
00180 
00181 void AlignmentMonitorMuonSystemMap1D::book()
00182 {
00183   std::string wheel_label[5]={"A","B","C","D","E"};
00184 
00185   for (int station = 1; station<=4; station++)
00186   {
00187     char c_station[4];
00188     sprintf(c_station, "%d", station);
00189     std::string s_station(c_station);
00190     
00191     bool do_y = true;
00192     if (station==4) do_y = false;
00193 
00194     // *** DT ***
00195     if (m_doDT) for (int sector = 1;  sector <= 14;  sector++)
00196     {
00197       if ((station<4 && sector <= 12) || station==4)
00198       {
00199         m_DTvsz_station[station-1][sector-1] = 
00200           new MuonSystemMapPlot1D("DTvsz_st" + s_station + "sec" + num02d(sector), this, 60, -660., 660., do_y,false);
00201         m_plots.push_back(m_DTvsz_station[station-1][sector-1]);
00202       }
00203     }
00204 
00205     if (m_doDT) for (int wheel = -2;  wheel <= 2;  wheel++)
00206     {
00207       m_DTvsphi_station[station-1][wheel+2] = 
00208         new MuonSystemMapPlot1D("DTvsphi_st" + s_station + "wh" + wheel_label[wheel+2], this, 180, -M_PI, M_PI, do_y, false);
00209       m_plots.push_back(m_DTvsphi_station[station-1][wheel+2]);
00210     }
00211 
00212     // *** CSC ***
00213     if (m_doCSC) for (int endcap = 1;  endcap <= 2;  endcap++)
00214     {
00215       std::string s_endcap("m");
00216       if (endcap == 1) s_endcap = "p";
00217 
00218       for (int chamber = 1;  chamber <= 36;  chamber++)
00219       {
00220         m_CSCvsr_me[endcap-1][station-1][chamber-1] =
00221           new MuonSystemMapPlot1D("CSCvsr_me" + s_endcap + s_station +"ch" + num02d(chamber), this, 60, 100., 700., false, false);
00222         m_plots.push_back(m_CSCvsr_me[endcap-1][station-1][chamber-1]);
00223       }
00224       
00225       for (int ring = 1; ring <= 3; ring++) // the ME1/a (ring4) is not independent from ME1/b (ring1)
00226       {
00227         char c_ring[4];
00228         sprintf(c_ring, "%d", ring);
00229         std::string s_ring(c_ring);
00230         if ( (station>1 && ring<=2) || station==1)
00231         {
00232           m_CSCvsphi_me[endcap-1][station-1][ring-1] = 
00233             new MuonSystemMapPlot1D("CSCvsphi_me" + s_endcap + s_station + s_ring, this, 180, -M_PI/180.*5., M_PI*(2.-5./180.), false, true);
00234           m_plots.push_back(m_CSCvsphi_me[endcap-1][station-1][ring-1]);
00235         }
00236       }
00237     } // endcaps
00238   } // stations
00239 
00240   m_counter_event = 0;
00241   m_counter_track = 0;
00242   m_counter_trackmoment = 0;
00243   m_counter_trackdxy = 0;
00244   m_counter_trackokay = 0;
00245   m_counter_dt = 0;
00246   m_counter_13numhits = 0;
00247   m_counter_2numhits = 0;
00248   m_counter_csc = 0;
00249   m_counter_cscnumhits = 0;
00250 }
00251 
00252 
00253 void AlignmentMonitorMuonSystemMap1D::event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection& trajtracks)
00254 {
00255   m_counter_event++;
00256 
00257   edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
00258   iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
00259 
00260   edm::Handle<reco::BeamSpot> beamSpot;
00261   iEvent.getByLabel(m_beamSpotTag, beamSpot);
00262 
00263   if (m_muonCollectionTag.label().empty()) // use trajectories
00264   {
00265     for (ConstTrajTrackPairCollection::const_iterator trajtrack = trajtracks.begin();  trajtrack != trajtracks.end();  ++trajtrack)
00266     {
00267       m_counter_track++;
00268       const Trajectory* traj = (*trajtrack).first;
00269       const reco::Track* track = (*trajtrack).second;
00270 
00271       if (m_minTrackPt < track->pt()  &&  track->pt() < m_maxTrackPt && m_minTrackP < track->p()  &&  track->p() < m_maxTrackP)
00272       {
00273         m_counter_trackmoment++;
00274         if ( fabs(track->dxy(beamSpot->position())) < m_maxDxy )
00275         {
00276           m_counter_trackdxy++;
00277 
00278           MuonResidualsFromTrack muonResidualsFromTrack(globalGeometry, traj, track, pNavigator(), 1000.);
00279           processMuonResidualsFromTrack(muonResidualsFromTrack, iEvent);
00280         }
00281       } // end if track has acceptable momentum
00282     } // end loop over tracks
00283   }
00284   else
00285   {
00286     edm::Handle<reco::MuonCollection> muons;
00287     iEvent.getByLabel(m_muonCollectionTag, muons);
00288 
00289     for (reco::MuonCollection::const_iterator muon = muons->begin();  muon != muons->end();  ++muon)
00290     {
00291       if ( !(muon->isTrackerMuon() && muon->innerTrack().isNonnull() ) ) continue;
00292 
00293       m_counter_track++;
00294 
00295       if (m_minTrackPt < muon->pt()  &&  muon->pt() < m_maxTrackPt && m_minTrackP < muon->p()  &&  muon->p() < m_maxTrackP )
00296       {
00297         m_counter_trackmoment++;
00298         if (fabs(muon->innerTrack()->dxy(beamSpot->position())) < m_maxDxy)
00299         {
00300           m_counter_trackdxy++;
00301 
00302           MuonResidualsFromTrack muonResidualsFromTrack(globalGeometry, &(*muon), pNavigator(), 100.);
00303           processMuonResidualsFromTrack(muonResidualsFromTrack, iEvent);
00304         }
00305       }
00306     }
00307   }
00308 }
00309 
00310 
00311 void AlignmentMonitorMuonSystemMap1D::processMuonResidualsFromTrack(MuonResidualsFromTrack &mrft, const edm::Event &iEvent)
00312 {
00313   if (mrft.trackerNumHits() < m_minTrackerHits) return;
00314   if (!m_allowTIDTEC  && mrft.contains_TIDTEC()) return;
00315   if (mrft.normalizedChi2() > m_maxTrackerRedChi2) return;
00316 
00317   int nMuChambers = 0;
00318   std::vector<DetId> chamberIds = mrft.chamberIds();
00319   for (unsigned ch=0; ch < chamberIds.size(); ch++)  if (chamberIds[ch].det() == DetId::Muon)  nMuChambers++;
00320   if (nMuChambers < m_minNCrossedChambers ) return;
00321 
00322   char charge = (mrft.getTrack()->charge() > 0 ? 1 : -1);
00323   // double qoverpt = track->charge() / track->pt();
00324   // double qoverpz = track->charge() / track->pz();
00325 
00326   m_counter_trackokay++;
00327 
00328   for (std::vector<DetId>::const_iterator chamberId = chamberIds.begin();  chamberId != chamberIds.end();  ++chamberId)
00329   {
00330     if (chamberId->det() != DetId::Muon  ) continue;
00331 
00332     if (m_doDT  &&  chamberId->subdetId() == MuonSubdetId::DT)
00333     {
00334       MuonChamberResidual *dt13 = mrft.chamberResidual(*chamberId, MuonChamberResidual::kDT13);
00335       MuonChamberResidual *dt2 = mrft.chamberResidual(*chamberId, MuonChamberResidual::kDT2);
00336       DTChamberId id(chamberId->rawId());
00337 
00338       m_counter_dt++;
00339 
00340       if (id.station() < 4 && dt13 != NULL  &&  dt13->numHits() >= m_minDT13Hits && dt2 != NULL  &&  dt2->numHits() >= m_minDT2Hits)
00341       {
00342         m_counter_13numhits++;
00343 
00344         double residual = dt13->global_residual();
00345         double resslope = dt13->global_resslope();
00346         double chi2 = dt13->chi2();
00347         int dof = dt13->ndof();
00348 
00349         align::GlobalPoint gpos;
00350         if (m_useStubPosition) gpos = dt13->global_stubpos();
00351         else gpos = dt13->global_trackpos();
00352         double phi = atan2(gpos.y(), gpos.x());
00353         double z = gpos.z();
00354 
00355         assert(1 <= id.sector()  &&  id.sector() <= 14);
00356 
00357         m_DTvsz_station[id.station()-1][id.sector()-1]->fill_x(charge, z, residual, chi2, dof);
00358         m_DTvsz_station[id.station()-1][id.sector()-1]->fill_dxdz(charge, z, resslope, chi2, dof);
00359         m_DTvsphi_station[id.station()-1][id.wheel()+2]->fill_x(charge, phi, residual, chi2, dof);
00360         m_DTvsphi_station[id.station()-1][id.wheel()+2]->fill_dxdz(charge, phi, resslope, chi2, dof);
00361 
00362         m_counter_2numhits++;
00363 
00364         residual = dt2->global_residual();
00365         resslope = dt2->global_resslope();
00366         chi2 = dt2->chi2();
00367         dof = dt2->ndof();
00368 
00369         if (m_useStubPosition) gpos = dt2->global_stubpos();
00370         else gpos = dt2->global_trackpos();
00371         phi = atan2(gpos.y(), gpos.x());
00372         z = gpos.z();
00373 
00374         assert(1 <= id.sector()  &&  id.sector() <= 14);
00375 
00376         m_DTvsz_station[id.station()-1][id.sector()-1]->fill_y(charge, z, residual, chi2, dof);
00377         m_DTvsz_station[id.station()-1][id.sector()-1]->fill_dydz(charge, z, resslope, chi2, dof);
00378         m_DTvsphi_station[id.station()-1][id.wheel()+2]->fill_y(charge, phi, residual, chi2, dof);
00379         m_DTvsphi_station[id.station()-1][id.wheel()+2]->fill_dydz(charge, phi, resslope, chi2, dof);
00380       }
00381 
00382       if (id.station() == 4 && dt13 != NULL  &&  dt13->numHits() >= m_minDT13Hits)
00383       {
00384         m_counter_13numhits++;
00385 
00386         double residual = dt13->global_residual();
00387         double resslope = dt13->global_resslope();
00388         double chi2 = dt13->chi2();
00389         int dof = dt13->ndof();
00390 
00391         align::GlobalPoint gpos;
00392         if (m_useStubPosition) gpos = dt13->global_stubpos();
00393         else gpos = dt13->global_trackpos();
00394         double phi = atan2(gpos.y(), gpos.x());
00395         double z = gpos.z();
00396 
00397         assert(1 <= id.sector()  &&  id.sector() <= 14);
00398 
00399         m_DTvsz_station[id.station()-1][id.sector()-1]->fill_x(charge, z, residual, chi2, dof);
00400         m_DTvsz_station[id.station()-1][id.sector()-1]->fill_dxdz(charge, z, resslope, chi2, dof);
00401         m_DTvsphi_station[id.station()-1][id.wheel()+2]->fill_x(charge, phi, residual, chi2, dof);
00402         m_DTvsphi_station[id.station()-1][id.wheel()+2]->fill_dxdz(charge, phi, resslope, chi2, dof);
00403       }
00404     }
00405 
00406     else if (m_doCSC  &&  chamberId->subdetId() == MuonSubdetId::CSC)
00407     {
00408       MuonChamberResidual *csc = mrft.chamberResidual(*chamberId, MuonChamberResidual::kCSC);
00409       CSCDetId id(chamberId->rawId());
00410 
00411       int ring = id.ring();
00412       if (id.ring()==4) ring = 1; // combine ME1/a + ME1/b
00413 
00414       m_counter_csc++;
00415 
00416       if (csc != NULL  &&  csc->numHits() >= m_minCSCHits)
00417       {
00418         m_counter_cscnumhits++;
00419 
00420         double residual = csc->global_residual();
00421         double resslope = csc->global_resslope();
00422         double chi2 = csc->chi2();
00423         int dof = csc->ndof();
00424 
00425         align::GlobalPoint gpos;
00426         if (m_useStubPosition) gpos = csc->global_stubpos();
00427         else gpos = csc->global_trackpos();
00428         double phi = atan2(gpos.y(), gpos.x());
00429         // start phi from -5deg
00430         if (phi<-M_PI/180.*5.) phi += 2.*M_PI;
00431         double R = sqrt(pow(gpos.x(), 2) + pow(gpos.y(), 2));
00432 
00433         int chamber = id.chamber() - 1;
00434         if (id.station() > 1  &&  ring == 1) chamber *= 2;
00435 
00436         assert(1 <= id.endcap()  &&  id.endcap() <= 2  &&  0 <= chamber  &&  chamber <= 35);
00437 
00438         if (R>0.) m_CSCvsphi_me[id.endcap()-1][id.station()-1][ring-1]->fill_x_1d(residual/R, chi2, dof);
00439 
00440         m_CSCvsr_me[id.endcap()-1][id.station()-1][chamber]->fill_x(charge, R, residual, chi2, dof);
00441         m_CSCvsr_me[id.endcap()-1][id.station()-1][chamber]->fill_dxdz(charge, R, resslope, chi2, dof);
00442         m_CSCvsphi_me[id.endcap()-1][id.station()-1][ring-1]->fill_x(charge, phi, residual, chi2, dof);
00443         m_CSCvsphi_me[id.endcap()-1][id.station()-1][ring-1]->fill_dxdz(charge, phi, resslope, chi2, dof);
00444 
00445         if (m_createNtuple && chi2 > 0.)//  &&  TMath::Prob(chi2, dof) < 0.95)
00446         {
00447           m_id.init(id);
00448           m_tr.q = charge;
00449           m_tr.pt = mrft.getTrack()->pt();
00450           m_tr.pz = mrft.getTrack()->pz();
00451           m_re.res = residual;
00452           m_re.slope = resslope;
00453           m_re.rho = R;
00454           m_re.phi = phi;
00455           m_re.z = gpos.z();
00456           m_run = iEvent.id().run();
00457           m_cscnt->Fill();
00458         }
00459 
00460       }
00461     }
00462 
00463     //else { assert(false); }
00464   } // end loop over chambers
00465 }
00466 
00467 
00468 void AlignmentMonitorMuonSystemMap1D::afterAlignment(const edm::EventSetup &iSetup)
00469 {
00470   std::cout << "AlignmentMonitorMuonSystemMap1D counters:"<<std::endl;
00471   std::cout << " monitor m_counter_event      = " << m_counter_event << std::endl;
00472   std::cout << " monitor m_counter_track      = " << m_counter_track << std::endl;
00473   std::cout << " monitor m_counter_trackppt   = " << m_counter_trackmoment << std::endl;
00474   std::cout << " monitor m_counter_trackdxy   = " << m_counter_trackdxy  << std::endl;
00475   std::cout << " monitor m_counter_trackokay  = " << m_counter_trackokay << std::endl;
00476   std::cout << " monitor m_counter_dt         = " << m_counter_dt << std::endl;
00477   std::cout << " monitor m_counter_13numhits  = " << m_counter_13numhits << std::endl;
00478   std::cout << " monitor m_counter_2numhits   = " << m_counter_2numhits << std::endl;
00479   std::cout << " monitor m_counter_csc        = " << m_counter_csc << std::endl;
00480   std::cout << " monitor m_counter_cscnumhits = " << m_counter_cscnumhits << std::endl;
00481 }
00482 
00483 
00484 AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D::MuonSystemMapPlot1D(std::string name, AlignmentMonitorMuonSystemMap1D *module, int bins, double low, double high, bool xy, bool add_1d)
00485    : m_name(name), m_bins(bins), m_xy(xy), m_1d(add_1d)
00486 {
00487   m_x_2d = m_y_2d = m_dxdz_2d = m_dydz_2d = NULL;
00488   std::stringstream name_x_2d, name_y_2d, name_dxdz_2d, name_dydz_2d;
00489   name_x_2d << m_name << "_x_2d";
00490   name_y_2d << m_name << "_y_2d";
00491   name_dxdz_2d << m_name << "_dxdz_2d";
00492   name_dydz_2d << m_name << "_dydz_2d";
00493 
00494   const int nbins = 200;
00495   const double window = 100.;
00496 
00497   m_x_2d = module->book2D("/iterN/", name_x_2d.str().c_str(), "", m_bins, low, high, nbins, -window, window);
00498   if (m_xy) m_y_2d = module->book2D("/iterN/", name_y_2d.str().c_str(), "", m_bins, low, high, nbins, -window, window);
00499   m_dxdz_2d = module->book2D("/iterN/", name_dxdz_2d.str().c_str(), "", m_bins, low, high, nbins, -window, window);
00500   if (m_xy) m_dydz_2d = module->book2D("/iterN/", name_dydz_2d.str().c_str(), "", m_bins, low, high, nbins, -window, window);
00501 
00502   m_x_1d = NULL;
00503   if (m_1d) {
00504     std::stringstream name_x_1d;//, name_y_1d, name_dxdz_1d, name_dydz_1d;
00505     name_x_1d << m_name << "_x_1d";
00506     m_x_1d = module->book1D("/iterN/", name_x_1d.str().c_str(), "", nbins, -window, window);
00507   }
00508 }
00509 
00510 
00511 void AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D::fill_x_1d(double residx, double chi2, int dof)
00512 {
00513   if (m_1d && chi2 > 0.) {
00514     // assume that residx was in radians
00515     double residual = residx * 1000.;
00516     m_x_1d->Fill(residual);
00517   }
00518 }
00519 
00520 
00521 void AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D::fill_x(char charge, double abscissa, double residx, double chi2, int dof)
00522 {
00523   if (chi2 > 0.) {
00524     double residual = residx * 10.;
00525     //double weight = dof / chi2;
00526     m_x_2d->Fill(abscissa, residual);
00527   }
00528 }
00529 
00530 
00531 void AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D::fill_y(char charge, double abscissa, double residy, double chi2, int dof)
00532 {
00533   if (m_xy  &&  chi2 > 0.) {
00534     double residual = residy * 10.;
00535     //double weight = dof / chi2;
00536     m_y_2d->Fill(abscissa, residual);
00537   }
00538 }
00539 
00540 
00541 void AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D::fill_dxdz(char charge, double abscissa, double slopex, double chi2, int dof)
00542 {
00543   if (chi2 > 0.) {
00544     double residual = slopex * 1000.;
00545     //double weight = dof / chi2;
00546     m_dxdz_2d->Fill(abscissa, residual);
00547   }
00548 }
00549 
00550 
00551 void AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D::fill_dydz(char charge, double abscissa, double slopey, double chi2, int dof)
00552 {
00553   if (m_xy  &&  chi2 > 0.) {
00554     double residual = slopey * 1000.;
00555     //double weight = dof / chi2;
00556     m_dydz_2d->Fill(abscissa, residual);
00557   }
00558 }
00559 
00560 
00561 DEFINE_EDM_PLUGIN(AlignmentMonitorPluginFactory, AlignmentMonitorMuonSystemMap1D, "AlignmentMonitorMuonSystemMap1D");